multiundocommand: keep undo/redo under protected

Minor code improvement
This commit is contained in:
itsmattkc
2021-08-01 13:37:32 -07:00
parent 8054124924
commit 3b9421f90e
11 changed files with 28 additions and 22 deletions
+5
View File
@@ -148,6 +148,11 @@ public:
return GetStandardValue(kSpeedInput).toDouble();
}
void set_speed(double s)
{
SetStandardValue(kSpeedInput, s);
}
bool reverse() const
{
return GetStandardValue(kReverseInput).toBool();
+1 -1
View File
@@ -2343,7 +2343,7 @@ void NodeSetPositionAsChildCommand::redo()
}
}
sub_command_->redo();
sub_command_->redo_now();
}
void NodeSetPositionToOffsetOfAnotherNodeCommand::redo()
+1 -1
View File
@@ -1406,7 +1406,7 @@ protected:
virtual void undo() override
{
sub_command_->undo();
sub_command_->undo_now();
}
private:
+1 -1
View File
@@ -168,7 +168,7 @@ void Folder::RemoveElementCommand::redo()
}
if (subcommand_) {
subcommand_->redo();
subcommand_->redo_now();
}
}
+1 -1
View File
@@ -145,7 +145,7 @@ public:
virtual void undo() override
{
if (subcommand_) {
subcommand_->undo();
subcommand_->undo_now();
}
}
+1 -1
View File
@@ -98,7 +98,7 @@ public:
const QVector<Block*>& GetSelectedBlocks() const
{
return static_cast<TimelineWidget*>(GetTimeBasedWidget())->GetSelectedBlocks();
return timeline_widget()->GetSelectedBlocks();
}
protected:
+4 -3
View File
@@ -82,9 +82,6 @@ class MultiUndoCommand : public UndoCommand
public:
MultiUndoCommand();
virtual void redo() override;
virtual void undo() override;
virtual Project* GetRelevantProject() const override
{
return nullptr;
@@ -105,6 +102,10 @@ public:
return children_[i];
}
protected:
virtual void redo() override;
virtual void undo() override;
private:
std::vector<UndoCommand*> children_;
+6 -6
View File
@@ -431,7 +431,7 @@ void NodeView::keyPressEvent(QKeyEvent *event)
// We undo the last action which SHOULD be adding the node
if (paste_command_) {
paste_command_->undo();
paste_command_->undo_now();
delete paste_command_;
paste_command_ = nullptr;
}
@@ -757,7 +757,7 @@ void NodeView::mouseReleaseEvent(QMouseEvent *event)
}
}
if (set_pos_command->child_count()) {
set_pos_command->redo();
set_pos_command->redo_now();
command->add_child(set_pos_command);
} else {
delete set_pos_command;
@@ -784,7 +784,7 @@ void NodeView::mouseReleaseEvent(QMouseEvent *event)
drop_edge_ = nullptr;
}
if (drop_edge_command->child_count()) {
drop_edge_command->redo();
drop_edge_command->redo_now();
command->add_child(drop_edge_command);
} else {
delete drop_edge_command;
@@ -822,7 +822,7 @@ void NodeView::mouseReleaseEvent(QMouseEvent *event)
}
if (remove_pos_command->child_count()) {
remove_pos_command->redo();
remove_pos_command->redo_now();
command->add_child(remove_pos_command);
} else {
delete remove_pos_command;
@@ -988,7 +988,7 @@ void NodeView::CreateNodeSlot(QAction *action)
paste_command_->add_child(new NodeSetPositionCommand(new_node, context, QPointF(0, 0), false));
}
paste_command_->add_child(new NodeViewAttachNodesToCursor(this, {new_node}));
paste_command_->redo();
paste_command_->redo_now();
this->setFocus();
}
@@ -1673,7 +1673,7 @@ void NodeView::PasteNodesInternal(const QVector<Node *> &duplicate_nodes)
// Attach nodes to cursor
paste_command_->add_child(new NodeViewAttachNodesToCursor(this, new_nodes));
paste_command_->redo();
paste_command_->redo_now();
}
NodeView::NodeViewAttachNodesToCursor::NodeViewAttachNodesToCursor(NodeView *view, const QVector<Node *> &nodes) :
+4 -4
View File
@@ -117,7 +117,7 @@ protected:
virtual void redo() override
{
command_->redo();
command_->redo_now();
graph_ = node_->parent();
node_->setParent(&memory_manager_);
@@ -128,7 +128,7 @@ protected:
node_->setParent(graph_);
graph_ = nullptr;
command_->undo();
command_->undo_now();
}
private:
@@ -179,12 +179,12 @@ protected:
virtual void redo() override
{
command_->redo();
command_->redo_now();
}
virtual void undo() override
{
command_->undo();
command_->undo_now();
}
private:
@@ -172,12 +172,12 @@ void TimelineAddTrackCommand::redo()
position_command_->add_child(new NodeSetPositionAsChildCommand(track_, merge_, timeline_->parent(), 1, 2, true));
}
}
position_command_->redo();
position_command_->redo_now();
}
void TimelineAddTrackCommand::undo()
{
position_command_->undo();
position_command_->undo_now();
// Remove merge if applicable
if (merge_) {
@@ -39,7 +39,7 @@ void BlockSplitCommand::redo()
new_block_ = static_cast<Block*>(Node::CopyNodeInGraph(block_, reconnect_tree_command_));
}
reconnect_tree_command_->redo();
reconnect_tree_command_->redo_now();
// Determine our new lengths
rational new_length = point_ - block_->in();
@@ -97,7 +97,7 @@ void BlockSplitCommand::undo()
track->RippleRemoveBlock(new_block());
// If we ran a reconnect command, disconnect now
reconnect_tree_command_->undo();
reconnect_tree_command_->undo_now();
track->EndOperation();
}