Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2014-10-09 19:34:49 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:29:59 +0300
commit9fbe5893b096db31e90039209d9ea0c5d21c9526 (patch)
treee6fbf3a0ee39cfc6dd4cfb1b9e8cfbaf36aaf527 /map/active_maps_layout.cpp
parentaf9ca3036112619648ab57fdc177e63066954c8d (diff)
[storage] CountryTree now initialized in Framework::AddMaps. It’s correct way for Android, when active maps set can be changed.
Diffstat (limited to 'map/active_maps_layout.cpp')
-rw-r--r--map/active_maps_layout.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/map/active_maps_layout.cpp b/map/active_maps_layout.cpp
index 02c913a115..0921454df1 100644
--- a/map/active_maps_layout.cpp
+++ b/map/active_maps_layout.cpp
@@ -1,34 +1,38 @@
#include "active_maps_layout.hpp"
-
#include "framework.hpp"
+#include "../std/algorithm.hpp"
+
+
namespace storage
{
ActiveMapsLayout::ActiveMapsLayout(Framework & framework)
: m_framework(framework)
{
- m_subscribeSlotID = m_framework.Storage().Subscribe(bind(&ActiveMapsLayout::StatusChangedCallback, this, _1),
- bind(&ActiveMapsLayout::ProgressChangedCallback, this, _1, _2));
-
- Init();
+ m_subscribeSlotID = GetStorage().Subscribe(bind(&ActiveMapsLayout::StatusChangedCallback, this, _1),
+ bind(&ActiveMapsLayout::ProgressChangedCallback, this, _1, _2));
}
ActiveMapsLayout::~ActiveMapsLayout()
{
- m_framework.Storage().Unsubscribe(m_subscribeSlotID);
+ GetStorage().Unsubscribe(m_subscribeSlotID);
}
-void ActiveMapsLayout::Init()
+void ActiveMapsLayout::Init(vector<string> const & maps)
{
Storage & storage = GetStorage();
- auto insertIndexFn = [&](TIndex const & index)
+ auto insertIndexFn = [&] (TIndex const & index)
{
- TStatus status;
- TMapOptions options;
- storage.CountryStatusEx(index, status, options);
- if (status == TStatus::EOnDisk || status == TStatus::EOnDiskOutOfDate)
- m_items.push_back({ index, status, options, options });
+ string const fName = storage.CountryFileNameWithoutExt(index) + DATA_FILE_EXTENSION;
+ if (binary_search(maps.begin(), maps.end(), fName))
+ {
+ TStatus status;
+ TMapOptions options;
+ storage.CountryStatusEx(index, status, options);
+ if (status == TStatus::EOnDisk || status == TStatus::EOnDiskOutOfDate)
+ m_items.push_back({ index, status, options, options });
+ }
};
TIndex root;
@@ -63,7 +67,7 @@ void ActiveMapsLayout::Init()
sort(m_items.begin(), m_items.end(), comparatorFn);
- m_split = make_pair(0, m_items.size());
+ m_split = { 0, m_items.size() };
for (size_t i = 0; i < m_items.size(); ++i)
{
if (m_items[i].m_status == TStatus::EOnDisk)
@@ -74,6 +78,12 @@ void ActiveMapsLayout::Init()
}
}
+void ActiveMapsLayout::Clear()
+{
+ m_items.clear();
+ m_split = { 0, 0 };
+}
+
void ActiveMapsLayout::UpdateAll()
{
vector<Item> toDownload;