Helpviewer/Bookmarks/BookmarksMenu.py

changeset 3002
6ffc581f00f1
parent 2403
e3d7a861547c
child 3003
cb43c34239b1
equal deleted inserted replaced
3001:3674ff5fa8f8 3002:6ffc581f00f1
18 18
19 class BookmarksMenu(E5ModelMenu): 19 class BookmarksMenu(E5ModelMenu):
20 """ 20 """
21 Class implementing the bookmarks menu base class. 21 Class implementing the bookmarks menu base class.
22 22
23 @signal openUrl(QUrl, str) emitted to open a URL with the given title in the 23 @signal openUrl(QUrl, str) emitted to open a URL with the given title in
24 current tab 24 the current tab
25 @signal newUrl(QUrl, str) emitted to open a URL with the given title in a 25 @signal newUrl(QUrl, str) emitted to open a URL with the given title in a
26 new tab 26 new tab
27 """ 27 """
28 openUrl = pyqtSignal(QUrl, str) 28 openUrl = pyqtSignal(QUrl, str)
29 newUrl = pyqtSignal(QUrl, str) 29 newUrl = pyqtSignal(QUrl, str)
132 132
133 if act is not None and act.menu() is None and self.index(act).isValid(): 133 if act is not None and act.menu() is None and self.index(act).isValid():
134 menu = QMenu() 134 menu = QMenu()
135 v = act.data() 135 v = act.data()
136 136
137 menuAction = menu.addAction(self.trUtf8("&Open"), self.__openBookmark) 137 menuAction = menu.addAction(
138 self.trUtf8("&Open"), self.__openBookmark)
138 menuAction.setData(v) 139 menuAction.setData(v)
139 menuAction = menu.addAction(self.trUtf8("Open in New &Tab\tCtrl+LMB"), 140 menuAction = menu.addAction(
141 self.trUtf8("Open in New &Tab\tCtrl+LMB"),
140 self.__openBookmarkInNewTab) 142 self.__openBookmarkInNewTab)
141 menuAction.setData(v) 143 menuAction.setData(v)
142 menu.addSeparator() 144 menu.addSeparator()
143 145
144 menuAction = menu.addAction(self.trUtf8("&Remove"), self.__removeBookmark) 146 menuAction = menu.addAction(
147 self.trUtf8("&Remove"), self.__removeBookmark)
145 menuAction.setData(v) 148 menuAction.setData(v)
146 menu.addSeparator() 149 menu.addSeparator()
147 150
148 menuAction = menu.addAction(self.trUtf8("&Properties..."), self.__edit) 151 menuAction = menu.addAction(
152 self.trUtf8("&Properties..."), self.__edit)
149 menuAction.setData(v) 153 menuAction.setData(v)
150 154
151 execAct = menu.exec_(QCursor.pos()) 155 execAct = menu.exec_(QCursor.pos())
152 if execAct is not None: 156 if execAct is not None:
153 self.close() 157 self.close()
192 idx = self.index(self.sender()) 196 idx = self.index(self.sender())
193 node = self.model().node(idx) 197 node = self.model().node(idx)
194 dlg = BookmarkPropertiesDialog(node) 198 dlg = BookmarkPropertiesDialog(node)
195 dlg.exec_() 199 dlg.exec_()
196 200
197 ########################################################################################## 201 ##############################################################################
198 202
199 203
200 class BookmarksMenuBarMenu(BookmarksMenu): 204 class BookmarksMenuBarMenu(BookmarksMenu):
201 """ 205 """
202 Class implementing a dynamically populated menu for bookmarks. 206 Class implementing a dynamically populated menu for bookmarks.
203 207
204 @signal openUrl(QUrl, str) emitted to open a URL with the given title in the 208 @signal openUrl(QUrl, str) emitted to open a URL with the given title in
205 current tab 209 the current tab
206 """ 210 """
207 openUrl = pyqtSignal(QUrl, str) 211 openUrl = pyqtSignal(QUrl, str)
208 212
209 def __init__(self, parent=None): 213 def __init__(self, parent=None):
210 """ 214 """
223 227
224 @return flag indicating if any actions were added (boolean) 228 @return flag indicating if any actions were added (boolean)
225 """ 229 """
226 import Helpviewer.HelpWindow 230 import Helpviewer.HelpWindow
227 231
228 self.__bookmarksManager = Helpviewer.HelpWindow.HelpWindow.bookmarksManager() 232 self.__bookmarksManager = Helpviewer.HelpWindow.HelpWindow\
233 .bookmarksManager()
229 self.setModel(self.__bookmarksManager.bookmarksModel()) 234 self.setModel(self.__bookmarksManager.bookmarksModel())
230 self.setRootIndex(self.__bookmarksManager.bookmarksModel()\ 235 self.setRootIndex(self.__bookmarksManager.bookmarksModel()\
231 .nodeIndex(self.__bookmarksManager.menu())) 236 .nodeIndex(self.__bookmarksManager.menu()))
232 237
233 # initial actions 238 # initial actions
277 act = self.addAction(self.trUtf8("Open all in Tabs")) 282 act = self.addAction(self.trUtf8("Open all in Tabs"))
278 act.triggered[()].connect(self.openAll) 283 act.triggered[()].connect(self.openAll)
279 284
280 def setInitialActions(self, actions): 285 def setInitialActions(self, actions):
281 """ 286 """
282 Public method to set the list of actions that should appear first in the menu. 287 Public method to set the list of actions that should appear first in
288 the menu.
283 289
284 @param actions list of initial actions (list of QAction) 290 @param actions list of initial actions (list of QAction)
285 """ 291 """
286 self.__initialActions = actions[:] 292 self.__initialActions = actions[:]
287 for act in self.__initialActions: 293 for act in self.__initialActions:

eric ide

mercurial