Ignore:
Timestamp:
Jun 5, 2023, 6:44:57 PM (18 months ago)
Author:
chronos
Message:
  • Modified: Remove U prefix from unit names.
  • Modified: Updated Common package.
File:
1 moved

Legend:

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

    r144 r145  
    1 unit UListViewSort;
     1unit ListViewSort;
    22
    33// Date: 2019-05-17
     
    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;
     
    147149destructor TListViewEx.Destroy;
    148150begin
    149   inherited Destroy;
     151  inherited;
    150152end;
    151153
     
    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.