Example #1
0
    def setEditorData(self, editor, index):
        # QMessageBox.warning(None, "Test", str(editor.metaObject().className(index))()) + str
        value = str(index.model().data(index, Qt.EditRole))

        if value == 'NULL':
            value = ''

        if editor.metaObject().className() == 'QTimeEdit' and value == '':
            editor.setTime(QTime(0, 0, 0))
            # if value == '':
            #     value ="00:00:00"
            #     QMessageBox.warning(None, "Test", unicode(index.model().data(index, Qt.EditRole)))
        elif editor.metaObject().className() == 'QLineEdit':
            editor.setText(value)

        elif editor.metaObject().className() == 'QComboBox':
            if index.column() == 23:  # sicherheit
                if value == '':
                    editor.setCurrentIndex(-1)
                else:
                    editor.setCurrentIndex(int(value) - 1)
            else:
                editor.setEditText(value)

        elif editor.metaObject().className() == 'QListWidget':
            #QMessageBox.warning(None, "Test", unicode(index.model().data(index, Qt.EditRole)))
            editor.clear()
            editor.addItems(str.split(value, ";"))
        else:
            QSqlRelationalDelegate.setEditorData(self, editor, index)
Example #2
0
    def setEditorData(self, editor, index):
        #QMessageBox.warning(None, "Test", str(editor.metaObject().className(index))()) + str
        #value = str(index.model().data(index, Qt.EditRole))
        fieldName = index.model().record().fieldName(index.column())
        value = str(index.data(Qt.EditRole))

        if value == 'NULL':
            value = ''

        if editor.metaObject().className() == 'QTimeEdit' and value == '':
            editor.setTime(QTime(0, 0, 0))
            # if value == '':
            #     value ="00:00:00"
            #     QMessageBox.warning(None, "Test", unicode(index.model().data(index, Qt.EditRole)))

        elif editor.metaObject().className() == 'QDateEdit' and value == '':
            editor.setDate(QDate())
            editor.setStyleSheet("{0} {{background-color: rgb(255, 229, 204);}}".format(editor.metaObject().className()))

        elif editor.metaObject().className() == 'QDateEdit' and value != '':
            if editor.isReadOnly():
                editor.setStyleSheet("{0} {{background-color: rgb(218, 218, 218);}}".format(editor.metaObject().className()))
            else:
                editor.setStyleSheet("")
            QSqlRelationalDelegate.setEditorData(self, editor, index)

        elif editor.metaObject().className() == 'QgsDateTimeEdit' and value == '':
            editor.setAllowNull(True)
            editor.clear()
            editor.clearFocus()
            editor.setAllowNull(False)

        elif editor.metaObject().className() == 'QgsDateTimeEdit' and value != '':
            editor.setAllowNull(False)
            QSqlRelationalDelegate.setEditorData(self, editor, index)

        elif editor.metaObject().className() == 'QLineEdit':
            editor.setText(value)

        elif editor.metaObject().className() == 'QComboBox':
            if fieldName == "weise":
                if value in ["schraeg", "schräg", "oblique"]:
                    editor.setCurrentIndex(APISFilm.OBLIQUE)
                elif value in ["senkrecht", "senk", "senk.", "vertical"]:
                    editor.setCurrentIndex(APISFilm.VERTICAL)
                else:
                    editor.setEditText(value)
            else:
                editor.setEditText(value)

        elif editor.metaObject().className() == 'QListWidget':
            #QMessageBox.warning(None, "Test", unicode(index.model().data(index, Qt.EditRole)))
            editor.clear()
            if value != '':
                str_list = filter(None, str.split(value, ";"))
                editor.addItems(str_list)
        else:
            QSqlRelationalDelegate.setEditorData(self, editor, index)
Example #3
0
 def setEditorData(self, editor, index):
     if index.column() == DATE:
         date = index.model().data(index, Qt.DisplayRole)
         editor.setDate(date)
     else:
         QSqlRelationalDelegate.setEditorData(self, editor, index)
Example #4
0
 def setEditorData(self, editor, index):
     if index.column() == ROOM:
         text = index.model().data(index, Qt.DisplayRole)
         editor.setText(text)
     else:
         QSqlRelationalDelegate.setEditorData(self, editor, index)