Esempio n. 1
0
class XOrbQueryPlugin(object):
    Flags = enum('ReferenceRequired')
    
    def __init__(self):
        self._operatorMap = OrderedDict()
        
    def createEditor(self, parent, column, op, value):
        """
        Creates a new editor for the parent based on the plugin parameters.
        
        :param      parent | <QWidget>
        
        :return     <QWidget> || None
        """
        try:
            cls = self._operatorMap[nativestring(op)].cls
        except KeyError, AttributeError:
            return None
        
        # create the new editor
        if cls:
            widget = cls(parent)
            widget.setAttribute(Qt.WA_DeleteOnClose)
            projexui.setWidgetValue(widget, value)
            return widget
        
        return None
Esempio n. 2
0
 def createEditor(self, parent, column, op, value):
     """
     Creates a new editor for the parent based on the plugin parameters.
     
     :param      parent | <QWidget>
     
     :return     <QWidget> || None
     """
     _, cls, _ = self._operatorMap.get(str(op), (None, None, None))
     
     # create the new editor
     if cls:
         widget = cls(parent)
         widget.setAttribute(Qt.WA_DeleteOnClose)
         projexui.setWidgetValue(widget, value)
         return widget
     
     return None
    def setQuery(self, query):
        """
        Sets the query information for this filter widget.
        
        :param      query | <orb.Query> || None
        """
        if query is None:
            return

        count = {}

        for widget in self.findChildren(QWidget):
            column = nativestring(widget.objectName())
            count.setdefault(column, 0)
            count[column] += 1

            success, value, _ = query.findValue(column, count[column])
            if success:
                projexui.setWidgetValue(widget, value)
 def setQuery(self, query):
     """
     Sets the query information for this filter widget.
     
     :param      query | <orb.Query> || None
     """
     if query is None:
         return
     
     count = {}
     
     for widget in self.findChildren(QWidget):
         column = nativestring(widget.objectName())
         count.setdefault(column, 0)
         count[column] += 1
         
         success, value, _ = query.findValue(column, count[column])
         if success:
             projexui.setWidgetValue(widget, value)
Esempio n. 5
0
 def refreshUi( self ):
     """
     Load the plugin information to the interface.
     """
     dataSet = self.dataSet()
     if not dataSet:
         return False
         
     # lookup widgets based on the data set information
     for widget in self.findChildren(QWidget):
         prop = unwrapVariant(widget.property('dataName'))
         if prop is None:
             continue
         
         # update the data for the widget
         prop_name = str(prop)
         if prop_name in dataSet:
             value = dataSet.value(prop_name)
             projexui.setWidgetValue(widget, value)
     
     return True
Esempio n. 6
0
 def refreshUi( self ):
     """
     Load the plugin information to the interface.
     """
     dataSet = self.dataSet()
     if not dataSet:
         return False
         
     # lookup widgets based on the data set information
     for widget in self.findChildren(QWidget):
         prop = unwrapVariant(widget.property('dataName'))
         if prop is None:
             continue
         
         # update the data for the widget
         prop_name = nativestring(prop)
         if prop_name in dataSet:
             value = dataSet.value(prop_name)
             projexui.setWidgetValue(widget, value)
     
     return True
Esempio n. 7
0
    def loadValues(self, values):
        """
        Loads the values from the inputed dictionary to the widget.
        
        :param      values | <dict>
        """
        table = self.tableType()
        if table:
            schema = table.schema()
        else:
            schema = None

        process = []
        for widget in self.findChildren(QWidget):
            prop = widget.property('columnName')
            if not prop:
                continue

            order = widget.property('columnOrder')
            if order:
                order = unwrapVariant(order)
            else:
                order = 10000000

            process.append((order, widget, prop))

        process.sort()
        for order, widget, prop in process:
            columnName = str(unwrapVariant(prop, ''))

            if not columnName:
                continue

            if isinstance(widget, XEnumBox) and schema:
                column = schema.column(columnName)
                if column.enum() is not None:
                    widget.setEnum(column.enum())

            if columnName in values:
                projexui.setWidgetValue(widget, values.get(columnName))
Esempio n. 8
0
 def loadValues(self, values):
     """
     Loads the values from the inputed dictionary to the widget.
     
     :param      values | <dict>
     """
     table = self.tableType()
     if table:
         schema = table.schema()
     else:
         schema = None
     
     process = []
     for widget in self.findChildren(QWidget):
         prop = widget.property('columnName')
         if not prop:
             continue
         
         order = widget.property('columnOrder')
         if order:
             order = unwrapVariant(order)
         else:
             order = 10000000
         
         process.append((order, widget, prop))
     
     process.sort()
     for order, widget, prop in process:
         columnName = nativestring(unwrapVariant(prop, ''))
         
         if not columnName:
             continue
         
         if isinstance(widget, XEnumBox) and schema:
             column = schema.column(columnName)
             if column.enum() is not None:
                 widget.setEnum(column.enum())
         
         if columnName in values:
             projexui.setWidgetValue(widget, values.get(columnName))
