22#include <wx/dataview.h>
23#include <wx/filename.h>
46 static const std::vector<FILE_CHECKLIST_ENTRY>
empty;
59 if( row.path == aPath )
61 row.checked = aChecked;
100 std::vector<wxString> paths;
107 paths.push_back( row.path );
124 std::vector<std::unique_ptr<CHECKLIST_NODE>>
children;
139 void SetEntries(
const std::vector<FILE_CHECKLIST_ENTRY>& aEntries )
141 m_data.SetEntries( aEntries );
149 for(
const std::unique_ptr<CHECKLIST_NODE>& section :
m_sectionNodes )
150 m_data.SetSectionChecked( section->section, aChecked );
152 for(
const std::unique_ptr<CHECKLIST_NODE>& section :
m_sectionNodes )
154 for(
const std::unique_ptr<CHECKLIST_NODE>& child : section->children )
155 ValueChanged( wxDataViewItem( child.get() ),
COL_CHECK );
157 ValueChanged( wxDataViewItem( section.get() ),
COL_CHECK );
163 wxString
PathFor(
const wxDataViewItem& aItem )
const
168 return wxEmptyString;
180 case COL_NAME:
return wxT(
"wxDataViewIconText" );
181 default:
return wxT(
"string" );
185 void GetValue( wxVariant& aVariant,
const wxDataViewItem& aItem,
unsigned int aCol )
const override
198 aVariant << wxDataViewIconText(
201 default: aVariant = wxString();
break;
212 default: aVariant = row.
status;
break;
217 bool GetAttr(
const wxDataViewItem& aItem,
unsigned int aCol, wxDataViewItemAttr& aAttr )
const override
233 bool SetValue(
const wxVariant& aVariant,
const wxDataViewItem& aItem,
unsigned int aCol )
override
240 bool checked = aVariant.GetBool();
246 for(
const std::unique_ptr<CHECKLIST_NODE>& child : node->
children )
247 ValueChanged( wxDataViewItem( child.get() ),
COL_CHECK );
260 wxDataViewItem
GetParent(
const wxDataViewItem& aItem )
const override
263 return ( node && node->
parent ) ? wxDataViewItem( node->
parent ) : wxDataViewItem();
277 unsigned int GetChildren(
const wxDataViewItem& aItem, wxDataViewItemArray& aChildren )
const override
281 for(
const std::unique_ptr<CHECKLIST_NODE>& section :
m_sectionNodes )
282 aChildren.Add( wxDataViewItem( section.get() ) );
284 return aChildren.GetCount();
291 for(
const std::unique_ptr<CHECKLIST_NODE>& child : node->
children )
292 aChildren.Add( wxDataViewItem( child.get() ) );
295 return aChildren.GetCount();
308 for(
const wxString& section :
m_data.Sections() )
310 auto sectionNode = std::make_unique<CHECKLIST_NODE>();
311 sectionNode->isSection =
true;
312 sectionNode->section = section;
314 for(
size_t i = 0; i <
m_data.Rows( section ).size(); ++i )
316 auto fileNode = std::make_unique<CHECKLIST_NODE>();
317 fileNode->section = section;
319 fileNode->parent = sectionNode.get();
320 sectionNode->children.push_back( std::move( fileNode ) );
333 WX_DATAVIEWCTRL( aParent, aId, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES ),
339 wxCOL_WIDTH_AUTOSIZE );
351 wxDataViewCtrl::DoSetToolTipText( aTip );
362 wxPoint screenPos = wxGetMousePosition();
364 if( IsShownOnScreen() && GetScreenRect().Contains( screenPos ) )
367 wxDataViewColumn* column =
nullptr;
369 HitTest( ScreenToClient( screenPos ), item, column );
373 if( !
path.IsEmpty() &&
path != wxFileName(
path ).GetFullName() )
381 wxDataViewCtrl::DoSetToolTipText( tip );
394 m_model->SetEntries( aEntries );
401 m_model->SetAllChecked( aChecked );
407 return m_model->CheckedPaths();
413 return m_model->PathFor( aItem );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
FILE_CHECKLIST_CTRL(wxWindow *aParent, wxWindowID aId=wxID_ANY)
void SetAllChecked(bool aChecked)
std::vector< wxString > GetCheckedPaths() const
~FILE_CHECKLIST_CTRL() override
wxString m_ownerTooltip
What the owner set, shown when no row has more to say.
wxString GetItemPath(const wxDataViewItem &aItem) const
Path of the file row for aItem, or empty for a section header or invalid item.
void onIdle(wxIdleEvent &aEvent)
wxDataViewCtrl sends no mouse moves, so the hovered row is read on idle.
wxString m_shownTooltip
What is on screen, so an unchanged hover is left alone.
void DoSetToolTipText(const wxString &aTip) override
WX_DATAVIEWCTRL drops tooltips for every data view it is the base of.
wxObjectDataPtr< FILE_CHECKLIST_MODEL > m_model
void SetEntries(const std::vector< FILE_CHECKLIST_ENTRY > &aEntries)
The rows and tick states behind FILE_CHECKLIST_CTRL.
std::vector< wxString > CheckedPaths() const
Paths of every ticked row, in the order they were added.
std::vector< wxString > m_sections
void SetEntries(const std::vector< FILE_CHECKLIST_ENTRY > &aEntries)
void SetSectionChecked(const wxString &aSection, bool aChecked)
std::map< wxString, std::vector< FILE_CHECKLIST_ENTRY > > m_rowsBySection
void SetChecked(const wxString &aPath, bool aChecked)
bool IsSectionChecked(const wxString &aSection) const
True when the section has rows and every one of them is ticked.
const std::vector< FILE_CHECKLIST_ENTRY > & Rows(const wxString &aSection) const
Rows under a section, in the order they were added. Empty for an unknown section.
bool IsContainer(const wxDataViewItem &aItem) const override
wxDataViewItem GetParent(const wxDataViewItem &aItem) const override
wxString PathFor(const wxDataViewItem &aItem) const
bool SetValue(const wxVariant &aVariant, const wxDataViewItem &aItem, unsigned int aCol) override
wxString GetColumnType(unsigned int aCol) const override
FILE_CHECKLIST_DATA m_data
std::vector< std::unique_ptr< CHECKLIST_NODE > > m_sectionNodes
std::vector< wxString > CheckedPaths() const
bool GetAttr(const wxDataViewItem &aItem, unsigned int aCol, wxDataViewItemAttr &aAttr) const override
void SetAllChecked(bool aChecked)
void SetEntries(const std::vector< FILE_CHECKLIST_ENTRY > &aEntries)
CHECKLIST_NODE * toNode(const wxDataViewItem &aItem) const
bool HasContainerColumns(const wxDataViewItem &aItem) const override
unsigned int GetChildren(const wxDataViewItem &aItem, wxDataViewItemArray &aChildren) const override
void GetValue(wxVariant &aVariant, const wxDataViewItem &aItem, unsigned int aCol) const override
unsigned int GetColumnCount() const override
Extension of the wxDataViewCtrl to include some helper functions for working with items.
bool AssociateModel(wxDataViewModel *aModel) override
Install a WX_ENSURE_VISIBLE_CANCELLER on aModel so deferred scrolls are dropped automatically when it...
static bool empty(const wxTextEntryBase *aCtrl)
std::vector< std::unique_ptr< CHECKLIST_NODE > > children
One file row in a FILE_CHECKLIST_CTRL.
wxString label
Shown in place of the path.
wxColour statusColour
Text colour for the status, or the default when not set.
wxString status
Free text, e.g. "Modified".