blob: 58f82c318b764310e6eb6eb04279b2f8105a2094 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#pragma once
#include "map/active_maps_layout.hpp"
#include "storage/index.hpp"
#include "storage/storage_defines.hpp"
#include "platform/local_country_file.hpp"
#include "base/buffer_vector.hpp"
#include "std/function.hpp"
#include "std/shared_ptr.hpp"
#include "std/string.hpp"
class Framework;
namespace storage
{
class Storage;
class CountryTree
{
public:
class CountryTreeListener
{
public:
virtual void ItemStatusChanged(int childPosition) = 0;
virtual void ItemProgressChanged(int childPosition, LocalAndRemoteSizeT const & sizes) = 0;
};
CountryTree() = default;
explicit CountryTree(Framework & framework);
CountryTree(CountryTree const & other) = delete;
~CountryTree();
CountryTree & operator=(CountryTree const & other);
/// @param[in] Sorted vector of current .mwm files.
void Init(vector<ActiveMapsLayout::TLocalFilePtr> const & maps);
void Clear();
ActiveMapsLayout & GetActiveMapLayout();
ActiveMapsLayout const & GetActiveMapLayout() const;
bool IsValid() const;
void SetDefaultRoot();
void SetParentAsRoot();
void SetChildAsRoot(int childPosition);
void ResetRoot();
bool HasRoot() const;
bool HasParent() const;
int GetChildCount() const;
bool IsLeaf(int childPosition) const;
string const & GetChildName(int position) const;
/// call this only if child IsLeaf == true
TStatus GetLeafStatus(int position) const;
MapOptions GetLeafOptions(int position) const;
LocalAndRemoteSizeT const GetDownloadableLeafSize(int position) const;
LocalAndRemoteSizeT const GetLeafSize(int position, MapOptions const & options) const;
LocalAndRemoteSizeT const GetRemoteLeafSizes(int position) const;
bool IsCountryRoot() const;
string const & GetRootName() const;
///@{
void DownloadCountry(int childPosition, MapOptions const & options);
void DeleteCountry(int childPosition, MapOptions const & options);
void RetryDownloading(int childPosition);
///@}
void CancelDownloading(int childPosition);
void SetListener(CountryTreeListener * listener);
void ResetListener();
void ShowLeafOnMap(int position);
private:
Storage const & GetStorage() const;
Storage & GetStorage();
void ConnectToCoreStorage();
void DisconnectFromCoreStorage();
private:
TIndex const & GetCurrentRoot() const;
void SetRoot(TIndex index);
TIndex const & GetChild(int childPosition) const;
int GetChildPosition(TIndex const & index);
void NotifyStatusChanged(TIndex const & index);
void NotifyProgressChanged(TIndex const & index, LocalAndRemoteSizeT const & sizes);
private:
int m_subscribeSlotID = 0;
mutable shared_ptr<ActiveMapsLayout> m_layout;
buffer_vector<TIndex, 16> m_levelItems;
CountryTreeListener * m_listener = nullptr;
};
}
|