Example #1
0
    def __init__(self, parent=None):
        super(XConsoleView, self).__init__(parent, autoKillThreads=False)

        # load the user interface
        projexui.loadUi(__file__, self)

        # define custom properties
        self._locked = False
        self._lastDetails = True
        self._lastHeight = None

        # set default properties
        self.uiConsoleEDIT.setLogger(logging.root)
        self.uiLoggerDDL.addItem(ROOT_LOGGER_TEXT)
        self.uiLoggerDDL.addItem('-----------')
        self.lockHeight()

        self.uiFindWIDGET.hide()

        all_loggers = logging.root.manager.loggerDict.keys()
        self.uiLoggerDDL.addItems(sorted(all_loggers))
        self.adjustLoggerIcons()

        # load level drop down list
        order = []
        size = QSize(120, 20)
        for i, item in enumerate(sorted(XLoggerWidget.LoggingMap.items())):
            level, data = item
            self.uiLevelDDL.addItem(projex.text.pretty(data[0]))
            self.uiLevelDDL.setItemIcon(i, QIcon(data[1]))
            self.uiLevelDDL.setItemData(i, wrapVariant(level))
            self.uiLevelDDL.setItemData(i, wrapVariant(size), Qt.SizeHintRole)

            if (logging.root.getEffectiveLevel() == level):
                self.uiLevelDDL.setCurrentIndex(i)

        # link the find widget with the text edit
        self.uiFindWIDGET.setTextEdit(self.uiConsoleEDIT)

        # create connections
        self.uiLevelDDL.currentIndexChanged.connect(self.adjustLevel)
        self.uiShowLevelCHK.toggled.connect(self.uiConsoleEDIT.setShowLevel)
        self.uiShowDetailsCHK.toggled.connect(
            self.uiConsoleEDIT.setShowDetails)
        self.uiShowDetailsCHK.clicked.connect(self.setLastDetails)
        self.uiLoggerDDL.currentIndexChanged.connect(self.updateLogger)
        self.uiMoreBTN.clicked.connect(self.unlockHeight)
        self.uiLessBTN.clicked.connect(self.lockHeight)
Example #2
0
 def createLexer( self, parent = None, colorSet = None ):
     # create an instance of the lexer
     cls = self.lexerType()
     if ( not cls ):
         return None
         
     output = cls(parent)
     if ( output and parent ):
         try:
             parent.setLexer(output)
         except AttributeError:
             pass
         
         # set lexer property options
         for key, value in self.lexerProperties().items():
             setter = getattr(output, 'set' + key[0].upper() + key[1:], None)
             if setter:
                 setter(value)
             else:
                 output.setProperty(key, wrapVariant(value))
         
         output.setFont(parent.font())
         
         if ( colorSet ):
             self.setColorSet(output, colorSet)
         
     return output
Example #3
0
    def createActionItem(self, key):
        """
        Creates a new action item for the inputed key.
        
        :param      key | <str>
        
        :return     <QTreeWidgetItem>
        """
        action = self._actions.get(key)
        if (not action):
            text = 'Missing Action: %s' % key
            item = QTreeWidgetItem([text])
            ico = projexui.resources.find('img/log/warning.png')
            item.setIcon(0, QIcon(ico))
        else:
            item = QTreeWidgetItem(
                [nativestring(action.text()).replace('&', '')])
            item.setIcon(0, action.icon())

        item.setSizeHint(0, QSize(120, 20))
        item.setData(0, Qt.UserRole, wrapVariant(key))

        flags = item.flags()
        flags ^= Qt.ItemIsDropEnabled
        item.setFlags(flags)

        return item
Example #4
0
 def addRecords(self, records):
     """
     Adds the given record to the system.
     
     :param      records | [<orb.Table>, ..]
     """
     label_mapper    = self.labelMapper()
     icon_mapper     = self.iconMapper()
     
     # create the items to display
     tree = None
     if self.showTreePopup():
         tree = self.treePopupWidget()
         tree.blockSignals(True)
         tree.setUpdatesEnabled(False)
     
     # add the items to the list
     start = self.count()
     self.addItems(map(label_mapper, records))
     
     # update the item information
     for i, record in enumerate(records):
         index = start + i
         
         self.setItemData(index, wrapVariant(record), Qt.UserRole)
         
         if icon_mapper:
             self.setItemIcon(index, icon_mapper(record))
         
         if tree:
             XOrbRecordItem(tree, record)
     
     if tree:
         tree.blockSignals(False)
         tree.setUpdatesEnabled(True)
Example #5
0
 def addRecordsFromThread(self, records):
     """
     Adds the given record to the system.
     
     :param      records | [<orb.Table>, ..]
     """
     label_mapper    = self.labelMapper()
     icon_mapper     = self.iconMapper()
     
     tree = None
     if self.showTreePopup():
         tree = self.treePopupWidget()
     
     # add the items to the list
     start = self.count()
     
     # update the item information
     blocked = self.signalsBlocked()
     self.blockSignals(True)
     for i, record in enumerate(records):
         index = start + i
         self.addItem(label_mapper(record))
         self.setItemData(index, wrapVariant(record), Qt.UserRole)
         
         if icon_mapper:
             self.setItemIcon(index, icon_mapper(record))
         
         if record == self._currentRecord:
             self.setCurrentIndex(self.count() - 1)
         
         if tree:
             XOrbRecordItem(tree, record)
     self.blockSignals(blocked)
