summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2015-05-18 10:52:03 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-18 13:53:18 -0700
commit67304056245cf3943c5084bd8ca47c82194563a5 (patch)
treef245c4298e06e0ff8d69d19840e3bfae9ed801bb
parent043bd3afb720870d2c3b4b9b0b1437b53e3b2f38 (diff)
downloadsubsurface-67304056245cf3943c5084bd8ca47c82194563a5.tar.gz
Ask user about merging dives more than 30m apart
...and remember the answer. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/divelistview.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 3c63bea50..16033dca9 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -16,6 +16,7 @@
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QStandardPaths>
+#include <QMessageBox>
#include "qthelper.h"
#include "undocommands.h"
#include "divelistview.h"
@@ -566,15 +567,32 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS
Q_EMIT currentDiveChanged(selected_dive);
}
-static bool can_merge(const struct dive *a, const struct dive *b)
+enum asked_user {NOTYET, MERGE, DONTMERGE};
+
+static bool can_merge(const struct dive *a, const struct dive *b, enum asked_user *have_asked)
{
if (!a || !b)
return false;
if (a->when > b->when)
return false;
/* Don't merge dives if there's more than half an hour between them */
- if (a->when + a->duration.seconds + 30 * 60 < b->when)
- return false;
+ if (a->when + a->duration.seconds + 30 * 60 < b->when) {
+ if (*have_asked == NOTYET) {
+ if (QMessageBox::warning(MainWindow::instance(),
+ MainWindow::instance()->tr("Warning"),
+ MainWindow::instance()->tr("Trying to merge dives with %1min interval in between").arg(
+ (b->when - a->when - a->duration.seconds) / 60),
+ QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) {
+ *have_asked = DONTMERGE;
+ return false;
+ } else {
+ *have_asked = MERGE;
+ return true;
+ }
+ } else {
+ return *have_asked == MERGE ? true : false;
+ }
+ }
return true;
}
@@ -582,10 +600,11 @@ void DiveListView::mergeDives()
{
int i;
struct dive *dive, *maindive = NULL;
+ enum asked_user have_asked = NOTYET;
for_each_dive (i, dive) {
if (dive->selected) {
- if (!can_merge(maindive, dive)) {
+ if (!can_merge(maindive, dive, &have_asked)) {
maindive = dive;
} else {
maindive = merge_two_dives(maindive, dive);