move xmlnodedata to serializers

Since this differs between serializers too, move the class into each with changes as appropriate
This commit is contained in:
itsmattkc
2022-01-22 21:09:36 -08:00
parent 83fad2a438
commit 8f8d43f634
9 changed files with 88 additions and 40 deletions
@@ -40,7 +40,7 @@ ProjectSerializer210528::LoadData ProjectSerializer210528::Load(Project *project
// can continue loading and queue it with the main window so it can handle the data
// appropriately in its own thread.
project->SetLayoutInfo(MainWindowLayoutInfo::fromXml(reader, xml_node_data));
project->SetLayoutInfo(MainWindowLayoutInfo::fromXml(reader, xml_node_data.node_ptrs));
} else if (reader->name() == QStringLiteral("uuid")) {
@@ -39,6 +39,33 @@ protected:
}
private:
struct XMLNodeData {
struct SerializedConnection {
NodeInput input;
quintptr output_node;
QString output_param;
};
struct BlockLink {
Node* block;
quintptr link;
};
struct GroupLink {
NodeGroup *group;
quintptr input_node;
QString input_id;
int input_element;
};
QHash<quintptr, Node*> node_ptrs;
QList<SerializedConnection> desired_connections;
QList<BlockLink> block_links;
QVector<GroupLink> group_input_links;
QHash<NodeGroup*, quintptr> group_output_links;
};
void LoadNode(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const;
void LoadInput(Node *node, QXmlStreamReader* reader, XMLNodeData &xml_node_data) const;
@@ -40,7 +40,7 @@ ProjectSerializer210907::LoadData ProjectSerializer210907::Load(Project *project
// can continue loading and queue it with the main window so it can handle the data
// appropriately in its own thread.
project->SetLayoutInfo(MainWindowLayoutInfo::fromXml(reader, xml_node_data));
project->SetLayoutInfo(MainWindowLayoutInfo::fromXml(reader, xml_node_data.node_ptrs));
} else if (reader->name() == QStringLiteral("uuid")) {
@@ -219,7 +219,7 @@ void ProjectSerializer210907::LoadNode(Node *node, XMLNodeData &xml_node_data, Q
}
}
xml_node_data.desired_connections.append({NodeInput(node, param_id, ele), output_node_id.toULongLong(), QString()});
xml_node_data.desired_connections.append({NodeInput(node, param_id, ele), output_node_id.toULongLong()});
} else {
reader->skipCurrentElement();
}
@@ -39,6 +39,32 @@ protected:
}
private:
struct XMLNodeData {
struct SerializedConnection {
NodeInput input;
quintptr output_node;
};
struct BlockLink {
Node* block;
quintptr link;
};
struct GroupLink {
NodeGroup *group;
quintptr input_node;
QString input_id;
int input_element;
};
QHash<quintptr, Node*> node_ptrs;
QList<SerializedConnection> desired_connections;
QList<BlockLink> block_links;
QVector<GroupLink> group_input_links;
QHash<NodeGroup*, quintptr> group_output_links;
};
void LoadNode(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const;
void LoadInput(Node *node, QXmlStreamReader* reader, XMLNodeData &xml_node_data) const;
@@ -42,7 +42,7 @@ ProjectSerializer211228::LoadData ProjectSerializer211228::Load(Project *project
// can continue loading and queue it with the main window so it can handle the data
// appropriately in its own thread.
project->SetLayoutInfo(MainWindowLayoutInfo::fromXml(reader, xml_node_data));
project->SetLayoutInfo(MainWindowLayoutInfo::fromXml(reader, xml_node_data.node_ptrs));
} else if (reader->name() == QStringLiteral("uuid")) {
@@ -341,7 +341,7 @@ void ProjectSerializer211228::LoadNode(Node *node, XMLNodeData &xml_node_data, Q
}
}
xml_node_data.desired_connections.append({NodeInput(node, param_id, ele), output_node_id.toULongLong(), QString()});
xml_node_data.desired_connections.append({NodeInput(node, param_id, ele), output_node_id.toULongLong()});
} else {
reader->skipCurrentElement();
}
@@ -41,6 +41,32 @@ protected:
}
private:
struct XMLNodeData {
struct SerializedConnection {
NodeInput input;
quintptr output_node;
};
struct BlockLink {
Node* block;
quintptr link;
};
struct GroupLink {
NodeGroup *group;
quintptr input_node;
QString input_id;
int input_element;
};
QHash<quintptr, Node*> node_ptrs;
QList<SerializedConnection> desired_connections;
QList<BlockLink> block_links;
QVector<GroupLink> group_input_links;
QHash<NodeGroup*, quintptr> group_output_links;
};
void LoadNode(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const;
void SaveNode(Node *node, QXmlStreamWriter *writer) const;