Added signal and slot for view scaling level change
authorSami Rämö <sami.ramo@ixonos.com>
Fri, 16 Apr 2010 13:30:52 +0000 (16:30 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Fri, 16 Apr 2010 13:30:52 +0000 (16:30 +0300)
Also renamed MapEngine::setZValues to setTilesDrawingLevels

src/map/mapengine.cpp
src/map/mapengine.h
src/map/maptile.h
src/map/mapview.cpp
src/map/mapview.h
src/ui/mapviewscreen.cpp

index 8efd679..e8d9905 100644 (file)
@@ -255,7 +255,7 @@ void MapEngine::zoomIn()
     m_zoomLevel++;
     emit zoomLevelChanged(m_zoomLevel);
 
-    setZValues();
+    setTilesDrawingLevels();
 
     calculateNewTiles(m_sceneCoordinate);
     removeOldTiles();
@@ -271,12 +271,12 @@ void MapEngine::zoomOut()
     m_zoomLevel--;
     emit zoomLevelChanged(m_zoomLevel);
 
-    setZValues();
+    setTilesDrawingLevels();
 
     calculateNewTiles(m_sceneCoordinate);
 }
 
-void MapEngine::setZValues()
+void MapEngine::setTilesDrawingLevels()
 {
     //qDebug() << __PRETTY_FUNCTION__ << "m_zoomLevel:" << m_zoomLevel;
 
@@ -298,3 +298,8 @@ QString MapEngine::tilePath(int zoomLevel, int x, int y)
 
     return tilePathString;
 }
+
+void MapEngine::scalingFactorChanged(qreal scaleFactor)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
index b6ccfd3..35b0947 100644 (file)
@@ -164,14 +164,11 @@ private:
     void parseURL(const QUrl &url, int &zoom, int &x, int &y);
 
     /**
-    * @brief Set zValues for all tiles in the scene
+    * @brief Set drawing order of all tiles in the scene
     *
-    * Drawing order of MapTiles, which has the zoom level higher than the current
-    * zoom level, is reversed and those MapTiles are mapped between lower level MapTiles.
-    * Example: If maximum zoom level is 18 and current view zoomlevel is 15, then
-    * the drawing order from top to bottom is 15, 16, 14, 17, 13, 18, 12, 11, 10, ...
+    * Check MapTile::setSceneLevel for more information.
     */
-    void setZValues();
+    void setTilesDrawingLevels();
 
     /**
     * @brief Calculate maximum value for tile in this zoom level.
@@ -242,6 +239,15 @@ private slots:
     void mapImageReceived(const QUrl &url, const QPixmap &pixmap);
 
     /**
+    * @brief Slot for view scaling factor change events
+    *
+    * Can be used to trigger scaling of zoom buttons, friend indicators and other
+    * MapScene elements which should retain their visual size
+    * @param scaleFactor view's scale factor
+    */
+    void scalingFactorChanged(qreal scaleFactor);
+
+    /**
     * @brief Slot for zooming in
     *
     */
index 79c81e7..31dfe7d 100644 (file)
@@ -52,6 +52,15 @@ public:
     */
     void setZoomLevel(int zoomLevel);
 
+    /**
+    * @brief Set drawing level of the tile based on current zoom level
+    *
+    * Drawing order of MapTiles, which has the zoom level higher than the current
+    * zoom level, is reversed and those MapTiles are mapped between lower level MapTiles.
+    * Example: If maximum zoom level is 18 and current view zoomlevel is 15, then
+    * the drawing order from top to bottom is 15, 16, 14, 17, 13, 18, 12, 11, 10, ...
+    * @param currentZoomLevel current zoom level
+    */
     void setSceneLevel(int currentZoomLevel);
 
     /**
index 7533ed8..ccf1a22 100644 (file)
@@ -75,6 +75,7 @@ void MapView::timerEvent(QTimerEvent *event)
 
     QTransform transform;
     transform.scale(scaleFactor, scaleFactor);
+    emit scalingFactorChanged(scaleFactor);
     setTransform(transform);
 }
 
index 2399e8f..630a6ac 100644 (file)
@@ -50,6 +50,16 @@ private:
     qreal currentScale();
 
 signals:
+
+    /**
+    * @brief Signal for view scale factor change events
+    *
+    * Can be used to trigger scaling of zoom buttons, friend indicators and other
+    * MapScene elements which should retain their visual size
+    * @param scaleFactor view's scale factor
+    */
+    void scalingFactorChanged(qreal scaleFactor);
+
     /**
     * @brief Signal for view scroll events
     *
index bdb6dcd..d6def4a 100644 (file)
@@ -34,9 +34,11 @@ MapViewScreen::MapViewScreen(QWidget *parent)
 
     connect(mapView, SIGNAL(viewScrolled(QPoint)), mapEngine, SLOT(setLocation(QPoint)));
     connect(mapEngine, SIGNAL(locationChanged(QPoint)),
-           mapView, SLOT(centerToSceneCoordinates(QPoint)));
+            mapView, SLOT(centerToSceneCoordinates(QPoint)));
     connect(mapEngine, SIGNAL(zoomLevelChanged(int)), mapView, SLOT(setZoomLevel(int)));
     connect(mapView, SIGNAL(viewResized(QSize)), mapEngine, SLOT(viewResized(QSize)));
+    connect(mapView, SIGNAL(scalingFactorChanged(qreal)),
+            mapEngine, SLOT(scalingFactorChanged(qreal)));
 
     QHBoxLayout *mapViewLayout = new QHBoxLayout;
     //DEBUG