Example #6
0
    def syncTree(self, recursive=False, blockSignals=True):
        """
        Syncs the information from this item to the tree.
        """
        tree = self.treeWidget()

        # sync the tree information
        if not tree:
            return

        if blockSignals:
            tree.blockSignals(True)

        date_format = self.ganttWidget().dateFormat()
        for c, col in enumerate(tree.columns()):
            value = self.property(col, '')
            #if (col == "Work Days" or col == "Calendar Days"):
            self.setData(c, Qt.EditRole, qt.wrapVariant(value))

        if recursive:
            for i in range(self.childCount()):
                self.child(i).syncTree(recursive=True, blockSignals=False)

        if blockSignals:
            tree.blockSignals(False)
Example #7
0
 def addItems(self, menus, processed=None):
     """
     Adds items to the completion tree from the menu.
     
     :param      menus | [<QMenu>, ..]
                 procesed | [<QAction>, ..] || None
     """
     if processed is None:
         processed = []
     
     for menu in menus:
         for action in menu.actions():
             # since we can have 1 action in more than 1 submenu, we
             # will want to make sure we're only adding a unique one
             # so we don't have duplicates
             text = nativestring(action.text())
             if text in processed or action.isSeparator():
                 continue
             
             processed.append(text)
             
             if text and unwrapVariant(action.data()) != 'menu':
                 item = XTreeWidgetItem(self._completer, [text])
                 item.setFixedHeight(20)
                 item.setIcon(0, action.icon())
                 item.setToolTip(0, action.toolTip())
                 item.setData(0, Qt.UserRole, wrapVariant(action))
Example #8
0
    def addItems(self, menus, processed=None):
        """
        Adds items to the completion tree from the menu.
        
        :param      menus | [<QMenu>, ..]
                    procesed | [<QAction>, ..] || None
        """
        if processed is None:
            processed = []

        for menu in menus:
            for action in menu.actions():
                # since we can have 1 action in more than 1 submenu, we
                # will want to make sure we're only adding a unique one
                # so we don't have duplicates
                text = nativestring(action.text())
                if text in processed or action.isSeparator():
                    continue

                processed.append(text)

                if text and unwrapVariant(action.data()) != 'menu':
                    item = XTreeWidgetItem(self._completer, [text])
                    item.setFixedHeight(20)
                    item.setIcon(0, action.icon())
                    item.setToolTip(0, action.toolTip())
                    item.setData(0, Qt.UserRole, wrapVariant(action))
Example #9
0
    def syncTree(self, recursive=False, blockSignals=True):
        """
        Syncs the information from this item to the tree.
        """
        tree = self.treeWidget()

        # sync the tree information
        if not tree:
            return

        items = [self]
        if recursive:
            items += list(self.children(recursive=True))

        if blockSignals and not tree.signalsBlocked():
            blocked = True
            tree.blockSignals(True)
        else:
            blocked = False

        date_format = self.ganttWidget().dateFormat()

        for item in items:
            for c, col in enumerate(tree.columns()):
                value = item.property(col, '')
                item.setData(c, Qt.EditRole, wrapVariant(value))

        if blocked:
            tree.blockSignals(False)
Example #10
0
    def setProperty(self, key, value):
        """
        Sets the custom property for this item's key to the inputed value.  If
        the widget has a column that matches the inputed key, then the value 
        will be added to the tree widget as well.
        
        :param      key     | <str>
                    value   | <variant>
        """
        if key == 'Name':
            self.setName(value)
        elif key == 'Start':
            self.setDateStart(value)
        elif key == 'End':
            self.setDateEnd(value)
        elif key == 'Calendar Days':
            self.setDuration(value)
        elif key == 'Time Start':
            self.setTimeStart(value)
        elif key == 'Time End':
            self.setTimeEnd(value)
        elif key == 'All Day':
            self.setAllDay(value)
        elif key == 'Workadys':
            pass
        else:
            self._properties[nativestring(key)] = value

            tree = self.treeWidget()
            if tree:
                col = tree.column(key)
                if col != -1:
                    self.setData(col, Qt.EditRole, wrapVariant(value))
Example #11
0
 def saveSettings(self, settings):
     """
     Saves these profiles as settings.
     
     :param      settings | <QSettings>
     """
     settings.setValue('profile_toolbar', wrapVariant(self.toString()))
Example #12
0
    def createLexer(self, parent=None, colorSet=None):
        # create an instance of the lexer
        cls = self.lexerType()
        if (not cls):
            return None

        output = cls(parent)
        if (output and parent):
            try:
                parent.setLexer(output)
            except AttributeError:
                pass

            # set lexer property options
            for key, value in self.lexerProperties().items():
                setter = getattr(output, 'set' + key[0].upper() + key[1:],
                                 None)
                if setter:
                    setter(value)
                else:
                    output.setProperty(key, wrapVariant(value))

            output.setFont(parent.font())

            if (colorSet):
                self.setColorSet(output, colorSet)

        return output
 def createActionItem( self, key ):
     """
     Creates a new action item for the inputed key.
     
     :param      key | <str>
     
     :return     <QTreeWidgetItem>
     """
     action = self._actions.get(key)
     if ( not action ):
         text = 'Missing Action: %s' % key
         item = QTreeWidgetItem([text])
         ico = projexui.resources.find('img/log/warning.png')
         item.setIcon(0, QIcon(ico))
     else:
         item = QTreeWidgetItem([str(action.text()).replace('&', '')])
         item.setIcon(0, action.icon())
     
     item.setSizeHint(0, QSize(120, 20))
     item.setData(0, Qt.UserRole, qt.wrapVariant(key))
     
     flags = item.flags()
     flags ^= Qt.ItemIsDropEnabled
     item.setFlags(flags)
     
     return item
 def saveSettings(self, settings):
     """
     Saves these profiles as settings.
     
     :param      settings | <QSettings>
     """
     settings.setValue('profile_toolbar', wrapVariant(self.toString()))
