2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Henri Lampela - henri.lampela@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 #ifndef IMAGEFETCHER_H
23 #define IMAGEFETCHER_H
27 class NetworkAccessManager;
32 * @brief ImageFetcher handles requests to get images.
34 * @author Henri Lampela
36 class ImageFetcher : public QObject
43 * @brief Default constructor
45 * @param manager QNetworkAccessManager
46 * @param parent Parent object
48 ImageFetcher(NetworkAccessManager *manager, QObject *parent = 0);
50 /*******************************************************************************
51 * CLASS SPECIFIC MEMBER FUNCTIONS AND SLOTS
52 ******************************************************************************/
56 * @brief Fecth image from given url
58 * @param url Image url
60 void fetchImage(const QUrl &url);
65 * @brief This slot is called when network manager has finished
66 * the download. Loads image and emits imageReceived signal with
67 * url and image. If there was a error in reply emits error-signal.
71 void downloadFinished(QNetworkReply *reply);
74 * @brief This slot is called when next download is started. Takes url
75 * from queue, sends request and puts request to download queue.
77 void startNextDownload();
79 /*******************************************************************************
81 ******************************************************************************/
84 * @brief Signal which is emitted when image
85 * is received from the server and loaded to pixmap.
87 * @param url URL to image
88 * @param image image QPixmap
90 void imageReceived(const QUrl &url, const QPixmap &image);
93 * @brief Signal which is emitted when there is error
96 * @param error error code
98 void error(const int error);
100 /*******************************************************************************
102 ******************************************************************************/
104 QList<QNetworkReply*> m_currentDownloads; ///< List of current downloads
105 QQueue<QUrl> m_downloadQueue; ///< Queue of pending requests
106 NetworkAccessManager *m_manager; ///< Network access manager
109 #endif // IMAGEFETCHER_H