| 175 | } |
| 176 | |
| 177 | void 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 | |
| 230 | void VariableChooserPrivate::updateButtonGeometry() |
| 231 | { |
nothing calls this directly
no test coverage detected