예제 #1
0
 def createEditor(self, parent, option, index):
     if index.column() == ROOM:
         editor = QLineEdit(parent)
         regex = QRegExp(r"(?:0[1-9]|1[0124-9]|2[0-7])"
                         r"(?:0[1-9]|[1-5][0-9]|6[012])")
         validator = QRegExpValidator(regex, parent)
         editor.setValidator(validator)
         editor.setInputMask("9999")
         editor.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
         return editor
     else:
         return QSqlRelationalDelegate.createEditor(self, parent, option,
                                                    index)
예제 #2
0
 def createEditor(self, parent, option, index):
     if (index.column() == ACTIONID and index.model().data(
             index, Qt.DisplayRole) == ACQUIRED):  # Acquired is read-only
         return
     if index.column() == DATE:
         editor = QDateEdit(parent)
         editor.setMaximumDate(QDate.currentDate())
         editor.setDisplayFormat("yyyy-MM-dd")
         if PYQT_VERSION_STR >= "4.1.0":
             editor.setCalendarPopup(True)
         editor.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
         return editor
     else:
         return QSqlRelationalDelegate.createEditor(self, parent, option,
                                                    index)