Changeset 126 for trunk/UContact.pas
- Timestamp:
- Apr 6, 2022, 11:36:27 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UContact.pas
r120 r126 136 136 NoGroups: TStringArray): Boolean; 137 137 procedure Assign(Source: TContactProperty); 138 function CompareTo(ContactProperty: TContactProperty): Boolean; 138 139 constructor Create; 139 140 destructor Destroy; override; … … 179 180 procedure Assign(Source: TContact); 180 181 function UpdateFrom(Source: TContact): Boolean; 182 function CompareTo(Contact: TContact): Boolean; 181 183 constructor Create; 182 184 destructor Destroy; override; … … 208 210 procedure Merge(Contact: TContact; FieldIndex: TContactFieldIndex); 209 211 function ToString: ansistring; override; 212 procedure RemoveExactDuplicates; 210 213 end; 211 214 … … 1049 1052 end; 1050 1053 1054 function TContactProperty.CompareTo(ContactProperty: TContactProperty): Boolean; 1055 var 1056 I: Integer; 1057 begin 1058 Result := (Name = ContactProperty.Name) and (Value = ContactProperty.Value) and 1059 (Attributes.Count = ContactProperty.Attributes.Count); 1060 if Result then begin 1061 for I := 0 to Attributes.Count - 1 do 1062 if not (Attributes[I] = ContactProperty.Attributes[I]) then begin 1063 Result := False; 1064 Break; 1065 end; 1066 end; 1067 end; 1068 1051 1069 constructor TContactProperty.Create; 1052 1070 begin … … 1080 1098 1081 1099 procedure TContacts.AddContacts(Contacts: TContacts); 1082 var 1083 I: Integer; 1084 NewContact: TContact; 1085 begin 1086 for I := 0 to Contacts.Count - 1 do begin 1087 NewContact := TContact.Create; 1088 NewContact.Assign(Contacts[I]); 1089 NewContact.ContactsFile := ContactsFile; 1090 Add(NewContact); 1091 end; 1100 begin 1101 InsertContacts(Count, Contacts); 1092 1102 end; 1093 1103 … … 1104 1114 Inc(Index); 1105 1115 end; 1116 end; 1117 1118 procedure TContacts.RemoveExactDuplicates; 1119 var 1120 I: Integer; 1121 J: Integer; 1122 begin 1123 for I := 0 to Count - 1 do 1124 for J := Count - 1 downto I + 1 do 1125 if Items[I].CompareTo(Items[J]) then begin 1126 Remove(Items[J]); 1127 end; 1106 1128 end; 1107 1129 … … 1554 1576 end; 1555 1577 1578 function TContact.CompareTo(Contact: TContact): Boolean; 1579 var 1580 I: Integer; 1581 begin 1582 Result := Properties.Count = Contact.Properties.Count; 1583 if Result then begin 1584 for I := 0 to Properties.Count - 1 do 1585 if not Properties[I].CompareTo(Contact.Properties[I]) then begin 1586 Result := False; 1587 Break; 1588 end; 1589 end; 1590 end; 1591 1556 1592 constructor TContact.Create; 1557 1593 begin
Note:
See TracChangeset
for help on using the changeset viewer.