Пример #1
0
    def setModelData(self, editor, model, index):
        """ Specifies how the model should be filled out with data from
        the editor
        """

        # if the baseDNs
        if index.column() == 5:

            returnList = []

            # Get the basedn-list from the editor
            for i in xrange(editor.count()):
                returnList.append(
                    editor.item(i).data(Qt.DisplayRole).toPyObject())

            # now that we have constructed the list, give it to the model
            model.setData(index, QVariant(returnList))
            return

        # if a combobox, get the index and give it to the model
        value = editor.property("currentIndex")
        if value.isValid():
            model.setData(index, value)
            return

        # else - default
        QStyledItemDelegate.setModelData(self, editor, model, index)
Пример #2
0
    def setModelData( self, editor, model, index ):

        if index.column() == DESCRIPCION:
            modelo = self.proxymodel
            if modelo.rowCount() > 0:
                fila = editor.currentIndex()
                model.setData( index, [
                                           modelo.index( fila, 0 ).data().toInt()[0],
                                           modelo.index( fila, 1 ).data().toString(),
                                           modelo.index( fila, 2 ).data().toInt()[0],
                                           modelo.index( fila, 3 ).data().toString()
                    ] )
                self.removeFromFilter( modelo.index( fila, 1 ).data().toString() )
                self.proxymodel.setFilterRegExp( self.filter() )
        elif index.column() == BANCO:
            modelo = self.bancosmodel
            if modelo.rowCount() == 0 :
                model.setData( index, [-1, ""] )
            else:
                fila = editor.currentIndex()
                model.setData( index, [
                                               modelo.index( fila, 0 ).data().toInt()[0],
                                               modelo.index( fila, 1 ).data().toString()
                        ] )
        else:
            QStyledItemDelegate.setModelData( self, editor, model, index )
Пример #3
0
    def setModelData(self, editor, model, index):
        """ Specifies how the model should be filled out with data from
        the editor
        """

        # if the baseDNs
        if index.column() == 5:

            returnList = []

            # Get the basedn-list from the editor
            for i in xrange(editor.count()):
                returnList.append(
                    editor.item(i).data(Qt.DisplayRole).toPyObject())

            # now that we have constructed the list, give it to the model
            model.setData(index, QVariant(returnList))
            return

        # if a combobox, get the index and give it to the model
        value = editor.property("currentIndex")
        if value.isValid():
            model.setData(index, value)
            return

        # else - default
        QStyledItemDelegate.setModelData(self, editor, model, index)
Пример #4
0
 def setModelData(self, editor, model, index):
     # Store data from the editor to the model.
     if index.column() == self._sort_cold_idx:
         disp_text = editor.currentText()
         enum = editor.itemData(editor.currentIndex())
         model.setData(index, enum, DATA_ROLE)
         model.setData(index, disp_text)
         model.reset_complementary_source()
     else:
         QStyledItemDelegate.setModelData(self, editor, model, index)
Пример #5
0
 def setModelData(self, editor, model, index):
     if index.column() == TEU:
         model.setData(index, QVariant(editor.value()))
     elif index.column() in (OWNER, COUNTRY):
         model.setData(index, QVariant(editor.currentText()))
     elif index.column() == NAME:
         model.setData(index, QVariant(editor.text()))
     elif index.column() == DESCRIPTION:
         model.setData(index, QVariant(editor.toSimpleHtml()))
     else:
         QStyledItemDelegate.setModelData(self, editor, model, index)
Пример #6
0
    def setModelData( self, editor, model, index ):

        if index.column() in ( NCUENTA, CODCUENTA ):
            if editor.currentIndex() != -1:
                proxyindex = self.proxymodel.index( editor.currentIndex() , 0 )
                sourceindex = self.proxymodel.mapToSource( proxyindex )

                model.setData( index, [
                                       self.accounts.index( sourceindex.row(), 0 ).data().toInt()[0],
                                       self.accounts.index( sourceindex.row(), 1 ).data(),
                                       self.accounts.index( sourceindex.row(), 2 ).data()
                                       ] )
        else:
            QStyledItemDelegate.setModelData( self, editor, model, index )
