24#include <wx/clipbrd.h>
26#include <wx/wupdlock.h>
30 wxWindowID winid,
const wxPoint& pos,
const wxSize& size ) :
31 wxListView( parent, winid, pos, size, wxLC_REPORT | wxLC_VIRTUAL ),
69 long idx = GetFirstSelected();
74 aSelectedList.emplace_back( idx );
76 idx = GetNextSelected( idx );
80 aSelectedList.emplace_back( idx );
81 idx = GetNextSelected( idx );
88 long item = aEvent.GetIndex();
121 std::vector<long> list;
142 std::vector<long> selection =
Sort();
144 for(
long row = 0; row < GetItemCount(); row++ )
147 SetItemState( row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
149 SetItemState( row, 0, wxLIST_STATE_SELECTED );
158 bool handled =
false;
160 switch( aEvent.GetKeyCode() )
165 for(
int row = 0; row < GetItemCount(); row++ )
166 SetItemState( row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
181 case WXK_NUMPAD_DOWN:
184 long focused = GetFocusedItem();
188 if( focused < GetItemCount() - 1 )
190 if( !(aEvent.GetModifiers() & wxMOD_SHIFT) )
194 while( (
next = GetNextSelected(
next ) ) != wxNOT_FOUND )
195 Select(
next,
false );
210 long focused = GetFocusedItem();
217 if( !(aEvent.GetModifiers() & wxMOD_SHIFT) )
221 while( (
next = GetNextSelected(
next ) ) != wxNOT_FOUND )
222 Select(
next,
false );
243 menu.Append( wxID_COPY,
_(
"Copy" ) );
256 if( !wxTheClipboard->Open() )
261 for(
int row = 0; row < GetItemCount(); row++ )
263 if( GetItemState( row, wxLIST_STATE_SELECTED ) != wxLIST_STATE_SELECTED )
266 bool firstCol =
true;
268 for(
int col = 0; col < GetColumnCount(); col++ )
270 if( GetColumnWidth( col ) <= 0 )
276 txt += GetItemText( row, col );
283 wxTheClipboard->SetData(
new wxTextDataObject( txt ) );
284 wxTheClipboard->Close();
290 std::vector<long> selection;
301 wxWindowUpdateLocker updateLock(
this );
305 std::vector<std::tuple<wxString, int, wxListColumnFormat>> columns =
m_handler->GetColumns();
307 for(
auto& [ columnName, colProportion, colAlign ] : columns )
308 AppendColumn( wxGetTranslation( columnName ), colAlign );
310 int widthUnit = GetClientSize().GetWidth() / 10;
312 for(
int ii = 0; ii < (int) columns.size(); ++ii )
313 SetColumnWidth( ii, widthUnit * std::get<1>( columns[ ii ] ) );
319 return m_handler->GetResultCell( (
int) item, (
int) column );
324 const wxPoint& aLocation,
const wxSize& aSize ) :
325 wxPanel( parent, aId, aLocation, aSize ),
328 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
331 sizer->Add(
m_listView, 5, wxRIGHT | wxBOTTOM | wxEXPAND, 1 );
342 int results =
m_handler->Search( query );
void OnItemDeselected(wxListEvent &aEvent)
void GetSelectRowsList(std::vector< long > &aSelectedList)
void OnColClicked(wxListEvent &aEvent)
void OnChar(wxKeyEvent &aEvent)
SEARCH_PANE_LISTVIEW(const std::shared_ptr< SEARCH_HANDLER > &aHandler, wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
void OnCopyMenu(wxCommandEvent &aEvent)
void OnContextMenu(wxContextMenuEvent &aEvent)
std::shared_ptr< SEARCH_HANDLER > m_handler
void OnItemSelected(wxListEvent &aEvent)
void OnItemActivated(wxListEvent &aEvent)
void CopySelectionToClipboard()
virtual ~SEARCH_PANE_LISTVIEW()
std::vector< long > Sort()
void OnUpdateUI(wxUpdateUIEvent &aEvent)
wxString OnGetItemText(long item, long column) const override
void RefreshColumnNames()
std::shared_ptr< SEARCH_HANDLER > m_handler
void Search(wxString &query)
SEARCH_PANE_TAB(const std::shared_ptr< SEARCH_HANDLER > &aHandler, wxWindow *parent, wxWindowID aId=wxID_ANY, const wxPoint &aLocation=wxDefaultPosition, const wxSize &aSize=wxDefaultSize)
SEARCH_PANE_LISTVIEW * m_listView
void RefreshColumnNames()
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...