コード例 #1
0
    def createEditor(self, parent, option, index: QtCore.QModelIndex):
        col = index.column()

        self.items = []
        if col == 2:
            self.items = ["Pocket", "Inside", "Outside", "Engrave"]
        if col == 7:
            self.items = ["Union", "Intersection", "Difference", "Xor"]
        if col == 8:
            self.items = ["Conventional", "Climb"]
        if col == 9:
            self.items = ["inch", "mm"]

        editor = PMFComboBox(parent, self.items)

        op = index.model().get_operation(index)
        attr = index.model().get_operation_attr(index)

        editor.assign_object(op)
        editor.assign_object_attribute(attr)
        editor.fill_control()

        # to flush a "setModelData" in place - it works! but model still has old value -
        editor.currentIndexChanged.connect(self.onEditorCurrentIndexChanged)

        return editor
コード例 #2
0
    def createEditor(self, parent, option, index: QtCore.QModelIndex):
        editor = PMFDoubleSpinBox(parent)

        op = index.model().get_operation(index)
        attr = index.model().get_operation_attr(index)

        editor.assign_object(op)
        editor.assign_object_attribute(attr)

        # to flush an "setModelData" in place - it works!
        editor.valueChanged.connect(self.onEditorValueChanged)

        return editor
コード例 #3
0
 def setEditorData(self, editor: QtWidgets.QWidget,
                   index: QtCore.QModelIndex) -> None:
     editor = cast(QtWidgets.QDateEdit, editor)
     date_ = index.model().data(index, QtCore.Qt.DisplayRole)
     if date_.isNull():
         date_ = QtCore.QDate.currentDate()
     editor.setDate(date_)
コード例 #4
0
 def handle_activated(self, event: QtCore.QModelIndex):
     model = event.model()
     if model.isDir(event):
         self.setRootIndex(event)
     else:
         path = model.filePath(event)
         subprocess.Popen(path,
                          shell=True,
                          creationflags=subprocess.CREATE_NEW_CONSOLE)
コード例 #5
0
    def createEditor(self, parent, option, index: QtCore.QModelIndex):
        editor = PMFCheckBox(parent)

        op = index.model().get_operation(index)
        attr = index.model().get_operation_attr(index)

        editor.assign_object(op)
        editor.assign_object_attribute(attr)

        # return editor # -> ugly checkbox on the left of the cell

        # -> for checkboxes to be centered: embed into a widget
        checkWidget = QtWidgets.QWidget(parent)
        checkLayout = QtWidgets.QHBoxLayout(checkWidget)
        checkLayout.addWidget(editor)
        checkLayout.setAlignment(QtCore.Qt.AlignCenter)
        checkLayout.setContentsMargins(0, 0, 0, 0)

        # to flush an "setModelData" in place - it works!
        editor.stateChanged.connect(self.onEditorStateChanged)

        return checkWidget
コード例 #6
0
 def handle_middle_clicked(self, event: QtCore.QModelIndex):
     wm.create(MyWidget(event.model(), event))