24#include <wx/clipbrd.h>
25#include <wx/wupdlock.h>
29 wxWindowID winid,
const wxPoint& pos,
const wxSize& size ) :
30 wxListView( parent, winid, pos, size, wxLC_REPORT | wxLC_VIRTUAL ),
31 m_handler( aHandler ),
33 m_sortAscending( true ),
34 m_selectionDirty( false )
64 long idx = GetFirstSelected();
69 aSelectedList.emplace_back( idx );
71 idx = GetNextSelected( idx );
75 aSelectedList.emplace_back( idx );
76 idx = GetNextSelected( idx );
83 long item = aEvent.GetIndex();
116 std::vector<long> list;
137 std::vector<long> selection =
Sort();
139 for(
long row = 0; row < GetItemCount(); row++ )
142 SetItemState( row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
144 SetItemState( row, 0, wxLIST_STATE_SELECTED );
153 bool handled =
false;
155 switch( aEvent.GetKeyCode() )
160 for(
int row = 0; row < GetItemCount(); row++ )
161 SetItemState( row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
170 if( wxTheClipboard->Open() )
174 for(
int row = 0; row < GetItemCount(); row++ )
176 if( GetItemState( row, wxLIST_STATE_SELECTED ) == wxLIST_STATE_SELECTED )
178 for(
int col = 0; col < GetColumnCount(); col++ )
180 if( GetColumnWidth( col ) > 0 )
182 txt += GetItemText( row, col );
184 if( row <= GetItemCount() - 1 )
193 wxTheClipboard->SetData(
new wxTextDataObject( txt ) );
194 wxTheClipboard->Close();
202 case WXK_NUMPAD_DOWN:
205 long focused = GetFocusedItem();
209 if( focused < GetItemCount() - 1 )
211 if( !(aEvent.GetModifiers() & wxMOD_SHIFT) )
215 while( (
next = GetNextSelected(
next ) ) != wxNOT_FOUND )
216 Select(
next,
false );
231 long focused = GetFocusedItem();
238 if( !(aEvent.GetModifiers() & wxMOD_SHIFT) )
242 while( (
next = GetNextSelected(
next ) ) != wxNOT_FOUND )
243 Select(
next,
false );
263 std::vector<long> selection;
274 wxWindowUpdateLocker updateLock(
this );
278 std::vector<std::tuple<wxString, int, wxListColumnFormat>> columns =
m_handler->GetColumns();
280 for(
auto& [ columnName, colProportion, colAlign ] : columns )
281 AppendColumn( wxGetTranslation( columnName ), colAlign );
283 int widthUnit = GetClientSize().GetWidth() / 10;
285 for(
int ii = 0; ii < (int) columns.size(); ++ii )
286 SetColumnWidth( ii, widthUnit * std::get<1>( columns[ ii ] ) );
292 return m_handler->GetResultCell( (
int) item, (
int) column );
297 const wxPoint& aLocation,
const wxSize& aSize ) :
298 wxPanel( parent, aId, aLocation, aSize ),
299 m_handler( aHandler )
301 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
304 sizer->Add(
m_listView, 5, wxRIGHT | wxBOTTOM | wxEXPAND, 1 );
315 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)
std::shared_ptr< SEARCH_HANDLER > m_handler
void OnItemSelected(wxListEvent &aEvent)
void OnItemActivated(wxListEvent &aEvent)
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...