FMH::Downloader
#include <downloader.h>
Signals | |
void | aborted () |
void | dataReady (QByteArray array) |
void | done () |
void | downloadReady () |
void | fileSaved (QString path) |
void | progress (int percent) |
void | warning (QString warning) |
Public Member Functions | |
Downloader (QObject *parent=nullptr) | |
void | downloadFile (const QUrl &source, const QUrl &destination) |
void | getArray (const QUrl &fileURL, const QMap< QString, QString > &headers={}) |
bool | isFinished () const |
bool | isRunning () const |
void | stop () |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QBindable< QString > | bindableObjectName () |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () const const |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isQuickItemType () const const |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_GADGET_EXPORT (EXPORT_MACRO) | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_MOC_INCLUDE Q_MOC_INCLUDE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setObjectName (QAnyStringView name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | setProperty (const char *name, QVariant &&value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType) |
QThread * | thread () const const |
Additional Inherited Members | |
Public Types inherited from QObject | |
typedef | QObjectList |
Properties inherited from QObject | |
objectName | |
Static Public Member Functions inherited from QObject | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
Protected Member Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Detailed Description
The Downloader class This is a quick helper to download remote content and save it as local files.
- Note
- Allows to make get request using optional headers.
Definition at line 56 of file downloader.h.
Constructor & Destructor Documentation
◆ Downloader()
FMH::Downloader::Downloader | ( | QObject * | parent = nullptr | ) |
Definition at line 13 of file downloader.cpp.
◆ ~Downloader()
|
virtual |
Definition at line 44 of file downloader.cpp.
Member Function Documentation
◆ aborted
|
signal |
Emitted when the download or data request has been aborted manually by calling the stop
method.
◆ dataReady
|
signal |
Emitted when the data is ready and can be parsed.
- Parameters
-
array the array raw data
◆ done
|
signal |
Emitted when the process has been finished.
Emitted as the downloadReady
signal.
◆ downloadFile()
Given a source URL to a file it downloads it to a given local destination.
- Parameters
-
source the remote file URL destination the local file URL destination with a name an suffix extension type
Definition at line 97 of file downloader.cpp.
◆ downloadReady
|
signal |
Emitted when the downloading has finished.
◆ fileSaved
|
signal |
Emitted after the downloading has finished and the file has been saved successfully.
- Parameters
-
path the location path of the new saved file
◆ getArray()
void FMH::Downloader::getArray | ( | const QUrl & | fileURL, |
const QMap< QString, QString > & | headers = {} ) |
Given a URL make a get request and once the reply is ready emits a signal with the retrieved array data.
- Note
- Usually this is used to retrieved structured information from a web API, such a a JSON or a XML file, to later be parsed.
- See also
- dataReady
- Parameters
-
fileURL the end point URL to make the request headers the optional set of HTTP request headers structured as a QMap of a key value pair of plain strings.
Definition at line 143 of file downloader.cpp.
◆ isFinished()
bool FMH::Downloader::isFinished | ( | ) | const |
Whether the process has finished successfully.
- See also
- aborted
Definition at line 50 of file downloader.cpp.
◆ isRunning()
bool FMH::Downloader::isRunning | ( | ) | const |
Whether the downloading or current request is still in progress.
Definition at line 60 of file downloader.cpp.
◆ progress
|
signal |
Emitted while the process is ongoing.
- Parameters
-
percent the process value from 0 to 100
◆ stop()
void FMH::Downloader::stop | ( | ) |
Force to stop the process of the data request or the downloading of the file.
Definition at line 71 of file downloader.cpp.
◆ warning
|
signal |
Emitted when there is a warning message, for example when an error has occurred during the process or at the end.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:32:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.