Skip to content

Commit

Permalink
projectserializer: explicitly differentiate between node and clip pas…
Browse files Browse the repository at this point in the history
…ting
  • Loading branch information
itsmattkc committed Mar 11, 2023
1 parent 3e47da7 commit 936d750
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/node/project/serializer/serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ProjectSerializer
{
kProject,
kOnlyNodes,
kOnlyClips,
kOnlyMarkers,
kOnlyKeyframes
};
Expand Down
2 changes: 1 addition & 1 deletion app/node/project/serializer/serializer220403.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ProjectSerializer220403::LoadData ProjectSerializer220403::Load(Project *project
LoadData load_data;

if ((load_type == kProject && reader->name() == QStringLiteral("project"))
|| (load_type == kOnlyNodes && (reader->name() == QStringLiteral("nodes") || reader->name() == QStringLiteral("timeline")))
|| ((load_type == kOnlyNodes && reader->name() == QStringLiteral("nodes")) || (load_type == kOnlyClips && reader->name() == QStringLiteral("timeline")))
|| (load_type == kOnlyKeyframes && reader->name() == QStringLiteral("keyframes"))
|| (load_type == kOnlyMarkers && reader->name() == QStringLiteral("markers"))) {
while (XMLReadNextStartElement(reader)) {
Expand Down
9 changes: 7 additions & 2 deletions app/node/project/serializer/serializer230220.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ ProjectSerializer230220::LoadData ProjectSerializer230220::Load(Project *project
}
break;
}
case kOnlyClips:
case kOnlyNodes:
{
if (reader->name() == QStringLiteral("nodes")) {
if ((load_type == kOnlyNodes && reader->name() == QStringLiteral("nodes")) || (load_type == kOnlyClips && reader->name() == QStringLiteral("timeline"))) {
QMap<quintptr, Node*> skipped_items;

while (XMLReadNextStartElement(reader)) {
Expand Down Expand Up @@ -395,7 +396,11 @@ void ProjectSerializer230220::Save(QXmlStreamWriter *writer, const SaveData &dat

writer->writeEndElement(); // keyframes
} else if (!data.GetOnlySerializeNodes().empty()) {
writer->writeStartElement(QStringLiteral("nodes"));
if (data.type() == kOnlyClips) {
writer->writeStartElement(QStringLiteral("timeline"));
} else {
writer->writeStartElement(QStringLiteral("nodes"));
}

writer->writeAttribute(QStringLiteral("version"), QString::number(1));

Expand Down
4 changes: 2 additions & 2 deletions app/widget/timelinewidget/timelinewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ bool TimelineWidget::CopySelected(bool cut)
}
}

ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyNodes);
ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyClips);
sdata.SetOnlySerializeNodesAndResolveGroups(selected_nodes);

// Cache the earliest in point so all copied clips have a "relative" in point that can be pasted anywhere
Expand Down Expand Up @@ -1938,7 +1938,7 @@ bool TimelineWidget::PasteInternal(bool insert)
return false;
}

ProjectSerializer::Result res = ProjectSerializer::Paste(ProjectSerializer::kOnlyNodes, GetConnectedNode()->project());
ProjectSerializer::Result res = ProjectSerializer::Paste(ProjectSerializer::kOnlyClips, GetConnectedNode()->project());
if (res.GetLoadData().nodes.isEmpty()) {
return false;
}
Expand Down

0 comments on commit 936d750

Please sign in to comment.