implement entire project in nodes
Project items are now represented directly in nodes opening up more versatility and possibilities. This is the first iteration of this and will be buggy. Need to test thoroughly.
This commit is contained in:
@@ -61,7 +61,7 @@ void NodeEdgeAddCommand::undo()
|
||||
|
||||
Project *NodeEdgeAddCommand::GetRelevantProject() const
|
||||
{
|
||||
return output_.node()->parent()->project();
|
||||
return output_.node()->project();
|
||||
}
|
||||
|
||||
NodeEdgeRemoveCommand::NodeEdgeRemoveCommand(const NodeOutput &output, const NodeInput &input) :
|
||||
@@ -82,13 +82,17 @@ void NodeEdgeRemoveCommand::undo()
|
||||
|
||||
Project *NodeEdgeRemoveCommand::GetRelevantProject() const
|
||||
{
|
||||
return output_.node()->parent()->project();
|
||||
return output_.node()->project();
|
||||
}
|
||||
|
||||
NodeAddCommand::NodeAddCommand(NodeGraph *graph, Node *node) :
|
||||
graph_(graph),
|
||||
node_(node)
|
||||
{
|
||||
if (memory_manager_.thread() != node->thread()) {
|
||||
memory_manager_.moveToThread(node_->thread());
|
||||
}
|
||||
|
||||
// Ensures that when this command is destroyed, if redo() is never called again, the node will be destroyed too
|
||||
node_->setParent(&memory_manager_);
|
||||
}
|
||||
@@ -105,7 +109,7 @@ void NodeAddCommand::undo()
|
||||
|
||||
Project *NodeAddCommand::GetRelevantProject() const
|
||||
{
|
||||
return graph_->project();
|
||||
return dynamic_cast<Project*>(graph_);
|
||||
}
|
||||
|
||||
NodeCopyInputsCommand::NodeCopyInputsCommand(Node *src, Node *dest, bool include_connections) :
|
||||
@@ -139,4 +143,30 @@ void NodeRemoveAndDisconnectCommand::prep()
|
||||
}
|
||||
}
|
||||
|
||||
void NodeRenameCommand::AddNode(Node *node, const QString &new_name)
|
||||
{
|
||||
nodes_.append(node);
|
||||
new_labels_.append(new_name);
|
||||
old_labels_.append(node->GetLabel());
|
||||
}
|
||||
|
||||
void NodeRenameCommand::redo()
|
||||
{
|
||||
for (int i=0; i<nodes_.size(); i++) {
|
||||
nodes_.at(i)->SetLabel(new_labels_.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
void NodeRenameCommand::undo()
|
||||
{
|
||||
for (int i=0; i<nodes_.size(); i++) {
|
||||
nodes_.at(i)->SetLabel(old_labels_.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
Project *NodeRenameCommand::GetRelevantProject() const
|
||||
{
|
||||
return nodes_.isEmpty() ? nullptr : nodes_.first()->project();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user