Пример #7
0
    def setModelData( self, editor, model, index ):

        if index.column() in ( NCUENTA, CODCUENTA ):
            if self.proxymodel.rowCount() > 0:
                fila = editor.currentIndex()
                modelo = self.proxymodel
                model.setData( index, [
                                       modelo.index( fila , 0 ).data(),
                                       modelo.index( fila, 1 ).data(),
                                       modelo.index( fila, 2 ).data()
                                       ] )
                self.filtrados.append( modelo.index( fila , 0 ).data().toString() )
                self.proxymodel.setFilterRegExp( self.filter() )
        else:
            QStyledItemDelegate.setModelData( self, editor, model, index )
Пример #8
0
    def setModelData(self, editor, model, index):
        if not editor:
            return

        column = index.column()

        fieldType = FieldsMappingModel.columns[column]['type']
        if fieldType == QVariant.Type:
            value = editor.itemData(editor.currentIndex())
            if value is None:
                value = QVariant.Invalid
            model.setData(index, value)

        elif fieldType == QgsExpression:
            (value, isExpression, isValid) = editor.currentField()
            model.setData(index, value)

        else:
            QStyledItemDelegate.setModelData(self, editor, model, index)
Пример #9
0
    def setModelData(self, editor, model, index):
        """copy data from editor to model"""
        #if _DBG_VERBOSE: print "updating model data", editor.text(),
        #print "  sender", self.sender()
        #traceback.print_stack(file=sys.stdout)
        row, col = index.row(), index.column()
        if row == C_FIELD:
            #if _DBG_VERBOSE: print "skip"
            return QStyledItemDelegate.setModelData(self, editor, model, index)

        if not self._modified: return
        if isinstance(editor, QLineEdit):
            model.setData(index, QVariant(editor.text()))
            #if _DBG_VERBOSE: print "done"
        elif isinstance(editor, Qwt.QwtSlider):
            model.setData(index, QVariant(editor.value()))
            #if _DBG_VERBOSE: print "done"
        else:
            #if _DBG_VERBOSE: print "skip"
            pass
Пример #10
0
    def setModelData(self, editor, model, index):
        """copy data from editor to model"""
        #if _DBG_VERBOSE: print "updating model data", editor.text(),
        #print "  sender", self.sender()
        #traceback.print_stack(file=sys.stdout)
        row, col = index.row(), index.column()
        if row == C_FIELD:
            #if _DBG_VERBOSE: print "skip"
            return QStyledItemDelegate.setModelData(self, editor, model, index)

        if not self._modified: return
        if isinstance(editor, QLineEdit):
            model.setData(index, QVariant(editor.text()))
            #if _DBG_VERBOSE: print "done"
        elif isinstance(editor, Qwt.QwtSlider):
            model.setData(index, QVariant(editor.value()))
            #if _DBG_VERBOSE: print "done"
        else:
            #if _DBG_VERBOSE: print "skip"
            pass
Пример #11
0
 def setModelData(self, editor, model, index):
     delegate = self.delegates.get(index.column())
     if delegate is not None:
         delegate.setModelData(editor, model, index)
     else:
         QStyledItemDelegate.setModelData(self, editor, model, index)
Пример #12
0
 def setModelData(self, editor, model, index):
     # This call below is to give a chance to the editor to tweak its content a little bit before
     # we send it to the model.
     if hasattr(editor, "prepareDataForCommit"):
         editor.prepareDataForCommit()
     QStyledItemDelegate.setModelData(self, editor, model, index)
Пример #13
0
 def setModelData(self, editor, model, index):
     if index.isValid() and index.column() == 0:
         model.setData(index, editor.currentText(), Qt.EditRole)
         return
     QStyledItemDelegate.setModelData(self, editor, model, index)
Пример #14
0
 def setModelData(self, editor, model, index):
     layer = index.data().toPyObject()
     if isinstance(layer, Layer):
         model.setData(index, editor.layer)
     else:
         QStyledItemDelegate.setModelData(self, editor, model, index)
Пример #15
0
 def setModelData(self, editor, model, index):
     layer = index.data().toPyObject()
     if isinstance(layer, Layer):
         model.setData(index, editor.layer)
     else:
         QStyledItemDelegate.setModelData(self, editor, model, index)
Пример #16
0
 def setModelData(self, editor, model, index):
     delegate = self.delegates.get(index.column())
     if delegate is not None:
         delegate.setModelData(editor, model, index)
     else:
         QStyledItemDelegate.setModelData(self, editor, model, index)
Пример #17
0
 def setModelData(self, editor, model, index):
     if index.isValid() and index.column() == 0:
         model.setData(index, editor.currentText(), Qt.EditRole)
         return
     QStyledItemDelegate.setModelData(self, editor, model, index)