From bfe61b2dff823d8f1a6ddadcdb88106788c41565 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Fri, 22 Sep 2023 23:35:17 +0200 Subject: [PATCH] Add dive mode as possible column Signed-off-by: Anton Lundin --- CHANGELOG.md | 1 + qt-models/divetripmodel.cpp | 9 +++++++++ qt-models/divetripmodel.h | 1 + 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f001c750..954f3abf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +desktop: add divemode as a possible dive list column desktop: hide only events with the same severity when 'Hide similar events' is used equipment: mark gas mixes reported by the dive computer as 'inactive' as 'not used' equipment: include unused cylinders in merged dive if the preference is enabled diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index d1631e4b0..8ecd16f9e 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -59,6 +59,7 @@ static QVariant dive_table_alignment(int column) case DiveTripModelBase::DIVEGUIDE: case DiveTripModelBase::LOCATION: case DiveTripModelBase::NOTES: + case DiveTripModelBase::DIVEMODE: return int(Qt::AlignLeft | Qt::AlignVCenter); } return QVariant(); @@ -260,6 +261,8 @@ QString DiveTripModelBase::getDescription(int column) return tr("Location"); case NOTES: return tr("Notes"); + case DIVEMODE: + return tr("Divemode"); default: return QString(); } @@ -359,6 +362,8 @@ QVariant DiveTripModelBase::diveData(const struct dive *d, int column, int role) return formatDiveGasString(d); case NOTES: return QString(d->notes); + case DIVEMODE: + return QString(divemode_text_ui[(int)d->dc.divemode]); } break; case Qt::DecorationRole: @@ -449,6 +454,8 @@ QVariant DiveTripModelBase::headerData(int section, Qt::Orientation orientation, return tr("Location"); case NOTES: return tr("Notes"); + case DIVEMODE: + return tr("Divemode"); } break; case Qt::ToolTipRole: @@ -1778,5 +1785,7 @@ bool DiveTripModelList::lessThan(const QModelIndex &i1, const QModelIndex &i2) c return lessThanHelper(strCmp(get_dive_location(d1), get_dive_location(d2)), row_diff); case NOTES: return lessThanHelper(strCmp(d1->notes, d2->notes), row_diff); + case DIVEMODE: + return lessThanHelper((int)d1->dc.divemode - (int)d2->dc.divemode, row_diff); } } diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h index 2ff449bef..63e4a5410 100644 --- a/qt-models/divetripmodel.h +++ b/qt-models/divetripmodel.h @@ -44,6 +44,7 @@ public: COUNTRY, LOCATION, NOTES, + DIVEMODE, COLUMNS };