| 133 | |
| 134 | |
| 135 | std::shared_ptr<Connection> |
| 136 | FlowScene:: |
| 137 | restoreConnection(QJsonObject const &connectionJson) |
| 138 | { |
| 139 | QUuid nodeInId = QUuid(connectionJson["in_id"].toString()); |
| 140 | QUuid nodeOutId = QUuid(connectionJson["out_id"].toString()); |
| 141 | |
| 142 | PortIndex portIndexIn = connectionJson["in_index"].toInt(); |
| 143 | PortIndex portIndexOut = connectionJson["out_index"].toInt(); |
| 144 | |
| 145 | auto nodeIn = _nodes[nodeInId].get(); |
| 146 | auto nodeOut = _nodes[nodeOutId].get(); |
| 147 | |
| 148 | auto getConverter = [&]() |
| 149 | { |
| 150 | QJsonValue converterVal = connectionJson["converter"]; |
| 151 | |
| 152 | if (!converterVal.isUndefined()) |
| 153 | { |
| 154 | QJsonObject converterJson = converterVal.toObject(); |
| 155 | |
| 156 | NodeDataType inType { converterJson["in"].toObject()["id"].toString(), |
| 157 | converterJson["in"].toObject()["name"].toString() }; |
| 158 | |
| 159 | NodeDataType outType { converterJson["out"].toObject()["id"].toString(), |
| 160 | converterJson["out"].toObject()["name"].toString() }; |
| 161 | |
| 162 | auto converter = |
| 163 | registry().getTypeConverter(outType, inType); |
| 164 | |
| 165 | if (converter) |
| 166 | return converter; |
| 167 | } |
| 168 | |
| 169 | return TypeConverter{}; |
| 170 | }; |
| 171 | |
| 172 | if( !nodeIn || !nodeOut) |
| 173 | { |
| 174 | qDebug() << "ERROR: invalid connection with UIDS " |
| 175 | << nodeInId << " and " << nodeOutId; |
| 176 | |
| 177 | return std::shared_ptr<Connection>(); |
| 178 | } |
| 179 | |
| 180 | std::shared_ptr<Connection> connection = |
| 181 | createConnection(*nodeIn, portIndexIn, |
| 182 | *nodeOut, portIndexOut, |
| 183 | getConverter()); |
| 184 | |
| 185 | connectionCreated(*connection); |
| 186 | |
| 187 | connection->connectionGeometry().setPortLayout( layout() ); |
| 188 | return connection; |
| 189 | } |
| 190 | |
| 191 | |
| 192 | void |
nothing calls this directly
no test coverage detected