No changes, just refactor common IsSorted() tests in wxGTK wxDataViewCtrl.

Add wxDataViewCtrlInternal::ShouldBeSorted() helper instead of testing for
both IsSorted() and wxDataViewModel::HasDefaultCompare() in several places.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71327 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-04-29 23:22:34 +00:00
parent 87cf085e96
commit f330dce9b7

View File

@@ -270,6 +270,14 @@ public:
bool IsSorted() const { return m_sort_column >= 0; } bool IsSorted() const { return m_sort_column >= 0; }
// Should we be sorted either because we have a configured sort column or
// because we have a default sort order?
bool ShouldBeSorted() const
{
return IsSorted() || GetDataViewModel()->HasDefaultCompare();
}
// accessors // accessors
wxDataViewModel* GetDataViewModel() { return m_wx_model; } wxDataViewModel* GetDataViewModel() { return m_wx_model; }
const wxDataViewModel* GetDataViewModel() const { return m_wx_model; } const wxDataViewModel* GetDataViewModel() const { return m_wx_model; }
@@ -360,7 +368,7 @@ public:
m_children.Add( id ); m_children.Add( id );
if (m_internal->IsSorted() || m_internal->GetDataViewModel()->HasDefaultCompare()) if (m_internal->ShouldBeSorted())
{ {
gs_internal = m_internal; gs_internal = m_internal;
m_children.Sort( &wxGtkTreeModelChildCmp ); m_children.Sort( &wxGtkTreeModelChildCmp );
@@ -369,7 +377,7 @@ public:
void InsertNode( wxGtkTreeModelNode* child, unsigned pos ) void InsertNode( wxGtkTreeModelNode* child, unsigned pos )
{ {
if (m_internal->IsSorted() || m_internal->GetDataViewModel()->HasDefaultCompare()) if (m_internal->ShouldBeSorted())
{ {
AddNode(child); AddNode(child);
return; return;
@@ -407,7 +415,7 @@ public:
{ {
m_children.Insert( id, pos ); m_children.Insert( id, pos );
if (m_internal->IsSorted() || m_internal->GetDataViewModel()->HasDefaultCompare()) if (m_internal->ShouldBeSorted())
{ {
gs_internal = m_internal; gs_internal = m_internal;
m_children.Sort( &wxGtkTreeModelChildCmp ); m_children.Sort( &wxGtkTreeModelChildCmp );