+ m_child->RemoveNotifier( m_notifierOnChild );
+}
+
+void wxDataViewSortedListModel::Resort()
+{
+ m_array.Clear();
+ size_t n = m_child->GetNumberOfRows();
+ size_t i;
+ for (i = 0; i < n; i++)
+ m_array.Add( i );
+}
+
+#if 0
+static void Dump( wxDataViewListModel *model, size_t col )
+{
+ size_t n = model->GetNumberOfRows();
+ size_t 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::ChildValueChanged( size_t col, size_t row )
+{
+ size_t i;
+ size_t len = m_array.GetCount();
+
+ // Remove and readd sorted. Find out at which
+ // position it was and where it ended.
+ size_t start_pos = 0,end_pos = 0;
+ for (i = 0; i < len; i++)
+ if (m_array[i] == row)
+ {
+ start_pos = i;
+ break;
+ }
+ m_array.RemoveAt( start_pos );
+ m_array.Add( row );
+
+ for (i = 0; i < len; i++)
+ if (m_array[i] == row)
+ {
+ end_pos = i;
+ break;
+ }
+
+ if (end_pos == start_pos)
+ return wxDataViewListModel::ValueChanged( col, start_pos );
+
+ // Create an array where order[old] -> new_pos, so that
+ // if nothing changed order[0] -> 0 etc.
+ size_t *order = new size_t[ len ];
+ // Fill up initial values.
+ for (i = 0; i < len; i++)
+ order[i] = i;
+
+ if (start_pos < end_pos)
+ {
+ for (i = start_pos; i < end_pos; i++)
+ order[i] = order[i+1];
+ order[end_pos] = start_pos;
+ }
+ else
+ {
+ for (i = end_pos; i > start_pos; i--)
+ order[i] = order[i-1];
+ order[start_pos] = end_pos;
+ }
+
+ wxDataViewListModel::RowsReordered( order );
+
+ delete [] order;
+
+ return true;