moved serialization

This commit is contained in:
itsmattkc
2023-02-21 14:26:34 -08:00
parent 85a8fbf1fd
commit 028651f9fb
31 changed files with 1203 additions and 1443 deletions
+28
View File
@@ -404,6 +404,34 @@ QVariant Footage::data(const DataType &d) const
return super::data(d);
}
bool Footage::LoadCustom(QXmlStreamReader *reader, SerializedData *data)
{
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("timestamp")) {
this->set_timestamp(reader->readElementText().toLongLong());
} else if (reader->name() == QStringLiteral("viewer")) {
if (!ViewerOutput::LoadCustom(reader, data)) {
return false;
}
} else {
reader->skipCurrentElement();
}
}
return true;
}
void Footage::SaveCustom(QXmlStreamWriter *writer) const
{
writer->writeTextElement(QStringLiteral("timestamp"), QString::number(this->timestamp()));
writer->writeStartElement(QStringLiteral("viewer"));
ViewerOutput::SaveCustom(writer);
writer->writeEndElement(); // viewer
}
void Footage::UpdateTooltip()
{
if (valid_) {
+3
View File
@@ -173,6 +173,9 @@ public:
virtual int GetTotalStreamCount() const override { return total_stream_count_; }
virtual bool LoadCustom(QXmlStreamReader *reader, SerializedData *data) override;
virtual void SaveCustom(QXmlStreamWriter *writer) const override;
static const QString kFilenameInput;
protected:
@@ -31,16 +31,7 @@ ProjectSerializer210528::LoadData ProjectSerializer210528::Load(Project *project
XMLNodeData xml_node_data;
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("layout")) {
// Since the main window's functions have to occur in the GUI thread (and we're likely
// loading in a secondary thread), we load all necessary data into a separate struct so we
// 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.node_ptrs));
} else if (reader->name() == QStringLiteral("uuid")) {
if (reader->name() == QStringLiteral("uuid")) {
project->SetUuid(QUuid::fromString(reader->readElementText()));
@@ -31,16 +31,7 @@ ProjectSerializer210907::LoadData ProjectSerializer210907::Load(Project *project
XMLNodeData xml_node_data;
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("layout")) {
// Since the main window's functions have to occur in the GUI thread (and we're likely
// loading in a secondary thread), we load all necessary data into a separate struct so we
// 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.node_ptrs));
} else if (reader->name() == QStringLiteral("uuid")) {
if (reader->name() == QStringLiteral("uuid")) {
project->SetUuid(QUuid::fromString(reader->readElementText()));
@@ -33,16 +33,7 @@ ProjectSerializer211228::LoadData ProjectSerializer211228::Load(Project *project
XMLNodeData xml_node_data;
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("layout")) {
// Since the main window's functions have to occur in the GUI thread (and we're likely
// loading in a secondary thread), we load all necessary data into a separate struct so we
// 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.node_ptrs));
} else if (reader->name() == QStringLiteral("uuid")) {
if (reader->name() == QStringLiteral("uuid")) {
project->SetUuid(QUuid::fromString(reader->readElementText()));
@@ -35,16 +35,7 @@ ProjectSerializer220403::LoadData ProjectSerializer220403::Load(Project *project
LoadData load_data;
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("layout")) {
// Since the main window's functions have to occur in the GUI thread (and we're likely
// loading in a secondary thread), we load all necessary data into a separate struct so we
// 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.node_ptrs));
} else if (reader->name() == QStringLiteral("uuid")) {
if (reader->name() == QStringLiteral("uuid")) {
project->SetUuid(QUuid::fromString(reader->readElementText()));
File diff suppressed because it is too large Load Diff
@@ -40,86 +40,6 @@ protected:
return 230220;
}
private:
struct XMLNodeData {
struct SerializedConnection {
NodeInput input;
quintptr output_node;
};
struct BlockLink {
Node* block;
quintptr link;
};
struct GroupLink {
NodeGroup *group;
QString passthrough_id;
quintptr input_node;
QString input_id;
int input_element;
QString custom_name;
InputFlags custom_flags;
NodeValue::Type data_type;
QVariant default_val;
QHash<QString, QVariant> custom_properties;
};
QHash<quintptr, Node*> node_ptrs;
QList<SerializedConnection> desired_connections;
QList<BlockLink> block_links;
QVector<GroupLink> group_input_links;
QHash<NodeGroup*, quintptr> group_output_links;
QHash<Node*, QUuid> node_uuids;
};
void LoadNode(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const;
void SaveNode(Node *node, QXmlStreamWriter *writer) const;
void LoadInput(Node *node, QXmlStreamReader* reader, XMLNodeData &xml_node_data) const;
void SaveInput(Node *node, QXmlStreamWriter* writer, const QString& id) const;
void LoadImmediate(QXmlStreamReader *reader, Node *node, const QString& input, int element, XMLNodeData& xml_node_data) const;
void SaveImmediate(QXmlStreamWriter *writer, Node *node, const QString &input, int element) const;
void LoadKeyframe(QXmlStreamReader *reader, NodeKeyframe *key, NodeValue::Type data_type) const;
void SaveKeyframe(QXmlStreamWriter *writer, NodeKeyframe *key, NodeValue::Type data_type) const;
bool LoadPosition(QXmlStreamReader *reader, quintptr *node_ptr, Node::Position *pos) const;
void SavePosition(QXmlStreamWriter *writer, Node *node, const Node::Position &pos) const;
void PostConnect(const XMLNodeData &xml_node_data) const;
void LoadNodeCustom(QXmlStreamReader *reader, Node *node, XMLNodeData &xml_node_data) const;
void SaveNodeCustom(QXmlStreamWriter *writer, Node *node) const;
void LoadTimelinePoints(QXmlStreamReader *reader, ViewerOutput *viewer) const;
void SaveTimelinePoints(QXmlStreamWriter *writer, ViewerOutput *viewer) const;
void LoadMarker(QXmlStreamReader *reader, TimelineMarker *marker) const;
void SaveMarker(QXmlStreamWriter *writer, TimelineMarker *marker) const;
void LoadWorkArea(QXmlStreamReader *reader, TimelineWorkArea *workarea) const;
void SaveWorkArea(QXmlStreamWriter *writer, TimelineWorkArea *workarea) const;
void LoadMarkerList(QXmlStreamReader *reader, TimelineMarkerList *markers) const;
void SaveMarkerList(QXmlStreamWriter *writer, TimelineMarkerList *markers) const;
void LoadValueHint(Node::ValueHint *hint, QXmlStreamReader *reader) const;
void SaveValueHint(const Node::ValueHint *hint, QXmlStreamWriter *writer) const;
};
}