@@ -182,50 +182,45 @@ class NODE_EDITOR_PUBLIC BasicGraphicsScene : public QGraphicsScene
182182 */
183183 void removeNodeFromGroup (NodeId nodeId);
184184
185+ /* *
186+ * @brief Loads serialized item (nodes, connections and groups) into the scene.
187+ * @param data Serialized scene payload.
188+ * @param pastePos Reference position used when pasting content.
189+ * @param usePastePos When true, places the loaded content relative to pastePos position.
190+ * @return Mapping between original node UUIDs and newly created node UUIDs.
191+ */
185192 std::unordered_map<QUuid, QUuid> loadItems (const QByteArray &data,
186193 QPointF pastePos,
187194 bool usePastePos = true );
188195
196+ /* *
197+ * @brief Loads scene data from memory.
198+ * @param data Serialized scene payload.
199+ * @return Mapping between original node UUIDs and newly created node UUIDs.
200+ */
189201 std::unordered_map<QUuid, QUuid> loadFromMemory (const QByteArray &data);
190202
191- QUuid encodeNodeId (NodeId nodeId)
192- {
193- QByteArray bytes (16 , 0 );
194- QDataStream stream (&bytes, QIODevice::WriteOnly);
195- stream << static_cast <quint32>(nodeId);
196- return QUuid::fromRfc4122 (bytes);
197- }
198-
199- NodeId decodeNodeUuid (QUuid const &uuid)
200- {
201- auto bytes = uuid.toRfc4122 ();
202- if (bytes.size () < static_cast <int >(sizeof (quint32)))
203- return QtNodes::InvalidNodeId;
204-
205- QDataStream stream (bytes);
206- quint32 value = 0 ;
207- stream >> value;
208- return static_cast <NodeId>(value);
209- }
210-
211- std::unordered_map<NodeId, NodeId> convertMap (std::unordered_map<QUuid, QUuid> const &uuidMap)
212- {
213- std::unordered_map<NodeId, NodeId> idMap;
214-
215- // Iterando pelo mapa de QUuids e convertendo para NodeIds
216- for (const auto &pair : uuidMap) {
217- // Decodificando os QUuids para NodeIds
218- NodeId keyNodeId = decodeNodeUuid (pair.first );
219- NodeId valueNodeId = decodeNodeUuid (pair.second );
220-
221- // Inserindo no novo mapa
222- if (keyNodeId != QtNodes::InvalidNodeId && valueNodeId != QtNodes::InvalidNodeId) {
223- idMap[keyNodeId] = valueNodeId;
224- }
225- }
226-
227- return idMap;
228- }
203+ /* *
204+ * @brief Encodes NodeId into a QUuid representation.
205+ * @param nodeId Node identifier.
206+ * @return QUuid carrying the binary value of nodeId.
207+ */
208+ QUuid encodeNodeId (NodeId nodeId);
209+
210+ /* *
211+ * @brief Decodes a node QUuid into a NodeId.
212+ * @param uuid QUuid containing an encoded node id.
213+ * @return Decoded NodeId.
214+ */
215+ NodeId decodeNodeUuid (QUuid const &uuid);
216+
217+ /* *
218+ * @brief Converts a QUuid-to-QUuid map into a NodeId-to-NodeId map.
219+ * @param uuidMap Map containing encoded old and new node QUuid pairs.
220+ * @return Map with decoded NodeId pairs, excluding invalid entries.
221+ */
222+
223+ std::unordered_map<NodeId, NodeId> convertMap (std::unordered_map<QUuid, QUuid> const &uuidMap);
229224
230225public:
231226 /* *
0 commit comments