Example #15
0
    def addRecords(self, records):
        """
        Adds the given record to the system.
        
        :param      records | [<orb.Table>, ..]
        """
        label_mapper = self.labelMapper()
        icon_mapper = self.iconMapper()

        # create the items to display
        tree = None
        if self.showTreePopup():
            tree = self.treePopupWidget()
            tree.blockSignals(True)
            tree.setUpdatesEnabled(False)

        # add the items to the list
        start = self.count()
        self.addItems(map(label_mapper, records))

        # update the item information
        for i, record in enumerate(records):
            index = start + i

            self.setItemData(index, wrapVariant(record), Qt.UserRole)

            if icon_mapper:
                self.setItemIcon(index, icon_mapper(record))

            if tree:
                XOrbRecordItem(tree, record)

        if tree:
            tree.blockSignals(False)
            tree.setUpdatesEnabled(True)
Example #16
0
 def itemChange( self, change, value ):
     """
     Overloads the base QGraphicsItem itemChange method to block user ability
     to move along the y-axis.
     
     :param      change      <int>
     :param      value       <variant>
     
     :return     <variant>
     """
     # only operate when it is a visible, geometric change
     if not (self.isVisible() and change == self.ItemPositionChange):
         return super(XGanttViewItem, self).itemChange( change, value )
     
     if self.isSyncing():
         return super(XGanttViewItem, self).itemChange(change, value)
     
     scene = self.scene()
     # only operate when we have a scene
     if not scene:
         return super(XNode, self).itemChange( change, value )
     
     point = value.toPointF()
     point.setY(self.pos().y())
     
     # create the return value
     new_value = wrapVariant(point)
     
     # call the base method to operate on the new point
     return super(XGanttViewItem, self).itemChange(change, new_value)
Example #17
0
    def itemChange(self, change, value):
        """
        Overloads the base QGraphicsItem itemChange method to block user ability
        to move along the y-axis.
        
        :param      change      <int>
        :param      value       <variant>
        
        :return     <variant>
        """
        # only operate when it is a visible, geometric change
        if (not (self.isVisible() and change == self.ItemPositionChange)):
            return super(XGanttViewItem, self).itemChange(change, value)

        if (self.isSyncing()):
            return super(XGanttViewItem, self).itemChange(change, value)

        scene = self.scene()
        # only operate when we have a scene
        if (not scene):
            return super(XNode, self).itemChange(change, value)

        point = value.toPointF()
        point.setY(self.pos().y())

        # create the return value
        new_value = qt.wrapVariant(point)

        # call the base method to operate on the new point
        return super(XGanttViewItem, self).itemChange(change, new_value)
Example #18
0
 def syncTree(self, recursive=False, blockSignals=True):
     """
     Syncs the information from this item to the tree.
     """
     tree = self.treeWidget()
     
     # sync the tree information
     if not tree:
         return
     
     items = [self]
     if recursive:
         items += list(self.children(recursive=True))
     
     if blockSignals and not tree.signalsBlocked():
         blocked = True
         tree.blockSignals(True)
     else:
         blocked = False
     
     date_format = self.ganttWidget().dateFormat()
     
     for item in items:
         for c, col in enumerate(tree.columns()):
             value = item.property(col, '')
             item.setData(c, Qt.EditRole, wrapVariant(value))
     
     if blocked:
         tree.blockSignals(False)
Example #19
0
    def addRecordsFromThread(self, records):
        """
        Adds the given record to the system.
        
        :param      records | [<orb.Table>, ..]
        """
        label_mapper = self.labelMapper()
        icon_mapper = self.iconMapper()

        tree = None
        if self.showTreePopup():
            tree = self.treePopupWidget()

        # add the items to the list
        start = self.count()

        # update the item information
        blocked = self.signalsBlocked()
        self.blockSignals(True)
        for i, record in enumerate(records):
            index = start + i
            self.addItem(label_mapper(record))
            self.setItemData(index, wrapVariant(record), Qt.UserRole)

            if icon_mapper:
                self.setItemIcon(index, icon_mapper(record))

            if record == self._currentRecord:
                self.setCurrentIndex(self.count() - 1)

            if tree:
                XOrbRecordItem(tree, record)
        self.blockSignals(blocked)
    def syncTree(self, recursive=False, blockSignals=True):
        """
        Syncs the information from this item to the tree.
        """
        tree = self.treeWidget()
        
        # sync the tree information
        if not tree:
            return
        
        if blockSignals:
            tree.blockSignals(True)

        date_format = self.ganttWidget().dateFormat()
        for c, col in enumerate(tree.columns()):
            value = self.property(col, '')
            #if (col == "Work Days" or col == "Calendar Days"):
            self.setData(c, Qt.EditRole, qt.wrapVariant(value))
        
        if recursive:
            for i in range(self.childCount()):
                self.child(i).syncTree(recursive=True, blockSignals=False)
        
        if blockSignals:
            tree.blockSignals(False)
