58 self.__parseTimer.setSingleShot(True) |
58 self.__parseTimer.setSingleShot(True) |
59 self.__parseTimer.setInterval(5 * 1000) |
59 self.__parseTimer.setInterval(5 * 1000) |
60 self.__parseTimer.timeout.connect(self.__parseEditor) |
60 self.__parseTimer.timeout.connect(self.__parseEditor) |
61 self.__editor.textChanged.connect(self.__resetParseTimer) |
61 self.__editor.textChanged.connect(self.__resetParseTimer) |
62 |
62 |
|
63 self.__selectedGlobal = "" |
|
64 self.__selectedMember = "" |
|
65 |
63 QTimer.singleShot(0, self.__parseEditor) |
66 QTimer.singleShot(0, self.__parseEditor) |
64 |
67 |
65 def shutdownTimer(self): |
68 def shutdownTimer(self): |
66 """ |
69 """ |
67 Public method to stop and disconnect the timer. |
70 Public method to stop and disconnect the timer. |
76 |
79 |
77 @return reference to the editor widget (Editor) |
80 @return reference to the editor widget (Editor) |
78 """ |
81 """ |
79 return self.__editor |
82 return self.__editor |
80 |
83 |
81 def __globalsActivated(self, index): |
84 def __globalsActivated(self, index, moveCursor=True): |
82 """ |
85 """ |
83 Private method to jump to the line of the selected global entry and to populate |
86 Private method to jump to the line of the selected global entry and to populate |
84 the members combo box. |
87 the members combo box. |
85 |
88 |
86 @param index index of the selected entry (integer) |
89 @param index index of the selected entry (integer) |
|
90 @keyparam moveCursor flag indicating to move the editor cursor (boolean) |
87 """ |
91 """ |
88 # step 1: go to the line of the selected entry |
92 # step 1: go to the line of the selected entry |
89 lineno = self.__globalsCombo.itemData(index) |
93 lineno = self.__globalsCombo.itemData(index) |
90 if lineno is not None: |
94 if lineno is not None: |
91 txt = self.__editor.text(lineno - 1).rstrip() |
95 if moveCursor: |
92 pos = len(txt.replace(txt.strip(), "")) |
96 txt = self.__editor.text(lineno - 1).rstrip() |
93 self.__editor.gotoLine(lineno, pos if pos == 0 else pos + 1) |
97 pos = len(txt.replace(txt.strip(), "")) |
94 self.__editor.setFocus() |
98 self.__editor.gotoLine(lineno, pos if pos == 0 else pos + 1) |
|
99 self.__editor.setFocus() |
95 |
100 |
96 # step 2: populate the members combo, if the entry is a class |
101 # step 2: populate the members combo, if the entry is a class |
97 self.__membersCombo.clear() |
102 self.__membersCombo.clear() |
98 entryName = self.__globalsCombo.itemText(index) |
103 entryName = self.__globalsCombo.itemText(index) |
99 if self.__module and entryName in self.__module.classes: |
104 if self.__module and entryName in self.__module.classes: |
135 for glob in cl.globals.values(): |
140 for glob in cl.globals.values(): |
136 items.append((glob.name, icon, glob.lineno)) |
141 items.append((glob.name, icon, glob.lineno)) |
137 for itm in sorted(items): |
142 for itm in sorted(items): |
138 self.__membersCombo.addItem(itm[1], itm[0], itm[2]) |
143 self.__membersCombo.addItem(itm[1], itm[0], itm[2]) |
139 |
144 |
140 def __membersActivated(self, index): |
145 def __membersActivated(self, index, moveCursor=True): |
141 """ |
146 """ |
142 Private method to jump to the line of the selected members entry. |
147 Private method to jump to the line of the selected members entry. |
143 |
148 |
144 @param index index of the selected entry (integer) |
149 @param index index of the selected entry (integer) |
|
150 @keyparam moveCursor flag indicating to move the editor cursor (boolean) |
145 """ |
151 """ |
146 lineno = self.__membersCombo.itemData(index) |
152 lineno = self.__membersCombo.itemData(index) |
147 if lineno is not None: |
153 if lineno is not None and moveCursor: |
148 txt = self.__editor.text(lineno - 1).rstrip() |
154 txt = self.__editor.text(lineno - 1).rstrip() |
149 pos = len(txt.replace(txt.strip(), "")) |
155 pos = len(txt.replace(txt.strip(), "")) |
150 self.__editor.gotoLine(lineno, pos if pos == 0 else pos + 1) |
156 self.__editor.gotoLine(lineno, pos if pos == 0 else pos + 1) |
151 self.__editor.setFocus() |
157 self.__editor.setFocus() |
152 |
158 |
170 if fn is None: |
176 if fn is None: |
171 fn = "" |
177 fn = "" |
172 self.__module = Module("", fn, sourceType) |
178 self.__module = Module("", fn, sourceType) |
173 self.__module.scan(src) |
179 self.__module.scan(src) |
174 |
180 |
|
181 # remember the current selections |
|
182 self.__selectedGlobal = self.__globalsCombo.currentText() |
|
183 self.__selectedMember = self.__membersCombo.currentText() |
|
184 |
175 self.__globalsCombo.clear() |
185 self.__globalsCombo.clear() |
176 self.__membersCombo.clear() |
186 self.__membersCombo.clear() |
177 |
187 |
178 self.__globalsCombo.addItem("") |
188 self.__globalsCombo.addItem("") |
179 |
189 |
213 else: |
223 else: |
214 icon = UI.PixmapCache.getIcon("attribute.png") |
224 icon = UI.PixmapCache.getIcon("attribute.png") |
215 items.append((glob.name, icon, glob.lineno)) |
225 items.append((glob.name, icon, glob.lineno)) |
216 for itm in sorted(items): |
226 for itm in sorted(items): |
217 self.__globalsCombo.addItem(itm[1], itm[0], itm[2]) |
227 self.__globalsCombo.addItem(itm[1], itm[0], itm[2]) |
|
228 |
|
229 # reset the currently selected entries without moving the text cursor |
|
230 index = self.__globalsCombo.findText(self.__selectedGlobal) |
|
231 if index != -1: |
|
232 self.__globalsCombo.setCurrentIndex(index) |
|
233 self.__globalsActivated(index, moveCursor=False) |
|
234 index = self.__membersCombo.findText(self.__selectedMember) |
|
235 if index != -1: |
|
236 self.__membersCombo.setCurrentIndex(index) |
|
237 self.__membersActivated(index, moveCursor=False) |