eval expression reuses ListWidgetItems of datasets; closes #31
This commit is contained in:
parent
ee8ea4f2c5
commit
3b79c571fb
@ -944,7 +944,6 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
def extend_fit(self, sets: list):
|
||||
w = FitExtension(self)
|
||||
res = w.exec()
|
||||
print(res)
|
||||
if res:
|
||||
p = w.values
|
||||
x = linspace(p[0], p[1], num=p[2])
|
||||
|
@ -31,14 +31,37 @@ class QEvalDialog(QtWidgets.QDialog, Ui_CalcDialog):
|
||||
self.namespace_widget.set_namespace(self.namespace)
|
||||
|
||||
def add_data(self, data):
|
||||
self.listWidget.clear()
|
||||
# self.listWidget.clear()
|
||||
tmp = []
|
||||
while self.listWidget.count():
|
||||
tmp.append(self.listWidget.takeItem(0))
|
||||
|
||||
for set_id, name in data:
|
||||
|
||||
# search if set was used before
|
||||
new_one = True
|
||||
for i in range(len(tmp)):
|
||||
w = tmp[i]
|
||||
if w.data(QtCore.Qt.UserRole) == set_id:
|
||||
|
||||
self.listWidget.addItem(w)
|
||||
tmp.pop(i)
|
||||
new_one = False
|
||||
break
|
||||
|
||||
# new set, create item
|
||||
if new_one:
|
||||
item = QtWidgets.QListWidgetItem(name)
|
||||
item.setData(QtCore.Qt.UserRole, set_id)
|
||||
item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable)
|
||||
item.setCheckState(QtCore.Qt.Checked)
|
||||
self.listWidget.addItem(item)
|
||||
|
||||
while len(tmp):
|
||||
# delete remaining ListWidgetItems
|
||||
w = tmp.pop()
|
||||
w.deleteLater()
|
||||
|
||||
def set_graphs(self, graphs: list):
|
||||
self.graph_comboBox.clear()
|
||||
self.graph_comboBox.addItem('New graph', userData='')
|
||||
|
Loading…
Reference in New Issue
Block a user