Esempio n. 1
0
void CTimeBarListModel::DeleteItems( const wxDataViewItemArray &items )
{
    wxArrayInt rows;
    for (unsigned i = 0; i < items.GetCount(); i++)
    {
        unsigned int row = GetRow( items[i] );
        if (row < m_textColValues.GetCount())
            rows.Add( row );
    }

    if (rows.GetCount() > 0)
    {
        // Sort in descending order so that the last
        // row will be deleted first. Otherwise the
        // remaining indeces would all be wrong.
        rows.Sort([](int *v1, int *v2)
        {
            return *v2-*v1;
        });
        for (unsigned i = 0; i < rows.GetCount(); i++)
        {
            m_textColValues.RemoveAt( rows[i] );
            m_view.RemoveAt( rows[i] );
            m_lock.RemoveAt( rows[i] );
        }
        // This is just to test if wxDataViewCtrl can
        // cope with removing rows not sorted in
        // descending order
        rows.Sort([](int *v1, int *v2)
        {
            return *v1-*v2;
        });
        RowsDeleted( rows );
    }
}
Esempio n. 2
0
void MyListModel::DeleteItems( const wxDataViewItemArray &items )
{
    unsigned i;
    wxArrayInt rows;
    for (i = 0; i < items.GetCount(); i++)
    {
        unsigned int row = GetRow( items[i] );
        if (row < m_textColValues.GetCount())
            rows.Add( row );
    }

    if (rows.GetCount() == 0)
    {
        // none of the selected items were in the range of the items
        // which we store... for simplicity, don't allow removing them
        wxLogError( "Cannot remove rows with an index greater than %d", m_textColValues.GetCount() );
        return;
    }

    // Sort in descending order so that the last
    // row will be deleted first. Otherwise the
    // remaining indeces would all be wrong.
    rows.Sort( my_sort_reverse );
    for (i = 0; i < rows.GetCount(); i++)
        m_textColValues.RemoveAt( rows[i] );

    // This is just to test if wxDataViewCtrl can
    // cope with removing rows not sorted in
    // descending order
    rows.Sort( my_sort );
    RowsDeleted( rows );
}
void
GRaggedFloatTableData::RemoveElement
	(
	const JIndex row,
	const JIndex col
	)
{
	JArray<JFloat>* dataCol = itsCols->NthElement(col);
	const JSize rowCount = dataCol->GetElementCount();
	if (row <= rowCount)
		{
		dataCol->RemoveElement(row);
		}
	if (itsBroadcast)
		{
		Broadcast(GRaggedFloatTableData::ElementRemoved(row, col));
		}

	if (GetMaxRowCount() == GetRowCount() - 2)
		{
		if (itsBroadcast)
			{
			Broadcast(JTableData::RowsRemoved(GetRowCount(), 1));
			}
		RowsDeleted(1);
		}
}