From 5e55f067237aae1d30f4c7f91df6e81160e31b11 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Thu, 7 Sep 2023 19:30:10 +0200 Subject: [PATCH] add completer to general fit linedit --- src/gui_qt/fit/fit_forms.py | 23 ++++++++++++++++++----- src/gui_qt/fit/fit_parameter.py | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/gui_qt/fit/fit_forms.py b/src/gui_qt/fit/fit_forms.py index 983a0db..d49fac9 100644 --- a/src/gui_qt/fit/fit_forms.py +++ b/src/gui_qt/fit/fit_forms.py @@ -19,8 +19,6 @@ class FitModelWidget(QtWidgets.QWidget, Ui_FitParameter): self.parametername.setText(label + ' ') - # validator = QtGui.QDoubleValidator() - # validator.setDecimals(9) # self.parameter_line.setValidator(validator) self.parameter_line.setText('1') self.parameter_line.setMaximumWidth(60) @@ -38,15 +36,21 @@ class FitModelWidget(QtWidgets.QWidget, Ui_FitParameter): if fixed: self.fixed_check.hide() - self.menu = QtWidgets.QMenu(self) - self.add_links() - self.is_linked = None self.parameter_pos = None self.func_idx = None self._linetext = '1' + self.completer = QtWidgets.QCompleter() + self.completer.setCompletionMode(QtWidgets.QCompleter.UnfilteredPopupCompletion) + self.parameter_hint_model = QtGui.QStandardItemModel() + self.completer.setModel(self.parameter_hint_model) + self.parameter_line.setCompleter(self.completer) + + self.menu = QtWidgets.QMenu(self) + self.add_links() + @property def name(self): return convert(self.parametername.text().strip(), old='html', new='str') @@ -130,16 +134,25 @@ class FitModelWidget(QtWidgets.QWidget, Ui_FitParameter): parameter = {} self.menu.clear() + self.parameter_hint_model.clear() + ac = QtWidgets.QAction('Link to...', self) ac.triggered.connect(self.link_parameter) self.menu.addAction(ac) for model_key, model_funcs in parameter.items(): m = QtWidgets.QMenu('Model ' + model_key, self) + hint_key = model_key + for func_name, func_params in model_funcs.items(): m2 = QtWidgets.QMenu(func_name, m) + hint_key += f'.{func_name}' for p_name, idx in func_params: ac = QtWidgets.QAction(p_name, m2) + hint_key += f'.{p_name}' + item = QtGui.QStandardItem(hint_key) + item.setData((model_key, *idx)) + self.parameter_hint_model.appendRow(item) ac.setData((model_key, *idx)) ac.triggered.connect(self.link_parameter) m2.addAction(ac) diff --git a/src/gui_qt/fit/fit_parameter.py b/src/gui_qt/fit/fit_parameter.py index b461d23..7c75f73 100644 --- a/src/gui_qt/fit/fit_parameter.py +++ b/src/gui_qt/fit/fit_parameter.py @@ -339,7 +339,7 @@ class ParameterSingleWidget(QtWidgets.QWidget): # self.value_line.setText(f'{float(val):.5g}') self.value_line.setText(f'{val}') - def show_as_local_parameter(self, is_local): + def show_as_local_parameter(self, is_local: bool): if is_local: self.label.setStyleSheet('font-weight: bold;') else: