moved timeline undoable commands to using the new NodeAddCommand

Previous iteration used some "magic code" that added clips automatically to the
timeline. This was functional but ultimately outside of the undo commands'
control meaning nodes could be infinitely added and abandoned. This makes the
add process part of the undo command which means it's all undoable as the user
would expect.
This commit is contained in:
itsmattkc
2019-12-14 00:04:57 +11:00
parent 18bf126574
commit 323718bc11
21 changed files with 120 additions and 114 deletions
+5 -5
View File
@@ -30,6 +30,7 @@
#include "config/config.h"
#include "core.h"
#include "node/block/gap/gap.h"
#include "widget/nodeview/nodeviewundo.h"
TimelineWidget::PointerTool::PointerTool(TimelineWidget *parent) :
Tool(parent),
@@ -158,10 +159,6 @@ void TimelineWidget::PointerTool::MouseReleaseInternal(TimelineViewMouseEvent *e
{
Q_UNUSED(event)
// We create a QObject on the stack so that when we allocate objects on the heap, they aren't parent-less and will
// get cleaned up if they aren't re-parented by the attached NodeGraph
QObject block_memory_manager;
QUndoCommand* command = new QUndoCommand();
// Since all the ghosts will be leaving their old position in some way, we replace all of them with gaps here so the
@@ -171,9 +168,12 @@ void TimelineWidget::PointerTool::MouseReleaseInternal(TimelineViewMouseEvent *e
// Replace old Block with a new Gap
GapBlock* gap = new GapBlock();
gap->setParent(&block_memory_manager);
gap->set_length(b->length());
new NodeAddCommand(static_cast<NodeGraph*>(b->parent()),
gap,
command);
new TrackReplaceBlockCommand(parent()->GetTrackFromReference(ghost->Track()),
b,
gap,