1
0
forked from IPKM/nmreval

undo of sets were missing from graph delete undo

This commit is contained in:
Dominik Demuth 2023-11-29 18:03:54 +01:00
parent 0c7ca0b9ba
commit 386bc5a371

View File

@ -302,6 +302,7 @@ class UpperManagement(QtCore.QObject):
@QtCore.pyqtSlot()
def delete_sets(self, rm_sets: list = None):
rm_graphs = []
print(rm_sets)
if rm_sets is None:
rm_sets = self.graphs[self.current_graph].sets + [self.current_graph]
@ -314,21 +315,27 @@ class UpperManagement(QtCore.QObject):
if k in self.data:
parent_graph = self.data[k].graph
if parent_graph not in rm_set_by_graph:
rm_set_by_graph[parent_graph] = []
rm_set_by_graph[parent_graph] = set()
rm_set_by_graph[parent_graph].append(k)
rm_set_by_graph[parent_graph].add(k)
elif k in self.graphs:
rm_graphs.append(k)
if k not in rm_set_by_graph:
rm_set_by_graph[k] = set()
for ss in self.graphs[k].sets:
rm_set_by_graph[k].add(ss)
else:
logger.warning(f'delete_sets: {k} is not in data or graph found')
for gid, sid_list in rm_set_by_graph.items():
cmd = DeleteCommand(self.data, sid_list, self.graphs, gid, self.newData, self.deleteData)
print('delete set')
cmd = DeleteCommand(self.data, list(sid_list), self.graphs, gid, self.newData, self.deleteData)
self.undostack.push(cmd)
for k in rm_graphs:
print('delete graphs')
cmd = DeleteGraphCommand(self.graphs, k, self.restoreGraph, self.deleteGraph)
self.undostack.push(cmd)