From e9ba8f0ff60144dd71bfb4e305a3a41dde2722f5 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 20 Apr 2015 22:11:43 -0700 Subject: Download dialog: we can accept a partial download after an error The dialog didn't accept "OK" and store the dives downloaded / selected so far if there had been an error. Especially with partial downloads from the Uemis SDA this is something that is quite reasonable to want to do, so allow exiting the dialog with OK even after an error. Signed-off-by: Dirk Hohndel --- qt-ui/downloadfromdivecomputer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index cd3dd90d0..c7a48c46b 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -420,7 +420,7 @@ void DownloadFromDCWidget::on_ok_clicked() { struct dive *dive; - if (currentState != DONE) + if (currentState != DONE && currentState != ERROR) return; // record all the dives in the 'real' dive_table -- cgit v1.2.3-70-g09d2 From 8bbb3dfe4241b200cc37420ed45d7303a99c8b27 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 20 Apr 2015 22:30:04 -0700 Subject: Uemis downloader: allow continuing download by clicking Retry When we run out of space in the Uemis filesystem we return an error. The user could reasonably unplug the SDA, insert it again and then retry to continue the download (that's what we tell them to do). In that case we need to make sure we start at the correct dive otherwise the same dives keep getting downloaded over and over again. Signed-off-by: Dirk Hohndel --- qt-ui/downloadfromdivecomputer.cpp | 11 +++++++++++ uemis-downloader.c | 9 ++++++++- uemis.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index c7a48c46b..04c78b998 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -1,6 +1,9 @@ #include "downloadfromdivecomputer.h" #include "helpers.h" #include "mainwindow.h" +#include "divelistview.h" +#include "display.h" +#include "uemis.h" #include #include @@ -282,6 +285,14 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked() diveImportedModel->clearTable(); clear_table(&downloadTable); } + if (ui.vendor->currentText() == "Uemis") { + if (currentState == ERROR && downloadTable.nr > 0) + // let the uemis code know how far we've gotten + uemis_set_max_diveid_from_dialog(downloadTable.dives[downloadTable.nr - 1]->dc.diveid); + else + // fresh download, so only look at what's in the dive_table + uemis_set_max_diveid_from_dialog(0); + } updateState(DOWNLOADING); // you cannot cancel the dialog, just the download diff --git a/uemis-downloader.c b/uemis-downloader.c index adf555a7c..64fb1c6da 100644 --- a/uemis-downloader.c +++ b/uemis-downloader.c @@ -814,6 +814,13 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char * return true; } +static int max_diveid_from_dialog; + +void uemis_set_max_diveid_from_dialog(int diveid) +{ + max_diveid_from_dialog = diveid; +} + static char *uemis_get_divenr(char *deviceidstr) { uint32_t deviceid, maxdiveid = 0; @@ -831,7 +838,7 @@ static char *uemis_get_divenr(char *deviceidstr) maxdiveid = dc->diveid; } } - snprintf(divenr, 10, "%d", maxdiveid); + snprintf(divenr, 10, "%d", maxdiveid > max_diveid_from_dialog ? maxdiveid : max_diveid_from_dialog); return strdup(divenr); } diff --git a/uemis.h b/uemis.h index 32c4bdc24..7a12b1ee9 100644 --- a/uemis.h +++ b/uemis.h @@ -16,6 +16,7 @@ void uemis_parse_divelog_binary(char *base64, void *divep); int uemis_get_weight_unit(int diveid); void uemis_mark_divelocation(int diveid, int divespot, char **location, degrees_t *latitude, degrees_t *longitude); void uemis_set_divelocation(int divespot, char *text, double longitude, double latitude); +void uemis_set_max_diveid_from_dialog(int diveid); typedef struct { -- cgit v1.2.3-70-g09d2 From 5810aedeac5cbcc2500d6bbe9c65aea6b1c40a8c Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 30 Apr 2015 16:35:46 -0700 Subject: Uemis downloader: clean up the path for Windows mount point Oops, we left the (UEMISSDA) in the path. This can never have worked without the user manually correcting it to just show the drive letter. Signed-off-by: Dirk Hohndel --- qt-ui/downloadfromdivecomputer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index 04c78b998..c59fb0d7b 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -305,10 +305,20 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked() thread->deleteLater(); } - data.devname = strdup(ui.device->currentText().toUtf8().data()); data.vendor = strdup(ui.vendor->currentText().toUtf8().data()); data.product = strdup(ui.product->currentText().toUtf8().data()); + if (same_string(data.vendor, "Uemis")) { + char *colon; + char *devname = strdup(ui.device->currentText().toUtf8().data()); + if ((colon = strstr(devname, ":\\ (UEMISSDA)")) != NULL) { + *(colon + 2) = '\0'; + fprintf(stderr, "shortened devname to \"%s\"", data.devname); + } + data.devname = devname; + } else { + data.devname = strdup(ui.device->currentText().toUtf8().data()); + } data.descriptor = descriptorLookup[ui.vendor->currentText() + ui.product->currentText()]; data.force_download = ui.forceDownload->isChecked(); data.create_new_trip = ui.createNewTrip->isChecked(); -- cgit v1.2.3-70-g09d2 From 02ed0ccabb88118f0e1fb56d1ef57d247fedebdc Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 2 May 2015 12:18:12 -0700 Subject: Improve multi dive tag list edits The old behavior was kind of crude. Just smack the tags that were on the displayed dive on all selected dives. This seems to make more sense. We figure out which tags were added to the displayed dive and add them to all selected dives. And we remove all tags that were removed from the displayed dive from all selected dives. Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 88cfd8849..2fafb65ff 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -1091,23 +1091,49 @@ void MainTab::on_timeEdit_timeChanged(const QTime &time) } // changing the tags on multiple dives is semantically strange - what's the right thing to do? +// here's what I think... add the tags that were added to the displayed dive and remove the tags +// that were removed from it void MainTab::saveTags() { struct dive *cd = current_dive; + struct tag_entry *added_list = NULL; + struct tag_entry *removed_list = NULL; + struct tag_entry *tl; + taglist_free(displayed_dive.tag_list); displayed_dive.tag_list = NULL; Q_FOREACH (const QString& tag, ui.tagWidget->getBlockStringList()) taglist_add_tag(&displayed_dive.tag_list, tag.toUtf8().data()); taglist_cleanup(&displayed_dive.tag_list); + + // figure out which tags were added and which tags were removed + added_list = taglist_added(cd->tag_list, displayed_dive.tag_list); + removed_list = taglist_added(displayed_dive.tag_list, cd->tag_list); + // dump_taglist("added tags:", added_list); + // dump_taglist("removed tags:", removed_list); + // we need to check if the tags were changed before just overwriting them - if (taglist_equal(displayed_dive.tag_list, cd->tag_list)) + if (added_list == NULL && removed_list == NULL) return; + MODIFY_SELECTED_DIVES( - QString tag; + // create a new tag list and all the existing tags that were not + // removed and then all the added tags + struct tag_entry *new_tag_list; + new_tag_list = NULL; + tl = mydive->tag_list; + while (tl) { + if (!taglist_contains(removed_list, tl->tag->name)) + taglist_add_tag(&new_tag_list, tl->tag->name); + tl = tl->next; + } + tl = added_list; + while (tl) { + taglist_add_tag(&new_tag_list, tl->tag->name); + tl = tl->next; + } taglist_free(mydive->tag_list); - mydive->tag_list = NULL; - Q_FOREACH (tag, ui.tagWidget->getBlockStringList()) - taglist_add_tag(&mydive->tag_list, tag.toUtf8().data()); + mydive->tag_list = new_tag_list; ); } -- cgit v1.2.3-70-g09d2