remove duplicates of keys in deletion; may help with #36

This commit is contained in:
Dominik Demuth 2023-04-08 17:16:05 +02:00
parent 0ec0021727
commit ffecc9c873
2 changed files with 12 additions and 3 deletions

View File

@ -287,13 +287,20 @@ class DataTree(QtWidgets.QTreeWidget):
for idx in self.selectedIndexes(): for idx in self.selectedIndexes():
if idx.column() == 1: if idx.column() == 1:
continue continue
item = self.itemFromIndex(idx) item = self.itemFromIndex(idx)
if item.parent() is None: if item.parent() is None:
for c_i in range(item.childCount()): for c_i in range(item.childCount()):
rm_sets.append(item.child(c_i).data(0, QtCore.Qt.UserRole)) # add sets inside graph to removal
child_data = item.child(c_i).data(0, QtCore.Qt.UserRole)
if child_data not in rm_sets:
rm_sets.append(child_data)
rm_graphs.append(item.data(0, QtCore.Qt.UserRole)) rm_graphs.append(item.data(0, QtCore.Qt.UserRole))
else: else:
rm_sets.append(item.data(0, QtCore.Qt.UserRole)) item_data = item.data(0, QtCore.Qt.UserRole)
if item_data not in rm_sets:
rm_sets.append(item_data)
# self.deleteItem.emit(rm_sets+rm_graphs) # self.deleteItem.emit(rm_sets+rm_graphs)
self.management.delete_sets(rm_sets+rm_graphs) self.management.delete_sets(rm_sets+rm_graphs)

View File

@ -291,8 +291,10 @@ class UpperManagement(QtCore.QObject):
if k in self.data: if k in self.data:
cmd = DeleteCommand(self.data, k, self.newData, self.deleteData) cmd = DeleteCommand(self.data, k, self.newData, self.deleteData)
self.undostack.push(cmd) self.undostack.push(cmd)
else: elif k in self.graphs:
rm_graphs.append(k) rm_graphs.append(k)
else:
logger.warning(f'delete_sets: {k} is not in data or graph found')
for k in rm_graphs: for k in rm_graphs:
cmd = DeleteGraphCommand(self.graphs, k, self.restoreGraph, self.deleteGraph) cmd = DeleteGraphCommand(self.graphs, k, self.restoreGraph, self.deleteGraph)