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.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/qt-ui/tagwidget.cpp b/qt-ui/tagwidget.cpp
index dfeeac537..8c45dceec 100644
--- a/qt-ui/tagwidget.cpp
+++ b/qt-ui/tagwidget.cpp
@@ -4,8 +4,9 @@
#include <QAbstractItemView>
#include <QSettings>
#include <QFont>
+#include "mainwindow.h"
-TagWidget::TagWidget(QWidget *parent) : GroupedLineEdit(parent), m_completer(NULL)
+TagWidget::TagWidget(QWidget *parent) : GroupedLineEdit(parent), m_completer(NULL), lastFinishedTag(false)
{
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(reparse()));
connect(this, SIGNAL(textChanged()), this, SLOT(reparse()));
@@ -137,13 +138,13 @@ void TagWidget::reparse()
}
}
-void TagWidget::completionSelected(const QString& completion)
+void TagWidget::completionSelected(const QString &completion)
{
completionHighlighted(completion);
emit textChanged();
}
-void TagWidget::completionHighlighted(const QString& completion)
+void TagWidget::completionHighlighted(const QString &completion)
{
QPair<int, int> pos = getCursorTagPosition();
setText(text().remove(pos.first, pos.second - pos.first).insert(pos.first, completion));
@@ -157,7 +158,7 @@ void TagWidget::setCursorPosition(int position)
blockSignals(false);
}
-void TagWidget::setText(const QString& text)
+void TagWidget::setText(const QString &text)
{
blockSignals(true);
GroupedLineEdit::setText(text);
@@ -176,6 +177,7 @@ void TagWidget::keyPressEvent(QKeyEvent *e)
{
QPair<int, int> pos;
QAbstractItemView *popup;
+ bool finishedTag = false;
switch (e->key()) {
case Qt::Key_Escape:
pos = getCursorTagPosition();
@@ -183,7 +185,7 @@ void TagWidget::keyPressEvent(QKeyEvent *e)
setText(text().remove(pos.first, pos.second - pos.first));
setCursorPosition(pos.first);
}
- popup= m_completer->popup();
+ popup = m_completer->popup();
if (popup)
popup->hide();
return;
@@ -199,13 +201,17 @@ void TagWidget::keyPressEvent(QKeyEvent *e)
if (popup)
popup->hide();
}
+ finishedTag = true;
}
- if (e->key() == Qt::Key_Tab || e->key() == Qt::Key_Return) { // let's pretend this is a comma instead
+ if (e->key() == Qt::Key_Tab && lastFinishedTag) { // if we already end in comma, go to next/prev field
+ MainWindow::instance()->information()->nextInputField(e); // by sending the key event to the MainTab widget
+ } else if (e->key() == Qt::Key_Tab || e->key() == Qt::Key_Return) { // otherwise let's pretend this is a comma instead
QKeyEvent fakeEvent(e->type(), Qt::Key_Comma, e->modifiers(), QString(","));
GroupedLineEdit::keyPressEvent(&fakeEvent);
} else {
GroupedLineEdit::keyPressEvent(e);
}
+ lastFinishedTag = finishedTag;
}
void TagWidget::wheelEvent(QWheelEvent *event)