forked from IPKM/nmreval
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):
|
def extend_fit(self, sets: list):
|
||||||
w = FitExtension(self)
|
w = FitExtension(self)
|
||||||
res = w.exec()
|
res = w.exec()
|
||||||
print(res)
|
|
||||||
if res:
|
if res:
|
||||||
p = w.values
|
p = w.values
|
||||||
x = linspace(p[0], p[1], num=p[2])
|
x = linspace(p[0], p[1], num=p[2])
|
||||||
|
@ -31,13 +31,36 @@ class QEvalDialog(QtWidgets.QDialog, Ui_CalcDialog):
|
|||||||
self.namespace_widget.set_namespace(self.namespace)
|
self.namespace_widget.set_namespace(self.namespace)
|
||||||
|
|
||||||
def add_data(self, data):
|
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:
|
for set_id, name in data:
|
||||||
item = QtWidgets.QListWidgetItem(name)
|
|
||||||
item.setData(QtCore.Qt.UserRole, set_id)
|
# search if set was used before
|
||||||
item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable)
|
new_one = True
|
||||||
item.setCheckState(QtCore.Qt.Checked)
|
for i in range(len(tmp)):
|
||||||
self.listWidget.addItem(item)
|
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):
|
def set_graphs(self, graphs: list):
|
||||||
self.graph_comboBox.clear()
|
self.graph_comboBox.clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user