Example #1
0
 def __init__(self, parent=None):
     super(XTimeDeltaEdit, self).__init__(parent)
     
     # define custom properties
     self.setStyleSheet(COMBO_STYLE)
     
     self._numberSpinner = QSpinBox(self)
     self._numberSpinner.setRange(0, 100000)
     self._numberSpinner.setFrame(False)
     self._numberSpinner.setButtonSymbols(QSpinBox.NoButtons)
     self._numberSpinner.setSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Expanding)
     
     self._unitCombo = QComboBox(self)
     self._unitCombo.setEditable(True)
     self._unitCombo.setInsertPolicy(QComboBox.NoInsert)
     self._unitCombo.setFrame(False)
     self._unitCombo.addItems(['year(s)',
                               'month(s)',
                               'week(s)',
                               'day(s)',
                               'hour(s)',
                               'minute(s)',
                               'second(s)'])
     
     self._unitCombo.setCurrentIndex(3)
     self._unitCombo.setSizePolicy(QSizePolicy.Expanding,
                                   QSizePolicy.Expanding)
     
     self._directionCombo = QComboBox(self)
     self._directionCombo.addItems(['ago', 'from now'])
     self._directionCombo.setEditable(True)
     self._directionCombo.setInsertPolicy(QComboBox.NoInsert)
     self._directionCombo.setFrame(False)
     self._directionCombo.setSizePolicy(QSizePolicy.Expanding,
                                        QSizePolicy.Expanding)
     
     # setup ui
     self.setFrameShape(QFrame.StyledPanel)
     self.setFrameShadow(QFrame.Sunken)
     self.setBackgroundRole(QPalette.Base)
     self.setAutoFillBackground(True)
     
     layout = QHBoxLayout()
     layout.setContentsMargins(2, 2, 2, 2)
     layout.setSpacing(0)
     layout.addWidget(self._numberSpinner)
     layout.addWidget(self._unitCombo)
     layout.addWidget(self._directionCombo)
     self.setLayout(layout)
    def __init__(self, parent=None):
        super(XViewProfileManager, self).__init__(parent)

        # define custom properties
        self._profiles = []
        self._optionsMenuPolicy = Qt.DefaultContextMenu
        self._viewWidget = None

        # define the interface
        self._profileCombo = QComboBox(self)
        self._optionsButton = QToolButton(self)
        self._optionsButton.setAutoRaise(True)
        self._optionsButton.setToolTip('Advanced Options')
        self._optionsButton.setIcon(QIcon(resources.find('img/advanced.png')))

        layout = QHBoxLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)

        layout.addWidget(self._profileCombo)
        layout.addWidget(self._optionsButton)

        self.setLayout(layout)

        # create connections
        self._profileCombo.currentIndexChanged.connect(
            self.handleProfileChange)
        self._optionsButton.clicked.connect(self.showOptionsMenu)
Example #3
0
    def createEditor(self, parent, option, index):
        combo = QComboBox(parent)

        keys = Q.Op.keys()
        keys = map(lambda x: projex.text.joinWords(x, ' ').lower(), keys)

        combo.addItems(sorted(keys))
        combo.setEditable(True)
        combo.setInsertPolicy(QComboBox.NoInsert)

        return combo
Example #4
0
    def createEditor(self, parent, option, index):
        schema = self.parent().schema()
        if (not schema):
            return None

        colNames = map(lambda x: x.displayName(), schema.columns())

        combo = QComboBox(parent)
        combo.setEditable(True)
        combo.setInsertPolicy(QComboBox.NoInsert)
        combo.addItems(colNames)

        return combo
Example #5
0
    def createEditor(self, parent, option, index):
        tree = self.parent()
        querywidget = tree.parent()
        item = tree.itemFromIndex(index)
        if (isinstance(item, XQueryItem) and not item.childCount()):
            ttype = querywidget.tableType()
            options = querywidget.factory().columnOptions(ttype)

        elif (isinstance(item, XJoinItem)):
            options = ['and', 'or']

        combo = QComboBox(parent)
        combo.setEditable(True)
        combo.setInsertPolicy(QComboBox.NoInsert)
        combo.addItems(sorted(options))

        return combo
Example #6
0
    def createEditor(self, parent, option, index):
        combo = QComboBox(parent)

        item = self.parent().itemFromIndex(index)
        columnType = item.columnType()

        operators = Q.ColumnOps.get(columnType, Q.ColumnOps[None])

        # create the keys based on the column type
        keys = []
        for operator in operators:
            op_name = Q.Op[operator]
            keys.append(projex.text.joinWords(op_name, ' ').lower())

        combo.addItems(sorted(keys))
        combo.setEditable(True)
        combo.setInsertPolicy(QComboBox.NoInsert)

        return combo
    def createEditor(self, parent, schema, columnName, operatorType):
        """
        Returns an editor for the inputed table type, based on the column and
        operator types.
        
        :param      schema          | <orb.TableSchema>
                    columnName      | <str>
                    operatorType    | <orb.Query.Op>
        
        :return     <QWidget>
        """
        column = schema.column(columnName)
        if (not column):
            return None

        ctype = column.columnType()

        # based on the column and operator type, the editor may change
        if (ctype == ColumnType.String):
            if (operatorType in (Q.Op.IsIn, Q.Op.IsNotIn)):
                widget = XMultiTagEdit(parent)
            else:
                widget = QLineEdit(parent)

        elif (ctype == ColumnType.Bool):
            widget = QComboBox(parent)
            widget.addItems(['True', 'False'])
            widget.setEditable(True)
            widget.setInsertPolicy(QComboBox.NoInsert)

        elif (ctype == ColumnType.ForeignKey):
            widget = XOrbRecordBox(parent)
            widget.setRecords(self.collectRecords(column))

        else:
            widget = None

        return widget