In virtual list mode, map first row to 1, not to 0 as this is reserved for an invalid item

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60996 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2009-06-11 15:10:52 +00:00
parent af665c2d7e
commit 86ba79ed17
2 changed files with 21 additions and 18 deletions

View File

@@ -517,20 +517,20 @@ void wxDataViewVirtualListModel::RowPrepended()
void wxDataViewVirtualListModel::RowInserted( unsigned int before )
{
m_lastIndex++;
wxDataViewItem item( wxUIntToPtr(before) );
wxDataViewItem item( wxUIntToPtr(before+1) );
ItemAdded( wxDataViewItem(0), item );
}
void wxDataViewVirtualListModel::RowAppended()
{
m_lastIndex++;
wxDataViewItem item( wxUIntToPtr(m_lastIndex) );
wxDataViewItem item( wxUIntToPtr(m_lastIndex+1) );
ItemAdded( wxDataViewItem(0), item );
}
void wxDataViewVirtualListModel::RowDeleted( unsigned int row )
{
wxDataViewItem item( wxUIntToPtr(row) );
wxDataViewItem item( wxUIntToPtr(row+1) );
wxDataViewModel::ItemDeleted( wxDataViewItem(0), item );
m_lastIndex++;
}
@@ -544,7 +544,7 @@ void wxDataViewVirtualListModel::RowsDeleted( const wxArrayInt &rows )
unsigned int i;
for (i = 0; i < sorted.GetCount(); i++)
{
wxDataViewItem item( wxUIntToPtr(sorted[i]) );
wxDataViewItem item( wxUIntToPtr(sorted[i]+1) );
array.Add( item );
}
wxDataViewModel::ItemsDeleted( wxDataViewItem(0), array );
@@ -564,12 +564,12 @@ void wxDataViewVirtualListModel::RowValueChanged( unsigned int row, unsigned int
unsigned int wxDataViewVirtualListModel::GetRow( const wxDataViewItem &item ) const
{
return wxPtrToUInt( item.GetID() );
return wxPtrToUInt( item.GetID() ) -1;
}
wxDataViewItem wxDataViewVirtualListModel::GetItem( unsigned int row ) const
{
return wxDataViewItem( wxUIntToPtr(row) );
return wxDataViewItem( wxUIntToPtr(row+1) );
}
bool wxDataViewVirtualListModel::HasDefaultCompare() const
@@ -582,8 +582,8 @@ int wxDataViewVirtualListModel::Compare(const wxDataViewItem& item1,
unsigned int WXUNUSED(column),
bool ascending) const
{
unsigned int pos1 = wxPtrToUInt(item1.GetID());
unsigned int pos2 = wxPtrToUInt(item2.GetID());
unsigned int pos1 = wxPtrToUInt(item1.GetID())-1;
unsigned int pos2 = wxPtrToUInt(item2.GetID())-1;
if (ascending)
return pos1 - pos2;