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:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "node/output/track/track.h"
|
||||
#include "transition/transition.h"
|
||||
|
||||
Block::Block() :
|
||||
|
||||
+18
-8
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "input.h"
|
||||
|
||||
#include <QMatrix4x4>
|
||||
#include <QVector2D>
|
||||
#include <QVector3D>
|
||||
#include <QVector4D>
|
||||
@@ -84,7 +85,7 @@ QString NodeInput::name()
|
||||
return NodeParam::name();
|
||||
}
|
||||
|
||||
void NodeInput::Load(QXmlStreamReader *reader, QHash<quintptr, NodeOutput*>& param_ptrs, QList<SerializedConnection> &input_connections, QList<FootageConnection>& footage_connections, const QAtomicInt *cancelled)
|
||||
void NodeInput::Load(QXmlStreamReader *reader, XMLNodeData &xml_node_data, const QAtomicInt *cancelled)
|
||||
{
|
||||
XMLAttributeLoop(reader, attr) {
|
||||
if (cancelled && *cancelled) {
|
||||
@@ -116,7 +117,7 @@ void NodeInput::Load(QXmlStreamReader *reader, QHash<quintptr, NodeOutput*>& par
|
||||
if (value_text.isEmpty()) {
|
||||
standard_value_.replace(val_index, QVariant());
|
||||
} else {
|
||||
standard_value_.replace(val_index, StringToValue(value_text, footage_connections));
|
||||
standard_value_.replace(val_index, StringToValue(value_text, xml_node_data.footage_connections));
|
||||
}
|
||||
|
||||
val_index++;
|
||||
@@ -165,7 +166,7 @@ void NodeInput::Load(QXmlStreamReader *reader, QHash<quintptr, NodeOutput*>& par
|
||||
}
|
||||
}
|
||||
|
||||
key_value = StringToValue(reader->readElementText(), footage_connections);
|
||||
key_value = StringToValue(reader->readElementText(), xml_node_data.footage_connections);
|
||||
|
||||
NodeKeyframePtr key = NodeKeyframe::Create(key_time, key_value, key_type, track);
|
||||
key->set_bezier_control_in(key_in_handle);
|
||||
@@ -189,13 +190,13 @@ void NodeInput::Load(QXmlStreamReader *reader, QHash<quintptr, NodeOutput*>& par
|
||||
}
|
||||
|
||||
if (reader->name() == QStringLiteral("connection")) {
|
||||
input_connections.append({this, reader->readElementText().toULongLong()});
|
||||
xml_node_data.desired_connections.append({this, reader->readElementText().toULongLong()});
|
||||
} else {
|
||||
reader->skipCurrentElement();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LoadInternal(reader, param_ptrs, input_connections, footage_connections, cancelled);
|
||||
LoadInternal(reader, xml_node_data, cancelled);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -268,7 +269,7 @@ const NodeParam::DataType &NodeInput::data_type() const
|
||||
return data_type_;
|
||||
}
|
||||
|
||||
void NodeInput::LoadInternal(QXmlStreamReader* reader, QHash<quintptr, NodeOutput *>&, QList<SerializedConnection>&, QList<FootageConnection>&, const QAtomicInt*)
|
||||
void NodeInput::LoadInternal(QXmlStreamReader* reader, XMLNodeData &, const QAtomicInt*)
|
||||
{
|
||||
reader->skipCurrentElement();
|
||||
}
|
||||
@@ -289,12 +290,21 @@ QString NodeInput::ValueToString(const QVariant &value) const
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
qWarning() << "Failed to convert type" << data_type_ << "to string";
|
||||
if (!value.isNull()) {
|
||||
qWarning() << "Failed to convert type" << QStringLiteral("%1").arg(data_type_, 0, 16) << "to string";
|
||||
}
|
||||
|
||||
/* fall through */
|
||||
|
||||
// These data types need no XML representation
|
||||
case kTexture:
|
||||
case kSamples:
|
||||
case kBuffer:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QVariant NodeInput::StringToValue(const QString &string, QList<NodeInput::FootageConnection>& footage_connections)
|
||||
QVariant NodeInput::StringToValue(const QString &string, QList<XMLNodeData::FootageConnection>& footage_connections)
|
||||
{
|
||||
switch (data_type_) {
|
||||
case kRational:
|
||||
|
||||
+3
-3
@@ -54,7 +54,7 @@ public:
|
||||
|
||||
virtual QString name() override;
|
||||
|
||||
virtual void Load(QXmlStreamReader* reader, QHash<quintptr, NodeOutput*>& param_ptrs, QList<SerializedConnection> &input_connections, QList<FootageConnection>& footage_connections, const QAtomicInt* cancelled) override;
|
||||
virtual void Load(QXmlStreamReader* reader, XMLNodeData& xml_node_data, const QAtomicInt* cancelled) override;
|
||||
|
||||
virtual void Save(QXmlStreamWriter* writer) const override;
|
||||
|
||||
@@ -270,14 +270,14 @@ signals:
|
||||
void PropertyChanged(const QString& s, const QVariant& v);
|
||||
|
||||
protected:
|
||||
virtual void LoadInternal(QXmlStreamReader* reader, QHash<quintptr, NodeOutput*>& param_ptrs, QList<SerializedConnection> &input_connections, QList<FootageConnection>& footage_connections, const QAtomicInt* cancelled);
|
||||
virtual void LoadInternal(QXmlStreamReader* reader, XMLNodeData& xml_node_data, const QAtomicInt* cancelled);
|
||||
|
||||
virtual void SaveInternal(QXmlStreamWriter* writer) const;
|
||||
|
||||
private:
|
||||
QString ValueToString(const QVariant& value) const;
|
||||
|
||||
QVariant StringToValue(const QString &string, QList<FootageConnection> &footage_connections);
|
||||
QVariant StringToValue(const QString &string, QList<XMLNodeData::FootageConnection> &footage_connections);
|
||||
|
||||
void SaveConnections(QXmlStreamWriter* writer) const;
|
||||
|
||||
|
||||
@@ -164,19 +164,19 @@ void NodeInputArray::RemoveAt(int index)
|
||||
RemoveLast();
|
||||
}
|
||||
|
||||
void NodeInputArray::LoadInternal(QXmlStreamReader *reader, QHash<quintptr, NodeOutput*>& param_ptrs, QList<SerializedConnection> &input_connections, QList<FootageConnection>& footage_connections, const QAtomicInt* cancelled)
|
||||
void NodeInputArray::LoadInternal(QXmlStreamReader *reader, XMLNodeData &xml_node_data, const QAtomicInt* cancelled)
|
||||
{
|
||||
if (reader->name() == QStringLiteral("subparameters")) {
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
if (reader->name() == QStringLiteral("input")) {
|
||||
Append();
|
||||
At(GetSize() - 1)->Load(reader, param_ptrs, input_connections, footage_connections, cancelled);
|
||||
At(GetSize() - 1)->Load(reader, xml_node_data, cancelled);
|
||||
} else {
|
||||
reader->skipCurrentElement();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
NodeInput::Load(reader, param_ptrs, input_connections, footage_connections, cancelled);
|
||||
NodeInput::Load(reader, xml_node_data, cancelled);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ signals:
|
||||
void SizeChanged(int size);
|
||||
|
||||
protected:
|
||||
virtual void LoadInternal(QXmlStreamReader* reader, QHash<quintptr, NodeOutput *> ¶m_ptrs, QList<SerializedConnection> &input_connections, QList<FootageConnection>& footage_connections, const QAtomicInt *cancelled) override;
|
||||
virtual void LoadInternal(QXmlStreamReader* reader, XMLNodeData& xml_node_data, const QAtomicInt *cancelled) override;
|
||||
|
||||
virtual void SaveInternal(QXmlStreamWriter* writer) const override;
|
||||
|
||||
|
||||
+6
-4
@@ -50,7 +50,7 @@ Node::~Node()
|
||||
}
|
||||
}
|
||||
|
||||
void Node::Load(QXmlStreamReader *reader, QHash<quintptr, NodeOutput *> &output_ptrs, QList<NodeInput::SerializedConnection>& input_connections, QList<NodeParam::FootageConnection>& footage_connections, const QAtomicInt* cancelled)
|
||||
void Node::Load(QXmlStreamReader *reader, XMLNodeData& xml_node_data, const QAtomicInt* cancelled)
|
||||
{
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
if (cancelled && *cancelled) {
|
||||
@@ -80,7 +80,7 @@ void Node::Load(QXmlStreamReader *reader, QHash<quintptr, NodeOutput *> &output_
|
||||
continue;
|
||||
}
|
||||
|
||||
param->Load(reader, output_ptrs, input_connections, footage_connections, cancelled);
|
||||
param->Load(reader, xml_node_data, cancelled);
|
||||
} else {
|
||||
reader->skipCurrentElement();
|
||||
}
|
||||
@@ -89,9 +89,11 @@ void Node::Load(QXmlStreamReader *reader, QHash<quintptr, NodeOutput *> &output_
|
||||
|
||||
void Node::Save(QXmlStreamWriter *writer, const QString &custom_name) const
|
||||
{
|
||||
writer->writeStartElement(custom_name.isEmpty() ? "node" : custom_name);
|
||||
writer->writeStartElement(custom_name.isEmpty() ? QStringLiteral("node") : custom_name);
|
||||
|
||||
writer->writeAttribute("id", id());
|
||||
writer->writeAttribute(QStringLiteral("id"), id());
|
||||
|
||||
writer->writeAttribute(QStringLiteral("ptr"), QString::number(reinterpret_cast<quintptr>(this)));
|
||||
|
||||
foreach (NodeParam* param, parameters()) {
|
||||
param->Save(writer);
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
#include "common/rational.h"
|
||||
#include "common/xmlutils.h"
|
||||
#include "node/dependency.h"
|
||||
#include "node/input.h"
|
||||
#include "node/inputarray.h"
|
||||
@@ -67,7 +68,7 @@ public:
|
||||
/**
|
||||
* @brief Clear current node variables and replace them with
|
||||
*/
|
||||
void Load(QXmlStreamReader* reader, QHash<quintptr, NodeOutput*>& param_ptrs, QList<NodeInput::SerializedConnection> &input_connections, QList<NodeParam::FootageConnection>& footage_connections, const QAtomicInt *cancelled);
|
||||
void Load(QXmlStreamReader* reader, XMLNodeData &xml_node_data, const QAtomicInt *cancelled);
|
||||
|
||||
/**
|
||||
* @brief Save this node into a text/XML format
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ QString NodeOutput::name()
|
||||
return NodeParam::name();
|
||||
}
|
||||
|
||||
void NodeOutput::Load(QXmlStreamReader* reader, QHash<quintptr, NodeOutput*>& param_ptrs, QList<SerializedConnection>&, QList<FootageConnection>&, const QAtomicInt *cancelled)
|
||||
void NodeOutput::Load(QXmlStreamReader* reader, XMLNodeData &xml_node_data, const QAtomicInt *cancelled)
|
||||
{
|
||||
XMLAttributeLoop(reader, attr) {
|
||||
if (cancelled && *cancelled) {
|
||||
@@ -52,7 +52,7 @@ void NodeOutput::Load(QXmlStreamReader* reader, QHash<quintptr, NodeOutput*>& pa
|
||||
if (attr.name() == "ptr") {
|
||||
quintptr saved_ptr = attr.value().toULongLong();
|
||||
|
||||
param_ptrs.insert(saved_ptr, this);
|
||||
xml_node_data.output_ptrs.insert(saved_ptr, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public:
|
||||
|
||||
virtual QString name() override;
|
||||
|
||||
virtual void Load(QXmlStreamReader* reader, QHash<quintptr, NodeOutput*>& param_ptrs, QList<SerializedConnection> &input_connections, QList<FootageConnection>& footage_connections, const QAtomicInt* cancelled) override;
|
||||
virtual void Load(QXmlStreamReader* reader, XMLNodeData& xml_node_data, const QAtomicInt* cancelled) override;
|
||||
|
||||
virtual void Save(QXmlStreamWriter* writer) const override;
|
||||
|
||||
|
||||
@@ -331,7 +331,7 @@ void TrackOutput::ReplaceBlock(Block *old, Block *replace)
|
||||
}
|
||||
}
|
||||
|
||||
TrackOutput *TrackOutput::TrackFromBlock(Block *block)
|
||||
TrackOutput *TrackOutput::TrackFromBlock(const Block *block)
|
||||
{
|
||||
NodeOutput* output = block->output();
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
|
||||
void UnblockInvalidateCache();
|
||||
|
||||
static TrackOutput* TrackFromBlock(Block* block);
|
||||
static TrackOutput* TrackFromBlock(const Block *block);
|
||||
|
||||
const rational& track_length() const;
|
||||
|
||||
|
||||
+2
-11
@@ -27,6 +27,7 @@
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
#include "common/rational.h"
|
||||
#include "common/xmlutils.h"
|
||||
#include "node/edge.h"
|
||||
|
||||
class Node;
|
||||
@@ -222,20 +223,10 @@ public:
|
||||
|
||||
virtual ~NodeParam() override;
|
||||
|
||||
struct SerializedConnection {
|
||||
NodeInput* input;
|
||||
quintptr output;
|
||||
};
|
||||
|
||||
struct FootageConnection {
|
||||
NodeInput* input;
|
||||
quintptr footage;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Load function
|
||||
*/
|
||||
virtual void Load(QXmlStreamReader* reader, QHash<quintptr, NodeOutput*>& param_ptrs, QList<SerializedConnection> &input_connections, QList<FootageConnection>& footage_connections, const QAtomicInt* cancelled) = 0;
|
||||
virtual void Load(QXmlStreamReader* reader, XMLNodeData& xml_node_data, const QAtomicInt* cancelled) = 0;
|
||||
|
||||
/**
|
||||
* @brief Save function
|
||||
|
||||
Reference in New Issue
Block a user