Exemplo n.º 1
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
Exemplo n.º 2
0
    def __init__(self, parent=None):
        super(XFontPickerWidget, self).__init__(parent)

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

        # define custom properties
        database = QFontDatabase()
        for family in sorted(database.families()):
            item = QTreeWidgetItem(self.uiFontTREE, [family])
            item.setFont(0, QFont(family))

        # set default properties

        # create connections
        self.uiSizeSPN.valueChanged.connect(self.setPointSize)
        self.uiFontTREE.itemDoubleClicked.connect(self.accepted)
Exemplo n.º 3
0
 def __init__( self, parent = None ):
     super(XFontPickerWidget, self).__init__( parent )
     
     # load the user interface
     projexui.loadUi(__file__, self)
     
     # define custom properties
     database = QFontDatabase()
     for family in sorted(database.families()):
         item = QTreeWidgetItem(self.uiFontTREE, [family])
         item.setFont(0, QFont(family))
     
     # set default properties
     
     # create connections
     self.uiSizeSPN.valueChanged.connect(self.setPointSize)
     self.uiFontTREE.itemDoubleClicked.connect(self.accepted)
Exemplo n.º 4
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
Exemplo n.º 5
0
 def refreshCards( self ):
     """
     Refreshes the results for the cards view of the browser.
     """
     cards = self.cardWidget()
     factory = self.factory()
     
     self.setUpdatesEnabled(False)
     self.blockSignals(True)
     
     cards.setUpdatesEnabled(False)
     cards.blockSignals(True)
     
     cards.clear()
     QApplication.instance().processEvents()
     
     if ( self.isGroupingActive() ):
         grouping = self.records().grouped()
         for groupName, records in sorted(grouping.items()):
             self._loadCardGroup(groupName, records, cards)
         
     else:
         for record in self.records():
             widget = factory.createCard(cards, record)
             if ( not widget ):
                 continue
             
             widget.adjustSize()
             
             # create the card item
             item = QTreeWidgetItem(cards)
             item.setSizeHint(0, QSize(0, widget.height()))
             cards.setItemWidget(item, 0, widget)
     
     cards.setUpdatesEnabled(True)
     cards.blockSignals(False)
     
     self.setUpdatesEnabled(True)
     self.blockSignals(False)
Exemplo n.º 6
0
    def refreshCards(self):
        """
        Refreshes the results for the cards view of the browser.
        """
        cards = self.cardWidget()
        factory = self.factory()

        self.setUpdatesEnabled(False)
        self.blockSignals(True)

        cards.setUpdatesEnabled(False)
        cards.blockSignals(True)

        cards.clear()
        QApplication.instance().processEvents()

        if self.isGroupingActive():
            grouping = self.records().grouped()
            for groupName, records in sorted(grouping.items()):
                self._loadCardGroup(groupName, records, cards)

        else:
            for record in self.records():
                widget = factory.createCard(cards, record)
                if not widget:
                    continue

                widget.adjustSize()

                # create the card item
                item = QTreeWidgetItem(cards)
                item.setSizeHint(0, QSize(0, widget.height()))
                cards.setItemWidget(item, 0, widget)

        cards.setUpdatesEnabled(True)
        cards.blockSignals(False)

        self.setUpdatesEnabled(True)
        self.blockSignals(False)
Exemplo n.º 7
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
Exemplo n.º 8
0
    def startCompletion(self, force=False):
        """
        Starts a new completion popup for the current object.
        
        :return     <bool> success
        """
        # add the top level items
        tree = self.completerTree()
        if not force and tree.isVisible():
            return

        tree.clear()

        # make sure we have a valid object
        obj, remain = self.objectAtCursor()

        if obj is None:
            tree.hide()
            return

        # determine the cursor position
        rect = self.cursorRect()
        cursor = self.textCursor()
        point = QPoint(rect.left(), rect.top() + 18)

        # compare the ids since some things might overload the __eq__
        # comparator
        if id(obj) == id(self._scope):
            o_keys = obj.keys()
        elif obj is not None:
            o_keys = dir(obj)

        keys = [key for key in sorted(o_keys) if not key.startswith('_')]
        if id(obj) == id(self._scope):
            if not remain:
                return False
            else:
                keys = filter(lambda x: x.startswith(remain[0]), keys)

        if not keys:
            return False

        for key in keys:
            tree.addTopLevelItem(QTreeWidgetItem([key]))

        tree.move(self.mapToGlobal(point))
        tree.show()
        return True
Exemplo n.º 9
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
Exemplo n.º 10
0
 def _loadCardGroup( self, groupName, records, parent = None ):
     if ( not groupName ):
         groupName = 'None'
     
     cards  = self.cardWidget()
     factory = self.factory()
     
     # create the group item
     group_item = QTreeWidgetItem(parent, [groupName])
     font = group_item.font(0)
     font.setBold(True)
     font.setPointSize(font.pointSize() + 2)
     group_item.setFont(0, font)
     group_item.setFlags(Qt.ItemIsEnabled)
     
     # load sub-groups
     if ( type(records) == dict ):
         for subgroup, records in sorted(records.items()):
             self._loadCardGroup(subgroup, records, group_item)
     else:
         for record in records:
             widget = factory.createCard(cards, record)
             if ( not widget ):
                 continue
             
             widget.adjustSize()
             
             # create the card item
             item = QTreeWidgetItem(group_item)
             item.setSizeHint(0, QSize(0, widget.height()))
             cards.setItemWidget(item, 0, widget)
     
     group_item.setExpanded(True)
Exemplo n.º 11
0
    def _loadCardGroup(self, groupName, records, parent=None):
        if not groupName:
            groupName = "None"

        cards = self.cardWidget()
        factory = self.factory()

        # create the group item
        group_item = QTreeWidgetItem(parent, [groupName])
        font = group_item.font(0)
        font.setBold(True)
        font.setPointSize(font.pointSize() + 2)
        group_item.setFont(0, font)
        group_item.setFlags(Qt.ItemIsEnabled)

        # load sub-groups
        if type(records) == dict:
            for subgroup, records in sorted(records.items()):
                self._loadCardGroup(subgroup, records, group_item)
        else:
            for record in records:
                widget = factory.createCard(cards, record)
                if not widget:
                    continue

                widget.adjustSize()

                # create the card item
                item = QTreeWidgetItem(group_item)
                item.setSizeHint(0, QSize(0, widget.height()))
                cards.setItemWidget(item, 0, widget)

        group_item.setExpanded(True)
Exemplo n.º 12
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
Exemplo n.º 13
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