diff --git a/src/forms/Bookmark/BookmarkView.cpp b/src/forms/Bookmark/BookmarkView.cpp index 58b1756..b8b6150 100644 --- a/src/forms/Bookmark/BookmarkView.cpp +++ b/src/forms/Bookmark/BookmarkView.cpp @@ -243,11 +243,7 @@ void BookmarkView::onTreeItemMenu( wxTreeEvent& event ) { void BookmarkView::onMenuItem(wxCommandEvent& event) { if (event.GetId() == wxCONTEXT_ADD_GROUP_ID) { - wxString stringVal = wxGetTextFromUser("Enter Group Name", "Add Group", ""); - if (stringVal.ToStdString() != "") { - wxGetApp().getBookmarkMgr().getGroup(stringVal.ToStdString()); - wxGetApp().getBookmarkMgr().updateBookmarks(); - } + onAddGroup(event); } } @@ -417,14 +413,74 @@ void BookmarkView::recentSelection(BookmarkEntry *bmSel) { this->Layout(); } +void BookmarkView::groupSelection(std::string groupName) { + recentSel = nullptr; + activeSel = nullptr; + bookmarkSel = nullptr; + groupSel = groupName; + + clearButtons(); + + hideProps(); + + addButton(m_buttonPanel, "Remove Group", wxCommandEventHandler( BookmarkView::onRemoveGroup )); + addButton(m_buttonPanel, "Rename Group", wxCommandEventHandler( BookmarkView::onRenameGroup )); + + showButtons(); + + this->Layout(); +} + + +void BookmarkView::bookmarkBranchSelection() { + recentSel = nullptr; + activeSel = nullptr; + bookmarkSel = nullptr; + + clearButtons(); + + hideProps(); + + addButton(m_buttonPanel, "Add Group", wxCommandEventHandler( BookmarkView::onAddGroup )); + + showButtons(); + + this->Layout(); +} + + +void BookmarkView::recentBranchSelection() { + m_propPanel->Hide(); + hideProps(); + this->Layout(); +} + + +void BookmarkView::activeBranchSelection() { + m_propPanel->Hide(); + hideProps(); + this->Layout(); +} + void BookmarkView::onTreeSelect( wxTreeEvent& event ) { - TreeViewItem* tvi = dynamic_cast(m_treeView->GetItemData(event.GetItem())); + wxTreeItemId itm = event.GetItem(); + TreeViewItem* tvi = dynamic_cast(m_treeView->GetItemData(itm)); if (!tvi) { - m_propPanel->Hide(); - hideProps(); - this->Layout(); + + if (itm == bookmarkBranch) { + + } else if (itm == activeBranch) { + + } else if (itm == recentBranch) { + + } else { + m_propPanel->Hide(); + hideProps(); + this->Layout(); + } + return; } @@ -438,6 +494,9 @@ void BookmarkView::onTreeSelect( wxTreeEvent& event ) { } else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) { m_propPanel->Show(); bookmarkSelection(tvi->bookmarkEnt); + } else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) { + m_propPanel->Show(); + groupSelection(tvi->groupName); } else { m_propPanel->Hide(); hideProps(); @@ -516,6 +575,25 @@ void BookmarkView::onActivateRecent( wxCommandEvent& event ) { } +void BookmarkView::onAddGroup( wxCommandEvent& event ) { + wxString stringVal = wxGetTextFromUser("Enter Group Name", "Add Group", ""); + if (stringVal.ToStdString() != "") { + wxGetApp().getBookmarkMgr().getGroup(stringVal.ToStdString()); + wxGetApp().getBookmarkMgr().updateBookmarks(); + groupSel = stringVal; + } +} + +void BookmarkView::onRemoveGroup( wxCommandEvent& event ) { + +} + + +void BookmarkView::onRenameGroup( wxCommandEvent& event ) { + +} + + void BookmarkView::onTreeBeginDrag( wxTreeEvent& event ) { TreeViewItem* tvi = dynamic_cast(m_treeView->GetItemData(event.GetItem())); diff --git a/src/forms/Bookmark/BookmarkView.h b/src/forms/Bookmark/BookmarkView.h index d444014..9d4013f 100644 --- a/src/forms/Bookmark/BookmarkView.h +++ b/src/forms/Bookmark/BookmarkView.h @@ -36,6 +36,11 @@ public: void bookmarkSelection(BookmarkEntry *bmSel); void activateBookmark(BookmarkEntry *bmEnt); void recentSelection(BookmarkEntry *bmSel); + void groupSelection(std::string groupName); + void bookmarkBranchSelection(); + void recentBranchSelection(); + void activeBranchSelection(); + wxTreeItemId refreshBookmarks(); void updateTheme(); void onMenuItem(wxCommandEvent& event); @@ -83,6 +88,10 @@ protected: void onActivateBookmark( wxCommandEvent& event ); void onActivateRecent( wxCommandEvent& event ); + void onAddGroup( wxCommandEvent& event ); + void onRemoveGroup( wxCommandEvent& event ); + void onRenameGroup( wxCommandEvent& event ); + std::atomic_bool mouseInView; @@ -94,6 +103,7 @@ protected: // Bookmarks std::atomic_bool doUpdateBookmarks; std::set< std::string > doUpdateBookmarkGroup; + std::string groupSel; BookmarkNames groupNames; std::map groups; BookmarkEntry *bookmarkSel;