6 """ |
6 """ |
7 Module implementing an outline widget for source code navigation of the editor. |
7 Module implementing an outline widget for source code navigation of the editor. |
8 """ |
8 """ |
9 |
9 |
10 import contextlib |
10 import contextlib |
|
11 import functools |
11 |
12 |
12 from PyQt6.QtCore import pyqtSlot, Qt, QCoreApplication, QModelIndex, QPoint |
13 from PyQt6.QtCore import pyqtSlot, Qt, QCoreApplication, QModelIndex, QPoint |
13 from PyQt6.QtWidgets import QTreeView, QAbstractItemView, QMenu, QApplication, QDialog |
14 from PyQt6.QtWidgets import QTreeView, QAbstractItemView, QMenu, QApplication, QDialog |
14 |
15 |
15 from UI.BrowserSortFilterProxyModel import BrowserSortFilterProxyModel |
16 from UI.BrowserSortFilterProxyModel import BrowserSortFilterProxyModel |
272 # create the attribute/import menu |
273 # create the attribute/import menu |
273 self.__gotoMenu = QMenu( |
274 self.__gotoMenu = QMenu( |
274 QCoreApplication.translate("EditorOutlineView", "Goto"), self |
275 QCoreApplication.translate("EditorOutlineView", "Goto"), self |
275 ) |
276 ) |
276 self.__gotoMenu.aboutToShow.connect(self.__showGotoMenu) |
277 self.__gotoMenu.aboutToShow.connect(self.__showGotoMenu) |
277 self.__gotoMenu.triggered.connect(self.__gotoAttribute) |
|
278 |
278 |
279 self.__attributeMenu = QMenu(self) |
279 self.__attributeMenu = QMenu(self) |
280 self.__attributeMenu.addMenu(self.__gotoMenu) |
280 self.__attributeMenu.addMenu(self.__gotoMenu) |
281 self.__attributeMenu.addSeparator() |
281 self.__attributeMenu.addSeparator() |
282 self.__attributeMenu.addAction( |
282 self.__attributeMenu.addAction( |
401 QCoreApplication.translate("EditorOutlineView", "Line {0}").format( |
401 QCoreApplication.translate("EditorOutlineView", "Line {0}").format( |
402 lineno |
402 lineno |
403 ) |
403 ) |
404 ) |
404 ) |
405 act.setData(lineno) |
405 act.setData(lineno) |
|
406 act.triggered.connect(functools.partial(self.__gotoAttribute, act)) |
406 |
407 |
407 ####################################################################### |
408 ####################################################################### |
408 ## Context menu handlers below |
409 ## Context menu handlers below |
409 ####################################################################### |
410 ####################################################################### |
410 |
411 |