Make the tag widget act more sanely when pressing Tab

When dealing with autocompletion, tag usually means "take this, move on".
In the tag widget the tab was added to the tag itself (and then stripped
when the input line was processed). Not exactly useful.

This feels a bit "hackish", but it seems to get the job done.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-11-07 13:40:57 +09:00
parent 9052035548
commit f262ed69cc

View file

@ -152,6 +152,7 @@ void TagWidget::keyPressEvent(QKeyEvent *e) {
switch (e->key()) { switch (e->key()) {
case Qt::Key_Return: case Qt::Key_Return:
case Qt::Key_Enter: case Qt::Key_Enter:
case Qt::Key_Tab:
/* /*
* Fake the QLineEdit behaviour by simply * Fake the QLineEdit behaviour by simply
* closing the QAbstractViewitem * closing the QAbstractViewitem
@ -162,6 +163,13 @@ void TagWidget::keyPressEvent(QKeyEvent *e) {
popup->hide(); popup->hide();
} }
} }
GroupedLineEdit::keyPressEvent(e); if (e->key() == Qt::Key_Tab) { // let's pretend this is a comma instead
QKeyEvent *fakeEvent = new QKeyEvent(e->type(), Qt::Key_Comma, e->modifiers(), QString(","));
qDebug() << "sending comma instead";
GroupedLineEdit::keyPressEvent(fakeEvent);
free(fakeEvent);
} else {
GroupedLineEdit::keyPressEvent(e);
}
} }