Ignore:
Timestamp:
Dec 27, 2024, 10:29:54 AM (13 days ago)
Author:
chronos
Message:
  • Fixed: ItemList interface implementation was not working as expected. Implemented as proxy list instead.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/FormList.pas

    r346 r349  
    4747      Selected: Boolean);
    4848  private
    49     FList: IList<TItem>;
    50     procedure SetList(AValue: IList<TItem>);
     49    FList: TBaseItemList;
     50    procedure SetList(AValue: TBaseItemList);
    5151    procedure UpdateListViewColumns;
    5252  public
     
    5555    procedure UpdateInterface;
    5656    procedure UpdateList;
    57     property List: IList<TItem> read FList write SetList;
     57    property List: TBaseItemList read FList write SetList;
    5858  end;
    5959
     
    8484          if List.Count <= MinItemCount then Break;
    8585          ListView1.Items[I].Selected := False;
    86           List.Remove(TItem(ListView1.Items[I].Data));
     86          FList.Remove(TItem(ListView1.Items[I].Data));
    8787        end;
    8888      UpdateList;
     
    9999  if Assigned(ListView1.Selected) then
    100100  with TItem(ListView1.Selected.Data) do begin
    101     TempEntry := List.CreateBaseItem;
     101    TempEntry := FList.CreateItem;
    102102    TempEntry.Assign(TItem(ListView1.Selected.Data));
    103103    FormItem := TFormItem.Create(Self);
     
    121121  FormItem: TFormItem;
    122122begin
    123   if (MaxItemCount <> -1) and (List.Count >= MaxItemCount) then Exit;
    124 
    125   TempEntry := List.CreateBaseItem;
     123  if (MaxItemCount <> -1) and (FList.Count >= MaxItemCount) then Exit;
     124
     125  TempEntry := FList.CreateItem;
    126126  FormItem := TFormItem.Create(Self);
    127127  try
    128     TempEntry.Name := List.GetNextAvailableName(SNew + ' ' + LowerCase(List.GetName));
     128    TempEntry.Name := FList.GetNextAvailableName(SNew + ' ' + LowerCase(List.GetName));
    129129    FormItem.Item := TempEntry;
    130130    if FormItem.ShowModal = mrOk then begin
    131       List.Add(TempEntry);
     131      FList.Add(TempEntry);
    132132      TempEntry := nil;
    133133      UpdateList;
     
    145145  FormItem: TFormItem;
    146146begin
    147   if (MaxItemCount <> -1) and (List.Count >= MaxItemCount) then Exit;
    148 
    149   TempEntry := List.CreateBaseItem;
     147  if (MaxItemCount <> -1) and (FList.Count >= MaxItemCount) then Exit;
     148
     149  TempEntry := FList.CreateItem;
    150150  TempEntry.Assign(TItem(ListView1.Selected.Data));
    151151  FormItem := TFormItem.Create(Self);
     
    154154    FormItem.Item := TempEntry;
    155155    if FormItem.ShowModal = mrOk then begin
    156       List.Add(TempEntry);
     156      FList.Add(TempEntry);
    157157      TempEntry := nil;
    158158      UpdateList;
     
    222222begin
    223223  if Item.Index < ListView1.Items.Count then
    224   with TItem(List[Item.Index]) do begin
     224  with FList[Item.Index] do begin
    225225    //Item.Caption := GetName;
    226     Item.Data := List[Item.Index];
    227     Fields := List.GetItemFields;
     226    Item.Data := FList[Item.Index];
     227    Fields := FList.GetItemFields;
    228228    try
    229229      for I := 0 to Fields.Count - 1 do begin
     
    256256end;
    257257
    258 procedure TFormList.SetList(AValue: IList<TItem>);
     258procedure TFormList.SetList(AValue: TBaseItemList);
    259259begin
    260260  if FList = AValue then Exit;
     
    269269  Fields: TItemFields;
    270270begin
     271  if not Assigned(FList) then begin
     272    while ListView1.Columns.Count > 0 do
     273      ListView1.Columns.Delete(ListView1.Columns.Count - 1);
     274    Exit;
     275  end;
    271276  Fields := List.GetItemFields;
    272277  ListView1.Columns.BeginUpdate;
     
    297302procedure TFormList.UpdateList;
    298303begin
    299   if Assigned(List) then ListView1.Items.Count := List.Count
     304  if Assigned(FList) then ListView1.Items.Count := FList.Count
    300305    else ListView1.Items.Count := 0;
    301306  ListView1.Refresh;
Note: See TracChangeset for help on using the changeset viewer.