diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-07-18 12:28:28 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-07-18 12:01:48 -0700 |
commit | 8ad7216e70a4f8005dddbc1f296cfc30a29e835a (patch) | |
tree | 092ff5da7a075eda45c937c1f60dd9ff9e5e3f1a | |
parent | 3aa55462dc2fc44151962a292f9b7034ec3863b2 (diff) | |
download | subsurface-8ad7216e70a4f8005dddbc1f296cfc30a29e835a.tar.gz |
Fixes incorrect editing policies.
The Working Press didn't correctly updated when there was a 'bar'
or 'psi' in the string ( and that was defalt behaviour );
The o2 didn't correctly updated when there was a '%' on the string
(and that was default behaviour ),
The He didn't correctly updated when there was a '%' on the string,
and that was also default behavior.
Now all of them correctly updates.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
-rw-r--r-- | qt-ui/models.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 347301424..0af5c7019 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -180,7 +180,7 @@ void CylindersModel::passInData(const QModelIndex& index, const QVariant& value) } } -#define CHANGED(_t,_u1,_u2) value._t() != data(index, role).toString().replace(_u1,"").replace(_u2,"")._t() +#define CHANGED(_t,_u1,_u2) value._t() != data(index, role).toString().remove(_u1).remove(_u2)._t() bool CylindersModel::setData(const QModelIndex& index, const QVariant& value, int role) { @@ -223,13 +223,15 @@ bool CylindersModel::setData(const QModelIndex& index, const QVariant& value, in break; case WORKINGPRESS: if (CHANGED(toDouble, "psi", "bar")) { - if (value.toDouble() != 0.0) { + QString vString = value.toString(); + vString.remove("psi").remove("bar"); + if (vString.toDouble() != 0.0) { TankInfoModel *tanks = TankInfoModel::instance(); QModelIndexList matches = tanks->match(tanks->index(0,0), Qt::DisplayRole, cyl->type.description); if (prefs.units.pressure == prefs.units.PSI) - cyl->type.workingpressure.mbar = psi_to_mbar(value.toDouble()); + cyl->type.workingpressure.mbar = psi_to_mbar(vString.toDouble()); else - cyl->type.workingpressure.mbar = value.toDouble() * 1000; + cyl->type.workingpressure.mbar = vString.toDouble() * 1000; if (!matches.isEmpty()) tanks->setData(tanks->index(matches.first().row(), TankInfoModel::BAR), cyl->type.workingpressure.mbar / 1000.0); mark_divelist_changed(TRUE); @@ -259,13 +261,13 @@ bool CylindersModel::setData(const QModelIndex& index, const QVariant& value, in break; case O2: if (CHANGED(toDouble, "%", "%")) { - cyl->gasmix.o2.permille = value.toDouble() * 10 + 0.5; + cyl->gasmix.o2.permille = value.toString().remove('%').toDouble() * 10 + 0.5; mark_divelist_changed(TRUE); } break; case HE: if (CHANGED(toDouble, "%", "%")) { - cyl->gasmix.he.permille = value.toDouble() * 10 + 0.5; + cyl->gasmix.he.permille = value.toString().remove('%').toDouble() * 10 + 0.5; mark_divelist_changed(TRUE); } break; |