MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / updateCurrentEditor

Method updateCurrentEditor

src/common/widget/variablechooser.cpp:177–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177void VariableChooserPrivate::updateCurrentEditor(QWidget *old, QWidget *widget)
178{
179 Q_UNUSED(old)
180
181 if (!widget)
182 return;
183
184 bool handle = false;
185 QWidget *parent = widget;
186 while (parent) {
187 if (parent == q)
188 return;
189 if (parent == q->parentWidget()) {
190 handle = true;
191 break;
192 }
193 parent = parent->parentWidget();
194 }
195 if (!handle)
196 return;
197
198 QLineEdit *previousLineEdit = lineEdit;
199 QWidget *previousWidget = currentWidget();
200 lineEdit = nullptr;
201 auto chooser = widget->property(VariableFlag).value<QWidget *>();
202 bool supportsVariables = chooser == q;
203 if (auto edit = qobject_cast<QLineEdit *>(widget))
204 lineEdit = (supportsVariables && !edit->isReadOnly() ? edit : nullptr);
205
206 QWidget *current = currentWidget();
207 if (current != previousWidget) {
208 if (previousWidget)
209 previousWidget->removeEventFilter(q);
210 if (previousLineEdit)
211 previousLineEdit->setTextMargins(0, 0, 0, 0);
212 if (iconButton) {
213 iconButton->hide();
214 iconButton->setParent(nullptr);
215 }
216 if (current) {
217 current->installEventFilter(q); // escape key handling and geometry changes
218 int margin = buttonMargin();
219 if (lineEdit)
220 lineEdit->setTextMargins(0, 0, margin, 0);
221 iconButton->setParent(current);
222 updateButtonGeometry();
223 iconButton->show();
224 } else {
225 q->hide();
226 }
227 }
228}
229
230void VariableChooserPrivate::updateButtonGeometry()
231{

Callers

nothing calls this directly

Calls 4

isReadOnlyMethod · 0.80
propertyMethod · 0.45
hideMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected