summaryrefslogtreecommitdiffstats
path: root/qt-ui/modeldelegates.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-07-16 19:05:49 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-16 15:53:21 -0700
commitb66f679d64eba168510e9aa6c2f6c0951aa5e927 (patch)
treee1e12e9eee18d602201ca94b7e7470843bb0f899 /qt-ui/modeldelegates.cpp
parent1b6144350d38c2246a0366ae52d0f99a758737e4 (diff)
downloadsubsurface-b66f679d64eba168510e9aa6c2f6c0951aa5e927.tar.gz
Complete the name of the first Cylinder on edit
When you entered part of the name of a cylinder this was being treated as a new cylinder, and not selecting the first one. Fixes #628 Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/modeldelegates.cpp')
-rw-r--r--qt-ui/modeldelegates.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp
index add853cce..3d9917773 100644
--- a/qt-ui/modeldelegates.cpp
+++ b/qt-ui/modeldelegates.cpp
@@ -222,18 +222,19 @@ void TankInfoDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
TankInfoModel *tanks = TankInfoModel::instance();
QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, currCombo.activeText);
int row;
+ QString cylinderName = currCombo.activeText;
if (matches.isEmpty()) {
- // we need to add this
tanks->insertRows(tanks->rowCount(), 1);
tanks->setData(tanks->index(tanks->rowCount() - 1, 0), currCombo.activeText);
row = tanks->rowCount() - 1;
} else {
row = matches.first().row();
+ cylinderName = matches.first().data().toString();
}
int tankSize = tanks->data(tanks->index(row, TankInfoModel::ML)).toInt();
int tankPressure = tanks->data(tanks->index(row, TankInfoModel::BAR)).toInt();
- mymodel->setData(IDX(CylindersModel::TYPE), currCombo.activeText, Qt::EditRole);
+ mymodel->setData(IDX(CylindersModel::TYPE), cylinderName, Qt::EditRole);
mymodel->passInData(IDX(CylindersModel::WORKINGPRESS), tankPressure);
mymodel->passInData(IDX(CylindersModel::SIZE), tankSize);
}