improve performance building data tree
This commit is contained in:
parent
9463ed1e6c
commit
0046d04683
@ -61,7 +61,7 @@ class DataTree(QtWidgets.QTreeWidget):
|
|||||||
|
|
||||||
self.update_indexes()
|
self.update_indexes()
|
||||||
|
|
||||||
def add_item(self, items: (tuple | list[tuple]), gid: str):
|
def add_item(self, items: (tuple | list[tuple]), gid: str, update: bool = True):
|
||||||
if isinstance(items, tuple):
|
if isinstance(items, tuple):
|
||||||
items = [items]
|
items = [items]
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ class DataTree(QtWidgets.QTreeWidget):
|
|||||||
|
|
||||||
self.resizeColumnToContents(0)
|
self.resizeColumnToContents(0)
|
||||||
break
|
break
|
||||||
|
if update:
|
||||||
self.update_indexes()
|
self.update_indexes()
|
||||||
|
|
||||||
@QtCore.pyqtSlot(QtWidgets.QTreeWidgetItem)
|
@QtCore.pyqtSlot(QtWidgets.QTreeWidgetItem)
|
||||||
@ -566,9 +566,9 @@ class DataWidget(QtWidgets.QWidget, Ui_DataWidget):
|
|||||||
self.tree.add_graph(idd, name)
|
self.tree.add_graph(idd, name)
|
||||||
self.tree.blockSignals(False)
|
self.tree.blockSignals(False)
|
||||||
|
|
||||||
def add_item(self, idd: str, name: str, value: str, gid: str):
|
def add_item(self, idd: str, name: str, value: str, gid: str, update: bool= True):
|
||||||
self.tree.blockSignals(True)
|
self.tree.blockSignals(True)
|
||||||
self.tree.add_item((idd, name, value), gid)
|
self.tree.add_item((idd, name, value), gid, update=update)
|
||||||
self.tree.blockSignals(False)
|
self.tree.blockSignals(False)
|
||||||
|
|
||||||
def add_item_list(self, loi: list, gid: str):
|
def add_item_list(self, loi: list, gid: str):
|
||||||
|
@ -207,7 +207,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
else:
|
else:
|
||||||
QtWidgets.QMessageBox.warning(self, 'Display disabled',
|
QtWidgets.QMessageBox.warning(self, 'Display disabled',
|
||||||
'If more than 200 sets are added at once, they are not displayed to avoid major performance issues.\n'
|
'If more than 200 sets are added at once, they are not displayed to avoid major performance issues.\n'
|
||||||
'Building the data tree may still take some time, the checkmark on the left is invalid.\n'
|
'The checkmark in the data tree is invalid.\n'
|
||||||
'Please display them manually in smaller batches, thank you!')
|
'Please display them manually in smaller batches, thank you!')
|
||||||
|
|
||||||
def remove(self, name: str | list):
|
def remove(self, name: str | list):
|
||||||
|
@ -353,8 +353,9 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
|||||||
for idd in sets:
|
for idd in sets:
|
||||||
new_item = self.management[idd]
|
new_item = self.management[idd]
|
||||||
self.datawidget.blockSignals(True)
|
self.datawidget.blockSignals(True)
|
||||||
self.datawidget.add_item(new_item.id, new_item.name, new_item.value, graph)
|
self.datawidget.add_item(new_item.id, new_item.name, new_item.value, graph, update=False)
|
||||||
self.datawidget.blockSignals(False)
|
self.datawidget.blockSignals(False)
|
||||||
|
self.datawidget.tree.update_indexes()
|
||||||
|
|
||||||
# if graph == self.fit_dialog.connected_figure:
|
# if graph == self.fit_dialog.connected_figure:
|
||||||
# self.fit_dialog.load(self.management.graphs.active(graph))
|
# self.fit_dialog.load(self.management.graphs.active(graph))
|
||||||
|
Loading…
Reference in New Issue
Block a user