Changeset 152 for trunk/Forms


Ignore:
Timestamp:
Jun 6, 2023, 5:05:18 PM (19 months ago)
Author:
chronos
Message:
  • Added: VCardProcessor class for processing contacts available from VCard package.
  • Added: Normalize menu action for normalization of contact property values.
Location:
trunk/Forms
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/FormCompare.pas

    r151 r152  
    3434    procedure CompareExternal;
    3535    procedure LoadConfig;
    36     procedure RemoveExactDuplicates(Contacts: TContacts);
    37     procedure NormalizePhoneNumbers(Contacts: TContacts);
    38     procedure RemovePhotos(Contacts: TContacts);
    3936    procedure SaveConfig;
    4037  end;
     
    4643
    4744uses
    48   Core, FormCompareSideBySide;
     45  Core, FormCompareSideBySide, VCardProcessor;
    4946
    5047{ TFormCompare }
     
    7269
    7370procedure TFormCompare.ButtonCompareClick(Sender: TObject);
     71var
     72  VCardProcessor: TVCardProcessor;
    7473begin
    7574  LeftVCard.Assign(TVCardFile(Core.Core.DataFile));
    7675  RightVCard.LoadFromFile(EditAnotherFile.Text);
    7776
    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;
    8188  end;
    8289
    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;
    9792
    9893  CompareExternal;
    99 end;
    100 
    101 procedure TFormCompare.RemovePhotos(Contacts: TContacts);
    102 var
    103   I: Integer;
    104   J: Integer;
    105   ContactProperties: TContactProperties;
    106 begin
    107   for I := 0 to Contacts.Count - 1 do
    108   with Contacts[I].Properties do begin
    109     ContactProperties := GetMultipleByName('PHOTO');
    110     for J := ContactProperties.Count - 1 downto 0 do
    111       Remove(ContactProperties[J]);
    112     ContactProperties.Free;
    113   end;
    114 end;
    115 
    116 procedure TFormCompare.NormalizePhoneNumbers(Contacts: TContacts);
    117 var
    118   I: Integer;
    119   J: Integer;
    120   ContactProperties: TContactProperties;
    121 begin
    122   for I := 0 to Contacts.Count - 1 do
    123   with Contacts[I].Properties do begin
    124     ContactProperties := GetMultipleByName('TEL');
    125     for J := 0 to ContactProperties.Count - 1 do begin
    126       ContactProperties[J].Value := StringReplace(ContactProperties[J].Value, ' ', '', [rfReplaceAll]);
    127       if not ContactProperties[J].Value.StartsWith('+') then
    128         ContactProperties[J].Value := Core.Core.DefaultPhoneCountryPrefix + ContactProperties[J].Value;
    129     end;
    130     ContactProperties.Free;
    131   end;
    13294end;
    13395
     
    212174end;
    213175
    214 procedure TFormCompare.RemoveExactDuplicates(Contacts: TContacts);
    215 var
    216   I: Integer;
    217 begin
    218   Contacts.RemoveExactDuplicates;
    219   for I := 0 to Contacts.Count - 1 do
    220     Contacts[I].Properties.RemoveExactDuplicates;
    221 end;
    222 
    223176procedure TFormCompare.SaveConfig;
    224177begin
  • trunk/Forms/FormFindDuplicity.lfm

    r149 r152  
    1212  OnDestroy = FormDestroy
    1313  OnShow = FormShow
    14   LCLVersion = '2.2.0.4'
     14  LCLVersion = '2.2.6.0'
    1515  object ListView1: TListView
    1616    Left = 5
     
    5555    TabOrder = 1
    5656    object ComboBoxField: TComboBox
    57       Left = 160
    58       Height = 41
    59       Top = 16
     57      Left = 192
     58      Height = 42
     59      Top = 14
    6060      Width = 326
    6161      ItemHeight = 0
     
    7171      Width = 135
    7272      Caption = 'By contact field:'
     73      ParentColor = False
    7374      ParentFont = False
    7475    end
    7576    object ButtonMerge: TButton
    76       Left = 496
     77      Left = 528
    7778      Height = 38
    7879      Top = 14
  • trunk/Forms/FormFindDuplicity.pas

    r149 r152  
    55uses
    66  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    7   ExtCtrls, StdCtrls, ActnList, Menus, VCard, Generics.Collections,
     7  ExtCtrls, StdCtrls, ActnList, Menus, VCard, Generics.Collections, RegistryEx,
    88  Generics.Defaults;
    99
     
    189189    Form.Contacts := TContacts.Create(False);
    190190    Form.Contacts.ParentVCard := Contacts.ParentVCard;
     191    Form.Context := TRegistryContext.Create(Core.Core.ApplicationInfo1.RegistryRoot,
     192      Core.Core.ApplicationInfo1.RegistryKey + '\ContactsColumns');
    191193    with TFoundItem(ListView1.Selected.Data) do
    192194      for I := 0 to Contacts.Count - 1 do
  • trunk/Forms/FormMain.lfm

    r149 r152  
    190190        Caption = '-'
    191191      end
     192      object MenuItem14: TMenuItem
     193        Action = Core.ANormalize
     194      end
    192195      object MenuItem13: TMenuItem
    193196        Action = Core.ARemoveExactDuplicates
  • trunk/Forms/FormMain.pas

    r150 r152  
    1919    MenuItem12: TMenuItem;
    2020    MenuItem13: TMenuItem;
     21    MenuItem14: TMenuItem;
    2122    MenuItemColumns: TMenuItem;
    2223    MenuItem3: TMenuItem;
  • trunk/Forms/FormSettings.lfm

    r151 r152  
    11object FormSettings: TFormSettings
    22  Left = 798
    3   Height = 521
     3  Height = 613
    44  Top = 204
    55  Width = 857
    66  Caption = 'Settings'
    7   ClientHeight = 521
     7  ClientHeight = 613
    88  ClientWidth = 857
    99  Constraints.MinHeight = 404
     
    1818    Left = 731
    1919    Height = 37
    20     Top = 468
     20    Top = 560
    2121    Width = 113
    2222    Anchors = [akRight, akBottom]
     
    3030    Left = 587
    3131    Height = 37
    32     Top = 468
     32    Top = 560
    3333    Width = 113
    3434    Anchors = [akRight, akBottom]
     
    4040  object ScrollBox1: TScrollBox
    4141    Left = 8
    42     Height = 448
     42    Height = 540
    4343    Top = 8
    4444    Width = 845
    4545    HorzScrollBar.Page = 504
    46     VertScrollBar.Page = 427
     46    VertScrollBar.Page = 475
    4747    Anchors = [akTop, akLeft, akRight, akBottom]
    48     ClientHeight = 446
     48    ClientHeight = 538
    4949    ClientWidth = 843
    5050    TabOrder = 2
     
    195195    end
    196196    object EditDefaultPhoneCountryPrefix: TEdit
    197       Left = 296
     197      Left = 312
    198198      Height = 43
    199199      Top = 384
     
    201201      TabOrder = 9
    202202    end
     203    object Label7: TLabel
     204      Left = 23
     205      Height = 26
     206      Top = 440
     207      Width = 267
     208      Caption = 'Default international call prefix:'
     209      ParentColor = False
     210    end
     211    object EditDefaultInternationalCallPrefix: TEdit
     212      Left = 312
     213      Height = 43
     214      Top = 432
     215      Width = 144
     216      TabOrder = 10
     217    end
    203218  end
    204219  object OpenDialog1: TOpenDialog
  • trunk/Forms/FormSettings.lrj

    r151 r152  
    1212{"hash":220155194,"name":"tformsettings.label5.caption","sourcebytes":[67,111,109,112,97,114,101,32,116,111,111,108,58],"value":"Compare tool:"},
    1313{"hash":77164181,"name":"tformsettings.buttonbrowse.caption","sourcebytes":[66,114,111,119,115,101],"value":"Browse"},
    14 {"hash":99356634,"name":"tformsettings.label6.caption","sourcebytes":[68,101,102,97,117,108,116,32,112,104,111,110,101,32,99,111,117,110,116,114,121,32,112,114,101,102,105,120,58],"value":"Default phone country prefix:"}
     14{"hash":99356634,"name":"tformsettings.label6.caption","sourcebytes":[68,101,102,97,117,108,116,32,112,104,111,110,101,32,99,111,117,110,116,114,121,32,112,114,101,102,105,120,58],"value":"Default phone country prefix:"},
     15{"hash":112394474,"name":"tformsettings.label7.caption","sourcebytes":[68,101,102,97,117,108,116,32,105,110,116,101,114,110,97,116,105,111,110,97,108,32,99,97,108,108,32,112,114,101,102,105,120,58],"value":"Default international call prefix:"}
    1516]}
  • trunk/Forms/FormSettings.pas

    r151 r152  
    2020    ComboBoxTheme: TComboBox;
    2121    EditCompareTool: TEdit;
     22    EditDefaultInternationalCallPrefix: TEdit;
    2223    EditDefaultVcardVersion: TEdit;
    2324    EditDefaultPhoneCountryPrefix: TEdit;
     
    2930    Label5: TLabel;
    3031    Label6: TLabel;
     32    Label7: TLabel;
    3133    LabelDPI: TLabel;
    3234    OpenDialog1: TOpenDialog;
     
    119121    EditMapUrl.Text := MapUrl;
    120122    EditCompareTool.Text := CompareTool;
    121     EditDefaultPhoneCountryPrefix.Text := DefaultPhoneCountryPrefix;
     123    EditDefaultPhoneCountryPrefix.Text := DefaultPhoneCountryCode;
     124    EditDefaultInternationalCallPrefix.Text := DefaultInternationalCallPrefix;
    122125  end;
    123126  UpdateInterface;
     
    133136    MapUrl := EditMapUrl.Text;
    134137    CompareTool := EditCompareTool.Text;
    135     DefaultPhoneCountryPrefix := EditDefaultPhoneCountryPrefix.Text;
     138    DefaultPhoneCountryCode := EditDefaultPhoneCountryPrefix.Text;
     139    DefaultInternationalCallPrefix := EditDefaultInternationalCallPrefix.Text;
    136140  end;
    137141end;
Note: See TracChangeset for help on using the changeset viewer.