Added const modifiers where applicable (PICKED_ITEMS_LIST).

Added PICKED_ITEMS_LIST::FindItem().
This commit is contained in:
Maciej Suminski 2013-12-18 13:27:18 +01:00
parent 4a0407fb69
commit 32065b339a
13 changed files with 45 additions and 26 deletions

View File

@ -50,7 +50,7 @@ PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST()
}
void PICKED_ITEMS_LIST::PushItem( ITEM_PICKER& aItem )
void PICKED_ITEMS_LIST::PushItem( const ITEM_PICKER& aItem )
{
m_ItemsList.push_back( aItem );
}
@ -70,7 +70,7 @@ ITEM_PICKER PICKED_ITEMS_LIST::PopItem()
}
bool PICKED_ITEMS_LIST::ContainsItem( EDA_ITEM* aItem ) const
bool PICKED_ITEMS_LIST::ContainsItem( const EDA_ITEM* aItem ) const
{
for( size_t i = 0; i < m_ItemsList.size(); i++ )
{
@ -82,6 +82,18 @@ bool PICKED_ITEMS_LIST::ContainsItem( EDA_ITEM* aItem ) const
}
int PICKED_ITEMS_LIST::FindItem( const EDA_ITEM* aItem ) const
{
for( size_t i = 0; i < m_ItemsList.size(); i++ )
{
if( m_ItemsList[i].GetItem() == aItem )
return i;
}
return -1;
}
void PICKED_ITEMS_LIST::ClearItemsList()
{
m_ItemsList.clear();
@ -157,7 +169,7 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
}
ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx )
ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx ) const
{
ITEM_PICKER picker;
@ -168,7 +180,7 @@ ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx )
}
EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx )
EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx ) const
{
if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].GetItem();
@ -177,7 +189,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx )
}
EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx )
EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx ) const
{
if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].GetLink();
@ -186,7 +198,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx )
}
UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx ) const
{
if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].GetStatus();
@ -195,7 +207,7 @@ UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
}
STATUS_FLAGS PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx )
STATUS_FLAGS PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx ) const
{
if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].GetFlags();

View File

@ -124,7 +124,7 @@ public:
* @param aTransformPoint = the reference point of the transformation,
* for commands like move
*/
virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) )
{

View File

@ -160,7 +160,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
}
void SCH_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint )
{

View File

@ -676,7 +676,7 @@ public:
* @param aTransformPoint = the reference point of the transformation,
* for commands like move
*/
void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) )
{

View File

@ -111,7 +111,7 @@ public:
void SetStatus( UNDO_REDO_T aStatus ) { m_undoRedoStatus = aStatus; }
UNDO_REDO_T GetStatus() { return m_undoRedoStatus; }
UNDO_REDO_T GetStatus() const { return m_undoRedoStatus; }
void SetFlags( STATUS_FLAGS aFlags ) { m_pickerFlags = aFlags; }
@ -148,7 +148,7 @@ public:
* pushes \a aItem to the top of the list
* @param aItem Picker to push on to the list.
*/
void PushItem( ITEM_PICKER& aItem );
void PushItem( const ITEM_PICKER& aItem );
/**
* Function PopItem
@ -160,7 +160,14 @@ public:
* Function IsItemInList
* @return True if \a aItem is found in the pick list.
*/
bool ContainsItem( EDA_ITEM* aItem ) const;
bool ContainsItem( const EDA_ITEM* aItem ) const;
/**
* Function FindItem
* @return Index of the searched item. If the item is not stored in the list, negative value
* is returned.
*/
int FindItem( const EDA_ITEM* aItem ) const;
/**
* Function ClearItemsList
@ -201,21 +208,21 @@ public:
* if this picker does not exist, a picker is returned,
* with its members set to 0 or NULL
*/
ITEM_PICKER GetItemWrapper( unsigned int aIdx );
ITEM_PICKER GetItemWrapper( unsigned int aIdx ) const;
/**
* Function GetPickedItem
* @return A pointer to the picked item
* @param aIdx Index of the picked item in the picked list
*/
EDA_ITEM* GetPickedItem( unsigned int aIdx );
EDA_ITEM* GetPickedItem( unsigned int aIdx ) const;
/**
* Function GetPickedItemLink
* @return link of the picked item, or null if does not exist
* @param aIdx Index of the picked item in the picked list
*/
EDA_ITEM* GetPickedItemLink( unsigned int aIdx );
EDA_ITEM* GetPickedItemLink( unsigned int aIdx ) const;
/**
* Function GetPickedItemStatus
@ -223,7 +230,7 @@ public:
* or UR_UNSPECIFIED if does not exist
* @param aIdx Index of the picked item in the picked list
*/
UNDO_REDO_T GetPickedItemStatus( unsigned int aIdx );
UNDO_REDO_T GetPickedItemStatus( unsigned int aIdx ) const;
/**
* Function GetPickerFlags
@ -231,7 +238,7 @@ public:
* @param aIdx Index of the picker in the picked list
* @return The value stored in the picker, if the picker exists, or 0 if does not exist
*/
STATUS_FLAGS GetPickerFlags( unsigned aIdx );
STATUS_FLAGS GetPickerFlags( unsigned aIdx ) const;
/**
* Function SetPickedItem

View File

@ -669,7 +669,7 @@ public:
* @param aTransformPoint = the reference point of the transformation,
* for commands like move
*/
virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0;

View File

@ -1080,7 +1080,7 @@ public:
* @param aTransformPoint = the reference point of the transformation,
* for commands like move
*/
void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );

View File

@ -659,7 +659,7 @@ public:
* @param aTransformPoint = the reference point of the transformation, for
* commands like move
*/
virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );

View File

@ -346,7 +346,7 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
}
void PCB_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
void PCB_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint )
{

View File

@ -198,7 +198,7 @@ private:
*/
void OnLeftDClick( wxDC*, const wxPoint& ) {}
void SaveCopyInUndoList( BOARD_ITEM*, UNDO_REDO_T, const wxPoint& ) {}
void SaveCopyInUndoList( PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint& ) {}
void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint& ) {}
DECLARE_EVENT_TABLE()

View File

@ -46,7 +46,7 @@ void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
}
void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint )
{

View File

@ -245,7 +245,7 @@ public:
* @param aTransformPoint = the reference point of the transformation, for
* commands like move
*/
virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );

View File

@ -202,7 +202,7 @@ private:
*/
void OnLeftDClick( wxDC*, const wxPoint& ) {}
void SaveCopyInUndoList( BOARD_ITEM*, UNDO_REDO_T, const wxPoint& ) {}
void SaveCopyInUndoList( PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint &) {}
void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint &) {}
DECLARE_EVENT_TABLE()