eric6/QScintilla/EditorAssembly.py

changeset 8088
7c454b82b6ed
parent 7923
91e843545d9a
child 8089
e43bf8d7baf9
diff -r db518728761c -r 7c454b82b6ed eric6/QScintilla/EditorAssembly.py
--- a/eric6/QScintilla/EditorAssembly.py	Tue Feb 09 08:33:41 2021 +0100
+++ b/eric6/QScintilla/EditorAssembly.py	Tue Feb 09 08:34:39 2021 +0100
@@ -56,7 +56,9 @@
         self.__editor = Editor(dbs, fn, vm, filetype, editor, tv)
         self.__buttonsWidget = EditorButtonsWidget(self.__editor, self)
         self.__globalsCombo = QComboBox()
+        self.__globalsCombo.setDuplicatesEnabled(True)
         self.__membersCombo = QComboBox()
+        self.__membersCombo.setDuplicatesEnabled(True)
         self.__sourceOutline = EditorOutlineView(
             self.__editor, populate=self.__showOutline)
         self.__sourceOutline.setMaximumWidth(
@@ -217,7 +219,7 @@
                 
                 # step 2.1: add class methods
                 from Utilities.ModuleParser import Function
-                items = {}
+                items = []
                 for meth in entry.methods.values():
                     if meth.modifier == Function.Static:
                         icon = UI.PixmapCache.getIcon("method_static")
@@ -229,15 +231,16 @@
                         icon = UI.PixmapCache.getIcon("method_protected")
                     else:
                         icon = UI.PixmapCache.getIcon("method")
-                    items[meth.name] = (icon, meth.lineno, meth.endlineno)
-                for key in sorted(items.keys()):
-                    itm = items[key]
-                    self.__membersCombo.addItem(itm[0], key, itm[1])
+                    items.append(
+                        (icon, meth.name, meth.lineno, meth.endlineno)
+                    )
+                for itm in sorted(items, key=lambda x: (x[1], x[2])):
+                    self.__membersCombo.addItem(itm[0], itm[1], itm[2])
                     memberIndex += 1
-                    self.__membersBoundaries[(itm[1], itm[2])] = memberIndex
+                    self.__membersBoundaries[(itm[2], itm[3])] = memberIndex
                 
                 # step 2.2: add class instance attributes
-                items = {}
+                items = []
                 for attr in entry.attributes.values():
                     if attr.isPrivate():
                         icon = UI.PixmapCache.getIcon("attribute_private")
@@ -246,19 +249,17 @@
                             "attribute_protected")
                     else:
                         icon = UI.PixmapCache.getIcon("attribute")
-                    items[attr.name] = (icon, attr.lineno)
-                for key in sorted(items.keys()):
-                    itm = items[key]
-                    self.__membersCombo.addItem(itm[0], key, itm[1])
+                    items.append((icon, attr.name, attr.lineno))
+                for itm in sorted(items, key=lambda x: (x[1], x[2])):
+                    self.__membersCombo.addItem(itm[0], itm[1], itm[2])
                 
                 # step 2.3: add class attributes
-                items = {}
+                items = []
                 icon = UI.PixmapCache.getIcon("attribute_class")
-                for glob in entry.globals.values():
-                    items[glob.name] = (icon, glob.lineno)
-                for key in sorted(items.keys()):
-                    itm = items[key]
-                    self.__membersCombo.addItem(itm[0], key, itm[1])
+                for globalVar in entry.globals.values():
+                    items.append((icon, globalVar.nameglobalVar.lineno))
+                for itm in sorted(items, key=lambda x: (x[1], x[2])):
+                    self.__membersCombo.addItem(itm[0], itm[1], itm[2])
     
     def __membersActivated(self, index, moveCursor=True):
         """
@@ -315,18 +316,19 @@
                 index = 0
                 
                 # step 1: add modules
-                items = {}
+                items = []
                 for module in self.__module.modules.values():
-                    items[module.name] = (UI.PixmapCache.getIcon("module"),
-                                          module.lineno, module.endlineno)
-                for key in sorted(items.keys()):
-                    itm = items[key]
-                    self.__globalsCombo.addItem(itm[0], key, itm[1])
+                    items.append(
+                        (UI.PixmapCache.getIcon("module"), module.name,
+                         module.lineno, module.endlineno)
+                    )
+                for itm in sorted(items, key=lambda x: (x[1], x[2])):
+                    self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
                     index += 1
-                    self.__globalsBoundaries[(itm[1], itm[2])] = index
+                    self.__globalsBoundaries[(itm[2], itm[3])] = index
                 
                 # step 2: add classes
-                items = {}
+                items = []
                 for cl in self.__module.classes.values():
                     if cl.isPrivate():
                         icon = UI.PixmapCache.getIcon("class_private")
@@ -334,15 +336,16 @@
                         icon = UI.PixmapCache.getIcon("class_protected")
                     else:
                         icon = UI.PixmapCache.getIcon("class")
-                    items[cl.name] = (icon, cl.lineno, cl.endlineno)
-                for key in sorted(items.keys()):
-                    itm = items[key]
-                    self.__globalsCombo.addItem(itm[0], key, itm[1])
+                    items.append(
+                        (icon, cl.name, cl.lineno, cl.endlineno)
+                    )
+                for itm in sorted(items, key=lambda x: (x[1], x[2])):
+                    self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
                     index += 1
-                    self.__globalsBoundaries[(itm[1], itm[2])] = index
+                    self.__globalsBoundaries[(itm[2], itm[3])] = index
                 
                 # step 3: add functions
-                items = {}
+                items = []
                 for func in self.__module.functions.values():
                     if func.isPrivate():
                         icon = UI.PixmapCache.getIcon("method_private")
@@ -350,27 +353,29 @@
                         icon = UI.PixmapCache.getIcon("method_protected")
                     else:
                         icon = UI.PixmapCache.getIcon("method")
-                    items[func.name] = (icon, func.lineno, func.endlineno)
-                for key in sorted(items.keys()):
-                    itm = items[key]
-                    self.__globalsCombo.addItem(itm[0], key, itm[1])
+                    items.append(
+                        (icon, func.name, func.lineno, func.endlineno)
+                    )
+                for itm in sorted(items, key=lambda x: (x[1], x[2])):
+                    self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
                     index += 1
-                    self.__globalsBoundaries[(itm[1], itm[2])] = index
+                    self.__globalsBoundaries[(itm[2], itm[3])] = index
                 
                 # step 4: add attributes
-                items = {}
-                for glob in self.__module.globals.values():
-                    if glob.isPrivate():
+                items = []
+                for globalValue in self.__module.globals.values():
+                    if globalValue.isPrivate():
                         icon = UI.PixmapCache.getIcon("attribute_private")
-                    elif glob.isProtected():
+                    elif globalValue.isProtected():
                         icon = UI.PixmapCache.getIcon(
                             "attribute_protected")
                     else:
                         icon = UI.PixmapCache.getIcon("attribute")
-                    items[glob.name] = (icon, glob.lineno)
-                for key in sorted(items.keys()):
-                    itm = items[key]
-                    self.__globalsCombo.addItem(itm[0], key, itm[1])
+                    items.append(
+                        (icon, globalValue.nameglobalValue.lineno)
+                    )
+                for itm in sorted(items, key=lambda x: (x[1], x[2])):
+                    self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
                 
                 # reset the currently selected entries without moving the
                 # text cursor

eric ide

mercurial