25 |
25 |
26 @signal openUrl(const QUrl&, const QString&) emitted to open a URL in the current |
26 @signal openUrl(const QUrl&, const QString&) emitted to open a URL in the current |
27 tab |
27 tab |
28 @signal newUrl(const QUrl&, const QString&) emitted to open a URL in a new tab |
28 @signal newUrl(const QUrl&, const QString&) emitted to open a URL in a new tab |
29 """ |
29 """ |
|
30 openUrl = pyqtSignal(QUrl, str) |
|
31 newUrl = pyqtSignal(QUrl, str) |
|
32 |
30 def __init__(self, parent = None, manager = None): |
33 def __init__(self, parent = None, manager = None): |
31 """ |
34 """ |
32 Constructor |
35 Constructor |
33 |
36 |
34 @param parent reference to the parent widget (QWidget |
37 @param parent reference to the parent widget (QWidget |
54 header = fm.width("m") * 40 |
57 header = fm.width("m") * 40 |
55 self.historyTree.header().resizeSection(0, header) |
58 self.historyTree.header().resizeSection(0, header) |
56 self.historyTree.header().setStretchLastSection(True) |
59 self.historyTree.header().setStretchLastSection(True) |
57 self.historyTree.setContextMenuPolicy(Qt.CustomContextMenu) |
60 self.historyTree.setContextMenuPolicy(Qt.CustomContextMenu) |
58 |
61 |
59 self.connect(self.historyTree, SIGNAL("activated(const QModelIndex&)"), |
62 self.historyTree.activated.connect(self.__activated) |
60 self.__activated) |
|
61 self.historyTree.customContextMenuRequested.connect( |
63 self.historyTree.customContextMenuRequested.connect( |
62 self.__customContextMenuRequested) |
64 self.__customContextMenuRequested) |
63 |
65 |
64 self.connect(self.searchEdit, SIGNAL("textChanged(QString)"), |
66 self.searchEdit.textChanged.connect(self.__proxyModel.setFilterFixedString) |
65 self.__proxyModel.setFilterFixedString) |
|
66 self.removeButton.clicked[()].connect(self.historyTree.removeSelected) |
67 self.removeButton.clicked[()].connect(self.historyTree.removeSelected) |
67 self.removeAllButton.clicked[()].connect(self.__historyManager.clear) |
68 self.removeAllButton.clicked[()].connect(self.__historyManager.clear) |
68 |
69 |
69 self.connect(self.__proxyModel, SIGNAL("modelReset()"), self.__modelReset) |
70 self.__proxyModel.modelReset.connect(self.__modelReset) |
70 |
71 |
71 def __modelReset(self): |
72 def __modelReset(self): |
72 """ |
73 """ |
73 Private slot handling a reset of the tree view's model. |
74 Private slot handling a reset of the tree view's model. |
74 """ |
75 """ |
117 |
118 |
118 @param newTab flag indicating to open the history entry in a new tab (boolean) |
119 @param newTab flag indicating to open the history entry in a new tab (boolean) |
119 """ |
120 """ |
120 idx = self.historyTree.currentIndex() |
121 idx = self.historyTree.currentIndex() |
121 if newTab: |
122 if newTab: |
122 self.emit(SIGNAL("newUrl(const QUrl&, const QString&)"), |
123 self.newUrl.emit( |
123 idx.data(HistoryModel.UrlRole), |
124 idx.data(HistoryModel.UrlRole), |
124 idx.data(HistoryModel.TitleRole)) |
125 idx.data(HistoryModel.TitleRole)) |
125 else: |
126 else: |
126 self.emit(SIGNAL("openUrl(const QUrl&, const QString&)"), |
127 self.openUrl.emit( |
127 idx.data(HistoryModel.UrlRole), |
128 idx.data(HistoryModel.UrlRole), |
128 idx.data(HistoryModel.TitleRole)) |
129 idx.data(HistoryModel.TitleRole)) |
129 |
130 |
130 def __copyHistory(self): |
131 def __copyHistory(self): |
131 """ |
132 """ |
132 Private slot to copy a history entry's URL to the clipboard. |
133 Private slot to copy a history entry's URL to the clipboard. |
133 """ |
134 """ |