From 87d3cd523493e009737887528d2c4040c0280804 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 23 May 2013 15:59:12 -0300 Subject: Also changes the size and working pressure of the cylinders this is more a 'Well, this is how we do it' than an actuall good commit. I'm probably using the wrong conversion paradigm ( none ) to convert the data from psi / bar and such, it changes the model with wrong data. Signed-off-by: Tomaz Canabrava --- qt-ui/modeldelegates.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index 283cf17b0..2dc52e655 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -77,7 +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(editor); + + 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); } TankInfoDelegate::TankInfoDelegate(QObject* parent): QStyledItemDelegate(parent) -- cgit v1.2.3-70-g09d2