#include <QDebug>
#include <QMouseEvent>
+#include <QParallelAnimationGroup>
#include "mapcommon.h"
#include "mapscroller.h"
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)
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)
void MapView::mousePressEvent(QMouseEvent *event)
{
+ qWarning() << __PRETTY_FUNCTION__;
qDebug() << __PRETTY_FUNCTION__;
m_time.start();
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());
#include <QTime>
class QPropertyAnimation;
+class QParallelAnimationGroup;
class MapScroller;
******************************************************************************/
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
*/
void viewZoomFinished();
+ void zoomIn();
+
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
QTime m_time; ///< Elapsed times in mouse events
MapScroller *m_scroller; ///< Kinetic scroller
+
+ QParallelAnimationGroup *m_group;
};
#endif // MAPVIEW_H
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
connect(m_mapView, SIGNAL(viewZoomFinished()),
this, SIGNAL(viewZoomFinished()));
+
+ connect(m_mapView, SIGNAL(zoomIn()),
+ this, SIGNAL(zoomIn()));
}
void MainWindow::buildMapScale()
private slots:
void init();
void cleanup();
+ void doubleClick();
void zoomLevelChange_data();
void zoomLevelChange();
}
/**
+ * @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()