desktop: don't save data to the "no-name" tank

There seems to be no point to saving data to the tank with
the empty name. Don't save tank-pressure and size to that
tank info.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-12-11 22:52:20 +01:00 committed by Dirk Hohndel
parent d16a9f118a
commit a55c7ff079

View file

@ -217,9 +217,11 @@ void TankInfoDelegate::setModelData(QWidget *, QAbstractItemModel *, const QMode
{
QAbstractItemModel *mymodel = currCombo.model;
TankInfoModel *tanks = TankInfoModel::instance();
QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, currCombo.activeText, 1, Qt::MatchFixedString | Qt::MatchWrap);
QString cylinderName = currCombo.activeText.trimmed();
if (cylinderName.isEmpty())
return;
QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, cylinderName, 1, Qt::MatchFixedString | Qt::MatchWrap);
int row;
QString cylinderName = currCombo.activeText;
if (matches.isEmpty()) {
tanks->insertRows(tanks->rowCount(), 1);
tanks->setData(tanks->index(tanks->rowCount() - 1, 0), currCombo.activeText);