[Completer] Highlight popup rows without rewriting the line edit (#7502)

* [Completer] Highlight popup rows without rewriting the line edit

Selecting a popup row with ClearAndSelect emits selectionChanged, which
QCompleter turns into highlighted() and QLineEdit turns into setText().
Since be2c16eca5 (#7466) that rewrites the typed text on every completion
reset / arrow-key press (e.g. typing "A" becomes "Axe" and cannot be
edited), regressing the 514014dc00 (#7447) fix that used NoUpdate.

Add selectWithoutRewrite(), which blocks the selection-model signals while
applying ClearAndSelect so the highlight stays visible without touching
the line edit, then syncs the preview manually. Route both the
above-popup auto-select and Up/Down navigation through it, and handle
Up/Down for below-popups too instead of falling through to Qt's
rewriting default. Enter/click acceptance via activated() is unchanged.

* [Completer] Repaint popup highlight after silent selection change

Blocking the selection model's signals also suppresses the view's own
selectionChanged/currentChanged repaints, so force a viewport update
after restoring signals. Use EnsureVisible to match Qt's normal scroll
behaviour.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-10-16 19:01:38 +02:00 • committed by GitHub
parent 456d9d9e70
commit bbe438b09a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 48 additions and 14 deletions

View file

@ -55,6 +55,7 @@ private:
void applyPopupWidth();
void updateOrientation();
void ensureClosestSelected();
void selectWithoutRewrite(const QModelIndex &index);
bool handlePopupKeyPress(QKeyEvent *event);
bool isPopupAboveWidget() const;