timeline/various: implemented block copy/paste
Implemented the ability to copy/paste blocks/clips in the timeline. This did require some large scale changes and reworking of the copy/paste system introduced a few commits ago, but should be largely functional now.
This commit is contained in:
+15
-8
@@ -1,16 +1,17 @@
|
||||
#include "xmlutils.h"
|
||||
|
||||
#include "node/factory.h"
|
||||
#include "widget/nodeview/nodeviewundo.h"
|
||||
|
||||
Node* XMLLoadNode(QXmlStreamReader* reader) {
|
||||
QString node_id;
|
||||
quintptr node_ptr = 0;
|
||||
|
||||
XMLAttributeLoop(reader, attr) {
|
||||
if (attr.name() == "id") {
|
||||
if (attr.name() == QStringLiteral("id")) {
|
||||
node_id = attr.value().toString();
|
||||
|
||||
// Currently the only thing we need
|
||||
break;
|
||||
} else if (attr.name() == QStringLiteral("ptr")) {
|
||||
node_ptr = attr.value().toULongLong();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,20 +22,26 @@ Node* XMLLoadNode(QXmlStreamReader* reader) {
|
||||
|
||||
Node* node = NodeFactory::CreateFromID(node_id);
|
||||
|
||||
if (!node) {
|
||||
if (node) {
|
||||
node->setProperty("xml_ptr", node_ptr);
|
||||
} else {
|
||||
qWarning() << "Failed to load" << node_id << "- no node with that ID is installed";
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
void XMLConnectNodes(const QHash<quintptr, NodeOutput*>& output_ptrs, const QList<NodeParam::SerializedConnection>& desired_connections)
|
||||
void XMLConnectNodes(const QHash<quintptr, NodeOutput*>& output_ptrs, const QList<XMLNodeData::SerializedConnection>& desired_connections, QUndoCommand *command)
|
||||
{
|
||||
foreach (const NodeParam::SerializedConnection& con, desired_connections) {
|
||||
foreach (const XMLNodeData::SerializedConnection& con, desired_connections) {
|
||||
NodeOutput* out = output_ptrs.value(con.output);
|
||||
|
||||
if (out) {
|
||||
NodeParam::ConnectEdge(out, con.input);
|
||||
if (command) {
|
||||
new NodeEdgeAddCommand(out, con.input, command);
|
||||
} else {
|
||||
NodeParam::ConnectEdge(out, con.input);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+25
-2
@@ -1,9 +1,15 @@
|
||||
#ifndef XMLREADLOOP_H
|
||||
#define XMLREADLOOP_H
|
||||
|
||||
#include <QUndoCommand>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
#include "node/node.h"
|
||||
class Node;
|
||||
class NodeParam;
|
||||
class NodeInput;
|
||||
class NodeOutput;
|
||||
|
||||
#include "project/item/footage/stream.h"
|
||||
|
||||
#define XMLAttributeLoop(reader, item) \
|
||||
QXmlStreamAttributes __attributes = reader->attributes(); \
|
||||
@@ -11,7 +17,24 @@
|
||||
|
||||
Node *XMLLoadNode(QXmlStreamReader* reader);
|
||||
|
||||
void XMLConnectNodes(const QHash<quintptr, NodeOutput *> &output_ptrs, const QList<NodeParam::SerializedConnection> &desired_connections);
|
||||
struct XMLNodeData {
|
||||
struct SerializedConnection {
|
||||
NodeInput* input;
|
||||
quintptr output;
|
||||
};
|
||||
|
||||
struct FootageConnection {
|
||||
NodeInput* input;
|
||||
quintptr footage;
|
||||
};
|
||||
|
||||
QHash<quintptr, NodeOutput*> output_ptrs;
|
||||
QList<SerializedConnection> desired_connections;
|
||||
QHash<quintptr, StreamPtr> footage_ptrs;
|
||||
QList<FootageConnection> footage_connections;
|
||||
};
|
||||
|
||||
void XMLConnectNodes(const QHash<quintptr, NodeOutput *> &output_ptrs, const QList<XMLNodeData::SerializedConnection> &desired_connections, QUndoCommand* command = nullptr);
|
||||
|
||||
bool XMLReadNextStartElement(QXmlStreamReader* reader);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user