Added missing comments.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 30 Jul 2010 12:51:43 +0000 (15:51 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 30 Jul 2010 12:51:43 +0000 (15:51 +0300)
src/map/mapengine.cpp
src/map/mapengine.h
src/ui/locationlistitem.cpp

index a56f158..ee80426 100644 (file)
@@ -129,14 +129,21 @@ QRect MapEngine::calculateTileGrid(SceneCoordinate coordinate)
     return QRect(topLeft, m_tilesGridSize);
 }
 
-void MapEngine::centerAndZoomTo(QRect rect)
+void MapEngine::centerAndZoomTo(QRect rect, bool useMargins)
 {
-    const int MARGIN_HORIZONTAL = 50;
-    const int MARGIN_VERTICAL = 5;
+    qDebug() << __PRETTY_FUNCTION__;
+
+    int marginHorizontal = 50;
+    int marginVertical = 5;
+
+    if (!useMargins) {
+        marginHorizontal = 0;
+        marginVertical = 0;
+    }
 
     // calculate the usable size of the view
-    int viewUsableHeight = m_viewSize.height() - 2 * MARGIN_VERTICAL;
-    int viewUsableWidth = m_viewSize.width() - 2 * MARGIN_HORIZONTAL;
+    int viewUsableHeight = m_viewSize.height() - 2 * marginHorizontal;
+    int viewUsableWidth = m_viewSize.width() - 2 * marginVertical;
 
     // calculate how many levels must be zoomed out from the closest zoom level to get the rect
     // fit inside the usable view area
@@ -312,6 +319,17 @@ bool MapEngine::isCenterTileChanged(SceneCoordinate coordinate)
     return (centerTile != temp);
 }
 
+void MapEngine::locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QRect area;
+    area.setTopRight(SceneCoordinate(neBound).toPointF().toPoint());
+    area.setBottomLeft(SceneCoordinate(swBound).toPointF().toPoint());
+
+    centerAndZoomTo(area, false);
+}
+
 qreal MapEngine::sceneResolution()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -623,11 +641,3 @@ void MapEngine::zoomOut()
         zoomed();
     }
 }
-
-void MapEngine::locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    centerAndZoomTo(QRect(SceneCoordinate(swBound).toPointF().toPoint(),
-                          SceneCoordinate(neBound).toPointF().toPoint()));
-}
index 087e273..567d08c 100644 (file)
@@ -232,8 +232,9 @@ private:
     * as big as possible.
     *
     * @param rect Target rect
+    * @param useMargins true if margins should be added to rect, false otherwise
     */
-    void centerAndZoomTo(QRect rect);
+    void centerAndZoomTo(QRect rect, bool useMargins = true);
 
     /**
      * @brief Request disabling of auto centering if centered too far from the real location.
@@ -315,6 +316,15 @@ private slots:
     void gpsPositionUpdate(GeoCoordinate position, qreal accuracy);
 
     /**
+    * @brief Called when location item is clicked.
+    *
+    * Calls centerAndZoomTo() with bounds.
+    * @param swBound south-west bound of location item
+    * @param neBound north-east bound of location item
+    */
+    void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
+
+    /**
      * @brief Slot for received map tile images
      *
      * Does receive map tile images from MapFetcher. Calls MapScene::addTile() for creating and adding
@@ -378,8 +388,6 @@ private slots:
      */
     void zoomOut();
 
-    void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
-
 /*******************************************************************************
  * SIGNALS
  ******************************************************************************/
index e14a8c1..c59c1c3 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "locationlistitem.h"
 
-const int LOCATION_SUBITEM_TEXT_MAX_WIDTH = SUBITEM_TEXT_MAX_WIDTH + MARGIN*2 + IMAGE_WIDTH;
+const int LOCATION_SUBITEM_TEXT_MAX_WIDTH = SUBITEM_TEXT_MAX_WIDTH + MARGIN + IMAGE_WIDTH;
 
 LocationListItem::LocationListItem()
 {