serializer: ensure backwards compatibility

This commit is contained in:
itsmattkc
2023-02-26 15:42:54 -08:00
parent 46d15396a6
commit 7ec8a4dd7e
31 changed files with 777 additions and 417 deletions
+3 -3
View File
@@ -188,10 +188,10 @@ void KeyframeView::SelectionManagerDeselectEvent(void *obj)
bool KeyframeView::CopySelected(bool cut)
{
if (!selection_manager_.GetSelectedObjects().empty()) {
ProjectSerializer::SaveData sdata;
ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyKeyframes);
sdata.SetOnlySerializeKeyframes(selection_manager_.GetSelectedObjects());
ProjectSerializer::Copy(sdata, QStringLiteral("keyframes"));
ProjectSerializer::Copy(sdata);
if (cut) {
DeleteSelected();
@@ -209,7 +209,7 @@ bool KeyframeView::Paste(std::function<Node *(const QString &)> find_node_functi
return false;
}
ProjectSerializer::Result res = ProjectSerializer::Paste(QStringLiteral("keyframes"));
ProjectSerializer::Result res = ProjectSerializer::Paste(ProjectSerializer::kOnlyKeyframes);
if (res == ProjectSerializer::kSuccess) {
const ProjectSerializer::SerializedKeyframes &keys = res.GetLoadData().keyframes;
+6 -6
View File
@@ -537,7 +537,7 @@ bool NodeParamView::CopySelected(bool cut)
return false;
}
ProjectSerializer::SaveData sdata(contexts_.first()->project());
ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyNodes);
ProjectSerializer::SerializedProperties properties;
QVector<Node*> nodes;
@@ -558,7 +558,7 @@ bool NodeParamView::CopySelected(bool cut)
sdata.SetOnlySerializeNodesAndResolveGroups(nodes);
sdata.SetProperties(properties);
ProjectSerializer::Copy(sdata, QStringLiteral("nodes"));
ProjectSerializer::Copy(sdata);
if (cut) {
DeleteSelected();
@@ -580,15 +580,15 @@ bool NodeParamView::Paste()
bool NodeParamView::Paste(QWidget *parent, std::function<QHash<Node *, Node*>(const ProjectSerializer::Result &)> get_existing_map_function)
{
ProjectSerializer::Result res = ProjectSerializer::Paste(QStringLiteral("nodes"));
if (res.GetLoadedNodes().isEmpty()) {
ProjectSerializer::Result res = ProjectSerializer::Paste(ProjectSerializer::kOnlyNodes);
if (res.GetLoadData().nodes.isEmpty()) {
return false;
}
// Determine if any nodes of this type are already in the editor
QHash<Node*, Node*> existing_nodes = get_existing_map_function(res);
QVector<Node*> nodes_to_paste_as_new = res.GetLoadedNodes();
QVector<Node*> nodes_to_paste_as_new = res.GetLoadData().nodes;
MultiUndoCommand *command = new MultiUndoCommand();
if (!existing_nodes.empty()) {
@@ -835,7 +835,7 @@ QHash<Node *, Node *> NodeParamView::GenerateExistingPasteMap(const ProjectSeria
{
QVector<Node*> ignore_nodes;
QHash<Node*, Node*> existing_nodes;
for (Node *n : r.GetLoadedNodes()) {
for (Node *n : r.GetLoadData().nodes) {
if (Node *existing = GetNodeWithIDAndIgnoreList(n->id(), ignore_nodes)) {
existing_nodes.insert(existing, n);
ignore_nodes.append(existing);
+5 -7
View File
@@ -225,7 +225,7 @@ void NodeView::CopySelected(bool cut)
QString copy_str;
QXmlStreamWriter writer(&copy_str);
ProjectSerializer::SaveData sdata(selected_nodes_.first()->project());
ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyNodes);
sdata.SetOnlySerializeNodesAndResolveGroups(selected_nodes_);
ProjectSerializer::SerializedProperties properties;
@@ -244,7 +244,7 @@ void NodeView::CopySelected(bool cut)
sdata.SetProperties(properties);
ProjectSerializer::Save(&writer, sdata, QStringLiteral("nodes"));
ProjectSerializer::Save(&writer, sdata);
Core::CopyStringToClipboard(copy_str);
@@ -259,8 +259,8 @@ void NodeView::Paste()
return;
}
ProjectSerializer::Result res = ProjectSerializer::Paste(QStringLiteral("nodes"));
if (res.GetLoadedNodes().isEmpty()) {
ProjectSerializer::Result res = ProjectSerializer::Paste(ProjectSerializer::kOnlyNodes);
if (res.GetLoadData().nodes.isEmpty()) {
return;
}
@@ -274,12 +274,10 @@ void NodeView::Paste()
pos.position.setY(node_props.value(QStringLiteral("y")).toDouble());
pos.expanded = node_props.value(QStringLiteral("expanded")).toDouble();
qDebug() << it.key() << pos.position;
map.insert(it.key(), pos);
}
PostPaste(res.GetLoadedNodes(), map);
PostPaste(res.GetLoadData().nodes, map);
}
void NodeView::Duplicate()
+2 -2
View File
@@ -911,7 +911,7 @@ void TimeBasedWidget::HideSnaps()
bool TimeBasedWidget::CopySelected(bool cut)
{
if (ruler()->hasFocus() && ruler()->CopySelected(cut)) {
if (ruler()->CopySelected(cut)) {
return true;
}
@@ -920,7 +920,7 @@ bool TimeBasedWidget::CopySelected(bool cut)
bool TimeBasedWidget::Paste()
{
if (ruler()->hasFocus() && ruler()->PasteMarkers()) {
if (ruler()->PasteMarkers()) {
return true;
}
+6 -6
View File
@@ -646,7 +646,7 @@ bool TimelineWidget::CopySelected(bool cut)
}
}
ProjectSerializer::SaveData sdata(selected_nodes.first()->project());
ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyNodes);
sdata.SetOnlySerializeNodesAndResolveGroups(selected_nodes);
// Cache the earliest in point so all copied clips have a "relative" in point that can be pasted anywhere
@@ -664,7 +664,7 @@ bool TimelineWidget::CopySelected(bool cut)
sdata.SetProperties(properties);
ProjectSerializer::Copy(sdata, QStringLiteral("timeline"));
ProjectSerializer::Copy(sdata);
if (cut) {
DeleteSelected();
@@ -1958,14 +1958,14 @@ bool TimelineWidget::PasteInternal(bool insert)
return false;
}
ProjectSerializer::Result res = ProjectSerializer::Paste(QStringLiteral("timeline"));
if (res.GetLoadedNodes().isEmpty()) {
ProjectSerializer::Result res = ProjectSerializer::Paste(ProjectSerializer::kOnlyNodes);
if (res.GetLoadData().nodes.isEmpty()) {
return false;
}
MultiUndoCommand *command = new MultiUndoCommand();
foreach (Node *n, res.GetLoadedNodes()) {
foreach (Node *n, res.GetLoadData().nodes) {
command->add_child(new NodeAddCommand(GetConnectedNode()->project(), n));
}
@@ -2013,7 +2013,7 @@ QHash<Node *, Node *> TimelineWidget::GenerateExistingPasteMap(const ProjectSeri
{
QHash<Node *, Node *> m;
for (Node *n : r.GetLoadedNodes()) {
for (Node *n : r.GetLoadData().nodes) {
for (Block *b : qAsConst(this->selected_blocks_)) {
for (auto it=b->GetContextPositions().cbegin(); it!=b->GetContextPositions().cend(); it++) {
if (it.key()->id() == n->id() && !m.contains(it.key())) {
+3 -3
View File
@@ -123,10 +123,10 @@ void SeekableWidget::DeleteSelected()
bool SeekableWidget::CopySelected(bool cut)
{
if (!selection_manager_.GetSelectedObjects().empty()) {
ProjectSerializer::SaveData sdata;
ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyMarkers);
sdata.SetOnlySerializeMarkers(selection_manager_.GetSelectedObjects());
ProjectSerializer::Copy(sdata, QStringLiteral("markers"));
ProjectSerializer::Copy(sdata);
if (cut) {
DeleteSelected();
@@ -140,7 +140,7 @@ bool SeekableWidget::CopySelected(bool cut)
bool SeekableWidget::PasteMarkers()
{
ProjectSerializer::Result res = ProjectSerializer::Paste(QStringLiteral("markers"));
ProjectSerializer::Result res = ProjectSerializer::Paste(ProjectSerializer::kOnlyMarkers);
if (res == ProjectSerializer::kSuccess) {
const std::vector<TimelineMarker*> &markers = res.GetLoadData().markers;
if (!markers.empty()) {