Merge branch 'master' into route_json
authorlampehe-local <henri.lampela@ixonos.com>
Wed, 21 Jul 2010 11:05:45 +0000 (14:05 +0300)
committerlampehe-local <henri.lampela@ixonos.com>
Wed, 21 Jul 2010 11:05:45 +0000 (14:05 +0300)
Conflicts:
src/engine/engine.cpp
src/map/mapengine.cpp
src/map/mapengine.h
src/src.pro

1  2 
src/engine/engine.cpp
src/engine/engine.h
src/map/mapengine.cpp
src/map/mapengine.h
src/map/mapscene.cpp
src/src.pro

  #include "facebookservice/facebookauthentication.h"
  #include "gps/gpsposition.h"
  #include "map/mapengine.h"
 +#include "routing/routingservice.h"
+ #include "mce.h"
+ #include "network/networkaccessmanager.h"
  #include "situareservice/situareservice.h"
  #include "ui/mainwindow.h"
- #include "network/networkaccessmanager.h"
- #include "mce.h"
- #include <cmath>
  
  #include "engine.h"
  
Simple merge
@@@ -55,12 -54,11 +55,12 @@@ MapEngine::MapEngine(QObject *parent
        m_scrollStartedByGps(false),
        m_smoothScrollRunning(false),
        m_zoomedIn(false),
-       m_zoomLevel(DEFAULT_ZOOM_LEVEL),
+       m_zoomLevel(MAP_DEFAULT_ZOOM_LEVEL),
        m_centerTile(QPoint(UNDEFINED, UNDEFINED)),
-       m_lastAutomaticPosition(QPoint(0, 0)),
+       m_sceneCoordinate(SceneCoordinate(GeoCoordinate(MAP_DEFAULT_LATITUDE, MAP_DEFAULT_LONGITUDE))),
        m_tilesGridSize(QSize(0, 0)),
 -      m_viewSize(QSize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT))
 +      m_viewSize(QSize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT)),
 +      m_mapRouteItem(0)
  {
      qDebug() << __PRETTY_FUNCTION__;
  
@@@ -129,36 -127,7 +129,29 @@@ QRect MapEngine::calculateTileGrid(Scen
      return QRect(topLeft, m_tilesGridSize);
  }
  
 +void MapEngine::centerAndZoomTo(QRect rect)
 +{
 +    const int MARGIN_HORIZONTAL = 50;
 +    const int MARGIN_VERTICAL = 5;
 +
 +    // calculate the usable size of the view
 +    int viewUsableHeight = m_viewSize.height() - 2 * MARGIN_VERTICAL;
 +    int viewUsableWidth = m_viewSize.width() - 2 * MARGIN_HORIZONTAL;
 +
 +    // calculate how many levels must be zoomed out from the closest zoom level to get the rect
 +    // fit inside the usable view area
 +    int shift = 0;
 +    while ((rect.height() > (viewUsableHeight * (1 << shift)))
 +           || (rect.width() > (viewUsableWidth * (1 << shift))))
 +        shift++;
 +
 +    scrollToPosition(rect.center());
 +
 +    int zoomLevel = qBound(MIN_VIEW_ZOOM_LEVEL, MAX_MAP_ZOOM_LEVEL - shift, MAX_MAP_ZOOM_LEVEL);
 +    setZoomLevel(zoomLevel);
 +}
 +
- QPointF MapEngine::centerGeoCoordinate()
- {
-     qDebug() << __PRETTY_FUNCTION__;
-     return convertSceneCoordinateToLatLon(m_zoomLevel, m_sceneCoordinate);
- }
- void MapEngine::centerToCoordinates(QPointF latLonCoordinate)
+ GeoCoordinate MapEngine::centerGeoCoordinate()
  {
      qDebug() << __PRETTY_FUNCTION__;
  
@@@ -28,7 -28,8 +28,9 @@@
  
  #include <QtCore>
  
 +#include "routing/route.h"
+ #include "coordinates/geocoordinate.h"
+ #include "coordinates/scenecoordinate.h"
  
  class QGraphicsScene;
  
@@@ -234,27 -218,17 +220,27 @@@ private
       *
       * Grid size is calculated from view size and scene's current center coordinate.
       *
-      * @param sceneCoordinate scene's current center coordinate
+      * @param coordinate scene's current center coordinate
       * @return QRect grid of tile coordinates
       */
-     QRect calculateTileGrid(QPoint sceneCoordinate);
+     QRect calculateTileGrid(SceneCoordinate coordinate);
  
      /**
 +    * @brief Center and zoom to given rect
 +    *
 +    * Map is centered to center point of the rect and zoomed so that whole rect is visible
 +    * as big as possible.
 +    *
 +    * @param rect Target rect
 +    */
 +    void centerAndZoomTo(QRect rect);
 +
 +    /**
       * @brief Request disabling of auto centering if centered too far from the real location.
       *
-      * @param sceneCoordinate scene's center coordinate
+      * @param coordinate scene's center coordinate
       */
-     void disableAutoCenteringIfRequired(QPoint sceneCoordinate);
+     void disableAutoCenteringIfRequired(SceneCoordinate coordinate);
  
      /**
       * @brief Get new tiles.
@@@ -364,18 -338,11 +350,18 @@@ private slots
       * @brief Set center point in the scene
       *
       * Does emit locationChanged signal.
-      * @param scenePosition Scene coordinates for new position
+      * @param coordinate Scene coordinates for new position
       */
-     void setCenterPosition(QPoint scenePosition);
+     void setCenterPosition(SceneCoordinate coordinate);
  
      /**
 +     * @brief Builds and sets route, also centers it
 +     *
 +     * @param route Route route information
 +     */
 +    void setRoute(Route &route);
 +
 +    /**
       * @brief Slot for actions after view zoom is finished
       *
       * Does run removeOutOfViewTiles
Simple merge
diff --cc src/src.pro
@@@ -55,10 -54,12 +54,16 @@@ SOURCES += main.cpp 
      user/user.cpp \
      ui/fullscreenbutton.cpp \
      engine/mce.cpp \
 +    routing/routingservice.cpp \
 +    routing/routesegment.cpp \
 +    routing/route.cpp \
-     map/maprouteitem.cpp
++    map/maprouteitem.cpp \
+     coordinates/scenecoordinate.cpp \
+     coordinates/geocoordinate.cpp \
+     ui/listview.cpp \
+     ui/listitem.cpp \
+     ui/listitemdelegate.cpp \
+     ui/friendlistitemdelegate.cpp
  HEADERS += application.h \
      common.h \
      engine/engine.h \
      user/user.h \
      ui/fullscreenbutton.h \
      engine/mce.h \
 +    routing/routingservice.h \
 +    routing/routingcommon.h \
 +    routing/routesegment.h \
 +    routing/route.h \
-     map/maprouteitem.h
++    map/maprouteitem.h \
+     map/osm.h \
+     coordinates/scenecoordinate.h \
+     coordinates/geocoordinate.h \
+     ui/listview.h \
+     ui/listitem.h \
+     ui/listitemdelegate.h \
+     ui/friendlistitemdelegate.h \
+     ui/listcommon.h
  QT += network \
      webkit