mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
QML UI: pick new highest dive number when manually adding dive
It's possible that this will create an out of order dive list, but it seems the most consistent way to do things and to avoid more than one dive with the same dive number (which could have happened if you add several dives manually that are not the newest dives in the dive list). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
a1aa83fcfd
commit
16c082112c
1 changed files with 9 additions and 4 deletions
|
@ -119,10 +119,15 @@ QString DiveListModel::startAddDive()
|
|||
struct dive *d;
|
||||
d = alloc_dive();
|
||||
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;
|
||||
|
||||
// find the highest dive nr we have and pick the next one
|
||||
struct dive *pd;
|
||||
int i, nr = 0;
|
||||
for_each_dive(i, pd) {
|
||||
if (pd->number > nr)
|
||||
nr = pd->number;
|
||||
}
|
||||
nr++;
|
||||
d->number = nr;
|
||||
d->dc.model = strdup("manually added dive");
|
||||
add_single_dive(-1, d);
|
||||
|
|
Loading…
Reference in a new issue