Added wxDataViewListIndexModel::RowsDeleted() and various related corrections
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50764 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -385,6 +385,8 @@ void wxDataViewIndexListModel::RowDeleted( unsigned int row )
|
||||
{
|
||||
if (m_useHash)
|
||||
{
|
||||
m_ordered = false;
|
||||
|
||||
wxDataViewItem item( m_hash[row] );
|
||||
wxDataViewModel::ItemDeleted( wxDataViewItem(0), item );
|
||||
m_hash.RemoveAt( row );
|
||||
@@ -397,6 +399,47 @@ void wxDataViewIndexListModel::RowDeleted( unsigned int row )
|
||||
}
|
||||
}
|
||||
|
||||
static int my_sort( int *v1, int *v2 )
|
||||
{
|
||||
return *v2-*v1;
|
||||
}
|
||||
|
||||
void wxDataViewIndexListModel::RowsDeleted( const wxArrayInt &rows )
|
||||
{
|
||||
wxArrayInt sorted = rows;
|
||||
sorted.Sort( my_sort );
|
||||
|
||||
if (m_useHash)
|
||||
{
|
||||
m_ordered = false;
|
||||
|
||||
wxDataViewItemArray array;
|
||||
unsigned int i;
|
||||
for (i = 0; i < rows.GetCount(); i++)
|
||||
{
|
||||
wxDataViewItem item( m_hash[rows[i]] );
|
||||
array.Add( item );
|
||||
}
|
||||
wxDataViewModel::ItemsDeleted( wxDataViewItem(0), array );
|
||||
|
||||
for (i = 0; i < sorted.GetCount(); i++)
|
||||
m_hash.RemoveAt( sorted[i] );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxDataViewItemArray array;
|
||||
unsigned int i;
|
||||
for (i = 0; i < sorted.GetCount(); i++)
|
||||
{
|
||||
wxDataViewItem item( (void*) sorted[i] );
|
||||
array.Add( item );
|
||||
}
|
||||
wxDataViewModel::ItemsDeleted( wxDataViewItem(0), array );
|
||||
|
||||
m_lastIndex -= rows.GetCount();
|
||||
}
|
||||
}
|
||||
|
||||
void wxDataViewIndexListModel::RowChanged( unsigned int row )
|
||||
{
|
||||
wxDataViewModel::ItemChanged( GetItem(row) );
|
||||
|
||||
@@ -2048,6 +2048,13 @@ bool Walker( wxDataViewTreeNode * node, DoJob & func )
|
||||
|
||||
bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxDataViewItem & item)
|
||||
{
|
||||
if (!m_root)
|
||||
{
|
||||
m_count++;
|
||||
UpdateDisplay();
|
||||
return true;
|
||||
}
|
||||
|
||||
SortPrepare();
|
||||
|
||||
wxDataViewTreeNode * node;
|
||||
@@ -2081,6 +2088,19 @@ void DestroyTreeHelper( wxDataViewTreeNode * node);
|
||||
bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent,
|
||||
const wxDataViewItem& item)
|
||||
{
|
||||
if (!m_root)
|
||||
{
|
||||
m_count--;
|
||||
if( m_currentRow > GetRowCount() )
|
||||
m_currentRow = m_count - 1;
|
||||
|
||||
m_selection.Empty();
|
||||
|
||||
UpdateDisplay();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxDataViewTreeNode * node = FindNode(parent);
|
||||
|
||||
wxCHECK_MSG( node != NULL, false, "item not found" );
|
||||
|
||||
Reference in New Issue
Block a user