00001 /* 00002 Situare - A location system for Facebook 00003 Copyright (C) 2010 Ixonos Plc. Authors: 00004 00005 Henri Lampela - henri.lampela@ixonos.com 00006 00007 Situare is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License 00009 version 2 as published by the Free Software Foundation. 00010 00011 Situare is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with Situare; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00019 USA. 00020 */ 00021 00022 #ifndef IMAGEFETCHER_H 00023 #define IMAGEFETCHER_H 00024 00025 #include <QtCore> 00026 00027 class NetworkAccessManager; 00028 class QNetworkReply; 00029 class QUrl; 00030 00036 class ImageFetcher : public QObject 00037 { 00038 Q_OBJECT 00039 00040 public: 00041 00048 ImageFetcher(NetworkAccessManager *manager, QObject *parent = 0); 00049 00050 /******************************************************************************* 00051 * CLASS SPECIFIC MEMBER FUNCTIONS AND SLOTS 00052 ******************************************************************************/ 00053 public slots: 00054 00060 void fetchImage(const QUrl &url); 00061 00062 private slots: 00063 00071 void downloadFinished(QNetworkReply *reply); 00072 00077 void startNextDownload(); 00078 00079 /******************************************************************************* 00080 * SIGNALS 00081 ******************************************************************************/ 00082 signals: 00090 void imageReceived(const QUrl &url, const QPixmap &image); 00091 00098 void error(const int context, const int error); 00099 00100 /******************************************************************************* 00101 * DATA MEMBERS 00102 ******************************************************************************/ 00103 private: 00104 QList<QNetworkReply*> m_currentDownloads; 00105 QQueue<QUrl> m_downloadQueue; 00106 NetworkAccessManager *m_manager; 00107 }; 00108 00109 #endif // IMAGEFETCHER_H