summaryrefslogtreecommitdiffstats
path: root/qt-ui/tagwidget.cpp
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 /qt-ui/tagwidget.cpp
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>
Diffstat (limited to 'qt-ui/tagwidget.cpp')
-rw-r--r--qt-ui/tagwidget.cpp16
1 files changed, 15 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);