예제 #1
0
    def __iterateOnData (self, data, parentWidget = None):
        print "ComponentTreeWidget.__iterateOnData"
        print "ComponentTreeWidget.__iterateOnData.%s" %data
        for item in sorted (data ['components']):
            if data ['components'] [item] not in self.bs.registeredComponents.keys ():
                print (
                "Warning: Component module " + data ['components'] [item] + " not found in registered components:")
                for component in self.bs.registeredComponents:
                    print "  " + component
                continue

            treeItem = QtWidgets.QTreeWidgetItem (parentWidget)
            treeItem.setData (0, QtCore.Qt.UserRole, data ['components'] [item])
            treeItem.setText (0, item)
            component = self.bs.registeredComponents [data ['components'] [item]]
            module = sys.modules [component.__module__]
            treeItem.setToolTip (0, module.__file__)

            if parentWidget is not None:
                parentWidget.setToolTip (0, os.path.dirname (module.__file__))

        for item in data ['subDirs'].keys ():
            treeItem = QtWidgets.QTreeWidgetItem (parentWidget)
            treeItem.setData (0, QtCore.Qt.UserRole, 'Folder')
            treeItem.setText (0, item)

            self.__iterateOnData (data ['subDirs'] [item], parentWidget = treeItem)
예제 #2
0
    def __init__(self, valueController, parent=None):
        super(StringEditor, self).__init__(valueController, parent=parent)

        vbox = QtWidgets.QVBoxLayout()

        self._editor = QtWidgets.QTextEdit(self)
        options = valueController.getOption('multiLine')
        self._editor.setMinimumHeight(options.get('numLines', 5) * 20)
        self._editor.setMaximumHeight(options.get('numLines', 5) * 20)
        vbox.addWidget(self._editor, 1)

        # vbox.addStretch(0)
        vbox.setContentsMargins(0, 0, 0, 0)
        self.setLayout(vbox)
        self.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                           QtWidgets.QSizePolicy.Expanding)

        self.updateEditorValue()

        # we get lots of 'editingFinished' events,
        # so filter to only generate undos for important ones.

        self._value = self._editor.toPlainText()

        def invokeSetter():
            value = self._editor.toPlainText()
            if self._value != value:
                self._value = value
                self._setValueToController()

        self._editor.textChanged.connect(self._setValueToController)

        self.setEditable(valueController.isEditable())
예제 #3
0
    def __init__(self, valueController, parent=None):
        super(StringListEditor, self).__init__(valueController, parent=parent)

        hbox = QtWidgets.QHBoxLayout()
        self._editor = QtWidgets.QListWidget(self)
        if self._valueController.hasOption('maxHeight'):
            self._editor.setMaximumHeight(
                self._valueController.getOption('maxHeight', 65))
            self.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                               QtWidgets.QSizePolicy.Fixed)
        else:
            self.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                               QtWidgets.QSizePolicy.Expanding)

        hbox.addWidget(self._editor, 1)
        hbox.setContentsMargins(0, 0, 0, 0)
        self.setLayout(hbox)

        self.updateEditorValue()

        if self.isEditable():

            def setSelectionOption(value):
                self._valueController.setOption('currentItem', value)

            self._editor.itemSelectionChanged.connect(setSelectionOption)
        else:
            self.setEditable(False)
예제 #4
0
    def constructAndAddElementEditor(self, index):
        elementEditor = self.constructElementEditor(index)

        row = index
        column = 0
        if self._displayIndex:
            self._grid.addWidget(QtWidgets.QLabel(str(index), self), row, column, QtCore.Qt.AlignRight | QtCore.Qt.AlignTop)
            column += 1
        if elementEditor is not None:
            self._grid.addWidget(elementEditor, row, column)
            column += 1

        if self.isEditable() and self._enableRemoveElements and not self._constSizeArray:
            self.removeElementButton = QtWidgets.QPushButton(self._removeElementButtonLabel, self)
            def removeElement():

                undoManager = UndoRedoManager.getInstance()
                undoManager.openBracket("Remove element from :" + self.getName())

                self.removeElement(index)
                self._setValueToController()

                undoManager.closeBracket()
                self.rebuild()

            self.removeElementButton.clicked.connect(removeElement)

            self._grid.addWidget(self.removeElementButton, row, column)

        if elementEditor is not None:
            self._editors.append(elementEditor)
