Changeset 120 for trunk/UContact.pas


Ignore:
Timestamp:
Feb 19, 2022, 12:09:21 AM (3 years ago)
Author:
chronos
Message:
  • Added: Partially implemented contacts compare.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UContact.pas

    r119 r120  
    229229    procedure SaveToFile(FileName: string); override;
    230230    procedure LoadFromFile(FileName: string); override;
     231    procedure Sort;
     232    procedure Assign(Source: TContactsFile);
    231233    constructor Create; override;
    232234    destructor Destroy; override;
     
    18701872end;
    18711873
     1874function CompareContactFullName(const Item1, Item2: TContact): Integer;
     1875begin
     1876  Result := CompareStr(Item1.Fields[cfFullName], Item2.Fields[cfFullName]);
     1877end;
     1878
     1879function ComparePropertyName(const Item1, Item2: TContactProperty): Integer;
     1880begin
     1881  Result := CompareStr(Item1.Name + ';' + Item1.Attributes.Text,
     1882    Item2.Name + ';' + Item2.Attributes.Text);
     1883end;
     1884
     1885procedure TContactsFile.Sort;
     1886var
     1887  I: Integer;
     1888begin
     1889  Contacts.Sort(CompareContactFullName);
     1890  for I := 0 to Contacts.Count - 1 do
     1891    Contacts[I].Properties.Sort(ComparePropertyName);
     1892end;
     1893
     1894procedure TContactsFile.Assign(Source: TContactsFile);
     1895begin
     1896  inherited Assign(Source);
     1897  Contacts.Assign(Source.Contacts);
     1898end;
     1899
    18721900constructor TContactsFile.Create;
    18731901begin
Note: See TracChangeset for help on using the changeset viewer.