Ignore:
Timestamp:
Jan 26, 2018, 11:23:26 PM (7 years ago)
Author:
chronos
Message:
  • Added: Contact edit form.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore set to
      *.lrj
      heaptrclog.trc
      lib
      vCardStudio
      *.lps
      *.res
  • trunk/Forms

    • Property svn:ignore set to
      *.lrj
  • trunk/Forms/UFormContacts.pas

    r1 r2  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ComCtrls, UContact;
     9  ComCtrls, Menus, ActnList, UContact;
    1010
    1111type
     
    1414
    1515  TFormContacts = class(TForm)
     16    AAdd: TAction;
     17    ARemove: TAction;
     18    AModify: TAction;
     19    ActionList1: TActionList;
    1620    ListView1: TListView;
     21    MenuItem1: TMenuItem;
     22    MenuItem2: TMenuItem;
     23    MenuItem3: TMenuItem;
     24    PopupMenuContact: TPopupMenu;
     25    ToolBar1: TToolBar;
     26    ToolButton1: TToolButton;
     27    ToolButton2: TToolButton;
     28    ToolButton3: TToolButton;
     29    procedure AAddExecute(Sender: TObject);
     30    procedure AModifyExecute(Sender: TObject);
     31    procedure ARemoveExecute(Sender: TObject);
     32    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    1733    procedure FormShow(Sender: TObject);
    1834    procedure ListView1Data(Sender: TObject; Item: TListItem);
     35    procedure ListView1DblClick(Sender: TObject);
     36    procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
     37      Selected: Boolean);
    1938  private
    2039
     
    2241    Contacts: TContacts;
    2342    procedure ReloadList;
     43    procedure UpdateInterface;
    2444  end;
    2545
     
    2747  FormContacts: TFormContacts;
    2848
     49
    2950implementation
    3051
    3152{$R *.lfm}
     53
     54uses
     55  UFormContact, UCore;
    3256
    3357{ TFormContacts }
     
    4266end;
    4367
     68procedure TFormContacts.ListView1DblClick(Sender: TObject);
     69begin
     70  AModify.Execute;
     71end;
     72
     73procedure TFormContacts.ListView1SelectItem(Sender: TObject; Item: TListItem;
     74  Selected: Boolean);
     75begin
     76  UpdateInterface;
     77end;
     78
    4479procedure TFormContacts.FormShow(Sender: TObject);
    4580begin
     81  Core.PersistentForm1.Load(Self);
    4682  ReloadList;
     83  UpdateInterface;
     84end;
     85
     86procedure TFormContacts.AAddExecute(Sender: TObject);
     87var
     88  FormContact: TFormContact;
     89begin
     90  FormContact := TFormContact.Create(nil);
     91  if FormContact.ShowModal = mrOK then begin
     92    FormContact.SaveData(TContact(ListView1.Selected.Data));
     93    ReloadList;
     94    UpdateInterface;
     95  end;
     96  FormContact.Free;
     97end;
     98
     99procedure TFormContacts.AModifyExecute(Sender: TObject);
     100var
     101  FormContact: TFormContact;
     102begin
     103  FormContact := TFormContact.Create(nil);
     104  FormContact.LoadData(TContact(ListView1.Selected.Data));
     105  if FormContact.ShowModal = mrOK then begin
     106    FormContact.SaveData(TContact(ListView1.Selected.Data));
     107    ReloadList;
     108    UpdateInterface;
     109  end;
     110  FormContact.Free;
     111end;
     112
     113procedure TFormContacts.ARemoveExecute(Sender: TObject);
     114var
     115  I: Integer;
     116begin
     117  for I := ListView1.Items.Count - 1 downto 0 do
     118    if ListView1.Items[I].Selected then begin
     119      Contacts.Delete(I);
     120    end;
     121  UpdateInterface;
     122end;
     123
     124procedure TFormContacts.FormClose(Sender: TObject; var CloseAction: TCloseAction
     125  );
     126begin
     127  Core.PersistentForm1.Save(Self);
    47128end;
    48129
     
    55136end;
    56137
     138procedure TFormContacts.UpdateInterface;
     139begin
     140  AModify.Enabled := Assigned(ListView1.Selected);
     141  ARemove.Enabled := Assigned(ListView1.Selected);
     142end;
     143
    57144end.
    58145
Note: See TracChangeset for help on using the changeset viewer.