예제 #5
0
    def __init__(self, valueController, parent=None):
        super(IntegerEditor, self).__init__(valueController, parent=parent)
        hbox = QtWidgets.QHBoxLayout()

        self._editor = QtWidgets.QSpinBox(self)

        if (self._dataType == 'UInt8' or self._dataType == 'UInt16'
                or self._dataType == 'UInt32' or self._dataType == 'UInt64'
                or self._dataType == 'Index' or self._dataType == 'Size'
                or self._dataType == 'Byte'):
            self._editor.setMinimum(0)
        else:
            self._editor.setMinimum(-100000000)

        self._editor.setMaximum(100000000)
        self._editor.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                   QtWidgets.QSizePolicy.Fixed)
        hbox.addWidget(self._editor, 1)

        hbox.addStretch(0)
        hbox.setContentsMargins(0, 0, 0, 0)
        self.setLayout(hbox)
        self.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                           QtWidgets.QSizePolicy.Fixed)

        self.updateEditorValue()

        self._editor.valueChanged.connect(self._setValueToController)

        self.setEditable(valueController.isEditable())
예제 #6
0
    def __init__(self, valueController, parent=None):
        super(ListViewEditor, self).__init__(valueController, parent=parent)

        hbox = QtWidgets.QHBoxLayout()
        self._editor = QtWidgets.QListWidget(self)

        self.__items = valueController.getOption('combo')
        for item in self.__items:
            self._editor.addItem(str(item))
        self._editor.setMaximumHeight(65)

        hbox.addWidget(self._editor, 1)

        hbox.addStretch(0)
        hbox.setContentsMargins(0, 0, 0, 0)
        self.setLayout(hbox)
        self.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                           QtWidgets.QSizePolicy.Fixed)

        self.updateEditorValue()

        if self.isEditable():
            self._editor.itemSelectionChanged.connect(
                self._setValueToController)
        else:
            self._editor.setReadOnly(True)
예제 #7
0
    def __init__(self, parent=None):

        # constructors of base classes
        super(BeamUI, self).__init__(parent)
        self.setObjectName('mainUI')
        self.setWindowIcon(QtGui.QIcon(''))

        self.setWindowTitle("Beam Editor")
        self.setAcceptDrops(True)

        self.graphViewWidget = KGraphViewWidget(parent=self)
        self.nodeLibrary = ComponentLibrary(parent=self)

        self.horizontalSplitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal,
                                                      parent=self)
        self.horizontalSplitter.addWidget(self.nodeLibrary)
        self.horizontalSplitter.addWidget(self.graphViewWidget)

        self.horizontalSplitter.setStretchFactor(0, 0)
        self.horizontalSplitter.setStretchFactor(1, 1)
        self.horizontalSplitter.setSizes([0, 100])
        self.horizontalSplitter.splitterMoved.connect(self.splitterMoved)
        self.nodeLibraryExpandedSize = 175

        grid = QtWidgets.QVBoxLayout(self)
        grid.addWidget(self.horizontalSplitter)
예제 #8
0
    def __init__(self, port, graph, hOffset, color, connectionPointType):
        super(PortCircle, self).__init__(port)

        self.__port = port
        self._graph = graph
        self._connectionPointType = connectionPointType
        self.__connections = set()
        self._supportsOnlySingleConnections = connectionPointType == 'In'

        self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed))
        size = QtCore.QSizeF(self.__diameter, self.__diameter)
        self.setPreferredSize(size)
        self.setWindowFrameMargins(0, 0, 0, 0)

        self.transform().translate(self.__radius * hOffset, 0)

        self.__defaultPen = QtGui.QPen(QtGui.QColor(25, 25, 25), 1.0)
        self.__hoverPen = QtGui.QPen(QtGui.QColor(255, 255, 100), 1.5)

        self._ellipseItem = QtWidgets.QGraphicsEllipseItem(self)
        self._ellipseItem.setPen(self.__defaultPen)
        self._ellipseItem.setPos(size.width()/2, size.height()/2)
        self._ellipseItem.setRect(
            -self.__radius,
            -self.__radius,
            self.__diameter,
            self.__diameter,
            )
        if connectionPointType == 'In':
            self._ellipseItem.setStartAngle(270 * 16)
            self._ellipseItem.setSpanAngle(180 * 16)

        self.setColor(color)
        self.setAcceptHoverEvents(True)
