Changeset 137 for trunk/Packages/Common/UListViewSort.pas
- Timestamp:
- Sep 9, 2022, 1:16:58 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/UListViewSort.pas
r131 r137 2 2 3 3 // Date: 2019-05-17 4 5 {$mode delphi}6 4 7 5 interface … … 9 7 uses 10 8 {$IFDEF Windows}Windows, CommCtrl, LMessages, {$ENDIF}Classes, Graphics, ComCtrls, SysUtils, 11 Controls, DateUtils, Dialogs, fgl,Forms, Grids, StdCtrls, ExtCtrls,12 LclIntf, LclType, LResources ;9 Controls, DateUtils, Dialogs, Forms, Grids, StdCtrls, ExtCtrls, 10 LclIntf, LclType, LResources, Generics.Collections, Generics.Defaults; 13 11 14 12 type … … 19 17 TCompareEvent = function (Item1, Item2: TObject): Integer of object; 20 18 TListFilterEvent = procedure (ListViewSort: TListViewSort) of object; 19 20 TObjects = TObjectList<TObject>; 21 21 22 22 { TListViewSort } … … 52 52 {$ENDIF} 53 53 public 54 List: TFPGObjectList<TObject>;55 Source: TFPGObjectList<TObject>;54 Source: TObjects; 55 List: TObjects; 56 56 constructor Create(AOwner: TComponent); override; 57 57 destructor Destroy; override; … … 149 149 destructor TListViewEx.Destroy; 150 150 begin 151 inherited Destroy;151 inherited; 152 152 end; 153 153 … … 338 338 ListViewSortCompare: TCompareEvent; 339 339 340 function ListViewCompare(const Item1, Item2: TObject): Integer;340 function ListViewCompare(constref Item1, Item2: TObject): Integer; 341 341 begin 342 342 Result := ListViewSortCompare(Item1, Item2); … … 349 349 ListViewSortCompare := Compare; 350 350 if (List.Count > 0) then 351 List.Sort( ListViewCompare);351 List.Sort(TComparer<TObject>.Construct(ListViewCompare)); 352 352 end; 353 353 … … 355 355 begin 356 356 if Assigned(FOnFilter) then FOnFilter(Self) 357 else if Assigned(Source) then 358 List.Assign(Source) else 357 else if Assigned(Source) then begin 359 358 List.Clear; 359 List.AddRange(Source); 360 end else List.Clear; 360 361 if ListView.Items.Count <> List.Count then 361 362 ListView.Items.Count := List.Count; … … 412 413 begin 413 414 inherited; 414 List := T FPGObjectList<TObject>.Create;415 List. FreeObjects := False;415 List := TObjects.Create; 416 List.OwnsObjects := False; 416 417 end; 417 418 418 419 destructor TListViewSort.Destroy; 419 420 begin 420 List.Free;421 FreeAndNil(List); 421 422 inherited; 422 423 end;
Note:
See TracChangeset
for help on using the changeset viewer.