示例#1
0
 def createEditor(self, parent, option, index):
     '''
     Creates a editor in the TreeView depending on type of the settings data.
     '''
     item = self._itemFromIndex(index)
     if item.edit_type() == SettingsValueItem.EDIT_TYPE_AUTODETECT:
         if isinstance(item.value(), bool):
             box = QCheckBox(parent)
             box.setFocusPolicy(Qt.StrongFocus)
             box.setAutoFillBackground(True)
             box.stateChanged.connect(self.edit_finished)
             return box
         elif isinstance(item.value(), int):
             box = QSpinBox(parent)
             box.setValue(item.value())
             if not item.value_min() is None:
                 box.setMinimum(item.value_min())
             if not item.value_max() is None:
                 box.setMaximum(item.value_max())
             return box
     elif item.edit_type() == SettingsValueItem.EDIT_TYPE_FOLDER:
         editor = PathEditor(item.value(), parent)
         editor.editing_finished_signal.connect(self.edit_finished)
         return editor
     elif item.edit_type() == SettingsValueItem.EDIT_TYPE_LIST:
         box = QComboBox(parent)
         box.addItems(item.value_list())
         index = box.findText(item.value())
         if index >= 0:
             box.setCurrentIndex(index)
         box.setEditable(False)
         return box
     return QStyledItemDelegate.createEditor(self, parent, option, index)
示例#2
0
 def createEditor(self, parent, option, index):
     '''
     Creates a editor in the TreeView depending on type of the settings data.
     '''
     item = self._itemFromIndex(index)
     if item.edit_type() == SettingsValueItem.EDIT_TYPE_AUTODETECT:
         if isinstance(item.value(), bool):
             box = QCheckBox(parent)
             box.setFocusPolicy(Qt.StrongFocus)
             box.setAutoFillBackground(True)
             box.stateChanged.connect(self.edit_finished)
             return box
         elif isinstance(item.value(), int):
             box = QSpinBox(parent)
             box.setValue(item.value())
             if not item.value_min() is None:
                 box.setMinimum(item.value_min())
             if not item.value_max() is None:
                 box.setMaximum(item.value_max())
             return box
     elif item.edit_type() == SettingsValueItem.EDIT_TYPE_FOLDER:
         editor = PathEditor(item.value(), parent)
         editor.editing_finished_signal.connect(self.edit_finished)
         return editor
     elif item.edit_type() == SettingsValueItem.EDIT_TYPE_LIST:
         box = QComboBox(parent)
         box.addItems(item.value_list())
         index = box.findText(item.value())
         if index >= 0:
             box.setCurrentIndex(index)
         box.setEditable(False)
         return box
     return QStyledItemDelegate.createEditor(self, parent, option, index)