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
+12 -2
View File
@@ -47,6 +47,7 @@ NodeViewItem::NodeViewItem(QGraphicsItem *parent) :
// Set flags for this widget
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);
setFlag(QGraphicsItem::ItemSendsGeometryChanges);
//
// We use font metrics to set all the UI measurements for DPI-awareness
@@ -77,6 +78,8 @@ void NodeViewItem::SetNode(Node *n)
{
node_ = n;
setPos(node_->GetPosition());
update();
}
@@ -256,8 +259,6 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
}
}
#include "node/block/block.h"
void NodeViewItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
// We override standard mouse behavior in some cases. In these cases, we don't want the standard "move" and "release"
@@ -470,3 +471,12 @@ void NodeViewItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
QGraphicsRectItem::mouseReleaseEvent(event);
}
}
QVariant NodeViewItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == ItemPositionHasChanged && node_) {
node_->SetPosition(value.toPointF());
}
return QGraphicsItem::itemChange(change, value);
}