Public Slots |
void | enqueueFetchMapImage (int zoomLevel, int x, int y) |
| Enqueue fetching of map image.
|
Signals |
void | mapImageReceived (int zoomLevel, int x, int y, const QPixmap &image) |
| Signal which is emitted when a map tile is received from the server and loaded to pixmap.
|
void | error (const QString &message) |
| Signal which is emitted when there is error in network reply.
|
Public Member Functions |
| MapFetcher (NetworkAccessManager *manager, QObject *parent=0) |
| Constructor for MapFetcher.
|
void | setDownloadQueueSize (int size) |
| Set size of the download queue.
|
Private Slots |
void | downloadFinished (QNetworkReply *reply) |
| This slot is called when network manager has finished the download. Loads image and emits imageReceived signal with url and image. If there was a error in reply emits error-signal.
|
void | checkNextRequestFromCache () |
| Check next request if it is found from cache.
|
void | startNextDownload () |
| This slot is called when next download is started. Takes url from queue, sends request and puts request to download queue.
|
Private Member Functions |
QUrl | buildURL (int zoomLevel, QPoint tileNumbers) |
| Build URL for donwloading single map tile from OpenStreetMap tile server.
|
void | limitPendingRequestsListSize () |
| Limit pending requests list size to m_pendingRequestsSize.
|
bool | loadImageFromCache (const QUrl &url) |
| Loads image from cache.
|
int | newestRequestIndex (bool cacheChecked) |
| Find first item based on criteria if the request is already checked from the cache.
|
void | parseURL (const QUrl &url, int *zoom, int *x, int *y) |
| Parse given URL to zoom, x and y values. Parsed values are placed in variables given as parameters.
|
bool | translateIndexesToUpperLevel (int &zoomLevel, int &x, int &y) |
| Translate indexes to matching upper level map tile indexes.
|
Private Attributes |
QList< QNetworkReply * > | m_currentDownloads |
| List of current downloads.
|
int | m_pendingRequestsSize |
| Max number of pending requests.
|
bool | m_fetchMapImagesTimerRunning |
| is the singleshot timer already running
|
NetworkAccessManager * | m_manager |
| Network access manager.
|
QList< MapTileRequest > | m_pendingRequests |
| List of map image fetching requests.
|
QUrl MapFetcher::buildURL |
( |
int |
zoomLevel, |
|
|
QPoint |
tileNumbers | |
|
) |
| | [private] |
Build URL for donwloading single map tile from OpenStreetMap tile server.
- Parameters:
-
| zoomLevel | Zoom level |
| tileNumbers | Tile x & y numbers |
- Returns:
- URL for the required tile
Map server string for building actual URL
1 zoom level 2 x index 3 y index
NOTE: If the URL is changed, then the parseURL method must be changed to match the new URL structure
void MapFetcher::checkNextRequestFromCache |
( |
|
) |
[private, slot] |
Check next request if it is found from cache.
Next queued request, which is not already checked against cache, is taken from the queue and checked against cache. If not found from cache, then cache checked flag is set. New download is started if there aren't too many simultaneus downloads already running.