Scribus
Open source desktop publishing at your fingertips
scdlthread.h
1 #ifndef SCDLTHREAD_H
2 #define SCDLTHREAD_H
3 
4 #include <QThread>
5 #include <QUrl>
6 #include <QStringList>
7 #include <QPair>
8 #include <QString>
9 #include <QQueue>
10 #include <QFile>
11 #include <QNetworkAccessManager>
12 
13 class ScDLThread : public QThread
14 {
15  Q_OBJECT
16  public:
17  ScDLThread(QObject * parent = 0);
18  ~ScDLThread();
19  void run();
20 
21  void addURL(const QUrl &url, bool overwrite, const QString& location, const QString& destinationLocation);
22  void addURLs(const QStringList &urlList, bool overwrite, const QString& location, const QString& destinationLocation);
23  void startDownloads();
24  QString saveFileName(const QUrl &url, const QString &location, bool overwrite);
25 
26  signals:
27  void finished();
28  void runSignal();
29  void fileStarted(const QString &);
30  void fileReceived(const QString &);
31  void fileFailed(const QString &);
32 
33  private slots:
34  void startNextDownload();
35  void downloadFinished();
36  void replyFinished(QNetworkReply* reply);
37  void downloadReadyRead();
38  void runSlot();
39 
40  private:
41  bool urlOK(QUrl url);
42  QStringList m_urlList;
43  QFile output;
44  QQueue<QPair<QUrl, QString> > downloadQueue;
45  int downloadedCount;
46  int totalCount;
47  QNetworkReply *currentDownload;
48  QNetworkAccessManager manager;
49 };
50 #endif
Definition: scdlthread.h:13