eric6/QScintilla/EditorAssembly.py

changeset 8088
7c454b82b6ed
parent 7923
91e843545d9a
child 8089
e43bf8d7baf9
equal deleted inserted replaced
8087:db518728761c 8088:7c454b82b6ed
54 self.__showOutline = Preferences.getEditor("ShowSourceOutline") 54 self.__showOutline = Preferences.getEditor("ShowSourceOutline")
55 55
56 self.__editor = Editor(dbs, fn, vm, filetype, editor, tv) 56 self.__editor = Editor(dbs, fn, vm, filetype, editor, tv)
57 self.__buttonsWidget = EditorButtonsWidget(self.__editor, self) 57 self.__buttonsWidget = EditorButtonsWidget(self.__editor, self)
58 self.__globalsCombo = QComboBox() 58 self.__globalsCombo = QComboBox()
59 self.__globalsCombo.setDuplicatesEnabled(True)
59 self.__membersCombo = QComboBox() 60 self.__membersCombo = QComboBox()
61 self.__membersCombo.setDuplicatesEnabled(True)
60 self.__sourceOutline = EditorOutlineView( 62 self.__sourceOutline = EditorOutlineView(
61 self.__editor, populate=self.__showOutline) 63 self.__editor, populate=self.__showOutline)
62 self.__sourceOutline.setMaximumWidth( 64 self.__sourceOutline.setMaximumWidth(
63 Preferences.getEditor("SourceOutlineWidth")) 65 Preferences.getEditor("SourceOutlineWidth"))
64 66
215 else: 217 else:
216 return 218 return
217 219
218 # step 2.1: add class methods 220 # step 2.1: add class methods
219 from Utilities.ModuleParser import Function 221 from Utilities.ModuleParser import Function
220 items = {} 222 items = []
221 for meth in entry.methods.values(): 223 for meth in entry.methods.values():
222 if meth.modifier == Function.Static: 224 if meth.modifier == Function.Static:
223 icon = UI.PixmapCache.getIcon("method_static") 225 icon = UI.PixmapCache.getIcon("method_static")
224 elif meth.modifier == Function.Class: 226 elif meth.modifier == Function.Class:
225 icon = UI.PixmapCache.getIcon("method_class") 227 icon = UI.PixmapCache.getIcon("method_class")
227 icon = UI.PixmapCache.getIcon("method_private") 229 icon = UI.PixmapCache.getIcon("method_private")
228 elif meth.isProtected(): 230 elif meth.isProtected():
229 icon = UI.PixmapCache.getIcon("method_protected") 231 icon = UI.PixmapCache.getIcon("method_protected")
230 else: 232 else:
231 icon = UI.PixmapCache.getIcon("method") 233 icon = UI.PixmapCache.getIcon("method")
232 items[meth.name] = (icon, meth.lineno, meth.endlineno) 234 items.append(
233 for key in sorted(items.keys()): 235 (icon, meth.name, meth.lineno, meth.endlineno)
234 itm = items[key] 236 )
235 self.__membersCombo.addItem(itm[0], key, itm[1]) 237 for itm in sorted(items, key=lambda x: (x[1], x[2])):
238 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
236 memberIndex += 1 239 memberIndex += 1
237 self.__membersBoundaries[(itm[1], itm[2])] = memberIndex 240 self.__membersBoundaries[(itm[2], itm[3])] = memberIndex
238 241
239 # step 2.2: add class instance attributes 242 # step 2.2: add class instance attributes
240 items = {} 243 items = []
241 for attr in entry.attributes.values(): 244 for attr in entry.attributes.values():
242 if attr.isPrivate(): 245 if attr.isPrivate():
243 icon = UI.PixmapCache.getIcon("attribute_private") 246 icon = UI.PixmapCache.getIcon("attribute_private")
244 elif attr.isProtected(): 247 elif attr.isProtected():
245 icon = UI.PixmapCache.getIcon( 248 icon = UI.PixmapCache.getIcon(
246 "attribute_protected") 249 "attribute_protected")
247 else: 250 else:
248 icon = UI.PixmapCache.getIcon("attribute") 251 icon = UI.PixmapCache.getIcon("attribute")
249 items[attr.name] = (icon, attr.lineno) 252 items.append((icon, attr.name, attr.lineno))
250 for key in sorted(items.keys()): 253 for itm in sorted(items, key=lambda x: (x[1], x[2])):
251 itm = items[key] 254 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
252 self.__membersCombo.addItem(itm[0], key, itm[1])
253 255
254 # step 2.3: add class attributes 256 # step 2.3: add class attributes
255 items = {} 257 items = []
256 icon = UI.PixmapCache.getIcon("attribute_class") 258 icon = UI.PixmapCache.getIcon("attribute_class")
257 for glob in entry.globals.values(): 259 for globalVar in entry.globals.values():
258 items[glob.name] = (icon, glob.lineno) 260 items.append((icon, globalVar.nameglobalVar.lineno))
259 for key in sorted(items.keys()): 261 for itm in sorted(items, key=lambda x: (x[1], x[2])):
260 itm = items[key] 262 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
261 self.__membersCombo.addItem(itm[0], key, itm[1])
262 263
263 def __membersActivated(self, index, moveCursor=True): 264 def __membersActivated(self, index, moveCursor=True):
264 """ 265 """
265 Private method to jump to the line of the selected members entry. 266 Private method to jump to the line of the selected members entry.
266 267
313 314
314 self.__globalsCombo.addItem("") 315 self.__globalsCombo.addItem("")
315 index = 0 316 index = 0
316 317
317 # step 1: add modules 318 # step 1: add modules
318 items = {} 319 items = []
319 for module in self.__module.modules.values(): 320 for module in self.__module.modules.values():
320 items[module.name] = (UI.PixmapCache.getIcon("module"), 321 items.append(
321 module.lineno, module.endlineno) 322 (UI.PixmapCache.getIcon("module"), module.name,
322 for key in sorted(items.keys()): 323 module.lineno, module.endlineno)
323 itm = items[key] 324 )
324 self.__globalsCombo.addItem(itm[0], key, itm[1]) 325 for itm in sorted(items, key=lambda x: (x[1], x[2])):
326 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
325 index += 1 327 index += 1
326 self.__globalsBoundaries[(itm[1], itm[2])] = index 328 self.__globalsBoundaries[(itm[2], itm[3])] = index
327 329
328 # step 2: add classes 330 # step 2: add classes
329 items = {} 331 items = []
330 for cl in self.__module.classes.values(): 332 for cl in self.__module.classes.values():
331 if cl.isPrivate(): 333 if cl.isPrivate():
332 icon = UI.PixmapCache.getIcon("class_private") 334 icon = UI.PixmapCache.getIcon("class_private")
333 elif cl.isProtected(): 335 elif cl.isProtected():
334 icon = UI.PixmapCache.getIcon("class_protected") 336 icon = UI.PixmapCache.getIcon("class_protected")
335 else: 337 else:
336 icon = UI.PixmapCache.getIcon("class") 338 icon = UI.PixmapCache.getIcon("class")
337 items[cl.name] = (icon, cl.lineno, cl.endlineno) 339 items.append(
338 for key in sorted(items.keys()): 340 (icon, cl.name, cl.lineno, cl.endlineno)
339 itm = items[key] 341 )
340 self.__globalsCombo.addItem(itm[0], key, itm[1]) 342 for itm in sorted(items, key=lambda x: (x[1], x[2])):
343 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
341 index += 1 344 index += 1
342 self.__globalsBoundaries[(itm[1], itm[2])] = index 345 self.__globalsBoundaries[(itm[2], itm[3])] = index
343 346
344 # step 3: add functions 347 # step 3: add functions
345 items = {} 348 items = []
346 for func in self.__module.functions.values(): 349 for func in self.__module.functions.values():
347 if func.isPrivate(): 350 if func.isPrivate():
348 icon = UI.PixmapCache.getIcon("method_private") 351 icon = UI.PixmapCache.getIcon("method_private")
349 elif func.isProtected(): 352 elif func.isProtected():
350 icon = UI.PixmapCache.getIcon("method_protected") 353 icon = UI.PixmapCache.getIcon("method_protected")
351 else: 354 else:
352 icon = UI.PixmapCache.getIcon("method") 355 icon = UI.PixmapCache.getIcon("method")
353 items[func.name] = (icon, func.lineno, func.endlineno) 356 items.append(
354 for key in sorted(items.keys()): 357 (icon, func.name, func.lineno, func.endlineno)
355 itm = items[key] 358 )
356 self.__globalsCombo.addItem(itm[0], key, itm[1]) 359 for itm in sorted(items, key=lambda x: (x[1], x[2])):
360 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
357 index += 1 361 index += 1
358 self.__globalsBoundaries[(itm[1], itm[2])] = index 362 self.__globalsBoundaries[(itm[2], itm[3])] = index
359 363
360 # step 4: add attributes 364 # step 4: add attributes
361 items = {} 365 items = []
362 for glob in self.__module.globals.values(): 366 for globalValue in self.__module.globals.values():
363 if glob.isPrivate(): 367 if globalValue.isPrivate():
364 icon = UI.PixmapCache.getIcon("attribute_private") 368 icon = UI.PixmapCache.getIcon("attribute_private")
365 elif glob.isProtected(): 369 elif globalValue.isProtected():
366 icon = UI.PixmapCache.getIcon( 370 icon = UI.PixmapCache.getIcon(
367 "attribute_protected") 371 "attribute_protected")
368 else: 372 else:
369 icon = UI.PixmapCache.getIcon("attribute") 373 icon = UI.PixmapCache.getIcon("attribute")
370 items[glob.name] = (icon, glob.lineno) 374 items.append(
371 for key in sorted(items.keys()): 375 (icon, globalValue.nameglobalValue.lineno)
372 itm = items[key] 376 )
373 self.__globalsCombo.addItem(itm[0], key, itm[1]) 377 for itm in sorted(items, key=lambda x: (x[1], x[2])):
378 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
374 379
375 # reset the currently selected entries without moving the 380 # reset the currently selected entries without moving the
376 # text cursor 381 # text cursor
377 index = self.__globalsCombo.findText(self.__selectedGlobal) 382 index = self.__globalsCombo.findText(self.__selectedGlobal)
378 if index != -1: 383 if index != -1:

eric ide

mercurial