: QObject(parent)
, m_centerTile(QPoint(UNDEFINED, UNDEFINED))
, m_viewSize(QSize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT))
- , m_zoomedIn(NO)
+ , m_zoomedIn(false)
, m_zoomLevel(DEFAULT_ZOOM_LEVEL)
{
m_mapScene = new MapScene(this);
{
// qDebug() << __PRETTY_FUNCTION__;
- if (m_zoomedIn == YES) {
- m_zoomedIn = NO;
+ if (m_zoomedIn) {
+ m_zoomedIn = false;
m_mapScene->removeOutOfViewTiles();
}
}
if (m_zoomLevel < MAX_MAP_ZOOM_LEVEL) {
m_zoomLevel++;
- m_zoomedIn = YES;
+ m_zoomedIn = true;
emit zoomLevelChanged(m_zoomLevel);
m_mapScene->setTilesDrawingLevels(m_zoomLevel);
* DATA MEMBERS
******************************************************************************/
private:
- enum ZoomedIn { YES, NO }; ///< Direction of the last zoom action
-
MapFetcher *m_mapFetcher; ///< Fetcher for map tiles
MapScene *m_mapScene; ///< Scene for map tiles
MapZoomPanel *m_mapZoomPanel; ///< Toolbar for zoom buttons
QPoint m_sceneCoordinate; ///< Current center coordinate
QRect m_viewTilesGrid; ///< Current grid of tiles in view (includes margin)
QSize m_viewSize; ///< Current view size
- ZoomedIn m_zoomedIn; ///< Flag for checking if zoomed in when zoom is finished
+ bool m_zoomedIn; ///< Flag for checking if zoomed in when zoom is finished
int m_zoomLevel; ///< Current zoom level
};
******************************************************************************/
public slots:
+ /**
+ * @brief Enqueue fetching of map image
+ *
+ * Image fetching is triggered after events have been processed
+ * so the UI stays responsive.
+ *
+ * @param url URL of the image to be fetched
+ */
void enqueueFetchMapImage(QUrl url);
private:
void downloadFinished(QNetworkReply *reply);
/**
- * @brief Fetch image from given URL.
+ * @brief Fetch next map image.
*
- * @param url URL to image
+ * Next queued request is taken from the queue and fetching is started
*/
void fetchMapImage();
QList<QNetworkReply*> m_currentDownloads; ///< List of current downloads
QQueue<QUrl> m_downloadQueue; ///< Queue of pending requests
- QList<QUrl> m_fetchMapImagesList;
- bool m_isFetchMapImagesTimerRunning;
+ QList<QUrl> m_fetchMapImagesList; ///< "Queue" for map image fetching requests
+ bool m_isFetchMapImagesTimerRunning; ///< is the singleshot timer already running
QNetworkAccessManager *m_manager; ///< Network access manager
};
m_removeStackedTilesList << newTile;
if (!m_isRemoveStackedTilesRunning) {
m_isRemoveStackedTilesRunning = true;
- QTimer::singleShot(0, this, SLOT(removeStackedTile()));
+ QTimer::singleShot(0, this, SLOT(runNextStackedTilesRemoval()));
}
}
return m_mapTilesInScene.contains(hashKey);
}
-void MapScene::removeStackedTile()
+void MapScene::runNextStackedTilesRemoval()
{
// qDebug() << __PRETTY_FUNCTION__;
// schedule removal of the next tile if the list is not empty
if (!m_removeStackedTilesList.isEmpty()) {
- QTimer::singleShot(0, this, SLOT(removeStackedTile()));
+ QTimer::singleShot(0, this, SLOT(runNextStackedTilesRemoval()));
}
else {
m_isRemoveStackedTilesRunning = false;
void debugItemsCount();
+ /**
+ * @brief Enqueue stacked tiles removal request
+ *
+ * Removal is triggered after events have been processed so the UI
+ * stays more responsive
+ * @param newTile New tile, which area under it is inspected
+ */
void enqueueRemoveStackedTiles(MapTile *newTile);
/**
/**
* @brief Remove tiles which are out of view bounds.
*
- * @param viewRect Current view rect
*/
void removeOutOfViewTiles();
*/
void setTilesDrawingLevels(int zoomLevel);
+ /**
+ * @brief Save new view rect
+ *
+ * View rect must be saved to local scope whenever it changes because
+ * it is used by removal algorithms and some of the algorithms are run
+ * delayed so the actual view rect may change before the cleanup
+ * algorithm is run.
+ *
+ * @param viewRect New view rect
+ */
void viewRectUpdated(QRect viewRect);
-public slots:
- void removeStackedTile();
+private slots:
+ /**
+ * @brief Slot for running next queued removal of stacked tiles
+ *
+ */
+ void runNextStackedTilesRemoval();
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
private:
- bool m_isRemoveStackedTilesRunning;
+ bool m_isRemoveStackedTilesRunning; ///< Is singleshot timer already running
QHash<QString, MapTile *> m_mapTilesInScene; ///< List of map tiles in map scene
- QList<MapTile *> m_removeStackedTilesList;
- QRect m_viewRect;
+ QList<MapTile *> m_removeStackedTilesList; ///< "Queue" for stacked tiles removal requests
+ QRect m_viewRect; ///< Current viewable area
};
#endif // MAPSCENE_H
{
Q_OBJECT
+ /**
+ * @brief View scaling
+ *
+ * @property viewScale
+ */
Q_PROPERTY(qreal viewScale READ viewScale WRITE setViewScale)
public:
*/
qreal currentScale();
+ /**
+ * @brief Set new view scale
+ *
+ * @param viewScale New scaling factor
+ */
void setViewScale(qreal viewScale);
+ /**
+ * @brief Get current view scale
+ *
+ * @return Current view scaling factor
+ */
qreal viewScale();
/*******************************************************************************
QPoint m_mousePosition; ///< Previous mouse event position
QPoint m_scenePosition; ///< New center position
int m_timerID; ///< ID number of the timer used for smooth zoom effect
- QPropertyAnimation *m_zoomAnimation;
+ QPropertyAnimation *m_zoomAnimation; ///< Zoom animation
qreal m_zoomScaleDelta; ///< Scaling factor delta for smooth zoom transition effect
qreal m_zoomTargetScale; ///< Scaling factor of the target zoom level
};