Example #21
0
 def setProperty(self, key, value):
     """
     Sets the custom property for this item's key to the inputed value.  If
     the widget has a column that matches the inputed key, then the value 
     will be added to the tree widget as well.
     
     :param      key     | <str>
                 value   | <variant>
     """
     if key == 'Name':
         self.setName(value)
     elif key == 'Start':
         self.setDateStart(value)
     elif key == 'End':
         self.setDateEnd(value)
     elif key == 'Calendar Days':
         self.setDuration(value)
     elif key == 'Time Start':
         self.setTimeStart(value)
     elif key == 'Time End':
         self.setTimeEnd(value)
     elif key == 'All Day':
         self.setAllDay(value)
     elif key == 'Workadys':
         pass
     else:
         self._properties[nativestring(key)] = value
         
         tree = self.treeWidget()
         if tree:
             col = tree.column(key)
             if col != -1:
                 self.setData(col, Qt.EditRole, wrapVariant(value))
Example #22
0
    def adjustLoggerIcons(self):
        """
        Updates the logger icons for all the loggers in the system.
        """
        default = XLoggerWidget.LoggingMap.get(
            logging.root.getEffectiveLevel())
        if (not default):
            default = XLoggerWidget.LoggingMap[logging.DEBUG]

        size = QSize(120, 20)
        for i in range(self.uiLoggerDDL.count()):
            text = str(self.uiLoggerDDL.itemText(i))
            if (text.startswith('---')):
                continue

            if (text == ROOT_LOGGER_TEXT):
                logger = logging.root
            else:
                logger = logging.getLogger(text)

            level = logger.getEffectiveLevel()
            icon = XLoggerWidget.LoggingMap.get(level, default)[1]

            self.uiLoggerDDL.setItemIcon(i, QIcon(icon))
            self.uiLoggerDDL.setItemData(i, wrapVariant(size), Qt.SizeHintRole)
Example #23
0
 def __init__(self, parent=None):
     super(XConsoleView, self).__init__(parent, autoKillThreads=False)
     
     # load the user interface
     projexui.loadUi(__file__, self)
     
     # define custom properties
     self._locked        = False
     self._lastDetails   = True
     self._lastHeight    = None
     
     # set default properties
     self.uiConsoleEDIT.setLogger(logging.root)
     self.uiLoggerDDL.addItem(ROOT_LOGGER_TEXT)
     self.uiLoggerDDL.addItem('-----------')
     self.lockHeight()
     
     self.uiFindWIDGET.hide()
     
     all_loggers = logging.root.manager.loggerDict.keys()
     self.uiLoggerDDL.addItems(sorted(all_loggers))
     self.adjustLoggerIcons()
     
     # load level drop down list
     order = []
     size = QSize(120, 20)
     for i, item in enumerate(sorted(XLoggerWidget.LoggingMap.items())):
         level, data = item
         self.uiLevelDDL.addItem(projex.text.pretty(data[0]))
         self.uiLevelDDL.setItemIcon(i, QIcon(data[1]))
         self.uiLevelDDL.setItemData(i, wrapVariant(level))
         self.uiLevelDDL.setItemData(i, wrapVariant(size), Qt.SizeHintRole)
         
         if ( logging.root.getEffectiveLevel() == level ):
             self.uiLevelDDL.setCurrentIndex(i)
     
     # link the find widget with the text edit
     self.uiFindWIDGET.setTextEdit(self.uiConsoleEDIT)
     
     # create connections
     self.uiLevelDDL.currentIndexChanged.connect( self.adjustLevel )
     self.uiShowLevelCHK.toggled.connect( self.uiConsoleEDIT.setShowLevel )
     self.uiShowDetailsCHK.toggled.connect(self.uiConsoleEDIT.setShowDetails)
     self.uiShowDetailsCHK.clicked.connect(self.setLastDetails)
     self.uiLoggerDDL.currentIndexChanged.connect( self.updateLogger )
     self.uiMoreBTN.clicked.connect( self.unlockHeight )
     self.uiLessBTN.clicked.connect( self.lockHeight )
Example #24
0
 def saveSettings(self, settings):
     """
     Saves the files for this menu to the settings.
     
     :param      settings | <QSettings>
     """
     value = wrapVariant(os.path.pathsep.join(self.filenames()))
     settings.setValue('recent_files', value)
 def saveSettings(self, settings):
     """
     Saves the files for this menu to the settings.
     
     :param      settings | <QSettings>
     """
     value = wrapVariant(os.path.pathsep.join(self.filenames()))
     settings.setValue('recent_files', value)
Example #26
0
def saveDataSet( settings, key, dataSet ):
    """
    Records the dataset settings to the inputed data set for the given key.
    
    :param      settings | <QSettings>
                key      | <str>
                dataSet  | <projex.dataset.DataSet>
    """
    for datakey, value in dataSet.items():
        datatype  = type(value).__name__
        
        if ( datatype in _dataValueTypes ):
            datavalue = _dataValueTypes[datatype][0](value)
        else:
            datavalue = value
        
        settings.setValue('%s/%s/type' % (key, datakey), wrapVariant(datatype))
        settings.setValue('%s/%s/value' % (key, datakey), wrapVariant(datavalue))
 def refresh( self ):
     """
     Clears out the actions for this menu and then loads the files.
     """
     self.clear()
     
     for i, filename in enumerate(self.filenames()):
         name   = '%i. %s' % (i+1, os.path.basename(filename))
         action = self.addAction(name)
         action.setData(wrapVariant(filename))
