summaryrefslogtreecommitdiffstats
path: root/qt-ui/tagwidget.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-07-10 13:19:07 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-10 10:17:50 -0700
commit37fa2fda03ec39e7099f5cf1f2d5b96d8cd9f2c2 (patch)
tree076f8a32778a55381ef0b50d0d430b8a30d32cd4 /qt-ui/tagwidget.cpp
parent892381b3ae0a27636b80a15c02167b21cd8e1ccd (diff)
downloadsubsurface-37fa2fda03ec39e7099f5cf1f2d5b96d8cd9f2c2.tar.gz
Forbid the use of empty strings as tags
Some tags were wrong when the user added two commas, so this patch forbids the use of a comma when we don't have any tags. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/tagwidget.cpp')
-rw-r--r--qt-ui/tagwidget.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/qt-ui/tagwidget.cpp b/qt-ui/tagwidget.cpp
index 8201e8e1b..819b561ed 100644
--- a/qt-ui/tagwidget.cpp
+++ b/qt-ui/tagwidget.cpp
@@ -169,6 +169,14 @@ void TagWidget::keyPressEvent(QKeyEvent *e)
popup->hide();
}
finishedTag = true;
+ break;
+ case Qt::Key_Comma: { /* if this is the last key, and the previous string is empty, ignore the comma. */
+ QString temp = text();
+ if (temp.split(QChar(',')).last().trimmed().isEmpty()){
+ e->ignore();
+ return;
+ }
+ }
}
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