Changeset 152 for trunk/Forms/FormCompare.pas
- Timestamp:
- Jun 6, 2023, 5:05:18 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/FormCompare.pas
r151 r152 34 34 procedure CompareExternal; 35 35 procedure LoadConfig; 36 procedure RemoveExactDuplicates(Contacts: TContacts);37 procedure NormalizePhoneNumbers(Contacts: TContacts);38 procedure RemovePhotos(Contacts: TContacts);39 36 procedure SaveConfig; 40 37 end; … … 46 43 47 44 uses 48 Core, FormCompareSideBySide ;45 Core, FormCompareSideBySide, VCardProcessor; 49 46 50 47 { TFormCompare } … … 72 69 73 70 procedure TFormCompare.ButtonCompareClick(Sender: TObject); 71 var 72 VCardProcessor: TVCardProcessor; 74 73 begin 75 74 LeftVCard.Assign(TVCardFile(Core.Core.DataFile)); 76 75 RightVCard.LoadFromFile(EditAnotherFile.Text); 77 76 78 if CheckBoxSortContacts.Checked then begin 79 LeftVCard.VCard.Contacts.Sort; 80 RightVCard.VCard.Contacts.Sort; 77 VCardProcessor := TVCardProcessor.Create(nil); 78 with VCardProcessor do 79 try 80 DefaultPhoneCountryCode := Core.Core.DefaultPhoneCountryCode; 81 RemovePhotos := CheckBoxWithoutPhotos.Checked; 82 RemovePhoneSpaces := CheckBoxNormalizePhoneNumbers.Checked; 83 AddDefaultPhoneCountryPrefix := CheckBoxNormalizePhoneNumbers.Checked; 84 RemoveExactDuplicates := CheckBoxRemoveExactDuplicates.Checked; 85 Order := CheckBoxSortContacts.Checked; 86 finally 87 Free; 81 88 end; 82 89 83 if CheckBoxWithoutPhotos.Checked then begin 84 RemovePhotos(LeftVCard.VCard.Contacts); 85 RemovePhotos(RightVCard.VCard.Contacts); 86 end; 87 88 if CheckBoxNormalizePhoneNumbers.Checked then begin 89 NormalizePhoneNumbers(LeftVCard.VCard.Contacts); 90 NormalizePhoneNumbers(RightVCard.VCard.Contacts); 91 end; 92 93 if CheckBoxRemoveExactDuplicates.Checked then begin 94 RemoveExactDuplicates(LeftVCard.VCard.Contacts); 95 RemoveExactDuplicates(RightVCard.VCard.Contacts); 96 end; 90 LeftVCard.VCard.Contacts.Sort; 91 RightVCard.VCard.Contacts.Sort; 97 92 98 93 CompareExternal; 99 end;100 101 procedure TFormCompare.RemovePhotos(Contacts: TContacts);102 var103 I: Integer;104 J: Integer;105 ContactProperties: TContactProperties;106 begin107 for I := 0 to Contacts.Count - 1 do108 with Contacts[I].Properties do begin109 ContactProperties := GetMultipleByName('PHOTO');110 for J := ContactProperties.Count - 1 downto 0 do111 Remove(ContactProperties[J]);112 ContactProperties.Free;113 end;114 end;115 116 procedure TFormCompare.NormalizePhoneNumbers(Contacts: TContacts);117 var118 I: Integer;119 J: Integer;120 ContactProperties: TContactProperties;121 begin122 for I := 0 to Contacts.Count - 1 do123 with Contacts[I].Properties do begin124 ContactProperties := GetMultipleByName('TEL');125 for J := 0 to ContactProperties.Count - 1 do begin126 ContactProperties[J].Value := StringReplace(ContactProperties[J].Value, ' ', '', [rfReplaceAll]);127 if not ContactProperties[J].Value.StartsWith('+') then128 ContactProperties[J].Value := Core.Core.DefaultPhoneCountryPrefix + ContactProperties[J].Value;129 end;130 ContactProperties.Free;131 end;132 94 end; 133 95 … … 212 174 end; 213 175 214 procedure TFormCompare.RemoveExactDuplicates(Contacts: TContacts);215 var216 I: Integer;217 begin218 Contacts.RemoveExactDuplicates;219 for I := 0 to Contacts.Count - 1 do220 Contacts[I].Properties.RemoveExactDuplicates;221 end;222 223 176 procedure TFormCompare.SaveConfig; 224 177 begin
Note:
See TracChangeset
for help on using the changeset viewer.