예제 #9
0
    def __init__(self, parent, graph, name, color, dataType, connectionPointType):
        super(BasePort, self).__init__(parent)

        self._node = parent
        self._graph = graph
        self._name = name
        self._dataType = dataType
        self._connectionPointType = connectionPointType

        self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed))

        layout = QtWidgets.QGraphicsLinearLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        self._color = color

        self._inCircle = None
        self._outCircle = None
        self._labelItem = None

        self._inCircleHolder = ItemHolder(self)
        self._outCircleHolder = ItemHolder(self)
        self._labelItemHolder = ItemHolder(self)

        self.layout().addItem(self._inCircleHolder)
        self.layout().setAlignment(self._inCircleHolder, QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)

        self.layout().addItem(self._labelItemHolder)
        self.layout().setAlignment(self._labelItemHolder, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)

        self.layout().addItem(self._outCircleHolder)
        self.layout().setAlignment(self._outCircleHolder, QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
예제 #10
0
    def createLayout(self):
        self.menuLayout = QtWidgets.QHBoxLayout()
        self.menuLayout.setContentsMargins(0, 0, 0, 0)
        self.menuLayout.setSpacing(0)

        # Menu
        self.menuBar = QtWidgets.QMenuBar()

        # File Menu
        self.fileMenu = self.menuBar.addMenu('&File')
        self.newAction = self.fileMenu.addAction('&New')
        self.newAction.setShortcut('Ctrl+N')
        self.newAction.setObjectName("newAction")

        # Edit Menu
        self.editMenu = self.menuBar.addMenu('&Edit')

        # Build Menu
        self.buildMenu = self.menuBar.addMenu('&Build')
        self.buildGuideAction = self.buildMenu.addAction('Build &Guide')
        self.buildGuideAction.setShortcut('Ctrl+G')
        self.buildGuideAction.setObjectName("buildGuideAction")

        self.buildRigAction = self.buildMenu.addAction('Build &Rig')
        self.buildRigAction.setShortcut('Ctrl+B')
        self.buildRigAction.setObjectName("buildRigAction")

        # Config Widget
        self.configsParent = QtWidgets.QFrame(self)
        self.configsParent.setObjectName('configParent')
        self.configsParent.setFrameStyle(QtWidgets.QFrame.NoFrame)
        self.configsParent.setMinimumWidth(160)

        self.configsLayout = QtWidgets.QVBoxLayout()
        self.configsLayout.setContentsMargins(0, 0, 0, 0)
        self.configsLayout.setSpacing(0)

        self.configsWidget = QtWidgets.QComboBox()
        self.configsWidget.setAutoFillBackground(True)
        self.configsWidget.setObjectName('configWidget')
        self.configsWidget.setMinimumWidth(160)
        self.configsWidget.addItem('Default Config', userData='Default Config')

        self.configsLayout.addWidget(self.configsWidget)
        self.configsParent.setLayout(self.configsLayout)

        configs = BeamSystem.getInstance().getConfigClassNames()
        for config in configs:
            self.configsWidget.addItem(config.split('.')[-1], userData=config)

        self.rigNameLabel = RigNameLabel('Rig Name:')

        self.menuLayout.addWidget(self.menuBar, 3)
        self.menuLayout.addWidget(self.configsParent, 0)
        self.setLayout(self.menuLayout)
예제 #11
0
    def __init__(self, valueController, parent=None):
        super(FilepathEditor, self).__init__(valueController, parent=parent)

        self.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                           QtWidgets.QSizePolicy.Fixed)

        self._line = QtWidgets.QLineEdit(self)
        self._browse = QtWidgets.QPushButton(' ... ', self)

        hbox = QtWidgets.QHBoxLayout()
        hbox.setContentsMargins(0, 0, 0, 0)
        hbox.addWidget(self._line)
        hbox.addWidget(self._browse)

        self.setLayout(hbox)
        self.__updateOptions()

        def localSetter(value):
            self._setValueToController()

        self._line.textEdited.connect(localSetter)

        def __onBrowse():
            if self._line.text() == '':
                initialDir = self._folder
            else:
                initialDir = os.path.join(self._folder, self._line.text())

            if self._saveFile:
                (filepath, filter) = QtWidgets.QFileDialog.getSaveFileName(
                    None,
                    caption=self._options['Title'],
                    dir=initialDir,
                    filter=self._options['Filter'])
            else:
                (filepath, filter) = QtWidgets.QFileDialog.getOpenFileName(
                    None,
                    caption=self._options['Title'],
                    dir=initialDir,
                    filter=self._options['Filter'])

            if filepath is None or len(filepath) == 0:
                return

            if self._folder != '':
                filepath = os.path.relpath(filepath, self._folder)

            self.setEditorValue(filepath)
            self._setValueToController()

        self._browse.clicked.connect(__onBrowse)
        valueController.optionChanged.connect(self.__updateOptions)

        self.updateEditorValue()
        self.setEditable(valueController.isEditable())