Esempio n. 9
0
    def __init__(self, scaffold, parent=None):
        super(XScaffoldPropertiesPage, self).__init__(parent)

        # setup the scaffolding options
        self._scaffold = scaffold

        self.setTitle('Properties')
        self.setSubTitle('Setup scaffold properties')

        if scaffold.uifile():
            projexui.loadUi(__file__, self, scaffold.uifile())
        else:
            layout = QtGui.QFormLayout()

            for prop in scaffold.properties():
                # define the text
                text = prop.label
                if prop.required:
                    text += '*'
                text += ':'

                # create a checkbox
                if prop.type == 'bool':
                    widget = QtGui.QCheckBox(self)
                    widget.setProperty('propertyName', wrapVariant(prop.name))
                    widget.setText(text.strip(':'))
                    layout.addRow(None, widget)

                # create a float
                elif prop.type == 'int':
                    lbl = QtGui.QLabel(text, self)
                    widget = QtGui.QSpinBox(self)
                    widget.setProperty('propertyName', wrapVariant(prop.name))
                    layout.addRow(lbl, widget)

                # create a double
                elif prop.type == 'float':
                    lbl = QtGui.QLabel(text, self)
                    widget = QtGui.QDoubleSpinBox(self)
                    widget.setProperty('propertyName', wrapVariant(prop.name))
                    layout.addRow(lbl, widget)

                # create a text edit
                elif prop.type == 'text':
                    lbl = QtGui.QLabel(text, self)
                    widget = XTextEdit(self)
                    widget.setProperty('propertyName', wrapVariant(prop.name))
                    layout.addRow(lbl, widget)

                # create a filepath
                elif prop.type == 'file':
                    lbl = QtGui.QLabel(text, self)
                    widget = XFilepathEdit(self)

                # create an icon
                elif prop.type == 'icon':
                    widget = XIconButton(self)
                    layout.addRow(lbl, widget)

                # create a line edit
                else:
                    lbl = QtGui.QLabel(text, self)

                    if prop.choices:
                        widget = XComboBox(self)
                        widget.setProperty('dataType', 'string')
                        widget.addItems([''] + prop.choices)
                    else:
                        widget = XLineEdit(self)

                        if prop.regex:
                            regexp = QtCore.QRegExp(prop.regex)
                            validator = QtGui.QRegExpValidator(regexp, widget)
                            widget.setValidator(validator)

                    widget.setProperty('propertyName', wrapVariant(prop.name))
                    layout.addRow(lbl, widget)

            self.setLayout(layout)

        for prop, widget in self.propertyWidgetMap().items():
            if prop.default is not None:
                try:
                    widget.setHint(prop.default)
                except AttributeError:
                    projexui.setWidgetValue(widget, prop.default)
Esempio n. 10
0
    def __init__(self, scaffold, parent=None):
        super(XScaffoldPropertiesPage, self).__init__(parent)
        
        # setup the scaffolding options
        self._scaffold = scaffold
        
        self.setTitle('Properties')
        self.setSubTitle('Setup scaffold properties')
        
        if scaffold.uifile():
            projexui.loadUi(__file__, self, scaffold.uifile())
        else:
            layout = QtGui.QFormLayout()
            
            for prop in scaffold.properties():
                # define the text
                text = prop.label
                if prop.required:
                    text += '*'
                text += ':'
                
                # create a checkbox
                if prop.type == 'bool':
                    widget = QtGui.QCheckBox(self)
                    widget.setProperty('propertyName', wrapVariant(prop.name))
                    widget.setText(text.strip(':'))
                    layout.addRow(None, widget)
                
                # create a float
                elif prop.type == 'int':
                    lbl = QtGui.QLabel(text, self)
                    widget = QtGui.QSpinBox(self)
                    widget.setProperty('propertyName', wrapVariant(prop.name))
                    layout.addRow(lbl, widget)
                
                # create a double
                elif prop.type == 'float':
                    lbl = QtGui.QLabel(text, self)
                    widget = QtGui.QDoubleSpinBox(self)
                    widget.setProperty('propertyName', wrapVariant(prop.name))
                    layout.addRow(lbl, widget)
                
                # create a text edit
                elif prop.type == 'text':
                    lbl = QtGui.QLabel(text, self)
                    widget = XTextEdit(self)
                    widget.setProperty('propertyName', wrapVariant(prop.name))
                    layout.addRow(lbl, widget)

                # create a filepath
                elif prop.type == 'file':
                    lbl = QtGui.QLabel(text, self)
                    widget = XFilepathEdit(self)

                # create an icon
                elif prop.type == 'icon':
                    widget = XIconButton(self)
                    layout.addRow(lbl, widget)

                # create a line edit
                else:
                    lbl = QtGui.QLabel(text, self)
                    
                    if prop.choices:
                        widget = XComboBox(self)
                        widget.setProperty('dataType', 'string')
                        widget.addItems([''] + prop.choices)
                    else:
                        widget = XLineEdit(self)
                        
                        if prop.regex:
                            regexp = QtCore.QRegExp(prop.regex)
                            validator = QtGui.QRegExpValidator(regexp, widget)
                            widget.setValidator(validator)
                    
                    widget.setProperty('propertyName', wrapVariant(prop.name))
                    layout.addRow(lbl, widget)
            
            self.setLayout(layout)

        for prop, widget in self.propertyWidgetMap().items():
            if prop.default is not None:
                try:
                    widget.setHint(prop.default)
                except AttributeError:
                    projexui.setWidgetValue(widget, prop.default)