Changeset 424 for trunk/Packages/Common/UListViewSort.pas
- Timestamp:
- Apr 25, 2022, 6:22:53 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/UListViewSort.pas
r423 r424 7 7 uses 8 8 {$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; 11 11 12 12 type … … 17 17 TCompareEvent = function (Item1, Item2: TObject): Integer of object; 18 18 TListFilterEvent = procedure (ListViewSort: TListViewSort) of object; 19 20 TObjects = TObjectList<TObject>; 19 21 20 22 { TListViewSort } … … 50 52 {$ENDIF} 51 53 public 52 List: TFPGObjectList<TObject>;53 Source: TFPGObjectList<TObject>;54 Source: TObjects; 55 List: TObjects; 54 56 constructor Create(AOwner: TComponent); override; 55 57 destructor Destroy; override; … … 336 338 ListViewSortCompare: TCompareEvent; 337 339 338 function ListViewCompare(const Item1, Item2: TObject): Integer;340 function ListViewCompare(constref Item1, Item2: TObject): Integer; 339 341 begin 340 342 Result := ListViewSortCompare(Item1, Item2); … … 347 349 ListViewSortCompare := Compare; 348 350 if (List.Count > 0) then 349 List.Sort( ListViewCompare);351 List.Sort(TComparer<TObject>.Construct(ListViewCompare)); 350 352 end; 351 353 … … 353 355 begin 354 356 if Assigned(FOnFilter) then FOnFilter(Self) 355 else if Assigned(Source) then 356 List.Assign(Source) else 357 else if Assigned(Source) then begin 357 358 List.Clear; 359 List.AddRange(Source); 360 end else List.Clear; 358 361 if ListView.Items.Count <> List.Count then 359 362 ListView.Items.Count := List.Count; … … 410 413 begin 411 414 inherited; 412 List := T FPGObjectList<TObject>.Create;413 List. FreeObjects := False;415 List := TObjects.Create; 416 List.OwnsObjects := False; 414 417 end; 415 418 416 419 destructor TListViewSort.Destroy; 417 420 begin 418 List.Free;421 FreeAndNil(List); 419 422 inherited; 420 423 end;
Note:
See TracChangeset
for help on using the changeset viewer.