implemented saving/loading for groups
This commit is contained in:
+44
-21
@@ -24,15 +24,30 @@
|
||||
#include "node/factory.h"
|
||||
#include "widget/nodeparamview/nodeparamviewundo.h"
|
||||
#include "widget/nodeview/nodeviewundo.h"
|
||||
//#include "widget/timelinewidget/undo/timelineundogeneral.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
void XMLConnectNodes(const XMLNodeData &xml_node_data, uint version, MultiUndoCommand *command)
|
||||
bool XMLReadNextStartElement(QXmlStreamReader *reader)
|
||||
{
|
||||
foreach (const XMLNodeData::SerializedConnection& con, xml_node_data.desired_connections) {
|
||||
Node *out = xml_node_data.node_ptrs.value(con.output_node);
|
||||
QXmlStreamReader::TokenType token;
|
||||
|
||||
if (out) {
|
||||
while ((token = reader->readNext()) != QXmlStreamReader::Invalid
|
||||
&& token != QXmlStreamReader::EndDocument) {
|
||||
if (reader->isEndElement()) {
|
||||
return false;
|
||||
} else if (reader->isStartElement()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void XMLNodeData::PostConnect(uint version, MultiUndoCommand *command) const
|
||||
{
|
||||
foreach (const XMLNodeData::SerializedConnection& con, desired_connections) {
|
||||
if (Node *out = node_ptrs.value(con.output_node)) {
|
||||
// Use output param as hint tag since we grandfathered those in
|
||||
Node::ValueHint hint(con.output_param);
|
||||
|
||||
@@ -53,28 +68,36 @@ void XMLConnectNodes(const XMLNodeData &xml_node_data, uint version, MultiUndoCo
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool XMLReadNextStartElement(QXmlStreamReader *reader)
|
||||
{
|
||||
QXmlStreamReader::TokenType token;
|
||||
|
||||
while ((token = reader->readNext()) != QXmlStreamReader::Invalid
|
||||
&& token != QXmlStreamReader::EndDocument) {
|
||||
if (reader->isEndElement()) {
|
||||
return false;
|
||||
} else if (reader->isStartElement()) {
|
||||
return true;
|
||||
foreach (const XMLNodeData::BlockLink& l, block_links) {
|
||||
Node *a = l.block;
|
||||
Node *b = node_ptrs.value(l.link);
|
||||
if (command) {
|
||||
command->add_child(new NodeLinkCommand(a, b, true));
|
||||
} else {
|
||||
Node::Link(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
foreach (const XMLNodeData::GroupLink &l, group_input_links) {
|
||||
if (Node *input_node = node_ptrs.value(l.input_node)) {
|
||||
NodeInput resolved(input_node, l.input_id, l.input_element);
|
||||
if (command) {
|
||||
command->add_child(new NodeGroupAddInputPassthrough(l.group, resolved));
|
||||
} else {
|
||||
l.group->AddInputPassthrough(resolved);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void XMLLinkBlocks(const XMLNodeData &xml_node_data)
|
||||
{
|
||||
foreach (const XMLNodeData::BlockLink& l, xml_node_data.block_links) {
|
||||
Block::Link(l.block, static_cast<Block*>(xml_node_data.node_ptrs.value(l.link)));
|
||||
for (auto it=group_output_links.cbegin(); it!=group_output_links.cend(); it++) {
|
||||
if (Node *output_node = node_ptrs.value(it.value())) {
|
||||
if (command) {
|
||||
command->add_child(new NodeGroupSetOutputPassthrough(it.key(), output_node));
|
||||
} else {
|
||||
it.key()->SetOutputPassthrough(output_node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-4
@@ -31,6 +31,7 @@ namespace olive {
|
||||
class Block;
|
||||
class Node;
|
||||
class NodeInput;
|
||||
class NodeGroup;
|
||||
|
||||
#define XMLAttributeLoop(reader, item) \
|
||||
foreach (const QXmlStreamAttribute& item, reader->attributes())
|
||||
@@ -49,14 +50,23 @@ struct XMLNodeData {
|
||||
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 PostConnect(uint version, MultiUndoCommand *command = nullptr) const;
|
||||
|
||||
};
|
||||
|
||||
void XMLConnectNodes(const XMLNodeData& xml_node_data, uint version, MultiUndoCommand *command = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Workaround for QXmlStreamReader::readNextStartElement not detecting the end of a document
|
||||
*
|
||||
@@ -68,8 +78,6 @@ void XMLConnectNodes(const XMLNodeData& xml_node_data, uint version, MultiUndoCo
|
||||
*/
|
||||
bool XMLReadNextStartElement(QXmlStreamReader* reader);
|
||||
|
||||
void XMLLinkBlocks(const XMLNodeData& xml_node_data);
|
||||
|
||||
}
|
||||
|
||||
#endif // XMLREADLOOP_H
|
||||
|
||||
Reference in New Issue
Block a user