aboutsummaryrefslogtreecommitdiff
path: root/src/identitycollection.cpp
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-28 16:30:52 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-28 16:30:52 +0200
commit6edd9e7a12a3827fb6aac62a88be01085e41e176 (patch)
tree4513475c7efaea92a154ff20e970ed3d4b475b7c /src/identitycollection.cpp
parenta53e490d2e96d22a24293019921af26e00f2bf7a (diff)
downloadkristall-6edd9e7a12a3827fb6aac62a88be01085e41e176.tar.gz
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.
Diffstat (limited to 'src/identitycollection.cpp')
-rw-r--r--src/identitycollection.cpp63
1 files changed, 63 insertions, 0 deletions
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<GroupNode>();
+ auto dst_group = std::make_unique<GroupNode>();
+
+ dst_group->title = src_group.title;
+
+ for(auto const & id : src_group.children) {
+ auto const & src_id = id->as<IdentityNode>();
+ auto dst_id = std::make_unique<IdentityNode>();
+
+ 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<GroupNode>();
+ auto dst_group = std::make_unique<GroupNode>();
+
+ dst_group->title = src_group.title;
+
+ for(auto const & id : src_group.children) {
+ auto const & src_id = id->as<IdentityNode>();
+ auto dst_id = std::make_unique<IdentityNode>();
+
+ 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();