From 7b196a5ef90ee96435ea762c7045ef47a6811a28 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 29 Sep 2020 23:29:53 +0200 Subject: desktop: allow moving dives to arbitrary trips The UI only allowed adding dives to trips above or below the current dive (and even that is buggy). This is a strange restriction, since trips are designed to be non-contiguous. Allow adding dives to any trip using the new trip selection dialog. The undo-command is already there, so only little code to write. This feature was requested on the mailing list. Signed-off-by: Berthold Stoeger --- desktop-widgets/divelistview.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'desktop-widgets/divelistview.cpp') diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index 390c78216..0a95005a6 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -24,6 +24,7 @@ #include "core/metrics.h" #include "desktop-widgets/simplewidgets.h" #include "desktop-widgets/mapwidget.h" +#include "desktop-widgets/tripselectiondialog.h" DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), currentLayout(DiveTripModelBase::TREE), @@ -650,6 +651,16 @@ void DiveListView::splitDives() Command::splitDives(d, duration_t{-1}); } +void DiveListView::addDivesToTrip() +{ + TripSelectionDialog dialog(MainWindow::instance()); + dive_trip *t = dialog.getTrip(); + std::vector dives = getDiveSelection(); + if (!t || dives.empty()) + return; + Command::addDivesToTrip(QVector::fromStdVector(dives), t); +} + void DiveListView::renumberDives() { RenumberDialog dialog(true, MainWindow::instance()); @@ -845,6 +856,7 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event) if (amount_selected > 1 && consecutive_selected()) popup.addAction(tr("Merge selected dives"), this, &DiveListView::mergeDives); if (amount_selected >= 1) { + popup.addAction(tr("Add dive(s) to arbitrary trip"), this, &DiveListView::addDivesToTrip); popup.addAction(tr("Renumber dive(s)"), this, &DiveListView::renumberDives); popup.addAction(tr("Shift dive times"), this, &DiveListView::shiftTimes); popup.addAction(tr("Split selected dives"), this, &DiveListView::splitDives); -- cgit v1.2.3-70-g09d2