コード例 #1
0
ファイル: SFTPTreeView.cpp プロジェクト: lpc1996/codelite
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()); }
}
コード例 #2
0
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);
        }
    }
}