diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-12-11 22:52:20 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-12-13 11:49:59 -0800 |
commit | a55c7ff0793c119e8472cecebfe8c059f55e74f8 (patch) | |
tree | 65e12039d52ecfea5d581d9218a00c0019485c61 | |
parent | d16a9f118a650e6aa3e70a8adb8c8e2be38fbb70 (diff) | |
download | subsurface-a55c7ff0793c119e8472cecebfe8c059f55e74f8.tar.gz |
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>
-rw-r--r-- | desktop-widgets/modeldelegates.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/desktop-widgets/modeldelegates.cpp b/desktop-widgets/modeldelegates.cpp index e2774240f..11d42c36e 100644 --- a/desktop-widgets/modeldelegates.cpp +++ b/desktop-widgets/modeldelegates.cpp @@ -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); |