Changeset 120 for trunk/UCore.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/UCore.pas

    r117 r120  
    1717    AAbout: TAction;
    1818    AboutDialog1: TAboutDialog;
     19    AFileCompare: TAction;
    1920    AViewSource: TAction;
    2021    ATest: TAction;
     
    4748    procedure AExitExecute(Sender: TObject);
    4849    procedure AFileCombineExecute(Sender: TObject);
     50    procedure AFileCompareExecute(Sender: TObject);
    4951    procedure AFileNewExecute(Sender: TObject);
    5052    procedure AFileOpenExecute(Sender: TObject);
     
    110112uses
    111113  UFormMain, UFormSettings, UContact, UFormContacts, UFormFindDuplicity,
    112   UFormGenerate, UFormError, UFormFind, UFormTest, UFormSource;
     114  UFormGenerate, UFormError, UFormFind, UFormTest, UFormSource, UFormCompare;
    113115
    114116resourcestring
     
    163165    ShowMessage(Format(SCombinedContacts, [LoadedFiles]));
    164166    UpdateFile;
     167  end;
     168end;
     169
     170procedure TCore.AFileCompareExecute(Sender: TObject);
     171var
     172  TempFile: TDataFile;
     173  LeftContacts: TContactsFile;
     174  RightContacts: TContactsFile;
     175begin
     176  TempFile := DefaultDataFileClass.Create;
     177  try
     178    OpenDialog1.Filter := TempFile.GetFileFilter;
     179  finally
     180    TempFile.Free;
     181  end;
     182  OpenDialog1.DefaultExt := '';
     183  if Assigned(DataFile) then begin
     184    OpenDialog1.InitialDir := ExtractFileDir(DataFile.FileName);
     185    OpenDialog1.FileName := ExtractFileName(DataFile.FileName);
     186  end;
     187  OpenDialog1.Options := OpenDialog1.Options - [ofAllowMultiSelect];
     188  if OpenDialog1.Execute then begin
     189    with TFormCompare.Create(nil) do
     190    try
     191      LeftContacts := TContactsFile(DefaultDataFileClass.Create);
     192      RightContacts := TContactsFile(DefaultDataFileClass.Create);
     193      try
     194        LeftContacts.Assign(TContactsFile(DataFile));
     195        LeftSide := LeftContacts;
     196        RightContacts.LoadFromFile(OpenDialog1.FileName);
     197        RightSide := RightContacts;
     198        ShowModal;
     199      finally
     200        LeftContacts.Free;
     201        RightContacts.Free;
     202      end;
     203    finally
     204      Free;
     205    end;
    165206  end;
    166207end;
     
    553594  AFileSplit.Enabled := Assigned(DataFile);
    554595  AFileCombine.Enabled := Assigned(DataFile);
     596  AFileCompare.Enabled := Assigned(DataFile);
    555597  AFind.Enabled := Assigned(DataFile);
    556598  AFindDuplicate.Enabled := Assigned(DataFile);
Note: See TracChangeset for help on using the changeset viewer.