summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar jan Iversen <jan@casacondor.com>2019-12-09 12:18:33 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-12-11 12:36:43 -0500
commit10ab833d7dc00da13aa0cf0f0490bae63cb1294a (patch)
tree7d4dece6bb1d1090ec7d0a0fd9b031faedbbd28d
parent2f680c1f765abcd0b25ceae46de2b4960f0d1b8d (diff)
downloadsubsurface-10ab833d7dc00da13aa0cf0f0490bae63cb1294a.tar.gz
core: make uploadDiveLogsDE slots workable for desktop
Secure that the slots/signals in uploadDiveLogsDE, which are without UI, can be used in DivelogsDeWebServices (to add the UI part). Signed-off-by: Jan Iversen <jan@casacondor.com>
-rw-r--r--core/uploadDiveLogsDE.cpp23
-rw-r--r--core/uploadDiveLogsDE.h2
2 files changed, 17 insertions, 8 deletions
diff --git a/core/uploadDiveLogsDE.cpp b/core/uploadDiveLogsDE.cpp
index 1d085529a..29877af70 100644
--- a/core/uploadDiveLogsDE.cpp
+++ b/core/uploadDiveLogsDE.cpp
@@ -261,13 +261,14 @@ void uploadDiveLogsDE::updateProgressSlot(qint64 current, qint64 total)
{
if (!reply)
return;
+
if (total <= 0 || current <= 0)
return;
- // Calculate percentage
+ // Calculate percentage as 0.x (values between 0.0 and 1.0)
// And signal whoever wants to know
qreal percentage = (float)current / (float)total;
- emit uploadProgress(percentage);
+ emit uploadProgress(percentage, 1.0);
// reset the timer: 30 seconds after we last got any data
timeout.start();
@@ -295,38 +296,46 @@ void uploadDiveLogsDE::uploadFinishedSlot()
report_error(tr("Upload failed").toUtf8());
return;
}
+ timeout.stop();
err = tr("Upload successful");
emit uploadFinish(true, err);
- timeout.stop();
return;
}
+ timeout.stop();
err = tr("Login failed");
report_error(err.toUtf8());
emit uploadFinish(false, err);
- timeout.stop();
return;
}
+ timeout.stop();
err = tr("Cannot parse response");
report_error(tr("Cannot parse response").toUtf8());
emit uploadFinish(false, err);
- timeout.stop();
}
}
void uploadDiveLogsDE::uploadTimeoutSlot()
{
+ timeout.stop();
+ if (reply) {
+ reply->deleteLater();
+ reply = NULL;
+ }
QString err(tr("divelogs.de not responding"));
report_error(err.toUtf8());
emit uploadFinish(false, err);
- timeout.stop();
}
void uploadDiveLogsDE::uploadErrorSlot(QNetworkReply::NetworkError error)
{
+ timeout.stop();
+ if (reply) {
+ reply->deleteLater();
+ reply = NULL;
+ }
QString err(tr("network error %1").arg(error));
report_error(err.toUtf8());
emit uploadFinish(false, err);
- timeout.stop();
}
diff --git a/core/uploadDiveLogsDE.h b/core/uploadDiveLogsDE.h
index 83bb813d6..48491d06e 100644
--- a/core/uploadDiveLogsDE.h
+++ b/core/uploadDiveLogsDE.h
@@ -24,7 +24,7 @@ private slots:
signals:
void uploadFinish(bool success, const QString &text);
- void uploadProgress(qreal percentage);
+ void uploadProgress(qreal percentage, qreal total);
private:
uploadDiveLogsDE();