mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
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>
This commit is contained in:
parent
dce3869339
commit
dc0be271bd
1 changed files with 9 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue