-wxDataViewSortedListModel::wxDataViewSortedListModel( wxDataViewListModel *child ) :
- m_array( wxDataViewIntermediateCmp )
-{
- m_child = child;
-
- m_ascending = true;
-
- m_notifierOnChild = new wxDataViewSortedListModelNotifier( this );
- m_child->AddNotifier( m_notifierOnChild );
-
- Resort();
-}
-
-wxDataViewSortedListModel::~wxDataViewSortedListModel()
-{
- if (m_child)
- m_child->RemoveNotifier( m_notifierOnChild );
-}
-
-// FIXME
-void wxDataViewSortedListModel::InitStatics()
-{
- s_CmpCol = 0;
- s_CmpModel = m_child;
- if (m_ascending)
- s_CmpFunc = wxDataViewListModelSortedDefaultCompare;
- else
- s_CmpFunc = wxDataViewListModelSortedDefaultCompareDescending;
-}
-
-void wxDataViewSortedListModel::Resort()
-{
- InitStatics();
-
- m_array.Clear();
- unsigned int n = m_child->GetRowCount();
- unsigned int i;
- for (i = 0; i < n; i++)
- m_array.Add( i );
-}
-
-#if 0
-static void Dump( wxDataViewListModel *model, unsigned int col )
-{
- unsigned int n = model->GetRowCount();
- unsigned int i;
- for (i = 0; i < n; i++)
- {
- wxVariant variant;
- model->GetValue( variant, col, i );
- wxString tmp;
- tmp = variant.GetString();
- wxPrintf( wxT("%d: %s\n"), (int) i, tmp.c_str() );
- }
-}
-#endif
-
-bool wxDataViewSortedListModel::ChildRowAppended()
-{
- // no need to fix up array
-
- unsigned int len = m_array.GetCount();
-
- unsigned int pos = m_array.Add( len );
-
- if (pos == 0)
- return wxDataViewListModel::RowPrepended();
-
- if (pos == len)
- return wxDataViewListModel::RowAppended();
-
- return wxDataViewListModel::RowInserted( pos );
-}
-
-bool wxDataViewSortedListModel::ChildRowPrepended()
-{
- // fix up array
- unsigned int i;
- unsigned int len = m_array.GetCount();
- for (i = 0; i < len; i++)
- {
- unsigned int value = m_array[i];
- m_array[i] = value+1;
- }
-
- unsigned int pos = m_array.Add( 0 );
-
- if (pos == 0)
- return wxDataViewListModel::RowPrepended();
-
- if (pos == len)
- return wxDataViewListModel::RowAppended();
-
- return wxDataViewListModel::RowInserted( pos );
-}
-
-bool wxDataViewSortedListModel::ChildRowInserted( unsigned int before )
-{
- // fix up array
- unsigned int i;
- unsigned int len = m_array.GetCount();
- for (i = 0; i < len; i++)
- {
- unsigned int value = m_array[i];
- if (value >= before)
- m_array[i] = value+1;
- }
-
- unsigned int pos = m_array.Add( before );
-
- if (pos == 0)
- return wxDataViewListModel::RowPrepended();
-
- if (pos == len)
- return wxDataViewListModel::RowAppended();
-
- return wxDataViewListModel::RowInserted( pos );
-}
-
-bool wxDataViewSortedListModel::ChildRowDeleted( unsigned int row )