summaryrefslogtreecommitdiffstats
path: root/qt-ui/modeldelegates.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-23 13:31:46 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-23 13:31:46 -0700
commitd273694954567319d26a162201efe0a76664c66a (patch)
tree926cb17b18bfc6ea6c1bdd1fcdbd9e3ba90120f5 /qt-ui/modeldelegates.cpp
parent87d3cd523493e009737887528d2c4040c0280804 (diff)
downloadsubsurface-d273694954567319d26a162201efe0a76664c66a.tar.gz
Allow the CylindersModel delegate to pass data in without unit conversions
With this we should have tank editing mostly done. See #122 (it's not quite fixed, we need the equivalent code for weight systems) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/modeldelegates.cpp')
-rw-r--r--qt-ui/modeldelegates.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp
index 2dc52e655..0cffe98c4 100644
--- a/qt-ui/modeldelegates.cpp
+++ b/qt-ui/modeldelegates.cpp
@@ -77,16 +77,16 @@ void TankInfoDelegate::setEditorData(QWidget* editor, const QModelIndex& index)
void TankInfoDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
QComboBox *c = static_cast<QComboBox*>(editor);
-
+ CylindersModel *mymodel = qobject_cast<CylindersModel *>(model);
TankInfoModel *tanks = TankInfoModel::instance();
QModelIndex tankIndex = tanks->match(tanks->index(0,0), Qt::DisplayRole, c->currentText()).first();
int tankSize = tanks->data(tanks->index(tankIndex.row(), TankInfoModel::ML)).toInt();
int tankPressure = tanks->data(tanks->index(tankIndex.row(), TankInfoModel::BAR)).toInt();
- model->setData(index, c->currentText(), Qt::EditRole);
- model->setData(model->index(index.row(), CylindersModel:: SIZE), tankSize );
- model->setData(model->index(index.row(), CylindersModel::WORKINGPRESS), tankPressure);
+ mymodel->setData(index, c->currentText(), Qt::EditRole);
+ mymodel->passInData(model->index(index.row(), CylindersModel::WORKINGPRESS), tankPressure);
+ mymodel->passInData(model->index(index.row(), CylindersModel::SIZE), tankSize);
}
TankInfoDelegate::TankInfoDelegate(QObject* parent): QStyledItemDelegate(parent)