Ignore:
Timestamp:
Dec 13, 2021, 11:33:11 PM (3 years ago)
Author:
chronos
Message:
  • Added: Copy, cut and paste context menu action in contacts list.
  • Modified: Merge multiple files action replaced by Combine action. During Combine action files are simply added into final contacts list even with duplicate contacts.
  • Modified: Added Merge button into Find duplicate window to merge contacts by selected contact field.
  • Modified: Show only used contact fields in Find duplicates window.
  • Fixed: Wrong items were removed if contacts and properties lists were in filtered state.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormFindDuplicity.pas

    r68 r73  
    3131    AShowContacts: TAction;
    3232    ActionList1: TActionList;
     33    ButtonMerge: TButton;
    3334    ComboBoxField: TComboBox;
    3435    Label1: TLabel;
     
    3839    PopupMenu1: TPopupMenu;
    3940    procedure AShowContactsExecute(Sender: TObject);
     41    procedure ButtonMergeClick(Sender: TObject);
    4042    procedure ComboBoxFieldChange(Sender: TObject);
    4143    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     
    109111var
    110112  ContactField: TContactField;
     113  Items: TStringList;
     114  I: Integer;
    111115begin
    112116  if FContacts = AValue then Exit;
    113117  FContacts := AValue;
    114118  if Assigned(FContacts) then begin
    115     Contacts.ContactsFile.Fields.LoadToStrings(ComboBoxField.Items);
     119    Items := TStringList.Create;
     120    try
     121      Contacts.ContactsFile.Fields.LoadToStrings(Items);
     122
     123      // Remove fields which are not used in contacts
     124      for I := Items.Count - 1 downto 0 do
     125        if Contacts.CountByField(TContactField(Items.Objects[I]).Index) = 0 then
     126          Items.Delete(I);
     127
     128      ComboBoxField.Items.Assign(Items);
     129    finally
     130      Items.Free;
     131    end;
    116132    ContactField := Contacts.ContactsFile.Fields.GetByIndex(ContactFieldIndex);
    117133    ComboBoxField.ItemIndex := ComboBoxField.Items.IndexOfObject(ContactField);
     
    156172  Core.Translator.TranslateComponentRecursive(Self);
    157173  Core.ThemeManager1.UseTheme(Self);
    158   ContactFieldIndex := cfTelCell;
     174  ContactFieldIndex := cfFullName;
    159175end;
    160176
     
    203219end;
    204220
     221procedure TFormFindDuplicity.ButtonMergeClick(Sender: TObject);
     222var
     223  TempContacts: TContactsFile;
     224  I: Integer;
     225begin
     226  TempContacts := TContactsFile.Create;
     227  try
     228    for I := 0 to Contacts.Count - 1 do
     229      TempContacts.Contacts.Merge(Contacts[I], TContactField(ComboBoxField.Items.Objects[ComboBoxField.ItemIndex]).Index);
     230    Contacts.Assign(TempContacts.Contacts);
     231    Find;
     232  finally
     233    TempContacts.Free;
     234  end;
     235end;
     236
    205237procedure TFormFindDuplicity.FormClose(Sender: TObject;
    206238  var CloseAction: TCloseAction);
Note: See TracChangeset for help on using the changeset viewer.