aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/tagwidget.cpp
diff options
context:
space:
mode:
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);