aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-26 21:34:45 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-26 21:34:45 -0800
commitdc0be271bd0d4f9823eb5212287f1a74cbecc2f7 (patch)
tree068e53120608d1795373863f0e2b0f8d81a0edb9
parentdce3869339563c31e6c6fdf267e803eca4d134ea (diff)
downloadsubsurface-dc0be271bd0d4f9823eb5212287f1a74cbecc2f7.tar.gz
QML UI: set up time and dive number when adding dive
Most likely when you manually add a dive on a device it is just about to happen or just ended, so starting out with the current time is likely a good guess. Which makes it the last dive in the dive list, so give it the next sequential number. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-models/divelistmodel.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp
index 114cd6d1f..fcdc0dfab 100644
--- a/qt-models/divelistmodel.cpp
+++ b/qt-models/divelistmodel.cpp
@@ -1,5 +1,6 @@
#include "divelistmodel.h"
#include "helpers.h"
+#include <QDateTime>
DiveListModel *DiveListModel::m_instance = NULL;
@@ -118,11 +119,18 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
return roles;
}
+// create a new dive. set the current time and add it to the end of the dive list
void DiveListModel::startAddDive()
{
struct dive *d;
d = alloc_dive();
- add_single_dive(get_divenr(d), d);
+ d->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset();
+ struct dive *pd = get_dive(dive_table.nr - 1);
+ int nr = 1;
+ if (pd && pd->number > 0)
+ nr = pd->number + 1;
+ d->number = nr;
+ add_single_dive(-1, d);
addDive(d);
}