From 37fa2fda03ec39e7099f5cf1f2d5b96d8cd9f2c2 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 10 Jul 2014 13:19:07 -0300 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/groupedlineedit.cpp | 2 ++ qt-ui/tagwidget.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/qt-ui/groupedlineedit.cpp b/qt-ui/groupedlineedit.cpp index 25488a95c..28758e02f 100644 --- a/qt-ui/groupedlineedit.cpp +++ b/qt-ui/groupedlineedit.cpp @@ -87,6 +87,8 @@ void GroupedLineEdit::addBlock(int start, int end) block.start = start; block.end = end; block.text = text().mid(start, end - start + 1).remove(',').trimmed(); + if (block.text.isEmpty()) + return; d->blocks.append(block); viewport()->update(); } 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 -- cgit v1.2.3-70-g09d2