From 6edd9e7a12a3827fb6aac62a88be01085e41e176 Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Sun, 28 Jun 2020 16:30:52 +0200 Subject: Huge refacoring of the settings stuff. Provides automated migration between old and new configuration file stuff. Themes are now just files in a folder instead of encoded data in the config file. --- src/identitycollection.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'src/identitycollection.cpp') diff --git a/src/identitycollection.cpp b/src/identitycollection.cpp index e839996..d68ab11 100644 --- a/src/identitycollection.cpp +++ b/src/identitycollection.cpp @@ -13,6 +13,69 @@ IdentityCollection::IdentityCollection(QObject *parent) } +IdentityCollection::IdentityCollection(const IdentityCollection &other) +{ + for(auto const & grp : other.root.children) + { + auto const & src_group = grp->as(); + auto dst_group = std::make_unique(); + + dst_group->title = src_group.title; + + for(auto const & id : src_group.children) { + auto const & src_id = id->as(); + auto dst_id = std::make_unique(); + + dst_id->identity = src_id.identity; + + dst_group->children.emplace_back(std::move(dst_id)); + } + + root.children.emplace_back(std::move(dst_group)); + } + + + relayout(); +} + +IdentityCollection &IdentityCollection::operator=(const IdentityCollection & other) +{ + beginResetModel(); + + root.children.clear(); + for(auto const & grp : other.root.children) + { + auto const & src_group = grp->as(); + auto dst_group = std::make_unique(); + + dst_group->title = src_group.title; + + for(auto const & id : src_group.children) { + auto const & src_id = id->as(); + auto dst_id = std::make_unique(); + + dst_id->identity = src_id.identity; + + dst_group->children.emplace_back(std::move(dst_id)); + } + + root.children.emplace_back(std::move(dst_group)); + } + + this->relayout(); + endResetModel(); + return *this; +} + +IdentityCollection &IdentityCollection::operator=(IdentityCollection && other) +{ + beginResetModel(); + this->root.children = std::move(other.root.children); + this->relayout(); + endResetModel(); + return *this; +} + void IdentityCollection::load(QSettings &settings) { this->beginResetModel(); -- cgit v1.2.3