Merge branch 'master' into map_double_click_zoom
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 18 Jun 2010 12:38:41 +0000 (15:38 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 18 Jun 2010 12:38:41 +0000 (15:38 +0300)
Conflicts:
src/src.pro

src/map/mapview.cpp
src/map/mapview.h
src/src.pro
src/ui/mainwindow.cpp
tests/map/mapview/testmapview.cpp

index 6b38ff4..cd31b36 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <QDebug>
 #include <QMouseEvent>
+#include <QParallelAnimationGroup>
 
 #include "mapcommon.h"
 #include "mapscroller.h"
@@ -53,6 +54,11 @@ MapView::MapView(QWidget *parent)
     setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing);
 
     m_scroller = &MapScroller::getInstance();
+
+    m_group = new QParallelAnimationGroup(this);
+
+    m_group->addAnimation(m_zoomAnimation);
+    m_group->addAnimation(m_scroller);
 }
 
 void MapView::centerToSceneCoordinates(QPoint sceneCoordinate)
@@ -62,10 +68,36 @@ void MapView::centerToSceneCoordinates(QPoint sceneCoordinate)
     centerOn(sceneCoordinate);
 }
 
+void MapView::mouseDoubleClickEvent(QMouseEvent *event)
+{
+    qWarning() << __PRETTY_FUNCTION__ << event->pos().x() << event->pos().y();
+    qWarning() << __PRETTY_FUNCTION__ << mapToScene(event->pos()).toPoint().x() <<
+            mapToScene(event->pos()).toPoint().y();
+
+    QPoint centerPosition = mapToScene(QPoint(width() / 2 - 1, height() / 2 - 1)).toPoint();
+    QPoint pressPosition = mapToScene(event->pos()).toPoint();
+    QPoint scenePosition = centerPosition - ((centerPosition - pressPosition) / 2);
+
+    m_zoomAnimation->setDuration(KINETIC_SCROLL_TIME_MS);
+    m_zoomAnimation->setStartValue(viewScale());
+    m_zoomAnimation->setEndValue(pow(2, ++m_zoomLevel - MAX_MAP_ZOOM_LEVEL));
+    m_zoomAnimation->setEasingCurve(QEasingCurve::OutCirc);
+
+    m_scroller->setDuration(KINETIC_SCROLL_TIME_MS);
+    m_scroller->setStartValue(centerPosition);
+    m_scroller->setEndValue(scenePosition);
+
+    m_group->start();
+
+    emit zoomIn();
+}
+
 void MapView::mouseMoveEvent(QMouseEvent *event)
 {
     m_scenePosition += m_mouseLastScenePosition - mapToScene(event->pos()).toPoint();
 
+    qWarning() << __PRETTY_FUNCTION__;
+
     qDebug() << __PRETTY_FUNCTION__ << "m_scenePosition:" << m_scenePosition;
 
     if (m_index >= VALUES)
@@ -84,6 +116,7 @@ void MapView::mouseMoveEvent(QMouseEvent *event)
 
 void MapView::mousePressEvent(QMouseEvent *event)
 {
+    qWarning() << __PRETTY_FUNCTION__;
     qDebug() << __PRETTY_FUNCTION__;
 
     m_time.start();
@@ -160,7 +193,7 @@ void MapView::setZoomLevel(int zoomLevel)
 
     m_zoomLevel = zoomLevel;
 
-    if (m_zoomAnimation) {
+    if (m_zoomAnimation && (m_zoomAnimation->state() == QAbstractAnimation::Stopped)) {
         m_zoomAnimation->stop();
         m_zoomAnimation->setDuration(ZOOM_TIME);
         m_zoomAnimation->setStartValue(viewScale());
index 1322663..db03580 100644 (file)
@@ -27,6 +27,7 @@
 #include <QTime>
 
 class QPropertyAnimation;
+class QParallelAnimationGroup;
 
 class MapScroller;
 
@@ -62,6 +63,14 @@ public:
  ******************************************************************************/
 protected:
     /**
+    * @brief Event handler for mouse double click event
+    *
+    * Emits zoomIn signal.
+    * @param event QMouseEvent
+    */
+    void mouseDoubleClickEvent(QMouseEvent *event);
+
+    /**
     * @brief Called when view is resized.
     *
     * @param event resize event
@@ -164,6 +173,8 @@ signals:
     */
     void viewZoomFinished();
 
+    void zoomIn();
+
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
@@ -182,6 +193,8 @@ private:
     QTime m_time;                         ///< Elapsed times in mouse events
 
     MapScroller *m_scroller;              ///< Kinetic scroller
+
+    QParallelAnimationGroup *m_group;
 };
 
 #endif // MAPVIEW_H
index 9f5825e..d1377cd 100644 (file)
@@ -122,18 +122,20 @@ simulator {
         SOURCES += network/networkhandlerprivate.cpp
         HEADERS += network/networkhandlerprivate.h
         QT += dbus
-        CONFIG += icd2 qdbus
-        SOURCES += gps/gpspositionprivateliblocation.cpp \
-                   gps/liblocationwrapper.cpp \
-                   gps/geopositioninfo.cpp \
-                   gps/geocoordinate.cpp
-        HEADERS += gps/gpspositionprivateliblocation.h \
-                   gps/liblocationwrapper.h \
-                   gps/geopositioninfo.h \
-                   gps/geocoordinate.h
-        CONFIG += link_pkgconfig
-        PKGCONFIG += glib-2.0 liblocation
-        LIBS += -llocation
+        CONFIG += icd2
+#        SOURCES += gps/gpspositionprivateliblocation.cpp \
+#                   gps/liblocationwrapper.cpp \
+#                   gps/geopositioninfo.cpp \
+#                   gps/geocoordinate.cpp
+#        HEADERS += gps/gpspositionprivateliblocation.h \
+#                   gps/liblocationwrapper.h \
+#                   gps/geopositioninfo.h \
+#                   gps/geocoordinate.h
+#        CONFIG += link_pkgconfig
+#        PKGCONFIG += glib-2.0 liblocation
+#        LIBS += -llocation
+        SOURCES += gps/gpspositionprivatestub.cpp
+        HEADERS += gps/gpspositionprivatestub.h
     } else {
         SOURCES += gps/gpspositionprivatestub.cpp \
                    network/networkhandlerprivatestub.cpp
index 48d63e5..8635428 100644 (file)
@@ -255,6 +255,9 @@ void MainWindow::buildMap()
 
     connect(m_mapView, SIGNAL(viewZoomFinished()),
             this, SIGNAL(viewZoomFinished()));
+
+    connect(m_mapView, SIGNAL(zoomIn()),
+            this, SIGNAL(zoomIn()));
 }
 
 void MainWindow::buildMapScale()
index 7179447..beaf11f 100644 (file)
@@ -32,6 +32,7 @@ public:
 private slots:
     void init();
     void cleanup();
+    void doubleClick();
     void zoomLevelChange_data();
     void zoomLevelChange();
 
@@ -66,6 +67,18 @@ void TestMapView::cleanup()
 }
 
 /**
+  * @brief Test view double click
+  */
+void TestMapView::doubleClick()
+{
+    QSignalSpy doubleClickSpy(m_mapView, SIGNAL(zoomIn()));
+    QVERIFY(doubleClickSpy.isValid());
+
+    QTest::mouseDClick(m_mapView, Qt::Key_Tab);
+    QCOMPARE(doubleClickSpy.count(), 1);
+}
+
+/**
   * @brief Test data for zoom level change test
   */
 void TestMapView::zoomLevelChange_data()