mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
892381b3ae
commit
37fa2fda03
2 changed files with 10 additions and 0 deletions
|
@ -87,6 +87,8 @@ void GroupedLineEdit::addBlock(int start, int end)
|
||||||
block.start = start;
|
block.start = start;
|
||||||
block.end = end;
|
block.end = end;
|
||||||
block.text = text().mid(start, end - start + 1).remove(',').trimmed();
|
block.text = text().mid(start, end - start + 1).remove(',').trimmed();
|
||||||
|
if (block.text.isEmpty())
|
||||||
|
return;
|
||||||
d->blocks.append(block);
|
d->blocks.append(block);
|
||||||
viewport()->update();
|
viewport()->update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,6 +169,14 @@ void TagWidget::keyPressEvent(QKeyEvent *e)
|
||||||
popup->hide();
|
popup->hide();
|
||||||
}
|
}
|
||||||
finishedTag = true;
|
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
|
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
|
MainWindow::instance()->information()->nextInputField(e); // by sending the key event to the MainTab widget
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue