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 <tcanabrava@kde.org>
This commit is contained in:
Tomaz Canabrava 2013-05-23 15:59:12 -03:00
parent babbfa9204
commit 87d3cd5234

View file

@ -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<QComboBox*>(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)