Add a Reset Bookmarks menu (empty the bookmarks), similar to Reset Session

This commit is contained in:
vsonnier 2018-01-12 19:17:04 +01:00
parent 0f72a0f683
commit 7b904bf803
4 changed files with 33 additions and 9 deletions

View File

@ -418,9 +418,11 @@ AppFrame::AppFrame() :
menu->AppendSeparator(); menu->AppendSeparator();
menu->Append(wxID_RESET, "&Reset Session"); menu->Append(wxID_RESET, "&Reset Session");
menu->AppendSeparator(); menu->AppendSeparator();
menu->Append(wxID_OPEN_BOOKMARK, "Open Bookmark"); menu->Append(wxID_OPEN_BOOKMARKS, "Open Bookmarks");
menu->Append(wxID_SAVE_BOOKMARK, "Save Bookmark"); menu->Append(wxID_SAVE_BOOKMARKS, "Save Bookmarks");
menu->Append(wxID_SAVEAS_BOOKMARK, "Save Bookmark As.."); menu->Append(wxID_SAVEAS_BOOKMARKS, "Save Bookmarks As..");
menu->AppendSeparator();
menu->Append(wxID_RESET_BOOKMARKS, "Reset Bookmarks");
#ifndef __APPLE__ #ifndef __APPLE__
menu->AppendSeparator(); menu->AppendSeparator();
@ -1407,7 +1409,7 @@ bool AppFrame::actionOnMenuLoadSave(wxCommandEvent& event) {
} }
//save mecanic for bookmark files //save mecanic for bookmark files
else if (event.GetId() == wxID_SAVE_BOOKMARK) { else if (event.GetId() == wxID_SAVE_BOOKMARKS) {
if (!currentBookmarkFile.empty()) { if (!currentBookmarkFile.empty()) {
wxGetApp().getBookmarkMgr().saveToFile(currentBookmarkFile, false, true); wxGetApp().getBookmarkMgr().saveToFile(currentBookmarkFile, false, true);
@ -1434,7 +1436,7 @@ bool AppFrame::actionOnMenuLoadSave(wxCommandEvent& event) {
return true; return true;
} }
else if (event.GetId() == wxID_OPEN_BOOKMARK) { else if (event.GetId() == wxID_OPEN_BOOKMARKS) {
wxFileDialog openFileDialog(this, _("Open XML Bookmark file"), "", "", "XML files (*.xml)|*.xml", wxFD_OPEN | wxFD_FILE_MUST_EXIST); wxFileDialog openFileDialog(this, _("Open XML Bookmark file"), "", "", "XML files (*.xml)|*.xml", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (openFileDialog.ShowModal() == wxID_CANCEL) { if (openFileDialog.ShowModal() == wxID_CANCEL) {
@ -1454,7 +1456,7 @@ bool AppFrame::actionOnMenuLoadSave(wxCommandEvent& event) {
return true; return true;
} }
else if (event.GetId() == wxID_SAVEAS_BOOKMARK) { else if (event.GetId() == wxID_SAVEAS_BOOKMARKS) {
wxFileDialog saveFileDialog(this, _("Save XML Bookmark file"), "", "", "XML files (*.xml)|*.xml", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); wxFileDialog saveFileDialog(this, _("Save XML Bookmark file"), "", "", "XML files (*.xml)|*.xml", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
if (saveFileDialog.ShowModal() == wxID_CANCEL) { if (saveFileDialog.ShowModal() == wxID_CANCEL) {
@ -1476,6 +1478,14 @@ bool AppFrame::actionOnMenuLoadSave(wxCommandEvent& event) {
return true; return true;
} }
else if (event.GetId() == wxID_RESET_BOOKMARKS) {
wxGetApp().getBookmarkMgr().resetBookmarks();
wxGetApp().getBookmarkMgr().updateBookmarks();
wxGetApp().getBookmarkMgr().updateActiveList();
return true;
}
return false; return false;
} }

View File

@ -43,9 +43,10 @@
#define wxID_SET_DB_OFFSET 2012 #define wxID_SET_DB_OFFSET 2012
#define wxID_ABOUT_CUBICSDR 2013 #define wxID_ABOUT_CUBICSDR 2013
#define wxID_OPEN_BOOKMARK 2020 #define wxID_OPEN_BOOKMARKS 2020
#define wxID_SAVE_BOOKMARK 2021 #define wxID_SAVE_BOOKMARKS 2021
#define wxID_SAVEAS_BOOKMARK 2022 #define wxID_SAVEAS_BOOKMARKS 2022
#define wxID_RESET_BOOKMARKS 2023
#define wxID_MAIN_SPLITTER 2050 #define wxID_MAIN_SPLITTER 2050
#define wxID_VIS_SPLITTER 2051 #define wxID_VIS_SPLITTER 2051

View File

@ -238,6 +238,17 @@ bool BookmarkMgr::loadFromFile(std::string bookmarkFn, bool backup, bool useFull
return loadStatusOk; return loadStatusOk;
} }
void BookmarkMgr::resetBookmarks() {
// Clear any active data
bmData.clear();
clearRecents();
clearRanges();
bmDataSorted.clear();
wxGetApp().getAppFrame()->getBookmarkView()->loadDefaultRanges();
}
bool BookmarkMgr::hasLastLoad(std::string bookmarkFn) { bool BookmarkMgr::hasLastLoad(std::string bookmarkFn) {
wxFileName lastLoaded(wxGetApp().getConfig()->getConfigDir(), bookmarkFn + ".lastloaded"); wxFileName lastLoaded(wxGetApp().getConfig()->getConfigDir(), bookmarkFn + ".lastloaded");

View File

@ -83,6 +83,8 @@ public:
void saveToFile(std::string bookmarkFn, bool backup = true, bool useFullpath = false); void saveToFile(std::string bookmarkFn, bool backup = true, bool useFullpath = false);
bool loadFromFile(std::string bookmarkFn, bool backup = true, bool useFullpath = false); bool loadFromFile(std::string bookmarkFn, bool backup = true, bool useFullpath = false);
void resetBookmarks();
bool hasLastLoad(std::string bookmarkFn); bool hasLastLoad(std::string bookmarkFn);
bool hasBackup(std::string bookmarkFn); bool hasBackup(std::string bookmarkFn);