summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gehad <gehadelrobey@gmail.com>2014-03-19 18:24:53 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-03-19 09:33:59 -0700
commitfdf6f3cd4e78bac6f9f674cb709e94a5b8f025fc (patch)
tree62bb3d8d3d74cc308c22ae430f492320754913d9
parentf2238300ef86afe88d35b13ef48c4367c274d144 (diff)
downloadsubsurface-fdf6f3cd4e78bac6f9f674cb709e94a5b8f025fc.tar.gz
Make Up/Down arrows work with tags
When using Up/Down arrows to scroll the tag list it always selected the first item in the list and doesn't scroll. Fixes #468 Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/tagwidget.cpp16
-rw-r--r--qt-ui/tagwidget.h1
2 files changed, 16 insertions, 1 deletions
diff --git a/qt-ui/tagwidget.cpp b/qt-ui/tagwidget.cpp
index 6ba4a0404..2733a144c 100644
--- a/qt-ui/tagwidget.cpp
+++ b/qt-ui/tagwidget.cpp
@@ -35,7 +35,7 @@ void TagWidget::setCompleter(QCompleter *completer)
m_completer = completer;
m_completer->setWidget(this);
connect(m_completer, SIGNAL(activated(QString)), this, SLOT(completionSelected(QString)));
- connect(m_completer, SIGNAL(highlighted(QString)), this, SLOT(completionSelected(QString)));
+ connect(m_completer, SIGNAL(highlighted(QString)), this, SLOT(completionHighlighted(QString)));
}
QPair<int, int> TagWidget::getCursorTagPosition()
@@ -152,6 +152,20 @@ void TagWidget::completionSelected(QString completion)
emit(textChanged());
}
+void TagWidget::completionHighlighted(QString completion)
+{
+ QPair<int, int> pos;
+ pos = getCursorTagPosition();
+ if (pos.first >= 0 && pos.second > 0) {
+ setText(text().remove(pos.first, pos.second - pos.first).insert(pos.first, completion));
+ setCursorPosition(pos.first + completion.length());
+ } else {
+ setText(completion.append(", "));
+ setCursorPosition(text().length());
+ }
+
+}
+
void TagWidget::setCursorPosition(int position)
{
blockSignals(true);
diff --git a/qt-ui/tagwidget.h b/qt-ui/tagwidget.h
index 161ec0601..42c94b4e0 100644
--- a/qt-ui/tagwidget.h
+++ b/qt-ui/tagwidget.h
@@ -20,6 +20,7 @@ public
slots:
void reparse();
void completionSelected(QString);
+ void completionHighlighted(QString);
protected:
void keyPressEvent(QKeyEvent *e);