Exemple #1
0
 def setModelData(self, editor: QtWidgets.QWidget, model: QtCore.QAbstractItemModel,
                  index: QtCore.QModelIndex):
     """ Take the editor, read the given value and set it in the model
     """
     dialog = editor.findChild(OrderedListInputDialog)
     value = dialog.items_selected()
     model.setData(index, value, QtCore.Qt.EditRole)
Exemple #2
0
    def setModelData(self, editor: QtWidgets.QWidget,
                     model: QtCore.QAbstractItemModel,
                     index: QtCore.QModelIndex):
        """ Take the editor, read the given value and set it in the model.

        If the new formula is the same as the existing one, do not call setData
        """
        dialog = editor.findChild(FormulaDialog)
        if dialog.result() == QtWidgets.QDialog.Rejected:
            # Cancel was clicked, do not store anything.
            return
        model.setData(index, dialog.formula, QtCore.Qt.EditRole)
Exemple #3
0
    def setEditorData(self, editor: QtWidgets.QWidget, index: QtCore.QModelIndex):
        """ Populate the editor with data if editing an existing field.
        """
        dialog = editor.findChild(OrderedListInputDialog)
        value = index.data(QtCore.Qt.DisplayRole)
        values = [] if not value else [i.lstrip() for i in value.split(",")]

        parent = self.parent()
        if getattr(parent, "table_name") == "activity_parameter":
            groups = parent.get_activity_groups(index, values)
            unchecked = dialog.add_items_value(groups)
            checked = dialog.add_items_value(values, True)
            dialog.set_items(checked + unchecked)
Exemple #4
0
    def setEditorData(self, editor: QtWidgets.QWidget,
                      index: QtCore.QModelIndex):
        """ Populate the editor with data if editing an existing field.
        """
        dialog = editor.findChild(FormulaDialog)
        data = index.data(QtCore.Qt.DisplayRole)

        parent = self.parent()
        # Check which table is asking for a list
        if getattr(parent, "table_name", "") in self.ACCEPTED_TABLES:
            items = parent.get_usable_parameters()
            dialog.insert_parameters(items)
            dialog.formula = data
            interpreter = parent.get_interpreter()
            dialog.insert_interpreter(interpreter)
            # Now see if we can construct a (partial) key
            if hasattr(parent, "key"):
                # This works for exchange tables.
                dialog.insert_key(parent.key)
            elif hasattr(parent, "get_key"):
                dialog.insert_key(parent.get_key())