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 * @brief Constructor for MapFetcher.
46 * @param manager Network access manager
47 * @param parent parent object
49 MapFetcher(QNetworkAccessManager *manager, QObject *parent = 0);
54 * @brief Fetch image from given URL.
56 * @param url URL to image
58 void fetchMapImage(const QUrl &url);
62 * @brief Signal which is emitted when a map tile
63 * is received from the server and loaded to pixmap.
65 * @param url URL to image
66 * @param image image pixmap
68 void mapImageReceived(const QUrl &url, const QPixmap &image);
71 * @brief Signal which is emitted when there is error
74 * @param message error message
76 void error(const QString &message);
81 * @brief This slot is called when network manager has finished
82 * the download. Loads image and emits imageReceived signal with
83 * url and image. If there was a error in reply emits error-signal.
87 void downloadFinished(QNetworkReply *reply);
90 * @brief This slot is called when next download is started. Takes url
91 * from queue, sends request and puts request to download queue.
93 void startNextDownload();
98 * @brief Loads image from cache if it's available and emits imageReveived
99 * signal with url and image. If image is in cache returns true, false
103 * @return bool true if image was loaded from cache, false otherwise
105 bool loadImageFromCache(const QUrl &url);
107 QNetworkAccessManager *m_manager; ///< Network access manager
108 QList<QNetworkReply*> currentDownloads; ///< List of current downloads
109 QQueue<QUrl> downloadQueue; ///< Queue of pending requests