From ca336d13e52ccde64f2d0e2962ee7dbd3fbea4f1 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 13 Dec 2019 06:33:12 +0100 Subject: [PATCH] Dive list: add option to mark dives valid If the dive the user clicked on is invalid show an option to make the dive valid. Signed-off-by: Berthold Stoeger --- desktop-widgets/divelistview.cpp | 10 +++++++++- desktop-widgets/divelistview.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index 7050863bf..9407fa3f0 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -841,6 +841,11 @@ void DiveListView::markDiveInvalid() Command::editInvalid(true, false); } +void DiveListView::markDiveValid() +{ + Command::editInvalid(false, false); +} + void DiveListView::deleteDive() { struct dive *d = contextMenuIndex.data(DiveTripModelBase::DIVE_ROLE).value(); @@ -920,7 +925,10 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event) } if (d) { popup.addAction(tr("Delete dive(s)"), this, &DiveListView::deleteDive); - popup.addAction(tr("Mark dive(s) invalid"), this, &DiveListView::markDiveInvalid); + if (d->invalid) + popup.addAction(tr("Mark dive(s) valid"), this, &DiveListView::markDiveValid); + else + popup.addAction(tr("Mark dive(s) invalid"), this, &DiveListView::markDiveInvalid); } if (amount_selected > 1 && consecutive_selected()) popup.addAction(tr("Merge selected dives"), this, &DiveListView::mergeDives); diff --git a/desktop-widgets/divelistview.h b/desktop-widgets/divelistview.h index 275e26779..a0ead2de3 100644 --- a/desktop-widgets/divelistview.h +++ b/desktop-widgets/divelistview.h @@ -47,6 +47,7 @@ slots: void removeFromTrip(); void deleteDive(); void markDiveInvalid(); + void markDiveValid(); void rowsInserted(const QModelIndex &parent, int start, int end) override; void reset() override; void mergeTripAbove();