Changeset View
Changeset View
Standalone View
Standalone View
host/downloadjob.cpp
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | 100 | if (it != end) { | |||
---|---|---|---|---|---|
103 | setProperty("destUrl", destination.toString(QUrl::RemoveFilename | QUrl::StripTrailingSlash)); | 103 | setProperty("destUrl", destination.toString(QUrl::RemoveFilename | QUrl::StripTrailingSlash)); | ||
104 | 104 | | |||
105 | m_destination = destination; | 105 | m_destination = destination; | ||
106 | descriptionDirty = true; | 106 | descriptionDirty = true; | ||
107 | } | 107 | } | ||
108 | 108 | | |||
109 | it = payload.constFind(QStringLiteral("totalBytes")); | 109 | it = payload.constFind(QStringLiteral("totalBytes")); | ||
110 | if (it != end) { | 110 | if (it != end) { | ||
111 | setTotalAmount(Bytes, it->toDouble()); | 111 | const qlonglong totalAmount = it->toDouble(); | ||
112 | if (totalAmount > -1) { | ||||
113 | setTotalAmount(Bytes, totalAmount); | ||||
114 | } | ||||
fvogt: To avoid casting and rounding errors later on, I suggest to use `const qlonglong totalAmount =… | |||||
112 | } | 115 | } | ||
113 | 116 | | |||
114 | it = payload.constFind(QStringLiteral("bytesReceived")); | 117 | it = payload.constFind(QStringLiteral("bytesReceived")); | ||
115 | if (it != end) { | 118 | if (it != end) { | ||
116 | setProcessedAmount(Bytes, it->toDouble()); | 119 | setProcessedAmount(Bytes, it->toDouble()); | ||
117 | } | 120 | } | ||
118 | 121 | | |||
119 | setTotalAmount(Files, 1); | 122 | setTotalAmount(Files, 1); | ||
▲ Show 20 Lines • Show All 114 Lines • Show Last 20 Lines |
To avoid casting and rounding errors later on, I suggest to use const qlonglong totalAmount = it->toDouble(); here.