+ unsigned int i;
+ unsigned int len = m_array.GetCount();
+
+ // Remove and readd sorted. Find out at which
+ // position it was and where it ended.
+ unsigned int 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::RowChanged( start_pos );
+
+ // Create an array where order[old] -> new_pos, so that
+ // if nothing changed order[0] -> 0 etc.
+ unsigned int *order = new unsigned int[ 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;
+}
+
+bool wxDataViewSortedListModel::ChildValueChanged( unsigned int col, unsigned int row )
+{
+ unsigned int i;
+ unsigned int len = m_array.GetCount();
+
+ // Remove and readd sorted. Find out at which
+ // position it was and where it ended.
+ unsigned int 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.
+ unsigned int *order = new unsigned int[ 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;
+}
+
+bool wxDataViewSortedListModel::ChildRowsReordered( unsigned int *WXUNUSED(new_order) )
+{
+ // Nothing needs to be done. If the sort criteria
+ // of this list don't change, the order of the
+ // items of the child list isn't relevant.
+ return true;
+}
+
+bool wxDataViewSortedListModel::ChildCleared()
+{
+ return wxDataViewListModel::Cleared();
+}
+
+unsigned int wxDataViewSortedListModel::GetRowCount() const
+{
+ if (!m_child) return 0;
+
+ return m_child->GetRowCount();
+}
+
+unsigned int wxDataViewSortedListModel::GetColumnCount() const
+{
+ if (!m_child) return 0;
+
+ return m_child->GetColumnCount();
+}
+
+wxString wxDataViewSortedListModel::GetColumnType( unsigned int col ) const
+{
+ return m_child->GetColumnType( col );
+}
+
+void wxDataViewSortedListModel::GetValue( wxVariant &variant, unsigned int col, unsigned int row ) const
+{
+ unsigned int child_row = m_array[row];
+ m_child->GetValue( variant, col, child_row );
+}
+
+bool wxDataViewSortedListModel::SetValue( const wxVariant &variant, unsigned int col, unsigned int row )
+{
+ unsigned int child_row = m_array[row];