Beispiel #1
0
    def __init__(self, valueController, parent=None):

        super(NestedEditor, self).__init__(valueController, parent=parent)

        self._value = self._invokeGetter()
        self._labels = {}
        self._editors = {}
        self._gridRow = 0
        self._grid = QtWidgets.QGridLayout()
        self._grid.setColumnStretch(1, 1)

        if self._valueController.hasOption('displayGroupbox'):
            groupBox = QtWidgets.QGroupBox(self._valueController.getDataType())
            groupBox.setLayout(self._grid)
            vbox = QtWidgets.QVBoxLayout()
            vbox.addWidget(groupBox)
            self.setLayout(vbox)
        else:
            self._grid.setContentsMargins(0, 0, 0, 0)
            self.setLayout(self._grid)
Beispiel #2
0
    def __init__(self, valueController, parent=None):
        super(ArrayEditor, self).__init__(valueController, parent=parent)

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

        self._enableAddElements = True  #valueController.getOption('enableAddElements', valueController.getOption('enableAddRemoveElements', True))
        self._enableRemoveElements = True  #valueController.getOption('enableRemoveElements', valueController.getOption('enableAddRemoveElements', True))

        self._addElementButtonLabel = 'add'  #valueController.getOption('addElementButtonLabel', 'add')
        self._removeElementButtonLabel = 'remove'  #valueController.getOption('removeElementButtonLabel', 'remove')

        self._displayGroupBox = False  #self._valueController.getOption('displayArrayLimit', True)
        self._displayIndex = False  #self._valueController.getOption('displayArrayLimit', True)
        self._displayArrayLimit = False  #self._valueController.getOption('displayArrayLimit', True)
        self._displayNumElements = False  #self._valueController.getOption('displayNumElements', True)
        self._arrayLimit = 3  #self._valueController.getOption('arrayLimit', 3)

        self._dataType = valueController.getDataType()

        self._valueArray = self._invokeGetter()
        self.determineElementType()

        vbox = QtWidgets.QVBoxLayout()

        if self._displayArrayLimit or self._displayNumElements:
            topToolbar = QtWidgets.QWidget(self)
            topToolbarLayout = QtWidgets.QHBoxLayout()
            topToolbar.setLayout(topToolbarLayout)
            vbox.addWidget(topToolbar, 0)

            if self._displayNumElements:
                topToolbarLayout.addWidget(
                    QtWidgets.QLabel(
                        'Num Elements:' + str(len(self._valueArray)), self))

            if self._displayArrayLimit:
                # display a widget to enable setting the maximum number of displayed elements.

                label = QtWidgets.QLabel('Max Displayed elements:', self)
                # label.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
                topToolbarLayout.addWidget(label, 0)

                spinBox = QtWidgets.QSpinBox(self)
                spinBox.setMinimum(0)
                spinBox.setMaximum(100)
                # spinBox.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
                spinBox.setValue(self._arrayLimit)

                def setArrayLimit(value):
                    self._arrayLimit = value
                    self.rebuild()

                spinBox.valueChanged.connect(setArrayLimit)
                topToolbarLayout.addWidget(spinBox, 0)
            topToolbarLayout.addStretch(1)

        self._grid = QtWidgets.QGridLayout()
        self._grid.setContentsMargins(0, 0, 0, 0)

        widget = QtWidgets.QWidget(self)
        widget.setLayout(self._grid)
        vbox.addWidget(widget)

        if self._displayGroupBox:
            groupBox = QtWidgets.QGroupBox(self._valueController.getDataType())
            groupBox.setLayout(vbox)
            groupBox.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                   QtWidgets.QSizePolicy.Expanding)

            groupBoxLayout = QtWidgets.QVBoxLayout()
            groupBoxLayout.addWidget(groupBox, 0)
            self.setLayout(groupBoxLayout)
        else:
            self.setLayout(vbox)

        self.build()

        if self._elementValueType == 'String':
            self.setAcceptDrops(self.isEditable())