35 lines
796 B
C++
35 lines
796 B
C++
#ifndef DOWNLOADER_H
|
|
#define DOWNLOADER_H
|
|
|
|
#include <QHash>
|
|
#include <QNetworkAccessManager>
|
|
#include <QObject>
|
|
|
|
class QFile;
|
|
class QNetworkReply;
|
|
class Settings;
|
|
|
|
// Download di file (libri) con segnali di progresso.
|
|
// Supporta più download concorrenti.
|
|
class Downloader : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit Downloader(Settings *settings, QObject *parent = 0);
|
|
|
|
Q_INVOKABLE void download(const QString &url, const QString &destPath);
|
|
|
|
signals:
|
|
void progress(qint64 received, qint64 total, const QString &path);
|
|
void finished(const QString &path, bool ok, const QString &error);
|
|
|
|
private:
|
|
Settings *m_settings;
|
|
QNetworkAccessManager m_nam;
|
|
QHash<QNetworkReply *, QFile *> m_files;
|
|
QHash<QNetworkReply *, QString> m_paths;
|
|
};
|
|
|
|
#endif // DOWNLOADER_H
|