Example #1
0
    def setModelData(self, editor, model, index):  #pylint: disable=invalid-name
        """Take the value in the combo box and write it to the model."""
        if not index.isValid():
            return

        if not isinstance(model, QSqlRelationalTableModel):
            proxy_model = model
            source_model = proxy_model.sourceModel()
            self.setModelData(editor, source_model,
                              proxy_model.mapToSource(index))
            return

        sql_model = model
        child_model = sql_model.relationModel(index.column())

        combobox = editor

        if not child_model or not combobox:
            QItemDelegate.setModelData(self, editor, model, index)
            return

        current_item = combobox.currentIndex()

        child_col_index = child_model.fieldIndex(
            sql_model.relation(index.column()).displayColumn())
        child_edit_index = child_model.fieldIndex(
            sql_model.relation(index.column()).indexColumn())

        child_col_data = child_model.data(
            child_model.index(current_item, child_col_index), Qt.DisplayRole)
        child_edit_data = child_model.data(
            child_model.index(current_item, child_edit_index), Qt.EditRole)

        sql_model.setData(index, child_col_data, Qt.DisplayRole)
        sql_model.setData(index, child_edit_data, Qt.EditRole)
Example #2
0
 def setModelData(self, editor, model, idx):
     # NOT IMPLEMENTED----------------------------------------------
     if editor.objectName() in ['ftype', 'dtype', 'stype', 'fpath', 'UUID']:
         modeldata = idx.data(Qt.DisplayRole)
         dict_ = eval(modeldata)
         newvalue = editor.text()
         dict_[editor.objectName()] = newvalue
         model.setData(idx, str(dict_))
     elif editor.objectName() in ['timestamp']:
         return
     else:
         QItemDelegate.setModelData(self, editor, model, idx)
Example #3
0
 def setModelData(self, editor, model, index):
     if isinstance(editor, QComboBox):
         model.setData(index, QVariant(editor.currentText()), Qt.EditRole)
     elif isinstance(editor, QTextEdit):
         model.setData(index, QVariant(editor.toPlainText()), Qt.EditRole)
     else:
         return QItemDelegate.setModelData(self, editor, model, index)
 def setModelData(self, editor, model, index):
     if isinstance(editor, QComboBox):
         self.comboDel.setModelData(editor, model, index)
     else:
         QItemDelegate.setModelData(self, editor, model, index)
Example #5
0
 def setModelData(self, editor, model, index):
     if isinstance(editor, QComboBox):
         self.comboDel.setModelData(editor, model, index)
     else:
         QItemDelegate.setModelData(self, editor, model, index)
Example #6
0
 def setModelData(self, editor, model, index):
     QItemDelegate.setModelData(self, editor, model, index)