mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
87d3cd5234
commit
d273694954
3 changed files with 27 additions and 4 deletions
|
@ -111,6 +111,28 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
|
|||
return ret;
|
||||
}
|
||||
|
||||
// this is our magic 'pass data in' function that allows the delegate to get
|
||||
// the data here without silly unit conversions;
|
||||
// so we only implement the two columns we care about
|
||||
void CylindersModel::passInData(const QModelIndex& index, const QVariant& value)
|
||||
{
|
||||
cylinder_t *cyl = ¤t->cylinder[index.row()];
|
||||
switch(index.column()) {
|
||||
case SIZE:
|
||||
if (cyl->type.size.mliter != value.toInt()) {
|
||||
cyl->type.size.mliter = value.toInt();
|
||||
mark_divelist_changed(TRUE);
|
||||
}
|
||||
break;
|
||||
case WORKINGPRESS:
|
||||
if (cyl->type.workingpressure.mbar != value.toInt()) {
|
||||
cyl->type.workingpressure.mbar = value.toInt();
|
||||
mark_divelist_changed(TRUE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define CHANGED(_t,_u1,_u2) value._t() != data(index, role).toString().replace(_u1,"").replace(_u2,"")._t()
|
||||
|
||||
bool CylindersModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue