Ignore:
Timestamp:
Dec 23, 2024, 8:16:05 AM (10 hours ago)
Author:
chronos
Message:
  • Modified: Improved implementation of TItemList class to be generic class to avoid explicit typecasting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/FormList.pas

    r317 r344  
    4646      Selected: Boolean);
    4747  private
    48     FList: TItemList;
    49     procedure SetList(AValue: TItemList);
     48    FList: IList<TItem>;
     49    procedure SetList(AValue: IList<TItem>);
    5050    procedure UpdateListViewColumns;
    5151  public
     
    5454    procedure UpdateInterface;
    5555    procedure UpdateList;
    56     property List: TItemList read FList write SetList;
     56    property List: IList<TItem> read FList write SetList;
    5757  end;
    5858
     
    9898  if Assigned(ListView1.Selected) then
    9999  with TItem(ListView1.Selected.Data) do begin
    100     TempEntry := List.CreateItem;
     100    TempEntry := List.CreateBaseItem;
    101101    TempEntry.Assign(TItem(ListView1.Selected.Data));
    102102    FormItem := TFormItem.Create(Self);
     
    122122  if (MaxItemCount <> -1) and (List.Count >= MaxItemCount) then Exit;
    123123
    124   TempEntry := List.CreateItem;
     124  TempEntry := List.CreateBaseItem;
    125125  FormItem := TFormItem.Create(Self);
    126126  try
    127     TempEntry.Name := List.GetNextAvailableName(SNew + ' ' + LowerCase(List.GetItemClass.GetClassName));
     127    TempEntry.Name := List.GetNextAvailableName(SNew + ' ' + LowerCase(List.GetName));
    128128    FormItem.Item := TempEntry;
    129129    if FormItem.ShowModal = mrOk then begin
     
    146146  if (MaxItemCount <> -1) and (List.Count >= MaxItemCount) then Exit;
    147147
    148   TempEntry := List.CreateItem;
     148  TempEntry := List.CreateBaseItem;
    149149  TempEntry.Assign(TItem(ListView1.Selected.Data));
    150150  FormItem := TFormItem.Create(Self);
     
    219219    //Item.Caption := GetName;
    220220    Item.Data := List[Item.Index];
    221     Fields := List.GetItemClass.GetFields;
     221    Fields := List.GetItemFields;
    222222    try
    223223      for I := 0 to Fields.Count - 1 do begin
     
    250250end;
    251251
    252 procedure TFormList.SetList(AValue: TItemList);
     252procedure TFormList.SetList(AValue: IList<TItem>);
    253253begin
    254254  if FList = AValue then Exit;
     
    261261  Fields: TItemFields;
    262262begin
    263   Fields := List.GetItemClass.GetFields;
     263  Fields := List.GetItemFields;
    264264  ListView1.Columns.BeginUpdate;
    265265  try
Note: See TracChangeset for help on using the changeset viewer.