예제 #12
0
    def createLayout(self):
        mainWidget = QtWidgets.QWidget()

        # Main Layout
        self.mainLayout = QtWidgets.QVBoxLayout()
        self.mainLayout.setContentsMargins(0, 0, 0, 0)

        self.beamUI = BeamUI(self)
        self.mainLayout.addWidget(self.beamUI, 1)
        mainWidget.setLayout(self.mainLayout)
        self.setCentralWidget(mainWidget)
예제 #13
0
    def __init__(self, valueController, parent=None):
        super(BaseSliderEditor, self).__init__(valueController, parent=parent)

        self._editEditor = QtWidgets.QLineEdit(self)
        self._sliderEditor = QtWidgets.QSlider(QtCore.Qt.Horizontal, self)

        self._range = valueController.getOption('range')
        # self._uiOutOfSliderRange = self._range
        # self._dynamicRange = True
        # self._uiDynamicRange = self._range

        # self._accurateRange = { 'min': 0, 'max': 0 }

        self.setEditable(self.isEditable())
예제 #14
0
    def __init__ (self, text, parent = None):
        super (NodeHeader, self).__init__ (parent)

        self.setSizePolicy (QtWidgets.QSizePolicy (QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding))

        layout = QtWidgets.QGraphicsLinearLayout ()
        layout.setContentsMargins (0, 0, 0, 0)
        layout.setSpacing (3)
        layout.setOrientation (QtCore.Qt.Horizontal)
        self.setLayout (layout)

        self._titleWidget = NodeTitle (text, self)
        layout.addItem (self._titleWidget)
        layout.setAlignment (self._titleWidget, QtCore.Qt.AlignCenter | QtCore.Qt.AlignTop)
예제 #15
0
    def __init__ (self, text, parent = None):
        super (NodeTitle, self).__init__ (parent)

        self.setSizePolicy (QtWidgets.QSizePolicy (QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed))

        self.__textItem = QtWidgets.QGraphicsTextItem (text, self)
        self.__textItem.setDefaultTextColor (self.__color)
        self.__textItem.setFont (self.__font)
        self.__textItem.setPos (0, -2)
        option = self.__textItem.document ().defaultTextOption ()
        option.setWrapMode (QtGui.QTextOption.NoWrap)
        self.__textItem.document ().setDefaultTextOption (option)
        self.__textItem.adjustSize ()

        self.setPreferredSize (self.textSize ())
