summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-06 17:10:32 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-06 17:13:03 -0800
commit93b5c0cd14fe33c80b801a0177e795462484f719 (patch)
treef3ebd4dcf43d363416352d3562b5ea82a999c694 /qt-ui
parent3a0f1380232561147385dca5ac2de3de8ab731bf (diff)
downloadsubsurface-93b5c0cd14fe33c80b801a0177e795462484f719.tar.gz
Finish download from divelogs.de
This is far from perfect. Avoid a weird warning when total = -1 is passed into the progress bar. Enable the Accept button once the download completes. Merge the downloaded dives into the existing dive list on Apply. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/subsurfacewebservices.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index 8699a23da..977e59fde 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -150,7 +150,9 @@ void WebServices::updateProgress(qint64 current, qint64 total)
{
if (!reply)
return;
-
+ if (total == -1) {
+ total = INT_MAX / 2 - 1;
+ }
if (total >= INT_MAX / 2) {
// over a gigabyte!
if (total >= Q_INT64_C(1) << 47) {
@@ -616,20 +618,8 @@ void DivelogsDeWebServices::downloadFinished()
zipFile.close();
return;
}
-
- quint64 entries = zip_get_num_entries(zip, 0);
- for (quint64 i = 0; i < entries; ++i) {
- struct zip_file *zip_file = zip_fopen_index(zip, i, 0);
- if (!zip_file) {
- QMessageBox::critical(this, tr("Corrupted download"),
- tr("The archive contains corrupt data:\n%1").arg(QString::fromLocal8Bit(zip_strerror(zip))));
- goto close_zip;
- }
-
- // ### FIXME: What do I do with this?
-
- zip_fclose(zip_file);
- }
+ // now allow the user to cancel or accept
+ ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
close_zip:
zip_close(zip);
@@ -672,6 +662,22 @@ void DivelogsDeWebServices::uploadError(QNetworkReply::NetworkError error)
void DivelogsDeWebServices::buttonClicked(QAbstractButton* button)
{
+ ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
+ switch(ui.buttonBox->buttonRole(button)){
+ case QDialogButtonBox::ApplyRole:{
+ char *errorptr = NULL;
+ parse_file(zipFile.fileName().toUtf8().constData(), &errorptr);
+ // ### FIXME: do something useful with the error - but there shouldn't be one, right?
+ if (errorptr)
+ qDebug() << errorptr;
+
+ hide();
+ close();
+ resetState();
+ mark_divelist_changed(TRUE);
+ mainWindow()->refreshDisplay();
+ }
+ }
}