Core: let count_divecomputers() operate on an arbitrary dive

Currently, count_divecomputers only works on the current_dive.
Instead, let it take a pointer to an arbitrary dive. This is
in preparation for being smarter in the undo code concerning
which dive computer to show on deletion.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-05-19 18:40:04 +02:00 committed by Dirk Hohndel
parent ac590235c9
commit 4fe9b39cdb
3 changed files with 6 additions and 7 deletions

View file

@ -1430,13 +1430,13 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
parentItem = parentItem->parentItem();
}
if (isDCName) {
if (dc_number == 0 && count_divecomputers() == 1)
if (dc_number == 0 && count_divecomputers(current_dive) == 1)
// nothing to do, can't delete or reorder
return;
// create menu to show when right clicking on dive computer name
if (dc_number > 0)
m.addAction(tr("Make first dive computer"), this, SLOT(makeFirstDC()));
if (count_divecomputers() > 1) {
if (count_divecomputers(current_dive) > 1) {
m.addAction(tr("Delete this dive computer"), this, SLOT(deleteCurrentDC()));
m.addAction(tr("Split this dive computer into own dive"), this, SLOT(splitCurrentDC()));
}