diff --git a/app/node/connectable.cpp b/app/node/connectable.cpp index bc49f7c65..24d4ba530 100644 --- a/app/node/connectable.cpp +++ b/app/node/connectable.cpp @@ -30,17 +30,17 @@ void NodeConnectable::ConnectEdge(Node *output, NodeInput *input, int element) InputConnection conn_to_in = {input, element}; // Connection exists - if (output->output_connections_.contains(conn_to_in)) { + if (std::find(output->output_connections_.begin(), output->output_connections_.end(), conn_to_in) != output->output_connections_.end()) { qDebug() << "Ignored connect that already exists"; return; } // Ensure a connection isn't getting overwritten - Q_ASSERT(!input->input_connections_.contains(element)); + Q_ASSERT(input->input_connections_.find(element) == input->input_connections_.end()); // Insert connections in both sides - output->output_connections_.append(conn_to_in); - input->input_connections_.insert(element, output); + output->output_connections_.push_back(conn_to_in); + input->input_connections_[element] = output; // Emit signals emit input->InputConnected(output, element); @@ -52,17 +52,17 @@ void NodeConnectable::DisconnectEdge(Node *output, NodeInput *input, int element InputConnection conn_to_in = {input, element}; // Connection exists - if (!output->output_connections_.contains(conn_to_in)) { + if (std::find(output->output_connections_.begin(), output->output_connections_.end(), conn_to_in) == output->output_connections_.end()) { qDebug() << "Ignored disconnect that doesn't exist"; return; } // Assertions to ensure connection exists - Q_ASSERT(input->input_connections_.value(element) == output); + Q_ASSERT(input->input_connections_.at(element) == output); // Remove connections from both sides - output->output_connections_.removeOne(conn_to_in); - input->input_connections_.remove(element); + output->output_connections_.erase(std::find(output->output_connections_.begin(), output->output_connections_.end(), conn_to_in)); + input->input_connections_.erase(input->input_connections_.find(element)); // Emit signals emit input->InputDisconnected(output, element); diff --git a/app/node/connectable.h b/app/node/connectable.h index 06ebe47d4..6d496a4be 100644 --- a/app/node/connectable.h +++ b/app/node/connectable.h @@ -72,20 +72,20 @@ signals: void InputDisconnected(Node* source, int element); protected: - const QVector& output_connections() const + const std::vector& output_connections() const { return output_connections_; } - const QMap& input_connections() const + const std::map& input_connections() const { return input_connections_; } private: - QVector output_connections_; + std::vector output_connections_; - QMap input_connections_; + std::map input_connections_; }; diff --git a/app/node/input.cpp b/app/node/input.cpp index 8da2b8968..98cb7481e 100644 --- a/app/node/input.cpp +++ b/app/node/input.cpp @@ -66,10 +66,10 @@ QString NodeInput::name() const void NodeInput::DisconnectAll() { - auto copied_edges = edges(); + std::map copied_edges = edges(); for (auto it=copied_edges.cbegin(); it!=copied_edges.cend(); it++) { - DisconnectEdge(it.value(), this, it.key()); + DisconnectEdge(it->second, this, it->first); } } @@ -154,9 +154,9 @@ void NodeInput::Save(QXmlStreamWriter *writer) const for (auto it=input_connections().cbegin(); it!=input_connections().cend(); it++) { writer->writeStartElement(QStringLiteral("connection")); - writer->writeAttribute(QStringLiteral("element"), QString::number(it.key())); + writer->writeAttribute(QStringLiteral("element"), QString::number(it->first)); - writer->writeCharacters(QString::number(reinterpret_cast(it.value()))); + writer->writeCharacters(QString::number(reinterpret_cast(it->second))); writer->writeEndElement(); // connection } @@ -389,9 +389,9 @@ NodeInputImmediate *NodeInput::CreateImmediate() void NodeInput::GetDependencies(QVector &list, bool traverse, bool exclusive_only) const { for (auto it=input_connections().cbegin(); it!=input_connections().cend(); it++) { - if (it.value()->edges().size() == 1 || !exclusive_only) { - Node* connected = it.value(); + Node* connected = it->second; + if (connected->edges().size() == 1 || !exclusive_only) { if (!list.contains(connected)) { list.append(connected); @@ -439,12 +439,12 @@ void NodeInput::ArrayInsert(int index) subinputs_.insert(index, CreateImmediate()); // Move connections down - auto copied_edges = edges(); - for (auto it=copied_edges.cend(); it!=copied_edges.cbegin(); it--) { - if (it.key() >= index) { + std::map copied_edges = edges(); + for (auto it=copied_edges.crbegin(); it!=copied_edges.crend(); it++) { + if (it->first >= index) { // Disconnect this and reconnect it one element down - DisconnectEdge(it.value(), this, it.key()); - ConnectEdge(it.value(), this, it.key() + 1); + DisconnectEdge(it->second, this, it->first); + ConnectEdge(it->second, this, it->first + 1); } } @@ -454,14 +454,14 @@ void NodeInput::ArrayInsert(int index) void NodeInput::ArrayRemove(int index) { // Move connections up - auto copied_edges = edges(); + std::map copied_edges = edges(); for (auto it=copied_edges.cbegin(); it!=copied_edges.cend(); it++) { - if (it.key() >= index) { + if (it->first >= index) { // Disconnect this and reconnect it one element up if it's not the element being removed - DisconnectEdge(it.value(), this, it.key()); + DisconnectEdge(it->second, this, it->first); - if (it.key() > index) { - ConnectEdge(it.value(), this, it.key() - 1); + if (it->first > index) { + ConnectEdge(it->second, this, it->first - 1); } } } @@ -482,10 +482,9 @@ void NodeInput::ArrayResize(int size) if (array_size_ > size) { // Decreasing in size, disconnect any extraneous edges for (int i=size; iinput_connections().cbegin(); it!=source->input_connections().cend(); it++) { - ConnectEdge(it.value(), dest, it.key()); + ConnectEdge(it->second, dest, it->first); } } else { // Just copy the primary connection (at -1) diff --git a/app/node/input.h b/app/node/input.h index da62d21ee..89ffe8c98 100644 --- a/app/node/input.h +++ b/app/node/input.h @@ -106,14 +106,14 @@ public: emit DataTypeChanged(type); } - const QMap& edges() const + const std::map& edges() const { return input_connections(); } bool IsConnected(int element = -1) const { - return input_connections().contains(element); + return input_connections().find(element) != input_connections().end(); } /** @@ -127,7 +127,7 @@ public: Node* GetConnectedNode(int element = -1) const { - return input_connections().value(element); + return input_connections().at(element); } bool IsConnectable() const diff --git a/app/node/node.cpp b/app/node/node.cpp index 825230987..9a112f7c9 100644 --- a/app/node/node.cpp +++ b/app/node/node.cpp @@ -167,7 +167,7 @@ void Node::RemoveNodeAndDisconnect(Node *node, QUndoCommand *command) foreach (NodeInput* input, node->inputs_) { for (auto it=input->edges().cbegin(); it!=input->edges().cend(); it++) { - new NodeEdgeRemoveCommand(it.value(), input, it.key(), command); + new NodeEdgeRemoveCommand(it->second, input, it->first, command); } } @@ -250,7 +250,7 @@ void Node::CopyDependencyGraph(const QVector &src, const QVector for (int i=0; iinputs()) { for (auto it=input->edges().cbegin(); it!=input->edges().cend(); it++) { - int connection_index = src.indexOf(it.value()); + int connection_index = src.indexOf(it->second); if (connection_index > -1) { // Found a connection @@ -258,9 +258,9 @@ void Node::CopyDependencyGraph(const QVector &src, const QVector NodeInput* dst_input = dst.at(i)->GetInputWithID(input->id()); if (command) { - new NodeEdgeAddCommand(dst_output, dst_input, it.key(), command); + new NodeEdgeAddCommand(dst_output, dst_input, it->first, command); } else { - ConnectEdge(dst_output, dst_input, it.key()); + ConnectEdge(dst_output, dst_input, it->first); } } } @@ -560,7 +560,7 @@ bool Node::InputsFrom(Node *n, bool recursively) const { foreach (NodeInput* input, inputs_) { for (auto it=input->edges().cbegin(); it!=input->edges().cend(); it++) { - Node* connected = it.value(); + Node* connected = it->second; if (connected == n) { return true; @@ -577,7 +577,7 @@ bool Node::InputsFrom(const QString &id, bool recursively) const { foreach (NodeInput* input, inputs_) { for (auto it=input->edges().cbegin(); it!=input->edges().cend(); it++) { - Node* connected = it.value(); + Node* connected = it->second; if (connected->id() == id) { return true; @@ -615,8 +615,8 @@ int Node::GetRoutesTo(Node *n) const void Node::DisconnectAll() { // Disconnect outputs (inputs will be disconnected in their respective destructors) - while (!edges().isEmpty()) { - DisconnectEdge(this, edges().first().input, edges().first().element); + while (!edges().empty()) { + DisconnectEdge(this, edges().front().input, edges().front().element); } } @@ -661,8 +661,8 @@ QVector Node::TransformTimeTo(const TimeRange &time, Node *target, bo // If this input is connected, traverse it to see if we stumble across the specified `node` foreach (NodeInput* input, inputs_) { for (auto it=input->edges().cbegin(); it!=input->edges().cend(); it++) { - TimeRange input_adjustment = InputTimeAdjustment(input, it.key(), time); - Node* connected = it.value(); + TimeRange input_adjustment = InputTimeAdjustment(input, it->first, time); + Node* connected = it->second; if (connected == target) { // We found the target, no need to keep traversing diff --git a/app/node/node.h b/app/node/node.h index 00d98dc70..abaad408d 100644 --- a/app/node/node.h +++ b/app/node/node.h @@ -396,7 +396,7 @@ public: virtual void Hash(QCryptographicHash& hash, const rational &time) const; - const QVector& edges() const + const std::vector& edges() const { return output_connections(); } @@ -491,7 +491,8 @@ template void Node::FindInputNodeInternal(const Node* n, QVector &list) { foreach (NodeInput* input, n->inputs_) { - foreach (Node* edge, input->edges()) { + for (auto it=input->edges().cbegin(); it!=input->edges().cend(); it++) { + Node* edge = it->second; T* cast_test = dynamic_cast(edge); if (cast_test) { diff --git a/app/render/previewautocacher.cpp b/app/render/previewautocacher.cpp index 608fdabdf..88ad8a65c 100644 --- a/app/render/previewautocacher.cpp +++ b/app/render/previewautocacher.cpp @@ -679,7 +679,7 @@ void PreviewAutoCacher::SetViewerNode(ViewerOutput *viewer_node) foreach (Node* node, graph->nodes()) { foreach (NodeInput* input, node->inputs()) { for (auto it=input->edges().cbegin(); it!=input->edges().cend(); it++) { - AddEdge(it.value(), input, it.key()); + AddEdge(it->second, input, it->first); } } }