diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index b95f4edc51..b24392adde 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -571,12 +571,12 @@ namespace android GetPinClickManager().OnClick(m2::PointD(x, y), m_wasLongClick); } - BookmarkAndCategory Framework::AddBookmark(size_t cat, m2::PointD const & pt, BookmarkCustomData & bm) + BookmarkAndCategory Framework::AddBookmark(size_t cat, m2::PointD const & pt, BookmarkData & bm) { return BookmarkAndCategory(cat, m_work.AddBookmark(cat, pt, bm)); } - void Framework::ReplaceBookmark(BookmarkAndCategory const & ind, BookmarkCustomData & bm) + void Framework::ReplaceBookmark(BookmarkAndCategory const & ind, BookmarkData & bm) { m_work.ReplaceBookmark(ind.first, ind.second, bm); } @@ -586,7 +586,8 @@ namespace android BookmarkCategory * pOld = m_work.GetBmCategory(ind.first); Bookmark const * oldBm = pOld->GetBookmark(ind.second); m2::PointD pt = oldBm->GetOrg(); - BookmarkCustomData bm(static_cast(oldBm->GetCustomData())); + BookmarkData bm(oldBm->GetName(), oldBm->GetType(), oldBm->GetDescription(), + oldBm->GetScale(), oldBm->GetTimeStamp()); pOld->DeleteBookmark(ind.second); pOld->SaveToKMLFile(); @@ -638,9 +639,9 @@ namespace android } template -T const & CastData(UserCustomData const & data) +T const * CastMark(UserMark const * data) { - return static_cast(data); + return static_cast(data); } @@ -656,7 +657,7 @@ T const & CastData(UserCustomData const & data) extern "C" { // API - void CallOnApiPointActivatedListener(shared_ptr obj, ApiCustomData const & data, double lat, double lon) + void CallOnApiPointActivatedListener(shared_ptr obj, ApiMarkPoint const * data, double lat, double lon) { JNIEnv * jniEnv = jni::GetEnv(); const jmethodID methodID = jni::GetJavaMethodID(jniEnv, @@ -664,8 +665,8 @@ extern "C" "onApiPointActivated", "(DDLjava/lang/String;Ljava/lang/String;)V"); - jstring j_name = jni::ToJavaString(jniEnv, data.GetName()); - jstring j_id = jni::ToJavaString(jniEnv, data.GetID()); + jstring j_name = jni::ToJavaString(jniEnv, data->GetName()); + jstring j_id = jni::ToJavaString(jniEnv, data->GetID()); jniEnv->CallVoidMethod(*obj.get(), methodID, lat, lon, j_name, j_id); } @@ -711,65 +712,39 @@ extern "C" void CallOnUserMarkActivated(shared_ptr obj, UserMark const * mark) { ::Framework * fm = g_framework->NativeFramework(); - UserCustomData const & data = mark->GetCustomData(); - switch (data.GetType()) + switch (mark->GetMarkType()) { - case UserCustomData::API: + case UserMark::API: { double lat, lon; mark->GetLatLon(lat, lon); - CallOnApiPointActivatedListener(obj, CastData(data), lat, lon); + CallOnApiPointActivatedListener(obj, CastMark(mark), lat, lon); } break; - case UserCustomData::BOOKMARK: + case UserMark::BOOKMARK: { - BookmarkAndCategory bmAndCat = MakeEmptyBookmarkAndCategory(); - for (size_t i = 0; i < fm->GetBmCategoriesCount(); ++i) - { - if (fm->GetBmCategory(i) == mark->GetContainer()) - { - bmAndCat.first = i; - break; - } - } - - ASSERT(bmAndCat.first != MakeEmptyBookmarkAndCategory().first, ()); - - BookmarkCategory const * cat = fm->GetBmCategory(bmAndCat.first); - for (size_t i = 0; i < cat->GetBookmarksCount(); ++i) - { - if (cat->GetBookmark(i) == mark) - { - bmAndCat.second = i; - break; - } - } - - ASSERT(IsValid(bmAndCat), ()); - CallOnBookmarkActivatedListener(obj, bmAndCat); + BookmarkAndCategory bmAndCat = fm->FindBookmark(mark); + if (IsValid(bmAndCat)) + CallOnBookmarkActivatedListener(obj, bmAndCat); } break; - case UserCustomData::POI: + case UserMark::POI: { - search::AddressInfo info; - fm->GetAddressInfoForGlobalPoint(mark->GetOrg(), info); - CallOnPoiActivatedListener(obj, mark->GetOrg(), info); + PoiMarkPoint const * poiMark = CastMark(mark); + CallOnPoiActivatedListener(obj, mark->GetOrg(), poiMark->GetInfo()); } break; - case UserCustomData::SEARCH: + case UserMark::SEARCH: { UserMarkContainer::Controller & c = fm->GetBookmarkManager().UserMarksGetController(UserMarkContainer::SEARCH_MARK); - size_t index = (size_t)-1; for (size_t i = 0; i < c.GetUserMarkCount(); ++i) { - if (c.GetUserMark(i) == mark) - { - index = i; - break; - } + if (c.GetUserMark(i) == mark) + { + CallOnAdditionalLayerActivatedListener(obj, i); + break; + } } - ASSERT(index != (size_t) -1, ()); - CallOnAdditionalLayerActivatedListener(obj, index); } break; } @@ -966,15 +941,15 @@ extern "C" UserMarkContainer::Controller & c = m.UserMarksGetController(UserMarkContainer::SEARCH_MARK); ASSERT_LESS(nIndex , c.GetUserMarkCount(), ("Invalid index", nIndex)); UserMark const * mark = c.GetUserMark(nIndex); - SearchCustomData const & data = CastData(mark->GetCustomData()); + search::AddressInfo const & info= CastMark(mark)->GetInfo(); const jclass javaClazz = env->GetObjectClass(jsearchResult); const jfieldID nameId = env->GetFieldID(javaClazz, "mName", "Ljava/lang/String;"); - env->SetObjectField(jsearchResult, nameId, jni::ToJavaString(env, data.GetName())); + env->SetObjectField(jsearchResult, nameId, jni::ToJavaString(env, info.GetPinName())); const jfieldID typeId = env->GetFieldID(javaClazz, "mTypeName", "Ljava/lang/String;"); - env->SetObjectField(jsearchResult, typeId, jni::ToJavaString(env, data.GetTypeName())); + env->SetObjectField(jsearchResult, typeId, jni::ToJavaString(env, info.GetPinType())); const jfieldID latId = env->GetFieldID(javaClazz, "mLat", "D"); env->SetDoubleField(jsearchResult, latId, MercatorBounds::YToLat(mark->GetOrg().y)); diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp index 657adee7e4..c2dc61a8a4 100644 --- a/android/jni/com/mapswithme/maps/Framework.hpp +++ b/android/jni/com/mapswithme/maps/Framework.hpp @@ -118,8 +118,8 @@ namespace android void Scale(double k); - BookmarkAndCategory AddBookmark(size_t category, m2::PointD const & pt, BookmarkCustomData & bm); - void ReplaceBookmark(BookmarkAndCategory const & ind, BookmarkCustomData & bm); + BookmarkAndCategory AddBookmark(size_t category, m2::PointD const & pt, BookmarkData & bm); + void ReplaceBookmark(BookmarkAndCategory const & ind, BookmarkData & bm); size_t ChangeBookmarkCategory(BookmarkAndCategory const & ind, size_t newCat); ::Framework * NativeFramework(); diff --git a/android/jni/com/mapswithme/maps/bookmarks/data/Bookmark.cpp b/android/jni/com/mapswithme/maps/bookmarks/data/Bookmark.cpp index 2a114a5ac6..f75ff92851 100644 --- a/android/jni/com/mapswithme/maps/bookmarks/data/Bookmark.cpp +++ b/android/jni/com/mapswithme/maps/bookmarks/data/Bookmark.cpp @@ -48,7 +48,7 @@ extern "C" Bookmark const * p = getBookmark(cat, bmk); // initialize new bookmark - BookmarkCustomData bm(jni::ToNativeString(env, name), jni::ToNativeString(env, type)); + BookmarkData bm(jni::ToNativeString(env, name), jni::ToNativeString(env, type)); if (descr != 0) bm.SetDescription(jni::ToNativeString(env, descr)); else diff --git a/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp b/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp index 8b8372c50c..d458b957c2 100644 --- a/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp +++ b/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp @@ -94,7 +94,7 @@ extern "C" MercatorBounds::LatToY(lat)); ::Framework * f = frm(); - BookmarkCustomData bmk(jni::ToNativeString(env, name), f->LastEditedBMType()); + BookmarkData bmk(jni::ToNativeString(env, name), f->LastEditedBMType()); return g_framework->AddBookmark(frm()->LastEditedBMCategory(), glbPoint, bmk).second; } diff --git a/data/resources-hdpi/basic.skn b/data/resources-hdpi/basic.skn index a3c5cae740..9a57038f89 100644 --- a/data/resources-hdpi/basic.skn +++ b/data/resources-hdpi/basic.skn @@ -1,524 +1,521 @@ - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - + + diff --git a/data/resources-hdpi/symbols.png b/data/resources-hdpi/symbols.png index 2e0c80f786..5cbb2f1963 100644 Binary files a/data/resources-hdpi/symbols.png and b/data/resources-hdpi/symbols.png differ diff --git a/data/resources-hdpi/symbols.sdf b/data/resources-hdpi/symbols.sdf index 92439bf222..4f85a61b57 100644 --- a/data/resources-hdpi/symbols.sdf +++ b/data/resources-hdpi/symbols.sdf @@ -1,178 +1,177 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/resources-ldpi/basic.skn b/data/resources-ldpi/basic.skn index 807422a986..a0070a1638 100644 --- a/data/resources-ldpi/basic.skn +++ b/data/resources-ldpi/basic.skn @@ -1,214 +1,214 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -217,13 +217,13 @@ - + - + - + @@ -259,10 +259,10 @@ - + - + @@ -289,61 +289,61 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -352,173 +352,170 @@ - - + + - + - + - + - + - - + + - - + + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - + + diff --git a/data/resources-ldpi/symbols.png b/data/resources-ldpi/symbols.png index 174e65b5c1..79f8751fc9 100644 Binary files a/data/resources-ldpi/symbols.png and b/data/resources-ldpi/symbols.png differ diff --git a/data/resources-ldpi/symbols.sdf b/data/resources-ldpi/symbols.sdf index f17f353ed8..2baf295965 100644 --- a/data/resources-ldpi/symbols.sdf +++ b/data/resources-ldpi/symbols.sdf @@ -1,178 +1,177 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/resources-mdpi/basic.skn b/data/resources-mdpi/basic.skn index 21e7c0caf3..da4dd2392f 100644 --- a/data/resources-mdpi/basic.skn +++ b/data/resources-mdpi/basic.skn @@ -1,524 +1,521 @@ - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - + + diff --git a/data/resources-mdpi/symbols.png b/data/resources-mdpi/symbols.png index 99f0ec5536..59b6b40dd8 100644 Binary files a/data/resources-mdpi/symbols.png and b/data/resources-mdpi/symbols.png differ diff --git a/data/resources-mdpi/symbols.sdf b/data/resources-mdpi/symbols.sdf index 1010a79384..17ea630bae 100644 --- a/data/resources-mdpi/symbols.sdf +++ b/data/resources-mdpi/symbols.sdf @@ -3,176 +3,175 @@ - - - - - + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/resources-xhdpi/basic.skn b/data/resources-xhdpi/basic.skn index a8d3047970..ea5a35e4c9 100644 --- a/data/resources-xhdpi/basic.skn +++ b/data/resources-xhdpi/basic.skn @@ -1,524 +1,521 @@ - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - + + diff --git a/data/resources-xhdpi/symbols.png b/data/resources-xhdpi/symbols.png index 740a79ff9b..4f888a4cf6 100644 Binary files a/data/resources-xhdpi/symbols.png and b/data/resources-xhdpi/symbols.png differ diff --git a/data/resources-xhdpi/symbols.sdf b/data/resources-xhdpi/symbols.sdf index f072471789..5973b808f3 100644 --- a/data/resources-xhdpi/symbols.sdf +++ b/data/resources-xhdpi/symbols.sdf @@ -1,178 +1,177 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/resources-xxhdpi/basic.skn b/data/resources-xxhdpi/basic.skn index ba71cc50cd..7d4d9d919f 100644 --- a/data/resources-xxhdpi/basic.skn +++ b/data/resources-xxhdpi/basic.skn @@ -1,524 +1,521 @@ - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - - - - + + diff --git a/data/resources-xxhdpi/symbols.png b/data/resources-xxhdpi/symbols.png index ffb416ae45..cf2e4429fa 100644 Binary files a/data/resources-xxhdpi/symbols.png and b/data/resources-xxhdpi/symbols.png differ diff --git a/data/resources-xxhdpi/symbols.sdf b/data/resources-xxhdpi/symbols.sdf index e3969949af..1c5be98059 100644 --- a/data/resources-xxhdpi/symbols.sdf +++ b/data/resources-xxhdpi/symbols.sdf @@ -1,178 +1,177 @@ - + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/resources-yota/basic.skn b/data/resources-yota/basic.skn index 0f45848f4f..767b022d62 100644 --- a/data/resources-yota/basic.skn +++ b/data/resources-yota/basic.skn @@ -1,524 +1,521 @@ - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - + + diff --git a/data/resources-yota/symbols.png b/data/resources-yota/symbols.png index 2c75999dab..24152dc250 100644 Binary files a/data/resources-yota/symbols.png and b/data/resources-yota/symbols.png differ diff --git a/data/resources-yota/symbols.sdf b/data/resources-yota/symbols.sdf index 4255876762..0395441fe2 100644 --- a/data/resources-yota/symbols.sdf +++ b/data/resources-yota/symbols.sdf @@ -3,176 +3,175 @@ - - - - - + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/styles/hdpi/api-result-active.png b/data/styles/hdpi/api-result-active.png deleted file mode 100644 index 87c1caf638..0000000000 Binary files a/data/styles/hdpi/api-result-active.png and /dev/null differ diff --git a/data/styles/ldpi/api-result-active.png b/data/styles/ldpi/api-result-active.png deleted file mode 100644 index 9f7a6e2d04..0000000000 Binary files a/data/styles/ldpi/api-result-active.png and /dev/null differ diff --git a/data/styles/mdpi/api-result-active.png b/data/styles/mdpi/api-result-active.png deleted file mode 100644 index b3f319068e..0000000000 Binary files a/data/styles/mdpi/api-result-active.png and /dev/null differ diff --git a/data/styles/xhdpi/api-result-active.png b/data/styles/xhdpi/api-result-active.png deleted file mode 100644 index 9d0f8e60b7..0000000000 Binary files a/data/styles/xhdpi/api-result-active.png and /dev/null differ diff --git a/data/styles/xxhdpi/api-result-active.png b/data/styles/xxhdpi/api-result-active.png deleted file mode 100644 index b7ce60c7dc..0000000000 Binary files a/data/styles/xxhdpi/api-result-active.png and /dev/null differ diff --git a/data/styles/yota/api-result-active.png b/data/styles/yota/api-result-active.png deleted file mode 100644 index b3f319068e..0000000000 Binary files a/data/styles/yota/api-result-active.png and /dev/null differ diff --git a/iphone/Maps/Bookmarks/PlacePageVC.mm b/iphone/Maps/Bookmarks/PlacePageVC.mm index b4c7244042..acf75ed28f 100644 --- a/iphone/Maps/Bookmarks/PlacePageVC.mm +++ b/iphone/Maps/Bookmarks/PlacePageVC.mm @@ -450,7 +450,7 @@ { [[Statistics instance] logEvent:@"Bookmark Category" withParameters:@{@"Changed" : @"NO"}]; - BookmarkCustomData newBm([self.pinTitle UTF8String], [self.pinColor UTF8String]); + BookmarkData newBm([self.pinTitle UTF8String], [self.pinColor UTF8String]); newBm.SetDescription([self.pinNotes UTF8String]); f.ReplaceBookmark(_pinEditedBookmark.first, _pinEditedBookmark.second, newBm); } @@ -460,7 +460,7 @@ - (void)addBookmarkToCategory:(size_t)index { - BookmarkCustomData bm([self.pinTitle UTF8String], [self.pinColor UTF8String]); + BookmarkData bm([self.pinTitle UTF8String], [self.pinColor UTF8String]); bm.SetDescription([self.pinNotes UTF8String]); _pinEditedBookmark = pair(index, GetFramework().AddBookmark(index, m2::PointD(_pinGlobalPosition.x, _pinGlobalPosition.y), bm)); diff --git a/iphone/Maps/Classes/PlacePageView.mm b/iphone/Maps/Classes/PlacePageView.mm index 24cf5bd276..ace63174ff 100644 --- a/iphone/Maps/Classes/PlacePageView.mm +++ b/iphone/Maps/Classes/PlacePageView.mm @@ -42,21 +42,21 @@ UserMark const * m_mark; } --(BOOL)isMarkOfType:(UserCustomData::Type)type +-(BOOL)isMarkOfType:(UserMark::Type)type { ASSERT(m_mark != NULL, ()); ASSERT(m_mark->GetContainer() != NULL, ()); - return m_mark->GetCustomData().GetType() == type; + return m_mark->GetMarkType() == type; } -(BOOL)isBookmark { - return [self isMarkOfType:UserCustomData::BOOKMARK]; + return [self isMarkOfType:UserMark::BOOKMARK]; } -(BOOL)isApiPoint { - return [self isMarkOfType:UserCustomData::API]; + return [self isMarkOfType:UserMark::API]; } -(BOOL)isEmpty @@ -64,38 +64,6 @@ return m_mark == NULL; } --(BookmarkAndCategory)initBookmarkandCategory -{ - Framework & fm = GetFramework(); - BookmarkAndCategory bmAndCat = MakeEmptyBookmarkAndCategory(); - if ([self isBookmark] == YES) - { - for (size_t i = 0; i < fm.GetBmCategoriesCount(); ++i) - { - if (m_mark->GetContainer() == fm.GetBmCategory(i)) - { - bmAndCat.first = i; - break; - } - } - - ASSERT(bmAndCat.first != MakeEmptyBookmarkAndCategory().first, ()); - - BookmarkCategory const * bmCat = fm.GetBmCategory(bmAndCat.first); - for (size_t i = 0; i < bmCat->GetBookmarksCount(); ++i) - { - if (bmCat->GetBookmark(i) == m_mark) - { - bmAndCat.second = i; - break; - } - } - } - - ASSERT(IsValid(bmAndCat), ()); - return bmAndCat; -} - - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; @@ -177,7 +145,8 @@ - (void)bookmarkCategoryDeletedNotification:(NSNotification *)notification { - if ([self initBookmarkandCategory].first == [[notification object] integerValue]) + BookmarkAndCategory bmAndCat = GetFramework().FindBookmark(m_mark); + if (bmAndCat.first == [[notification object] integerValue]) { [self deleteBookmark]; [self updateBookmarkStateAnimated:NO]; @@ -186,9 +155,10 @@ - (void)bookmarkDeletedNotification:(NSNotification *)notification { + BookmarkAndCategory bmAndCat = GetFramework().FindBookmark(m_mark); BookmarkAndCategory bookmarkAndCategory; [[notification object] getValue:&bookmarkAndCategory]; - if (bookmarkAndCategory == [self initBookmarkandCategory]) + if (bookmarkAndCategory == bmAndCat) { [self deleteBookmark]; [self updateBookmarkStateAnimated:NO]; @@ -431,7 +401,7 @@ - (void)editButtonPressed:(id)sender { if ([self isBookmark] == YES) - [self.delegate placePageView:self willEditBookmarkAndCategory:[self initBookmarkandCategory]]; + [self.delegate placePageView:self willEditBookmarkAndCategory:GetFramework().FindBookmark(m_mark)]; else { search::AddressInfo info; @@ -465,27 +435,30 @@ namespace { template - T const & CastData(UserCustomData const & data) { return static_cast(data); } + T const * CastData(UserMark const * data) + { + ASSERT(dynamic_cast(data) != NULL, ()); + return static_cast(data); + } } - (void)showUserMark:(UserMark const *)mark { m_mark = mark; - UserCustomData const & customData = m_mark->GetCustomData(); - UserCustomData::Type type = customData.GetType(); + UserMark::Type type = mark->GetMarkType(); switch (type) { - case UserCustomData::BOOKMARK: - [self bookmarkActivated:CastData(customData)]; + case UserMark::BOOKMARK: + [self bookmarkActivated:CastData(m_mark)]; break; - case UserCustomData::POI: - [self poiActivated:CastData(customData)]; + case UserMark::POI: + [self poiActivated:CastData(m_mark)]; break; - case UserCustomData::API: - [self apiPointActivated:CastData(customData)]; + case UserMark::API: + [self apiPointActivated:CastData(m_mark)]; break; - case UserCustomData::SEARCH: - [self searchResultActivated:CastData(customData)]; + case UserMark::SEARCH: + [self searchResultActivated:CastData(m_mark)]; break; default: @@ -493,27 +466,29 @@ namespace } } -- (void)poiActivated:(PoiCustomData const &)data +- (void)poiActivated:(PoiMarkPoint const *)data { - [self processName:data.GetName() type:data.GetTypeName() address:data.GetAddress()]; + search::AddressInfo info = data->GetInfo(); + [self processName:info.GetPinName() type:info.GetPinType() address:info.FormatAddress()]; } -- (void)searchResultActivated:(SearchCustomData const &)data +- (void)searchResultActivated:(SearchMarkPoint const *)data { [[MapsAppDelegate theApp].m_locationManager start:self]; [self hideAll]; - string name = data.GetName(); + search::AddressInfo info = data->GetInfo(); + string name = info.GetPinName(); self.titleLabel.text = name.empty() ? NSLocalizedString(@"dropped_pin", nil) : [NSString stringWithUTF8String:name.c_str()]; self.titleLabel.hidden = NO; - if (!data.GetTypeName().empty()) + if (!info.GetPinType().empty()) { - self.typeLabel.text = [NSString stringWithUTF8String:data.GetTypeName().c_str()]; + self.typeLabel.text = [NSString stringWithUTF8String:info.GetPinType().c_str()]; self.typeLabel.hidden = NO; } - self.addressLabel.text = [NSString stringWithUTF8String:data.GetAddress().c_str()]; + self.addressLabel.text = [NSString stringWithUTF8String:info.FormatAddress().c_str()]; self.addressLabel.hidden = ![self.addressLabel.text length]; self.locationView.hidden = NO; @@ -523,7 +498,7 @@ namespace [self updateBookmarkStateAnimated:NO]; } -- (void)apiPointActivated:(ApiCustomData const &)data +- (void)apiPointActivated:(ApiMarkPoint const *)data { Framework & framework = GetFramework(); @@ -562,26 +537,26 @@ namespace [self.guideButton setTitle:appTitle forState:UIControlStateNormal]; } - self.titleLabel.text = [NSString stringWithUTF8String:data.GetName().c_str()]; + self.titleLabel.text = [NSString stringWithUTF8String:data->GetName().c_str()]; search::AddressInfo info; framework.GetAddressInfoForGlobalPoint(m_mark->GetOrg(), info); [self processName:info.GetPinName() type:info.GetPinType() address:info.FormatAddress()]; } -- (void)bookmarkActivated:(BookmarkCustomData const &)data +- (void)bookmarkActivated:(Bookmark const *)data { Framework & framework = GetFramework(); [[MapsAppDelegate theApp].m_locationManager start:self]; [self hideAll]; - string name = data.GetName(); + string name = data->GetName(); self.titleLabel.text = name.empty() ? NSLocalizedString(@"dropped_pin", nil) : [NSString stringWithUTF8String:name.c_str()]; self.titleLabel.hidden = NO; - if (!data.GetTypeName().empty()) + if (!data->GetType().empty()) { - self.typeLabel.text = [NSString stringWithUTF8String:data.GetTypeName().c_str()]; + self.typeLabel.text = [NSString stringWithUTF8String:data->GetType().c_str()]; self.typeLabel.hidden = NO; } @@ -636,35 +611,17 @@ namespace - (void)deleteBookmark { - ASSERT(m_mark->GetCustomData().GetType() == UserCustomData::BOOKMARK, ()); + ASSERT(m_mark->GetMarkType() == UserMark::BOOKMARK, ()); ASSERT(m_mark->GetContainer() != NULL, ()); ASSERT(m_mark->GetContainer()->GetType() == UserMarkContainer::BOOKMARK_MARK, ()); Framework & fm = GetFramework(); - - BookmarkCategory const * category = static_cast(m_mark->GetContainer()); - int categoryIndex = -1; - for (int i = 0; i < fm.GetBmCategoriesCount(); ++i) + BookmarkAndCategory bmAndCat = fm.FindBookmark(m_mark); + if (IsValid(bmAndCat)) { - if (category == fm.GetBmCategory(i)) - { - categoryIndex = i; - break; - } - } - - ASSERT(categoryIndex != -1, ()); - - for (int i = 0; i < category->GetBookmarksCount(); ++i) - { - Bookmark const * bm = category->GetBookmark(i); - if (bm == m_mark) - { - m2::PointD orgPt = m_mark->GetOrg(); - fm.GetBmCategory(categoryIndex)->DeleteBookmark(i); - m_mark = fm.ActivateAddressMark(orgPt); - ASSERT(m_mark != NULL, ()); - break; - } + m2::PointD orgPt = m_mark->GetOrg(); + fm.GetBmCategory(bmAndCat.first)->DeleteBookmark(bmAndCat.second); + m_mark = fm.ActivateAddressMark(orgPt); + ASSERT(m_mark != NULL, ()); } fm.Invalidate(); @@ -682,7 +639,7 @@ namespace string pinName = info.GetPinName(); string name = pinName.empty() ? [NSLocalizedString(@"dropped_pin", nil) UTF8String] : pinName.c_str(); - BookmarkCustomData bm(name, boomarkType); + BookmarkData bm(name, boomarkType); size_t bmIndex = framework.AddBookmark(categoryIndex, m_mark->GetOrg(), bm); m_mark = framework.GetBmCategory(categoryIndex)->GetBookmark(bmIndex); framework.Invalidate(); @@ -690,7 +647,7 @@ namespace - (void)updateBookmarkStateAnimated:(BOOL)animated { - bool isBookmark = m_mark->GetCustomData().GetType() == UserCustomData::BOOKMARK; + bool isBookmark = [self isBookmark]; self.bookmarkButton.selected = isBookmark; [UIView animateWithDuration:0.25 animations:^{ self.largeShareButton.alpha = isBookmark ? 0 : 1; diff --git a/map/bookmark.cpp b/map/bookmark.cpp index 5859e13f74..d9e08b81a7 100644 --- a/map/bookmark.cpp +++ b/map/bookmark.cpp @@ -29,22 +29,25 @@ Track const * BookmarkCategory::GetTrack(size_t index) const return (index < m_tracks.size() ? m_tracks[index] : 0); } -void BookmarkCategory::AddBookmark(m2::PointD const & ptOrg, BookmarkCustomData const & bm) +void BookmarkCategory::AddBookmark(m2::PointD const & ptOrg, BookmarkData const & bm) { UserMark * mark = base_t::GetController().CreateUserMark(ptOrg); - mark->InjectCustomData(new BookmarkCustomData(bm)); + static_cast(mark)->SetData(bm); } -void BookmarkCategory::ReplaceBookmark(size_t index, BookmarkCustomData const & bm) +void BookmarkCategory::ReplaceBookmark(size_t index, BookmarkData const & bm) { Controller c = base_t::GetController(); ASSERT_LESS (index, c.GetUserMarkCount(), ()); if (index < c.GetUserMarkCount()) - base_t::GetController().EditUserMark(index, new BookmarkCustomData(bm)); + { + Bookmark * mark = static_cast(c.GetUserMarkForEdit(index)); + mark->SetData(bm); + } } BookmarkCategory::BookmarkCategory(const string & name, Framework & framework) - : base_t(UserMarkContainer::BOOKMARK_MARK, graphics::bookmarkDepth, framework) + : base_t(graphics::bookmarkDepth, framework) , m_name(name) { } @@ -104,13 +107,13 @@ size_t BookmarkCategory::GetBookmarksCount() const Bookmark const * BookmarkCategory::GetBookmark(size_t index) const { base_t::Controller const & c = base_t::GetController(); - return (Bookmark *)(index < c.GetUserMarkCount() ? c.GetUserMark(index) : 0); + return static_cast(index < c.GetUserMarkCount() ? c.GetUserMark(index) : 0); } Bookmark * BookmarkCategory::GetBookmark(size_t index) { base_t::Controller & c = base_t::GetController(); - return (Bookmark *)(index < c.GetUserMarkCount() ? c.GetUserMark(index) : 0); + return static_cast(index < c.GetUserMarkCount() ? c.GetUserMark(index) : 0); } namespace @@ -344,7 +347,7 @@ namespace if (MakeValid()) { if (POINT == m_geometryType) - m_category.AddBookmark(m_org, BookmarkCustomData(m_name, m_type, m_description, m_scale, m_timeStamp)); + m_category.AddBookmark(m_org, BookmarkData(m_name, m_type, m_description, m_scale, m_timeStamp)); else if (LINE == m_geometryType) { Track track(m_points); diff --git a/map/bookmark.hpp b/map/bookmark.hpp index 0c43368e08..f181951d85 100644 --- a/map/bookmark.hpp +++ b/map/bookmark.hpp @@ -17,12 +17,18 @@ class Track; -class BookmarkCustomData : public UserCustomData +class BookmarkData { public: - BookmarkCustomData(string const & name, string const & type, - string const & description = "", double scale = -1.0, - time_t timeStamp = my::INVALID_TIME_STAMP) + BookmarkData() + : m_scale(-1.0) + , m_timeStamp(my::INVALID_TIME_STAMP) + { + } + + BookmarkData(string const & name, string const & type, + string const & description = "", double scale = -1.0, + time_t timeStamp = my::INVALID_TIME_STAMP) : m_name(name) , m_description(description) , m_type(type) @@ -31,16 +37,14 @@ public: { } - virtual Type GetType() const { return BOOKMARK; } - string const & GetName() const { return m_name; } void SetName(const string & name) { m_name = name; } string const & GetDescription() const { return m_description; } void SetDescription(const string & description) { m_description = description; } - string const & GetTypeName() const { return m_type; } - void SetTypeName(const string & type) { m_type = type; } + string const & GetType() const { return m_type; } + void SetType(const string & type) { m_type = type; } double const & GetScale() const { return m_scale; } void SetScale(double scale) { m_scale = scale; } @@ -58,53 +62,48 @@ private: class Bookmark : public ICustomDrawable { + BookmarkData m_data; + public: Bookmark(m2::PointD const & ptOrg, UserMarkContainer * container) : ICustomDrawable(ptOrg, container) { - Inject(); } + Bookmark(BookmarkData const & data, + m2::PointD const & ptOrg, + UserMarkContainer * container) + : ICustomDrawable(ptOrg, container) + , m_data(data) + { + } + + void SetData(BookmarkData const & data) { m_data = data; } + + virtual Type GetMarkType() const { return BOOKMARK; } + m2::PointD const & GetOrg() const { return UserMark::GetOrg(); } - string const & GetName() const { return GetData()->GetName(); } + string const & GetName() const { return m_data.GetName(); } //void SetName(string const & name) { m_name = name; } /// @return Now its a bookmark color - name of icon file - string const & GetType() const { return GetData()->GetTypeName(); } + string const & GetType() const { return m_data.GetType(); } //void SetType(string const & type) { m_type = type; } m2::RectD GetViewport() const { return m2::RectD(GetOrg(), GetOrg()); } - string const & GetDescription() const { return GetData()->GetDescription(); } - void SetDescription(string const & description) { GetData()->SetDescription(description); } + string const & GetDescription() const { return m_data.GetDescription(); } + void SetDescription(string const & description) { m_data.SetDescription(description); } /// @return my::INVALID_TIME_STAMP if bookmark has no timestamp - time_t GetTimeStamp() const { return GetData()->GetTimeStamp(); } - void SetTimeStamp(time_t timeStamp) { GetData()->SetTimeStamp(timeStamp); } + time_t GetTimeStamp() const { return m_data.GetTimeStamp(); } + void SetTimeStamp(time_t timeStamp) { m_data.SetTimeStamp(timeStamp); } - double GetScale() const { return GetData()->GetScale(); } - void SetScale(double scale) { GetData()->SetScale(scale); } + double GetScale() const { return m_data.GetScale(); } + void SetScale(double scale) { m_data.SetScale(scale); } virtual graphics::DisplayList * GetDisplayList(UserMarkDLCache * cache) const { return cache->FindUserMark(UserMarkDLCache::Key(GetType(), graphics::EPosAbove, GetContainer()->GetDepth())); } - -private: - void Inject(m2::PointD const & org = m2::PointD(), string const & name = "", - string const & type = "", string const & descr = "", - double scale = -1, time_t timeStamp = my::INVALID_TIME_STAMP) - { - InjectCustomData(new BookmarkCustomData(name, descr, type, scale, timeStamp)); - } - - BookmarkCustomData * GetData() - { - return static_cast(&GetCustomData()); - } - - BookmarkCustomData const * GetData() const - { - return static_cast(&GetCustomData()); - } }; class BookmarkCategory : public UserMarkContainer @@ -124,6 +123,8 @@ public: BookmarkCategory(string const & name, Framework & framework); ~BookmarkCategory(); + virtual Type GetType() const { return BOOKMARK_MARK; } + void ClearBookmarks(); void ClearTracks(); @@ -131,8 +132,8 @@ public: /// @name Theese functions are called from Framework only. //@{ - void AddBookmark(m2::PointD const & ptOrg, BookmarkCustomData const & bm); - void ReplaceBookmark(size_t index, BookmarkCustomData const & bm); + void AddBookmark(m2::PointD const & ptOrg, BookmarkData const & bm); + void ReplaceBookmark(size_t index, BookmarkData const & bm); //@} /// @name Tracks routine. @@ -174,6 +175,8 @@ public: //@} protected: + virtual string GetTypeName() const { return "search-result"; } + virtual string GetActiveTypeName() const { return "search-result-active"; } virtual UserMark * AllocateUserMark(m2::PointD const & ptOrg); }; diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index 324f6c5fdf..4c53b3bb9c 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -26,8 +26,8 @@ BookmarkManager::BookmarkManager(Framework & f) , m_cache(NULL) { m_userMarkLayers.reserve(2); - m_userMarkLayers.push_back(new UserMarkContainer(UserMarkContainer::SEARCH_MARK, graphics::activePinDepth, m_framework)); - m_userMarkLayers.push_back(new UserMarkContainer(UserMarkContainer::API_MARK, graphics::activePinDepth, m_framework)); + m_userMarkLayers.push_back(new SearchUserMarkContainer(graphics::activePinDepth, m_framework)); + m_userMarkLayers.push_back(new ApiUserMarkContainer(graphics::activePinDepth, m_framework)); UserMarkContainer::InitPoiSelectionMark(FindUserMarksContainer(UserMarkContainer::SEARCH_MARK)); } @@ -175,7 +175,7 @@ void BookmarkManager::LoadBookmark(string const & filePath) m_categories.push_back(cat); } -size_t BookmarkManager::AddBookmark(size_t categoryIndex, const m2::PointD & ptOrg, BookmarkCustomData & bm) +size_t BookmarkManager::AddBookmark(size_t categoryIndex, const m2::PointD & ptOrg, BookmarkData & bm) { bm.SetTimeStamp(time(0)); bm.SetScale(m_framework.GetDrawScale()); @@ -186,19 +186,19 @@ size_t BookmarkManager::AddBookmark(size_t categoryIndex, const m2::PointD & ptO pCat->SaveToKMLFile(); m_lastCategoryUrl = pCat->GetFileName(); - m_lastType = bm.GetTypeName(); + m_lastType = bm.GetType(); SaveState(); return (pCat->GetBookmarksCount() - 1); } -void BookmarkManager::ReplaceBookmark(size_t catIndex, size_t bmIndex, BookmarkCustomData const & bm) +void BookmarkManager::ReplaceBookmark(size_t catIndex, size_t bmIndex, BookmarkData const & bm) { BookmarkCategory * pCat = m_categories[catIndex]; pCat->ReplaceBookmark(bmIndex, bm); pCat->SaveToKMLFile(); - m_lastType = bm.GetTypeName(); + m_lastType = bm.GetType(); SaveState(); } diff --git a/map/bookmark_manager.hpp b/map/bookmark_manager.hpp index ec170727e8..16d3678ac3 100644 --- a/map/bookmark_manager.hpp +++ b/map/bookmark_manager.hpp @@ -40,8 +40,8 @@ public: void LoadBookmark(string const & filePath); /// Client should know where it adds bookmark - size_t AddBookmark(size_t categoryIndex, m2::PointD const & ptOrg, BookmarkCustomData & bm); - void ReplaceBookmark(size_t catIndex, size_t bmIndex, BookmarkCustomData const & bm); + size_t AddBookmark(size_t categoryIndex, m2::PointD const & ptOrg, BookmarkData & bm); + void ReplaceBookmark(size_t catIndex, size_t bmIndex, BookmarkData const & bm); size_t LastEditedBMCategory(); string LastEditedBMType() const; diff --git a/map/framework.cpp b/map/framework.cpp index 7d2ca1486c..b8732c7734 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -336,12 +336,12 @@ void Framework::LoadBookmarks() m_bmManager.LoadBookmarks(); } -size_t Framework::AddBookmark(size_t categoryIndex, const m2::PointD & ptOrg, BookmarkCustomData & bm) +size_t Framework::AddBookmark(size_t categoryIndex, const m2::PointD & ptOrg, BookmarkData & bm) { return m_bmManager.AddBookmark(categoryIndex, ptOrg, bm); } -void Framework::ReplaceBookmark(size_t catIndex, size_t bmIndex, BookmarkCustomData const & bm) +void Framework::ReplaceBookmark(size_t catIndex, size_t bmIndex, const BookmarkData & bm) { m_bmManager.ReplaceBookmark(catIndex, bmIndex, bm); } @@ -1103,11 +1103,12 @@ void Framework::ShowSearchResult(search::Result const & res) UserMarkContainer::Type type = UserMarkContainer::SEARCH_MARK; m_bmManager.UserMarksSetVisible(type, true); m_bmManager.UserMarksClear(type); - UserMark * mark = m_bmManager.UserMarksAddMark(type, res.GetFeatureCenter()); + search::AddressInfo info; - GetAddressInfoForGlobalPoint(mark->GetOrg(), info); - mark->InjectCustomData(new SearchCustomData(res.GetString(), res.GetFeatureType(), - info.FormatNameAndAddress())); + m2::PointD ptOrg = res.GetFeatureCenter(); + GetAddressInfoForGlobalPoint(ptOrg, info); + SearchMarkPoint * mark = static_cast(m_bmManager.UserMarksAddMark(type, ptOrg)); + mark->SetInfo(info); int scale; m2::PointD center; @@ -1169,12 +1170,11 @@ void Framework::ShowAllSearchResults() search::Result const & r = searchRes.GetResult(i); if (r.GetResultType() != Result::RESULT_SUGGESTION) { - UserMark * mark = m_bmManager.UserMarksAddMark(type, r.GetFeatureCenter()); AddressInfo info; - GetAddressInfoForGlobalPoint(mark->GetOrg(), info); - mark->InjectCustomData(new SearchCustomData(r.GetString(), r.GetFeatureType(), - info.FormatNameAndAddress())); - + m2::PointD ptOrg = r.GetFeatureCenter(); + GetAddressInfoForGlobalPoint(ptOrg, info); + SearchMarkPoint * mark = static_cast(m_bmManager.UserMarksAddMark(type, ptOrg)); + mark->SetInfo(info); rect.Add(r.GetFeatureCenter()); } } @@ -1499,9 +1499,8 @@ UserMark const * Framework::ActivateUserMark(m2::PointD const & pxPoint, bool is if (needMark) { - UserMark * poiMark = UserMarkContainer::UserMarkForPoi(m_navigator.PtoG(pxPivot)); - poiMark->InjectCustomData(new PoiCustomData(info.GetPinName(), info.GetPinType(), - info.FormatAddress())); + PoiMarkPoint * poiMark = UserMarkContainer::UserMarkForPoi(m_navigator.PtoG(pxPivot)); + poiMark->SetInfo(info); mark = poiMark; } } @@ -1515,12 +1514,40 @@ UserMark const * Framework::ActivateAddressMark(m2::PointD const & globalPoint) { search::AddressInfo info; GetAddressInfoForGlobalPoint(globalPoint, info); - UserMark * mark = UserMarkContainer::UserMarkForPoi(globalPoint); - mark->InjectCustomData(new PoiCustomData(info.GetPinName(), info.GetPinType(), info.FormatAddress())); + PoiMarkPoint * mark = UserMarkContainer::UserMarkForPoi(globalPoint); + mark->SetInfo(info); m_bmManager.ActivateMark(mark); return mark; } +BookmarkAndCategory Framework::FindBookmark(UserMark const * mark) +{ + BookmarkAndCategory empty = MakeEmptyBookmarkAndCategory(); + BookmarkAndCategory result = empty; + for (size_t i = 0; i < GetBmCategoriesCount(); ++i) + { + if (mark->GetContainer() == GetBmCategory(i)) + { + result.first = i; + break; + } + } + + ASSERT(result.first != empty.first, ()); + BookmarkCategory const * cat = GetBmCategory(result.first); + for (size_t i = 0; i < cat->GetBookmarksCount(); ++i) + { + if (mark == cat->GetBookmark(i)) + { + result.second = i; + break; + } + } + + ASSERT(result != empty, ()); + return result; +} + StringsBundle const & Framework::GetStringsBundle() { return m_stringsBundle; diff --git a/map/framework.hpp b/map/framework.hpp index 1e07a99a49..ce3cc62543 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -179,8 +179,8 @@ public: void LoadBookmarks(); /// @return Created bookmark index in category. - size_t AddBookmark(size_t categoryIndex, m2::PointD const & ptOrg, BookmarkCustomData & bm); - void ReplaceBookmark(size_t catIndex, size_t bmIndex, BookmarkCustomData const & bm); + size_t AddBookmark(size_t categoryIndex, m2::PointD const & ptOrg, BookmarkData & bm); + void ReplaceBookmark(size_t catIndex, size_t bmIndex, BookmarkData const & bm); /// @return Created bookmark category index. size_t AddCategory(string const & categoryName); @@ -427,6 +427,7 @@ public: shared_ptr const & GetLocationState() const; UserMark const * ActivateUserMark(m2::PointD const & pxPoint, bool isLongPress); UserMark const * ActivateAddressMark(m2::PointD const & globalPoint); + BookmarkAndCategory FindBookmark(UserMark const * mark); public: string CodeGe0url(Bookmark const * bmk, bool addName); diff --git a/map/map_tests/bookmarks_test.cpp b/map/map_tests/bookmarks_test.cpp index ff2bd67c5e..d0ac70526c 100644 --- a/map/map_tests/bookmarks_test.cpp +++ b/map/map_tests/bookmarks_test.cpp @@ -262,7 +262,7 @@ UNIT_TEST(Bookmarks_Timestamp) char const * arrCat[] = { "cat", "cat1" }; - BookmarkCustomData b1("name", "type"); + BookmarkData b1("name", "type"); fm.AddCategory(arrCat[0]); fm.AddBookmark(0, orgPoint, b1); @@ -270,7 +270,7 @@ UNIT_TEST(Bookmarks_Timestamp) time_t const timeStamp = pBm->GetTimeStamp(); TEST_NOT_EQUAL(timeStamp, my::INVALID_TIME_STAMP, ()); - BookmarkCustomData b3("newName", "newType"); + BookmarkData b3("newName", "newType"); b3.SetTimeStamp(12345); TEST_NOT_EQUAL(b3.GetTimeStamp(), timeStamp, ()); @@ -316,13 +316,13 @@ UNIT_TEST(Bookmarks_Getting) for (int i = 0; i < 3; ++i) fm.AddCategory(arrCat[i]); - BookmarkCustomData bm("1", "placemark-red"); + BookmarkData bm("1", "placemark-red"); fm.AddBookmark(0, m2::PointD(38, 20), bm); BookmarkCategory const * c1 = fm.GetBmCategory(0); - bm = BookmarkCustomData("2", "placemark-red"); + bm = BookmarkData("2", "placemark-red"); fm.AddBookmark(1, m2::PointD(41, 20), bm); BookmarkCategory const * c2 = fm.GetBmCategory(1); - bm = BookmarkCustomData("3", "placemark-red"); + bm = BookmarkData("3", "placemark-red"); fm.AddBookmark(2, m2::PointD(41, 40), bm); BookmarkCategory const * c3 = fm.GetBmCategory(2); @@ -347,7 +347,7 @@ UNIT_TEST(Bookmarks_Getting) cat = GetCategory(mark); TEST_EQUAL(cat->GetName(), arrCat[2], ()); - bm = BookmarkCustomData("4", "placemark-blue"); + bm = BookmarkData("4", "placemark-blue"); fm.AddBookmark(2, m2::PointD(41, 40), bm); BookmarkCategory const * c33 = fm.GetBmCategory(2); @@ -490,14 +490,14 @@ UNIT_TEST(Bookmarks_AddingMoving) m2::PointD const globalPoint = m2::PointD(40, 20); m2::PointD const pixelPoint = fm.GtoP(globalPoint); - BookmarkCustomData bm("name", "placemark-red"); + BookmarkData bm("name", "placemark-red"); fm.AddBookmark(0, globalPoint, bm); BookmarkCategory const * c1 = fm.GetBmCategory(0); Bookmark const * mark = GetBookmarkPxPoint(fm, pixelPoint); BookmarkCategory const * cat = GetCategory(mark); TEST_EQUAL(cat->GetName(), arrCat[0], ()); - bm = BookmarkCustomData("name2", "placemark-blue"); + bm = BookmarkData("name2", "placemark-blue"); fm.AddBookmark(0, globalPoint, bm); BookmarkCategory const * c11 = fm.GetBmCategory(0); TEST_EQUAL(c1, c11, ()); @@ -508,7 +508,7 @@ UNIT_TEST(Bookmarks_AddingMoving) TEST_EQUAL(mark->GetType(), "placemark-red", ()); // Edit name, type and category of bookmark - bm = BookmarkCustomData("name3", "placemark-green"); + bm = BookmarkData("name3", "placemark-green"); fm.AddBookmark(1, globalPoint, bm); BookmarkCategory const * c2 = fm.GetBmCategory(1); TEST_NOT_EQUAL(c1, c2, ()); @@ -566,7 +566,7 @@ UNIT_TEST(BookmarkCategory_EmptyName) { Framework framework; BookmarkCategory * pCat = new BookmarkCategory("", framework); - pCat->AddBookmark(m2::PointD(0, 0), BookmarkCustomData("", "placemark-red")); + pCat->AddBookmark(m2::PointD(0, 0), BookmarkData("", "placemark-red")); pCat->SaveToKMLFile(); pCat->SetName("xxx"); diff --git a/map/map_tests/mwm_url_tests.cpp b/map/map_tests/mwm_url_tests.cpp index 1e090cd919..2eff3989f4 100644 --- a/map/map_tests/mwm_url_tests.cpp +++ b/map/map_tests/mwm_url_tests.cpp @@ -52,28 +52,19 @@ namespace bool TestName(int index, string const & name) { - return GetData(index).GetName() == name; + return GetMark(index)->GetName() == name; } bool TestID(int index, string const & id) { - return GetData(index).GetID() == id; + return GetMark(index)->GetID() == id; } private: - UserMark const * GetMark(int index) const + ApiMarkPoint const * GetMark(int index) const { TEST_LESS(index, m_c->GetUserMarkCount(), ()); - return m_c->GetUserMark(index); - } - - ApiCustomData const & GetData(int index) const - { - UserMark const * mark = GetMark(index); - TEST_NOT_EQUAL(mark->GetContainer(), NULL, ()); - TEST_EQUAL(mark->GetContainer()->GetType(), type, ()); - TEST_EQUAL(mark->GetCustomData().GetType(), UserCustomData::API, ()); - return static_cast(mark->GetCustomData()); + return static_cast(m_c->GetUserMark(index)); } private: diff --git a/map/mwm_url.cpp b/map/mwm_url.cpp index c36cea1369..19957d99a0 100644 --- a/map/mwm_url.cpp +++ b/map/mwm_url.cpp @@ -67,8 +67,9 @@ bool ParsedMapApi::Parse(Uri const & uri) ApiPoint const & p = points[i]; m2::PointD glPoint(MercatorBounds::LonToX(p.m_lon), MercatorBounds::LatToY(p.m_lat)); - UserMark * mark = m_controller->CreateUserMark(glPoint); - mark->InjectCustomData(new ApiCustomData(p.m_name, p.m_id)); + ApiMarkPoint * mark = static_cast(m_controller->CreateUserMark(glPoint)); + mark->SetName(p.m_name); + mark->SetID(p.m_id); } return true; diff --git a/map/user_mark.cpp b/map/user_mark.cpp index 53922b91e2..045b5b5896 100644 --- a/map/user_mark.cpp +++ b/map/user_mark.cpp @@ -3,22 +3,13 @@ #include "../indexer/mercator.hpp" -namespace -{ - static EmptyCustomData s_emptyData; -} - -UserMark::UserMark(const m2::PointD & ptOrg, UserMarkContainer * container) +UserMark::UserMark(m2::PointD const & ptOrg, UserMarkContainer * container) : m_ptOrg(ptOrg) , m_container(container) - , m_customData(NULL) { } -UserMark::~UserMark() -{ - delete m_customData; -} +UserMark::~UserMark() {} UserMarkContainer const * UserMark::GetContainer() const { @@ -36,20 +27,6 @@ void UserMark::GetLatLon(double & lat, double & lon) const lat = MercatorBounds::YToLat(m_ptOrg.y); } -void UserMark::InjectCustomData(UserCustomData * customData) -{ - delete m_customData; - m_customData = customData; -} - -UserCustomData const & UserMark::GetCustomData() const -{ - if (m_customData == NULL) - return s_emptyData; - - return *m_customData; -} - void UserMark::Activate() const { m_container->ActivateMark(this); @@ -59,11 +36,3 @@ void UserMark::Diactivate() const { m_container->DiactivateMark(); } - -UserCustomData & UserMark::GetCustomData() -{ - if (m_customData == NULL) - return s_emptyData; - - return *m_customData; -} diff --git a/map/user_mark.hpp b/map/user_mark.hpp index f3fbc4b901..d148f4b2d6 100644 --- a/map/user_mark.hpp +++ b/map/user_mark.hpp @@ -2,6 +2,8 @@ #include "../geometry/point2d.hpp" +#include "../search/result.hpp" + #include "../std/string.hpp" #include "../std/noncopyable.hpp" @@ -14,88 +16,17 @@ namespace graphics class DisplayList; } -class UserCustomData +class UserMark : private noncopyable { public: enum Type { - EMPTY, - POI, - SEARCH, API, + SEARCH, + POI, BOOKMARK }; - virtual ~UserCustomData() {} - - virtual Type GetType() const = 0; -}; - -class EmptyCustomData : public UserCustomData -{ -public: - virtual Type GetType() const { return EMPTY; } -}; - -class BaseCustomData : public UserCustomData -{ -public: - BaseCustomData(string const & name, string const & typeName, string address) - : m_name(name) - , m_typeName(typeName) - , m_address(address) {} - - string const & GetName() const { return m_name; } - string const & GetTypeName() const { return m_typeName; } - string const & GetAddress() const { return m_address; } - -private: - string m_name; - string m_typeName; - string m_address; -}; - -class PoiCustomData : public BaseCustomData -{ - typedef BaseCustomData base_t; -public: - PoiCustomData(string const & name, string const & typeName, string address) - : base_t(name, typeName, address) {} - - virtual Type GetType() const { return POI; } -}; - -class SearchCustomData : public BaseCustomData -{ - typedef BaseCustomData base_t; -public: - SearchCustomData(string const & name, string const & typeName, string address) - : base_t(name, typeName, address) {} - - virtual Type GetType() const { return SEARCH; } -}; - -class ApiCustomData : public UserCustomData -{ - typedef UserCustomData base_t; -public: - ApiCustomData(string const & name, string const & id) - : m_name(name) - , m_id(id) {} - - virtual Type GetType() const { return API; } - - string const & GetName() const { return m_name; } - string const & GetID() const {return m_id; } - -private: - string m_name; - string m_id; -}; - -class UserMark : private noncopyable -{ -public: UserMark(m2::PointD const & ptOrg, UserMarkContainer * container); virtual ~UserMark(); @@ -103,22 +34,83 @@ public: m2::PointD const & GetOrg() const; void GetLatLon(double & lat, double & lon) const; virtual bool IsCustomDrawable() const { return false;} - - // custom data must be allocated in head - // memory where allocated custom data will be deallocated by UserMark - void InjectCustomData(UserCustomData * customData); - UserCustomData const & GetCustomData() const; + virtual Type GetMarkType() const = 0; protected: friend class BookmarkManager; void Activate() const; void Diactivate() const; - UserCustomData & GetCustomData(); protected: m2::PointD m_ptOrg; mutable UserMarkContainer * m_container; - UserCustomData * m_customData; +}; + +class ApiMarkPoint : public UserMark +{ +public: + ApiMarkPoint(m2::PointD const & ptOrg, UserMarkContainer * container) + : UserMark(ptOrg, container) + { + } + + ApiMarkPoint(string const & name, + string const & id, + m2::PointD const & ptOrg, + UserMarkContainer * container) + : UserMark(ptOrg, container) + , m_name(name) + , m_id(id) + { + } + + UserMark::Type GetMarkType() const { return API; } + + string const & GetName() const { return m_name; } + void SetName(string const & name) { m_name = name; } + + string const & GetID() const { return m_id; } + void SetID(string const & id) { m_id = id; } + +private: + string m_name; + string m_id; +}; + +class SearchMarkPoint : public UserMark +{ +public: + SearchMarkPoint(search::AddressInfo const & info, + m2::PointD const & ptOrg, + UserMarkContainer * container) + : UserMark(ptOrg, container) + , m_info(info) + { + } + + SearchMarkPoint(m2::PointD const & ptOrg, UserMarkContainer * container) + : UserMark(ptOrg, container) + { + } + + UserMark::Type GetMarkType() const { return SEARCH; } + + search::AddressInfo const & GetInfo() const { return m_info; } + void SetInfo(search::AddressInfo const & info) { m_info = info; } + +private: + search::AddressInfo m_info; +}; + +class PoiMarkPoint : public SearchMarkPoint +{ +public: + PoiMarkPoint(UserMarkContainer * container) + : SearchMarkPoint(m2::PointD(0.0, 0.0), container) {} + + UserMark::Type GetMarkType() const { return POI; } + + void SetPtOrg(m2::PointD const & ptOrg) { m_ptOrg = ptOrg; } }; class ICustomDrawable : public UserMark diff --git a/map/user_mark_container.cpp b/map/user_mark_container.cpp index 00f1728e83..3b8c847a0f 100644 --- a/map/user_mark_container.cpp +++ b/map/user_mark_container.cpp @@ -15,6 +15,7 @@ #include "../base/stl_add.hpp" #include "../std/scoped_ptr.hpp" +#include "../std/algorithm.hpp" namespace { @@ -163,15 +164,13 @@ namespace } } -UserMarkContainer::UserMarkContainer(Type type, double layerDepth, Framework & framework) +UserMarkContainer::UserMarkContainer(double layerDepth, Framework & framework) : m_controller(this) - , m_type(type) , m_isVisible(true) , m_layerDepth(layerDepth) , m_activeMark(NULL) , m_framework(framework) { - ASSERT(m_type >= 0 && m_type < TERMINANT, ()); } UserMarkContainer::~UserMarkContainer() @@ -222,50 +221,18 @@ void UserMarkContainer::Clear() m_activeMark = NULL; } -static string s_TypeNames[] = -{ - "search-result", - "api-result", - "search-result" // Bookmark active we draw as a search active -}; - -string UserMarkContainer::GetTypeName() const -{ - ASSERT(m_type < ARRAY_SIZE(s_TypeNames), ()); - return s_TypeNames[m_type]; -} - -string UserMarkContainer::GetActiveTypeName() const -{ - return GetTypeName() + "-active"; -} - -UserMark * UserMarkContainer::AllocateUserMark(m2::PointD const & ptOrg) -{ - return new UserMark(ptOrg, this); -} - namespace { - class PoiUserMark : public UserMark - { - public: - PoiUserMark(UserMarkContainer * container) - : UserMark(m2::PointD(0.0, 0.0), container) {} - - void SetPtOrg(m2::PointD const & ptOrg) { m_ptOrg = ptOrg; } - }; - - static scoped_ptr s_selectionUserMark; + static scoped_ptr s_selectionUserMark; } void UserMarkContainer::InitPoiSelectionMark(UserMarkContainer * container) { ASSERT(s_selectionUserMark == NULL, ()); - s_selectionUserMark.reset(new PoiUserMark(container)); + s_selectionUserMark.reset(new PoiMarkPoint(container)); } -UserMark * UserMarkContainer::UserMarkForPoi(m2::PointD const & ptOrg) +PoiMarkPoint * UserMarkContainer::UserMarkForPoi(m2::PointD const & ptOrg) { ASSERT(s_selectionUserMark != NULL, ()); s_selectionUserMark->SetPtOrg(ptOrg); @@ -295,12 +262,6 @@ UserMark * UserMarkContainer::GetUserMark(size_t index) return m_userMarks[index]; } -void UserMarkContainer::EditUserMark(size_t index, UserCustomData * data) -{ - UserMark * mark = GetUserMark(index); - mark->InjectCustomData(data); -} - namespace { @@ -328,6 +289,13 @@ void UserMarkContainer::DeleteUserMark(size_t index) DeleteItem(m_userMarks, index); } +void UserMarkContainer::DeleteUserMark(UserMark const * mark) +{ + vector::iterator it = find(m_userMarks.begin(), m_userMarks.end(), mark); + if (it != m_userMarks.end()) + DeleteUserMark(distance(m_userMarks.begin(), it)); +} + void UserMarkContainer::StartActivationAnim() { PinAnimation * anim = new PinAnimation(m_framework); @@ -353,3 +321,43 @@ double UserMarkContainer::GetActiveMarkScale() const return 1.0; } + +SearchUserMarkContainer::SearchUserMarkContainer(double layerDepth, Framework & framework) + : UserMarkContainer(layerDepth, framework) +{ +} + +string SearchUserMarkContainer::GetTypeName() const +{ + return "search-result"; +} + +string SearchUserMarkContainer::GetActiveTypeName() const +{ + return "search-result-active"; +} + +UserMark * SearchUserMarkContainer::AllocateUserMark(const m2::PointD & ptOrg) +{ + return new SearchMarkPoint(ptOrg, this); +} + +ApiUserMarkContainer::ApiUserMarkContainer(double layerDepth, Framework & framework) + : UserMarkContainer(layerDepth, framework) +{ +} + +string ApiUserMarkContainer::GetTypeName() const +{ + return "api-result"; +} + +string ApiUserMarkContainer::GetActiveTypeName() const +{ + return "search-result-active"; +} + +UserMark * ApiUserMarkContainer::AllocateUserMark(const m2::PointD & ptOrg) +{ + return new ApiMarkPoint(ptOrg, this); +} diff --git a/map/user_mark_container.hpp b/map/user_mark_container.hpp index 2ea5a34e68..dc5bde367a 100644 --- a/map/user_mark_container.hpp +++ b/map/user_mark_container.hpp @@ -34,8 +34,9 @@ public: UserMark * CreateUserMark(m2::PointD ptOrg) { return m_container->CreateUserMark(ptOrg); } size_t GetUserMarkCount() const { return m_container->GetUserMarkCount(); } UserMark const * GetUserMark(size_t index) const { return m_container->GetUserMark(index); } - void EditUserMark(size_t index, UserCustomData * data) { m_container->EditUserMark(index, data); } + UserMark * GetUserMarkForEdit(size_t index) { return m_container->GetUserMark(index); } void DeleteUserMark(size_t index) { m_container->DeleteUserMark(index); } + void DeleteUserMark(UserMark const * mark) { m_container->DeleteUserMark(mark); } private: UserMarkContainer * m_container; @@ -45,14 +46,14 @@ public: { SEARCH_MARK, API_MARK, - BOOKMARK_MARK, - TERMINANT + BOOKMARK_MARK }; - UserMarkContainer(Type type, double layerDepth, Framework & framework); + UserMarkContainer(double layerDepth, Framework & framework); virtual ~UserMarkContainer(); void SetScreen(graphics::Screen * cacheScreen); + virtual Type GetType() const = 0; bool IsVisible() const { return m_isVisible; } void SetVisible(bool isVisible) { m_isVisible = isVisible; } @@ -68,19 +69,18 @@ public: void Clear(); - Type const & GetType() const { return m_type; } double GetDepth() const { return m_layerDepth; } static void InitPoiSelectionMark(UserMarkContainer * container); - static UserMark * UserMarkForPoi(m2::PointD const & ptOrg); + static PoiMarkPoint * UserMarkForPoi(m2::PointD const & ptOrg); Controller const & GetController() const { return m_controller; } Controller & GetController() { return m_controller; } protected: - virtual string GetTypeName() const; - virtual string GetActiveTypeName() const; - virtual UserMark * AllocateUserMark(m2::PointD const & ptOrg); + virtual string GetTypeName() const = 0; + virtual string GetActiveTypeName() const = 0; + virtual UserMark * AllocateUserMark(m2::PointD const & ptOrg) = 0; private: friend class Controller; @@ -88,12 +88,11 @@ private: size_t GetUserMarkCount() const; UserMark const * GetUserMark(size_t index) const; UserMark * GetUserMark(size_t index); - void EditUserMark(size_t index, UserCustomData * data); void DeleteUserMark(size_t index); + void DeleteUserMark(UserMark const * mark); private: Controller m_controller; - Type m_type; bool m_isVisible; double m_layerDepth; vector m_userMarks; @@ -108,3 +107,29 @@ private: Framework & m_framework; shared_ptr m_animTask; }; + +class SearchUserMarkContainer : public UserMarkContainer +{ +public: + SearchUserMarkContainer(double layerDepth, Framework & framework); + + virtual Type GetType() const { return SEARCH_MARK; } + +protected: + virtual string GetTypeName() const; + virtual string GetActiveTypeName() const; + virtual UserMark * AllocateUserMark(m2::PointD const & ptOrg); +}; + +class ApiUserMarkContainer : public UserMarkContainer +{ +public: + ApiUserMarkContainer(double layerDepth, Framework & framework); + + virtual Type GetType() const { return API_MARK; } + +protected: + virtual string GetTypeName() const; + virtual string GetActiveTypeName() const; + virtual UserMark * AllocateUserMark(m2::PointD const & ptOrg); +}; diff --git a/qt/search_panel.cpp b/qt/search_panel.cpp index 8be3aced46..188c60b35e 100644 --- a/qt/search_panel.cpp +++ b/qt/search_panel.cpp @@ -129,8 +129,10 @@ void SearchPanel::OnSearchResult(ResultsT * res) if (e.GetResultType() != ResultT::RESULT_SUGGESTION) { - UserMark * mark = manager.UserMarksAddMark(UserMarkContainer::SEARCH_MARK, e.GetFeatureCenter()); - mark->InjectCustomData(new SearchCustomData(e.GetString(), "", "")); + SearchMarkPoint * mark = static_cast(manager.UserMarksAddMark(UserMarkContainer::SEARCH_MARK, e.GetFeatureCenter())); + search::AddressInfo info; + info.MakeFrom(e); + mark->SetInfo(info); // For debug purposes: add bookmarks for search results m_pTable->setItem(rowCount, 0, create_item(QString::fromUtf8(e.GetFeatureType())));