git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61078
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// internal
virtual bool IsVirtualListModel() const { return false; }
// internal
virtual bool IsVirtualListModel() const { return false; }
- unsigned int GetLastIndex() const { return m_lastIndex; }
+ unsigned int GetCount() const { return m_hash.GetCount(); }
private:
wxDataViewItemArray m_hash;
private:
wxDataViewItemArray m_hash;
- unsigned int m_lastIndex;
+ unsigned int m_nextFreeID;
// internal
virtual bool IsVirtualListModel() const { return true; }
// internal
virtual bool IsVirtualListModel() const { return true; }
- unsigned int GetLastIndex() const { return m_lastIndex; }
+ unsigned int GetCount() const { return m_size; }
- wxDataViewItemArray m_hash;
- unsigned int m_lastIndex;
bool m_ordered;
};
#endif
bool m_ordered;
};
#endif
unsigned int i;
for (i = 1; i < initial_size+1; i++)
m_hash.Add( wxUIntToPtr(i) );
unsigned int i;
for (i = 1; i < initial_size+1; i++)
m_hash.Add( wxUIntToPtr(i) );
- m_lastIndex = initial_size + 1;
+ m_nextFreeID = initial_size + 1;
}
wxDataViewIndexListModel::~wxDataViewIndexListModel()
}
wxDataViewIndexListModel::~wxDataViewIndexListModel()
unsigned int i;
for (i = 1; i < new_size+1; i++)
m_hash.Add( wxUIntToPtr(i) );
unsigned int i;
for (i = 1; i < new_size+1; i++)
m_hash.Add( wxUIntToPtr(i) );
- m_lastIndex = new_size + 1;
+
+ m_nextFreeID = new_size + 1;
wxDataViewModel::Cleared();
}
wxDataViewModel::Cleared();
}
- unsigned int id = m_lastIndex++;
+ unsigned int id = m_nextFreeID;
+ m_nextFreeID++;
+
m_hash.Insert( wxUIntToPtr(id), 0 );
wxDataViewItem item( wxUIntToPtr(id) );
ItemAdded( wxDataViewItem(0), item );
m_hash.Insert( wxUIntToPtr(id), 0 );
wxDataViewItem item( wxUIntToPtr(id) );
ItemAdded( wxDataViewItem(0), item );
}
void wxDataViewIndexListModel::RowInserted( unsigned int before )
{
m_ordered = false;
}
void wxDataViewIndexListModel::RowInserted( unsigned int before )
{
m_ordered = false;
- unsigned int id = m_lastIndex++;
+ unsigned int id = m_nextFreeID;
+ m_nextFreeID++;
+
m_hash.Insert( wxUIntToPtr(id), before );
wxDataViewItem item( wxUIntToPtr(id) );
ItemAdded( wxDataViewItem(0), item );
m_hash.Insert( wxUIntToPtr(id), before );
wxDataViewItem item( wxUIntToPtr(id) );
ItemAdded( wxDataViewItem(0), item );
void wxDataViewIndexListModel::RowAppended()
{
void wxDataViewIndexListModel::RowAppended()
{
- unsigned int id = m_lastIndex++;
+ unsigned int id = m_nextFreeID;
+ m_nextFreeID++;
+
m_hash.Add( wxUIntToPtr(id) );
wxDataViewItem item( wxUIntToPtr(id) );
ItemAdded( wxDataViewItem(0), item );
m_hash.Add( wxUIntToPtr(id) );
wxDataViewItem item( wxUIntToPtr(id) );
ItemAdded( wxDataViewItem(0), item );
unsigned int wxDataViewIndexListModel::GetRow( const wxDataViewItem &item ) const
{
if (m_ordered)
unsigned int wxDataViewIndexListModel::GetRow( const wxDataViewItem &item ) const
{
if (m_ordered)
- {
- unsigned int pos = wxPtrToUInt( item.GetID() );
- return pos-1;
- }
+ return wxPtrToUInt(item.GetID())-1;
// assert for not found
return (unsigned int) m_hash.Index( item.GetID() );
// assert for not found
return (unsigned int) m_hash.Index( item.GetID() );
- unsigned int pos1 = wxPtrToUInt(item1.GetID());
- unsigned int pos2 = wxPtrToUInt(item2.GetID());
+ unsigned int pos1 = wxPtrToUInt(item1.GetID()); // -1 not needed here
+ unsigned int pos2 = wxPtrToUInt(item2.GetID()); // -1 not needed here
if (ascending)
return pos1 - pos2;
if (ascending)
return pos1 - pos2;
wxDataViewVirtualListModel::wxDataViewVirtualListModel( unsigned int initial_size )
{
wxDataViewVirtualListModel::wxDataViewVirtualListModel( unsigned int initial_size )
{
- m_lastIndex = initial_size-1;
}
wxDataViewVirtualListModel::~wxDataViewVirtualListModel()
}
wxDataViewVirtualListModel::~wxDataViewVirtualListModel()
void wxDataViewVirtualListModel::Reset( unsigned int new_size )
{
void wxDataViewVirtualListModel::Reset( unsigned int new_size )
{
- m_lastIndex = new_size-1;
wxDataViewModel::Cleared();
}
void wxDataViewVirtualListModel::RowPrepended()
{
wxDataViewModel::Cleared();
}
void wxDataViewVirtualListModel::RowPrepended()
{
wxDataViewItem item( wxUIntToPtr(1) );
ItemAdded( wxDataViewItem(0), item );
}
void wxDataViewVirtualListModel::RowInserted( unsigned int before )
{
wxDataViewItem item( wxUIntToPtr(1) );
ItemAdded( wxDataViewItem(0), item );
}
void wxDataViewVirtualListModel::RowInserted( unsigned int before )
{
wxDataViewItem item( wxUIntToPtr(before+1) );
ItemAdded( wxDataViewItem(0), item );
}
void wxDataViewVirtualListModel::RowAppended()
{
wxDataViewItem item( wxUIntToPtr(before+1) );
ItemAdded( wxDataViewItem(0), item );
}
void wxDataViewVirtualListModel::RowAppended()
{
- m_lastIndex++;
- wxDataViewItem item( wxUIntToPtr(m_lastIndex+1) );
+ m_size++;
+ wxDataViewItem item( wxUIntToPtr(m_size) );
ItemAdded( wxDataViewItem(0), item );
}
ItemAdded( wxDataViewItem(0), item );
}
{
wxDataViewItem item( wxUIntToPtr(row+1) );
wxDataViewModel::ItemDeleted( wxDataViewItem(0), item );
{
wxDataViewItem item( wxUIntToPtr(row+1) );
wxDataViewModel::ItemDeleted( wxDataViewItem(0), item );
}
void wxDataViewVirtualListModel::RowsDeleted( const wxArrayInt &rows )
}
void wxDataViewVirtualListModel::RowsDeleted( const wxArrayInt &rows )
}
wxDataViewModel::ItemsDeleted( wxDataViewItem(0), array );
}
wxDataViewModel::ItemsDeleted( wxDataViewItem(0), array );
- m_lastIndex -= rows.GetCount();
+ m_size -= rows.GetCount();
}
void wxDataViewVirtualListModel::RowChanged( unsigned int row )
}
void wxDataViewVirtualListModel::RowChanged( unsigned int row )
unsigned int WXUNUSED(column),
bool ascending) const
{
unsigned int WXUNUSED(column),
bool ascending) const
{
- unsigned int pos1 = wxPtrToUInt(item1.GetID())-1;
- unsigned int pos2 = wxPtrToUInt(item2.GetID())-1;
+ unsigned int pos1 = wxPtrToUInt(item1.GetID()); // -1 not needed here
+ unsigned int pos2 = wxPtrToUInt(item2.GetID()); // -1 not needed here
if (ascending)
return pos1 - pos2;
if (ascending)
return pos1 - pos2;
- wxDataViewIndexListModel *list_model =
- (wxDataViewIndexListModel*) GetOwner()->GetModel();
-#ifndef __WXMAC__
- return list_model->GetLastIndex() + 1;
-#else
- return list_model->GetLastIndex() - 1;
-#endif
+ wxDataViewVirtualListModel *list_model =
+ (wxDataViewVirtualListModel*) GetOwner()->GetModel();
+ return list_model->GetCount();
gboolean wxDataViewCtrlInternal::get_iter( GtkTreeIter *iter, GtkTreePath *path )
{
gboolean wxDataViewCtrlInternal::get_iter( GtkTreeIter *iter, GtkTreePath *path )
{
if (m_wx_model->IsVirtualListModel())
{
if (m_wx_model->IsVirtualListModel())
{
- wxDataViewIndexListModel *wx_model = (wxDataViewIndexListModel*) m_wx_model;
-
+ wxDataViewVirtualListModel *wx_model = (wxDataViewVirtualListModel*) m_wx_model;
+
unsigned int i = (unsigned int)gtk_tree_path_get_indices (path)[0];
unsigned int i = (unsigned int)gtk_tree_path_get_indices (path)[0];
-
- if (i >= wx_model->GetLastIndex() + 1)
+
+ if (i >= wx_model->GetCount())
return FALSE;
iter->stamp = m_gtk_model->stamp;
return FALSE;
iter->stamp = m_gtk_model->stamp;
{
if (m_wx_model->IsVirtualListModel())
{
{
if (m_wx_model->IsVirtualListModel())
{
- wxDataViewIndexListModel *wx_model = (wxDataViewIndexListModel*) m_wx_model;
+ wxDataViewVirtualListModel *wx_model = (wxDataViewVirtualListModel*) m_wx_model;
// user_data is just the index +1
int n = ( (wxUIntPtr) iter->user_data ) -1;
// user_data is just the index +1
int n = ( (wxUIntPtr) iter->user_data ) -1;
if (n == -1)
return FALSE;
if (n == -1)
return FALSE;
- if (n >= (int) wx_model->GetLastIndex())
+ if (n >= (int) wx_model->GetCount())
return FALSE;
// user_data is just the index +1 (+2 because we need the next)
return FALSE;
// user_data is just the index +1 (+2 because we need the next)
return FALSE;
iter->stamp = m_gtk_model->stamp;
return FALSE;
iter->stamp = m_gtk_model->stamp;
- iter->user_data = (gpointer) 0;
+ iter->user_data = (gpointer) 1;
{
if (m_wx_model->IsVirtualListModel())
{
{
if (m_wx_model->IsVirtualListModel())
{
+ wxDataViewVirtualListModel *wx_model = (wxDataViewVirtualListModel*) m_wx_model;
+
+ if (iter == NULL)
+ return (gint) wx_model->GetCount();
+
// this is a list, nodes have no children
return FALSE;
}
// this is a list, nodes have no children
return FALSE;
}
{
if (m_wx_model->IsVirtualListModel())
{
{
if (m_wx_model->IsVirtualListModel())
{
- wxDataViewIndexListModel *wx_model = (wxDataViewIndexListModel*) m_wx_model;
+ wxDataViewVirtualListModel *wx_model = (wxDataViewVirtualListModel*) m_wx_model;
- return (gint) wx_model->GetLastIndex() + 1;
+ return (gint) wx_model->GetCount();
{
if (m_wx_model->IsVirtualListModel())
{
{
if (m_wx_model->IsVirtualListModel())
{
- wxDataViewIndexListModel *wx_model = (wxDataViewIndexListModel*) m_wx_model;
+ wxDataViewVirtualListModel *wx_model = (wxDataViewVirtualListModel*) m_wx_model;
if (parent)
return FALSE;
if (parent)
return FALSE;
- if (n >= (gint) wx_model->GetLastIndex() + 1)
+ if (n >= (gint) wx_model->GetCount())
return FALSE;
iter->stamp = m_gtk_model->stamp;
// user_data is just the index +1
return FALSE;
iter->stamp = m_gtk_model->stamp;
// user_data is just the index +1
- iter->user_data = (gpointer) (n-1);
+ iter->user_data = (gpointer) (n+1);