Albert
Loading...
Searching...
No Matches
albert::Download Class Reference

#include <albert/download.h>

Description

Downloads a file from the given URL to the given path.

Does not check if the file exists. The download will fail to save the file in this case.

Inherits QObject.

Public Member Functions

 Download (const QUrl &url, const QString &path, QObject *parent=nullptr)
 Constructs a download with the given url, path and parent.
 
 ~Download ()
 Destructs this download.
 
const QUrl & url ()
 Returns the url of the download.
 
const QString & path ()
 Returns the destination path of the download.
 
bool isActive ()
 Returns true if the download is active.
 
const QString & error ()
 Returns the error of the download, if any.
 
void start ()
 Starts the download.
 

Static Public Member Functions

static std::shared_ptr< Downloadunique (const QUrl &url, const QString &path)
 Returns a unique download for url and path.
 

Signals

void finished ()
 Emitted when the download has finished.
 

Constructor & Destructor Documentation

◆ Download()

albert::Download::Download ( const QUrl &  url,
const QString &  path,
QObject *  parent = nullptr 
)

Constructs a download with the given url, path and parent.

◆ ~Download()

albert::Download::~Download ( )

Destructs this download.

Member Function Documentation

◆ error()

const QString & albert::Download::error ( )

Returns the error of the download, if any.

This function is thread-safe.

◆ finished

void albert::Download::finished ( )
signal

Emitted when the download has finished.

◆ isActive()

bool albert::Download::isActive ( )

Returns true if the download is active.

This function is thread-safe.

◆ path()

const QString & albert::Download::path ( )

Returns the destination path of the download.

This function is thread-safe.

◆ start()

void albert::Download::start ( )

Starts the download.

Do not move the download to another thread after calling this method.

◆ unique()

static std::shared_ptr< Download > albert::Download::unique ( const QUrl &  url,
const QString &  path 
)
static

Returns a unique download for url and path.

If a download for the same URL and path already exists, it is returned; otherwise a new download is created and returned. The download created is automatically started and lives in the main thread.

This function is thread-safe.

◆ url()

const QUrl & albert::Download::url ( )

Returns the url of the download.

This function is thread-safe.


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