[desktop] Correct distance in search results.

This commit is contained in:
vng 2013-03-28 19:58:49 +03:00 committed by Alex Zolotarev
parent 51af009487
commit eb1efa49ef
3 changed files with 23 additions and 15 deletions

View file

@ -4,6 +4,8 @@
#include "../map/render_policy.hpp"
#include "../search/result.hpp"
#include "../gui/controller.hpp"
#include "../graphics/opengl/opengl.hpp"
@ -11,6 +13,8 @@
#include "../platform/settings.hpp"
#include "../platform/platform.hpp"
#include <QtCore/QLocale>
#include <QtGui/QMouseEvent>
#include <QtGui/QMenu>
#include <QtGui/QApplication>
@ -501,9 +505,25 @@ namespace qt
if (m_framework->GetCurrentPosition(lat, lon))
params.SetPosition(lat, lon);
/// @todo This stuff doesn't work (QT4xx bug). Probably in QT5 ...
//QLocale loc = QApplication::keyboardInputLocale();
//params.SetInputLanguage(loc.name().toAscii().data());
return m_framework->Search(params);
}
string DrawWidget::GetDistance(search::Result const & res) const
{
string dist;
double lat, lon;
if (m_framework->GetCurrentPosition(lat, lon))
{
double dummy;
(void) m_framework->GetDistanceAndAzimut(res.GetFeatureCenter(), lat, lon, -1.0, dist, dummy);
}
return dist;
}
void DrawWidget::ShowSearchResult(search::Result const & res)
{
m_framework->ShowSearchResult(res);

View file

@ -83,6 +83,7 @@ namespace qt
void SetScaleControl(QScaleSlider * pScale);
bool Search(search::SearchParams params);
string GetDistance(search::Result const & res) const;
void ShowSearchResult(search::Result const & res);
void CloseSearch();

View file

@ -148,22 +148,9 @@ void SearchPanel::OnSearchResult(ResultsT * res)
Bookmark bm(e.GetFeatureCenter(), e.GetString(), "placemark-red");
frm.AdditionalPoiLayerAddPoi(bm);
m_pTable->setItem(rowCount, 0,
create_item(QString::fromUtf8(e.GetFeatureType())));
m_pTable->setItem(rowCount, 0, create_item(QString::fromUtf8(e.GetFeatureType())));
string strDist;
bool const drawDir = MeasurementUtils::FormatDistance(e.GetDistanceFromCenter(), strDist);
m_pTable->setItem(rowCount, 3, create_item(strDist.c_str()));
if (drawDir)
{
/*
QTableWidgetItem * item =
new QTableWidgetItem(draw_direction(e.GetDirectionFromCenter()), QString());
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
m_pTable->setItem(rowCount, 4, item);
*/
}
m_pTable->setItem(rowCount, 3, create_item(m_pDrawWidget->GetDistance(e).c_str()));
}
m_results.push_back(e);