Example #28
0
 def refresh( self ):
     """
     Clears out the actions for this menu and then loads the files.
     """
     self.clear()
     
     for i, filename in enumerate(self.filenames()):
         name   = '%i. %s' % (i+1, os.path.basename(filename))
         action = self.addAction(name)
         action.setData(wrapVariant(filename))
Example #29
0
def saveDataSet(settings, key, dataSet):
    """
    Records the dataset settings to the inputed data set for the given key.
    
    :param      settings | <QSettings>
                key      | <str>
                dataSet  | <projex.dataset.DataSet>
    """
    for datakey, value in dataSet.items():
        datatype = type(value).__name__

        if (datatype in _dataValueTypes):
            datavalue = _dataValueTypes[datatype][0](value)
        else:
            datavalue = value

        settings.setValue('%s/%s/type' % (key, datakey), wrapVariant(datatype))
        settings.setValue('%s/%s/value' % (key, datakey),
                          wrapVariant(datavalue))
Example #30
0
 def setValue(self, key, value):
     """
     Sets the value for the given key to the inputed value.
     
     :param      key | <str>
                 value | <variant>
     """
     if self._customFormat:
         self._customFormat.setValue(key, value)
     else:
         super(XSettings, self).setValue(key, wrapVariant(value))
Example #31
0
 def setValue(self, key, value):
     """
     Sets the value for the given key to the inputed value.
     
     :param      key | <str>
                 value | <variant>
     """
     if self._customFormat:
         self._customFormat.setValue(key, value)
     else:
         super(XSettings, self).setValue(key, wrapVariant(value))
Example #32
0
    def updateColumnValue(self, column, value, index=None):
        """
        Assigns the value for the column of this record to the inputed value.
        
        :param      index | <int>
                    value | <variant>
        """
        if index is None:
            index = self.treeWidget().column(column.name())

        if type(value) == datetime.date:
            self.setData(index, Qt.EditRole, wrapVariant(value))
        elif type(value) == datetime.time:
            self.setData(index, Qt.EditRole, wrapVariant(value))
        elif type(value) == datetime.datetime:
            self.setData(index, Qt.EditRole, wrapVariant(value))
        elif type(value) in (float, int):
            if column.enum():
                self.setText(index, column.enum().displayText(value))
            else:
                self.setData(index, Qt.EditRole, wrapVariant(value))
        elif value is not None:
            self.setText(index, nativestring(value))
        else:
            self.setText(index, "")

        self.setSortData(index, value)

        # map default value information
        try:
            mapper = self.treeWidget().columnMappers().get(column.columnName())
        except AttributeError:
            mapper = None

        if mapper is None:
            form = column.stringFormat()
            if form:
                mapper = form.format

        if mapper:
            self.setText(index, mapper(value))
Example #33
0
    def setName(self, name):
        """
        Sets the name of this widget item to the inputed name.
        
        :param      name | <str>
        """
        self._name = name

        tree = self.treeWidget()
        if tree:
            col = tree.column('Name')
            if col != -1:
                self.setData(col, Qt.EditRole, wrapVariant(name))
Example #34
0
 def setName(self, name):
     """
     Sets the name of this widget item to the inputed name.
     
     :param      name | <str>
     """
     self._name = name
     
     tree = self.treeWidget()
     if tree:
         col = tree.column('Name')
         if col != -1:
             self.setData(col, Qt.EditRole, wrapVariant(name))
Example #35
0
 def updateColumnValue(self, column, value, index=None):
     """
     Assigns the value for the column of this record to the inputed value.
     
     :param      index | <int>
                 value | <variant>
     """
     if index is None:
         index = self.treeWidget().column(column.name())
     
     if type(value) == datetime.date:
         self.setData(index, Qt.EditRole, wrapVariant(value))
     elif type(value) == datetime.time:
         self.setData(index, Qt.EditRole, wrapVariant(value))
     elif type(value) == datetime.datetime:
         self.setData(index, Qt.EditRole, wrapVariant(value))
     elif type(value) in (float, int):
         self.setData(index, Qt.EditRole, wrapVariant(value))
     elif value is not None:
         self.setText(index, str(value))
     else:
         self.setText(index, '')
     
     self.setSortData(index, value)
     
     # map default value information
     try:
         mapper = self.treeWidget().columnMappers().get(column.columnName())
     except AttributeError:
         mapper = None
     
     if mapper is None:
         form = column.stringFormat()
         if form:
             mapper = form.format
     
     if mapper:
         self.setText(index, mapper(value))
Example #36
0
    def __init__(self, parent, uifile=''):
        uifile = ''

        super(XSchemeConfigWidget, self).__init__(parent, uifile)

        # define the font widgets
        self._applicationFont = QFontComboBox(self)
        self._applicationFont.setProperty('dataName', wrapVariant('font'))
        self._applicationFont.setSizePolicy(QSizePolicy.Expanding,
                                            QSizePolicy.Preferred)

        self._applicationFontSize = QSpinBox(self)
        self._applicationFontSize.setProperty('dataName',
                                              wrapVariant('fontSize'))

        self._colorButton = XColorButton(self)

        hbox = QHBoxLayout()
        hbox.addWidget(QLabel('Font:', self))
        hbox.addWidget(self._applicationFont)
        hbox.addWidget(QLabel('Size:', self))
        hbox.addWidget(self._applicationFontSize)
        hbox.addWidget(QLabel('Quick Color:', self))
        hbox.addWidget(self._colorButton)

        # define the color tree
        self._colorTree = XColorTreeWidget(self)
        self._colorTree.setProperty('dataName', wrapVariant('colorSet'))

        vbox = QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.addWidget(self._colorTree)

        self.setLayout(vbox)

        # create connections
        self._colorButton.colorChanged.connect(self._colorTree.setQuickColor)
