void SFTPTreeView::OnSelectionChanged(wxTreeEvent& event) { MyClientDataVect_t items = GetSelectionsItemData(); if(items.size() != 1) return; MyClientData* cd = items.at(0); if(cd->IsFolder()) { m_textCtrlQuickJump->ChangeValue(cd->GetFullPath()); } }
void SFTPTreeView::OnAddBookmark(wxAuiToolBarEvent& event) { if ( event.IsDropDownClicked() ) { // Show the menu const wxArrayString &bookmarks = m_account.GetBookmarks(); wxMenu menu; for(size_t i=0; i<bookmarks.GetCount(); ++i) { menu.Append(ID_SFTP_BOOKMARK_FIRST+i, bookmarks.Item(i)); } menu.AppendSeparator(); menu.Append(ID_SFTP_BOOKMARK_SETTINGS, _("Manage bookmarks...")); wxPoint pt = event.GetItemRect().GetBottomLeft(); pt.y++; int sel = m_auibar->GetPopupMenuSelectionFromUser( menu, pt ); if ( sel >= ID_SFTP_BOOKMARK_FIRST && sel <= ID_SFTP_BOOKMARK_LAST ) { // A bookmark was selected CallAfter( &SFTPTreeView::DoBuildTree, bookmarks.Item(sel - ID_SFTP_BOOKMARK_FIRST) ); } else if ( sel == ID_SFTP_BOOKMARK_SETTINGS ) { // Bookmark settings CallAfter( &SFTPTreeView::ManageBookmarks ); } } else { try { // sanity if ( !m_sftp || !m_sftp->IsConnected() ) { return; } // Get the current selection MyClientDataVect_t selections = GetSelectionsItemData(); if ( selections.size() != 1 ) return; MyClientData* cd = selections.at(0); CHECK_PTR_RET( cd ); if ( !cd->IsFolder() ) return; m_account.AddBookmark( cd->GetFullPath() ); SFTPSettings settings; settings.Load(); settings.UpdateAccount( m_account ); settings.Save(); } catch (clException &e) { ::wxMessageBox(e.What(), "SFTP", wxICON_ERROR|wxOK|wxCENTER); } } }
MyClientDataVect_t SFTPTreeView::GetSelectionsItemData() { MyClientDataVect_t res; wxArrayTreeItemIds items; m_treeCtrl->GetSelections(items); for(size_t i = 0; i < items.GetCount(); ++i) { MyClientData* cd = GetItemData(items.Item(i)); if(cd) { res.push_back(cd); } } return res; }
MyClientDataVect_t SFTPTreeView::GetSelectionsItemData() { MyClientDataVect_t res; wxTreeListItems items; m_treeListCtrl->GetSelections(items); for(size_t i = 0; i < items.size(); ++i) { MyClientData* cd = GetItemData(items.at(i)); if(cd) { res.push_back(cd); } } return res; }