@@ -169,6 +169,7 @@ void NoteRelationScene::drawForNote(const Note ¬e) {
169
169
// Allow drawing again and clear the scene
170
170
setAllowDrawing ();
171
171
m_connections.clear ();
172
+ m_noteItems.clear ();
172
173
clear ();
173
174
174
175
// This runs the gathering of note relations in a different thread
@@ -183,6 +184,8 @@ void NoteRelationScene::drawForNote(const Note ¬e) {
183
184
QSqlDatabase db = DatabaseService::createSharedMemoryDatabase (connectionName);
184
185
185
186
auto rootNoteItem = createNoteItem (QPointF (100 , 100 ), note);
187
+ m_noteItems[note.getId ()] = rootNoteItem;
188
+
186
189
createLinkedNoteItems (noteList, connectionName, note, rootNoteItem);
187
190
188
191
// Update all connections
@@ -243,9 +246,16 @@ void NoteRelationScene::createLinkedNoteItems(const QVector<Note> ¬eList,
243
246
// Calculate position in a circle around the root note item
244
247
QPointF notePos = calculateRadialPosition (rootCenter, index , linkedNotes.size (), radius);
245
248
const Note &linkedNote = it.key ();
249
+ int linkedNoteId = linkedNote.getId ();
250
+
251
+ // Check if note item already exists
252
+ NoteItem *linkedNoteItem = m_noteItems[linkedNoteId];
246
253
247
- // Create note item at calculated position
248
- NoteItem *linkedNoteItem = createNoteItem (notePos, linkedNote, level);
254
+ if (linkedNoteItem == nullptr ) {
255
+ // Create note item at calculated position
256
+ linkedNoteItem = createNoteItem (notePos, linkedNote, level);
257
+ m_noteItems[linkedNoteId] = linkedNoteItem;
258
+ }
249
259
250
260
// Create connection between root and this note
251
261
createConnection (rootNoteItem, linkedNoteItem);
0 commit comments