24 |
24 |
25 @signal openUrl(const QUrl&, const QString&) emitted to open a URL in the current |
25 @signal openUrl(const QUrl&, const QString&) emitted to open a URL in the current |
26 tab |
26 tab |
27 @signal newUrl(const QUrl&, const QString&) emitted to open a URL in a new tab |
27 @signal newUrl(const QUrl&, const QString&) emitted to open a URL in a new tab |
28 """ |
28 """ |
|
29 openUrl = pyqtSignal(QUrl, str) |
|
30 newUrl = pyqtSignal(QUrl, str) |
|
31 |
29 def __init__(self, model, parent = None): |
32 def __init__(self, model, parent = None): |
30 """ |
33 """ |
31 Constructor |
34 Constructor |
32 |
35 |
33 @param model reference to the bookmarks model (BookmarksModel) |
36 @param model reference to the bookmarks model (BookmarksModel) |
42 self.setRootIndex(model.nodeIndex( |
45 self.setRootIndex(model.nodeIndex( |
43 Helpviewer.HelpWindow.HelpWindow.bookmarksManager().toolbar())) |
46 Helpviewer.HelpWindow.HelpWindow.bookmarksManager().toolbar())) |
44 |
47 |
45 self.setContextMenuPolicy(Qt.CustomContextMenu) |
48 self.setContextMenuPolicy(Qt.CustomContextMenu) |
46 self.customContextMenuRequested.connect(self.__contextMenuRequested) |
49 self.customContextMenuRequested.connect(self.__contextMenuRequested) |
47 self.connect(self, SIGNAL("activated(const QModelIndex &)"), |
50 self.activated.connect(self.__bookmarkActivated) |
48 self.__bookmarkActivated) |
|
49 |
51 |
50 self.setHidden(True) |
52 self.setHidden(True) |
51 self.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) |
53 self.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) |
52 |
54 |
53 self._build() |
55 self._build() |
91 @param idx index of the activated bookmark (QModelIndex) |
93 @param idx index of the activated bookmark (QModelIndex) |
92 """ |
94 """ |
93 assert idx.isValid() |
95 assert idx.isValid() |
94 |
96 |
95 if self._keyboardModifiers & Qt.ControlModifier: |
97 if self._keyboardModifiers & Qt.ControlModifier: |
96 self.emit(SIGNAL("newUrl(const QUrl&, const QString&)"), |
98 self.newUrl.emit( |
97 idx.data(BookmarksModel.UrlRole), |
99 idx.data(BookmarksModel.UrlRole), |
98 idx.data(Qt.DisplayRole)) |
100 idx.data(Qt.DisplayRole)) |
99 else: |
101 else: |
100 self.emit(SIGNAL("openUrl(const QUrl&, const QString&)"), |
102 self.openUrl.emit( |
101 idx.data(BookmarksModel.UrlRole), |
103 idx.data(BookmarksModel.UrlRole), |
102 idx.data(Qt.DisplayRole)) |
104 idx.data(Qt.DisplayRole)) |
103 |
105 |
104 def __openToolBarBookmark(self): |
106 def __openToolBarBookmark(self): |
105 """ |
107 """ |
106 Private slot to open a bookmark in the current browser tab. |
108 Private slot to open a bookmark in the current browser tab. |
107 """ |
109 """ |
108 idx = self.index(self.sender()) |
110 idx = self.index(self.sender()) |
109 |
111 |
110 if self._keyboardModifiers & Qt.ControlModifier: |
112 if self._keyboardModifiers & Qt.ControlModifier: |
111 self.emit(SIGNAL("newUrl(const QUrl&, const QString&)"), |
113 self.newUrl.emit( |
112 idx.data(BookmarksModel.UrlRole), |
114 idx.data(BookmarksModel.UrlRole), |
113 idx.data(Qt.DisplayRole)) |
115 idx.data(Qt.DisplayRole)) |
114 else: |
116 else: |
115 self.emit(SIGNAL("openUrl(const QUrl&, const QString&)"), |
117 self.openUrl.emit( |
116 idx.data(BookmarksModel.UrlRole), |
118 idx.data(BookmarksModel.UrlRole), |
117 idx.data(Qt.DisplayRole)) |
119 idx.data(Qt.DisplayRole)) |
118 self.resetFlags() |
120 self.resetFlags() |
119 |
121 |
120 def __openBookmark(self): |
122 def __openBookmark(self): |
121 """ |
123 """ |
122 Private slot to open a bookmark in the current browser tab. |
124 Private slot to open a bookmark in the current browser tab. |
123 """ |
125 """ |
124 idx = self.index(self.sender()) |
126 idx = self.index(self.sender()) |
125 |
127 |
126 self.emit(SIGNAL("openUrl(const QUrl&, const QString&)"), |
128 self.openUrl.emit( |
127 idx.data(BookmarksModel.UrlRole), |
129 idx.data(BookmarksModel.UrlRole), |
128 idx.data(Qt.DisplayRole)) |
130 idx.data(Qt.DisplayRole)) |
129 |
131 |
130 def __openBookmarkInNewTab(self): |
132 def __openBookmarkInNewTab(self): |
131 """ |
133 """ |
132 Private slot to open a bookmark in a new browser tab. |
134 Private slot to open a bookmark in a new browser tab. |
133 """ |
135 """ |
134 idx = self.index(self.sender()) |
136 idx = self.index(self.sender()) |
135 |
137 |
136 self.emit(SIGNAL("newUrl(const QUrl&, const QString&)"), |
138 self.newUrl.emit( |
137 idx.data(BookmarksModel.UrlRole), |
139 idx.data(BookmarksModel.UrlRole), |
138 idx.data(Qt.DisplayRole)) |
140 idx.data(Qt.DisplayRole)) |
139 |
141 |
140 def __removeBookmark(self): |
142 def __removeBookmark(self): |
141 """ |
143 """ |
142 Private slot to remove a bookmark. |
144 Private slot to remove a bookmark. |
143 """ |
145 """ |
167 Protected method to create the menu for a tool bar action. |
169 Protected method to create the menu for a tool bar action. |
168 |
170 |
169 @return menu for a tool bar action (E5ModelMenu) |
171 @return menu for a tool bar action (E5ModelMenu) |
170 """ |
172 """ |
171 menu = BookmarksMenu(self) |
173 menu = BookmarksMenu(self) |
172 self.connect(menu, SIGNAL("openUrl(const QUrl&, const QString&)"), |
174 menu.openUrl.connect(self.openUrl) |
173 self, SIGNAL("openUrl(const QUrl&, const QString&)")) |
175 menu.newUrl.connect(self.newUrl) |
174 self.connect(menu, SIGNAL("newUrl(const QUrl&, const QString&)"), |
|
175 self, SIGNAL("newUrl(const QUrl&, const QString&)")) |
|
176 return menu |
176 return menu |