From 9d3c06aef0f89f9b1e10182a6db23861d53492ef Mon Sep 17 00:00:00 2001 From: zetaPRIME Date: Tue, 22 Jan 2019 15:52:48 -0500 Subject: [PATCH] swap graph serialization over to node conversion functions --- xybrid/data/graph.cpp | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/xybrid/data/graph.cpp b/xybrid/data/graph.cpp index 962eaf2..eedd9ed 100644 --- a/xybrid/data/graph.cpp +++ b/xybrid/data/graph.cpp @@ -48,15 +48,7 @@ void Graph::saveData(QCborMap& m) const { for (auto ch : children) { if (!ch->plugin) continue; indices[ch.get()] = idx++; - QCborMap chm; - - chm.insert(QString("id"), QString::fromStdString(ch->plugin->id)); - if (!ch->name.empty()) chm.insert(QString("name"), QString::fromStdString(ch->name)); - chm.insert(QString("x"), ch->x); - chm.insert(QString("y"), ch->y); - ch->saveData(chm); - - c << chm; + c << ch->toCbor(); } m.insert(QString("children"), c); @@ -101,16 +93,7 @@ void Graph::loadData(const QCborMap& m) { { /* children */ } { QCborArray c = m.value("children").toArray(); - - for (auto chmv : c) { - auto chm = chmv.toMap(); - auto ch = PluginRegistry::createInstance(chm.value("id").toString().toStdString()); - ch->parentTo(g); - ch->name = chm.value("name").toString().toStdString(); - ch->x = static_cast(chm.value("x").toInteger()); - ch->y = static_cast(chm.value("y").toInteger()); - ch->loadData(chm); - } + for (auto chmv : c) Node::fromCbor(chmv, g); // oh, that's it? } { /* connections */ } {