Changeset 51 for trunk/Forms/UFormContacts.pas
- Timestamp:
- Dec 3, 2021, 7:44:05 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormContacts.pas
r43 r51 15 15 TFormContacts = class(TForm) 16 16 AAdd: TAction; 17 AClone: TAction; 17 18 ASelectAll: TAction; 18 19 ARemove: TAction; … … 26 27 MenuItem3: TMenuItem; 27 28 MenuItem4: TMenuItem; 29 MenuItem5: TMenuItem; 28 30 PopupMenuContact: TPopupMenu; 29 31 StatusBar1: TStatusBar; … … 32 34 ToolButton2: TToolButton; 33 35 ToolButton3: TToolButton; 36 ToolButton4: TToolButton; 34 37 procedure AAddExecute(Sender: TObject); 38 procedure ACloneExecute(Sender: TObject); 35 39 procedure AModifyExecute(Sender: TObject); 36 40 procedure ARemoveExecute(Sender: TObject); … … 80 84 81 85 procedure TFormContacts.ListView1Data(Sender: TObject; Item: TListItem); 86 87 procedure AddItem(Text: string; IsCaption: Boolean = False); 88 begin 89 if IsCaption then begin 90 if Text <> '' then Item.Caption := Text 91 else Item.Caption := ' '; 92 end else begin 93 if Text <> '' then Item.SubItems.Add(Text) 94 else Item.SubItems.Add(' '); 95 end; 96 end; 97 82 98 begin 83 99 if Item.Index < ListViewSort1.List.Count then 84 100 with TContact(ListViewSort1.List[Item.Index]) do begin 85 Item.Caption := Fields[cfFullName]; 86 Item.SubItems.Add(Fields[cfFirstName]); 87 Item.SubItems.Add(Fields[cfMiddleName]); 88 Item.SubItems.Add(Fields[cfLastName]); 89 Item.SubItems.Add(Fields[cfTelCell]); 90 Item.SubItems.Add(Fields[cfTelHome]); 101 102 AddItem(Fields[cfFullName], True); 103 AddItem(Fields[cfFirstName]); 104 AddItem(Fields[cfMiddleName]); 105 AddItem(Fields[cfLastName]); 106 AddItem(Fields[cfTelCell]); 107 AddItem(Fields[cfTelHome]); 91 108 Item.Data := ListViewSort1.List[Item.Index]; 92 109 end; … … 228 245 if FormContact.ShowModal = mrOK then begin 229 246 Contacts.Add(Contact); 247 Core.DataFile.Modified := True; 248 ReloadList; 249 UpdateInterface; 250 Contact := nil; 251 end; 252 finally 253 if Assigned(Contact) then 254 Contact.Free; 255 end; 256 finally 257 FormContact.Free; 258 end; 259 end; 260 261 procedure TFormContacts.ACloneExecute(Sender: TObject); 262 var 263 FormContact: TFormContact; 264 Contact: TContact; 265 begin 266 FormContact := TFormContact.Create(nil); 267 try 268 Contact := TContact.Create; 269 try 270 Contact.Assign(TContact(ListView1.Selected.Data)); 271 FormContact.Contact := Contact; 272 FormContact.OnPrevious := FormContactPrevious; 273 FormContact.OnNext := FormContactNext; 274 if FormContact.ShowModal = mrOK then begin 275 Contacts.Add(Contact); 230 276 Contact := nil; 231 277 Core.DataFile.Modified := True; … … 250 296 try 251 297 Contact := TContact.Create; 252 Contact.Assign(TContact(ListView1.Selected.Data));253 FormContact.Contact := Contact;254 FormContact.OnPrevious := FormContactPrevious;255 FormContact.OnNext := FormContactNext;256 298 try 299 Contact.Assign(TContact(ListView1.Selected.Data)); 300 FormContact.Contact := Contact; 301 FormContact.OnPrevious := FormContactPrevious; 302 FormContact.OnNext := FormContactNext; 257 303 if FormContact.ShowModal = mrOK then begin 258 304 TContact(ListView1.Selected.Data).Assign(Contact);
Note:
See TracChangeset
for help on using the changeset viewer.