work towards group editor

This commit is contained in:
itsmattkc
2021-12-27 15:16:49 -08:00
parent a8ac7edd51
commit 5223483e8e
23 changed files with 500 additions and 267 deletions
-4
View File
@@ -105,10 +105,6 @@ void NodeGraph::childEvent(QChildEvent *event)
// Remove from any contexts
foreach (Node *context, node_children_) {
context->RemoveNodeFromContext(node);
if (NodeGroup *group = dynamic_cast<NodeGroup*>(context)) {
group->RemoveNode(node);
}
}
}
}
+4 -38
View File
@@ -55,28 +55,14 @@ QString NodeGroup::Description() const
void NodeGroup::Retranslate()
{
foreach (Node *n, nodes_) {
n->Retranslate();
}
}
void NodeGroup::AddNode(Node *node)
{
nodes_.append(node);
emit NodeAddedToGroup(node);
}
void NodeGroup::RemoveNode(Node *node)
{
if (nodes_.removeOne(node)) {
emit NodeRemovedFromGroup(node);
for (auto it=GetContextPositions().cbegin(); it!=GetContextPositions().cend(); it++) {
it.key()->Retranslate();
}
}
void NodeGroup::AddInputPassthrough(const NodeInput &input)
{
Q_ASSERT(nodes_.contains(input.node()));
Q_ASSERT(ContextContainsNode(input.node()));
for (auto it=input_passthroughs_.cbegin(); it!=input_passthroughs_.cend(); it++) {
if (it.value() == input) {
@@ -109,7 +95,7 @@ void NodeGroup::RemoveInputPassthrough(const NodeInput &input)
void NodeGroup::SetOutputPassthrough(Node *node)
{
Q_ASSERT(!node || nodes_.contains(node));
Q_ASSERT(!node || ContextContainsNode(node));
output_passthrough_ = node;
@@ -145,16 +131,6 @@ QString NodeGroup::GetInputName(const QString &id) const
return input_passthroughs_.value(id).name();
}
void NodeAddToGroupCommand::redo()
{
group_->AddNode(node_);
}
void NodeAddToGroupCommand::undo()
{
group_->RemoveNode(node_);
}
void NodeGroupSetCustomNameCommand::redo()
{
old_name_ = group_->GetCustomName();
@@ -183,16 +159,6 @@ void NodeGroupAddInputPassthrough::undo()
}
}
void NodeRemoveFromGroupCommand::redo()
{
group_->RemoveNode(node_);
}
void NodeRemoveFromGroupCommand::undo()
{
group_->AddNode(node_);
}
void NodeGroupSetOutputPassthrough::redo()
{
old_output_ = group_->GetOutputPassthrough();
-70
View File
@@ -41,20 +41,6 @@ public:
virtual void Retranslate() override;
void AddNode(Node *node);
void RemoveNode(Node *node);
bool ContainsNode(Node *node) const
{
return nodes_.contains(node);
}
const QVector<Node*> &GetNodes() const
{
return nodes_;
}
void AddInputPassthrough(const NodeInput &input);
void RemoveInputPassthrough(const NodeInput &input);
@@ -96,10 +82,6 @@ public:
virtual QString GetInputName(const QString& id) const override;
signals:
void NodeAddedToGroup(Node *node);
void NodeRemovedFromGroup(Node *node);
void InputPassthroughAdded(NodeGroup *group, const NodeInput &input);
void InputPassthroughRemoved(NodeGroup *group, const NodeInput &input);
@@ -107,8 +89,6 @@ signals:
void OutputPassthroughChanged(NodeGroup *group, Node *output);
private:
QVector<Node*> nodes_;
QHash<QString, NodeInput> input_passthroughs_;
Node *output_passthrough_;
@@ -117,56 +97,6 @@ private:
};
class NodeAddToGroupCommand : public UndoCommand
{
public:
NodeAddToGroupCommand(Node *node, NodeGroup *group) :
node_(node),
group_(group)
{}
virtual Project * GetRelevantProject() const override
{
return node_->project();
}
protected:
virtual void redo() override;
virtual void undo() override;
private:
Node *node_;
NodeGroup *group_;
};
class NodeRemoveFromGroupCommand : public UndoCommand
{
public:
NodeRemoveFromGroupCommand(Node *node, NodeGroup *group) :
node_(node),
group_(group)
{}
virtual Project * GetRelevantProject() const override
{
return node_->project();
}
protected:
virtual void redo() override;
virtual void undo() override;
private:
Node *node_;
NodeGroup *group_;
};
class NodeGroupSetCustomNameCommand : public UndoCommand
{
public: