From 3858afbfa4f2f60cc33f39a471d36a1e1a3514c7 Mon Sep 17 00:00:00 2001 From: weinan li Date: Mon, 10 Nov 2025 08:38:31 +0000 Subject: dolphin: improve keyboard search behavior for repeated characters The original keyboard search implementation had a limitation when dealing with files containing repeated characters like 44.txt. When typing 44, it would trigger rapid navigation to the next item starting with 4 instead of matching the full string 44. This patch introduces a smarter search strategy: 1. First attempt full string matching for exact file names 2. If full match fails and user is typing repeating characters, fall back to rapid navigation using either: - Last successful search string (for extended searches like 444 -> 4444) - First character only (original rapid navigation behavior) The changes include: - Modified changeCurrentItem signal to include a found parameter for search result feedback - Added m_lastSuccessfulSearch to track successful searches for better fallback behavior - Used Qt::DirectConnection to ensure synchronous execution for immediate result feedback This provides better user experience when searching for files with repeated characters while maintaining the rapid navigation feature for quick browsing. BUG: 501851 --- src/kitemviews/private/kitemlistkeyboardsearchmanager.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/kitemviews/private/kitemlistkeyboardsearchmanager.h') diff --git a/src/kitemviews/private/kitemlistkeyboardsearchmanager.h b/src/kitemviews/private/kitemlistkeyboardsearchmanager.h index 5cb8effbf..4437f97b4 100644 --- a/src/kitemviews/private/kitemlistkeyboardsearchmanager.h +++ b/src/kitemviews/private/kitemlistkeyboardsearchmanager.h @@ -66,7 +66,7 @@ Q_SIGNALS: */ // TODO: Think about getting rid of the bool parameter // (see https://doc.qt.io/archives/qq/qq13-apis.html#thebooleanparametertrap) - void changeCurrentItem(const QString &string, bool searchFromNextItem); + void changeCurrentItem(const QString &string, bool searchFromNextItem, bool *found); private: bool shouldClearSearchIfInputTimeReached(); @@ -76,6 +76,7 @@ private: QElapsedTimer m_keyboardInputTime; /** Time in milliseconds in which a key press is considered as a continuation of the previous search input. */ qint64 m_timeout; + QString m_lastSuccessfulSearch; }; #endif -- cgit v1.3.1