implement "type" for xml node data
This commit is contained in:
@@ -51,7 +51,7 @@ void NodeCopyPasteService::CopyNodesToClipboard(QVector<Node *> nodes, void *use
|
||||
|
||||
CopyNodesToClipboardCallback(nodes, &data, userdata);
|
||||
|
||||
ProjectSerializer::Save(&writer, data);
|
||||
ProjectSerializer::Save(&writer, data, type_);
|
||||
|
||||
Core::CopyStringToClipboard(copy_str);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ void NodeCopyPasteService::PasteNodesFromClipboard(void *userdata)
|
||||
QXmlStreamReader reader(clipboard);
|
||||
|
||||
Project temp;
|
||||
ProjectSerializer::Result res = ProjectSerializer::Load(&temp, &reader);
|
||||
ProjectSerializer::Result res = ProjectSerializer::Load(&temp, &reader, type_);
|
||||
|
||||
if (res.code() != ProjectSerializer::kSuccess) {
|
||||
return;
|
||||
|
||||
@@ -34,7 +34,9 @@ namespace olive {
|
||||
class NodeCopyPasteService
|
||||
{
|
||||
public:
|
||||
NodeCopyPasteService() = default;
|
||||
NodeCopyPasteService(const QString &type) :
|
||||
type_(type)
|
||||
{}
|
||||
|
||||
protected:
|
||||
void CopyNodesToClipboard(QVector<Node *> nodes, void* userdata = nullptr);
|
||||
@@ -45,6 +47,9 @@ protected:
|
||||
|
||||
virtual void PasteNodesToClipboardCallback(const QVector<Node*> &nodes, const ProjectSerializer::LoadData &load_data, void *userdata){}
|
||||
|
||||
private:
|
||||
QString type_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -55,14 +55,14 @@ void ProjectSerializer::Destroy()
|
||||
instances_.clear();
|
||||
}
|
||||
|
||||
ProjectSerializer::Result ProjectSerializer::Load(Project *project, const QString &filename)
|
||||
ProjectSerializer::Result ProjectSerializer::Load(Project *project, const QString &filename, const QString &type)
|
||||
{
|
||||
QFile project_file(filename);
|
||||
|
||||
if (project_file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
QXmlStreamReader reader(&project_file);
|
||||
|
||||
Result inner_result = Load(project, &reader);
|
||||
Result inner_result = Load(project, &reader, type);
|
||||
|
||||
project_file.close();
|
||||
|
||||
@@ -82,13 +82,13 @@ ProjectSerializer::Result ProjectSerializer::Load(Project *project, const QStrin
|
||||
}
|
||||
}
|
||||
|
||||
ProjectSerializer::Result ProjectSerializer::Load(Project *project, QXmlStreamReader *reader)
|
||||
ProjectSerializer::Result ProjectSerializer::Load(Project *project, QXmlStreamReader *reader, const QString &type)
|
||||
{
|
||||
// Determine project version
|
||||
uint version = 0;
|
||||
|
||||
while (!version && XMLReadNextStartElement(reader)) {
|
||||
if (reader->name() == QStringLiteral("olive") || reader->name() == QStringLiteral("project")) {
|
||||
if (reader->name() == QStringLiteral("olive") || reader->name() == type) {
|
||||
while(!version && XMLReadNextStartElement(reader)) {
|
||||
if (reader->name() == QStringLiteral("version")) {
|
||||
version = reader->readElementText().toUInt();
|
||||
@@ -135,7 +135,7 @@ ProjectSerializer::Result ProjectSerializer::Load(Project *project, QXmlStreamRe
|
||||
}
|
||||
}
|
||||
|
||||
ProjectSerializer::Result ProjectSerializer::Save(const SaveData &data)
|
||||
ProjectSerializer::Result ProjectSerializer::Save(const SaveData &data, const QString &type)
|
||||
{
|
||||
QString temp_save = FileFunctions::GetSafeTemporaryFilename(data.GetFilename());
|
||||
|
||||
@@ -144,7 +144,7 @@ ProjectSerializer::Result ProjectSerializer::Save(const SaveData &data)
|
||||
if (project_file.open(QFile::WriteOnly | QFile::Text)) {
|
||||
QXmlStreamWriter writer(&project_file);
|
||||
|
||||
Result inner_result = Save(&writer, data);
|
||||
Result inner_result = Save(&writer, data, type);
|
||||
|
||||
project_file.close();
|
||||
|
||||
@@ -167,7 +167,7 @@ ProjectSerializer::Result ProjectSerializer::Save(const SaveData &data)
|
||||
}
|
||||
}
|
||||
|
||||
ProjectSerializer::Result ProjectSerializer::Save(QXmlStreamWriter *writer, const SaveData &data)
|
||||
ProjectSerializer::Result ProjectSerializer::Save(QXmlStreamWriter *writer, const SaveData &data, const QString &type)
|
||||
{
|
||||
writer->setAutoFormatting(true);
|
||||
|
||||
@@ -187,11 +187,11 @@ ProjectSerializer::Result ProjectSerializer::Save(QXmlStreamWriter *writer, cons
|
||||
writer->writeTextElement("url", data.GetFilename());
|
||||
}
|
||||
|
||||
writer->writeStartElement(QStringLiteral("project"));
|
||||
writer->writeStartElement(type);
|
||||
|
||||
serializer->Save(writer, data, nullptr);
|
||||
|
||||
writer->writeEndElement(); // project
|
||||
writer->writeEndElement(); // [type]
|
||||
|
||||
writer->writeEndElement(); // olive
|
||||
|
||||
|
||||
@@ -137,11 +137,11 @@ public:
|
||||
|
||||
static void Destroy();
|
||||
|
||||
static Result Load(Project *project, const QString &filename);
|
||||
static Result Load(Project *project, QXmlStreamReader *read_device);
|
||||
static Result Load(Project *project, const QString &filename, const QString &type);
|
||||
static Result Load(Project *project, QXmlStreamReader *read_device, const QString &type);
|
||||
|
||||
static Result Save(const SaveData &data);
|
||||
static Result Save(QXmlStreamWriter *write_device, const SaveData &data);
|
||||
static Result Save(const SaveData &data, const QString &type);
|
||||
static Result Save(QXmlStreamWriter *write_device, const SaveData &data, const QString &type);
|
||||
|
||||
protected:
|
||||
virtual LoadData Load(Project *project, QXmlStreamReader *reader, void *reserved) const = 0;
|
||||
|
||||
@@ -37,7 +37,7 @@ bool ProjectLoadTask::Run()
|
||||
|
||||
project_->set_filename(GetFilename());
|
||||
|
||||
ProjectSerializer::Result result = ProjectSerializer::Load(project_, GetFilename());
|
||||
ProjectSerializer::Result result = ProjectSerializer::Load(project_, GetFilename(), QStringLiteral("project"));
|
||||
|
||||
switch (result.code()) {
|
||||
case ProjectSerializer::kSuccess:
|
||||
|
||||
@@ -42,7 +42,7 @@ bool ProjectSaveTask::Run()
|
||||
|
||||
ProjectSerializer::SaveData data(project_, using_filename);
|
||||
|
||||
ProjectSerializer::Result result = ProjectSerializer::Save(data);
|
||||
ProjectSerializer::Result result = ProjectSerializer::Save(data, QStringLiteral("project"));
|
||||
|
||||
bool success = false;
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ const double NodeView::kMinimumScale = 0.1;
|
||||
|
||||
NodeView::NodeView(QWidget *parent) :
|
||||
HandMovableView(parent),
|
||||
NodeCopyPasteService(QStringLiteral("nodes")),
|
||||
drop_edge_(nullptr),
|
||||
create_edge_(nullptr),
|
||||
create_edge_output_item_(nullptr),
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace olive {
|
||||
|
||||
TimelineWidget::TimelineWidget(QWidget *parent) :
|
||||
super(true, true, parent),
|
||||
NodeCopyPasteService(QStringLiteral("timeline")),
|
||||
rubberband_(QRubberBand::Rectangle, this),
|
||||
active_tool_(nullptr),
|
||||
use_audio_time_units_(false),
|
||||
|
||||
Reference in New Issue
Block a user