Example #37
0
 def __init__( self, parent, uifile = '' ):
     uifile = ''
     
     super(XSchemeConfigWidget, self).__init__(parent, uifile)
     
     # define the font widgets
     self._applicationFont     = QFontComboBox(self)
     self._applicationFont.setProperty('dataName', wrapVariant('font'))
     self._applicationFont.setSizePolicy( QSizePolicy.Expanding,
                                          QSizePolicy.Preferred )
                                        
     self._applicationFontSize = QSpinBox(self)
     self._applicationFontSize.setProperty('dataName', wrapVariant('fontSize'))
     
     self._colorButton = XColorButton(self)
     
     hbox = QHBoxLayout()
     hbox.addWidget(QLabel('Font:', self))
     hbox.addWidget(self._applicationFont)
     hbox.addWidget(QLabel('Size:', self))
     hbox.addWidget(self._applicationFontSize)
     hbox.addWidget(QLabel('Quick Color:', self))
     hbox.addWidget(self._colorButton)
     
     # define the color tree
     self._colorTree = XColorTreeWidget(self)
     self._colorTree.setProperty('dataName', wrapVariant('colorSet'))
     
     vbox = QVBoxLayout()
     vbox.addLayout(hbox)
     vbox.addWidget(self._colorTree)
     
     self.setLayout(vbox)
     
     # create connections
     self._colorButton.colorChanged.connect( self._colorTree.setQuickColor )
    def startDrag(self, dragData):
        """
        Starts a new drag with the inputed data.
        
        :param      dragData | <dict>
        """
        # create the mime data
        mimeData = QMimeData()
        for key, value in dragData.items():
            mimeData.setData('application/x-%s' % key, wrapVariant(value))

        # create the drag instance
        drag = QDrag(self.scene().chart())
        drag.setMimeData(mimeData)
        drag.exec_()
Example #39
0
    def _addDatasetAction(self, dataset):
        """
        Adds an action for the inputed dataset to the toolbar
        
        :param      dataset | <XChartDataset>
        """
        # create the toolbar action
        action = QAction(dataset.name(), self)
        action.setIcon(XColorIcon(dataset.color()))
        action.setCheckable(True)
        action.setChecked(True)
        action.setData(wrapVariant(dataset))
        action.toggled.connect(self.toggleDataset)

        self.uiDatasetTBAR.addAction(action)
Example #40
0
    def _addDatasetAction(self, dataset):
        """
        Adds an action for the inputed dataset to the toolbar
        
        :param      dataset | <XChartDataset>
        """
        # create the toolbar action
        action = QAction(dataset.name(), self)
        action.setIcon(XColorIcon(dataset.color()))
        action.setCheckable(True)
        action.setChecked(True)
        action.setData(wrapVariant(dataset))
        action.toggled.connect(self.toggleDataset)

        self.uiDatasetTBAR.addAction(action)
Example #41
0
    def createSeparatorItem(self):
        """
        Creates a new separator item.
        
        :return     <QTreeWidgetItem>
        """
        item = QTreeWidgetItem(['                                    '])
        font = item.font(0)
        font.setStrikeOut(True)
        item.setFont(0, font)
        item.setData(0, Qt.UserRole, wrapVariant('separator'))
        flags = item.flags()
        flags ^= Qt.ItemIsDropEnabled
        item.setFlags(flags)

        return item
 def createMenuItem( self, title ):
     """
     Creates a new menu item with the given title.
     
     :param      title | <str>
     
     :return     <QTreeWidgetItem>
     """
     item = QTreeWidgetItem([title])
     ico = projexui.resources.find('img/folder.png')
     
     item.setIcon(0, QIcon(ico))
     item.setSizeHint(0, QSize(120, 20))
     item.setData(0, Qt.UserRole, qt.wrapVariant('menu'))
     
     return item
Example #43
0
    def createMenuItem(self, title):
        """
        Creates a new menu item with the given title.
        
        :param      title | <str>
        
        :return     <QTreeWidgetItem>
        """
        item = QTreeWidgetItem([title])
        ico = projexui.resources.find('img/folder.png')

        item.setIcon(0, QIcon(ico))
        item.setSizeHint(0, QSize(120, 20))
        item.setData(0, Qt.UserRole, wrapVariant('menu'))

        return item
 def createSeparatorItem( self ):
     """
     Creates a new separator item.
     
     :return     <QTreeWidgetItem>
     """
     item = QTreeWidgetItem(['                                    '])
     font = item.font(0)
     font.setStrikeOut(True)
     item.setFont(0, font)
     item.setData(0, Qt.UserRole, qt.wrapVariant('separator'))
     flags = item.flags()
     flags ^= Qt.ItemIsDropEnabled
     item.setFlags(flags)
     
     return item
 def startDrag(self, dragData):
     """
     Starts a new drag with the inputed data.
     
     :param      dragData | <dict>
     """
     # create the mime data
     mimeData = QMimeData()
     for key, value in dragData.items():
         mimeData.setData('application/x-%s' % key, wrapVariant(value))
     
     # create the drag instance
     drag = QDrag(self.scene().chart())
     drag.setMimeData(mimeData)
     drag.exec_()
     
