Example #1
0
    def setEditorData(self, editor, index):
        """Specifies how the given editor should be filled out with the
        data from the model.
        """

        if not index.isValid():
            return

        # if BaseDNs
        if index.column() == 5:

            # List of strings from the model
            d = index.data().toPyObject()
            # Empty the editor (clear old list)
            editor.clear()
            # Fill it out with new data
            for tmpBase in d:
                # The editor is the items parent, so it gets added to
                # the list
                QListWidgetItem(tmpBase, editor)
                # Can also do this
                #editor.addItem(QListWidgetItem(tmpBase))
            return

        # NOTE: If a QComboBox just set the index it should display
        # (the strings displayed is in the .ui-file) this means the
        # strings in the *.ui file HAS TO BE IN THE CORRECT ORDER.

        # If QComboBoxes has currentIndex just give it the data.
        if editor.property("currentIndex").isValid():
            editor.setProperty("currentIndex", index.data())
            return

        # else (default)
        QStyledItemDelegate.setEditorData(self, editor, index)
Example #2
0
    def setEditorData(self, editor, index):
        """Specifies how the given editor should be filled out with the
        data from the model.
        """

        if not index.isValid():
            return

        # if BaseDNs
        if index.column() == 5:

            # List of strings from the model
            d = index.data().toPyObject()
            # Empty the editor (clear old list)
            editor.clear()
            # Fill it out with new data
            for tmpBase in d:
                # The editor is the items parent, so it gets added to
                # the list
                QListWidgetItem(tmpBase, editor)
                # Can also do this
                #editor.addItem(QListWidgetItem(tmpBase))
            return

        # NOTE: If a QComboBox just set the index it should display
        # (the strings displayed is in the .ui-file) this means the
        # strings in the *.ui file HAS TO BE IN THE CORRECT ORDER.

        # If QComboBoxes has currentIndex just give it the data.
        if editor.property("currentIndex").isValid():
            editor.setProperty("currentIndex", index.data())
            return

        # else (default)
        QStyledItemDelegate.setEditorData(self, editor, index)
Example #3
0
 def setEditorData(self, editor, index):
     # Set the combobox index
     if index.column() == self._sort_cold_idx:
         sort_enum = index.data(DATA_ROLE)
         idx = editor.findData(sort_enum)
         if idx != -1:
             editor.setCurrentIndex(idx)
     else:
         QStyledItemDelegate.setEditorData(self, editor, index)
Example #4
0
 def setEditorData( self, editor, index ):
     """
     En esta funcion se inicializan los datos a mostrarse en el editor
     se ejecuta justo en el momento en el que se muestra el editor
     """
     if index.column() == ABONO:
         valortemp = index.model().data( index, Qt.EditRole )
         editor.setValue( valortemp )
     else:
         QStyledItemDelegate.setEditorData( self, editor, index )
Example #5
0
 def setEditorData( self, editor, index ):
     """
     Aca se definen los datos iniciales que tendra el control, 
     justo antes de mostrarlo
     """
     if index.column() in ( NOMBRE, TELEFONO, RUC, EMAIL ):
         text = index.model().data( index, Qt.DisplayRole )
         editor.setText( text.toString() )
     else:
         QStyledItemDelegate.setEditorData( self, editor, index )
Example #6
0
 def setEditorData( self, editor, index ):
     data = index.data()
     if index.column() in ( BANCO, DESCRIPCION ):
         i = editor.findText( data if type( data ) != QVariant else data.toString() )
         if i == -1:
             i = 0
         editor.setCurrentIndex( i )
     elif index.column() == MONTO:
         editor.setValue( index.model().data( index, Qt.EditRole ) if index.model().data( index, Qt.EditRole ) != "" else 0 )
     else:
         QStyledItemDelegate.setEditorData( self, editor, index )
Example #7
0
    def setEditorData(self, editor, index):
        row, col = index.row(), index.column()
        if row == C_FIELD:
            return QStyledItemDelegate.setEditorData(self, editor, index)

        val = index.model().data(index, Qt.EditRole)

        #elem, fld, hdl = index.model()._elemrec[row]
        #elem.updateBoundary()
        #bd = elem.boundary(fld)
        #if self.valmeter and bd:
        #    vdbl, ok = val.toFloat()
        #    if ok and bd[0] and bd[1]:
        #        self.valmeter.setRange(bd[0], bd[1])
        #        self.valmeter.setValue(vdbl)
        #        self.valmeter.setVisible(True)
        #print "Setting editor to", text, index.model()._value[r]
        if isinstance(editor, QLineEdit):
            text = val.toString()
            #print "    set editor ", editor, "to", text
            editor.setText(text)
        elif isinstance(editor, Qwt.QwtSlider):
            value, err = val.toFloat()
            #print "slider value:", value
            #value = index.model().data(index, Qt.DisplayRole)
            editor.setValue(value)
        else:
            _logger.error("unknown editor, can not set its data")

        self.emit(SIGNAL("editingElement(PyQt_PyObject)"),
                  index.model()._elemrec[row])
