forked from organicmaps/organicmaps
Simple bookmarks routine.
This commit is contained in:
parent
fc27fb88ec
commit
c0d4b2c0ea
7 changed files with 61 additions and 11 deletions
20
map/bookmark.hpp
Normal file
20
map/bookmark.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include "../geometry/point2d.hpp"
|
||||
|
||||
#include "../std/string.hpp"
|
||||
|
||||
|
||||
class Bookmark
|
||||
{
|
||||
m2::PointD m_org;
|
||||
string m_name;
|
||||
|
||||
public:
|
||||
Bookmark(m2::PointD const & org, string const & name)
|
||||
: m_org(org), m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
m2::PointD GetOrg() const { return m_org; }
|
||||
};
|
|
@ -181,6 +181,16 @@ void Framework::RemoveLocalMaps()
|
|||
m_model.RemoveAllCountries();
|
||||
}
|
||||
|
||||
void Framework::AddBookmark(m2::PointD const & pt, string const & name)
|
||||
{
|
||||
m_bookmarks.push_back(Bookmark(pt, name));
|
||||
}
|
||||
|
||||
void Framework::ClearBookmarks()
|
||||
{
|
||||
m_bookmarks.clear();
|
||||
}
|
||||
|
||||
void Framework::GetLocalMaps(vector<string> & outMaps)
|
||||
{
|
||||
Platform & pl = GetPlatform();
|
||||
|
@ -378,7 +388,9 @@ void Framework::DrawAdditionalInfo(shared_ptr<PaintEvent> const & e)
|
|||
{
|
||||
ASSERT ( m_renderPolicy, () );
|
||||
|
||||
e->drawer()->screen()->beginFrame();
|
||||
DrawerYG * pDrawer = e->drawer();
|
||||
|
||||
pDrawer->screen()->beginFrame();
|
||||
|
||||
/// m_informationDisplay is set and drawn after the m_renderPolicy
|
||||
|
||||
|
@ -394,14 +406,20 @@ void Framework::DrawAdditionalInfo(shared_ptr<PaintEvent> const & e)
|
|||
|
||||
m_informationDisplay.enableRuler(true/*!IsEmptyModel()*/);
|
||||
|
||||
m_informationDisplay.doDraw(e->drawer());
|
||||
m_informationDisplay.doDraw(pDrawer);
|
||||
|
||||
m_locationState.DrawMyPosition(*e->drawer(), m_navigator.Screen());
|
||||
m_locationState.DrawMyPosition(*pDrawer, m_navigator.Screen());
|
||||
|
||||
if (m_drawPlacemark)
|
||||
m_informationDisplay.drawPlacemark(e->drawer(), m_navigator.GtoP(m_placemark));
|
||||
m_informationDisplay.drawPlacemark(pDrawer, "placemark", m_navigator.GtoP(m_placemark));
|
||||
|
||||
e->drawer()->screen()->endFrame();
|
||||
for (list<Bookmark>::const_iterator i = m_bookmarks.begin(); i != m_bookmarks.end(); ++i)
|
||||
{
|
||||
/// @todo Pass different symbol.
|
||||
m_informationDisplay.drawPlacemark(pDrawer, "placemark", m_navigator.GtoP(i->GetOrg()));
|
||||
}
|
||||
|
||||
pDrawer->screen()->endFrame();
|
||||
}
|
||||
|
||||
/// Function for calling from platform dependent-paint function.
|
||||
|
|
|
@ -8,9 +8,12 @@
|
|||
#include "location_state.hpp"
|
||||
#include "navigator.hpp"
|
||||
#include "feature_vec_model.hpp"
|
||||
#include "bookmark.hpp"
|
||||
|
||||
#include "../defines.hpp"
|
||||
|
||||
#include "../search/search_engine.hpp"
|
||||
|
||||
#include "../storage/storage.hpp"
|
||||
|
||||
#include "../indexer/mercator.hpp"
|
||||
|
@ -43,8 +46,6 @@
|
|||
#include "../std/scoped_ptr.hpp"
|
||||
#include "../std/target_os.hpp"
|
||||
|
||||
#include "../search/search_engine.hpp"
|
||||
|
||||
|
||||
//#define DRAW_TOUCH_POINTS
|
||||
|
||||
|
@ -59,6 +60,8 @@ protected:
|
|||
model::FeaturesFetcher m_model;
|
||||
Navigator m_navigator;
|
||||
|
||||
list<Bookmark> m_bookmarks;
|
||||
|
||||
scoped_ptr<RenderPolicy> m_renderPolicy;
|
||||
bool m_hasPendingInvalidate, m_doForceUpdate, m_queryMaxScaleMode, m_drawPlacemark;
|
||||
|
||||
|
@ -116,6 +119,9 @@ public:
|
|||
void AddLocalMaps();
|
||||
void RemoveLocalMaps();
|
||||
|
||||
void AddBookmark(m2::PointD const & pt, string const & name);
|
||||
void ClearBookmarks();
|
||||
|
||||
storage::Storage & Storage() { return m_storage; }
|
||||
|
||||
void OnLocationStatusChanged(location::TLocationStatus newStatus);
|
||||
|
|
|
@ -243,9 +243,9 @@ void InformationDisplay::drawMemoryWarning(DrawerYG * drawer)
|
|||
enableMemoryWarning(false);
|
||||
}
|
||||
|
||||
void InformationDisplay::drawPlacemark(DrawerYG * pDrawer, m2::PointD const & pt)
|
||||
void InformationDisplay::drawPlacemark(DrawerYG * pDrawer, char const * symbol, m2::PointD const & pt)
|
||||
{
|
||||
pDrawer->drawSymbol(pt, "placemark", yg::EPosAbove, yg::maxDepth);
|
||||
pDrawer->drawSymbol(pt, symbol, yg::EPosAbove, yg::maxDepth);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -101,7 +101,7 @@ public:
|
|||
void memoryWarning();
|
||||
void drawMemoryWarning(DrawerYG * pDrawer);
|
||||
|
||||
void drawPlacemark(DrawerYG * pDrawer, m2::PointD const & pt);
|
||||
void drawPlacemark(DrawerYG * pDrawer, char const * symbol, m2::PointD const & pt);
|
||||
|
||||
void enableBenchmarkInfo(bool doEnable);
|
||||
bool addBenchmarkInfo(string const & name, m2::RectD const & globalRect, double frameDuration);
|
||||
|
|
|
@ -44,7 +44,8 @@ HEADERS += \
|
|||
basic_render_policy.hpp \
|
||||
proto_to_yg_styles.hpp \
|
||||
test_render_policy.hpp \
|
||||
queued_render_policy.hpp
|
||||
queued_render_policy.hpp \
|
||||
bookmark.hpp
|
||||
|
||||
SOURCES += \
|
||||
feature_vec_model.cpp \
|
||||
|
|
|
@ -123,6 +123,9 @@ void SearchPanel::OnSearchResult(ResultsT * res, int queryId)
|
|||
m_pTable->setRowCount(0);
|
||||
m_results.clear();
|
||||
|
||||
Framework & frm = m_pDrawWidget->GetFramework();
|
||||
frm.ClearBookmarks();
|
||||
|
||||
for (ResultsT::IterT i = res->Begin(); i != res->End(); ++i)
|
||||
{
|
||||
ResultT const & e = *i;
|
||||
|
@ -135,6 +138,8 @@ void SearchPanel::OnSearchResult(ResultsT * res, int queryId)
|
|||
|
||||
if (e.GetResultType() == ResultT::RESULT_FEATURE)
|
||||
{
|
||||
frm.AddBookmark(e.GetFeatureCenter(), e.GetString());
|
||||
|
||||
m_pTable->setItem(rowCount, 0,
|
||||
create_item(QString::fromUtf8(e.GetFeatureType())));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue