AssetDownloader: Implement the downloader using TaskTree
Task-number: QTBUG-122550 Change-Id: I990d0db1c5f0246aab0d796f438b26976650dc2c Reviewed-by: Ali Kianian <ali.kianian@qt.io> Reviewed-by: Kai Köhne <kai.koehne@qt.io> (cherry picked from commit 6dff842b2a55cc941e7868a12c725e0a8c6afdb1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
355f68bc4a
commit
4285216860
@ -4,7 +4,6 @@
|
|||||||
qt_internal_add_module(ExamplesAssetDownloaderPrivate
|
qt_internal_add_module(ExamplesAssetDownloaderPrivate
|
||||||
CONFIG_MODULE_NAME examples_asset_downloader
|
CONFIG_MODULE_NAME examples_asset_downloader
|
||||||
STATIC
|
STATIC
|
||||||
EXCEPTIONS
|
|
||||||
INTERNAL_MODULE
|
INTERNAL_MODULE
|
||||||
SOURCES
|
SOURCES
|
||||||
assetdownloader.cpp assetdownloader.h
|
assetdownloader.cpp assetdownloader.h
|
||||||
@ -15,11 +14,13 @@ qt_internal_add_module(ExamplesAssetDownloaderPrivate
|
|||||||
tasking/tasking_global.h
|
tasking/tasking_global.h
|
||||||
tasking/tasktree.cpp tasking/tasktree.h
|
tasking/tasktree.cpp tasking/tasktree.h
|
||||||
tasking/tasktreerunner.cpp tasking/tasktreerunner.h
|
tasking/tasktreerunner.cpp tasking/tasktreerunner.h
|
||||||
LIBRARIES
|
DEFINES
|
||||||
|
QT_NO_CAST_FROM_ASCII
|
||||||
|
PUBLIC_LIBRARIES
|
||||||
Qt6::Concurrent
|
Qt6::Concurrent
|
||||||
|
Qt6::Core
|
||||||
Qt6::CorePrivate
|
Qt6::CorePrivate
|
||||||
Qt6::Network
|
Qt6::Network
|
||||||
PUBLIC_LIBRARIES
|
NO_GENERATE_CPP_EXPORTS
|
||||||
Qt6::Core
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -8,22 +8,24 @@
|
|||||||
// W A R N I N G
|
// W A R N I N G
|
||||||
// -------------
|
// -------------
|
||||||
//
|
//
|
||||||
// This file is not part of the Qt API. It exists purely as an
|
// This file is not part of the Qt API. It exists purely as an
|
||||||
// implementation detail. This header file may change from version to
|
// implementation detail. This header file may change from version to
|
||||||
// version without notice, or even be removed.
|
// version without notice, or even be removed.
|
||||||
//
|
//
|
||||||
// We mean it.
|
// We mean it.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QScopedPointer>
|
|
||||||
#include <QtCore/QUrl>
|
#include <QtCore/QUrl>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
namespace QtExamples {
|
namespace Assets::Downloader {
|
||||||
|
|
||||||
class AssetDownloaderPrivate;
|
class AssetDownloaderPrivate;
|
||||||
|
|
||||||
class AssetDownloader : public QObject
|
class AssetDownloader : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -34,32 +36,12 @@ class AssetDownloader : public QObject
|
|||||||
WRITE setDownloadBase
|
WRITE setDownloadBase
|
||||||
NOTIFY downloadBaseChanged)
|
NOTIFY downloadBaseChanged)
|
||||||
|
|
||||||
Q_PROPERTY(
|
|
||||||
int completedDownloadsCount
|
|
||||||
READ completedDownloadsCount
|
|
||||||
NOTIFY completedDownloadsCountChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(
|
|
||||||
int allDownloadsCount
|
|
||||||
READ allDownloadsCount
|
|
||||||
NOTIFY allDownloadsCountChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(
|
|
||||||
double progress
|
|
||||||
READ progress
|
|
||||||
NOTIFY progressChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(
|
Q_PROPERTY(
|
||||||
QUrl preferredLocalDownloadDir
|
QUrl preferredLocalDownloadDir
|
||||||
READ preferredLocalDownloadDir
|
READ preferredLocalDownloadDir
|
||||||
WRITE setPreferredLocalDownloadDir
|
WRITE setPreferredLocalDownloadDir
|
||||||
NOTIFY preferredLocalDownloadDirChanged)
|
NOTIFY preferredLocalDownloadDirChanged)
|
||||||
|
|
||||||
Q_PROPERTY(
|
|
||||||
QUrl localDownloadDir
|
|
||||||
READ localDownloadDir
|
|
||||||
NOTIFY localDownloadDirChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(
|
Q_PROPERTY(
|
||||||
QUrl offlineAssetsFilePath
|
QUrl offlineAssetsFilePath
|
||||||
READ offlineAssetsFilePath
|
READ offlineAssetsFilePath
|
||||||
@ -78,31 +60,18 @@ class AssetDownloader : public QObject
|
|||||||
WRITE setZipFileName
|
WRITE setZipFileName
|
||||||
NOTIFY zipFileNameChanged)
|
NOTIFY zipFileNameChanged)
|
||||||
|
|
||||||
Q_PROPERTY(State state READ state NOTIFY stateChanged)
|
Q_PROPERTY(
|
||||||
|
QUrl localDownloadDir
|
||||||
|
READ localDownloadDir
|
||||||
|
NOTIFY localDownloadDirChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class State {
|
|
||||||
NotDownloadedState,
|
|
||||||
DownloadingZipState,
|
|
||||||
ExtractingZipState,
|
|
||||||
DownloadingFilesState,
|
|
||||||
MovingFilesState,
|
|
||||||
DownloadedState,
|
|
||||||
ErrorState
|
|
||||||
};
|
|
||||||
Q_ENUM(State)
|
|
||||||
|
|
||||||
AssetDownloader(QObject *parent = nullptr);
|
AssetDownloader(QObject *parent = nullptr);
|
||||||
~AssetDownloader();
|
~AssetDownloader();
|
||||||
|
|
||||||
QUrl downloadBase() const;
|
QUrl downloadBase() const;
|
||||||
void setDownloadBase(const QUrl &downloadBase);
|
void setDownloadBase(const QUrl &downloadBase);
|
||||||
|
|
||||||
int allDownloadsCount() const;
|
|
||||||
int completedDownloadsCount() const;
|
|
||||||
QUrl localDownloadDir() const;
|
|
||||||
double progress() const;
|
|
||||||
|
|
||||||
QUrl preferredLocalDownloadDir() const;
|
QUrl preferredLocalDownloadDir() const;
|
||||||
void setPreferredLocalDownloadDir(const QUrl &localDir);
|
void setPreferredLocalDownloadDir(const QUrl &localDir);
|
||||||
|
|
||||||
@ -115,35 +84,28 @@ public:
|
|||||||
QString zipFileName() const;
|
QString zipFileName() const;
|
||||||
void setZipFileName(const QString &zipFileName);
|
void setZipFileName(const QString &zipFileName);
|
||||||
|
|
||||||
State state() const;
|
QUrl localDownloadDir() const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void setProgressPercent(int);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void stateChanged(State);
|
void started();
|
||||||
void downloadBaseChanged(const QUrl &);
|
void finished(bool success);
|
||||||
void allDownloadsCountChanged(int count);
|
void progressChanged(int progressValue, int progressMaximum, const QString &progressText);
|
||||||
void downloadStarted();
|
|
||||||
void completedDownloadsCountChanged(int count);
|
|
||||||
void downloadFinished();
|
|
||||||
void downloadingFileChanged(const QUrl &url);
|
|
||||||
void preferredLocalDownloadDirChanged(const QUrl &url);
|
|
||||||
void localDownloadDirChanged(const QUrl &url);
|
void localDownloadDirChanged(const QUrl &url);
|
||||||
void progressChanged(double progress);
|
|
||||||
|
void downloadBaseChanged(const QUrl &);
|
||||||
|
void preferredLocalDownloadDirChanged(const QUrl &url);
|
||||||
void offlineAssetsFilePathChanged(const QUrl &);
|
void offlineAssetsFilePathChanged(const QUrl &);
|
||||||
void jsonFileNameChanged(const QString &);
|
void jsonFileNameChanged(const QString &);
|
||||||
void zipFileNameChanged(const QString &);
|
void zipFileNameChanged(const QString &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DECLARE_PRIVATE(AssetDownloader)
|
std::unique_ptr<AssetDownloaderPrivate> d;
|
||||||
QScopedPointer<AssetDownloaderPrivate> d_ptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QtExamples
|
} // namespace Assets::Downloader
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user