Exemplo n.º 1
1
 def setEditorData(self, editor, index):
     """ load data from model to editor """
     m = index.model()
     if index.column() == 1:
         txt = m.data(index, Qt.DisplayRole)
         editor.setEditText(txt)
     else:
         # use default
         QItemDelegate.setEditorData(self, editor, index)
Exemplo n.º 2
0
 def setEditorData(self, editor, index):
     """ load data from model to editor """
     m = index.model()
     if index.column() == 1:
         txt = m.data(index, Qt.DisplayRole)
         editor.setEditText(txt)
     else:
         # use default
         QItemDelegate.setEditorData(self, editor, index)
Exemplo n.º 3
0
 def setEditorData(self, editor, index):
     text = from_qvariant(index.model().data(index, Qt.DisplayRole), str)
     if index.column() in (MOD1, MOD2, MOD3, KEY):
         i = editor.findText(text)
         if i == -1:
             i = 0
         editor.setCurrentIndex(i)
     else:
         QItemDelegate.setEditorData(self, editor, index)
Exemplo n.º 4
0
 def setEditorData(self,editor,index):
     """Set initial data for the editor"""
     if index.column() == 0:
         current = index.model().data(index,Qt.DisplayRole)
         editor.setText(current)
     elif index.column() == 1:
         current = index.model().data(index,Qt.DisplayRole)
         editor.setCurrentIndex(editor.findData(current))
     else:
         QItemDelegate.setEditorData(self,editor,index)
Exemplo n.º 5
0
 def setEditorData(self, editor, index):
     model = index.model()
     horse = model.horseList[index.row()]
     if model.isColumn("name", index):
         editor.setText(horse.name)
     elif model.isColumn("rating", index):
         ratingIndex = model.getColumn("rating", index)
         editor.setValue(horse[ratingIndex])
     elif model.isColumn("adjust", index):
         adjustIndex = model.getColumn("adjust", index)
         editor.setValue(model.race.adjusts.getAdjust(model.race.adjusts[adjustIndex], horse))
     else:
         QItemDelegate.setEditorData(self, editor, index)
Exemplo n.º 6
0
 def setEditorData(self, editor, index):
     """
     Changes how model data are displayed in widget.
     :param editor: QWidget used for editing
     :param index: QModelIndex, index for model
     """
     if index.column() == ELEMENT:
         set_combobox_to_model_value(editor, index, self.element_codes)
     elif index.column() == HIERARCHY:
         set_combobox_to_model_value(editor, index, self.hierarchy_codes)
     elif index.column() == OFFSET:
         set_combobox_to_model_value(editor, index, self.offset_codes)
     else:
         QItemDelegate.setEditorData(self, editor, index)
Exemplo n.º 7
0
 def setEditorData(self, editor, index):
     """ load data from model to editor """
     m = index.model()
     try:
         if index.column() == self.column:
             txt = m.data(index, Qt.DisplayRole)
             checkList = txt[1:-1].split(',')
             for i in range(editor.count()):
                 item = editor.item(i)
                 item.setCheckState(Qt.Checked if item.text() in checkList else Qt.Unchecked)
         else:
             # use default
             QItemDelegate.setEditorData(self, editor, index)
     except:
         pass
Exemplo n.º 8
0
 def setEditorData(self, editor, index):
     """ load data from model to editor """
     m = index.model()
     try:
         if index.column() == self.column:
             txt = m.data(index, Qt.DisplayRole)
             checkList = txt[1:-1].split(',')
             for i in range(editor.count()):
                 item = editor.item(i)
                 item.setCheckState(Qt.Checked if item.text() in
                                    checkList else Qt.Unchecked)
         else:
             # use default
             QItemDelegate.setEditorData(self, editor, index)
     except:
         pass
