[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [nepomukshell] /: Autocompletion Fixes in the Query Editor
From:       Vishesh Handa <handa.vish () gmail ! com>
Date:       2012-05-11 11:34:55
Message-ID: 20120511113455.E5785A60A9 () git ! kde ! org
[Download RAW message or body]

Git commit e9d2b80c53951410d4477c5e820632c766cf89ea by Vishesh Handa.
Committed on 11/05/2012 at 13:27.
Pushed by vhanda into branch 'master'.

Autocompletion Fixes in the Query Editor

* Do not show the autocompletion list when moving around between text
* Select the first completion as the deafult completion in the list

Thanks to Raveendra Bhat <ravee.bhat69@gmail.com> for the patch.

REVIEW: 104606
CCMAIL: ravee.bhat69@gmail.com

M  +9    -3    queryeditor.cpp

http://commits.kde.org/nepomukshell/e9d2b80c53951410d4477c5e820632c766cf89ea

diff --git a/queryeditor.cpp b/queryeditor.cpp
index 9745a1b..9e9f39c 100644
--- a/queryeditor.cpp
+++ b/queryeditor.cpp
@@ -100,10 +100,16 @@ void QueryEditor::keyPressEvent(QKeyEvent* e)
     QTextEdit::keyPressEvent(e);
 
     QString text = wordUnderCursor();
-    if( text.length() < 2 ) // min 2 char for completion
+    //Minimum 2 characters to show completion list. Hide list when moving around between text.
+    if (e->text().isEmpty()|| text.length() < 2) {
+        m_completer->popup()->hide();
         return;
-
-    m_completer->setCompletionPrefix( text );
+    }
+    // Select first completion as default completion in the list.
+    if (text != m_completer->completionPrefix()) {
+        m_completer->setCompletionPrefix(text);
+        m_completer->popup()->setCurrentIndex(m_completer->completionModel()->index(0, 0));
+    }
 
     QRect cr = cursorRect();
     cr.setWidth( m_completer->popup()->sizeHintForColumn(0)
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic