diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-08-05 21:21:31 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-08-05 21:21:31 -0700 |
commit | d85d08e14f9ed2b39e0d4d2cdc772e26f02fef78 (patch) | |
tree | bbf65c4d0a159db69c5551c84e17927d6ddd4567 /qt-ui | |
parent | 4d775fd049f72af0b94c37d729246ae992472d3a (diff) | |
download | subsurface-d85d08e14f9ed2b39e0d4d2cdc772e26f02fef78.tar.gz |
Data validation
Instead of refusing cylinder pressure data let's just mark it as red when
the values don't seem to make sense.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/models.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 8963c1287..7fc941558 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -95,6 +95,21 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const cylinder_t *cyl = &displayed_dive.cylinder[index.row()]; switch (role) { + case Qt::BackgroundRole: { + switch (index.column()) { + // mark the cylinder start / end pressure in red if the values + // seem implausible + case START: + case END: + if ((cyl->start.mbar && !cyl->end.mbar) || + (cyl->end.mbar && cyl->start.mbar <= cyl->end.mbar)) + ret = REDORANGE1_HIGH_TRANS; + else + ret = WHITE1; + break; + } + break; + } case Qt::FontRole: { QFont font = defaultModelFont(); switch (index.column()) { @@ -235,13 +250,14 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in } break; case START: - if (CHANGED() && (!cyl->end.mbar || string_to_pressure(vString.toUtf8().data()).mbar >= cyl->end.mbar)) { + if (CHANGED()) { cyl->start = string_to_pressure(vString.toUtf8().data()); changed = true; } break; case END: - if (CHANGED() && (!cyl->start.mbar || string_to_pressure(vString.toUtf8().data()).mbar <= cyl->start.mbar)) { + if (CHANGED()) { + //&& (!cyl->start.mbar || string_to_pressure(vString.toUtf8().data()).mbar <= cyl->start.mbar)) { cyl->end = string_to_pressure(vString.toUtf8().data()); changed = true; } |