From 04dc2ccba18a1d6312c7aa26a7f847e8118f7b25 Mon Sep 17 00:00:00 2001 From: Denis Koronchik Date: Fri, 19 Sep 2014 17:58:03 +0300 Subject: [PATCH] [qt] Replace gps pos for testing (with alt key pressed) --- qt/draw_widget.cpp | 26 +++++++++++++++++++++++--- qt/draw_widget.hpp | 4 ++++ qt/mainwindow.cpp | 2 +- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index a525830543..5cdc3aaf08 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -79,7 +79,8 @@ namespace qt m_isRotate(false), //m_redrawInterval(100), m_ratio(1.0), - m_pScale(0) + m_pScale(0), + m_emulatingLocation(false) { // Initialize with some stubs for test. PinClickManager & manager = GetBalloonManager(); @@ -397,6 +398,18 @@ namespace qt else m_framework->StartRoutingSession(m_framework->PtoG(pt)); } + if (e->modifiers() & Qt::AltModifier) + { + m_emulatingLocation = true; + m2::PointD const point = m_framework->PtoG(pt); + + location::GpsInfo info; + info.m_latitude = MercatorBounds::YToLat(point.y); + info.m_longitude = MercatorBounds::XToLon(point.x); + info.m_horizontalAccuracy = 10.0; + + m_framework->OnLocationUpdate(info); + } else { // init press task params @@ -513,6 +526,9 @@ namespace qt QGLWidget::keyReleaseEvent(e); StopRotating(e); + + if (e->key() == Qt::Key_Alt) + m_emulatingLocation = false; } void DrawWidget::StopRotating(QMouseEvent * e) @@ -529,9 +545,7 @@ namespace qt void DrawWidget::StopRotating(QKeyEvent * e) { if (m_isRotate && (e->key() == Qt::Key_Control)) - { m_framework->StopRotate(GetRotateEvent(mapFromGlobal(QCursor::pos()))); - } } void DrawWidget::StopDragging(QMouseEvent * e) @@ -613,6 +627,12 @@ namespace qt setFocus(); } + void DrawWidget::OnLocationUpdate(location::GpsInfo const & info) + { + if (!m_emulatingLocation) + m_framework->OnLocationUpdate(info); + } + void DrawWidget::QueryMaxScaleMode() { m_framework->XorQueryMaxScaleMode(); diff --git a/qt/draw_widget.hpp b/qt/draw_widget.hpp index 4bbedb4a95..136aa8be93 100644 --- a/qt/draw_widget.hpp +++ b/qt/draw_widget.hpp @@ -93,6 +93,8 @@ namespace qt void ShowSearchResult(search::Result const & res); void CloseSearch(); + void OnLocationUpdate(location::GpsInfo const & info); + void SaveState(); void LoadState(); @@ -144,6 +146,8 @@ namespace qt m2::PointD m_taskPoint; bool m_wasLongClick, m_isCleanSingleClick; + bool m_emulatingLocation; + PinClickManager & GetBalloonManager() { return m_framework->GetBalloonManager(); } }; } diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index 4ede1f348d..48c8859570 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -331,7 +331,7 @@ void MainWindow::OnLocationError(location::TLocationError errorCode) void MainWindow::OnLocationUpdated(location::GpsInfo const & info) { - m_pDrawWidget->GetFramework().OnLocationUpdate(info); + m_pDrawWidget->OnLocationUpdate(info); } void MainWindow::OnMyPosition()