Exemple #1
0
 def setModelData(self, editor: QtGui.QWidget,
                  model: QtCore.QAbstractItemModel,
                  index: QtCore.QModelIndex) -> None:
     assert isinstance(editor, QtGui.QLineEdit)
     text = editor.text()
     model.setData(index,
                   text.title() if editor.hasAcceptableInput() else text,
                   QtCore.Qt.EditRole)
Exemple #2
0
    def setModelData(self, editor: QtGui.QWidget,
                     model: QtCore.QAbstractItemModel,
                     index: QtCore.QModelIndex) -> None:
        assert isinstance(editor, QtGui.QLineEdit)

        text = editor.text()
        if editor.hasAcceptableInput() and not text.startswith("+2"):
            text = "+2" + text

        model.setData(index, text, QtCore.Qt.EditRole)