Mobile: improve helper function to track selected dives

While on mobile there should always be only one selected dive, it's very
cheap to make sure that amount_selected is tracked correctly.  The
incrementing of amount_selected is done in case an invalid id is passed
in.

Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2019-10-12 15:30:11 -07:00
parent 4fb2f89bb5
commit 5f11c94f02

View file

@ -1378,10 +1378,17 @@ bool QMLManager::undoDelete(int id)
void QMLManager::selectDive(int id)
{
int i;
extern int amount_selected;
struct dive *dive = NULL;
for_each_dive (i, dive)
amount_selected = 0;
for_each_dive (i, dive) {
dive->selected = (dive->id == id);
if (dive->selected)
amount_selected++;
}
if (amount_selected == 0)
qWarning("QManager::selectDive() called with unknown id");
}
void QMLManager::deleteDive(int id)