src/eric7/WebBrowser/Bookmarks/BookmarksMenu.py

branch
eric7
changeset 10436
f6881d10e995
parent 9653
e67609152c5e
child 10439
21c28b0f9e41
equal deleted inserted replaced
10435:c712d09cc839 10436:f6881d10e995
36 36
37 def __init__(self, parent=None): 37 def __init__(self, parent=None):
38 """ 38 """
39 Constructor 39 Constructor
40 40
41 @param parent reference to the parent widget (QWidget) 41 @param parent reference to the parent widget
42 @type QWidget
42 """ 43 """
43 EricModelMenu.__init__(self, parent) 44 EricModelMenu.__init__(self, parent)
44 45
45 self.activated.connect(self.__activated) 46 self.activated.connect(self.__activated)
46 self.setStatusBarTextRole(BookmarksModel.UrlStringRole) 47 self.setStatusBarTextRole(BookmarksModel.UrlStringRole)
51 52
52 def createBaseMenu(self): 53 def createBaseMenu(self):
53 """ 54 """
54 Public method to get the menu that is used to populate sub menu's. 55 Public method to get the menu that is used to populate sub menu's.
55 56
56 @return reference to the menu (BookmarksMenu) 57 @return reference to the menu
58 @rtype BookmarksMenu
57 """ 59 """
58 menu = BookmarksMenu(self) 60 menu = BookmarksMenu(self)
59 menu.openUrl.connect(self.openUrl) 61 menu.openUrl.connect(self.openUrl)
60 menu.newTab.connect(self.newTab) 62 menu.newTab.connect(self.newTab)
61 menu.newWindow.connect(self.newWindow) 63 menu.newWindow.connect(self.newWindow)
63 65
64 def __updateVisitCount(self, idx): 66 def __updateVisitCount(self, idx):
65 """ 67 """
66 Private method to update the visit count of a bookmark. 68 Private method to update the visit count of a bookmark.
67 69
68 @param idx index of the bookmark item (QModelIndex) 70 @param idx index of the bookmark item
71 @type QModelIndex
69 """ 72 """
70 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow 73 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow
71 74
72 bookmarkNode = self.model().node(idx) 75 bookmarkNode = self.model().node(idx)
73 manager = WebBrowserWindow.bookmarksManager() 76 manager = WebBrowserWindow.bookmarksManager()
75 78
76 def __activated(self, idx): 79 def __activated(self, idx):
77 """ 80 """
78 Private slot handling the activated signal. 81 Private slot handling the activated signal.
79 82
80 @param idx index of the activated item (QModelIndex) 83 @param idx index of the activated item
84 @type QModelIndex
81 """ 85 """
82 if self._keyboardModifiers & Qt.KeyboardModifier.ControlModifier: 86 if self._keyboardModifiers & Qt.KeyboardModifier.ControlModifier:
83 self.newTab.emit( 87 self.newTab.emit(
84 idx.data(BookmarksModel.UrlRole), idx.data(Qt.ItemDataRole.DisplayRole) 88 idx.data(BookmarksModel.UrlRole), idx.data(Qt.ItemDataRole.DisplayRole)
85 ) 89 )
153 157
154 def __contextMenuRequested(self, pos): 158 def __contextMenuRequested(self, pos):
155 """ 159 """
156 Private slot to handle the context menu request. 160 Private slot to handle the context menu request.
157 161
158 @param pos position the context menu shall be shown (QPoint) 162 @param pos position the context menu shall be shown
163 @type QPoint
159 """ 164 """
160 act = self.actionAt(pos) 165 act = self.actionAt(pos)
161 166
162 if ( 167 if (
163 act is not None 168 act is not None
292 297
293 def __init__(self, parent=None): 298 def __init__(self, parent=None):
294 """ 299 """
295 Constructor 300 Constructor
296 301
297 @param parent reference to the parent widget (QWidget) 302 @param parent reference to the parent widget
303 @type QWidget
298 """ 304 """
299 BookmarksMenu.__init__(self, parent) 305 BookmarksMenu.__init__(self, parent)
300 306
301 self.__initialActions = [] 307 self.__initialActions = []
302 308
303 def prePopulated(self): 309 def prePopulated(self):
304 """ 310 """
305 Public method to add any actions before the tree. 311 Public method to add any actions before the tree.
306 312
307 @return flag indicating if any actions were added (boolean) 313 @return flag indicating if any actions were added
314 @rtype bool
308 """ 315 """
309 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow 316 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow
310 317
311 manager = WebBrowserWindow.bookmarksManager() 318 manager = WebBrowserWindow.bookmarksManager()
312 self.setModel(manager.bookmarksModel()) 319 self.setModel(manager.bookmarksModel())
359 def setInitialActions(self, actions): 366 def setInitialActions(self, actions):
360 """ 367 """
361 Public method to set the list of actions that should appear first in 368 Public method to set the list of actions that should appear first in
362 the menu. 369 the menu.
363 370
364 @param actions list of initial actions (list of QAction) 371 @param actions list of initial actions
372 @type list of QAction
365 """ 373 """
366 self.__initialActions = actions[:] 374 self.__initialActions = actions[:]
367 for act in self.__initialActions: 375 for act in self.__initialActions:
368 self.addAction(act) 376 self.addAction(act)
369 377

eric ide

mercurial