X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/526954c5968baa29218c994ec48e476ae2bd4b9f..65fb4b3a4f18e1d8b58ac92d50d4cc7f81f03783:/samples/dataview/mymodels.cpp diff --git a/samples/dataview/mymodels.cpp b/samples/dataview/mymodels.cpp index ec5be5516e..a3cb111198 100644 --- a/samples/dataview/mymodels.cpp +++ b/samples/dataview/mymodels.cpp @@ -244,6 +244,17 @@ bool MyMusicTreeModel::SetValue( const wxVariant &variant, return false; } +bool MyMusicTreeModel::IsEnabled( const wxDataViewItem &item, + unsigned int col ) const +{ + wxASSERT(item.IsOk()); + + MyMusicTreeModelNode *node = (MyMusicTreeModelNode*) item.GetID(); + + // disable Beethoven's ratings, his pieces can only be good + return !(col == 3 && node->m_artist.EndsWith("Beethoven")); +} + wxDataViewItem MyMusicTreeModel::GetParent( const wxDataViewItem &item ) const { // the invisible root node has no parent @@ -317,13 +328,11 @@ static int my_sort( int *v1, int *v2 ) return *v1-*v2; } -#define INITIAL_NUMBER_OF_ITEMS 100000 +#define INITIAL_NUMBER_OF_ITEMS 10000 MyListModel::MyListModel() : wxDataViewVirtualListModel( INITIAL_NUMBER_OF_ITEMS ) { - m_virtualItems = INITIAL_NUMBER_OF_ITEMS; - // the first 100 items are really stored in this model; // all the others are synthesized on request static const unsigned NUMBER_REAL_ITEMS = 100; @@ -350,6 +359,7 @@ void MyListModel::Prepend( const wxString &text ) void MyListModel::DeleteItem( const wxDataViewItem &item ) { unsigned int row = GetRow( item ); + if (row >= m_textColValues.GetCount()) return; @@ -392,8 +402,7 @@ void MyListModel::DeleteItems( const wxDataViewItemArray &items ) void MyListModel::AddMany() { - m_virtualItems += 1000; - Reset( m_textColValues.GetCount() + m_virtualItems ); + Reset( GetCount()+1000 ); } void MyListModel::GetValueByRow( wxVariant &variant, @@ -527,3 +536,14 @@ bool MyListModel::SetValueByRow( const wxVariant &variant, return false; } + + +// ---------------------------------------------------------------------------- +// MyListStoreDerivedModel +// ---------------------------------------------------------------------------- + +bool MyListStoreDerivedModel::IsEnabledByRow(unsigned int row, unsigned int col) const +{ + // disabled the last two checkboxes + return !(col == 0 && 8 <= row && row <= 9); +}