Changeset 2 for trunk/Forms/UFormContacts.pas
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:ignore
set to
*.lrj
heaptrclog.trc
lib
vCardStudio
*.lps
*.res
-
Property svn:ignore
set to
-
trunk/Forms
-
Property svn:ignore
set to
*.lrj
-
Property svn:ignore
set to
-
trunk/Forms/UFormContacts.pas
r1 r2 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, UContact;9 ComCtrls, Menus, ActnList, UContact; 10 10 11 11 type … … 14 14 15 15 TFormContacts = class(TForm) 16 AAdd: TAction; 17 ARemove: TAction; 18 AModify: TAction; 19 ActionList1: TActionList; 16 20 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); 17 33 procedure FormShow(Sender: TObject); 18 34 procedure ListView1Data(Sender: TObject; Item: TListItem); 35 procedure ListView1DblClick(Sender: TObject); 36 procedure ListView1SelectItem(Sender: TObject; Item: TListItem; 37 Selected: Boolean); 19 38 private 20 39 … … 22 41 Contacts: TContacts; 23 42 procedure ReloadList; 43 procedure UpdateInterface; 24 44 end; 25 45 … … 27 47 FormContacts: TFormContacts; 28 48 49 29 50 implementation 30 51 31 52 {$R *.lfm} 53 54 uses 55 UFormContact, UCore; 32 56 33 57 { TFormContacts } … … 42 66 end; 43 67 68 procedure TFormContacts.ListView1DblClick(Sender: TObject); 69 begin 70 AModify.Execute; 71 end; 72 73 procedure TFormContacts.ListView1SelectItem(Sender: TObject; Item: TListItem; 74 Selected: Boolean); 75 begin 76 UpdateInterface; 77 end; 78 44 79 procedure TFormContacts.FormShow(Sender: TObject); 45 80 begin 81 Core.PersistentForm1.Load(Self); 46 82 ReloadList; 83 UpdateInterface; 84 end; 85 86 procedure TFormContacts.AAddExecute(Sender: TObject); 87 var 88 FormContact: TFormContact; 89 begin 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; 97 end; 98 99 procedure TFormContacts.AModifyExecute(Sender: TObject); 100 var 101 FormContact: TFormContact; 102 begin 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; 111 end; 112 113 procedure TFormContacts.ARemoveExecute(Sender: TObject); 114 var 115 I: Integer; 116 begin 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; 122 end; 123 124 procedure TFormContacts.FormClose(Sender: TObject; var CloseAction: TCloseAction 125 ); 126 begin 127 Core.PersistentForm1.Save(Self); 47 128 end; 48 129 … … 55 136 end; 56 137 138 procedure TFormContacts.UpdateInterface; 139 begin 140 AModify.Enabled := Assigned(ListView1.Selected); 141 ARemove.Enabled := Assigned(ListView1.Selected); 142 end; 143 57 144 end. 58 145
Note:
See TracChangeset
for help on using the changeset viewer.