Changeset View
Standalone View
src/kcombobox.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 34 | public: | |||
---|---|---|---|---|---|
51 | bool trapReturnKey = false; | 51 | bool trapReturnKey = false; | ||
52 | KComboBox * const q_ptr; | 52 | KComboBox * const q_ptr; | ||
53 | Q_DECLARE_PUBLIC(KComboBox) | 53 | Q_DECLARE_PUBLIC(KComboBox) | ||
54 | }; | 54 | }; | ||
55 | 55 | | |||
56 | void KComboBoxPrivate::init() | 56 | void KComboBoxPrivate::init() | ||
57 | { | 57 | { | ||
58 | Q_Q(KComboBox); | 58 | Q_Q(KComboBox); | ||
59 | q->QComboBox::setAutoCompletion(false); // otherwise setLineEdit will create a completer... | | |||
broulik: With this removed, the `KUrlComboBox` in e.g. "Look in" in KFind autocompletes history entries… | |||||
Good catch! More precisely, history entries are offered in the lineedit edit, pre-selected, and only hitting "Del" allows to get normal path completion. Amazing. setAutoCompletion(false) really only does setCompleter(nullptr) like we do (and setting the bool for the old unused property). Ah.... unless we're not yet editable when coming here, and we're made editable later, then no code is doing the setCompleter(nullptr) anymore. Tricky! In fact, due to the way init() is called, isEditable() is *NEVER* true here. I'll keep working on a fix, just wanted to let you know I'm on it. dfaure: Good catch!
More precisely, history entries are offered in the lineedit edit, pre-selected… | |||||
60 | 59 | | |||
61 | if (q->isEditable()) { | 60 | if (q->isEditable()) { | ||
62 | q->setCompleter(nullptr); | 61 | q->setCompleter(nullptr); // remove the builtin completer, we have our own | ||
63 | q->lineEdit()->setContextMenuPolicy(Qt::DefaultContextMenu); | 62 | q->lineEdit()->setContextMenuPolicy(Qt::DefaultContextMenu); | ||
64 | } | 63 | } | ||
65 | } | 64 | } | ||
66 | 65 | | |||
67 | void KComboBoxPrivate::_k_lineEditDeleted() | 66 | void KComboBoxPrivate::_k_lineEditDeleted() | ||
68 | { | 67 | { | ||
69 | Q_Q(KComboBox); | 68 | Q_Q(KComboBox); | ||
70 | // yes, we need those ugly casts due to the multiple inheritance | 69 | // yes, we need those ugly casts due to the multiple inheritance | ||
▲ Show 20 Lines • Show All 278 Lines • ▼ Show 20 Line(s) | 347 | connect(d->klineEdit, &KLineEdit::textRotation, | |||
349 | this, &KComboBox::textRotation); | 348 | this, &KComboBox::textRotation); | ||
350 | 349 | | |||
351 | connect(d->klineEdit, &KLineEdit::completionModeChanged, | 350 | connect(d->klineEdit, &KLineEdit::completionModeChanged, | ||
352 | this, &KComboBox::completionModeChanged); | 351 | this, &KComboBox::completionModeChanged); | ||
353 | 352 | | |||
354 | connect(d->klineEdit, &KLineEdit::aboutToShowContextMenu, | 353 | connect(d->klineEdit, &KLineEdit::aboutToShowContextMenu, | ||
355 | this, &KComboBox::aboutToShowContextMenu); | 354 | this, &KComboBox::aboutToShowContextMenu); | ||
356 | 355 | | |||
356 | // match the declaration of the deprecated signal | ||||
357 | #if QT_DEPRECATED_SINCE(5, 15) || QT_VERSION < QT_VERSION_CHECK(5, 14, 0) | ||||
357 | connect(d->klineEdit, &KLineEdit::completionBoxActivated, | 358 | connect(d->klineEdit, &KLineEdit::completionBoxActivated, | ||
358 | this, QOverload<const QString&>::of(&QComboBox::activated)); | 359 | this, QOverload<const QString&>::of(&QComboBox::activated)); | ||
360 | #endif | ||||
361 | #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) | ||||
362 | connect(d->klineEdit, &KLineEdit::completionBoxActivated, | ||||
363 | this, QOverload<const QString&>::of(&QComboBox::textActivated)); | ||||
Why the QOverload<const QString&>::of() with &QComboBox::textActivated? Accidental copy&paste? kossebau: Why the `QOverload<const QString&>::of()` with `&QComboBox::textActivated`? Accidental… | |||||
364 | #endif | ||||
359 | 365 | | |||
360 | d->klineEdit->setTrapReturnKey(d->trapReturnKey); | 366 | d->klineEdit->setTrapReturnKey(d->trapReturnKey); | ||
361 | } | 367 | } | ||
362 | } | 368 | } | ||
363 | 369 | | |||
364 | void KComboBox::setCurrentItem(const QString &item, bool insert, int index) | 370 | void KComboBox::setCurrentItem(const QString &item, bool insert, int index) | ||
365 | { | 371 | { | ||
366 | int sel = -1; | 372 | int sel = -1; | ||
Show All 40 Lines |
With this removed, the KUrlComboBox in e.g. "Look in" in KFind autocompletes history entries rather than paths when hitting tab.