From 40a9f8befbff199173a921b5ab84b876b871fff7 Mon Sep 17 00:00:00 2001 From: AccentuSoft Date: Thu, 14 Apr 2022 04:08:42 +0300 Subject: [PATCH] Fix bug with importing only links not working properly if fields are left out. Fix bug with scenes not being always redrawn if links are imported. --- Core/Interface/CentralPane.py | 9 ++-- Core/Interface/MenuBar.py | 80 ++++++++++++++++++----------------- 2 files changed, 44 insertions(+), 45 deletions(-) diff --git a/Core/Interface/CentralPane.py b/Core/Interface/CentralPane.py index 00af656..8dc4b33 100644 --- a/Core/Interface/CentralPane.py +++ b/Core/Interface/CentralPane.py @@ -460,7 +460,6 @@ class TabbedPane(QtWidgets.QTabWidget): linkGroupingOverride: bool = False) -> None: for canvas in self.canvasTabs: scene = self.canvasTabs[canvas].scene() - sceneChanged = False with scene.resolutionThreadingLock: addedNodes = [] @@ -469,8 +468,6 @@ class TabbedPane(QtWidgets.QTabWidget): parentUID = newLink[0] if parentUID in scene.nodesDict and uid not in scene.nodesDict: if uid not in scene.sceneGraph.nodes: - sceneChanged = True - nodeJSON = self.entityDB.getEntity(uid) # This is more efficient for large canvases than syncing afterwards. @@ -507,9 +504,9 @@ class TabbedPane(QtWidgets.QTabWidget): [scene.removeNode(item) for item in addedNodes] scene.addNodeProgrammatic(uid, itemUIDs, fromServer=True) - if sceneChanged: - scene.rearrangeGraph() - # self.mainWindow.syncCanvasByName(canvas) + # Even if nothing is added, the graph could need to be rearranged for clarity. + scene.rearrangeGraph() + # self.mainWindow.syncCanvasByName(canvas) def serverLinkAddHelper(self, linkJson: dict, overwrite: bool = False) -> None: """ diff --git a/Core/Interface/MenuBar.py b/Core/Interface/MenuBar.py index 6d562fe..58ab808 100644 --- a/Core/Interface/MenuBar.py +++ b/Core/Interface/MenuBar.py @@ -656,50 +656,52 @@ class MenuBar(QtWidgets.QMenuBar): newLinks.append((entityOneJSON['uid'], entityTwoJSON['uid'], linkJSONThree['Resolution'])) - else: - entityOneType = importLinksCSVDialog.entityOneTypeChoiceDropdown.currentText() - entityTwoType = importLinksCSVDialog.entityTwoTypeChoiceDropdown.currentText() + else: + entityOneType = importLinksCSVDialog.entityOneTypeChoiceDropdown.currentText() + entityTwoType = importLinksCSVDialog.entityTwoTypeChoiceDropdown.currentText() - for row in csvDF.itertuples(index=False): - count = 0 - linkJSON = {} - entityOneJSON = {} - entityTwoJSON = {} - resolutionID = "" - notes = "" + for row in csvDF.itertuples(index=False): + count = 0 + linkJSON = {} + entityOneJSON = {} + entityTwoJSON = {} + resolutionID = "" + notes = "" - for column in row: - column = str(column) - mapping = csvDF.columns[count] - if mapping == 'Entity One': - entityOneJSON = self.parent().LENTDB.getEntityOfType(column, entityOneType) - elif mapping == 'Entity Two': - entityTwoJSON = self.parent().LENTDB.getEntityOfType(column, entityTwoType) - elif mapping == 'Notes': - notes = column - elif mapping == 'Resolution ID': - resolutionID = column - else: - linkJSON[mapping] = column - count += 1 + for column in row: + column = str(column) + mapping = csvDF.columns[count] + if mapping == 'Entity One': + entityOneJSON = self.parent().LENTDB.getEntityOfType(column, + entityOneType) + elif mapping == 'Entity Two': + entityTwoJSON = self.parent().LENTDB.getEntityOfType(column, + entityTwoType) + elif mapping == 'Notes': + notes = column + elif mapping == 'Resolution ID': + resolutionID = column + else: + linkJSON[mapping] = column + count += 1 - if (entityOneJSON is not None) and (entityTwoJSON is not None): - linkJSON['uid'] = (entityOneJSON['uid'], entityTwoJSON['uid']) - linkJSON['Notes'] = notes - if importLinksCSVDialog.randAsIs.isChecked(): - linkJSON['Resolution'] = resolutionID - elif importLinksCSVDialog.randMerge.isChecked(): - linkJSON['Resolution'] = resolutionID + ' | ' + str(uuid4()) - elif importLinksCSVDialog.randReplace.isChecked(): - linkJSON['Resolution'] = str(uuid4()) + if (entityOneJSON is not None) and (entityTwoJSON is not None): + linkJSON['uid'] = (entityOneJSON['uid'], entityTwoJSON['uid']) + linkJSON['Notes'] = notes + if importLinksCSVDialog.randAsIs.isChecked(): + linkJSON['Resolution'] = resolutionID + elif importLinksCSVDialog.randMerge.isChecked(): + linkJSON['Resolution'] = resolutionID + ' | ' + str(uuid4()) + elif importLinksCSVDialog.randReplace.isChecked(): + linkJSON['Resolution'] = str(uuid4()) - # If 'Resolution ID' is not mapped, generate random IDs. - if not linkJSON.get('Resolution'): - linkJSON['Resolution'] = str(uuid4()) + # If 'Resolution ID' is not mapped, generate random IDs. + if not linkJSON.get('Resolution'): + linkJSON['Resolution'] = str(uuid4()) - if self.parent().LENTDB.addLink(linkJSON) is not None: - newLinks.append((entityOneJSON['uid'], entityTwoJSON['uid'], - linkJSON['Resolution'])) + if self.parent().LENTDB.addLink(linkJSON) is not None: + newLinks.append((entityOneJSON['uid'], entityTwoJSON['uid'], + linkJSON['Resolution'])) newNodeUIDs = [newEntity['uid'] for newEntity in self.parent().LENTDB.addEntities(newNodes)]