8 """ |
8 """ |
9 |
9 |
10 |
10 |
11 from PyQt5.QtCore import pyqtSignal, Qt, QUrl, QModelIndex |
11 from PyQt5.QtCore import pyqtSignal, Qt, QUrl, QModelIndex |
12 from PyQt5.QtGui import QFontMetrics, QCursor |
12 from PyQt5.QtGui import QFontMetrics, QCursor |
13 from PyQt5.QtWidgets import QDialog, QMenu, QApplication |
13 from PyQt5.QtWidgets import ( |
|
14 QDialog, QMenu, QApplication, QInputDialog, QLineEdit |
|
15 ) |
14 |
16 |
15 from E5Gui.E5TreeSortFilterProxyModel import E5TreeSortFilterProxyModel |
17 from E5Gui.E5TreeSortFilterProxyModel import E5TreeSortFilterProxyModel |
16 |
18 |
17 from .Ui_BookmarksDialog import Ui_BookmarksDialog |
19 from .Ui_BookmarksDialog import Ui_BookmarksDialog |
18 |
20 |
173 self.tr("&Delete"), self.bookmarksTree.removeSelected) |
175 self.tr("&Delete"), self.bookmarksTree.removeSelected) |
174 act.setEnabled(idx.flags() & Qt.ItemIsDragEnabled) |
176 act.setEnabled(idx.flags() & Qt.ItemIsDragEnabled) |
175 menu.addSeparator() |
177 menu.addSeparator() |
176 act = menu.addAction(self.tr("&Properties..."), self.__edit) |
178 act = menu.addAction(self.tr("&Properties..."), self.__edit) |
177 act.setEnabled(idx.flags() & Qt.ItemIsEditable) |
179 act.setEnabled(idx.flags() & Qt.ItemIsEditable) |
|
180 if idx.isValid() and node.type() == BookmarkNode.Folder: |
|
181 menu.addSeparator() |
|
182 menu.addAction(self.tr("New &Folder..."), self.__newFolder) |
178 menu.exec_(QCursor.pos()) |
183 menu.exec_(QCursor.pos()) |
179 |
184 |
180 def __activated(self, idx): |
185 def __activated(self, idx): |
181 """ |
186 """ |
182 Private slot to handle the activation of an entry. |
187 Private slot to handle the activation of an entry. |
325 # Select bookmarks menu as default. |
330 # Select bookmarks menu as default. |
326 idx = self.__proxyModel.index(1, 0) |
331 idx = self.__proxyModel.index(1, 0) |
327 |
332 |
328 idx = self.__proxyModel.mapToSource(idx) |
333 idx = self.__proxyModel.mapToSource(idx) |
329 parent = self.__bookmarksModel.node(idx) |
334 parent = self.__bookmarksModel.node(idx) |
330 node = BookmarkNode(BookmarkNode.Folder) |
335 title, ok = QInputDialog.getText( |
331 node.title = self.tr("New Folder") |
336 self, |
332 self.__bookmarksManager.addBookmark(parent, node, row) |
337 self.tr("New Bookmark Folder"), |
|
338 self.tr("Enter title for new bookmark folder:"), |
|
339 QLineEdit.Normal) |
|
340 |
|
341 if ok: |
|
342 if not title: |
|
343 title = self.tr("New Folder") |
|
344 node = BookmarkNode(BookmarkNode.Folder) |
|
345 node.title = title |
|
346 self.__bookmarksManager.addBookmark(parent, node, row) |