25#include <wx/clipbrd.h>
29 wxWindowID winid,
const wxPoint& pos,
30 const wxSize& size ) :
31 wxListView( parent, winid, pos, size, wxLC_REPORT | wxLC_VIRTUAL ),
34 m_sortAscending( true ),
35 m_selectionDirty( false )
65 long idx = GetFirstSelected();
70 aSelectedList.emplace_back( idx );
72 idx = GetNextSelected( idx );
76 aSelectedList.emplace_back( idx );
77 idx = GetNextSelected( idx );
84 long item = aEvent.GetIndex();
117 std::vector<long> list;
138 std::vector<long> selection =
Sort();
140 for(
long row = 0; row < GetItemCount(); row++ )
143 SetItemState( row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
145 SetItemState( row, 0, wxLIST_STATE_SELECTED );
154 if( aEvent.GetKeyCode() == WXK_CONTROL_A )
157 for(
int row = 0; row < GetItemCount(); row++ )
158 SetItemState( row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
160 else if( aEvent.GetKeyCode() == WXK_CONTROL_C )
163 if( wxTheClipboard->Open() )
167 for(
int row = 0; row < GetItemCount(); row++ )
169 if( GetItemState( row, wxLIST_STATE_SELECTED ) == wxLIST_STATE_SELECTED )
171 for(
int col = 0; col < GetColumnCount(); col++ )
173 if( GetColumnWidth( col ) > 0 )
175 txt += GetItemText( row, col );
177 if( row <= GetItemCount() - 1 )
186 wxTheClipboard->SetData(
new wxTextDataObject( txt ) );
187 wxTheClipboard->Close();
195 std::vector<long> selection;
209 std::vector<std::tuple<wxString, int, wxListColumnFormat>> columns =
m_handler->
GetColumns();
211 for(
auto& [ columnName, colProportion, colAlign ] : columns )
212 AppendColumn( wxGetTranslation( columnName ), colAlign );
214 int widthUnit = GetClientSize().GetWidth() / 10;
216 for(
int ii = 0; ii < (int) columns.size(); ++ii )
217 SetColumnWidth( ii, widthUnit * std::get<1>( columns[ ii ] ) );
230 const wxPoint& aLocation,
const wxSize& aSize ) :
231 wxPanel( parent, aId, aLocation, aSize ),
234 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
237 sizer->Add(
m_listView, 5, wxRIGHT | wxBOTTOM | wxEXPAND, 1 );
std::vector< std::tuple< wxString, int, wxListColumnFormat > > GetColumns() const
virtual wxString GetResultCell(int row, int col)=0
virtual void Sort(int aCol, bool aAscending, std::vector< long > *aSelection)=0
virtual void SelectItems(std::vector< long > &aItemRows)
virtual void ActivateItem(long aItemRow)
virtual int Search(const wxString &string)=0
void OnItemDeselected(wxListEvent &aEvent)
SEARCH_PANE_LISTVIEW(SEARCH_HANDLER *handler, wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
void GetSelectRowsList(std::vector< long > &aSelectedList)
void OnColClicked(wxListEvent &aEvent)
void OnChar(wxKeyEvent &aEvent)
void OnItemSelected(wxListEvent &aEvent)
SEARCH_HANDLER * m_handler
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()
SEARCH_HANDLER * m_handler
void Search(wxString &query)
SEARCH_PANE_LISTVIEW * m_listView
void RefreshColumnNames()
SEARCH_PANE_TAB(SEARCH_HANDLER *handler, wxWindow *parent, wxWindowID aId=wxID_ANY, const wxPoint &aLocation=wxDefaultPosition, const wxSize &aSize=wxDefaultSize)
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...