Loading bookmark fix

This commit is contained in:
Kirill Zhdanovich 2013-02-03 19:03:06 +03:00 committed by Alex Zolotarev
parent fe335bc65a
commit 2295e03d51
2 changed files with 19 additions and 5 deletions

View file

@ -373,6 +373,17 @@ void Framework::LoadBookmarks()
}
}
void Framework::LoadBookmark(string const & filePath)
{
BookmarkCategory * cat = BookmarkCategory::CreateFromKMLFile(filePath);
if (cat)
{
m_bookmarks.push_back(cat);
LOG(LINFO, ("Loaded bookmarks category", cat->GetName(), "with", cat->GetBookmarksCount(), "bookmarks"));
}
}
BookmarkCategory * Framework::AddBookmark(string const & category, Bookmark const & bm)
{
// Get global non-rotated viewport rect and calculate viewport scale level.
@ -574,10 +585,11 @@ string const GenerateValidandUniqFilePathForKLM(string const & filename)
bool Framework::AddBookmarksFile(string const & filePath)
{
string const fileExt = GetFileExt(filePath);
string fileSavePath;
if (fileExt == KML_EXTENSION)
{
string savePath = GenerateValidandUniqFilePathForKLM( GetFileName(filePath) );
if (!my::CopyFile(filePath, savePath))
fileSavePath = GenerateValidandUniqFilePathForKLM( GetFileName(filePath) );
if (!my::CopyFile(filePath, fileSavePath))
return false;
}
else if (fileExt == KMZ_EXTENSION)
@ -598,8 +610,8 @@ bool Framework::AddBookmarksFile(string const & filePath)
}
if (kmlFileName.empty())
return false;
string const savePath = GenerateValidandUniqFilePathForKLM(kmlFileName);
ZipFileReader::UnzipFile(filePath, kmlFileName, savePath);
fileSavePath = GenerateValidandUniqFilePathForKLM(kmlFileName);
ZipFileReader::UnzipFile(filePath, kmlFileName, fileSavePath);
}
catch (RootException const & e)
{
@ -614,7 +626,7 @@ bool Framework::AddBookmarksFile(string const & filePath)
}
// Update freshly added bookmarks
LoadBookmarks();
LoadBookmark(fileSavePath);
return true;
}

View file

@ -187,6 +187,8 @@ public:
/// Scans and loads all kml files with bookmarks in WritableDir
void LoadBookmarks();
void LoadBookmark(string const & filePath);
// Always returns existing or newly created bookmark category
BookmarkCategory * AddBookmark(string const & category, Bookmark const & bm);
inline size_t GetBmCategoriesCount() const { return m_bookmarks.size(); }