summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-09-29 23:29:53 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-03 10:01:13 -0700
commit7b196a5ef90ee96435ea762c7045ef47a6811a28 (patch)
treee23e71d1d83f47f1c9d66a2f79b179c4d34edd50
parentf5fe6839c7672f775e35068f46fbb2d2e41b8bf5 (diff)
downloadsubsurface-7b196a5ef90ee96435ea762c7045ef47a6811a28.tar.gz
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 <bstoeger@mail.tuwien.ac.at>
-rw-r--r--CHANGELOG.md1
-rw-r--r--desktop-widgets/divelistview.cpp12
-rw-r--r--desktop-widgets/divelistview.h1
3 files changed, 14 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fb1193eda..7b9095728 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,4 @@
+- desktop: allow adding dives to arbitrary trips
- desktop: respect page-up, page-down, home and end keys for selection change [#2957]
- Use pO2 from prefernces for MOD display in equipment tab
- filter: more flexible filtering system based on individual constraints
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<dive *> dives = getDiveSelection();
+ if (!t || dives.empty())
+ return;
+ Command::addDivesToTrip(QVector<dive *>::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);
diff --git a/desktop-widgets/divelistview.h b/desktop-widgets/divelistview.h
index f1a5eba8d..17cff4b02 100644
--- a/desktop-widgets/divelistview.h
+++ b/desktop-widgets/divelistview.h
@@ -50,6 +50,7 @@ slots:
void mergeDives();
void splitDives();
void renumberDives();
+ void addDivesToTrip();
void shiftTimes();
void diveSelectionChanged(const QVector<QModelIndex> &indices);
void currentDiveChanged(QModelIndex index);