Example #46
0
 def saveSettings( self, settings ):
     """
     Records the current structure of the view widget to the inputed \
     settings instance.
     
     :param      settings | <QSettings>
     """
     # record the profile
     profile = self.saveProfile()
     key     = self.objectName()
     
     settings.setValue('%s/profile' % key, qt.wrapVariant(profile.toString()))
     
     # record the view type settings
     for viewType in self.viewTypes():
         viewType.saveGlobalSettings(settings)
Example #47
0
    def saveSettings(self, settings):
        """
        Records the current structure of the view widget to the inputed \
        settings instance.
        
        :param      settings | <QSettings>
        """
        # record the profile
        profile = self.saveProfile()
        key = self.objectName()

        settings.setValue('%s/profile' % key,
                          qt.wrapVariant(profile.toString()))

        # record the view type settings
        for viewType in self.viewTypes():
            viewType.saveGlobalSettings(settings)
Example #48
0
    def addRecord(self, record):
        """
        Adds the given record to the system.
        
        :param      record | <str>
        """
        label_mapper = self.labelMapper()
        icon_mapper = self.iconMapper()

        self.addItem(label_mapper(record))
        self.setItemData(self.count() - 1, wrapVariant(record), Qt.UserRole)

        # load icon
        if icon_mapper:
            self.setItemIcon(self.count() - 1, icon_mapper(record))

        if self.showTreePopup():
            XOrbRecordItem(self.treePopupWidget(), record)
Example #49
0
    def saveSettings(self, settings):
        """
        Saves the settings for this widget to the application
        
        :param      settings | <QSettings>
        """
        settings.beginGroup(self.objectName())

        curr_prof = self.currentProfile()
        if (curr_prof):
            settings.setValue('current', curr_prof.name())

        for profile in self.profiles():
            settings.beginGroup(profile.name())
            settings.setValue('profile', qt.wrapVariant(profile.toString()))
            settings.endGroup()

        settings.endGroup()
 def saveSettings(self, settings):
     """
     Saves the settings for this widget to the application
     
     :param      settings | <QSettings>
     """
     settings.beginGroup(self.objectName())
     
     curr_prof = self.currentProfile()
     if curr_prof:
         settings.setValue('current', curr_prof.name())
     
     for profile in self.profiles():
         settings.beginGroup(profile.name())
         settings.setValue('profile', wrapVariant(profile.toString()))
         settings.endGroup()
     
     settings.endGroup()
Example #51
0
 def addRecord(self, record):
     """
     Adds the given record to the system.
     
     :param      record | <str>
     """
     label_mapper    = self.labelMapper()
     icon_mapper     = self.iconMapper()
     
     self.addItem(label_mapper(record))
     self.setItemData(self.count() - 1, wrapVariant(record), Qt.UserRole)
     
     # load icon
     if icon_mapper:
         self.setItemIcon(self.count() - 1, icon_mapper(record))
     
     if self.showTreePopup():
         XOrbRecordItem(self.treePopupWidget(), record)
Example #52
0
    def updateItemData(self, item, index):
	"""
	Updates the item information from the tree.
	
	:param      item    | <XGanttWidgetItem>
		    index   | <int>
	"""
	value = qt.unwrapVariant(item.data(index, Qt.EditRole))
	
	if type(value) == QDateTime:
	    value = value.date()
	    item.setData(index, Qt.EditRole, qt.wrapVariant(value))
	
	if type(value) == QDate:
	    value = value.toPython()
	
	columnName = self.treeWidget().columnOf(index)
	item.setProperty(columnName, value)
	item.sync()
Example #53
0
    def updateItemData(self, item, index):
        """
	Updates the item information from the tree.
	
	:param      item    | <XGanttWidgetItem>
		    index   | <int>
	"""
        value = qt.unwrapVariant(item.data(index, Qt.EditRole))

        if type(value) == QDateTime:
            value = value.date()
            item.setData(index, Qt.EditRole, qt.wrapVariant(value))

        if type(value) == QDate:
            value = value.toPython()

        columnName = self.treeWidget().columnOf(index)
        item.setProperty(columnName, value)
        item.sync()
    def setProperty( self, key, value ):
        """
        Sets the custom property for this item's key to the inputed value.  If
        the widget has a column that matches the inputed key, then the value 
        will be added to the tree widget as well.
        
        :param      key     | <str>
                    value   | <variant>
        """
        if key == 'Name':
            if self._dbEntry._type == "project":
		self.setName(value)            
		self._dbEntry.setProperty(propertyname = key, value = value)
            #self.sync()
        elif key == 'Start':
            if self.dateStart() != value:
		self.setDateStart(value)
		self.dataUpdated(self.dateStart(),self.dateEnd())
        elif key == 'End':
            if self.dateEnd() != value:
		self.setDateEnd(value)
		self.dataUpdated(self.dateStart(),self.dateEnd())
        elif key == 'Calendar Days':
            if self.duration() != value:
		self.setDuration(value)
        elif key == 'Time Start':
            self.setTimeStart(value)
        elif key == 'Time End':
            self.setTimeEnd(value)
        elif key == 'All Day':
            self.setAllDay(value)
        elif key == 'Work Days':
            if self.weekdays() != value:
		self.setWorkdayDuration(value)
        else:
            self._properties[str(key)] = value
            
            tree = self.treeWidget()
            if tree:
                col = tree.column(key)
                if col != -1:
                    self.setData(col, Qt.EditRole, qt.wrapVariant(value))
