9 |
9 |
10 from PyQt4.QtCore import pyqtSignal, Qt, QUrl, QModelIndex |
10 from PyQt4.QtCore import pyqtSignal, Qt, QUrl, QModelIndex |
11 from PyQt4.QtGui import QDialog, QFontMetrics, QMenu, QCursor, QApplication |
11 from PyQt4.QtGui import QDialog, QFontMetrics, QMenu, QCursor, QApplication |
12 |
12 |
13 from E5Gui.E5TreeSortFilterProxyModel import E5TreeSortFilterProxyModel |
13 from E5Gui.E5TreeSortFilterProxyModel import E5TreeSortFilterProxyModel |
14 |
|
15 import Helpviewer.HelpWindow |
|
16 from .BookmarkNode import BookmarkNode |
|
17 from .BookmarksModel import BookmarksModel |
|
18 from .BookmarkPropertiesDialog import BookmarkPropertiesDialog |
|
19 |
14 |
20 from .Ui_BookmarksDialog import Ui_BookmarksDialog |
15 from .Ui_BookmarksDialog import Ui_BookmarksDialog |
21 |
16 |
22 |
17 |
23 class BookmarksDialog(QDialog, Ui_BookmarksDialog): |
18 class BookmarksDialog(QDialog, Ui_BookmarksDialog): |
40 super().__init__(parent) |
35 super().__init__(parent) |
41 self.setupUi(self) |
36 self.setupUi(self) |
42 |
37 |
43 self.__bookmarksManager = manager |
38 self.__bookmarksManager = manager |
44 if self.__bookmarksManager is None: |
39 if self.__bookmarksManager is None: |
|
40 import Helpviewer.HelpWindow |
45 self.__bookmarksManager = Helpviewer.HelpWindow.HelpWindow.bookmarksManager() |
41 self.__bookmarksManager = Helpviewer.HelpWindow.HelpWindow.bookmarksManager() |
46 |
42 |
47 self.__bookmarksModel = self.__bookmarksManager.bookmarksModel() |
43 self.__bookmarksModel = self.__bookmarksManager.bookmarksModel() |
48 self.__proxyModel = E5TreeSortFilterProxyModel(self) |
44 self.__proxyModel = E5TreeSortFilterProxyModel(self) |
49 self.__proxyModel.setFilterKeyColumn(-1) |
45 self.__proxyModel.setFilterKeyColumn(-1) |
129 """ |
125 """ |
130 Private slot to handle the context menu request for the bookmarks tree. |
126 Private slot to handle the context menu request for the bookmarks tree. |
131 |
127 |
132 @param pos position the context menu was requested (QPoint) |
128 @param pos position the context menu was requested (QPoint) |
133 """ |
129 """ |
|
130 from .BookmarkNode import BookmarkNode |
|
131 |
134 menu = QMenu() |
132 menu = QMenu() |
135 idx = self.bookmarksTree.indexAt(pos) |
133 idx = self.bookmarksTree.indexAt(pos) |
136 idx = idx.sibling(idx.row(), 0) |
134 idx = idx.sibling(idx.row(), 0) |
137 sourceIndex = self.__proxyModel.mapToSource(idx) |
135 sourceIndex = self.__proxyModel.mapToSource(idx) |
138 node = self.__bookmarksModel.node(sourceIndex) |
136 node = self.__bookmarksModel.node(sourceIndex) |
176 """ |
174 """ |
177 Private method to open a bookmark. |
175 Private method to open a bookmark. |
178 |
176 |
179 @param newTab flag indicating to open the bookmark in a new tab (boolean) |
177 @param newTab flag indicating to open the bookmark in a new tab (boolean) |
180 """ |
178 """ |
|
179 from .BookmarkNode import BookmarkNode |
|
180 from .BookmarksModel import BookmarksModel |
|
181 |
181 idx = self.bookmarksTree.currentIndex() |
182 idx = self.bookmarksTree.currentIndex() |
182 sourceIndex = self.__proxyModel.mapToSource(idx) |
183 sourceIndex = self.__proxyModel.mapToSource(idx) |
183 node = self.__bookmarksModel.node(sourceIndex) |
184 node = self.__bookmarksModel.node(sourceIndex) |
184 if not idx.parent().isValid() or \ |
185 if not idx.parent().isValid() or \ |
185 node is None or \ |
186 node is None or \ |
212 |
213 |
213 def __edit(self): |
214 def __edit(self): |
214 """ |
215 """ |
215 Private slot to edit a bookmarks properties. |
216 Private slot to edit a bookmarks properties. |
216 """ |
217 """ |
|
218 from .BookmarkPropertiesDialog import BookmarkPropertiesDialog |
|
219 |
217 idx = self.bookmarksTree.currentIndex() |
220 idx = self.bookmarksTree.currentIndex() |
218 sourceIndex = self.__proxyModel.mapToSource(idx) |
221 sourceIndex = self.__proxyModel.mapToSource(idx) |
219 node = self.__bookmarksModel.node(sourceIndex) |
222 node = self.__bookmarksModel.node(sourceIndex) |
220 dlg = BookmarkPropertiesDialog(node) |
223 dlg = BookmarkPropertiesDialog(node) |
221 dlg.exec_() |
224 dlg.exec_() |
222 |
225 |
223 def __newFolder(self): |
226 def __newFolder(self): |
224 """ |
227 """ |
225 Private slot to add a new bookmarks folder. |
228 Private slot to add a new bookmarks folder. |
226 """ |
229 """ |
|
230 from .BookmarkNode import BookmarkNode |
|
231 |
227 currentIndex = self.bookmarksTree.currentIndex() |
232 currentIndex = self.bookmarksTree.currentIndex() |
228 idx = QModelIndex(currentIndex) |
233 idx = QModelIndex(currentIndex) |
229 sourceIndex = self.__proxyModel.mapToSource(idx) |
234 sourceIndex = self.__proxyModel.mapToSource(idx) |
230 sourceNode = self.__bookmarksModel.node(sourceIndex) |
235 sourceNode = self.__bookmarksModel.node(sourceIndex) |
231 row = -1 # append new folder as the last item per default |
236 row = -1 # append new folder as the last item per default |