node: added command to remove position from context
This commit is contained in:
@@ -2348,4 +2348,24 @@ void NodeSetPositionToOffsetOfAnotherNodeCommand::undo()
|
||||
graph->SetNodePosition(node_, relative_, old_pos_);
|
||||
}
|
||||
|
||||
void NodeRemovePositionFromContextCommand::redo()
|
||||
{
|
||||
NodeGraph *graph = node_->parent();
|
||||
|
||||
contained_ = graph->ContextContainsNode(node_, context_);
|
||||
|
||||
if (contained_) {
|
||||
old_pos_ = graph->GetNodePosition(node_, context_);
|
||||
graph->RemoveNodePosition(node_, context_);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeRemovePositionFromContextCommand::undo()
|
||||
{
|
||||
if (contained_) {
|
||||
NodeGraph *graph = node_->parent();
|
||||
graph->SetNodePosition(node_, context_, old_pos_);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1445,6 +1445,35 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class NodeRemovePositionFromContextCommand : public UndoCommand
|
||||
{
|
||||
public:
|
||||
NodeRemovePositionFromContextCommand(Node *node, Node *context) :
|
||||
node_(node),
|
||||
context_(context)
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project * GetRelevantProject() const override
|
||||
{
|
||||
return node_->project();
|
||||
}
|
||||
|
||||
virtual void redo() override;
|
||||
|
||||
virtual void undo() override;
|
||||
|
||||
private:
|
||||
Node *node_;
|
||||
|
||||
Node *context_;
|
||||
|
||||
QPointF old_pos_;
|
||||
|
||||
bool contained_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODE_H
|
||||
|
||||
Reference in New Issue
Block a user