swap graph serialization over to node conversion functions

portability/boost
zetaPRIME 2019-01-22 15:52:48 -05:00
parent c74f312d2c
commit 9d3c06aef0
1 changed files with 2 additions and 19 deletions

View File

@ -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<int>(chm.value("x").toInteger());
ch->y = static_cast<int>(chm.value("y").toInteger());
ch->loadData(chm);
}
for (auto chmv : c) Node::fromCbor(chmv, g); // oh, that's it?
}
{ /* connections */ } {