TSearcheableCollection
Overview
The TSearcheableCollection class is a base class for collections of various objects that provide 'name' support like the possibility to get or set names for items, notifications about adding, removing or renaming items and methods for looking up, cloning and moving items.
This class isn't used directly, but its methods are used by its descendants.
Location
- Unit: uDASupportClasses.pas
- Ancestry: TOwnedCollection | TSearcheableCollection
constructor Create
Initializes the collection with the supplied parameters.
constructor Create(AOwner: TPersistent; ItemClass: TCollectionItemClass)
Parameters:
- AOwner: owner
- ItemClass: item class
CloneItem
Inserts a copy of an item and names it "Copy nn of " of the cloned item name.
function CloneItem(iIndex: Integer): Integer
Parameters:
- iIndex: position.
FindItem virtual
Finds the first occurrence of the item with the supplied name. Search is case-insensitive.
function FindItem(const aName: string): TCollectionItem
Parameters:
- aName: the supplied name
FindUniqueName
Returns the supplied name if the item with that name is absent in the collection or adds a number to it and sequentially increments it until the result is unique.
function FindUniqueName(const iBaseName: string): string
Parameters:
- iBaseName: the supplied name
FindUniqueNameEx
Does the same as FindUniqueName, but uses a template with a numeric parameter as second argument, it should be compatible with the Delphi Format function.
function FindUniqueNameEx(const iBaseName: string; const iNumberedName: string): string
Parameters:
- iBaseName: the supplied name
- iNumberedName: numeric parameter
GetDefaultItem
Looks for the first occurrence of the item that has a boolean property with the name "Default" and the value true. Raises an exception if no such item can be found.
function GetDefaultItem: TCollectionItem
GetItemDefault protected dynamic
Returns default item's name
function GetItemDefault(anItem: TCollectionItem): Boolean
Parameters:
- anItem: given item
GetItemName protected reintroduce dynamic
Gets the name of the specified item.
function GetItemName(anItem: TCollectionItem): string
Parameters:
- anItem: the specified item.
ItemByName
Returns an item with the specified name.
function ItemByName(const aName: string): TCollectionItem
Parameters:
- aName: fClientFields
ItemName protected virtual
Returns the string "item".
function ItemName: string
MoveItem
Moves the item from one position to another. Checks boundaries.
procedure MoveItem(iFromIndex: Integer; iToIndex: Integer)
Parameters:
- iFromIndex: old index
- iToIndex: new index
Notify protected override
Notifies about the adding or removal of an item if the event handler is assigned. If an item with an empty name is added and items without name are not allowed, it sets the name to "Item" plus number.
procedure Notify(Item: TCollectionItem; Action: TCollectionNotification)
Parameters:
- Item: given item
- Action: action
OnItemRemoved
Event handler for removing an item.
property OnItemRemoved: TDAItemRemovedEvent read write
delegate: procedure OnItemRemoved(aSender: TObject; const aName: string)
OnItemRenamed
Event handler for renaming an item.
property OnItemRenamed: TDAItemRenamedEvent read write
delegate: procedure OnItemRenamed(aSender: TObject; const aOldName: string; const aNewName: string)
SetItemName protected reintroduce dynamic
Sets a new name for the specified item.
function SetItemName(anItem: TCollectionItem; const aName: string): string
Parameters:
- anItem: item
- aName: name
TriggerOnItemRemoved virtual
Calls the event handler if it was assigned.
procedure TriggerOnItemRemoved(const iName: string)
Parameters:
- iName: item name
TriggerOnItemRenamed virtual
Calls the event handler if it was assigned.
procedure TriggerOnItemRenamed(const iOldName: string; const iNewName: string)
Parameters:
- iOldName: old name
- iNewName: new name
constructor Create
Initializes the collection with the supplied parameters.
constructor Create(AOwner: TPersistent; ItemClass: TCollectionItemClass)
Parameters:
- AOwner: owner
- ItemClass: item class
CloneItem
Inserts a copy of an item and names it "Copy nn of " of the cloned item name.
function CloneItem(iIndex: Integer): Integer
Parameters:
- iIndex: position.
FindItem virtual
Finds the first occurrence of the item with the supplied name. Search is case-insensitive.
function FindItem(const aName: string): TCollectionItem
Parameters:
- aName: the supplied name
FindUniqueName
Returns the supplied name if the item with that name is absent in the collection or adds a number to it and sequentially increments it until the result is unique.
function FindUniqueName(const iBaseName: string): string
Parameters:
- iBaseName: the supplied name
FindUniqueNameEx
Does the same as FindUniqueName, but uses a template with a numeric parameter as second argument, it should be compatible with the Delphi Format function.
function FindUniqueNameEx(const iBaseName: string; const iNumberedName: string): string
Parameters:
- iBaseName: the supplied name
- iNumberedName: numeric parameter
GetDefaultItem
Looks for the first occurrence of the item that has a boolean property with the name "Default" and the value true. Raises an exception if no such item can be found.
function GetDefaultItem: TCollectionItem
GetItemDefault protected dynamic
Returns default item's name
function GetItemDefault(anItem: TCollectionItem): Boolean
Parameters:
- anItem: given item
GetItemName protected reintroduce dynamic
Gets the name of the specified item.
function GetItemName(anItem: TCollectionItem): string
Parameters:
- anItem: the specified item.
ItemByName
Returns an item with the specified name.
function ItemByName(const aName: string): TCollectionItem
Parameters:
- aName: fClientFields
ItemName protected virtual
Returns the string "item".
function ItemName: string
MoveItem
Moves the item from one position to another. Checks boundaries.
procedure MoveItem(iFromIndex: Integer; iToIndex: Integer)
Parameters:
- iFromIndex: old index
- iToIndex: new index
Notify protected override
Notifies about the adding or removal of an item if the event handler is assigned. If an item with an empty name is added and items without name are not allowed, it sets the name to "Item" plus number.
procedure Notify(Item: TCollectionItem; Action: TCollectionNotification)
Parameters:
- Item: given item
- Action: action
SetItemName protected reintroduce dynamic
Sets a new name for the specified item.
function SetItemName(anItem: TCollectionItem; const aName: string): string
Parameters:
- anItem: item
- aName: name
TriggerOnItemRemoved virtual
Calls the event handler if it was assigned.
procedure TriggerOnItemRemoved(const iName: string)
Parameters:
- iName: item name
TriggerOnItemRenamed virtual
Calls the event handler if it was assigned.
procedure TriggerOnItemRenamed(const iOldName: string; const iNewName: string)
Parameters:
- iOldName: old name
- iNewName: new name
OnItemRemoved
Event handler for removing an item.
property OnItemRemoved: TDAItemRemovedEvent read write
delegate: procedure OnItemRemoved(aSender: TObject; const aName: string)
OnItemRenamed
Event handler for renaming an item.
property OnItemRenamed: TDAItemRenamedEvent read write
delegate: procedure OnItemRenamed(aSender: TObject; const aOldName: string; const aNewName: string)
- TDAColumnMappingCollection
- TDAConnectionCollection
- TDADatasetRelationshipCollection
- TDADeltaProcessorItemCollection
- TDAJoinDataTableCollection
- TDAJoinSourceTableCollection
- TDASQLCommandCollection
- TDAStatementCollection
- TDAUnionDataTableCollection
- TDAUnionSourceTableCollection
- TDAUpdateRuleCollection
- TSearcheableCollectionCached