diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-05-19 14:25:35 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-19 20:12:59 +0900 |
commit | eaa4e5948ab8506a2a6126a574922b011146d7b7 (patch) | |
tree | d31cf5bb420b77ec73fbe6f4a70ae875c5571de3 /qt-ui/downloadfromdivecomputer.cpp | |
parent | 4059180ef275e527b33c2b3d7153adcc24d82096 (diff) | |
download | subsurface-eaa4e5948ab8506a2a6126a574922b011146d7b7.tar.gz |
Make the code easier to read
This uses the new helper function from commit fc4f133f19d0 ("Add new
helper function that looks up the index of a dive by its uniq ID") to make
the logic implemented in commit 122593a63a46 ("Fix selection after
downloading dives from the dive computer") much saner to read.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/downloadfromdivecomputer.cpp')
-rw-r--r-- | qt-ui/downloadfromdivecomputer.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index a341a0c37..9760d1107 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -383,22 +383,17 @@ void DownloadFromDCWidget::onDownloadThreadFinished() for (int i = dive_table.nr - 1; i >= previousLast; i--) delete_single_dive(i); } else if (dive_table.nr) { - int i; - struct dive *d; + int uniqId, idx; // remember the last downloaded dive (on most dive computers this will be the chronologically // first new dive) and select it again after processing all the dives MainWindow::instance()->dive_list()->unselectDives(); - get_dive(dive_table.nr - 1)->selected = true; + uniqId = get_dive(dive_table.nr - 1)->id; process_dives(true, preferDownloaded()); // after process_dives does any merging or resorting needed, we need // to recreate the model for the dive list so we can select the newest dive MainWindow::instance()->recreateDiveList(); - for_each_dive(i, d) { - if (d->selected) - break; - } - d->selected = false; - MainWindow::instance()->dive_list()->selectDive(i, true); + idx = get_idx_by_uniq_id(uniqId); + MainWindow::instance()->dive_list()->selectDive(idx, true); } } else if (currentState == CANCELLING || currentState == CANCELLED){ if (import_thread_cancelled) { |