8#include <QtCore/QObject>
10#include <QtNetwork/QNetworkReply>
11#include <QtNetwork/QNetworkRequest>
13class QNetworkAccessManager;
14class QAbstractNetworkCache;
118 QUrl
url()
const {
return _url; }
134 void setCache(QAbstractNetworkCache *cache);
146 bool start(
const QString &remoteUrl);
205 void _onDownloadFinished();
206 void _onDownloadError(QNetworkReply::NetworkError code);
207 void _onDecompressionFinished(
bool success);
211 void _setState(
State newState);
213 void _setErrorString(
const QString &
error);
215 void _emitFinished(
bool success,
const QString &
localPath,
const QString &errorMessage);
216 bool _writeReplyData(
const QByteArray &data);
217 bool _failForWriteError(
const QString &context);
218 QString _generateOutputPath(
const QString &remoteUrl)
const;
220 void _startDecompression();
222 QNetworkAccessManager *_networkManager =
nullptr;
223 QNetworkReply *_currentReply =
nullptr;
225 QFile *_outputFile =
nullptr;
230 QString _expectedHash;
231 QString _errorString;
232 QString _compressedFilePath;
234 qreal _progress = 0.0;
235 qint64 _totalBytes = -1;
236 qint64 _bytesReceived = 0;
240 bool _autoDecompress =
false;
241 bool _finishEmitted =
false;
242 bool _lastResultFromCache =
false;
QObject wrapper for compression operations with progress signals.
File download with progress, decompression, and hash verification.
State
Current download progress (0.0 to 1.0)
@ Completed
Download completed successfully.
@ Verifying
Verifying file hash.
@ Cancelled
Download was cancelled.
@ Decompressing
Decompressing downloaded file.
@ Downloading
Actively downloading.
@ Idle
No download in progress.
void setTimeout(int timeoutMs)
Set request timeout in milliseconds.
void finished(bool success, const QString &localPath, const QString &errorMessage)
void setExpectedHash(const QString &hash)
void localPathChanged(const QString &localPath)
Emitted when local path changes.
void runningChanged(bool running)
Emitted when running state changes.
bool autoDecompress() const
void totalBytesChanged(qint64 totalBytes)
Emitted when total bytes changes.
qint64 totalBytes() const
void stateChanged(State state)
Emitted when state changes.
void autoDecompressChanged(bool autoDecompress)
Emitted when auto-decompress setting changes.
QString localPath() const
qint64 bytesReceived() const
bool start(const QString &remoteUrl)
void setCache(QAbstractNetworkCache *cache)
Set network cache for downloads.
void bytesReceivedChanged(qint64 bytesReceived)
Emitted when bytes received changes.
void errorStringChanged(const QString &errorString)
Emitted when error string changes.
QNetworkAccessManager * networkManager() const
Get the network access manager (for advanced configuration)
QString outputPath() const
void setOutputPath(const QString &path)
QString errorString() const
void setAutoDecompress(bool enabled)
QString expectedHash() const
void cancel()
Cancel current download.
void progressChanged(qreal progress)
Emitted when download progress changes.
void expectedHashChanged(const QString &expectedHash)
Emitted when expected hash setting changes.
void downloadProgress(qint64 bytesReceived, qint64 totalBytes)
Emitted during download with byte counts.
void outputPathChanged(const QString &outputPath)
Emitted when output path setting changes.
~QGCFileDownload() override
void urlChanged(const QUrl &url)
Emitted when URL changes.
void decompressionProgress(qreal progress)
Emitted during decompression (0.0 to 1.0)
bool lastResultFromCache() const
constexpr int kDefaultTimeoutMs
Default request timeout in milliseconds.
Common request configuration options.