src/eric7/WebBrowser/Bookmarks/BookmarksDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
7 Module implementing a dialog to manage bookmarks. 7 Module implementing a dialog to manage bookmarks.
8 """ 8 """
9 9
10 from PyQt6.QtCore import pyqtSignal, Qt, QUrl, QModelIndex 10 from PyQt6.QtCore import pyqtSignal, Qt, QUrl, QModelIndex
11 from PyQt6.QtGui import QFontMetrics, QCursor 11 from PyQt6.QtGui import QFontMetrics, QCursor
12 from PyQt6.QtWidgets import ( 12 from PyQt6.QtWidgets import QDialog, QMenu, QApplication, QInputDialog, QLineEdit
13 QDialog, QMenu, QApplication, QInputDialog, QLineEdit
14 )
15 13
16 from EricCore.EricTreeSortFilterProxyModel import EricTreeSortFilterProxyModel 14 from EricCore.EricTreeSortFilterProxyModel import EricTreeSortFilterProxyModel
17 15
18 from .Ui_BookmarksDialog import Ui_BookmarksDialog 16 from .Ui_BookmarksDialog import Ui_BookmarksDialog
19 17
20 18
21 class BookmarksDialog(QDialog, Ui_BookmarksDialog): 19 class BookmarksDialog(QDialog, Ui_BookmarksDialog):
22 """ 20 """
23 Class implementing a dialog to manage bookmarks. 21 Class implementing a dialog to manage bookmarks.
24 22
25 @signal openUrl(QUrl, str) emitted to open a URL in the current tab 23 @signal openUrl(QUrl, str) emitted to open a URL in the current tab
26 @signal newTab(QUrl, str) emitted to open a URL in a new tab 24 @signal newTab(QUrl, str) emitted to open a URL in a new tab
27 @signal newBackgroundTab(QUrl, str) emitted to open a URL in a new 25 @signal newBackgroundTab(QUrl, str) emitted to open a URL in a new
28 background tab 26 background tab
29 @signal newWindow(QUrl, str) emitted to open a URL in a new window 27 @signal newWindow(QUrl, str) emitted to open a URL in a new window
30 """ 28 """
29
31 openUrl = pyqtSignal(QUrl, str) 30 openUrl = pyqtSignal(QUrl, str)
32 newTab = pyqtSignal(QUrl, str) 31 newTab = pyqtSignal(QUrl, str)
33 newBackgroundTab = pyqtSignal(QUrl, str) 32 newBackgroundTab = pyqtSignal(QUrl, str)
34 newWindow = pyqtSignal(QUrl, str) 33 newWindow = pyqtSignal(QUrl, str)
35 34
36 def __init__(self, parent=None, manager=None): 35 def __init__(self, parent=None, manager=None):
37 """ 36 """
38 Constructor 37 Constructor
39 38
40 @param parent reference to the parent widget (QWidget 39 @param parent reference to the parent widget (QWidget
41 @param manager reference to the bookmarks manager object 40 @param manager reference to the bookmarks manager object
42 (BookmarksManager) 41 (BookmarksManager)
43 """ 42 """
44 super().__init__(parent) 43 super().__init__(parent)
45 self.setupUi(self) 44 self.setupUi(self)
46 self.setWindowFlags(Qt.WindowType.Window) 45 self.setWindowFlags(Qt.WindowType.Window)
47 46
48 self.__bookmarksManager = manager 47 self.__bookmarksManager = manager
49 if self.__bookmarksManager is None: 48 if self.__bookmarksManager is None:
50 import WebBrowser.WebBrowserWindow 49 import WebBrowser.WebBrowserWindow
50
51 self.__bookmarksManager = ( 51 self.__bookmarksManager = (
52 WebBrowser.WebBrowserWindow.WebBrowserWindow.bookmarksManager() 52 WebBrowser.WebBrowserWindow.WebBrowserWindow.bookmarksManager()
53 ) 53 )
54 54
55 self.__bookmarksModel = self.__bookmarksManager.bookmarksModel() 55 self.__bookmarksModel = self.__bookmarksManager.bookmarksModel()
56 self.__proxyModel = EricTreeSortFilterProxyModel(self) 56 self.__proxyModel = EricTreeSortFilterProxyModel(self)
57 self.__proxyModel.setFilterKeyColumn(-1) 57 self.__proxyModel.setFilterKeyColumn(-1)
58 self.__proxyModel.setSourceModel(self.__bookmarksModel) 58 self.__proxyModel.setSourceModel(self.__bookmarksModel)
59 59
60 self.searchEdit.textChanged.connect( 60 self.searchEdit.textChanged.connect(self.__proxyModel.setFilterFixedString)
61 self.__proxyModel.setFilterFixedString) 61
62
63 self.bookmarksTree.setModel(self.__proxyModel) 62 self.bookmarksTree.setModel(self.__proxyModel)
64 self.bookmarksTree.setExpanded(self.__proxyModel.index(0, 0), True) 63 self.bookmarksTree.setExpanded(self.__proxyModel.index(0, 0), True)
65 fm = QFontMetrics(self.font()) 64 fm = QFontMetrics(self.font())
66 try: 65 try:
67 header = fm.horizontalAdvance("m") * 40 66 header = fm.horizontalAdvance("m") * 40
68 except AttributeError: 67 except AttributeError:
69 header = fm.width("m") * 40 68 header = fm.width("m") * 40
70 self.bookmarksTree.header().resizeSection(0, header) 69 self.bookmarksTree.header().resizeSection(0, header)
71 self.bookmarksTree.header().setStretchLastSection(True) 70 self.bookmarksTree.header().setStretchLastSection(True)
72 self.bookmarksTree.setContextMenuPolicy( 71 self.bookmarksTree.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
73 Qt.ContextMenuPolicy.CustomContextMenu) 72
74
75 self.bookmarksTree.activated.connect(self.__activated) 73 self.bookmarksTree.activated.connect(self.__activated)
76 self.bookmarksTree.customContextMenuRequested.connect( 74 self.bookmarksTree.customContextMenuRequested.connect(
77 self.__customContextMenuRequested) 75 self.__customContextMenuRequested
78 76 )
79 self.removeButton.clicked.connect( 77
80 self.bookmarksTree.removeSelected) 78 self.removeButton.clicked.connect(self.bookmarksTree.removeSelected)
81 self.addFolderButton.clicked.connect(self.__newFolder) 79 self.addFolderButton.clicked.connect(self.__newFolder)
82 80
83 self.__expandNodes(self.__bookmarksManager.bookmarks()) 81 self.__expandNodes(self.__bookmarksManager.bookmarks())
84 82
85 def closeEvent(self, evt): 83 def closeEvent(self, evt):
86 """ 84 """
87 Protected method to handle the closing of the dialog. 85 Protected method to handle the closing of the dialog.
88 86
89 @param evt reference to the event object (QCloseEvent) (ignored) 87 @param evt reference to the event object (QCloseEvent) (ignored)
90 """ 88 """
91 self.__shutdown() 89 self.__shutdown()
92 90
93 def reject(self): 91 def reject(self):
94 """ 92 """
95 Public method called when the dialog is rejected. 93 Public method called when the dialog is rejected.
96 """ 94 """
97 self.__shutdown() 95 self.__shutdown()
98 super().reject() 96 super().reject()
99 97
100 def __shutdown(self): 98 def __shutdown(self):
101 """ 99 """
102 Private method to perform shutdown actions for the dialog. 100 Private method to perform shutdown actions for the dialog.
103 """ 101 """
104 if self.__saveExpandedNodes(self.bookmarksTree.rootIndex()): 102 if self.__saveExpandedNodes(self.bookmarksTree.rootIndex()):
105 self.__bookmarksManager.changeExpanded() 103 self.__bookmarksManager.changeExpanded()
106 104
107 def __saveExpandedNodes(self, parent): 105 def __saveExpandedNodes(self, parent):
108 """ 106 """
109 Private method to save the child nodes of an expanded node. 107 Private method to save the child nodes of an expanded node.
110 108
111 @param parent index of the parent node (QModelIndex) 109 @param parent index of the parent node (QModelIndex)
112 @return flag indicating a change (boolean) 110 @return flag indicating a change (boolean)
113 """ 111 """
114 changed = False 112 changed = False
115 for row in range(self.__proxyModel.rowCount(parent)): 113 for row in range(self.__proxyModel.rowCount(parent)):
120 if self.bookmarksTree.isExpanded(child): 118 if self.bookmarksTree.isExpanded(child):
121 childNode.expanded = True 119 childNode.expanded = True
122 changed |= self.__saveExpandedNodes(child) 120 changed |= self.__saveExpandedNodes(child)
123 else: 121 else:
124 childNode.expanded = False 122 childNode.expanded = False
125 changed |= (wasExpanded != childNode.expanded) 123 changed |= wasExpanded != childNode.expanded
126 124
127 return changed 125 return changed
128 126
129 def __expandNodes(self, node): 127 def __expandNodes(self, node):
130 """ 128 """
131 Private method to expand all child nodes of a node. 129 Private method to expand all child nodes of a node.
132 130
133 @param node reference to the bookmark node to expand (BookmarkNode) 131 @param node reference to the bookmark node to expand (BookmarkNode)
134 """ 132 """
135 for childNode in node.children(): 133 for childNode in node.children():
136 if childNode.expanded: 134 if childNode.expanded:
137 idx = self.__bookmarksModel.nodeIndex(childNode) 135 idx = self.__bookmarksModel.nodeIndex(childNode)
138 idx = self.__proxyModel.mapFromSource(idx) 136 idx = self.__proxyModel.mapFromSource(idx)
139 self.bookmarksTree.setExpanded(idx, True) 137 self.bookmarksTree.setExpanded(idx, True)
140 self.__expandNodes(childNode) 138 self.__expandNodes(childNode)
141 139
142 def __customContextMenuRequested(self, pos): 140 def __customContextMenuRequested(self, pos):
143 """ 141 """
144 Private slot to handle the context menu request for the bookmarks tree. 142 Private slot to handle the context menu request for the bookmarks tree.
145 143
146 @param pos position the context menu was requested (QPoint) 144 @param pos position the context menu was requested (QPoint)
147 """ 145 """
148 from .BookmarkNode import BookmarkNode 146 from .BookmarkNode import BookmarkNode
149 147
150 menu = QMenu() 148 menu = QMenu()
151 idx = self.bookmarksTree.indexAt(pos) 149 idx = self.bookmarksTree.indexAt(pos)
152 idx = idx.sibling(idx.row(), 0) 150 idx = idx.sibling(idx.row(), 0)
153 sourceIndex = self.__proxyModel.mapToSource(idx) 151 sourceIndex = self.__proxyModel.mapToSource(idx)
154 node = self.__bookmarksModel.node(sourceIndex) 152 node = self.__bookmarksModel.node(sourceIndex)
155 if idx.isValid() and node.type() != BookmarkNode.Folder: 153 if idx.isValid() and node.type() != BookmarkNode.Folder:
156 menu.addAction( 154 menu.addAction(self.tr("&Open"), self.__openBookmarkInCurrentTab)
157 self.tr("&Open"), self.__openBookmarkInCurrentTab) 155 menu.addAction(self.tr("Open in New &Tab"), self.__openBookmarkInNewTab)
158 menu.addAction(
159 self.tr("Open in New &Tab"), self.__openBookmarkInNewTab)
160 menu.addAction( 156 menu.addAction(
161 self.tr("Open in New &Background Tab"), 157 self.tr("Open in New &Background Tab"),
162 self.__openBookmarkInNewBackgroundTab) 158 self.__openBookmarkInNewBackgroundTab,
159 )
163 menu.addAction( 160 menu.addAction(
164 self.tr("Open in New &Window"), self.__openBookmarkInNewWindow) 161 self.tr("Open in New &Window"), self.__openBookmarkInNewWindow
162 )
165 menu.addAction( 163 menu.addAction(
166 self.tr("Open in New Pri&vate Window"), 164 self.tr("Open in New Pri&vate Window"),
167 self.__openBookmarkInPrivateWindow) 165 self.__openBookmarkInPrivateWindow,
166 )
168 menu.addSeparator() 167 menu.addSeparator()
169 act = menu.addAction(self.tr("Edit &Name"), self.__editName) 168 act = menu.addAction(self.tr("Edit &Name"), self.__editName)
170 act.setEnabled(idx.flags() & Qt.ItemFlag.ItemIsEditable == 169 act.setEnabled(
171 Qt.ItemFlag.ItemIsEditable) 170 idx.flags() & Qt.ItemFlag.ItemIsEditable == Qt.ItemFlag.ItemIsEditable
171 )
172 if idx.isValid() and node.type() != BookmarkNode.Folder: 172 if idx.isValid() and node.type() != BookmarkNode.Folder:
173 menu.addAction(self.tr("Edit &Address"), self.__editAddress) 173 menu.addAction(self.tr("Edit &Address"), self.__editAddress)
174 menu.addSeparator() 174 menu.addSeparator()
175 act = menu.addAction( 175 act = menu.addAction(self.tr("&Delete"), self.bookmarksTree.removeSelected)
176 self.tr("&Delete"), self.bookmarksTree.removeSelected) 176 act.setEnabled(
177 act.setEnabled(idx.flags() & Qt.ItemFlag.ItemIsDragEnabled == 177 idx.flags() & Qt.ItemFlag.ItemIsDragEnabled == Qt.ItemFlag.ItemIsDragEnabled
178 Qt.ItemFlag.ItemIsDragEnabled) 178 )
179 menu.addSeparator() 179 menu.addSeparator()
180 act = menu.addAction(self.tr("&Properties..."), self.__edit) 180 act = menu.addAction(self.tr("&Properties..."), self.__edit)
181 act.setEnabled(idx.flags() & Qt.ItemFlag.ItemIsEditable == 181 act.setEnabled(
182 Qt.ItemFlag.ItemIsEditable) 182 idx.flags() & Qt.ItemFlag.ItemIsEditable == Qt.ItemFlag.ItemIsEditable
183 )
183 if idx.isValid() and node.type() == BookmarkNode.Folder: 184 if idx.isValid() and node.type() == BookmarkNode.Folder:
184 menu.addSeparator() 185 menu.addSeparator()
185 menu.addAction(self.tr("New &Folder..."), self.__newFolder) 186 menu.addAction(self.tr("New &Folder..."), self.__newFolder)
186 menu.exec(QCursor.pos()) 187 menu.exec(QCursor.pos())
187 188
188 def __activated(self, idx): 189 def __activated(self, idx):
189 """ 190 """
190 Private slot to handle the activation of an entry. 191 Private slot to handle the activation of an entry.
191 192
192 @param idx reference to the entry index (QModelIndex) 193 @param idx reference to the entry index (QModelIndex)
193 """ 194 """
194 if ( 195 if QApplication.keyboardModifiers() & Qt.KeyboardModifier.ControlModifier:
195 QApplication.keyboardModifiers() &
196 Qt.KeyboardModifier.ControlModifier
197 ):
198 self.__openBookmarkInNewTab() 196 self.__openBookmarkInNewTab()
199 elif ( 197 elif QApplication.keyboardModifiers() & Qt.KeyboardModifier.ShiftModifier:
200 QApplication.keyboardModifiers() &
201 Qt.KeyboardModifier.ShiftModifier
202 ):
203 self.__openBookmarkInNewWindow() 198 self.__openBookmarkInNewWindow()
204 else: 199 else:
205 self.__openBookmarkInCurrentTab() 200 self.__openBookmarkInCurrentTab()
206 201
207 def __openBookmarkInCurrentTab(self): 202 def __openBookmarkInCurrentTab(self):
208 """ 203 """
209 Private slot to open a bookmark in the current browser tab. 204 Private slot to open a bookmark in the current browser tab.
210 """ 205 """
211 self.__openBookmark() 206 self.__openBookmark()
212 207
213 def __openBookmarkInNewTab(self): 208 def __openBookmarkInNewTab(self):
214 """ 209 """
215 Private slot to open a bookmark in a new browser tab. 210 Private slot to open a bookmark in a new browser tab.
216 """ 211 """
217 self.__openBookmark(newTab=True) 212 self.__openBookmark(newTab=True)
218 213
219 def __openBookmarkInNewBackgroundTab(self): 214 def __openBookmarkInNewBackgroundTab(self):
220 """ 215 """
221 Private slot to open a bookmark in a new browser tab. 216 Private slot to open a bookmark in a new browser tab.
222 """ 217 """
223 self.__openBookmark(newTab=True, background=True) 218 self.__openBookmark(newTab=True, background=True)
224 219
225 def __openBookmarkInNewWindow(self): 220 def __openBookmarkInNewWindow(self):
226 """ 221 """
227 Private slot to open a bookmark in a new browser window. 222 Private slot to open a bookmark in a new browser window.
228 """ 223 """
229 self.__openBookmark(newWindow=True) 224 self.__openBookmark(newWindow=True)
230 225
231 def __openBookmarkInPrivateWindow(self): 226 def __openBookmarkInPrivateWindow(self):
232 """ 227 """
233 Private slot to open a bookmark in a new private browser window. 228 Private slot to open a bookmark in a new private browser window.
234 """ 229 """
235 self.__openBookmark(newWindow=True, privateWindow=True) 230 self.__openBookmark(newWindow=True, privateWindow=True)
236 231
237 def __openBookmark(self, newTab=False, newWindow=False, 232 def __openBookmark(
238 privateWindow=False, background=False): 233 self, newTab=False, newWindow=False, privateWindow=False, background=False
234 ):
239 """ 235 """
240 Private method to open a bookmark. 236 Private method to open a bookmark.
241 237
242 @param newTab flag indicating to open the bookmark in a new tab 238 @param newTab flag indicating to open the bookmark in a new tab
243 @type bool 239 @type bool
244 @param newWindow flag indicating to open the bookmark in a new window 240 @param newWindow flag indicating to open the bookmark in a new window
245 @type bool 241 @type bool
246 @param privateWindow flag indicating to open the bookmark in a new 242 @param privateWindow flag indicating to open the bookmark in a new
250 background tab 246 background tab
251 @type bool 247 @type bool
252 """ 248 """
253 from .BookmarkNode import BookmarkNode 249 from .BookmarkNode import BookmarkNode
254 from .BookmarksModel import BookmarksModel 250 from .BookmarksModel import BookmarksModel
255 251
256 idx = self.bookmarksTree.currentIndex() 252 idx = self.bookmarksTree.currentIndex()
257 sourceIndex = self.__proxyModel.mapToSource(idx) 253 sourceIndex = self.__proxyModel.mapToSource(idx)
258 node = self.__bookmarksModel.node(sourceIndex) 254 node = self.__bookmarksModel.node(sourceIndex)
259 if ( 255 if (
260 not idx.parent().isValid() or 256 not idx.parent().isValid()
261 node is None or 257 or node is None
262 node.type() == BookmarkNode.Folder 258 or node.type() == BookmarkNode.Folder
263 ): 259 ):
264 return 260 return
265 261
266 if newWindow: 262 if newWindow:
267 from WebBrowser.WebBrowserWindow import WebBrowserWindow 263 from WebBrowser.WebBrowserWindow import WebBrowserWindow
264
268 url = idx.sibling(idx.row(), 1).data(BookmarksModel.UrlRole) 265 url = idx.sibling(idx.row(), 1).data(BookmarksModel.UrlRole)
269 if privateWindow: 266 if privateWindow:
270 WebBrowserWindow.mainWindow().newPrivateWindow(url) 267 WebBrowserWindow.mainWindow().newPrivateWindow(url)
271 else: 268 else:
272 WebBrowserWindow.mainWindow().newWindow(url) 269 WebBrowserWindow.mainWindow().newWindow(url)
273 else: 270 else:
274 if newTab: 271 if newTab:
275 if background: 272 if background:
276 self.newBackgroundTab.emit( 273 self.newBackgroundTab.emit(
277 idx.sibling(idx.row(), 1).data( 274 idx.sibling(idx.row(), 1).data(BookmarksModel.UrlRole),
278 BookmarksModel.UrlRole), 275 idx.sibling(idx.row(), 0).data(Qt.ItemDataRole.DisplayRole),
279 idx.sibling(idx.row(), 0).data( 276 )
280 Qt.ItemDataRole.DisplayRole))
281 else: 277 else:
282 self.newTab.emit( 278 self.newTab.emit(
283 idx.sibling(idx.row(), 1).data( 279 idx.sibling(idx.row(), 1).data(BookmarksModel.UrlRole),
284 BookmarksModel.UrlRole), 280 idx.sibling(idx.row(), 0).data(Qt.ItemDataRole.DisplayRole),
285 idx.sibling(idx.row(), 0).data( 281 )
286 Qt.ItemDataRole.DisplayRole))
287 else: 282 else:
288 self.openUrl.emit( 283 self.openUrl.emit(
289 idx.sibling(idx.row(), 1).data( 284 idx.sibling(idx.row(), 1).data(BookmarksModel.UrlRole),
290 BookmarksModel.UrlRole), 285 idx.sibling(idx.row(), 0).data(Qt.ItemDataRole.DisplayRole),
291 idx.sibling(idx.row(), 0).data( 286 )
292 Qt.ItemDataRole.DisplayRole))
293 self.__bookmarksManager.incVisitCount(node) 287 self.__bookmarksManager.incVisitCount(node)
294 288
295 def __editName(self): 289 def __editName(self):
296 """ 290 """
297 Private slot to edit the name part of a bookmark. 291 Private slot to edit the name part of a bookmark.
298 """ 292 """
299 idx = self.bookmarksTree.currentIndex() 293 idx = self.bookmarksTree.currentIndex()
300 idx = idx.sibling(idx.row(), 0) 294 idx = idx.sibling(idx.row(), 0)
301 self.bookmarksTree.edit(idx) 295 self.bookmarksTree.edit(idx)
302 296
303 def __editAddress(self): 297 def __editAddress(self):
304 """ 298 """
305 Private slot to edit the address part of a bookmark. 299 Private slot to edit the address part of a bookmark.
306 """ 300 """
307 idx = self.bookmarksTree.currentIndex() 301 idx = self.bookmarksTree.currentIndex()
308 idx = idx.sibling(idx.row(), 1) 302 idx = idx.sibling(idx.row(), 1)
309 self.bookmarksTree.edit(idx) 303 self.bookmarksTree.edit(idx)
310 304
311 def __edit(self): 305 def __edit(self):
312 """ 306 """
313 Private slot to edit a bookmarks properties. 307 Private slot to edit a bookmarks properties.
314 """ 308 """
315 from .BookmarkPropertiesDialog import BookmarkPropertiesDialog 309 from .BookmarkPropertiesDialog import BookmarkPropertiesDialog
316 310
317 idx = self.bookmarksTree.currentIndex() 311 idx = self.bookmarksTree.currentIndex()
318 sourceIndex = self.__proxyModel.mapToSource(idx) 312 sourceIndex = self.__proxyModel.mapToSource(idx)
319 node = self.__bookmarksModel.node(sourceIndex) 313 node = self.__bookmarksModel.node(sourceIndex)
320 dlg = BookmarkPropertiesDialog(node) 314 dlg = BookmarkPropertiesDialog(node)
321 dlg.exec() 315 dlg.exec()
322 316
323 def __newFolder(self): 317 def __newFolder(self):
324 """ 318 """
325 Private slot to add a new bookmarks folder. 319 Private slot to add a new bookmarks folder.
326 """ 320 """
327 from .BookmarkNode import BookmarkNode 321 from .BookmarkNode import BookmarkNode
328 322
329 currentIndex = self.bookmarksTree.currentIndex() 323 currentIndex = self.bookmarksTree.currentIndex()
330 idx = QModelIndex(currentIndex) 324 idx = QModelIndex(currentIndex)
331 sourceIndex = self.__proxyModel.mapToSource(idx) 325 sourceIndex = self.__proxyModel.mapToSource(idx)
332 sourceNode = self.__bookmarksModel.node(sourceIndex) 326 sourceNode = self.__bookmarksModel.node(sourceIndex)
333 row = -1 # append new folder as the last item per default 327 row = -1 # append new folder as the last item per default
334 328
335 if ( 329 if sourceNode is not None and sourceNode.type() != BookmarkNode.Folder:
336 sourceNode is not None and
337 sourceNode.type() != BookmarkNode.Folder
338 ):
339 # If the selected item is not a folder, add a new folder to the 330 # If the selected item is not a folder, add a new folder to the
340 # parent folder, but directly below the selected item. 331 # parent folder, but directly below the selected item.
341 idx = idx.parent() 332 idx = idx.parent()
342 row = currentIndex.row() + 1 333 row = currentIndex.row() + 1
343 334
344 if not idx.isValid(): 335 if not idx.isValid():
345 # Select bookmarks menu as default. 336 # Select bookmarks menu as default.
346 idx = self.__proxyModel.index(1, 0) 337 idx = self.__proxyModel.index(1, 0)
347 338
348 idx = self.__proxyModel.mapToSource(idx) 339 idx = self.__proxyModel.mapToSource(idx)
349 parent = self.__bookmarksModel.node(idx) 340 parent = self.__bookmarksModel.node(idx)
350 title, ok = QInputDialog.getText( 341 title, ok = QInputDialog.getText(
351 self, 342 self,
352 self.tr("New Bookmark Folder"), 343 self.tr("New Bookmark Folder"),
353 self.tr("Enter title for new bookmark folder:"), 344 self.tr("Enter title for new bookmark folder:"),
354 QLineEdit.EchoMode.Normal) 345 QLineEdit.EchoMode.Normal,
355 346 )
347
356 if ok: 348 if ok:
357 if not title: 349 if not title:
358 title = self.tr("New Folder") 350 title = self.tr("New Folder")
359 node = BookmarkNode(BookmarkNode.Folder) 351 node = BookmarkNode(BookmarkNode.Folder)
360 node.title = title 352 node.title = title

eric ide

mercurial