Example #8
0
 def setEditorData(self, editor, index):
     text = index.model().data(index, Qt.DisplayRole).toString()
     if index.column() == TEU:
         value = text.replace(QRegExp("[., ]"), "").toInt()[0]
         editor.setValue(value)
     elif index.column() in (OWNER, COUNTRY):
         i = editor.findText(text)
         if i == -1:
             i = 0
         editor.setCurrentIndex(i)
     elif index.column() == NAME:
         editor.setText(text)
     elif index.column() == DESCRIPTION:
         editor.setHtml(text)
     else:
         QStyledItemDelegate.setEditorData(self, editor, index)
Example #9
0
    def setEditorData(self, editor, index):
        if not editor:
            return

        column = index.column()
        value = index.model().data(index, Qt.EditRole)

        fieldType = FieldsMappingModel.columns[column]['type']
        if fieldType == QVariant.Type:
            editor.setCurrentIndex(editor.findData(value))

        elif fieldType == QgsExpression:
            editor.setField(value)

        else:
            QStyledItemDelegate.setEditorData(self, editor, index)
Example #10
0
    def setEditorData(self, editor, index):
        row, col = index.row(), index.column()
        if row == C_FIELD:
            return QStyledItemDelegate.setEditorData(self, editor, index)

        val = index.model().data(index, Qt.EditRole)

        #elem, fld, hdl = index.model()._elemrec[row]
        #elem.updateBoundary()
        #bd = elem.boundary(fld)
        #if self.valmeter and bd:
        #    vdbl, ok = val.toFloat()
        #    if ok and bd[0] and bd[1]:
        #        self.valmeter.setRange(bd[0], bd[1])
        #        self.valmeter.setValue(vdbl)
        #        self.valmeter.setVisible(True)
        #print "Setting editor to", text, index.model()._value[r]
        if isinstance(editor, QLineEdit):
            text = val.toString()
            #print "    set editor ", editor, "to", text
            editor.setText(text)
        elif isinstance(editor, Qwt.QwtSlider):
            value, err = val.toFloat()
            #print "slider value:", value
            #value = index.model().data(index, Qt.DisplayRole)
            editor.setValue(value)
        else:
            _logger.error("unknown editor, can not set its data")

        self.emit(SIGNAL("editingElement(PyQt_PyObject)"), 
                  index.model()._elemrec[row])
Example #11
0
 def setEditorData(self, editor, index):
     text = index.model().data(index, Qt.DisplayRole).toString()
     if index.column() == TEU:
         value = text.replace(QRegExp("[., ]"), "").toInt()[0]
         editor.setValue(value)
     elif index.column() in (OWNER, COUNTRY):
         i = editor.findText(text)
         if i == -1:
             i = 0
         editor.setCurrentIndex(i)
     elif index.column() == NAME:
         editor.setText(text)
     elif index.column() == DESCRIPTION:
         editor.setHtml(text)
     else:
         QStyledItemDelegate.setEditorData(self, editor, index)
Example #12
0
    def setEditorData( self, editor, index ):
        if index.column() in ( CODCUENTA, NCUENTA ):
            model = index.model()
            current = model.data( model.index( index.row(), IDCUENTA ) )
            self.proxymodel.setFilterRegExp( self.filter( model, current ) )

            text = index.data( Qt.DisplayRole ).toString()
            i = editor.findText( text )
            if i == -1:
                i = 0

            editor.setCurrentIndex( i )
            editor.lineEdit().selectAll()

        elif index.column() == MONTO:
            editor.setValue( index.model().data( index, Qt.EditRole ) if index.model().data( index, Qt.EditRole ) != "" else 0 )
        else:
            QStyledItemDelegate.setEditorData( self, editor, index )
Example #13
0
 def setEditorData(self, widget, index):
     if index.isValid() and index.column() == 0:
         setListValue(widget, index.data(Qt.EditRole))
         return
     QStyledItemDelegate.setEditorData(self, widget, index)
Example #14
0
 def setEditorData(self, widget, index):
     if index.isValid() and index.column() == 0:
         setListValue(widget, index.data(Qt.EditRole))
         return
     QStyledItemDelegate.setEditorData(self, widget, index)
Example #15
0
 def setEditorData(self, editor, index):
     layer = index.data().toPyObject()
     if isinstance(layer, Layer):
         editor.layer = layer
     else:
         QStyledItemDelegate.setEditorData(self, editor, index)
Example #16
0
 def setEditorData(self, editor, index):
     layer = index.data().toPyObject()
     if isinstance(layer, Layer):
         editor.layer = layer
     else:
         QStyledItemDelegate.setEditorData(self, editor, index)
Example #17
0
 def setEditorData(self, editor, index):
     delegate = self.delegates.get(index.column())
     if delegate is not None:
         delegate.setEditorData(editor, index)
     else:
         QStyledItemDelegate.setEditorData(self, editor, index)
 def setEditorData( self, editor, index ):
     if index.column() == CANTIDAD:
         editor.setValue( index.data( Qt.DisplayRole ).toInt()[0] )
     else:
         QStyledItemDelegate.setEditorData( self, editor, index )
Example #19
0
 def setEditorData(self, editor, index):
     delegate = self.delegates.get(index.column())
     if delegate is not None:
         delegate.setEditorData(editor, index)
     else:
         QStyledItemDelegate.setEditorData(self, editor, index)
Example #20
0
 def setEditorData(self, editor, index):
     if index.column() == NUMAJUSTE:
         editor.setValue(index.data(Qt.EditRole).toInt()[0])
     else:
         QStyledItemDelegate.setEditorData(self, editor, index)