Ignore:
Timestamp:
Apr 25, 2022, 6:22:53 PM (2 years ago)
Author:
chronos
Message:
  • Modified: Update Common package to version 0.10.
  • Modified: fgl unit replaced by Generics.Collections.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/UListViewSort.pas

    r423 r424  
    77uses
    88  {$IFDEF Windows}Windows, CommCtrl, LMessages, {$ENDIF}Classes, Graphics, ComCtrls, SysUtils,
    9   Controls, DateUtils, Dialogs, fgl, Forms, Grids, StdCtrls, ExtCtrls,
    10   LclIntf, LclType, LResources;
     9  Controls, DateUtils, Dialogs, Forms, Grids, StdCtrls, ExtCtrls,
     10  LclIntf, LclType, LResources, Generics.Collections, Generics.Defaults;
    1111
    1212type
     
    1717  TCompareEvent = function (Item1, Item2: TObject): Integer of object;
    1818  TListFilterEvent = procedure (ListViewSort: TListViewSort) of object;
     19
     20  TObjects = TObjectList<TObject>;
    1921
    2022  { TListViewSort }
     
    5052    {$ENDIF}
    5153  public
    52     List: TFPGObjectList<TObject>;
    53     Source: TFPGObjectList<TObject>;
     54    Source: TObjects;
     55    List: TObjects;
    5456    constructor Create(AOwner: TComponent); override;
    5557    destructor Destroy; override;
     
    336338  ListViewSortCompare: TCompareEvent;
    337339
    338 function ListViewCompare(const Item1, Item2: TObject): Integer;
     340function ListViewCompare(constref Item1, Item2: TObject): Integer;
    339341begin
    340342  Result := ListViewSortCompare(Item1, Item2);
     
    347349  ListViewSortCompare := Compare;
    348350  if (List.Count > 0) then
    349     List.Sort(ListViewCompare);
     351    List.Sort(TComparer<TObject>.Construct(ListViewCompare));
    350352end;
    351353
     
    353355begin
    354356  if Assigned(FOnFilter) then FOnFilter(Self)
    355   else if Assigned(Source) then
    356     List.Assign(Source) else
     357  else if Assigned(Source) then begin
    357358    List.Clear;
     359    List.AddRange(Source);
     360  end else List.Clear;
    358361  if ListView.Items.Count <> List.Count then
    359362    ListView.Items.Count := List.Count;
     
    410413begin
    411414  inherited;
    412   List := TFPGObjectList<TObject>.Create;
    413   List.FreeObjects := False;
     415  List := TObjects.Create;
     416  List.OwnsObjects := False;
    414417end;
    415418
    416419destructor TListViewSort.Destroy;
    417420begin
    418   List.Free;
     421  FreeAndNil(List);
    419422  inherited;
    420423end;
Note: See TracChangeset for help on using the changeset viewer.