2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Jussi Laitinen - jussi.laitinen@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,
26 #include <QNetworkAccessManager>
28 #include "mapfetcher.h"
34 * @brief MapFetcher handles requests to get map tiles.
36 * @author Jussi Laitinen jussi.laitinen@ixonos.com
38 class MapFetcher : public QObject
44 * @todo remove fn:s from comment blocks
49 * @brief Constructor for MapFetcher.
51 * @param parent parent object
53 MapFetcher(QNetworkAccessManager *manager, QObject *parent = 0);
58 * @brief Fetch image from given URL.
60 * @param url URL to image
62 void fetchMapImage(const QUrl &url);
66 * @brief Signal which is emitted when a map tile
67 * is received from the server and loaded to pixmap.
69 * @param url URL to image
70 * @param image image pixmap
72 void mapImageReceived(const QUrl &url, const QPixmap &image);
75 * @brief Signal which is emitted when there is error
78 * @param message error message
80 void error(const QString &message);
85 * @brief This slot is called when network manager has finished
86 * the download. Loads image and emits imageReceived signal with
87 * url and image. If there was a error in reply emits error-signal.
91 void downloadFinished(QNetworkReply *reply);
94 * @brief This slot is called when next download is started. Takes url
95 * from queue, sends request and puts request to download queue.
97 void startNextDownload();
102 * @brief Loads image from cache if it's available and emits imageReveived
103 * signal with url and image. If image is in cache returns true, false
107 * @return bool true if image was loaded from cache, false otherwise
109 bool loadImageFromCache(const QUrl &url);
111 * @todo add comments for data members
115 QNetworkAccessManager *m_manager; ///< Network access manager
116 QList<QNetworkReply*> currentDownloads; ///< List of current downloads
117 QQueue<QUrl> downloadQueue; ///< Queue of pending requests