85 |
85 |
86 @param index index of the selected entry (integer) |
86 @param index index of the selected entry (integer) |
87 """ |
87 """ |
88 # step 1: go to the line of the selected entry |
88 # step 1: go to the line of the selected entry |
89 lineno = self.__globalsCombo.itemData(index) |
89 lineno = self.__globalsCombo.itemData(index) |
90 txt = self.__editor.text(lineno - 1).rstrip() |
90 if lineno is not None: |
91 pos = len(txt.replace(txt.strip(), "")) |
91 txt = self.__editor.text(lineno - 1).rstrip() |
92 self.__editor.gotoLine(lineno, pos if pos == 0 else pos +1) |
92 pos = len(txt.replace(txt.strip(), "")) |
93 self.__editor.setFocus() |
93 self.__editor.gotoLine(lineno, pos if pos == 0 else pos +1) |
94 |
94 self.__editor.setFocus() |
95 # step 2: populate the members combo, if the entry is a class |
|
96 self.__membersCombo.clear() |
|
97 entryName = self.__globalsCombo.itemText(index) |
|
98 if self.__module and entryName in self.__module.classes: |
|
99 cl = self.__module.classes[entryName] |
|
100 |
95 |
101 # step 2.1: add class methods |
96 # step 2: populate the members combo, if the entry is a class |
102 items = [] |
97 self.__membersCombo.clear() |
103 for meth in cl.methods.values(): |
98 entryName = self.__globalsCombo.itemText(index) |
104 if meth.modifier == Function.Static: |
99 if self.__module and entryName in self.__module.classes: |
105 icon = UI.PixmapCache.getIcon("method_static.png") |
100 cl = self.__module.classes[entryName] |
106 elif meth.modifier == Function.Class: |
101 |
107 icon = UI.PixmapCache.getIcon("method_class.png") |
102 # step 2.1: add class methods |
108 elif meth.isPrivate(): |
103 items = [] |
109 icon = UI.PixmapCache.getIcon("method_private.png") |
104 for meth in cl.methods.values(): |
110 elif meth.isProtected(): |
105 if meth.modifier == Function.Static: |
111 icon = UI.PixmapCache.getIcon("method_protected.png") |
106 icon = UI.PixmapCache.getIcon("method_static.png") |
112 else: |
107 elif meth.modifier == Function.Class: |
113 icon = UI.PixmapCache.getIcon("method.png") |
108 icon = UI.PixmapCache.getIcon("method_class.png") |
114 items.append((meth.name, icon, meth.lineno)) |
109 elif meth.isPrivate(): |
115 for itm in sorted(items): |
110 icon = UI.PixmapCache.getIcon("method_private.png") |
116 self.__membersCombo.addItem(itm[1], itm[0], itm[2]) |
111 elif meth.isProtected(): |
117 |
112 icon = UI.PixmapCache.getIcon("method_protected.png") |
118 # step 2.2: add class instance attributes |
113 else: |
119 items = [] |
114 icon = UI.PixmapCache.getIcon("method.png") |
120 for attr in cl.attributes.values(): |
115 items.append((meth.name, icon, meth.lineno)) |
121 if attr.isPrivate(): |
116 for itm in sorted(items): |
122 icon = UI.PixmapCache.getIcon("attribute_private.png") |
117 self.__membersCombo.addItem(itm[1], itm[0], itm[2]) |
123 elif attr.isProtected(): |
118 |
124 icon = UI.PixmapCache.getIcon("attribute_protected.png") |
119 # step 2.2: add class instance attributes |
125 else: |
120 items = [] |
126 icon = UI.PixmapCache.getIcon("attribute.png") |
121 for attr in cl.attributes.values(): |
127 items.append((attr.name, icon, attr.lineno)) |
122 if attr.isPrivate(): |
128 for itm in sorted(items): |
123 icon = UI.PixmapCache.getIcon("attribute_private.png") |
129 self.__membersCombo.addItem(itm[1], itm[0], itm[2]) |
124 elif attr.isProtected(): |
130 |
125 icon = UI.PixmapCache.getIcon("attribute_protected.png") |
131 # step 2.3: add class attributes |
126 else: |
132 items = [] |
127 icon = UI.PixmapCache.getIcon("attribute.png") |
133 icon = UI.PixmapCache.getIcon("attribute_class.png") |
128 items.append((attr.name, icon, attr.lineno)) |
134 for glob in cl.globals.values(): |
129 for itm in sorted(items): |
135 items.append((glob.name, icon, glob.lineno)) |
130 self.__membersCombo.addItem(itm[1], itm[0], itm[2]) |
136 for itm in sorted(items): |
131 |
137 self.__membersCombo.addItem(itm[1], itm[0], itm[2]) |
132 # step 2.3: add class attributes |
|
133 items = [] |
|
134 icon = UI.PixmapCache.getIcon("attribute_class.png") |
|
135 for glob in cl.globals.values(): |
|
136 items.append((glob.name, icon, glob.lineno)) |
|
137 for itm in sorted(items): |
|
138 self.__membersCombo.addItem(itm[1], itm[0], itm[2]) |
138 |
139 |
139 def __membersActivated(self, index): |
140 def __membersActivated(self, index): |
140 """ |
141 """ |
141 Private method to jump to the line of the selected members entry. |
142 Private method to jump to the line of the selected members entry. |
142 |
143 |
143 @param index index of the selected entry (integer) |
144 @param index index of the selected entry (integer) |
144 """ |
145 """ |
145 lineno = self.__membersCombo.itemData(index) |
146 lineno = self.__membersCombo.itemData(index) |
146 txt = self.__editor.text(lineno - 1).rstrip() |
147 if lineno is not None: |
147 pos = len(txt.replace(txt.strip(), "")) |
148 txt = self.__editor.text(lineno - 1).rstrip() |
148 self.__editor.gotoLine(lineno, pos if pos == 0 else pos +1) |
149 pos = len(txt.replace(txt.strip(), "")) |
149 self.__editor.setFocus() |
150 self.__editor.gotoLine(lineno, pos if pos == 0 else pos +1) |
|
151 self.__editor.setFocus() |
150 |
152 |
151 def __resetParseTimer(self): |
153 def __resetParseTimer(self): |
152 """ |
154 """ |
153 Private slot to reset the parse timer. |
155 Private slot to reset the parse timer. |
154 """ |
156 """ |