地面站终端 App
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB

/****************************************************************************
*
* (c) 2022 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#pragma once
#include "QGCFileDownload.h"
#include <QNetworkDiskCache>
class QGCCachedFileDownload : public QObject
{
Q_OBJECT
public:
QGCCachedFileDownload(QObject* parent, const QString& cacheDirectory);
/// Download the specified remote file.
/// @param url File to download
/// @param maxCacheAgeSec Maximum age of cached item in seconds
/// @return true: Asynchronous download has started, false: Download initialization failed
bool download(const QString& url, int maxCacheAgeSec);
signals:
void downloadProgress(qint64 curr, qint64 total);
void downloadComplete(QString remoteFile, QString localFile, QString errorMsg);
private:
void onDownloadCompleted(QString remoteFile, QString localFile, QString errorMsg);
QGCFileDownload* _fileDownload;
QNetworkDiskCache* _diskCache;
bool _downloadFromNetwork{false};
};