mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
4d775fd049
commit
d85d08e14f
1 changed files with 18 additions and 2 deletions
|
@ -95,6 +95,21 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
|
||||||
|
|
||||||
cylinder_t *cyl = &displayed_dive.cylinder[index.row()];
|
cylinder_t *cyl = &displayed_dive.cylinder[index.row()];
|
||||||
switch (role) {
|
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: {
|
case Qt::FontRole: {
|
||||||
QFont font = defaultModelFont();
|
QFont font = defaultModelFont();
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
|
@ -235,13 +250,14 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case START:
|
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());
|
cyl->start = string_to_pressure(vString.toUtf8().data());
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case END:
|
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());
|
cyl->end = string_to_pressure(vString.toUtf8().data());
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue