Helpviewer/Bookmarks/BookmarksMenu.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2525
8b507a9a2d40
parent 3003
cb43c34239b1
child 3060
5883ce99ee12
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
20 20
21 class BookmarksMenu(E5ModelMenu): 21 class BookmarksMenu(E5ModelMenu):
22 """ 22 """
23 Class implementing the bookmarks menu base class. 23 Class implementing the bookmarks menu base class.
24 24
25 @signal openUrl(QUrl, str) emitted to open a URL with the given title in the 25 @signal openUrl(QUrl, str) emitted to open a URL with the given title in
26 current tab 26 the current tab
27 @signal newUrl(QUrl, str) emitted to open a URL with the given title in a 27 @signal newUrl(QUrl, str) emitted to open a URL with the given title in a
28 new tab 28 new tab
29 """ 29 """
30 openUrl = pyqtSignal(QUrl, str) 30 openUrl = pyqtSignal(QUrl, str)
31 newUrl = pyqtSignal(QUrl, str) 31 newUrl = pyqtSignal(QUrl, str)
130 130
131 @param pos position the context menu shall be shown (QPoint) 131 @param pos position the context menu shall be shown (QPoint)
132 """ 132 """
133 act = self.actionAt(pos) 133 act = self.actionAt(pos)
134 134
135 if act is not None and act.menu() is None and self.index(act).isValid(): 135 if act is not None and \
136 act.menu() is None and \
137 self.index(act).isValid():
136 menu = QMenu() 138 menu = QMenu()
137 v = act.data() 139 v = act.data()
138 140
139 menuAction = menu.addAction(self.trUtf8("&Open"), self.__openBookmark) 141 menuAction = menu.addAction(
142 self.trUtf8("&Open"), self.__openBookmark)
140 menuAction.setData(v) 143 menuAction.setData(v)
141 menuAction = menu.addAction(self.trUtf8("Open in New &Tab\tCtrl+LMB"), 144 menuAction = menu.addAction(
145 self.trUtf8("Open in New &Tab\tCtrl+LMB"),
142 self.__openBookmarkInNewTab) 146 self.__openBookmarkInNewTab)
143 menuAction.setData(v) 147 menuAction.setData(v)
144 menu.addSeparator() 148 menu.addSeparator()
145 149
146 menuAction = menu.addAction(self.trUtf8("&Remove"), self.__removeBookmark) 150 menuAction = menu.addAction(
151 self.trUtf8("&Remove"), self.__removeBookmark)
147 menuAction.setData(v) 152 menuAction.setData(v)
148 menu.addSeparator() 153 menu.addSeparator()
149 154
150 menuAction = menu.addAction(self.trUtf8("&Properties..."), self.__edit) 155 menuAction = menu.addAction(
156 self.trUtf8("&Properties..."), self.__edit)
151 menuAction.setData(v) 157 menuAction.setData(v)
152 158
153 execAct = menu.exec_(QCursor.pos()) 159 execAct = menu.exec_(QCursor.pos())
154 if execAct is not None: 160 if execAct is not None:
155 self.close() 161 self.close()
194 idx = self.index(self.sender()) 200 idx = self.index(self.sender())
195 node = self.model().node(idx) 201 node = self.model().node(idx)
196 dlg = BookmarkPropertiesDialog(node) 202 dlg = BookmarkPropertiesDialog(node)
197 dlg.exec_() 203 dlg.exec_()
198 204
199 ########################################################################################## 205 ##############################################################################
200 206
201 207
202 class BookmarksMenuBarMenu(BookmarksMenu): 208 class BookmarksMenuBarMenu(BookmarksMenu):
203 """ 209 """
204 Class implementing a dynamically populated menu for bookmarks. 210 Class implementing a dynamically populated menu for bookmarks.
205 211
206 @signal openUrl(QUrl, str) emitted to open a URL with the given title in the 212 @signal openUrl(QUrl, str) emitted to open a URL with the given title in
207 current tab 213 the current tab
208 """ 214 """
209 openUrl = pyqtSignal(QUrl, str) 215 openUrl = pyqtSignal(QUrl, str)
210 216
211 def __init__(self, parent=None): 217 def __init__(self, parent=None):
212 """ 218 """
225 231
226 @return flag indicating if any actions were added (boolean) 232 @return flag indicating if any actions were added (boolean)
227 """ 233 """
228 import Helpviewer.HelpWindow 234 import Helpviewer.HelpWindow
229 235
230 self.__bookmarksManager = Helpviewer.HelpWindow.HelpWindow.bookmarksManager() 236 self.__bookmarksManager = Helpviewer.HelpWindow.HelpWindow\
237 .bookmarksManager()
231 self.setModel(self.__bookmarksManager.bookmarksModel()) 238 self.setModel(self.__bookmarksManager.bookmarksModel())
232 self.setRootIndex(self.__bookmarksManager.bookmarksModel()\ 239 self.setRootIndex(self.__bookmarksManager.bookmarksModel()\
233 .nodeIndex(self.__bookmarksManager.menu())) 240 .nodeIndex(self.__bookmarksManager.menu()))
234 241
235 # initial actions 242 # initial actions
279 act = self.addAction(self.trUtf8("Open all in Tabs")) 286 act = self.addAction(self.trUtf8("Open all in Tabs"))
280 act.triggered[()].connect(self.openAll) 287 act.triggered[()].connect(self.openAll)
281 288
282 def setInitialActions(self, actions): 289 def setInitialActions(self, actions):
283 """ 290 """
284 Public method to set the list of actions that should appear first in the menu. 291 Public method to set the list of actions that should appear first in
292 the menu.
285 293
286 @param actions list of initial actions (list of QAction) 294 @param actions list of initial actions (list of QAction)
287 """ 295 """
288 self.__initialActions = actions[:] 296 self.__initialActions = actions[:]
289 for act in self.__initialActions: 297 for act in self.__initialActions:

eric ide

mercurial