73 |
74 |
74 dictionary = ClassBrowsers.scan( |
75 dictionary = ClassBrowsers.scan( |
75 self.__editor.text(), self.__filename, self.__module |
76 self.__editor.text(), self.__filename, self.__module |
76 ) |
77 ) |
77 if dictionary is not None: |
78 if dictionary is not None: |
78 keys = list(dictionary) |
79 if len(dictionary) > 0: |
79 if len(keys) > 0: |
|
80 parentItem = self.rootItem |
80 parentItem = self.rootItem |
81 |
81 |
82 if repopulate: |
82 if repopulate: |
83 last = len(keys) - 1 |
83 last = len(dictionary) - 1 |
84 if "@@Coding@@" in keys and not Preferences.getEditor( |
84 if "@@Coding@@" in dictionary and not Preferences.getEditor( |
85 "SourceOutlineShowCoding" |
85 "SourceOutlineShowCoding" |
86 ): |
86 ): |
87 last -= 1 |
87 last -= 1 |
88 self.beginInsertRows(QModelIndex(), 0, last) |
88 self.beginInsertRows(QModelIndex(), 0, last) |
89 |
89 |
90 for key in keys: |
90 for key in dictionary: |
91 if key.startswith("@@"): |
91 if key.startswith("@@"): |
92 # special treatment done later |
92 # special treatment done later |
93 continue |
93 continue |
94 cl = dictionary[key] |
94 cl = dictionary[key] |
95 with contextlib.suppress(AttributeError): |
95 with contextlib.suppress(AttributeError): |
96 if cl.module == self.__module: |
96 if cl.module == self.__module: |
97 node = BrowserClassItem(parentItem, cl, self.__filename) |
97 if isinstance(cl, ClbrBaseClasses.Class): |
|
98 node = BrowserClassItem(parentItem, cl, self.__filename) |
|
99 elif isinstance(cl, ClbrBaseClasses.Function): |
|
100 node = BrowserMethodItem( |
|
101 parentItem, cl, self.__filename |
|
102 ) |
98 self._addItem(node, parentItem) |
103 self._addItem(node, parentItem) |
99 if "@@Coding@@" in keys and Preferences.getEditor( |
104 if "@@Coding@@" in dictionary and Preferences.getEditor( |
100 "SourceOutlineShowCoding" |
105 "SourceOutlineShowCoding" |
101 ): |
106 ): |
102 node = BrowserCodingItem( |
107 node = BrowserCodingItem( |
103 parentItem, |
108 parentItem, |
104 QCoreApplication.translate( |
109 QCoreApplication.translate( |
105 "EditorOutlineModel", "Coding: {0}" |
110 "EditorOutlineModel", "Coding: {0}" |
106 ).format(dictionary["@@Coding@@"].coding), |
111 ).format(dictionary["@@Coding@@"].coding), |
107 dictionary["@@Coding@@"].linenumber, |
112 dictionary["@@Coding@@"].linenumber, |
108 ) |
113 ) |
109 self._addItem(node, parentItem) |
114 self._addItem(node, parentItem) |
110 if "@@Globals@@" in keys: |
115 if "@@Globals@@" in dictionary: |
111 node = BrowserGlobalsItem( |
116 node = BrowserGlobalsItem( |
112 parentItem, |
117 parentItem, |
113 dictionary["@@Globals@@"].globals, |
118 dictionary["@@Globals@@"].globals, |
114 QCoreApplication.translate("EditorOutlineModel", "Globals"), |
119 QCoreApplication.translate("EditorOutlineModel", "Globals"), |
115 ) |
120 ) |
116 self._addItem(node, parentItem) |
121 self._addItem(node, parentItem) |
117 if "@@Import@@" in keys or "@@ImportFrom@@" in keys: |
122 if "@@Import@@" in dictionary or "@@ImportFrom@@" in dictionary: |
118 node = BrowserImportsItem( |
123 node = BrowserImportsItem( |
119 parentItem, |
124 parentItem, |
120 QCoreApplication.translate("EditorOutlineModel", "Imports"), |
125 QCoreApplication.translate("EditorOutlineModel", "Imports"), |
121 ) |
126 ) |
122 self._addItem(node, parentItem) |
127 self._addItem(node, parentItem) |
123 if "@@Import@@" in keys: |
128 if "@@Import@@" in dictionary: |
124 for importedModule in ( |
129 for importedModule in ( |
125 dictionary["@@Import@@"].getImports().values() |
130 dictionary["@@Import@@"].getImports().values() |
126 ): |
131 ): |
127 m_node = BrowserImportItem( |
132 m_node = BrowserImportItem( |
128 node, |
133 node, |