Added wxDataViewListIndexModel::Reset(), clarified and corrected wxDataViewModel::Cleared(), corrected sample

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50768 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2007-12-17 13:56:28 +00:00
parent 8b6cf9bf10
commit 33ba5a0562
9 changed files with 114 additions and 28 deletions

View File

@@ -369,16 +369,22 @@ class MyListModel: public wxDataViewIndexListModel
public:
MyListModel() :
#ifdef __WXMAC__
wxDataViewIndexListModel( 1000 )
wxDataViewIndexListModel( 1000 + 100 )
#else
wxDataViewIndexListModel( 100000 )
wxDataViewIndexListModel( 100000 + 100 )
#endif
{
#ifdef __WXMAC__
m_virtualItems = 1000;
#else
m_virtualItems = 100000;
#endif
unsigned int i;
for (i = 0; i < 100; i++)
{
wxString str;
str.Printf( "row number %d", i );
str.Printf( "Test %d", i );
m_array.Add( str );
}
@@ -396,6 +402,9 @@ public:
void DeleteItem( const wxDataViewItem &item )
{
unsigned int row = GetRow( item );
if (row >= m_array.GetCount())
return;
m_array.RemoveAt( row );
RowDeleted( row );
}
@@ -407,7 +416,8 @@ public:
for (i = 0; i < items.GetCount(); i++)
{
unsigned int row = GetRow( items[i] );
rows.Add( row );
if (row < m_array.GetCount())
rows.Add( row );
}
// Sort in descending order so that the last
@@ -426,6 +436,8 @@ public:
void AddMany()
{
m_virtualItems += 1000;
Reset( m_array.GetCount() + m_virtualItems );
}
// implementation of base class virtuals to define model
@@ -443,11 +455,6 @@ public:
return "string";
}
virtual unsigned int GetRowCount()
{
return m_array.GetCount();
}
virtual void GetValue( wxVariant &variant,
unsigned int row, unsigned int col ) const
{
@@ -456,7 +463,7 @@ public:
if (row >= m_array.GetCount())
{
wxString str;
str.Printf( "row %d", row );
str.Printf( "row %d", row - m_array.GetCount() );
variant = str;
}
else
@@ -471,10 +478,10 @@ public:
} else
if (col==2)
{
if ((row % 2) == 1)
variant = "Blue";
if (row >= m_array.GetCount())
variant = "plain";
else
variant = "Italic";
variant = "blue italic";
}
}
@@ -483,10 +490,11 @@ public:
if (col != 2)
return false;
if ((row % 2) == 1)
if (row < m_array.GetCount())
{
attr.SetColour( *wxBLUE );
else
attr.SetItalic( true );
}
return true;
}
@@ -508,6 +516,7 @@ public:
wxArrayString m_array;
wxIcon m_icon;
int m_virtualItems;
};
// -------------------------------------