NDEVR
API Documentation
ItemDownloader

Used for Downloading resources from a network. More...

Inheritance diagram for ItemDownloader:
[legend]
Collaboration diagram for ItemDownloader:
[legend]

Public Member Functions

uint08 currentDownloadSize () const
 Returns the number of bytes downloaded so far.
const QByteArray & downloadedData () const
 Returns the downloaded data.
void downloadedSignal ()
 Emitted when the download completes successfully.
void downloadFailedSignal (StringView)
 Emitted when a download fails, with an error message.
fltp08 downloadPercent () const
 Returns the download progress as a percentage.
void percentChangedSignal ()
 Emitted when the download progress percentage changes.
void start (TimeSpan timeout=TimeSpan(10.0))
 Starts the download with an optional timeout.
uint08 totalDownloadSize () const
 Returns the total expected download size.

Static Public Member Functions

static bool DownloadToFile (const StringView &url, const File &location, ProgressInfo &log)
 Downloads a file from a URL and saves it to a local path.
static ItemDownloaderGetItemDownloader (const StringView &url)
 Returns an existing or new ItemDownloader for the given URL.
static bool HasNetworkManager ()
 Returns whether a NetworkAccessManager has been set.
static NetworkAccessManagerNetworkManager ()
 Returns the global NetworkAccessManager.
static void SetAccessManager (NetworkAccessManager *manager)
 Sets the global NetworkAccessManager used for all downloads.

Protected Member Functions

 ItemDownloader (const StringView &url, QObject *parent=nullptr)
 Constructs an ItemDownloader for the given URL string.
 ItemDownloader (QUrl url, QObject *parent=nullptr)
 Constructs an ItemDownloader for the given QUrl.
void setNetworkRequest (const StringView &url)
 Configures the internal network request for the given URL.

Detailed Description

Used for Downloading resources from a network.


Definition at line 178 of file ItemDownloader.h.

Constructor & Destructor Documentation

◆ ItemDownloader() [1/2]

ItemDownloader::ItemDownloader ( const StringView & url,
QObject * parent = nullptr )
explicitprotected

Constructs an ItemDownloader for the given URL string.

Parameters
[in]urlThe URL to download from.
[in]parentThe parent QObject.

Referenced by ItemDownloader(), and GetItemDownloader().

◆ ItemDownloader() [2/2]

ItemDownloader::ItemDownloader ( QUrl url,
QObject * parent = nullptr )
explicitprotected

Constructs an ItemDownloader for the given QUrl.

Parameters
[in]urlThe URL to download from.
[in]parentThe parent QObject.

References ItemDownloader().

Member Function Documentation

◆ currentDownloadSize()

uint08 ItemDownloader::currentDownloadSize ( ) const
inlinenodiscard

Returns the number of bytes downloaded so far.

Returns
The current download size in bytes.

Definition at line 211 of file ItemDownloader.h.

◆ downloadedData()

const QByteArray & ItemDownloader::downloadedData ( ) const
nodiscard

Returns the downloaded data.

Returns
A const reference to the downloaded QByteArray.

◆ downloadPercent()

fltp08 ItemDownloader::downloadPercent ( ) const
nodiscard

Returns the download progress as a percentage.

Returns
The download percentage (0.0 to 100.0).

◆ DownloadToFile()

bool ItemDownloader::DownloadToFile ( const StringView & url,
const File & location,
ProgressInfo & log )
static

Downloads a file from a URL and saves it to a local path.

Parameters
[in]urlThe URL to download from.
[in]locationThe local file path to save to.
[in]logProgress tracking object.
Returns
True if the download succeeded.

◆ GetItemDownloader()

ItemDownloader * ItemDownloader::GetItemDownloader ( const StringView & url)
static

Returns an existing or new ItemDownloader for the given URL.

Parameters
[in]urlThe URL to download from.
Returns
A pointer to the ItemDownloader handling this URL.

References ItemDownloader().

◆ HasNetworkManager()

bool ItemDownloader::HasNetworkManager ( )
static

Returns whether a NetworkAccessManager has been set.

Returns
True if a network manager is available.

◆ NetworkManager()

NetworkAccessManager * ItemDownloader::NetworkManager ( )
static

Returns the global NetworkAccessManager.

Returns
A pointer to the network access manager.

◆ SetAccessManager()

void ItemDownloader::SetAccessManager ( NetworkAccessManager * manager)
static

Sets the global NetworkAccessManager used for all downloads.

Parameters
[in]managerThe network access manager to use.

◆ setNetworkRequest()

void ItemDownloader::setNetworkRequest ( const StringView & url)
protected

Configures the internal network request for the given URL.

Parameters
[in]urlThe URL to set up the request for.

◆ start()

void ItemDownloader::start ( TimeSpan timeout = TimeSpan(10.0))

Starts the download with an optional timeout.

Parameters
[in]timeoutThe timeout duration before the download is aborted.

◆ totalDownloadSize()

uint08 ItemDownloader::totalDownloadSize ( ) const
inlinenodiscard

Returns the total expected download size.

Returns
The total download size in bytes.

Definition at line 216 of file ItemDownloader.h.


The documentation for this class was generated from the following file: