setLocation(sceneCoord);
qDebug() << "centerToScene: " << sceneCoord.x() << "," << sceneCoord.y();
- emit centerToSceneCoordinates(sceneCoord);
+ //emit centerToSceneCoordinates(sceneCoord);
}
QUrl MapEngine::buildURL(int zoomLevel, QPoint tileNumbers)
mapTile->setTileNumber(QPoint(x, y));
mapTile->setPixmap(pixmap);
- mapTilesInScene.insert(url.toString(), mapTile);
- m_mapScene->addMapTile(mapTile);
+ if (!mapTilesInScene.contains(url.toString())) {
+ mapTilesInScene.insert(url.toString(), mapTile);
+ m_mapScene->addMapTile(mapTile);
- qDebug() << "Tile count: " << mapTilesInScene.size();
+ qDebug() << "Tile count: " << mapTilesInScene.size();
+ }
+
+ /*if (mapTilesInScene.size() > 20) {
+ MapTile * tile = mapTilesInScene.take(url.toString());
+ m_mapScene->removeItem(tile);
+ }*/
}
QGraphicsScene* MapEngine::scene()
int bottomRightX = grid.bottomRight().x();
int bottomRightY = grid.bottomRight().y();
- qDebug() << topLeftX << "," << topLeftY;
- qDebug() << bottomRightY << "," << bottomRightX;
-
int tileMaxVal = tileMaxValue(m_zoomLevel);
for (int x = topLeftX; x <= bottomRightX; ++x) {
QUrl url = buildURL(m_zoomLevel, QPoint(tileX, tileY));
if (!mapTilesInScene.contains(url.toString())) {
- emit fetchImage(buildURL(m_zoomLevel, QPoint(tileX, tileY)));
+ emit fetchImage(url);
}
}
}
#include "mapfetcher.h"
static int MAX_PARALLEL_DOWNLOADS = 2;
+static int DOWNLOAD_QUEUE_SIZE = 16;
MapFetcher::MapFetcher(QNetworkAccessManager *manager, QObject *parent)
: QObject(parent), m_manager(manager)
if (loadImageFromCache(url))
return;
+ if (downloadQueue.size() >= DOWNLOAD_QUEUE_SIZE)
+ downloadQueue.dequeue();
+
downloadQueue.enqueue(url);
if (currentDownloads.size() < MAX_PARALLEL_DOWNLOADS)
connect(mapEngine, SIGNAL(zoomLevelChanged(int)), mapView, SLOT(setZoomLevel(int)));
QHBoxLayout *mapViewLayout = new QHBoxLayout;
+ //DEBUG
+ QVBoxLayout *mapControlLayout = new QVBoxLayout;
+ QWidget *mapControl = new QWidget(this);
+ mapControl->setLayout(mapControlLayout);
+ search = new QPushButton("Search", this);
+ zoomOut = new QPushButton("-", this);
+ zoomIn = new QPushButton("+", this);
+ mapControlLayout->addWidget(&latLine);
+ mapControlLayout->addWidget(&lonLine);
+ mapControlLayout->addWidget(search);
+ mapControlLayout->addWidget(zoomIn);
+ mapControlLayout->addWidget(zoomOut);
+ mapViewLayout->addWidget(mapControl);
+ connect(search, SIGNAL(clicked()), this, SLOT(searchMap()));
+ connect(zoomIn, SIGNAL(clicked()), this, SLOT(zoomInMap()));
+ connect(zoomOut, SIGNAL(clicked()), this, SLOT(zoomOutMap()));
+ //DEBUG
mapViewLayout->addWidget(mapView);
setLayout(mapViewLayout);
mapEngine->setViewLocation(QPointF(25.5000, 65.0000));
}
+
+void MapViewScreen::searchMap()
+{
+ qreal lat = latLine.text().toFloat();
+ qreal lon = lonLine.text().toFloat();
+
+ qDebug() << lat << "," << lon;
+
+ mapEngine->setViewLocation(QPointF(lon, lat));
+}
+
+void MapViewScreen::zoomInMap()
+{
+ //mapEngine->zoomLevelChanged();
+}
+
+void MapViewScreen::zoomOutMap()
+{
+ //mapEngine->zoomLevelChanged();
+}
public:
MapViewScreen(QWidget *parent = 0);
+private slots:
+ void searchMap();
+ void zoomInMap();
+ void zoomOutMap();
+
private:
MapEngine *mapEngine;
-
+ //DEBUG
+ QPushButton *zoomIn;
+ QPushButton *zoomOut;
+ QLineEdit latLine;
+ QLineEdit lonLine;
+ QPushButton *search;
};
#endif // MAPVIEWTAB_H