From a55c7ff0793c119e8472cecebfe8c059f55e74f8 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 11 Dec 2020 22:52:20 +0100 Subject: [PATCH] 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 --- desktop-widgets/modeldelegates.cpp | 6 ++++-- 1 file 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);