aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/downloadfromdivecomputer.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-18 19:08:58 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-19 20:12:59 +0900
commit5e3f7ba22fe2dcb8af597d011bba16b3a7317c2a (patch)
tree59093563a68a469edcc1013cb8c4fc473e605273 /qt-ui/downloadfromdivecomputer.cpp
parentb36c8f07c7019fac1bc72d3b44a4486ea6d3458d (diff)
downloadsubsurface-5e3f7ba22fe2dcb8af597d011bba16b3a7317c2a.tar.gz
Fix selection after downloading dives from the dive computer
If we successfully download dives, the old selection should be cleared and the one of the newly downloaded dives should be selected. I decided to pick the last dive downloaded, which for most dive computers (but for example not for the Uemis SDA) will be the first or earliest of the dives. That seems much more intuitive than keeping the previous selection around. Of course this is harder than it should be because of the way we track selections and because we need a consistent dive list model in order to change the selection. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/downloadfromdivecomputer.cpp')
-rw-r--r--qt-ui/downloadfromdivecomputer.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index 8c0f81aa5..a341a0c37 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -382,8 +382,23 @@ void DownloadFromDCWidget::onDownloadThreadFinished()
// down in the dive_table
for (int i = dive_table.nr - 1; i >= previousLast; i--)
delete_single_dive(i);
- } else {
+ } else if (dive_table.nr) {
+ int i;
+ struct dive *d;
+ // 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;
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);
}
} else if (currentState == CANCELLING || currentState == CANCELLED){
if (import_thread_cancelled) {