Merge branch 'dvc-compare-values'

Fix comparing items with checkboxes in wxTreeListCtrl and make it
simpler to correctly implement item comparison in other
wxDataViewCtrl-derived classes.

See https://github.com/wxWidgets/wxWidgets/pull/558
This commit is contained in:
Vadim Zeitlin
2017-10-21 19:59:12 +02:00
4 changed files with 67 additions and 2 deletions

View File

@@ -386,6 +386,10 @@ public:
unsigned col,
bool ascending) const wxOVERRIDE;
protected:
virtual int DoCompareValues(const wxVariant& value1,
const wxVariant& value2) const wxOVERRIDE;
private:
// The control we're associated with.
wxTreeListCtrl* const m_treelist;
@@ -778,6 +782,22 @@ wxTreeListModel::Compare(const wxDataViewItem& item1,
return result;
}
int wxTreeListModel::DoCompareValues(const wxVariant& value1,
const wxVariant& value2) const
{
if ( value1.GetType() == wxS("wxDataViewCheckIconText") )
{
wxDataViewCheckIconText iconText1, iconText2;
iconText1 << value1;
iconText2 << value2;
return iconText1.GetText().Cmp(iconText2.GetText());
}
return wxDataViewModel::DoCompareValues(value1, value2);
}
// ============================================================================
// wxTreeListCtrl implementation
// ============================================================================