unit FormMerge;

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls,
  VCard, FormEx;

type

  { TFormMerge }

  TFormMerge = class(TFormEx)
    ButtonOk: TButton;
    ButtonCancel: TButton;
    ListView1: TListView;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure ListView1Data(Sender: TObject; Item: TListItem);
  private
    procedure ReloadList;
  public
    Source: TVCard;
    Merged: TVCard;
  end;

var
  FormMerge: TFormMerge;


implementation

{$R *.lfm}

{ TFormMerge }

procedure TFormMerge.FormCreate(Sender: TObject);
begin
  Source := TVCard.Create(nil);
  Merged := TVCard.Create(nil);
end;

procedure TFormMerge.FormDestroy(Sender: TObject);
begin
  FreeAndNil(Source);
  FreeAndNil(Merged);
end;

procedure TFormMerge.FormShow(Sender: TObject);
begin
  Merged.Assign(Source);
  //Merged.Merge;
  ReloadList;
end;

procedure TFormMerge.ListView1Data(Sender: TObject; Item: TListItem);
begin
  if Item.Index < Merged.Contacts.Count then
  with Merged.Contacts[Item.Index] do begin
    Item.Caption := IntToStr(Item.Index);
    //Item.SubItems.Add(TextLabel);
  end;
end;

procedure TFormMerge.ReloadList;
begin
  ListView1.Items.Count := Merged.Contacts.Count;
  ListView1.Refresh;
end;

end.