예제 #16
0
    def createLayout(self):
        self._mainLayout = QtWidgets.QVBoxLayout()
        self._mainLayout.setContentsMargins(10, 10, 10, 10)

        self._commentTextEdit = QtWidgets.QTextEdit(self)
        self._commentTextEdit.setText(self.nodeItem.getComment())
        self._commentTextEdit.setMinimumHeight(20)
        self._commentTextEdit.setMaximumHeight(40)

        self._settingsLayout = QtWidgets.QGridLayout()
        self._settingsLayout.setContentsMargins(10, 10, 10, 10)
        self._settingsLayout.setSpacing(3)
        self._settingsLayout.setColumnMinimumWidth(0, 75)
        self._settingsLayout.setColumnStretch(0, 0)
        self._settingsLayout.setColumnStretch(1, 1)

        # Settings widgets
        self._colorLabel = QtWidgets.QLabel('Color', self)
        self._colorLabel.setObjectName('color_label')
        self._colorLabel.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                       QtWidgets.QSizePolicy.Fixed)
        self._colorLabel.setMinimumWidth(75)
        self._colorWidget = KColorWidget(self, self.nodeItem.getColor())

        self._settingsLayout.addWidget(self._colorLabel,
                                       0,
                                       0,
                                       1,
                                       1,
                                       alignment=QtCore.Qt.AlignLeft)
        self._settingsLayout.addWidget(self._colorWidget,
                                       0,
                                       1,
                                       1,
                                       1,
                                       alignment=QtCore.Qt.AlignLeft)

        # OK and Cancel buttons
        self.buttons = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
            QtCore.Qt.Horizontal, self)

        self._mainLayout.addWidget(self._commentTextEdit)
        self._mainLayout.addLayout(self._settingsLayout)
        self._mainLayout.addStretch(1)
        self._mainLayout.addWidget(self.buttons)

        self.setLayout(self._mainLayout)
예제 #17
0
    def addSeparator(self, name=None):

        separatorEditor = QtWidgets.QFrame(self.paramsGroup)
        separatorEditor.setFrameShape(QtWidgets.QFrame.HLine)
        separatorEditor.setObjectName('separatorFrame')
        if name is not None:
            labelEditor = QtWidgets.QLabel(name, self.paramsGroup)
            labelEditor.setObjectName('separatorLabel')

            self.paramsLayout.addWidget(labelEditor, self.gridRow, 0)
            self.paramsLayout.addWidget(separatorEditor, self.gridRow, 1,
                                        QtCore.Qt.AlignBottom)
            self.gridRow += 1
        else:
            self.paramsLayout.addWidget(separatorEditor, self.gridRow, 0, 1, 2)
            self.gridRow += 1
예제 #18
0
    def createLayout (self):
        mainWidget = QtWidgets.QWidget ()

        # Main Layout
        self.mainLayout = QtWidgets.QVBoxLayout()
        self.mainLayout.setContentsMargins(0, 0, 0, 0)

        self.beamUI = BeamUI(self)
        self.beamMenu = BeamMenu (self)
        self.beamUI.graphViewWidget.setGuideRigName('MyRig')
        self.beamMenu.updateRigNameLabel()

        self.mainLayout.addWidget (self.beamMenu)
        self.mainLayout.addWidget (self.beamUI, 1)
        mainWidget.setLayout (self.mainLayout)
        self.setCentralWidget (mainWidget)
예제 #19
0
 def __init__(self, parent):
     super(PortList, self).__init__(parent)
     layout = QtWidgets.QGraphicsLinearLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     layout.setSpacing(4)
     layout.setOrientation(QtCore.Qt.Vertical)
     self.setLayout(layout)