Example #55
0
    def setProperty(self, key, value):
        """
        Sets the custom property for this item's key to the inputed value.  If
        the widget has a column that matches the inputed key, then the value 
        will be added to the tree widget as well.
        
        :param      key     | <str>
                    value   | <variant>
        """
        if key == 'Name':
            if self._dbEntry._type == "project":
                self.setName(value)
                self._dbEntry.setProperty(propertyname=key, value=value)
            #self.sync()
        elif key == 'Start':
            if self.dateStart() != value:
                self.setDateStart(value)
                self.dataUpdated(self.dateStart(), self.dateEnd())
        elif key == 'End':
            if self.dateEnd() != value:
                self.setDateEnd(value)
                self.dataUpdated(self.dateStart(), self.dateEnd())
        elif key == 'Calendar Days':
            if self.duration() != value:
                self.setDuration(value)
        elif key == 'Time Start':
            self.setTimeStart(value)
        elif key == 'Time End':
            self.setTimeEnd(value)
        elif key == 'All Day':
            self.setAllDay(value)
        elif key == 'Work Days':
            if self.weekdays() != value:
                self.setWorkdayDuration(value)
        else:
            self._properties[str(key)] = value

            tree = self.treeWidget()
            if tree:
                col = tree.column(key)
                if col != -1:
                    self.setData(col, Qt.EditRole, qt.wrapVariant(value))
Example #56
0
    def addMenu(self, submenu):
        """
        Adds a new submenu to this menu.  Overloads the base QMenu addMenu \
        method so that it will return an XMenu instance vs. a QMenu when \
        creating a submenu by passing in a string.
        
        :param      submenu | <str> || <QMenu>
        
        :return     <QMenu>
        """
        # create a new submenu based on a string input
        if not isinstance(submenu, QMenu):
            title = nativestring(submenu)
            submenu = XMenu(self)
            submenu.setTitle(title)
            submenu.setShowTitle(self.showTitle())
            super(XMenu, self).addMenu(submenu)
        else:
            super(XMenu, self).addMenu(submenu)

        submenu.menuAction().setData(wrapVariant('menu'))

        return submenu
Example #57
0
 def addMenu(self, submenu):
     """
     Adds a new submenu to this menu.  Overloads the base QMenu addMenu \
     method so that it will return an XMenu instance vs. a QMenu when \
     creating a submenu by passing in a string.
     
     :param      submenu | <str> || <QMenu>
     
     :return     <QMenu>
     """
     # create a new submenu based on a string input
     if not isinstance(submenu, QMenu):
         title = nativestring(submenu)
         submenu = XMenu(self)
         submenu.setTitle(title)
         submenu.setShowTitle(self.showTitle())
         super(XMenu, self).addMenu(submenu)
     else:
         super(XMenu, self).addMenu(submenu)
     
     submenu.menuAction().setData(wrapVariant('menu'))
     
     return submenu
Example #58
0
    def updateItemData(self, item, index):
        """
        Updates the item information from the tree.
        
        :param      item    | <XGanttWidgetItem>
                    index   | <int>
        """
        from projexui.widgets.xganttwidget.xganttwidgetitem import XGanttWidgetItem
        if not isinstance(item, XGanttWidgetItem):
            return

        value = unwrapVariant(item.data(index, Qt.EditRole))

        if type(value) == QDateTime:
            value = value.date()
            item.setData(index, Qt.EditRole, wrapVariant(value))

        if type(value) == QDate:
            value = value.toPython()

        columnName = self.treeWidget().columnOf(index)
        item.setProperty(columnName, value)
        item.sync()
Example #59
0
 def updateItemData(self, item, index):
     """
     Updates the item information from the tree.
     
     :param      item    | <XGanttWidgetItem>
                 index   | <int>
     """
     from projexui.widgets.xganttwidget.xganttwidgetitem import XGanttWidgetItem
     if not isinstance(item, XGanttWidgetItem):
         return
     
     value = unwrapVariant(item.data(index, Qt.EditRole))
     
     if type(value) == QDateTime:
         value = value.date()
         item.setData(index, Qt.EditRole, wrapVariant(value))
     
     if type(value) == QDate:
         value = value.toPython()
     
     columnName = self.treeWidget().columnOf(index)
     item.setProperty(columnName, value)
     item.sync()
Example #60
0
 def adjustLoggerIcons( self ):
     """
     Updates the logger icons for all the loggers in the system.
     """
     default = XLoggerWidget.LoggingMap.get(logging.root.getEffectiveLevel())
     if ( not default ):
         default = XLoggerWidget.LoggingMap[logging.DEBUG]
     
     size = QSize(120, 20)
     for i in range(self.uiLoggerDDL.count()):
         text = str(self.uiLoggerDDL.itemText(i))
         if ( text.startswith('---') ):
             continue
         
         if ( text == ROOT_LOGGER_TEXT ):
             logger = logging.root
         else:
             logger = logging.getLogger(text)
         
         level = logger.getEffectiveLevel()
         icon = XLoggerWidget.LoggingMap.get(level, default)[1]
         
         self.uiLoggerDDL.setItemIcon(i, QIcon(icon))
         self.uiLoggerDDL.setItemData(i, wrapVariant(size), Qt.SizeHintRole)