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:
authorExMix <rahuba.youri@mapswithme.com>2014-10-08 12:10:41 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:29:39 +0300
commit09773ea66d30f75f46171017c38654eb91730054 (patch)
tree780d67f7f412acde53dad1ee4c607d07c59b516b /map/country_status_display.cpp
parent29214d78b3283a05de3072a2631daf145b11b390 (diff)
[core] correct format map size
Diffstat (limited to 'map/country_status_display.cpp')
-rw-r--r--map/country_status_display.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/map/country_status_display.cpp b/map/country_status_display.cpp
index 91f37c6b16..e3dffc35a2 100644
--- a/map/country_status_display.cpp
+++ b/map/country_status_display.cpp
@@ -320,6 +320,25 @@ void CountryStatusDisplay::SetContentForState()
}
}
+namespace
+{
+ void FormatMapSize(int sizeInBytes, string & units, int & sizeToDownload)
+ {
+ int const mbInBytes = 1024 * 1024;
+ int const kbInBytes = 1024;
+ if (sizeInBytes < mbInBytes)
+ {
+ sizeToDownload = sizeInBytes / kbInBytes;
+ units = "KB";
+ }
+ else
+ {
+ sizeToDownload = sizeInBytes / mbInBytes;
+ units = "MB";
+ }
+ }
+}
+
void CountryStatusDisplay::SetContentForDownloadPropose()
{
ASSERT(m_label->isVisible(), ());
@@ -330,10 +349,12 @@ void CountryStatusDisplay::SetContentForDownloadPropose()
LocalAndRemoteSizeT withRouting = m_activeMaps.GetCountrySize(m_countryIdx, TMapOptions::EMapWithCarRouting);
m_label->setText(m_displayMapName);
- int mbToDownload = mapOnlySize.second / (1024 * 1024);
- m_primaryButton->setText(FormatStatusMessage<int, int>("country_status_download", &mbToDownload));
- mbToDownload = withRouting.second / (1024 * 1024);
- m_secondaryButton->setText(FormatStatusMessage<int, int>("country_status_download_routing", &mbToDownload));
+ int sizeToDownload;
+ string units;
+ FormatMapSize(mapOnlySize.second, units, sizeToDownload);
+ m_primaryButton->setText(FormatStatusMessage<int, string>("country_status_download", &sizeToDownload, &units));
+ FormatMapSize(withRouting.second, units, sizeToDownload);
+ m_secondaryButton->setText(FormatStatusMessage<int, string>("country_status_download_routing", &sizeToDownload));
}
void CountryStatusDisplay::SetContentForProgress()