Пример #1
0
    def rebuild(self):
        """
        Rebuilds the parts widget with the latest text.
        """
        navitem = self.currentItem()
        if (navitem):
            navitem.initialize()

        self.setUpdatesEnabled(False)
        self.scrollWidget().show()
        self._originalText = ''

        partsw = self.partsWidget()
        for button in self._buttonGroup.buttons():
            self._buttonGroup.removeButton(button)
            button.close()
            button.setParent(None)
            button.deleteLater()

        # create the root button
        layout = partsw.layout()
        parts = self.parts()

        button = QToolButton(partsw)
        button.setAutoRaise(True)
        button.setMaximumWidth(12)
        button.setArrowType(Qt.RightArrow)

        button.setProperty('path', wrapVariant(''))
        button.setProperty('is_completer', wrapVariant(True))
        last_button = button

        self._buttonGroup.addButton(button)
        layout.insertWidget(0, button)

        # check to see if we have a navigation model setup
        if (self._navigationModel):
            last_item = self._navigationModel.itemByPath(self.text())
            show_last = last_item and last_item.rowCount() > 0
        else:
            show_last = False

        # load the navigation system
        count = len(parts)
        for i, part in enumerate(parts):
            path = self.separator().join(parts[:i + 1])

            button = QToolButton(partsw)
            button.setAutoRaise(True)
            button.setText(part)

            if (self._navigationModel):
                item = self._navigationModel.itemByPath(path)
                if (item):
                    button.setIcon(item.icon())
                    button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)

            button.setProperty('path', wrapVariant(path))
            button.setProperty('is_completer', wrapVariant(False))

            self._buttonGroup.addButton(button)
            layout.insertWidget((i * 2) + 1, button)

            # determine if we should show the final button
            if (show_last or i < (count - 1)):
                button = QToolButton(partsw)
                button.setAutoRaise(True)
                button.setMaximumWidth(12)
                button.setArrowType(Qt.RightArrow)

                button.setProperty('path', wrapVariant(path))
                button.setProperty('is_completer', wrapVariant(True))

                self._buttonGroup.addButton(button)
                layout.insertWidget((i * 2) + 2, button)

                last_button = button

        if (self.scrollWidget().width() < partsw.width()):
            self.scrollParts(partsw.width() - self.scrollWidget().width())

        self.setUpdatesEnabled(True)
        self.navigationChanged.emit()
Пример #2
0
 def rebuild( self ):
     """
     Rebuilds the parts widget with the latest text.
     """
     navitem = self.currentItem()
     if ( navitem ):
         navitem.initialize()
         
     self.setUpdatesEnabled(False)
     self.scrollWidget().show()
     self._originalText = ''
     
     partsw = self.partsWidget()
     for button in self._buttonGroup.buttons():
         self._buttonGroup.removeButton(button)
         button.close()
         button.setParent(None)
         button.deleteLater()
     
     # create the root button
     layout = partsw.layout()
     parts  = self.parts()
     
     button = QToolButton(partsw)
     button.setAutoRaise(True)
     button.setMaximumWidth(12)
     button.setArrowType(Qt.RightArrow)
     
     button.setProperty('path',          wrapVariant(''))
     button.setProperty('is_completer',  wrapVariant(True))
     last_button = button
         
     self._buttonGroup.addButton(button)
     layout.insertWidget(0, button)
     
     # check to see if we have a navigation model setup
     if ( self._navigationModel ):
         last_item = self._navigationModel.itemByPath(self.text())
         show_last =  last_item and last_item.rowCount() > 0
     else:
         show_last = False
     
     # load the navigation system
     count = len(parts)
     for i, part in enumerate(parts):
         path = self.separator().join(parts[:i+1])
         
         button = QToolButton(partsw)
         button.setAutoRaise(True)
         button.setText(part)
         
         if ( self._navigationModel ):
             item = self._navigationModel.itemByPath(path)
             if ( item ):
                 button.setIcon(item.icon())
                 button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
         
         button.setProperty('path',         wrapVariant(path))
         button.setProperty('is_completer', wrapVariant(False))
         
         self._buttonGroup.addButton(button)
         layout.insertWidget((i * 2) + 1, button)
         
         # determine if we should show the final button
         if ( show_last or i < (count - 1) ):
             button = QToolButton(partsw)
             button.setAutoRaise(True)
             button.setMaximumWidth(12)
             button.setArrowType(Qt.RightArrow)
             
             button.setProperty('path',          wrapVariant(path))
             button.setProperty('is_completer',  wrapVariant(True))
         
             self._buttonGroup.addButton(button)
             layout.insertWidget((i * 2) + 2, button)
             
             last_button = button
     
     if ( self.scrollWidget().width() < partsw.width() ):
         self.scrollParts(partsw.width() - self.scrollWidget().width())
         
     self.setUpdatesEnabled(True)
     self.navigationChanged.emit()