+ bool ret = true;
+
+ wxNode *node = m_notifiers.GetFirst();
+ while (node)
+ {
+ wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData();
+ if (!notifier->Cleared())
+ ret = false;
+ node = node->GetNext();
+ }
+
+ return ret;
+}
+
+void wxDataViewListModel::AddViewingColumn( wxDataViewColumn *view_column, size_t model_column )
+{
+ m_viewingColumns.Append( new wxDataViewViewingColumn( view_column, model_column ) );
+}
+
+void wxDataViewListModel::RemoveViewingColumn( wxDataViewColumn *column )
+{
+ wxNode *node = m_viewingColumns.GetFirst();
+ while (node)
+ {
+ wxDataViewViewingColumn* tmp = (wxDataViewViewingColumn*) node->GetData();
+
+ if (tmp->m_viewColumn == column)
+ {
+ m_viewingColumns.DeleteObject( tmp );
+ return;
+ }
+
+ node = node->GetNext();
+ }
+}
+
+void wxDataViewListModel::AddNotifier( wxDataViewListModelNotifier *notifier )
+{
+ m_notifiers.Append( notifier );
+ notifier->SetOwner( this );
+}
+
+void wxDataViewListModel::RemoveNotifier( wxDataViewListModelNotifier *notifier )
+{
+ m_notifiers.DeleteObject( notifier );
+}
+
+// ---------------------------------------------------------
+// wxDataViewSortedListModelNotifier
+// ---------------------------------------------------------
+
+class wxDataViewSortedListModelNotifier: public wxDataViewListModelNotifier
+{
+public:
+ wxDataViewSortedListModelNotifier( wxDataViewSortedListModel *model )
+ { m_model = model; }
+
+ virtual bool RowAppended() { return true; }
+ virtual bool RowPrepended() { return true; }
+ virtual bool RowInserted( size_t WXUNUSED(before) ) { return true; }
+ virtual bool RowDeleted( size_t WXUNUSED(row) ) { return true; }
+ virtual bool RowChanged( size_t WXUNUSED(row) ) { return true; }
+ virtual bool ValueChanged( size_t col, size_t row )
+ { return m_model->ChildValueChanged( col, row); }
+ virtual bool RowsReordered( size_t *WXUNUSED(new_order) ) { return true; }
+ virtual bool Cleared() { return true; }
+
+ wxDataViewSortedListModel *m_model;
+};
+
+// ---------------------------------------------------------
+// wxDataViewSortedListModel compare function
+// ---------------------------------------------------------
+
+int wxCALLBACK wxDataViewListModelSortedDefaultCompare
+ (size_t row1, size_t row2, size_t col, wxDataViewListModel* model )
+{
+ wxVariant value1,value2;
+ model->GetValue( value1, col, row1 );
+ model->GetValue( value2, col, row2 );
+ if (value1.GetType() == wxT("string"))
+ {
+ wxString str1 = value1.GetString();
+ wxString str2 = value2.GetString();
+ return str1.Cmp( str2 );
+ }
+ if (value1.GetType() == wxT("long"))
+ {
+ long l1 = value1.GetLong();
+ long l2 = value2.GetLong();
+ return l1-l2;
+ }
+ if (value1.GetType() == wxT("double"))
+ {
+ double d1 = value1.GetDouble();
+ double d2 = value2.GetDouble();
+ if (d1 == d2) return 0;
+ if (d1 < d2) return 1;
+ return -1;
+ }
+ if (value1.GetType() == wxT("datetime"))
+ {
+ wxDateTime dt1 = value1.GetDateTime();
+ wxDateTime dt2 = value2.GetDateTime();
+ if (dt1.IsEqualTo(dt2)) return 0;
+ if (dt1.IsEarlierThan(dt2)) return 1;
+ return -1;
+ }
+
+ return 0;
+}
+
+static wxDataViewListModelCompare s_CmpFunc;
+static wxDataViewListModel *s_CmpModel;
+static size_t s_CmpCol;
+
+int LINKAGEMODE wxDataViewIntermediateCmp( size_t row1, size_t row2 )
+{
+ return s_CmpFunc( row1, row2, s_CmpCol, s_CmpModel );
+}
+
+// ---------------------------------------------------------
+// wxDataViewSortedListModel
+// ---------------------------------------------------------
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewSortedListModel, wxDataViewListModel)
+
+wxDataViewSortedListModel::wxDataViewSortedListModel( wxDataViewListModel *child ) :
+ m_array( wxDataViewIntermediateCmp )
+{
+ m_child = child;
+ s_CmpCol = 0;
+ s_CmpModel = child;
+ s_CmpFunc = wxDataViewListModelSortedDefaultCompare;
+
+ m_notifierOnChild = new wxDataViewSortedListModelNotifier( this );
+ m_child->AddNotifier( m_notifierOnChild );
+
+ Resort();