Exemplo n.º 9
0
 def setEditorData(self, editor, index):
     """
     Re-formats dates for the lineedit
     :param editor: Editor widget
     :param index: Model index
     """
     try:
         index_num = index.column()
         if index_num in self.date_cols:
             value = str(index.model().data(index, Qt.DisplayRole))
             date_obj = datetime.datetime.strptime(value, "%Y%m%d")
             date_clean = str(date_obj.strftime("%d/%m/%Y"))
             editor.setText(date_clean)
         else:
             QItemDelegate.setEditorData(self, editor, index)
     except ValueError:
         pass
Exemplo n.º 10
0
    def setEditorData(self, editor, index):
        """
        Accessor to set editor data

        @param editor: 
        @type editor:

        @param index: 
        @type index:
        """
        if index.column() == COL_VALUE:
            if sys.version_info > (3,): # python3 support
                value = index.data()
            else:
                value = str(index.data().toString())
            i = editor.findText(value)
            editor.setCurrentIndex (i)
        else:
            QItemDelegate.setEditorData(self, editor, index)
Exemplo n.º 11
0
 def setEditorData(self, editor, index):
     """
     Changes how model data are displayed in widget.
     :param editor: QWidget used for editing
     :param index: QModelIndex, index for model
     """
     if index.column() in (STREET_CLASS, LANE_NUMBER, CARRIAGEWAY,
                           SPEED_LIMIT):
         text = str(index.model().data(index, Qt.DisplayRole))
         i = editor.findText(text)
         if i == -1:
             i = 0
         editor.setCurrentIndex(i)
     elif index.column() == RURAL_URBAN_ID:
         set_combobox_to_model_value(editor, index, self.rural_urban_codes)
     elif index.column() == SECTION_TYPE:
         set_combobox_to_model_value(editor, index, self.section_type_codes)
     else:
         QItemDelegate.setEditorData(self, editor, index)
Exemplo n.º 12
0
 def setEditorData(self, editor, index):
     if isinstance(editor, QComboBox):
         i = editor.findText(index.data(Qt.EditRole).toString())
         if i > -1:
             editor.setCurrentIndex(i)
         else:
             editor.setEditText(index.data(Qt.EditRole).toString())
         editor.lineEdit().selectAll()
     elif isinstance(editor, QTextEdit):
         editor.setText(index.data(Qt.EditRole).toString())
         editor.selectAll()
     else:
         return QItemDelegate.setEditorData(self, editor, index)
Exemplo n.º 13
0
 def setEditorData(self, editor, index):
     if isinstance(editor, QComboBox):
         i = editor.findText(index.data(Qt.EditRole).toString())
         if i > -1:
             editor.setCurrentIndex(i)
         else:
             editor.setEditText(index.data(Qt.EditRole).toString())
         editor.lineEdit().selectAll()
     elif isinstance(editor, QTextEdit):
         editor.setText(index.data(Qt.EditRole).toString())
         editor.selectAll()
     else:
         return QItemDelegate.setEditorData(self, editor, index)
 def setEditorData(self, QWidget, QModelIndex):
     QItemDelegate.setEditorData(self, QWidget, QModelIndex)
Exemplo n.º 15
0
 def setEditorData(self, editor, index):
     if editor.text().strip():
         QItemDelegate.setEditorData(self, editor, index)
Exemplo n.º 16
0
 def setEditorData(self, editor, index):
     if isinstance(editor, QComboBox):
         self.comboDel.setEditorData(editor, index)
     else:
         QItemDelegate.setEditorData(self, editor, index)
Exemplo n.º 17
0
 def setEditorData(self, QWidget, QModelIndex):
     QItemDelegate.setEditorData(self, QWidget, QModelIndex)
Exemplo n.º 18
0
 def setEditorData(self, editor, index):
     if editor.text().strip():
         QItemDelegate.setEditorData(self, editor, index)
Exemplo n.º 19
0
 def setEditorData(self, editor, index):
     delegate = self.delegates.get(index.column())
     if delegate is not None:
         delegate.setEditorData(editor, index)
     else:
         QItemDelegate.setEditorData(self, editor, index)