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:
parent
af665c2d7e
commit
86ba79ed17
@ -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;
|
||||
|
@ -1820,7 +1820,7 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||
}
|
||||
else
|
||||
{
|
||||
dataitem = wxDataViewItem( wxUIntToPtr(item) );
|
||||
dataitem = wxDataViewItem( wxUIntToPtr(item+1) );
|
||||
}
|
||||
|
||||
model->GetValue( value, dataitem, col->GetModelColumn());
|
||||
@ -2028,7 +2028,7 @@ bool Walker( wxDataViewTreeNode * node, DoJob & func )
|
||||
|
||||
bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxDataViewItem & item)
|
||||
{
|
||||
if (!m_root)
|
||||
if (IsVirtualList())
|
||||
{
|
||||
m_count++;
|
||||
UpdateDisplay();
|
||||
@ -2066,14 +2066,15 @@ bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxData
|
||||
static void DestroyTreeHelper( wxDataViewTreeNode * node);
|
||||
|
||||
bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent,
|
||||
const wxDataViewItem& item)
|
||||
const wxDataViewItem& item)
|
||||
{
|
||||
if (!m_root)
|
||||
if (IsVirtualList())
|
||||
{
|
||||
m_count--;
|
||||
if( m_currentRow > GetRowCount() )
|
||||
m_currentRow = m_count - 1;
|
||||
|
||||
// TODO: why empty the entire selection?
|
||||
m_selection.Empty();
|
||||
|
||||
UpdateDisplay();
|
||||
@ -2777,15 +2778,17 @@ private:
|
||||
|
||||
wxDataViewItem wxDataViewMainWindow::GetItemByRow(unsigned int row) const
|
||||
{
|
||||
if (!m_root)
|
||||
if (IsVirtualList())
|
||||
{
|
||||
return wxDataViewItem( wxUIntToPtr(row) );
|
||||
return wxDataViewItem( wxUIntToPtr(row+1) );
|
||||
}
|
||||
else
|
||||
{
|
||||
RowToItemJob job( row, -2 );
|
||||
Walker( m_root , job );
|
||||
return job.GetResult();
|
||||
wxDataViewItem res = job.GetResult();
|
||||
// wxPrintf( "row %d, item %d\n", row, (int) res.GetID() );
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3199,7 +3202,7 @@ wxRect wxDataViewMainWindow::GetItemRect( const wxDataViewItem & item,
|
||||
|
||||
int wxDataViewMainWindow::RecalculateCount()
|
||||
{
|
||||
if (!m_root)
|
||||
if (IsVirtualList())
|
||||
{
|
||||
wxDataViewIndexListModel *list_model =
|
||||
(wxDataViewIndexListModel*) GetOwner()->GetModel();
|
||||
@ -3272,9 +3275,9 @@ int wxDataViewMainWindow::GetRowByItem(const wxDataViewItem & item) const
|
||||
if( model == NULL )
|
||||
return -1;
|
||||
|
||||
if (!m_root)
|
||||
if (IsVirtualList())
|
||||
{
|
||||
return wxPtrToUInt( item.GetID() );
|
||||
return wxPtrToUInt( item.GetID() ) -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user