[ios] Added country rect centering to downloader

This commit is contained in:
Alex Zolotarev 2011-04-08 04:27:01 +02:00 committed by Alex Zolotarev
parent ab5b360e10
commit b2f0ad97df
6 changed files with 33 additions and 0 deletions

View file

@ -33,6 +33,8 @@
- (id) initWithCoder: (NSCoder *)coder;
- (void) ZoomToRect: (m2::RectD const &) rect;
- (void) UpdateIcon: (NSTimer *)theTimer;
- (void) OnUpdateLocation: (m2::PointD const &) mercatorPoint
withErrorRadius: (double) errorRadius

View file

@ -26,6 +26,11 @@ typedef FrameWork<model::FeaturesFetcher, Navigator> framework_t;
shared_ptr<Locator> m_locator;
storage::Storage m_storage;
- (void) ZoomToRect: (m2::RectD const &) rect
{
if (m_framework)
m_framework->ShowRect(rect);
}
- (void)UpdateIcon:(NSTimer *)theTimer
{

View file

@ -125,6 +125,17 @@ static bool IsOurIndex(TIndex const & theirs, TIndex const & ours)
// return nil;
//}
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
TIndex index = CalculateIndex(m_index, indexPath);
if (m_storage->CountryStatus(index) == EOnDisk)
{
m2::RectD bounds = m_storage->CountryBounds(index);
[[MapsAppDelegate theApp].settingsManager Hide];
[[MapsAppDelegate theApp].mapViewController ZoomToRect:bounds];
}
}
- (NSInteger) tableView: (UITableView *)tableView numberOfRowsInSection: (NSInteger)section
{
return m_storage->CountriesCount(m_index);
@ -164,6 +175,8 @@ static bool IsOurIndex(TIndex const & theirs, TIndex const & ours)
blue:68.f/255.f
alpha:1.f];
cell.detailTextLabel.text = [NSString stringWithFormat: @"Downloaded (%qu %s), touch to delete", size, kBorMBorGB];
// also add "sight" icon for centering on the country
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
break;
case EDownloading:

View file

@ -521,6 +521,12 @@ public:
UpdateNow();
}
void ShowRect(m2::RectD const & rect)
{
m_navigator.SetFromRect(rect);
UpdateNow();
}
void MemoryWarning()
{
// clearing caches on memory warning.

View file

@ -266,6 +266,12 @@ namespace storage
for_each(country.Tiles().begin(), country.Tiles().end(), DeleteMap());
}
m2::RectD Storage::CountryBounds(TIndex const & index) const
{
Country const & country = CountryByIndex(index);
return country.Bounds();
}
void Storage::DeleteCountry(TIndex const & index)
{
Country const & country = CountryByIndex(index);

View file

@ -128,6 +128,7 @@ namespace storage
string CountryName(TIndex const & index) const;
TLocalAndRemoteSize CountrySizeInBytes(TIndex const & index) const;
TStatus CountryStatus(TIndex const & index) const;
m2::RectD CountryBounds(TIndex const & index) const;
void DownloadCountry(TIndex const & index);
void DeleteCountry(TIndex const & index);