forked from organicmaps/organicmaps
Bookmark category id assignment changed.
This commit is contained in:
parent
e6d910a9eb
commit
b918e138b4
4 changed files with 22 additions and 16 deletions
|
@ -55,8 +55,8 @@ uint64_t LoadLastBmCategoryId()
|
|||
uint64_t lastId;
|
||||
std::string val;
|
||||
if (GetPlatform().GetSecureStorage().Load(kLastBookmarkCategoryId, val) && strings::to_uint64(val, lastId))
|
||||
return lastId;
|
||||
return static_cast<uint64_t>(UserMark::BOOKMARK);
|
||||
return max(static_cast<uint64_t>(UserMark::COUNT), lastId);
|
||||
return static_cast<uint64_t>(UserMark::COUNT);
|
||||
}
|
||||
|
||||
void SaveLastBmCategoryId(uint64_t lastId)
|
||||
|
@ -66,7 +66,7 @@ void SaveLastBmCategoryId(uint64_t lastId)
|
|||
|
||||
uint64_t ResetLastBmCategoryId()
|
||||
{
|
||||
auto const lastId = static_cast<uint64_t>(UserMark::BOOKMARK);
|
||||
auto const lastId = static_cast<uint64_t>(UserMark::COUNT);
|
||||
SaveLastBmCategoryId(lastId);
|
||||
return lastId;
|
||||
}
|
||||
|
@ -431,9 +431,9 @@ BookmarkManager::BookmarkManager(Callbacks && callbacks)
|
|||
std::bind(&ConvertAfterDownloading, _1, _2)))
|
||||
{
|
||||
ASSERT(m_callbacks.m_getStringsBundle != nullptr, ());
|
||||
ASSERT_GREATER_OR_EQUAL(m_lastGroupID, UserMark::BOOKMARK, ());
|
||||
m_userMarkLayers.reserve(UserMark::BOOKMARK);
|
||||
for (uint32_t i = 0; i < UserMark::BOOKMARK; ++i)
|
||||
ASSERT_GREATER_OR_EQUAL(m_lastGroupID, UserMark::COUNT, ());
|
||||
m_userMarkLayers.reserve(UserMark::COUNT - 1);
|
||||
for (uint32_t i = 1; i < UserMark::COUNT; ++i)
|
||||
m_userMarkLayers.emplace_back(std::make_unique<UserMarkLayer>(static_cast<UserMark::Type>(i)));
|
||||
|
||||
m_selectionMark = CreateUserMark<StaticMarkPoint>(m2::PointD{});
|
||||
|
@ -1340,7 +1340,7 @@ public:
|
|||
|
||||
void operator()(df::MarkGroupID groupId)
|
||||
{
|
||||
m2::AnyRectD const & rect = m_rectHolder(min((UserMark::Type)groupId, UserMark::BOOKMARK));
|
||||
m2::AnyRectD const & rect = m_rectHolder(BookmarkManager::GetGroupType(groupId));
|
||||
if (UserMark const * p = m_manager->FindMarkInRect(groupId, rect, m_d))
|
||||
{
|
||||
static double const kEps = 1e-5;
|
||||
|
@ -1381,8 +1381,8 @@ UserMark const * BookmarkManager::FindNearestUserMark(TTouchRectHolder const & h
|
|||
UserMarkLayer const * BookmarkManager::GetGroup(df::MarkGroupID groupId) const
|
||||
{
|
||||
ASSERT_THREAD_CHECKER(m_threadChecker, ());
|
||||
if (groupId < UserMark::Type::BOOKMARK)
|
||||
return m_userMarkLayers[groupId].get();
|
||||
if (groupId < UserMark::Type::COUNT)
|
||||
return m_userMarkLayers[groupId - 1].get();
|
||||
|
||||
ASSERT(m_categories.find(groupId) != m_categories.end(), ());
|
||||
return m_categories.at(groupId).get();
|
||||
|
@ -1391,8 +1391,8 @@ UserMarkLayer const * BookmarkManager::GetGroup(df::MarkGroupID groupId) const
|
|||
UserMarkLayer * BookmarkManager::GetGroup(df::MarkGroupID groupId)
|
||||
{
|
||||
ASSERT_THREAD_CHECKER(m_threadChecker, ());
|
||||
if (groupId < UserMark::Type::BOOKMARK)
|
||||
return m_userMarkLayers[groupId].get();
|
||||
if (groupId < UserMark::Type::COUNT)
|
||||
return m_userMarkLayers[groupId - 1].get();
|
||||
|
||||
auto const it = m_categories.find(groupId);
|
||||
return it != m_categories.end() ? it->second.get() : nullptr;
|
||||
|
@ -1855,7 +1855,7 @@ df::GroupIDSet BookmarkManager::MarksChangesTracker::GetAllGroupIds() const
|
|||
{
|
||||
auto const & groupIds = m_bmManager.GetBmGroupsIdList();
|
||||
df::GroupIDSet resultingSet(groupIds.begin(), groupIds.end());
|
||||
for (uint32_t i = 0; i < UserMark::BOOKMARK; ++i)
|
||||
for (uint32_t i = 1; i < UserMark::COUNT; ++i)
|
||||
resultingSet.insert(static_cast<df::MarkGroupID>(i));
|
||||
return resultingSet;
|
||||
}
|
||||
|
|
|
@ -141,7 +141,11 @@ public:
|
|||
void UpdateViewport(ScreenBase const & screen);
|
||||
void Teardown();
|
||||
|
||||
static bool IsBookmarkCategory(df::MarkGroupID groupId) { return groupId >= UserMark::BOOKMARK; }
|
||||
static UserMark::Type GetGroupType(df::MarkGroupID groupId)
|
||||
{
|
||||
return groupId >= UserMark::COUNT ? UserMark::BOOKMARK : static_cast<UserMark::Type>(groupId);
|
||||
}
|
||||
static bool IsBookmarkCategory(df::MarkGroupID groupId) { return groupId >= UserMark::COUNT; }
|
||||
static bool IsBookmark(df::MarkID markId) { return UserMark::GetMarkType(markId) == UserMark::BOOKMARK; }
|
||||
|
||||
template <typename UserMarkT>
|
||||
|
@ -332,7 +336,7 @@ private:
|
|||
ASSERT_LESS(groupId, m_userMarkLayers.size(), ());
|
||||
m_userMarks.emplace(markId, std::move(mark));
|
||||
m_changesTracker.OnAddMark(markId);
|
||||
m_userMarkLayers[groupId]->AttachUserMark(markId);
|
||||
m_userMarkLayers[groupId - 1]->AttachUserMark(markId);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ df::MarkID GetNextUserMarkId(UserMark::Type type, bool reset = false)
|
|||
return df::kInvalidMarkId;
|
||||
}
|
||||
|
||||
static_assert(UserMark::Type::BOOKMARK < (1 << kMarkIdTypeBitsCount), "Not enough bits for user mark type.");
|
||||
static_assert(UserMark::Type::COUNT <= (1 << kMarkIdTypeBitsCount), "Not enough bits for user mark type.");
|
||||
|
||||
auto const typeBits = static_cast<uint64_t>(type) << (sizeof(df::MarkID) * 8 - kMarkIdTypeBitsCount);
|
||||
if (type == UserMark::Type::BOOKMARK)
|
||||
|
@ -147,5 +147,6 @@ string DebugPrint(UserMark::Type type)
|
|||
case UserMark::Type::ROUTING: return "ROUTING";
|
||||
case UserMark::Type::LOCAL_ADS: return "LOCAL_ADS";
|
||||
case UserMark::Type::TRANSIT: return "TRANSIT";
|
||||
case UserMark::Type::COUNT: return "COUNT";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
|
||||
enum Type: uint32_t
|
||||
{
|
||||
BOOKMARK, // Should always be the first one
|
||||
API,
|
||||
SEARCH,
|
||||
STATIC,
|
||||
|
@ -39,7 +40,7 @@ public:
|
|||
TRANSIT,
|
||||
LOCAL_ADS,
|
||||
DEBUG_MARK,
|
||||
BOOKMARK, // Should always be the last one
|
||||
COUNT,
|
||||
};
|
||||
|
||||
UserMark(df::MarkID id, m2::PointD const & ptOrg, UserMark::Type type);
|
||||
|
|
Loading…
Add table
Reference in a new issue