forked from organicmaps/organicmaps
[assessment-tool] Added buttons that display user position and viewport.
This commit is contained in:
parent
d6aad15547
commit
5d7c0d9b27
11 changed files with 91 additions and 21 deletions
|
@ -1590,7 +1590,7 @@ bool Framework::QueryMayBeSkipped(SearchIntent const & intent, search::SearchPar
|
|||
return true;
|
||||
}
|
||||
|
||||
void Framework::ShowSearchResult(search::Result const & res)
|
||||
void Framework::ShowSearchResult(search::Result const & res, bool animation)
|
||||
{
|
||||
CancelAllSearches();
|
||||
StopLocationFollow();
|
||||
|
@ -1619,7 +1619,7 @@ void Framework::ShowSearchResult(search::Result const & res)
|
|||
}
|
||||
|
||||
m2::PointD const center = info.GetMercator();
|
||||
CallDrapeFunction(bind(&df::DrapeEngine::SetModelViewCenter, _1, center, scale, true));
|
||||
CallDrapeFunction(bind(&df::DrapeEngine::SetModelViewCenter, _1, center, scale, animation));
|
||||
|
||||
UserMarkContainer::UserMarkForPoi()->SetPtOrg(center);
|
||||
ActivateMapSelection(false, df::SelectionShape::OBJECT_POI, info);
|
||||
|
|
|
@ -549,7 +549,7 @@ public:
|
|||
|
||||
bool GetCurrentPosition(double & lat, double & lon) const;
|
||||
|
||||
void ShowSearchResult(search::Result const & res);
|
||||
void ShowSearchResult(search::Result const & res, bool animation = true);
|
||||
size_t ShowSearchResults(search::Results const & results);
|
||||
|
||||
list<TSearchRequest> const & GetLastSearchQueries() const { return m_searchQuerySaver.Get(); }
|
||||
|
|
|
@ -99,6 +99,8 @@ void ContextList::Resize(size_t size)
|
|||
|
||||
for (size_t i = size; i < oldSize; ++i)
|
||||
m_contexts[i].Clear();
|
||||
if (size < m_contexts.size())
|
||||
m_contexts.erase(m_contexts.begin() + size, m_contexts.end());
|
||||
|
||||
m_hasChanges.resize(size);
|
||||
for (size_t i = oldSize; i < size; ++i)
|
||||
|
|
|
@ -184,6 +184,29 @@ void MainModel::OnResultSelected(int index)
|
|||
m_view->MoveViewportToResult(results.GetResult(index));
|
||||
}
|
||||
|
||||
void MainModel::OnShowViewportClicked()
|
||||
{
|
||||
CHECK(m_selectedSample != kInvalidIndex, ());
|
||||
CHECK(m_selectedSample < m_contexts.Size(), ());
|
||||
|
||||
auto const & context = m_contexts[m_selectedSample];
|
||||
m_view->MoveViewportToRect(context.m_sample.m_viewport);
|
||||
}
|
||||
|
||||
void MainModel::OnShowPositionClicked()
|
||||
{
|
||||
CHECK(m_selectedSample != kInvalidIndex, ());
|
||||
CHECK(m_selectedSample < m_contexts.Size(), ());
|
||||
|
||||
static int constexpr kViewportAroundPositionSizeM = 100;
|
||||
|
||||
auto const & context = m_contexts[m_selectedSample];
|
||||
auto const & position = context.m_sample.m_pos;
|
||||
auto const rect =
|
||||
MercatorBounds::RectByCenterXYAndSizeInMeters(position, kViewportAroundPositionSizeM);
|
||||
m_view->MoveViewportToRect(rect);
|
||||
}
|
||||
|
||||
bool MainModel::HasChanges() { return m_contexts.HasChanges(); }
|
||||
|
||||
void MainModel::OnUpdate(size_t index, Edits::Update const & update)
|
||||
|
|
|
@ -32,6 +32,8 @@ public:
|
|||
|
||||
void OnSampleSelected(int index) override;
|
||||
void OnResultSelected(int index) override;
|
||||
void OnShowViewportClicked() override;
|
||||
void OnShowPositionClicked() override;
|
||||
bool HasChanges() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -60,7 +60,7 @@ void MainView::SetSamples(ContextList::SamplesSlice const & samples)
|
|||
|
||||
void MainView::ShowSample(size_t index, search::Sample const & sample, bool hasEdits)
|
||||
{
|
||||
m_framework.ShowRect(sample.m_viewport, -1 /* maxScale */, false /* animation */);
|
||||
MoveViewportToRect(sample.m_viewport);
|
||||
|
||||
m_sampleView->SetContents(sample);
|
||||
m_sampleView->show();
|
||||
|
@ -75,7 +75,12 @@ void MainView::ShowResults(search::Results::Iter begin, search::Results::Iter en
|
|||
|
||||
void MainView::MoveViewportToResult(search::Result const & result)
|
||||
{
|
||||
m_framework.ShowSearchResult(result);
|
||||
m_framework.ShowSearchResult(result, false /* animation */);
|
||||
}
|
||||
|
||||
void MainView::MoveViewportToRect(m2::RectD const & rect)
|
||||
{
|
||||
m_framework.ShowRect(rect, -1 /* maxScale */, false /* animation */);
|
||||
}
|
||||
|
||||
void MainView::OnSampleChanged(size_t index, Edits::Update const & update, bool hasEdits)
|
||||
|
@ -222,8 +227,7 @@ void MainView::InitDocks()
|
|||
|
||||
{
|
||||
auto * model = m_samplesView->selectionModel();
|
||||
connect(model, SIGNAL(selectionChanged(QItemSelection const &, QItemSelection const &)), this,
|
||||
SLOT(OnSampleSelected(QItemSelection const &)));
|
||||
connect(model, &QItemSelectionModel::selectionChanged, this, &MainView::OnSampleSelected);
|
||||
}
|
||||
|
||||
m_samplesDock = CreateDock(*m_samplesView);
|
||||
|
@ -232,10 +236,14 @@ void MainView::InitDocks()
|
|||
|
||||
m_sampleView = new SampleView(this /* parent */);
|
||||
|
||||
connect(m_sampleView, &SampleView::OnShowViewportClicked,
|
||||
[this]() { m_model->OnShowViewportClicked(); });
|
||||
connect(m_sampleView, &SampleView::OnShowPositionClicked,
|
||||
[this]() { m_model->OnShowPositionClicked(); });
|
||||
|
||||
{
|
||||
auto * model = m_sampleView->GetResultsView().selectionModel();
|
||||
connect(model, SIGNAL(selectionChanged(QItemSelection const &, QItemSelection const &)), this,
|
||||
SLOT(OnResultSelected(QItemSelection const &)));
|
||||
connect(model, &QItemSelectionModel::selectionChanged, this, &MainView::OnResultSelected);
|
||||
}
|
||||
|
||||
m_sampleDock = CreateDock(*m_sampleView);
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
void ShowResults(search::Results::Iter begin, search::Results::Iter end) override;
|
||||
|
||||
void MoveViewportToResult(search::Result const & result) override;
|
||||
void MoveViewportToRect(m2::RectD const & rect) override;
|
||||
|
||||
void OnSampleChanged(size_t index, Edits::Update const & update, bool hasEdits) override;
|
||||
void EnableSampleEditing(size_t index, Edits & edits) override;
|
||||
|
@ -45,7 +46,7 @@ protected:
|
|||
// QMainWindow overrides:
|
||||
void closeEvent(QCloseEvent * event) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
private slots:
|
||||
void OnSampleSelected(QItemSelection const & current);
|
||||
void OnResultSelected(QItemSelection const & current);
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ public:
|
|||
|
||||
virtual void OnSampleSelected(int index) = 0;
|
||||
virtual void OnResultSelected(int index) = 0;
|
||||
virtual void OnShowViewportClicked() = 0;
|
||||
virtual void OnShowPositionClicked() = 0;
|
||||
virtual bool HasChanges() = 0;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -15,16 +15,28 @@
|
|||
#include <QtWidgets/QHeaderView>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QLineEdit>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename Layout>
|
||||
Layout * BuildSubLayout(QLayout & mainLayout, QWidget & parent)
|
||||
{
|
||||
auto * box = new QWidget(&parent);
|
||||
auto * subLayout = BuildLayoutWithoutMargins<Layout>(box /* parent */);
|
||||
box->setLayout(subLayout);
|
||||
mainLayout.addWidget(box);
|
||||
return subLayout;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SampleView::SampleView(QWidget * parent) : QWidget(parent)
|
||||
{
|
||||
auto * mainLayout = BuildLayoutWithoutMargins<QVBoxLayout>(this /* parent */);
|
||||
|
||||
{
|
||||
auto * box = new QWidget(this /* parent */);
|
||||
auto * layout = BuildLayoutWithoutMargins<QHBoxLayout>(box /* parent */);
|
||||
box->setLayout(layout);
|
||||
auto * layout = BuildSubLayout<QHBoxLayout>(*mainLayout, *this /* parent */);
|
||||
|
||||
m_query = new QLineEdit(this /* parent */);
|
||||
m_query->setToolTip(tr("Query text"));
|
||||
|
@ -41,21 +53,27 @@ SampleView::SampleView(QWidget * parent) : QWidget(parent)
|
|||
// will be ready.
|
||||
m_langs->setEnabled(false);
|
||||
layout->addWidget(m_langs);
|
||||
|
||||
mainLayout->addWidget(box);
|
||||
}
|
||||
|
||||
{
|
||||
auto * box = new QWidget(this /* parent */);
|
||||
auto * layout = BuildLayoutWithoutMargins<QVBoxLayout>(box /* parent */);
|
||||
box->setLayout(layout);
|
||||
auto * layout = BuildSubLayout<QHBoxLayout>(*mainLayout, *this /* parent */);
|
||||
|
||||
m_showViewport = new QPushButton(tr("Show viewport"), this /* parent */);
|
||||
connect(m_showViewport, &QPushButton::clicked, [this]() { emit OnShowViewportClicked(); });
|
||||
layout->addWidget(m_showViewport);
|
||||
|
||||
m_showPosition = new QPushButton(tr("Show position"), this /* parent */);
|
||||
connect(m_showPosition, &QPushButton::clicked, [this]() { emit OnShowPositionClicked(); });
|
||||
layout->addWidget(m_showPosition);
|
||||
}
|
||||
|
||||
{
|
||||
auto * layout = BuildSubLayout<QVBoxLayout>(*mainLayout, *this /* parent */);
|
||||
|
||||
layout->addWidget(new QLabel(tr("Found results")));
|
||||
|
||||
m_results = new ResultsView(*box /* parent */);
|
||||
m_results = new ResultsView(*this /* parent */);
|
||||
layout->addWidget(m_results);
|
||||
|
||||
mainLayout->addWidget(box);
|
||||
}
|
||||
|
||||
setLayout(mainLayout);
|
||||
|
@ -69,6 +87,8 @@ void SampleView::SetContents(search::Sample const & sample)
|
|||
m_query->home(false /* mark */);
|
||||
|
||||
m_langs->Select(sample.m_locale);
|
||||
m_showViewport->setEnabled(true);
|
||||
m_showPosition->setEnabled(true);
|
||||
|
||||
m_results->Clear();
|
||||
}
|
||||
|
@ -95,6 +115,8 @@ void SampleView::Clear()
|
|||
{
|
||||
m_query->setText(QString());
|
||||
m_langs->Select("default");
|
||||
m_showViewport->setEnabled(false);
|
||||
m_showPosition->setEnabled(false);
|
||||
m_results->Clear();
|
||||
m_edits = nullptr;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
class LanguagesList;
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
class ResultsView;
|
||||
|
||||
class SampleView : public QWidget
|
||||
|
@ -29,9 +30,15 @@ public:
|
|||
|
||||
ResultsView & GetResultsView() { return *m_results; }
|
||||
|
||||
signals:
|
||||
void OnShowViewportClicked();
|
||||
void OnShowPositionClicked();
|
||||
|
||||
private:
|
||||
QLineEdit * m_query = nullptr;
|
||||
LanguagesList * m_langs = nullptr;
|
||||
QPushButton * m_showViewport = nullptr;
|
||||
QPushButton * m_showPosition = nullptr;
|
||||
ResultsView * m_results = nullptr;
|
||||
|
||||
Edits * m_edits = nullptr;
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "search/search_quality/assessment_tool/context.hpp"
|
||||
#include "search/search_quality/assessment_tool/edits.hpp"
|
||||
|
||||
#include "geometry/rect2d.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -23,6 +25,7 @@ public:
|
|||
virtual void ShowResults(search::Results::Iter begin, search::Results::Iter end) = 0;
|
||||
|
||||
virtual void MoveViewportToResult(search::Result const & result) = 0;
|
||||
virtual void MoveViewportToRect(m2::RectD const & rect) = 0;
|
||||
|
||||
virtual void OnSampleChanged(size_t index, Edits::Update const & update, bool hasEdits) = 0;
|
||||
virtual void EnableSampleEditing(size_t index, Edits & edits) = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue