42 @type Editor |
42 @type Editor |
43 @param tv reference to the task viewer object |
43 @param tv reference to the task viewer object |
44 @type TaskViewer |
44 @type TaskViewer |
45 """ |
45 """ |
46 super().__init__() |
46 super().__init__() |
47 |
47 |
48 self.__layout = QGridLayout(self) |
48 self.__layout = QGridLayout(self) |
49 self.__layout.setContentsMargins(0, 0, 0, 0) |
49 self.__layout.setContentsMargins(0, 0, 0, 0) |
50 self.__layout.setSpacing(1) |
50 self.__layout.setSpacing(1) |
51 |
51 |
52 from .EditorButtonsWidget import EditorButtonsWidget |
52 from .EditorButtonsWidget import EditorButtonsWidget |
53 from .Editor import Editor |
53 from .Editor import Editor |
54 from .EditorOutline import EditorOutlineView |
54 from .EditorOutline import EditorOutlineView |
55 |
55 |
56 self.__showOutline = Preferences.getEditor("ShowSourceOutline") |
56 self.__showOutline = Preferences.getEditor("ShowSourceOutline") |
57 |
57 |
58 self.__editor = Editor(dbs, fn, vm, filetype, editor, tv) |
58 self.__editor = Editor(dbs, fn, vm, filetype, editor, tv) |
59 self.__buttonsWidget = EditorButtonsWidget(self.__editor, self) |
59 self.__buttonsWidget = EditorButtonsWidget(self.__editor, self) |
60 self.__globalsCombo = QComboBox() |
60 self.__globalsCombo = QComboBox() |
61 self.__globalsCombo.setDuplicatesEnabled(True) |
61 self.__globalsCombo.setDuplicatesEnabled(True) |
62 self.__membersCombo = QComboBox() |
62 self.__membersCombo = QComboBox() |
63 self.__membersCombo.setDuplicatesEnabled(True) |
63 self.__membersCombo.setDuplicatesEnabled(True) |
64 self.__sourceOutline = EditorOutlineView( |
64 self.__sourceOutline = EditorOutlineView( |
65 self.__editor, populate=self.__showOutline) |
65 self.__editor, populate=self.__showOutline |
|
66 ) |
66 self.__sourceOutline.setMaximumWidth( |
67 self.__sourceOutline.setMaximumWidth( |
67 Preferences.getEditor("SourceOutlineWidth")) |
68 Preferences.getEditor("SourceOutlineWidth") |
68 |
69 ) |
|
70 |
69 self.__layout.addWidget(self.__buttonsWidget, 1, 0, -1, 1) |
71 self.__layout.addWidget(self.__buttonsWidget, 1, 0, -1, 1) |
70 self.__layout.addWidget(self.__globalsCombo, 0, 1) |
72 self.__layout.addWidget(self.__globalsCombo, 0, 1) |
71 self.__layout.addWidget(self.__membersCombo, 0, 2) |
73 self.__layout.addWidget(self.__membersCombo, 0, 2) |
72 self.__layout.addWidget(self.__editor, 1, 1, 1, 2) |
74 self.__layout.addWidget(self.__editor, 1, 1, 1, 2) |
73 self.__layout.addWidget(self.__sourceOutline, 0, 3, -1, -1) |
75 self.__layout.addWidget(self.__sourceOutline, 0, 3, -1, -1) |
74 |
76 |
75 self.setFocusProxy(self.__editor) |
77 self.setFocusProxy(self.__editor) |
76 |
78 |
77 self.__module = None |
79 self.__module = None |
78 |
80 |
79 self.__shutdownTimerCalled = False |
81 self.__shutdownTimerCalled = False |
80 self.__parseTimer = QTimer(self) |
82 self.__parseTimer = QTimer(self) |
81 self.__parseTimer.setSingleShot(True) |
83 self.__parseTimer.setSingleShot(True) |
82 self.__parseTimer.setInterval(5 * 1000) |
84 self.__parseTimer.setInterval(5 * 1000) |
83 self.__editor.textChanged.connect(self.__resetParseTimer) |
85 self.__editor.textChanged.connect(self.__resetParseTimer) |
84 self.__editor.refreshed.connect(self.__resetParseTimer) |
86 self.__editor.refreshed.connect(self.__resetParseTimer) |
85 |
87 |
86 self.__selectedGlobal = "" |
88 self.__selectedGlobal = "" |
87 self.__selectedMember = "" |
89 self.__selectedMember = "" |
88 self.__globalsBoundaries = {} |
90 self.__globalsBoundaries = {} |
89 self.__membersBoundaries = {} |
91 self.__membersBoundaries = {} |
90 |
92 |
91 self.__activateOutline(self.__showOutline) |
93 self.__activateOutline(self.__showOutline) |
92 self.__activateCombos(not self.__showOutline) |
94 self.__activateCombos(not self.__showOutline) |
93 |
95 |
94 ericApp().getObject("UserInterface").preferencesChanged.connect( |
96 ericApp().getObject("UserInterface").preferencesChanged.connect( |
95 self.__preferencesChanged) |
97 self.__preferencesChanged |
96 |
98 ) |
|
99 |
97 def shutdownTimer(self): |
100 def shutdownTimer(self): |
98 """ |
101 """ |
99 Public method to stop and disconnect the timer. |
102 Public method to stop and disconnect the timer. |
100 """ |
103 """ |
101 self.__parseTimer.stop() |
104 self.__parseTimer.stop() |
102 if not self.__shutdownTimerCalled: |
105 if not self.__shutdownTimerCalled: |
103 self.__editor.textChanged.disconnect(self.__resetParseTimer) |
106 self.__editor.textChanged.disconnect(self.__resetParseTimer) |
104 self.__editor.refreshed.disconnect(self.__resetParseTimer) |
107 self.__editor.refreshed.disconnect(self.__resetParseTimer) |
105 self.__shutdownTimerCalled = True |
108 self.__shutdownTimerCalled = True |
106 |
109 |
107 def getEditor(self): |
110 def getEditor(self): |
108 """ |
111 """ |
109 Public method to get the reference to the editor widget. |
112 Public method to get the reference to the editor widget. |
110 |
113 |
111 @return reference to the editor widget |
114 @return reference to the editor widget |
112 @rtype Editor |
115 @rtype Editor |
113 """ |
116 """ |
114 return self.__editor |
117 return self.__editor |
115 |
118 |
116 def __preferencesChanged(self): |
119 def __preferencesChanged(self): |
117 """ |
120 """ |
118 Private slot handling a change of preferences. |
121 Private slot handling a change of preferences. |
119 """ |
122 """ |
120 showOutline = Preferences.getEditor("ShowSourceOutline") |
123 showOutline = Preferences.getEditor("ShowSourceOutline") |
121 if showOutline != self.__showOutline: |
124 if showOutline != self.__showOutline: |
122 self.__showOutline = showOutline |
125 self.__showOutline = showOutline |
123 self.__activateOutline(self.__showOutline) |
126 self.__activateOutline(self.__showOutline) |
124 self.__activateCombos(not self.__showOutline) |
127 self.__activateCombos(not self.__showOutline) |
125 |
128 |
126 ####################################################################### |
129 ####################################################################### |
127 ## Methods dealing with the navigation combos below |
130 ## Methods dealing with the navigation combos below |
128 ####################################################################### |
131 ####################################################################### |
129 |
132 |
130 def __activateCombos(self, activate): |
133 def __activateCombos(self, activate): |
131 """ |
134 """ |
132 Private slot to activate the navigation combo boxes. |
135 Private slot to activate the navigation combo boxes. |
133 |
136 |
134 @param activate flag indicating to activate the combo boxes |
137 @param activate flag indicating to activate the combo boxes |
135 @type bool |
138 @type bool |
136 """ |
139 """ |
137 self.__globalsCombo.setVisible(activate) |
140 self.__globalsCombo.setVisible(activate) |
138 self.__membersCombo.setVisible(activate) |
141 self.__membersCombo.setVisible(activate) |
139 if activate: |
142 if activate: |
140 self.__globalsCombo.activated[int].connect( |
143 self.__globalsCombo.activated[int].connect(self.__globalsActivated) |
141 self.__globalsActivated) |
144 self.__membersCombo.activated[int].connect(self.__membersActivated) |
142 self.__membersCombo.activated[int].connect( |
145 self.__editor.cursorLineChanged.connect(self.__editorCursorLineChanged) |
143 self.__membersActivated) |
|
144 self.__editor.cursorLineChanged.connect( |
|
145 self.__editorCursorLineChanged) |
|
146 self.__parseTimer.timeout.connect(self.__parseEditor) |
146 self.__parseTimer.timeout.connect(self.__parseEditor) |
147 |
147 |
148 self.__parseEditor() |
148 self.__parseEditor() |
149 |
149 |
150 line, _ = self.__editor.getCursorPosition() |
150 line, _ = self.__editor.getCursorPosition() |
151 self.__editorCursorLineChanged(line) |
151 self.__editorCursorLineChanged(line) |
152 else: |
152 else: |
153 with contextlib.suppress(TypeError): |
153 with contextlib.suppress(TypeError): |
154 self.__globalsCombo.activated[int].disconnect( |
154 self.__globalsCombo.activated[int].disconnect(self.__globalsActivated) |
155 self.__globalsActivated) |
155 self.__membersCombo.activated[int].disconnect(self.__membersActivated) |
156 self.__membersCombo.activated[int].disconnect( |
|
157 self.__membersActivated) |
|
158 self.__editor.cursorLineChanged.disconnect( |
156 self.__editor.cursorLineChanged.disconnect( |
159 self.__editorCursorLineChanged) |
157 self.__editorCursorLineChanged |
|
158 ) |
160 self.__parseTimer.timeout.disconnect(self.__parseEditor) |
159 self.__parseTimer.timeout.disconnect(self.__parseEditor) |
161 |
160 |
162 self.__globalsCombo.clear() |
161 self.__globalsCombo.clear() |
163 self.__membersCombo.clear() |
162 self.__membersCombo.clear() |
164 self.__globalsBoundaries = {} |
163 self.__globalsBoundaries = {} |
165 self.__membersBoundaries = {} |
164 self.__membersBoundaries = {} |
166 |
165 |
167 def __globalsActivated(self, index, moveCursor=True): |
166 def __globalsActivated(self, index, moveCursor=True): |
168 """ |
167 """ |
169 Private method to jump to the line of the selected global entry and to |
168 Private method to jump to the line of the selected global entry and to |
170 populate the members combo box. |
169 populate the members combo box. |
171 |
170 |
172 @param index index of the selected entry |
171 @param index index of the selected entry |
173 @type int |
172 @type int |
174 @param moveCursor flag indicating to move the editor cursor |
173 @param moveCursor flag indicating to move the editor cursor |
175 @type bool |
174 @type bool |
176 """ |
175 """ |
227 icon = UI.PixmapCache.getIcon("method_private") |
223 icon = UI.PixmapCache.getIcon("method_private") |
228 elif meth.isProtected(): |
224 elif meth.isProtected(): |
229 icon = UI.PixmapCache.getIcon("method_protected") |
225 icon = UI.PixmapCache.getIcon("method_protected") |
230 else: |
226 else: |
231 icon = UI.PixmapCache.getIcon("method") |
227 icon = UI.PixmapCache.getIcon("method") |
232 items.append( |
228 items.append((icon, meth.name, meth.lineno, meth.endlineno)) |
233 (icon, meth.name, meth.lineno, meth.endlineno) |
|
234 ) |
|
235 for itm in sorted(items, key=lambda x: (x[1], x[2])): |
229 for itm in sorted(items, key=lambda x: (x[1], x[2])): |
236 self.__membersCombo.addItem(itm[0], itm[1], itm[2]) |
230 self.__membersCombo.addItem(itm[0], itm[1], itm[2]) |
237 memberIndex += 1 |
231 memberIndex += 1 |
238 self.__membersBoundaries[(itm[2], itm[3])] = memberIndex |
232 self.__membersBoundaries[(itm[2], itm[3])] = memberIndex |
239 |
233 |
240 # step 2.2: add class instance attributes |
234 # step 2.2: add class instance attributes |
241 items = [] |
235 items = [] |
242 for attr in entry.attributes.values(): |
236 for attr in entry.attributes.values(): |
243 if attr.isPrivate(): |
237 if attr.isPrivate(): |
244 icon = UI.PixmapCache.getIcon("attribute_private") |
238 icon = UI.PixmapCache.getIcon("attribute_private") |
245 elif attr.isProtected(): |
239 elif attr.isProtected(): |
246 icon = UI.PixmapCache.getIcon( |
240 icon = UI.PixmapCache.getIcon("attribute_protected") |
247 "attribute_protected") |
|
248 else: |
241 else: |
249 icon = UI.PixmapCache.getIcon("attribute") |
242 icon = UI.PixmapCache.getIcon("attribute") |
250 items.append((icon, attr.name, attr.lineno)) |
243 items.append((icon, attr.name, attr.lineno)) |
251 for itm in sorted(items, key=lambda x: (x[1], x[2])): |
244 for itm in sorted(items, key=lambda x: (x[1], x[2])): |
252 self.__membersCombo.addItem(itm[0], itm[1], itm[2]) |
245 self.__membersCombo.addItem(itm[0], itm[1], itm[2]) |
253 |
246 |
254 # step 2.3: add class attributes |
247 # step 2.3: add class attributes |
255 items = [] |
248 items = [] |
256 icon = UI.PixmapCache.getIcon("attribute_class") |
249 icon = UI.PixmapCache.getIcon("attribute_class") |
257 for globalVar in entry.globals.values(): |
250 for globalVar in entry.globals.values(): |
258 items.append((icon, globalVar.name, globalVar.lineno)) |
251 items.append((icon, globalVar.name, globalVar.lineno)) |
259 for itm in sorted(items, key=lambda x: (x[1], x[2])): |
252 for itm in sorted(items, key=lambda x: (x[1], x[2])): |
260 self.__membersCombo.addItem(itm[0], itm[1], itm[2]) |
253 self.__membersCombo.addItem(itm[0], itm[1], itm[2]) |
261 |
254 |
262 def __membersActivated(self, index, moveCursor=True): |
255 def __membersActivated(self, index, moveCursor=True): |
263 """ |
256 """ |
264 Private method to jump to the line of the selected members entry. |
257 Private method to jump to the line of the selected members entry. |
265 |
258 |
266 @param index index of the selected entry |
259 @param index index of the selected entry |
267 @type int |
260 @type int |
268 @param moveCursor flag indicating to move the editor cursor |
261 @param moveCursor flag indicating to move the editor cursor |
269 @type bool |
262 @type bool |
270 """ |
263 """ |
271 lineno = self.__membersCombo.itemData(index) |
264 lineno = self.__membersCombo.itemData(index) |
272 if lineno is not None and moveCursor: |
265 if lineno is not None and moveCursor: |
273 txt = self.__editor.text(lineno - 1).rstrip() |
266 txt = self.__editor.text(lineno - 1).rstrip() |
274 pos = len(txt.replace(txt.strip(), "")) |
267 pos = len(txt.replace(txt.strip(), "")) |
275 self.__editor.gotoLine(lineno, pos if pos == 0 else pos + 1, |
268 self.__editor.gotoLine( |
276 firstVisible=True, expand=True) |
269 lineno, pos if pos == 0 else pos + 1, firstVisible=True, expand=True |
|
270 ) |
277 self.__editor.setFocus() |
271 self.__editor.setFocus() |
278 |
272 |
279 def __resetParseTimer(self): |
273 def __resetParseTimer(self): |
280 """ |
274 """ |
281 Private slot to reset the parse timer. |
275 Private slot to reset the parse timer. |
282 """ |
276 """ |
283 self.__parseTimer.stop() |
277 self.__parseTimer.stop() |
284 self.__parseTimer.start() |
278 self.__parseTimer.start() |
285 |
279 |
286 def __parseEditor(self): |
280 def __parseEditor(self): |
287 """ |
281 """ |
288 Private method to parse the editor source and repopulate the globals |
282 Private method to parse the editor source and repopulate the globals |
289 combo. |
283 combo. |
290 """ |
284 """ |
291 from Utilities.ModuleParser import Module, getTypeFromTypeName |
285 from Utilities.ModuleParser import Module, getTypeFromTypeName |
292 |
286 |
293 self.__module = None |
287 self.__module = None |
294 sourceType = getTypeFromTypeName(self.__editor.determineFileType()) |
288 sourceType = getTypeFromTypeName(self.__editor.determineFileType()) |
295 if sourceType != -1: |
289 if sourceType != -1: |
296 src = self.__editor.text() |
290 src = self.__editor.text() |
297 if src: |
291 if src: |
298 fn = self.__editor.getFileName() |
292 fn = self.__editor.getFileName() |
299 if fn is None: |
293 if fn is None: |
300 fn = "" |
294 fn = "" |
301 self.__module = Module("", fn, sourceType) |
295 self.__module = Module("", fn, sourceType) |
302 self.__module.scan(src) |
296 self.__module.scan(src) |
303 |
297 |
304 # remember the current selections |
298 # remember the current selections |
305 self.__selectedGlobal = self.__globalsCombo.currentText() |
299 self.__selectedGlobal = self.__globalsCombo.currentText() |
306 self.__selectedMember = self.__membersCombo.currentText() |
300 self.__selectedMember = self.__membersCombo.currentText() |
307 |
301 |
308 self.__globalsCombo.clear() |
302 self.__globalsCombo.clear() |
309 self.__membersCombo.clear() |
303 self.__membersCombo.clear() |
310 self.__globalsBoundaries = {} |
304 self.__globalsBoundaries = {} |
311 self.__membersBoundaries = {} |
305 self.__membersBoundaries = {} |
312 |
306 |
313 self.__globalsCombo.addItem("") |
307 self.__globalsCombo.addItem("") |
314 index = 0 |
308 index = 0 |
315 |
309 |
316 # step 1: add modules |
310 # step 1: add modules |
317 items = [] |
311 items = [] |
318 for module in self.__module.modules.values(): |
312 for module in self.__module.modules.values(): |
319 items.append( |
313 items.append( |
320 (UI.PixmapCache.getIcon("module"), module.name, |
314 ( |
321 module.lineno, module.endlineno) |
315 UI.PixmapCache.getIcon("module"), |
|
316 module.name, |
|
317 module.lineno, |
|
318 module.endlineno, |
|
319 ) |
322 ) |
320 ) |
323 for itm in sorted(items, key=lambda x: (x[1], x[2])): |
321 for itm in sorted(items, key=lambda x: (x[1], x[2])): |
324 self.__globalsCombo.addItem(itm[0], itm[1], itm[2]) |
322 self.__globalsCombo.addItem(itm[0], itm[1], itm[2]) |
325 index += 1 |
323 index += 1 |
326 self.__globalsBoundaries[(itm[2], itm[3])] = index |
324 self.__globalsBoundaries[(itm[2], itm[3])] = index |
327 |
325 |
328 # step 2: add classes |
326 # step 2: add classes |
329 items = [] |
327 items = [] |
330 for cl in self.__module.classes.values(): |
328 for cl in self.__module.classes.values(): |
331 if cl.isPrivate(): |
329 if cl.isPrivate(): |
332 icon = UI.PixmapCache.getIcon("class_private") |
330 icon = UI.PixmapCache.getIcon("class_private") |
333 elif cl.isProtected(): |
331 elif cl.isProtected(): |
334 icon = UI.PixmapCache.getIcon("class_protected") |
332 icon = UI.PixmapCache.getIcon("class_protected") |
335 else: |
333 else: |
336 icon = UI.PixmapCache.getIcon("class") |
334 icon = UI.PixmapCache.getIcon("class") |
337 items.append( |
335 items.append((icon, cl.name, cl.lineno, cl.endlineno)) |
338 (icon, cl.name, cl.lineno, cl.endlineno) |
|
339 ) |
|
340 for itm in sorted(items, key=lambda x: (x[1], x[2])): |
336 for itm in sorted(items, key=lambda x: (x[1], x[2])): |
341 self.__globalsCombo.addItem(itm[0], itm[1], itm[2]) |
337 self.__globalsCombo.addItem(itm[0], itm[1], itm[2]) |
342 index += 1 |
338 index += 1 |
343 self.__globalsBoundaries[(itm[2], itm[3])] = index |
339 self.__globalsBoundaries[(itm[2], itm[3])] = index |
344 |
340 |
345 # step 3: add functions |
341 # step 3: add functions |
346 items = [] |
342 items = [] |
347 for func in self.__module.functions.values(): |
343 for func in self.__module.functions.values(): |
348 if func.isPrivate(): |
344 if func.isPrivate(): |
349 icon = UI.PixmapCache.getIcon("method_private") |
345 icon = UI.PixmapCache.getIcon("method_private") |
350 elif func.isProtected(): |
346 elif func.isProtected(): |
351 icon = UI.PixmapCache.getIcon("method_protected") |
347 icon = UI.PixmapCache.getIcon("method_protected") |
352 else: |
348 else: |
353 icon = UI.PixmapCache.getIcon("method") |
349 icon = UI.PixmapCache.getIcon("method") |
354 items.append( |
350 items.append((icon, func.name, func.lineno, func.endlineno)) |
355 (icon, func.name, func.lineno, func.endlineno) |
|
356 ) |
|
357 for itm in sorted(items, key=lambda x: (x[1], x[2])): |
351 for itm in sorted(items, key=lambda x: (x[1], x[2])): |
358 self.__globalsCombo.addItem(itm[0], itm[1], itm[2]) |
352 self.__globalsCombo.addItem(itm[0], itm[1], itm[2]) |
359 index += 1 |
353 index += 1 |
360 self.__globalsBoundaries[(itm[2], itm[3])] = index |
354 self.__globalsBoundaries[(itm[2], itm[3])] = index |
361 |
355 |
362 # step 4: add attributes |
356 # step 4: add attributes |
363 items = [] |
357 items = [] |
364 for globalValue in self.__module.globals.values(): |
358 for globalValue in self.__module.globals.values(): |
365 if globalValue.isPrivate(): |
359 if globalValue.isPrivate(): |
366 icon = UI.PixmapCache.getIcon("attribute_private") |
360 icon = UI.PixmapCache.getIcon("attribute_private") |
367 elif globalValue.isProtected(): |
361 elif globalValue.isProtected(): |
368 icon = UI.PixmapCache.getIcon( |
362 icon = UI.PixmapCache.getIcon("attribute_protected") |
369 "attribute_protected") |
|
370 else: |
363 else: |
371 icon = UI.PixmapCache.getIcon("attribute") |
364 icon = UI.PixmapCache.getIcon("attribute") |
372 items.append( |
365 items.append((icon, globalValue.name, globalValue.lineno)) |
373 (icon, globalValue.name, globalValue.lineno) |
|
374 ) |
|
375 for itm in sorted(items, key=lambda x: (x[1], x[2])): |
366 for itm in sorted(items, key=lambda x: (x[1], x[2])): |
376 self.__globalsCombo.addItem(itm[0], itm[1], itm[2]) |
367 self.__globalsCombo.addItem(itm[0], itm[1], itm[2]) |
377 |
368 |
378 # reset the currently selected entries without moving the |
369 # reset the currently selected entries without moving the |
379 # text cursor |
370 # text cursor |
380 index = self.__globalsCombo.findText(self.__selectedGlobal) |
371 index = self.__globalsCombo.findText(self.__selectedGlobal) |
381 if index != -1: |
372 if index != -1: |
382 self.__globalsCombo.setCurrentIndex(index) |
373 self.__globalsCombo.setCurrentIndex(index) |
388 else: |
379 else: |
389 self.__globalsCombo.clear() |
380 self.__globalsCombo.clear() |
390 self.__membersCombo.clear() |
381 self.__membersCombo.clear() |
391 self.__globalsBoundaries = {} |
382 self.__globalsBoundaries = {} |
392 self.__membersBoundaries = {} |
383 self.__membersBoundaries = {} |
393 |
384 |
394 def __editorCursorLineChanged(self, lineno): |
385 def __editorCursorLineChanged(self, lineno): |
395 """ |
386 """ |
396 Private slot handling a line change of the cursor of the editor. |
387 Private slot handling a line change of the cursor of the editor. |
397 |
388 |
398 @param lineno line number of the cursor |
389 @param lineno line number of the cursor |
399 @type int |
390 @type int |
400 """ |
391 """ |
401 lineno += 1 # cursor position is zero based, code info one based |
392 lineno += 1 # cursor position is zero based, code info one based |
402 |
393 |
403 # step 1: search in the globals |
394 # step 1: search in the globals |
404 indexFound = 0 |
395 indexFound = 0 |
405 for (lower, upper), index in self.__globalsBoundaries.items(): |
396 for (lower, upper), index in self.__globalsBoundaries.items(): |
406 if upper == -1: |
397 if upper == -1: |
407 upper = 1000000 # it is the last line |
398 upper = 1000000 # it is the last line |
408 if lower <= lineno <= upper: |
399 if lower <= lineno <= upper: |
409 indexFound = index |
400 indexFound = index |
410 break |
401 break |
411 self.__globalsCombo.setCurrentIndex(indexFound) |
402 self.__globalsCombo.setCurrentIndex(indexFound) |
412 self.__globalsActivated(indexFound, moveCursor=False) |
403 self.__globalsActivated(indexFound, moveCursor=False) |
413 |
404 |
414 # step 2: search in members |
405 # step 2: search in members |
415 indexFound = 0 |
406 indexFound = 0 |
416 for (lower, upper), index in self.__membersBoundaries.items(): |
407 for (lower, upper), index in self.__membersBoundaries.items(): |
417 if upper == -1: |
408 if upper == -1: |
418 upper = 1000000 # it is the last line |
409 upper = 1000000 # it is the last line |
419 if lower <= lineno <= upper: |
410 if lower <= lineno <= upper: |
420 indexFound = index |
411 indexFound = index |
421 break |
412 break |
422 self.__membersCombo.setCurrentIndex(indexFound) |
413 self.__membersCombo.setCurrentIndex(indexFound) |
423 self.__membersActivated(indexFound, moveCursor=False) |
414 self.__membersActivated(indexFound, moveCursor=False) |
424 |
415 |
425 ####################################################################### |
416 ####################################################################### |
426 ## Methods dealing with the source outline below |
417 ## Methods dealing with the source outline below |
427 ####################################################################### |
418 ####################################################################### |
428 |
419 |
429 def __activateOutline(self, activate): |
420 def __activateOutline(self, activate): |
430 """ |
421 """ |
431 Private slot to activate the source outline view. |
422 Private slot to activate the source outline view. |
432 |
423 |
433 @param activate flag indicating to activate the source outline view |
424 @param activate flag indicating to activate the source outline view |
434 @type bool |
425 @type bool |
435 """ |
426 """ |
436 self.__sourceOutline.setActive(activate) |
427 self.__sourceOutline.setActive(activate) |
437 |
428 |
438 if activate: |
429 if activate: |
439 self.__sourceOutline.setVisible( |
430 self.__sourceOutline.setVisible( |
440 self.__sourceOutline.isSupportedLanguage( |
431 self.__sourceOutline.isSupportedLanguage(self.__editor.getLanguage()) |
441 self.__editor.getLanguage() |
|
442 ) |
|
443 ) |
432 ) |
444 |
433 |
445 self.__parseTimer.timeout.connect(self.__sourceOutline.repopulate) |
434 self.__parseTimer.timeout.connect(self.__sourceOutline.repopulate) |
446 self.__editor.languageChanged.connect(self.__editorChanged) |
435 self.__editor.languageChanged.connect(self.__editorChanged) |
447 self.__editor.editorRenamed.connect(self.__editorChanged) |
436 self.__editor.editorRenamed.connect(self.__editorChanged) |
448 else: |
437 else: |
449 self.__sourceOutline.hide() |
438 self.__sourceOutline.hide() |
450 |
439 |
451 with contextlib.suppress(TypeError): |
440 with contextlib.suppress(TypeError): |
452 self.__parseTimer.timeout.disconnect( |
441 self.__parseTimer.timeout.disconnect(self.__sourceOutline.repopulate) |
453 self.__sourceOutline.repopulate) |
|
454 self.__editor.languageChanged.disconnect(self.__editorChanged) |
442 self.__editor.languageChanged.disconnect(self.__editorChanged) |
455 self.__editor.editorRenamed.disconnect(self.__editorChanged) |
443 self.__editor.editorRenamed.disconnect(self.__editorChanged) |
456 |
444 |
457 def __editorChanged(self): |
445 def __editorChanged(self): |
458 """ |
446 """ |
459 Private slot handling changes of the editor language or file name. |
447 Private slot handling changes of the editor language or file name. |
460 """ |
448 """ |
461 supported = self.__sourceOutline.isSupportedLanguage( |
449 supported = self.__sourceOutline.isSupportedLanguage( |
462 self.__editor.getLanguage()) |
450 self.__editor.getLanguage() |
463 |
451 ) |
|
452 |
464 self.__sourceOutline.setVisible(supported) |
453 self.__sourceOutline.setVisible(supported) |
|
454 |
465 |
455 |
466 # |
456 # |
467 # eflag: noqa = Y113 |
457 # eflag: noqa = Y113 |