From 430a77b8a75668f2fac21cdced3fac2d05073089 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 18 Jul 2013 12:28:28 -0300 Subject: 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 --- qt-ui/models.cpp | 14 ++++++++------ 1 file 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; -- cgit v1.2.3-70-g09d2