Skip to content

Commit

Permalink
Add a Reset Bookmarks menu (empty the bookmarks), similar to Reset Se…
Browse files Browse the repository at this point in the history
…ssion
  • Loading branch information
vsonnier committed Jan 12, 2018
1 parent 0f72a0f commit 7b904bf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
22 changes: 16 additions & 6 deletions src/AppFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,11 @@ AppFrame::AppFrame() :
menu->AppendSeparator();
menu->Append(wxID_RESET, "&Reset Session");
menu->AppendSeparator();
menu->Append(wxID_OPEN_BOOKMARK, "Open Bookmark");
menu->Append(wxID_SAVE_BOOKMARK, "Save Bookmark");
menu->Append(wxID_SAVEAS_BOOKMARK, "Save Bookmark As..");
menu->Append(wxID_OPEN_BOOKMARKS, "Open Bookmarks");
menu->Append(wxID_SAVE_BOOKMARKS, "Save Bookmarks");
menu->Append(wxID_SAVEAS_BOOKMARKS, "Save Bookmarks As..");
menu->AppendSeparator();
menu->Append(wxID_RESET_BOOKMARKS, "Reset Bookmarks");

#ifndef __APPLE__
menu->AppendSeparator();
Expand Down Expand Up @@ -1407,7 +1409,7 @@ bool AppFrame::actionOnMenuLoadSave(wxCommandEvent& event) {
}

//save mecanic for bookmark files
else if (event.GetId() == wxID_SAVE_BOOKMARK) {
else if (event.GetId() == wxID_SAVE_BOOKMARKS) {

if (!currentBookmarkFile.empty()) {
wxGetApp().getBookmarkMgr().saveToFile(currentBookmarkFile, false, true);
Expand All @@ -1434,7 +1436,7 @@ bool AppFrame::actionOnMenuLoadSave(wxCommandEvent& event) {

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);
if (openFileDialog.ShowModal() == wxID_CANCEL) {
Expand All @@ -1454,7 +1456,7 @@ bool AppFrame::actionOnMenuLoadSave(wxCommandEvent& event) {

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);
if (saveFileDialog.ShowModal() == wxID_CANCEL) {
Expand All @@ -1476,6 +1478,14 @@ bool AppFrame::actionOnMenuLoadSave(wxCommandEvent& event) {

return true;
}
else if (event.GetId() == wxID_RESET_BOOKMARKS) {

wxGetApp().getBookmarkMgr().resetBookmarks();
wxGetApp().getBookmarkMgr().updateBookmarks();
wxGetApp().getBookmarkMgr().updateActiveList();

return true;
}

return false;
}
Expand Down
7 changes: 4 additions & 3 deletions src/AppFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@
#define wxID_SET_DB_OFFSET 2012
#define wxID_ABOUT_CUBICSDR 2013

#define wxID_OPEN_BOOKMARK 2020
#define wxID_SAVE_BOOKMARK 2021
#define wxID_SAVEAS_BOOKMARK 2022
#define wxID_OPEN_BOOKMARKS 2020
#define wxID_SAVE_BOOKMARKS 2021
#define wxID_SAVEAS_BOOKMARKS 2022
#define wxID_RESET_BOOKMARKS 2023

#define wxID_MAIN_SPLITTER 2050
#define wxID_VIS_SPLITTER 2051
Expand Down
11 changes: 11 additions & 0 deletions src/BookmarkMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ bool BookmarkMgr::loadFromFile(std::string bookmarkFn, bool backup, bool useFull
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) {
wxFileName lastLoaded(wxGetApp().getConfig()->getConfigDir(), bookmarkFn + ".lastloaded");
Expand Down
2 changes: 2 additions & 0 deletions src/BookmarkMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class BookmarkMgr {
void saveToFile(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 hasBackup(std::string bookmarkFn);

Expand Down

0 comments on commit 7b904bf

Please sign in to comment.