コード例 #1
0
    def __showForwardMenu(self):
        """
        Private slot showing the forwards navigation menu.
        """
        self.__forwardMenu.clear()
        history = self.__mw.currentBrowser().history()
        historyCount = history.count()
        forwardItems = history.forwardItems(historyCount)

        count = 0
        for index in range(len(forwardItems)):
            item = forwardItems[index]
            act = QAction(self)
            act.setData(index + 1)
            icon = WebBrowserWindow.icon(item.url())
            act.setIcon(icon)
            act.setText(item.title())
            self.__forwardMenu.addAction(act)

            count += 1
            if count == 20:
                break

        self.__forwardMenu.addSeparator()
        self.__forwardMenu.addAction(self.tr("Clear History"),
                                     self.__clearHistory)
コード例 #2
0
    def data(self, index, role):
        """
        Public method to get data from the model.
        
        @param index index to get data for (QModelIndex)
        @param role role of the data to retrieve (integer)
        @return requested data
        """
        if index.row() >= self.__manager.enginesCount() or index.row() < 0:
            return None

        engine = self.__manager.engine(
            self.__manager.allEnginesNames()[index.row()])

        if engine is None:
            return None

        if index.column() == 0:
            if role == Qt.DisplayRole:
                return engine.name()

            elif role == Qt.DecorationRole:
                image = engine.image()
                if image.isNull():
                    from WebBrowser.WebBrowserWindow import WebBrowserWindow
                    icon = WebBrowserWindow.icon(QUrl(engine.imageUrl()))
                else:
                    icon = QIcon(QPixmap.fromImage(image))
                return icon

            elif role == Qt.ToolTipRole:
                description = self.tr(
                    "<strong>Description:</strong> {0}").format(
                        engine.description())
                if engine.providesSuggestions():
                    description += "<br/>"
                    description += self.tr(
                        "<strong>Provides contextual suggestions</strong>")

                return description
        elif index.column() == 1:
            if role in [Qt.EditRole, Qt.DisplayRole]:
                return ",".join(self.__manager.keywordsForEngine(engine))
            elif role == Qt.ToolTipRole:
                return self.tr(
                    "Comma-separated list of keywords that may"
                    " be entered in the location bar followed by search terms"
                    " to search with this engine")

        return None