diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-05-23 13:31:46 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-23 13:31:46 -0700 |
commit | d273694954567319d26a162201efe0a76664c66a (patch) | |
tree | 926cb17b18bfc6ea6c1bdd1fcdbd9e3ba90120f5 /qt-ui/models.cpp | |
parent | 87d3cd523493e009737887528d2c4040c0280804 (diff) | |
download | subsurface-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/models.cpp')
-rw-r--r-- | qt-ui/models.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 029a788bf..0ef054533 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -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) |