forked from organicmaps/organicmaps
[assessment-tool] Implemented viewport move to a selected search result.
This commit is contained in:
parent
1e899e5a89
commit
9171ff6ce9
9 changed files with 51 additions and 6 deletions
|
@ -72,6 +72,7 @@ void MainModel::Open(string const & path)
|
|||
m_path = path;
|
||||
|
||||
m_view->SetSamples(ContextList::SamplesSlice(m_contexts));
|
||||
m_selectedSample = -1;
|
||||
}
|
||||
|
||||
void MainModel::Save()
|
||||
|
@ -112,6 +113,8 @@ void MainModel::OnSampleSelected(int index)
|
|||
CHECK_LESS(index, m_contexts.Size(), ());
|
||||
CHECK(m_view, ());
|
||||
|
||||
m_selectedSample = index;
|
||||
|
||||
auto & context = m_contexts[index];
|
||||
auto const & sample = context.m_sample;
|
||||
m_view->ShowSample(index, sample, context.HasChanges());
|
||||
|
@ -169,6 +172,18 @@ void MainModel::OnSampleSelected(int index)
|
|||
}
|
||||
}
|
||||
|
||||
void MainModel::OnResultSelected(int index)
|
||||
{
|
||||
CHECK_GREATER_OR_EQUAL(m_selectedSample, 0, ());
|
||||
CHECK_LESS(m_selectedSample, m_contexts.Size(), ());
|
||||
auto const & context = m_contexts[m_selectedSample];
|
||||
auto const & results = context.m_results;
|
||||
|
||||
CHECK_GREATER_OR_EQUAL(index, 0, ());
|
||||
CHECK_LESS(index, results.GetCount(), ());
|
||||
m_view->MoveViewportToResult(results.GetResult(index));
|
||||
}
|
||||
|
||||
bool MainModel::HasChanges() { return m_contexts.HasChanges(); }
|
||||
|
||||
void MainModel::OnUpdate(size_t index, Edits::Update const & update)
|
||||
|
@ -193,13 +208,14 @@ void MainModel::OnResults(uint64_t timestamp, size_t index, search::Results cons
|
|||
m_view->ShowResults(results.begin() + m_numShownResults, results.end());
|
||||
m_numShownResults = results.GetCount();
|
||||
|
||||
auto & context = m_contexts[index];
|
||||
context.m_results = results;
|
||||
|
||||
if (!results.IsEndedNormal())
|
||||
return;
|
||||
|
||||
auto & context = m_contexts[index];
|
||||
if (!context.m_initialized)
|
||||
{
|
||||
context.m_results = results;
|
||||
context.m_edits.ResetRelevances(relevances);
|
||||
context.m_goldenMatching = goldenMatching;
|
||||
context.m_actualMatching = actualMatching;
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
void SaveAs(std::string const & path) override;
|
||||
|
||||
void OnSampleSelected(int index) override;
|
||||
void OnResultSelected(int index) override;
|
||||
bool HasChanges() override;
|
||||
|
||||
private:
|
||||
|
@ -53,6 +54,7 @@ private:
|
|||
|
||||
std::weak_ptr<search::ProcessorHandle> m_queryHandle;
|
||||
uint64_t m_queryTimestamp = 0;
|
||||
int m_selectedSample = -1;
|
||||
size_t m_numShownResults = 0;
|
||||
|
||||
ThreadChecker m_threadChecker;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "search/search_quality/assessment_tool/helpers.hpp"
|
||||
#include "search/search_quality/assessment_tool/model.hpp"
|
||||
#include "search/search_quality/assessment_tool/results_view.hpp"
|
||||
#include "search/search_quality/assessment_tool/sample_view.hpp"
|
||||
#include "search/search_quality/assessment_tool/samples_view.hpp"
|
||||
|
||||
|
@ -72,6 +73,11 @@ void MainView::ShowResults(search::Results::Iter begin, search::Results::Iter en
|
|||
m_sampleView->ShowResults(begin, end);
|
||||
}
|
||||
|
||||
void MainView::MoveViewportToResult(search::Result const & result)
|
||||
{
|
||||
m_framework.ShowSearchResult(result);
|
||||
}
|
||||
|
||||
void MainView::OnSampleChanged(size_t index, Edits::Update const & update, bool hasEdits)
|
||||
{
|
||||
m_samplesView->OnUpdate(index);
|
||||
|
@ -127,6 +133,14 @@ void MainView::OnSampleSelected(QItemSelection const & current)
|
|||
m_model->OnSampleSelected(index.row());
|
||||
}
|
||||
|
||||
void MainView::OnResultSelected(QItemSelection const & current)
|
||||
{
|
||||
CHECK(m_model, ());
|
||||
auto indexes = current.indexes();
|
||||
for (auto const & index : indexes)
|
||||
m_model->OnResultSelected(index.row());
|
||||
}
|
||||
|
||||
void MainView::InitMenuBar()
|
||||
{
|
||||
auto * bar = menuBar();
|
||||
|
@ -217,6 +231,13 @@ void MainView::InitDocks()
|
|||
SetSamplesDockTitle(false /* hasEdits */);
|
||||
|
||||
m_sampleView = new SampleView(this /* parent */);
|
||||
|
||||
{
|
||||
auto * model = m_sampleView->GetResultsView().selectionModel();
|
||||
connect(model, SIGNAL(selectionChanged(QItemSelection const &, QItemSelection const &)), this,
|
||||
SLOT(OnResultSelected(QItemSelection const &)));
|
||||
}
|
||||
|
||||
m_sampleDock = CreateDock(*m_sampleView);
|
||||
addDockWidget(Qt::RightDockWidgetArea, m_sampleDock);
|
||||
SetSampleDockTitle(false /* hasEdits */);
|
||||
|
|
|
@ -31,6 +31,8 @@ public:
|
|||
void ShowSample(size_t index, search::Sample const & sample, bool hasEdits) override;
|
||||
void ShowResults(search::Results::Iter begin, search::Results::Iter end) override;
|
||||
|
||||
void MoveViewportToResult(search::Result const & result) override;
|
||||
|
||||
void OnSampleChanged(size_t index, Edits::Update const & update, bool hasEdits) override;
|
||||
void EnableSampleEditing(size_t index, Edits & edits) override;
|
||||
void OnSamplesChanged(bool hasEdits) override;
|
||||
|
@ -45,6 +47,7 @@ protected:
|
|||
|
||||
private Q_SLOTS:
|
||||
void OnSampleSelected(QItemSelection const & current);
|
||||
void OnResultSelected(QItemSelection const & current);
|
||||
|
||||
private:
|
||||
enum class SaveResult
|
||||
|
|
|
@ -16,6 +16,7 @@ public:
|
|||
virtual void SaveAs(std::string const & path) = 0;
|
||||
|
||||
virtual void OnSampleSelected(int index) = 0;
|
||||
virtual void OnResultSelected(int index) = 0;
|
||||
virtual bool HasChanges() = 0;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace search
|
|||
class Result;
|
||||
}
|
||||
|
||||
class ResultsView : private QListWidget
|
||||
class ResultsView : public QListWidget
|
||||
{
|
||||
public:
|
||||
explicit ResultsView(QWidget & parent);
|
||||
|
@ -30,8 +30,6 @@ public:
|
|||
|
||||
void Clear();
|
||||
|
||||
QWidget * GetWidget() { return this; }
|
||||
|
||||
private:
|
||||
std::vector<ResultView *> m_results;
|
||||
};
|
||||
|
|
|
@ -53,7 +53,7 @@ SampleView::SampleView(QWidget * parent) : QWidget(parent)
|
|||
layout->addWidget(new QLabel(tr("Found results")));
|
||||
|
||||
m_results = new ResultsView(*box /* parent */);
|
||||
layout->addWidget(m_results->GetWidget());
|
||||
layout->addWidget(m_results);
|
||||
|
||||
mainLayout->addWidget(box);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ public:
|
|||
void Update(Edits::Update const & update);
|
||||
void Clear();
|
||||
|
||||
ResultsView & GetResultsView() { return *m_results; }
|
||||
|
||||
private:
|
||||
QLineEdit * m_query = nullptr;
|
||||
LanguagesList * m_langs = nullptr;
|
||||
|
|
|
@ -22,6 +22,8 @@ public:
|
|||
virtual void ShowSample(size_t index, search::Sample const & sample, bool hasEdits) = 0;
|
||||
virtual void ShowResults(search::Results::Iter begin, search::Results::Iter end) = 0;
|
||||
|
||||
virtual void MoveViewportToResult(search::Result const & result) = 0;
|
||||
|
||||
virtual void OnSampleChanged(size_t index, Edits::Update const & update, bool hasEdits) = 0;
|
||||
virtual void EnableSampleEditing(size_t index, Edits & edits) = 0;
|
||||
virtual void OnSamplesChanged(bool hasEdits) = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue