diff --git a/common/widgets/search_pane_tab.cpp b/common/widgets/search_pane_tab.cpp index 7f0297d0c1..300e63d409 100644 --- a/common/widgets/search_pane_tab.cpp +++ b/common/widgets/search_pane_tab.cpp @@ -22,6 +22,7 @@ #include #include #include +#include SEARCH_PANE_LISTVIEW::SEARCH_PANE_LISTVIEW( SEARCH_HANDLER* handler, wxWindow* parent, wxWindowID winid, const wxPoint& pos, @@ -42,6 +43,7 @@ SEARCH_PANE_LISTVIEW::SEARCH_PANE_LISTVIEW( SEARCH_HANDLER* handler, wxWindow* p Bind( wxEVT_LIST_ITEM_DESELECTED, &SEARCH_PANE_LISTVIEW::OnItemDeselected, this ); Bind( wxEVT_LIST_COL_CLICK, &SEARCH_PANE_LISTVIEW::OnColClicked, this ); Bind( wxEVT_UPDATE_UI, &SEARCH_PANE_LISTVIEW::OnUpdateUI, this ); + Bind( wxEVT_CHAR, &SEARCH_PANE_LISTVIEW::OnChar, this ); } @@ -51,7 +53,9 @@ SEARCH_PANE_LISTVIEW::~SEARCH_PANE_LISTVIEW() Unbind( wxEVT_LIST_ITEM_ACTIVATED, &SEARCH_PANE_LISTVIEW::OnItemActivated, this ); Unbind( wxEVT_LIST_ITEM_FOCUSED, &SEARCH_PANE_LISTVIEW::OnItemSelected, this ); Unbind( wxEVT_LIST_ITEM_DESELECTED, &SEARCH_PANE_LISTVIEW::OnItemDeselected, this ); + Unbind( wxEVT_LIST_COL_CLICK, &SEARCH_PANE_LISTVIEW::OnColClicked, this ); Unbind( wxEVT_UPDATE_UI, &SEARCH_PANE_LISTVIEW::OnUpdateUI, this ); + Unbind( wxEVT_CHAR, &SEARCH_PANE_LISTVIEW::OnChar, this ); } @@ -133,6 +137,44 @@ void SEARCH_PANE_LISTVIEW::OnColClicked( wxListEvent& aEvent ) } +void SEARCH_PANE_LISTVIEW::OnChar( wxKeyEvent& aEvent ) +{ + if( aEvent.GetKeyCode() == WXK_CONTROL_A ) + { + // Select All + for( int row = 0; row < GetItemCount(); row++ ) + SetItemState( row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); + } + else if( aEvent.GetKeyCode() == WXK_CONTROL_C ) + { + // Copy to clipboard the selected rows + if( wxTheClipboard->Open() ) + { + wxString txt; + for( int row = 0; row < GetItemCount(); row++ ) + { + if( GetItemState( row, wxLIST_STATE_SELECTED ) == wxLIST_STATE_SELECTED ) + { + for( int col = 0; col < GetColumnCount(); col++ ) + { + if( GetColumnWidth( col ) > 0 ) + { + txt += GetItemText( row, col ); + if( row <= GetItemCount() - 1 ) + txt += wxT( "\t" ); + } + } + txt += wxT( "\n" ); + } + } + + wxTheClipboard->SetData( new wxTextDataObject( txt ) ); + wxTheClipboard->Close(); + } + } +} + + void SEARCH_PANE_LISTVIEW::Sort() { m_handler->Sort( m_sortCol, m_sortAscending ); diff --git a/include/widgets/search_pane_tab.h b/include/widgets/search_pane_tab.h index 3777ac70e6..68150251e7 100644 --- a/include/widgets/search_pane_tab.h +++ b/include/widgets/search_pane_tab.h @@ -49,6 +49,7 @@ protected: void OnItemDeselected( wxListEvent& aEvent ); void OnColClicked( wxListEvent& aEvent ); void OnUpdateUI( wxUpdateUIEvent& aEvent ); + void OnChar( wxKeyEvent& aEvent ); void GetSelectRowsList( std::vector& aSelectedList );