OSDN Git Service

Tab and back tab in locator where moving the focus to some weird place.
authorcon <qtc-committer@nokia.com>
Tue, 25 Jan 2011 12:10:24 +0000 (13:10 +0100)
committercon <qtc-committer@nokia.com>
Tue, 25 Jan 2011 12:10:55 +0000 (13:10 +0100)
Let it cycle through elements instead.

Requested-by: aep
src/plugins/locator/locatorwidget.cpp

index 8eed3b6..8def1b2 100644 (file)
@@ -111,6 +111,26 @@ public:
     }
 #endif
 
+    void next() {
+        int index = currentIndex().row();
+        ++index;
+        if (index >= model()->rowCount(QModelIndex())) {
+            // wrap
+            index = 0;
+        }
+        setCurrentIndex(model()->index(index, 0));
+    }
+
+    void previous() {
+        int index = currentIndex().row();
+        --index;
+        if (index < 0) {
+            // wrap
+            index = model()->rowCount(QModelIndex()) - 1;
+        }
+        setCurrentIndex(model()->index(index, 0));
+    }
+
 private:
     QSize m_preferredSize;
 };
@@ -386,6 +406,12 @@ bool LocatorWidget::eventFilter(QObject *obj, QEvent *event)
         case Qt::Key_Escape:
             m_completionList->hide();
             return true;
+        case Qt::Key_Tab:
+            m_completionList->next();
+            return true;
+        case Qt::Key_Backtab:
+            m_completionList->previous();
+            return true;
         default:
             break;
         }