예제 #20
0
    def __init__(self, valueController, parent=None):
        super(ScalarSliderEditor, self).__init__(valueController,
                                                 parent=parent)

        hbox = QtWidgets.QHBoxLayout()

        validator = QtGui.QDoubleValidator(self)
        validator.setRange(self._range['min'], self._range['max'], 4)

        self._editEditor.setValidator(validator)
        self._editEditor.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                       QtWidgets.QSizePolicy.Fixed)

        self._sliderEditor.setMinimum(self._range['min'] * 1000)
        self._sliderEditor.setMaximum(self._range['max'] * 1000)
        self._sliderEditor.setSizePolicy(
            QtWidgets.QSizePolicy.MinimumExpanding,
            QtWidgets.QSizePolicy.Fixed)
        self._sliderEditor.setTickInterval(1000)

        self._editEditor.setMinimumWidth(50)
        self._editEditor.setMaximumWidth(90)

        hbox.addWidget(self._editEditor, 1)
        hbox.addWidget(self._sliderEditor, 1)
        hbox.addStretch()
        self.setLayout(hbox)
        self.layout().setContentsMargins(0, 0, 0, 0)

        self.updateEditorValue()

        def __sliderPressed():
            self.beginInteraction()

        def __sliderReleased():
            self.endInteraction()

        def __sliderMoved(value):
            if self._updatingEditor:
                return
            value = float(value) / 1000
            self._editEditor.setText(str(round(value, 4)))
            self._value = value
            self._setValueToController()

        def __textEdited():
            if self._updatingEditor:
                return
            value = self.getEditorValue()
            # if self._dynamicRange:
            #     self.updateSliderRange(value)
            self._sliderEditor.setValue(value * 1000)
            self._setValueToController()

        self._sliderEditor.sliderPressed.connect(__sliderPressed)
        self._sliderEditor.sliderReleased.connect(__sliderReleased)
        self._sliderEditor.valueChanged.connect(__sliderMoved)
        self._editEditor.editingFinished.connect(__textEdited)

        self.setEditable(valueController.isEditable())
예제 #21
0
    def build(self):

        self._editors = []

        for i in range(0, len(self._valueArray)):
            if self._displayArrayLimit and i == self._arrayLimit:
                break
            self.constructAndAddElementEditor(i)

        if self.isEditable() and self._enableAddElements:
            if not self._displayArrayLimit or self._displayArrayLimit and len(self._valueArray) < self._arrayLimit and not self._constSizeArray:
                self.addElementButton = QtWidgets.QPushButton(self._addElementButtonLabel, self)
                def addElement():
                    undoManager = UndoRedoManager.getInstance()
                    undoManager.openBracket("Add element to :" + self.getName())

                    self.addElement()
                    self._setValueToController()

                    undoManager.closeBracket()
                    self.rebuild()

                self.addElementButton.clicked.connect(addElement)
                if self._displayIndex:
                    self._grid.addWidget(self.addElementButton, len(self._valueArray), 1, 1, 2)
                else:
                    self._grid.addWidget(self.addElementButton, len(self._valueArray), 0, 1, 2)
예제 #22
0
    def __init__(self, parent):
        super(ItemHolder, self).__init__(parent)

        layout = QtWidgets.QGraphicsLinearLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)
예제 #23
0
    def dropOn(self, event):
        if event.isAccepted():
            return False, None, None, None

        index = QtWidgets.QModelIndex()
        row = -1
        col = -1

        if self.viewport().rect().contains(event.pos()):
            index = self.indexAt(event.pos())
            if (not index.isValid()
                    or not self.visualRect(index).contains(event.pos())):
                index = self.rootIndex()

        if self.model().supportedDropActions() & event.dropAction():
            if index != self.rootIndex():
                dropIndicatorPosition = self.position(event.pos(),
                                                      self.visualRect(index),
                                                      index)
                qabw = QtWidgets.QAbstractItemView
                if dropIndicatorPosition == qabw.AboveItem:
                    row = index.row()
                    col = index.column()
                elif dropIndicatorPosition == qabw.BelowItem:
                    row = index.row() + 1
                    col = index.column()
                else:
                    row = index.row()
                    col = index.column()

            if not self.droppingOnItself(event, index):
                return True, row, col, index

        return False, None, None, None
예제 #24
0
    def dropEvent(self, event):
        if not event.isAccepted() and event.source() == self:
            drop_row = self.drop_on(event)

            rows = sorted(set(item.row() for item in self.selectedItems()))
            rows_to_move = [[
                QtWidgets.QTableWidgetItem(self.item(row_index, column_index))
                for column_index in range(self.columnCount())
            ] for row_index in rows]

            for row_index in reversed(rows):
                self.removeRow(row_index)
                if row_index < drop_row:
                    drop_row -= 1

            for row_index, data in enumerate(rows_to_move):
                row_index += drop_row
                self.insertRow(row_index)
                for column_index, column_data in enumerate(data):
                    self.setItem(row_index, column_index, column_data)
            event.accept()
            for row_index in range(len(rows_to_move)):
                for column_index in range(self.columnCount()):
                    self.item(drop_row + row_index,
                              column_index).setSelected(True)
예제 #25
0
    def __init__(self, valueController, parent=None):
        super(LineEditor, self).__init__(valueController, parent=parent)

        hbox = QtWidgets.QHBoxLayout()

        self._editor = LineEditEditor(valueController, parent=self)
        hbox.addWidget(self._editor, 1)

        hbox.addStretch(0)
        hbox.setContentsMargins(0, 0, 0, 0)
        self.setLayout(hbox)
        self.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                           QtWidgets.QSizePolicy.Fixed)

        self.updateEditorValue()

        # we get lots of 'editingFinished' events,
        # so filter to only generate undos for important ones.
        self._value = valueController.getValue()

        def invokeSetter():
            value = self._editor.text()
            if self._value != value:
                self._value = value
                self._setValueToController()

        self._editor.editingFinished.connect(invokeSetter)

        self.setEditable(valueController.isEditable())
예제 #26
0
    def editRigName(self):
        dialog = QtWidgets.QInputDialog(self)
        dialog.setObjectName('RigNameDialog')
        text, ok = dialog.getText(self, 'Edit Rig Name', 'New Rig Name', text=self.guideRig.getName())

        if ok is True:
            self.setGuideRigName(text)
예제 #27
0
    def addValueEditor(self, name, widget):

        # widget.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        label = QtWidgets.QLabel(name, self)
        # label.setMaximumWidth(200)
        # label.setContentsMargins(0, 5, 0, 0)
        # label.setMinimumWidth(60)
        # label.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        # label.setAlignment(QtCore.Qt.AlignRight)
        # label.adjustSize()

        rowSpan = widget.getRowSpan()
        columnSpan = widget.getColumnSpan()
        # if columnSpan==1:
        self._grid.addWidget(label, self._gridRow, 0,
                             QtCore.Qt.AlignRight | QtCore.Qt.AlignTop)
        self._grid.addWidget(widget, self._gridRow, 1)  #, QtCore.Qt.AlignLeft)
        self._gridRow += 1
        # else:
        #     self._grid.addWidget(label, self._gridRow, 0, QtCore.Qt.AlignRight | QtCore.Qt.AlignTop)
        #     self._grid.addWidget(widget, self._gridRow+1, 0, rowSpan, columnSpan)
        #     self._gridRow += 2

        self._labels[name] = label
        self._editors[name] = widget
예제 #28
0
    def __init__(self, valueController, parent=None):
        super(Vec2Editor, self).__init__(valueController, parent=parent)

        self.__editors = []
        hbox = QtWidgets.QHBoxLayout()

        def defineLineEditSubEditor():
            widget = LineEdit(self)
            validator = QtGui.QDoubleValidator(self)
            validator.setDecimals(3)
            widget.setValidator(validator)
            self.__editors.append(widget)
            return widget

        self.__editXEditor = defineLineEditSubEditor()
        self.__editYEditor = defineLineEditSubEditor()

        hbox.addWidget(self.__editXEditor, 1)
        hbox.addWidget(self.__editYEditor, 1)
        hbox.addStretch(0)
        hbox.setContentsMargins(0, 0, 0, 0)
        self.setLayout(hbox)
        self.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed)

        self.updateEditorValue()

        self.__editXEditor.editingFinished.connect(self._setValueToController)
        self.__editYEditor.editingFinished.connect(self._setValueToController)

        self.setEditable( valueController.isEditable() )
예제 #29
0
    def openColorDialog(self):

        colorDialog = QtWidgets.QColorDialog()
        colorDialog.setOption(QtWidgets.QColorDialog.DontUseNativeDialog, True)
        newColor = colorDialog.getColor(self._color, self)
        if newColor.isValid():
            self._color = newColor
            self.colorChanged.emit(newColor)
예제 #30
0
    def reset(self):
        self.setScene(QtWidgets.QGraphicsScene())

        self.__connections = set()
        self.__nodes = {}
        self.__selection = set()

        self._manipulationMode = MANIP_MODE_NONE
        self._selectionRect = None