Tue, 08 Nov 2022 18:18:01 +0100
Changed the editor outline model to use the new way of getting the class browser module.
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
8881
54e42bc2437a
Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
3 | # Copyright (c) 2020 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the editor outline model. |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
10 | import contextlib |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | import os |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
13 | from PyQt6.QtCore import QCoreApplication, QModelIndex |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
15 | from eric7 import Preferences |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
16 | from eric7.UI.BrowserModel import ( |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
17 | BrowserClassAttributesItem, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
18 | BrowserClassItem, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
19 | BrowserCodingItem, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
20 | BrowserGlobalsItem, |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
21 | BrowserImportItem, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
22 | BrowserImportsItem, |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
23 | BrowserItem, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
24 | BrowserMethodItem, |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
25 | BrowserModel, |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | ) |
9491
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
27 | from eric7.Utilities import ClassBrowsers |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | class EditorOutlineModel(BrowserModel): |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | """ |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | Class implementing the editor outline model. |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
34 | |
9491
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
35 | SupportedLanguages = { |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
36 | "IDL": "idl", |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
37 | "JavaScript": "javascript", |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
38 | "Protocol": "protobuf", |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
39 | "Python3": "python", |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
40 | "MicroPython": "python", |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
41 | "Cython": "python", |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
42 | "Ruby": "ruby", |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
43 | } |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
44 | |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
45 | def __init__(self, editor, populate=True): |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | """ |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
48 | |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | @param editor reference to the editor containing the source text |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | @type Editor |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
51 | @param populate flag indicating to populate the outline |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
52 | @type bool |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
54 | super().__init__(nopopulate=True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
55 | |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | self.__editor = editor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
57 | |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | self.__populated = False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
59 | |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | rootData = QCoreApplication.translate("EditorOutlineModel", "Name") |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | self.rootItem = BrowserItem(None, rootData) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
62 | |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
63 | if populate: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
64 | self.__populateModel() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
65 | |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | def __populateModel(self, repopulate=False): |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | """ |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | Private slot to populate the model. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
69 | |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | @param repopulate flag indicating a repopulation |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | @type bool |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | """ |
7686
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
73 | self.__filename = self.__editor.getFileName() |
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
74 | self.__module = os.path.basename(self.__filename) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
75 | |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | language = self.__editor.getLanguage() |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | if language in EditorOutlineModel.SupportedLanguages: |
9491
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
78 | mod = ClassBrowsers.getClassBrowserModule( |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
79 | EditorOutlineModel.SupportedLanguages[language] |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
80 | ) |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
81 | if mod: |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
82 | dictionary = mod.scan( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
83 | self.__editor.text(), self.__filename, self.__module |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
84 | ) |
9491
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
85 | mod.clearModulesCache() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
86 | |
9491
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
87 | keys = list(dictionary.keys()) |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
88 | if len(keys) > 0: |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
89 | parentItem = self.rootItem |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
90 | |
9491
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
91 | if repopulate: |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
92 | last = len(keys) - 1 |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
93 | if "@@Coding@@" in keys and not Preferences.getEditor( |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
94 | "SourceOutlineShowCoding" |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
95 | ): |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
96 | last -= 1 |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
97 | self.beginInsertRows(QModelIndex(), 0, last) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
98 | |
9491
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
99 | for key in keys: |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
100 | if key.startswith("@@"): |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
101 | # special treatment done later |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
102 | continue |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
103 | cl = dictionary[key] |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
104 | with contextlib.suppress(AttributeError): |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
105 | if cl.module == self.__module: |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
106 | node = BrowserClassItem(parentItem, cl, self.__filename) |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
107 | self._addItem(node, parentItem) |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
108 | if "@@Coding@@" in keys and Preferences.getEditor( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
109 | "SourceOutlineShowCoding" |
7757
1f9f35f9be6d
File Browser, Project Source Browser, Editor Outline: added option to suppress the source code encoding line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7697
diff
changeset
|
110 | ): |
9491
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
111 | node = BrowserCodingItem( |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
112 | parentItem, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
113 | QCoreApplication.translate( |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
114 | "EditorOutlineModel", "Coding: {0}" |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
115 | ).format(dictionary["@@Coding@@"].coding), |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
116 | dictionary["@@Coding@@"].linenumber, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
117 | ) |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
118 | self._addItem(node, parentItem) |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
119 | if "@@Globals@@" in keys: |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
120 | node = BrowserGlobalsItem( |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
121 | parentItem, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
122 | dictionary["@@Globals@@"].globals, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
123 | QCoreApplication.translate("EditorOutlineModel", "Globals"), |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
124 | ) |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
125 | self._addItem(node, parentItem) |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
126 | if "@@Import@@" in keys or "@@ImportFrom@@" in keys: |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
127 | node = BrowserImportsItem( |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
128 | parentItem, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
129 | QCoreApplication.translate("EditorOutlineModel", "Imports"), |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
130 | ) |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
131 | self._addItem(node, parentItem) |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
132 | if "@@Import@@" in keys: |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
133 | for importedModule in ( |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
134 | dictionary["@@Import@@"].getImports().values() |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
135 | ): |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
136 | m_node = BrowserImportItem( |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
137 | node, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
138 | importedModule.importedModuleName, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
139 | importedModule.file, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
140 | importedModule.linenos, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
141 | ) |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
142 | self._addItem(m_node, node) |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
143 | for ( |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
144 | importedName, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
145 | linenos, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
146 | ) in importedModule.importedNames.items(): |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
147 | mn_node = BrowserImportItem( |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
148 | m_node, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
149 | importedName, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
150 | importedModule.file, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
151 | linenos, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
152 | isModule=False, |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
153 | ) |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
154 | self._addItem(mn_node, m_node) |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
155 | if repopulate: |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
156 | self.endInsertRows() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
157 | |
9491
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
158 | self.__populated = True |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
159 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
160 | |
9491
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
161 | self.clear() |
91bcf8b893ee
Changed the editor outline model to use the new way of getting the class browser module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
162 | self.__populated = False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
163 | |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | def isPopulated(self): |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | """ |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | Public method to check, if the model is populated. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
167 | |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | @return flag indicating a populated model |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | @rtype bool |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | """ |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | return self.__populated |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
172 | |
7685
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | def repopulate(self): |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | """ |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | Public slot to repopulate the model. |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | """ |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | self.clear() |
0b6e8c0d6403
Started implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | self.__populateModel(repopulate=True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
179 | |
7686
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
180 | def editor(self): |
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
181 | """ |
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
182 | Public method to retrieve a reference to the editor. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
183 | |
7686
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
184 | @return reference to the editor |
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
185 | @rtype Editor |
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
186 | """ |
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
187 | return self.__editor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
188 | |
7686
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
189 | def fileName(self): |
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
190 | """ |
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
191 | Public method to retrieve the file name of the editor. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
192 | |
7686
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
193 | @return file name of the editor |
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
194 | @rtype str |
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
195 | """ |
379d402162ca
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7685
diff
changeset
|
196 | return self.__filename |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
197 | |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
198 | def itemIndexByLine(self, lineno): |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
199 | """ |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
200 | Public method to find an item's index given a line number. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
201 | |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
202 | @param lineno one based line number of the item |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
203 | @type int |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
204 | @return index of the item found |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
205 | @rtype QModelIndex |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
206 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
207 | |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
208 | def findItem(lineno, parent): |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
209 | """ |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
210 | Function to iteratively search for an item containing the given |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
211 | line. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
212 | |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
213 | @param lineno one based line number of the item |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
214 | @type int |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
215 | @param parent reference to the parent item |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
216 | @type BrowserItem |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
217 | @return found item or None |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
218 | @rtype BrowserItem |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
219 | """ |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
220 | if not parent.isPopulated(): |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
221 | if parent.isLazyPopulated(): |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
222 | self.populateItem(parent) |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
223 | else: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
224 | return None |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
225 | for child in parent.children(): |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
226 | if isinstance(child, BrowserClassAttributesItem): |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
227 | itm = findItem(lineno, child) |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
228 | if itm is not None: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
229 | return itm |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
230 | elif isinstance(child, (BrowserClassItem, BrowserMethodItem)): |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
231 | start, end = child.boundaries() |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
232 | if end == -1: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
233 | end = 1000000 # assume end of file |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
234 | if start <= lineno <= end: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
235 | itm = findItem(lineno, child) |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
236 | if itm is not None: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
237 | return itm |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
238 | else: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
239 | return child |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
240 | elif hasattr(child, "linenos"): |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
241 | if lineno in child.linenos(): |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
242 | return child |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
243 | elif hasattr(child, "lineno") and lineno == child.lineno(): |
8222
5994b80b8760
Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
244 | return child |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
245 | else: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
246 | return None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
247 | |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
248 | if self.__populated: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
249 | for rootChild in self.rootItem.children(): |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
250 | itm = None |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
251 | if isinstance(rootChild, BrowserClassItem): |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
252 | start, end = rootChild.boundaries() |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
253 | if end == -1: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
254 | end = 1000000 # assume end of file |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
255 | if start <= lineno <= end: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
256 | itm = findItem(lineno, rootChild) |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
257 | if itm is None: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
258 | itm = rootChild |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
259 | elif isinstance(rootChild, (BrowserImportsItem, BrowserGlobalsItem)): |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
260 | itm = findItem(lineno, rootChild) |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
261 | elif ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
262 | isinstance(rootChild, BrowserCodingItem) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
263 | and lineno == rootChild.lineno() |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
264 | ): |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
265 | itm = rootChild |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
266 | if itm is not None: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
267 | return self.createIndex(itm.row(), 0, itm) |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
268 | else: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
269 | return QModelIndex() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
270 | |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7686
diff
changeset
|
271 | return QModelIndex() |