00001 /* Copyright (C) 2010 Väinö Lappi <djap84@gmail.com> 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00016 00017 */ 00018 #ifndef HTTPDOWNLOADER_H 00019 #define HTTPDOWNLOADER_H 00020 00021 #include <QtGui/QDialog> 00022 #include <QtNetwork/QHttp> 00023 #include <QIODevice> 00024 00025 namespace Ui { 00026 class HttpDownloader; 00027 } 00028 00037 class HttpDownloader : public QDialog { 00038 Q_OBJECT 00039 public: 00040 HttpDownloader(QWidget *parent = 0); 00041 ~HttpDownloader(); 00042 00053 void StartDownload(const QByteArray &encodedHost, const QByteArray &encodedPath, QIODevice *target, bool showProgressDialog); 00054 00062 int getErrorID(); 00063 00071 QString getErrorString(); 00072 00079 void HandleUiLanguageChange(); 00080 00087 QString getLastAttemptedDownloadAddress(); 00088 00089 protected: 00090 void changeEvent(QEvent *e); 00091 private: 00096 Ui::HttpDownloader *m_ui; 00097 00102 QHttp *httpEngine; 00103 00108 QString iFullDownloadAddress; 00109 protected slots: 00110 00119 void DownloadProgress(int ready, int total); 00120 00130 void DownloadReady(bool error); 00131 signals: 00137 void downloadFinished(int errorID); 00138 00145 void progressMaxValue(int value); //set max value for progressbar (received as "total"-parameter of SLOT DownloadProgress) 00146 00153 void progressCurrentValue(int value); //set current value of progressbar (received as "ready"-parameter of SLOT DownloadProgress) 00154 00161 void setFileLabelText(const QString &text); //Set text to currently loading label 00162 00168 void setTitleLabelText(const QString &text); 00169 }; 00170 00171 #endif // HTTPDOWNLOADER_H