diff --git a/platform/location.hpp b/platform/location.hpp index 38b5b4fe66..6311af4cf5 100644 --- a/platform/location.hpp +++ b/platform/location.hpp @@ -32,7 +32,8 @@ namespace location EAndroidNative, EGoogle, ETizen, - EPredictor + EPredictor, + EUser }; /// Our structure ALWAYS has valid lat, lon and horizontal accuracy. diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index 858b17236f..24b405e954 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -28,7 +28,6 @@ #include #include -#include #include #include @@ -317,15 +316,8 @@ void DrawWidget::SetMapStyle(MapStyle mapStyle) void DrawWidget::SubmitFakeLocationPoint(m2::PointD const & pt) { m_emulatingLocation = true; - m2::PointD const point = m_framework.P3dtoG(pt); - - location::GpsInfo info; - info.m_latitude = MercatorBounds::YToLat(point.y); - info.m_longitude = MercatorBounds::XToLon(point.x); - info.m_horizontalAccuracy = 10; - info.m_timestamp = QDateTime::currentMSecsSinceEpoch() / 1000.0; - - m_framework.OnLocationUpdate(info); + auto const point = m_framework.P3dtoG(pt); + m_framework.OnLocationUpdate(qt::common::MakeGpsInfo(point)); if (m_framework.GetRoutingManager().IsRoutingActive()) { diff --git a/qt/qt_common/helpers.cpp b/qt/qt_common/helpers.cpp index a6081809b3..15ba4b68b1 100644 --- a/qt/qt_common/helpers.cpp +++ b/qt/qt_common/helpers.cpp @@ -1,5 +1,9 @@ #include "qt/qt_common/helpers.hpp" +#include "geometry/mercator.hpp" + +#include + namespace qt { namespace common @@ -23,5 +27,16 @@ bool IsCommandModifier(QMouseEvent const * const e) { return e->modifiers() & Qt bool IsShiftModifier(QMouseEvent const * const e) { return e->modifiers() & Qt::ShiftModifier; } bool IsAltModifier(QMouseEvent const * const e) { return e->modifiers() & Qt::AltModifier; } + +location::GpsInfo MakeGpsInfo(m2::PointD const & point) +{ + location::GpsInfo info; + info.m_source = location::EUser; + info.m_latitude = MercatorBounds::YToLat(point.y); + info.m_longitude = MercatorBounds::XToLon(point.x); + info.m_horizontalAccuracy = 10; + info.m_timestamp = QDateTime::currentMSecsSinceEpoch() / 1000.0; + return info; +} } // namespace common } // namespace qt diff --git a/qt/qt_common/helpers.hpp b/qt/qt_common/helpers.hpp index 71c1c37e83..b3f6882852 100644 --- a/qt/qt_common/helpers.hpp +++ b/qt/qt_common/helpers.hpp @@ -1,5 +1,7 @@ #pragma once +#include "platform/location.hpp" + #include namespace qt @@ -24,5 +26,7 @@ struct Hotkey int m_key = 0; char const * m_slot = nullptr; }; + +location::GpsInfo MakeGpsInfo(m2::PointD const & point); } // namespace common } // namespace qt diff --git a/search/search_quality/assessment_tool/main_model.cpp b/search/search_quality/assessment_tool/main_model.cpp index 7680e318fd..1ef4b5108d 100644 --- a/search/search_quality/assessment_tool/main_model.cpp +++ b/search/search_quality/assessment_tool/main_model.cpp @@ -122,7 +122,7 @@ void MainModel::OnSampleSelected(int index) auto & context = m_contexts[index]; auto const & sample = context.m_sample; - m_view->ShowSample(index, sample, sample.m_posAvailable, context.HasChanges()); + m_view->ShowSample(index, sample, sample.m_posAvailable, sample.m_pos, context.HasChanges()); ResetSearch(); auto const timestamp = m_queryTimestamp; diff --git a/search/search_quality/assessment_tool/main_view.cpp b/search/search_quality/assessment_tool/main_view.cpp index 6c4a6cf28b..1aee006781 100644 --- a/search/search_quality/assessment_tool/main_view.cpp +++ b/search/search_quality/assessment_tool/main_view.cpp @@ -82,11 +82,11 @@ void MainView::OnSearchCompleted() } void MainView::ShowSample(size_t sampleIndex, search::Sample const & sample, bool positionAvailable, - bool hasEdits) + m2::PointD const & position, bool hasEdits) { MoveViewportToRect(sample.m_viewport); - m_sampleView->SetContents(sample, positionAvailable); + m_sampleView->SetContents(sample, positionAvailable, position); m_sampleView->show(); OnResultChanged(sampleIndex, ResultType::Found, Edits::Update::MakeAll()); diff --git a/search/search_quality/assessment_tool/main_view.hpp b/search/search_quality/assessment_tool/main_view.hpp index 03b29c2885..59968fc668 100644 --- a/search/search_quality/assessment_tool/main_view.hpp +++ b/search/search_quality/assessment_tool/main_view.hpp @@ -33,7 +33,7 @@ public: void OnSearchStarted() override; void OnSearchCompleted() override; void ShowSample(size_t sampleIndex, search::Sample const & sample, bool positionAvailable, - bool hasEdits) override; + m2::PointD const & position, bool hasEdits) override; void AddFoundResults(search::Results::ConstIter begin, search::Results::ConstIter end) override; void ShowNonFoundResults(std::vector const & results, diff --git a/search/search_quality/assessment_tool/sample_view.cpp b/search/search_quality/assessment_tool/sample_view.cpp index a460461f4f..07a9f47fbd 100644 --- a/search/search_quality/assessment_tool/sample_view.cpp +++ b/search/search_quality/assessment_tool/sample_view.cpp @@ -1,5 +1,6 @@ #include "search/search_quality/assessment_tool/sample_view.hpp" +#include "qt/qt_common/helpers.hpp" #include "qt/qt_common/spinner.hpp" #include "map/bookmark_manager.hpp" @@ -12,6 +13,8 @@ #include "search/search_quality/assessment_tool/results_view.hpp" #include "search/search_quality/sample.hpp" +#include "platform/location.hpp" + #include #include #include @@ -150,7 +153,8 @@ SampleView::SampleView(QWidget * parent, Framework & framework) Clear(); } -void SampleView::SetContents(search::Sample const & sample, bool positionAvailable) +void SampleView::SetContents(search::Sample const & sample, bool positionAvailable, + m2::PointD const & position) { if (!sample.m_query.empty()) { @@ -172,6 +176,10 @@ void SampleView::SetContents(search::Sample const & sample, bool positionAvailab m_relatedQueriesBox->show(); ClearAllResults(); + if (positionAvailable) + ShowUserPosition(position); + else + HideUserPosition(); } void SampleView::OnSearchStarted() { m_spinner->Show(); } @@ -264,6 +272,7 @@ void SampleView::Clear() m_relatedQueriesBox->hide(); ClearAllResults(); + HideUserPosition(); OnSearchCompleted(); } @@ -284,3 +293,13 @@ void SampleView::SetEdits(ResultsView & results, Edits & edits) } void SampleView::OnRemoveNonFoundResult(int row) { m_nonFoundResultsEdits->Delete(row); } + +void SampleView::ShowUserPosition(m2::PointD const & position) +{ + m_framework.OnLocationUpdate(qt::common::MakeGpsInfo(position)); +} + +void SampleView::HideUserPosition() +{ + m_framework.OnLocationError(location::EGPSIsOff); +} diff --git a/search/search_quality/assessment_tool/sample_view.hpp b/search/search_quality/assessment_tool/sample_view.hpp index aca6e59c77..8bf4ebb801 100644 --- a/search/search_quality/assessment_tool/sample_view.hpp +++ b/search/search_quality/assessment_tool/sample_view.hpp @@ -4,6 +4,8 @@ #include "search/search_quality/assessment_tool/edits.hpp" #include "search/search_quality/sample.hpp" +#include "geometry/point2d.hpp" + #include #include @@ -23,7 +25,8 @@ public: SampleView(QWidget * parent, Framework & framework); - void SetContents(search::Sample const & sample, bool positionAvailable); + void SetContents(search::Sample const & sample, bool positionAvailable, + m2::PointD const & position); void OnSearchStarted(); void OnSearchCompleted(); @@ -54,6 +57,9 @@ private: void SetEdits(ResultsView & results, Edits & edits); void OnRemoveNonFoundResult(int row); + void ShowUserPosition(m2::PointD const & position); + void HideUserPosition(); + Framework & m_framework; Spinner * m_spinner = nullptr; diff --git a/search/search_quality/assessment_tool/view.hpp b/search/search_quality/assessment_tool/view.hpp index 166418e281..4e319f3e1d 100644 --- a/search/search_quality/assessment_tool/view.hpp +++ b/search/search_quality/assessment_tool/view.hpp @@ -5,6 +5,7 @@ #include "search/search_quality/assessment_tool/edits.hpp" #include "search/search_quality/sample.hpp" +#include "geometry/point2d.hpp" #include "geometry/rect2d.hpp" #include @@ -31,7 +32,7 @@ public: virtual void OnSearchStarted() = 0; virtual void OnSearchCompleted() = 0; virtual void ShowSample(size_t index, search::Sample const & sample, bool positionAvailable, - bool hasEdits) = 0; + m2::PointD const & position, bool hasEdits) = 0; virtual void AddFoundResults(search::Results::ConstIter begin, search::Results::ConstIter end) = 0;