1
0
forked from IPKM/nmreval

UpperManagement.deleteDate emits list of sets, indexes in datawidget are now only updated once

This commit is contained in:
Dominik Demuth 2023-04-15 15:40:49 +02:00
parent e41c42d573
commit bd8a4f16ea
4 changed files with 25 additions and 15 deletions

View File

@ -20,6 +20,7 @@ class DataTree(QtWidgets.QTreeWidget):
saveFits = QtCore.pyqtSignal(list) saveFits = QtCore.pyqtSignal(list)
extendFits = QtCore.pyqtSignal(list) extendFits = QtCore.pyqtSignal(list)
# noinspection PyUnresolvedReferences
def __init__(self, parent=None): def __init__(self, parent=None):
super().__init__(parent=parent) super().__init__(parent=parent)
@ -248,7 +249,6 @@ class DataTree(QtWidgets.QTreeWidget):
self.blockSignals(False) self.blockSignals(False)
def update_indexes(self): def update_indexes(self):
graph_cnt = -1 graph_cnt = -1
set_cnt = 0 set_cnt = 0
@ -343,7 +343,7 @@ class DataTree(QtWidgets.QTreeWidget):
self.setDragEnabled(idx.column() == 0) self.setDragEnabled(idx.column() == 0)
super().mousePressEvent(evt) super().mousePressEvent(evt)
def remove_item(self, ids: list): def remove_item(self, ids: list[str]):
iterator = QtWidgets.QTreeWidgetItemIterator(self) iterator = QtWidgets.QTreeWidgetItemIterator(self)
while iterator.value(): while iterator.value():
item = iterator.value() item = iterator.value()
@ -527,6 +527,7 @@ class DataWidget(QtWidgets.QWidget, Ui_DataWidget):
self.setupUi(self) self.setupUi(self)
self.tree = DataTree(self) self.tree = DataTree(self)
self.verticalLayout.addWidget(self.tree) self.verticalLayout.addWidget(self.tree)
# noinspection PyUnresolvedReferences
self.tree.selectionModel().selectionChanged.connect(lambda x, y: self.show_property(x)) self.tree.selectionModel().selectionChanged.connect(lambda x, y: self.show_property(x))
self.tree.keyChanged.connect(lambda x, y: self.keyChanged.emit(x, y)) self.tree.keyChanged.connect(lambda x, y: self.keyChanged.emit(x, y))
@ -554,7 +555,7 @@ class DataWidget(QtWidgets.QWidget, Ui_DataWidget):
self.tree.add_item(loi, gid) self.tree.add_item(loi, gid)
self.tree.blockSignals(False) self.tree.blockSignals(False)
def remove_item(self, key): def remove_item(self, key: list[str]):
self.tree.remove_item(key) self.tree.remove_item(key)
def show_property(self, _: QtCore.QModelIndex = None): def show_property(self, _: QtCore.QModelIndex = None):

View File

@ -236,9 +236,9 @@ class DeleteCommand(QtWidgets.QUndoCommand):
# stop graph from rescaling and updating legend # stop graph from rescaling and updating legend
self.__graph_container[self.__graph_key].block(True) self.__graph_container[self.__graph_key].block(True)
self.__signal_remove.emit(list(self.__keys[::-1]))
for sid in self.__keys[::-1]: for sid in self.__keys[::-1]:
val = self.__value[sid] val = self.__value[sid]
self.__signal_remove.emit(sid)
if isinstance(val, FitContainer): if isinstance(val, FitContainer):
try: try:
@ -264,7 +264,7 @@ class DeleteCommand(QtWidgets.QUndoCommand):
except KeyError: except KeyError:
pass pass
self.__signal_add.emit([sid], val.graph) self.__signal_add.emit(list(self.__keys), self.__graph_key)
self.__graph_container[self.__graph_key].block(False) self.__graph_container[self.__graph_key].block(False)

View File

@ -348,7 +348,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def remove_graph(self, gid: str): def remove_graph(self, gid: str):
self.datawidget.remove_item(gid) self.datawidget.remove_item([gid])
val_figure = self.valuewidget.connected_figure val_figure = self.valuewidget.connected_figure
self.valuewidget.remove_graph() self.valuewidget.remove_graph()
@ -733,9 +733,10 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
self.datawidget.set_name(sid, self.management[sid].name) self.datawidget.set_name(sid, self.management[sid].name)
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(list)
def delete_data(self, sid): def delete_data(self, sid: list[str]):
if self.valuewidget.shown_set == sid: for key in sid:
if self.valuewidget.shown_set == key:
self.tabWidget.setCurrentIndex(0) self.tabWidget.setCurrentIndex(0)
self.datawidget.remove_item(sid) self.datawidget.remove_item(sid)

View File

@ -75,7 +75,7 @@ class UpperManagement(QtCore.QObject):
restoreGraph = QtCore.pyqtSignal(str) restoreGraph = QtCore.pyqtSignal(str)
deleteGraph = QtCore.pyqtSignal(str) deleteGraph = QtCore.pyqtSignal(str)
newData = QtCore.pyqtSignal(list, str) newData = QtCore.pyqtSignal(list, str)
deleteData = QtCore.pyqtSignal(str) deleteData = QtCore.pyqtSignal(list)
dataChanged = QtCore.pyqtSignal(str) dataChanged = QtCore.pyqtSignal(str)
fitFinished = QtCore.pyqtSignal(list) fitFinished = QtCore.pyqtSignal(list)
stopFit = QtCore.pyqtSignal() stopFit = QtCore.pyqtSignal()
@ -234,9 +234,17 @@ class UpperManagement(QtCore.QObject):
for k in plotkeys: for k in plotkeys:
self.data[k].graph = gid self.data[k].graph = gid
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(list)
def plot_from_graph(self, key: str): def plot_from_graph(self, key: list[str]):
self.graphs[self.data[key].graph].remove(key) sort_graph = {}
for sid in key:
v = self.data[sid].graph
if v not in sort_graph:
sort_graph[v] = []
sort_graph[v].append(sid)
for gid, sets in sort_graph.items():
self.graphs[gid].remove(sets)
@QtCore.pyqtSlot(list, str, str) @QtCore.pyqtSlot(list, str, str)
def move_sets(self, sets: list, dest: str, src: (str|list), pos: int = -1): def move_sets(self, sets: list, dest: str, src: (str|list), pos: int = -1):