Changeset 128 for trunk/UContact.pas


Ignore:
Timestamp:
Apr 8, 2022, 9:43:55 PM (2 years ago)
Author:
chronos
Message:
  • Modified: Use Generics.Collection instead of fgl for better Delphi compatibility.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UContact.pas

    r127 r128  
    44
    55uses
    6   Classes, SysUtils, fgl, Dialogs, UDataFile, LazUTF8, Base64, Graphics;
     6  Classes, SysUtils, Generics.Collections, Generics.Defaults, Dialogs,
     7  UDataFile, LazUTF8, Base64, Graphics, UListViewSort;
    78
    89type
     
    6263    cfPeerTube, cfLinkedIn, cfMastodon, cfMySpace, cfReddit);
    6364
    64   TContactFieldIndexes = TFPGList<TContactFieldIndex>;
     65  TContactFieldIndexes = TList<TContactFieldIndex>;
    6566
    6667  TContactFilterItem = class
     
    7172  { TContactFilterItems }
    7273
    73   TContactFilterItems = class(TFPGObjectList<TContactFilterItem>)
     74  TContactFilterItems = class(TObjectList<TContactFilterItem>)
    7475    function AddNew(FieldIndex: TContactFieldIndex; Value: string): TContactFilterItem;
    7576  end;
     
    9899  { TContactFields }
    99100
    100   TContactFields = class(TFPGObjectList<TContactField>)
     101  TContactFields = class(TObjectList<TContactField>)
    101102  private
    102103    Indexes: array[TContactFieldIndex] of TContactField;
     
    143144  { TContactProperties }
    144145
    145   TContactProperties = class(TFPGObjectList<TContactProperty>)
     146  TContactProperties = class(TObjectList<TContactProperty>)
    146147    function AddNew(Name, Value: string): TContactProperty;
    147148    procedure Assign(Source: TContactProperties);
    148     procedure AssignToList(List: TFPGObjectList<TObject>);
     149    procedure AssignToList(List: TObjects);
    149150    function GetByName(Name: string): TContactProperty;
    150151    function GetByNameGroups(Name: string; Groups: TStringArray;
     
    197198  { TContacts }
    198199
    199   TContacts = class(TFPGObjectList<TContact>)
     200  TContacts = class(TObjectList<TContact>)
    200201    ContactsFile: TContactsFile;
    201202    procedure Assign(Source: TContacts);
    202203    procedure AddContacts(Contacts: TContacts);
    203204    procedure InsertContacts(Index: Integer; Contacts: TContacts);
    204     procedure AssignToList(List: TFPGObjectList<TObject>);
     205    procedure AssignToList(List: TObjects);
    205206    function AddNew: TContact;
    206207    function Search(Text: string; FieldIndex: TContactFieldIndex): TContact;
     
    854855end;
    855856
    856 procedure TContactProperties.AssignToList(List: TFPGObjectList<TObject>);
     857procedure TContactProperties.AssignToList(List: TObjects);
    857858var
    858859  I: Integer;
     
    11261127end;
    11271128
    1128 procedure TContacts.AssignToList(List: TFPGObjectList<TObject>);
    1129 var
    1130   I: Integer;
    1131 begin
    1132   while List.Count > Count do List.Delete(List.Count - 1);
    1133   while List.Count < Count do List.Add(nil);
    1134   for I := 0 to Count - 1 do
     1129procedure TContacts.AssignToList(List: TObjects);
     1130var
     1131  I: Integer;
     1132begin
     1133  while List.Count > Count do
     1134    List.Delete(List.Count - 1);
     1135  for I := 0 to List.Count - 1 do
    11351136    List[I] := Items[I];
     1137  while List.Count < Count do
     1138    List.Add(Items[List.Count]);
    11361139end;
    11371140
     
    19061909end;
    19071910
    1908 function CompareContactFullName(const Item1, Item2: TContact): Integer;
     1911function CompareContactFullName(constref Item1, Item2: TContact): Integer;
    19091912begin
    19101913  Result := CompareStr(Item1.Fields[cfFullName], Item2.Fields[cfFullName]);
    19111914end;
    19121915
    1913 function ComparePropertyName(const Item1, Item2: TContactProperty): Integer;
     1916function ComparePropertyName(constref Item1, Item2: TContactProperty): Integer;
    19141917begin
    19151918  Result := CompareStr(Item1.Name + ';' + Item1.Attributes.Text,
     
    19211924  I: Integer;
    19221925begin
    1923   Contacts.Sort(CompareContactFullName);
     1926  Contacts.Sort(TComparer<TContact>.Construct(CompareContactFullName));
    19241927  for I := 0 to Contacts.Count - 1 do
    1925     Contacts[I].Properties.Sort(ComparePropertyName);
     1928    Contacts[I].Properties.Sort(TComparer<TContactProperty>.Construct(ComparePropertyName));
    19261929end;
    19271930
Note: See TracChangeset for help on using the changeset viewer.