Changeset 73 for trunk/Forms/UFormContacts.pas
- Timestamp:
- Dec 13, 2021, 11:33:11 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormContacts.pas
r72 r73 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, Menus, ActnList, UContact, UListViewSort, fgl, LazUTF8 ;9 ComCtrls, Menus, ActnList, UContact, UListViewSort, fgl, LazUTF8, Clipbrd; 10 10 11 11 type … … 16 16 AAdd: TAction; 17 17 AClone: TAction; 18 ACopy: TAction; 19 ACut: TAction; 20 APaste: TAction; 18 21 ALoadFromFile: TAction; 19 22 ASaveToFile: TAction; … … 26 29 ListViewSort1: TListViewSort; 27 30 MenuItem1: TMenuItem; 31 MenuItem10: TMenuItem; 32 MenuItem11: TMenuItem; 33 MenuItem12: TMenuItem; 28 34 MenuItem2: TMenuItem; 29 35 MenuItem3: TMenuItem; … … 33 39 MenuItem7: TMenuItem; 34 40 MenuItem8: TMenuItem; 41 MenuItem9: TMenuItem; 35 42 OpenDialog1: TOpenDialog; 36 43 PopupMenuContact: TPopupMenu; … … 47 54 procedure AAddExecute(Sender: TObject); 48 55 procedure ACloneExecute(Sender: TObject); 56 procedure ACopyExecute(Sender: TObject); 57 procedure ACutExecute(Sender: TObject); 49 58 procedure ALoadFromFileExecute(Sender: TObject); 50 59 procedure AModifyExecute(Sender: TObject); 60 procedure APasteExecute(Sender: TObject); 51 61 procedure ARemoveExecute(Sender: TObject); 52 62 procedure ASaveToFileExecute(Sender: TObject); … … 334 344 end; 335 345 346 procedure TFormContacts.ACopyExecute(Sender: TObject); 347 var 348 Text: string; 349 Strings: TStringList; 350 I: Integer; 351 begin 352 Strings := TStringList.Create; 353 try 354 Text := ''; 355 for I := 0 to ListView1.Items.Count - 1 do 356 if ListView1.Items[I].Selected then begin 357 TContact(ListView1.Items[I].Data).SaveToStrings(Strings); 358 Text := Text + Strings.Text; 359 end; 360 Clipboard.AsText := Text; 361 finally 362 Strings.Free; 363 end; 364 end; 365 366 procedure TFormContacts.ACutExecute(Sender: TObject); 367 var 368 Text: string; 369 Strings: TStringList; 370 I: Integer; 371 begin 372 Strings := TStringList.Create; 373 try 374 Text := ''; 375 for I := 0 to ListView1.Items.Count - 1 do 376 if ListView1.Items[I].Selected then begin 377 TContact(ListView1.Items[I].Data).SaveToStrings(Strings); 378 Text := Text + Strings.Text; 379 end; 380 Clipboard.AsText := Text; 381 for I := 0 to ListView1.Items.Count - 1 do 382 if ListView1.Items[I].Selected then begin 383 Contacts.Delete(Contacts.IndexOf(ListView1.Items[I].Data)); 384 end; 385 ReloadList; 386 ListView1.ClearSelection; 387 UpdateInterface; 388 finally 389 Strings.Free; 390 end; 391 end; 392 336 393 procedure TFormContacts.ALoadFromFileExecute(Sender: TObject); 337 394 var … … 384 441 end; 385 442 443 procedure TFormContacts.APasteExecute(Sender: TObject); 444 var 445 PasteContacts: TContactsFile; 446 Lines: TStringList; 447 begin 448 PasteContacts := TContactsFile.Create; 449 Lines := TStringList.Create; 450 try 451 Lines.Text := Clipboard.AsText; 452 PasteContacts.LoadFromStrings(Lines); 453 if PasteContacts.Contacts.Count > 0 then begin 454 if Assigned(ListView1.Selected) then begin 455 Contacts.InsertContacts(Contacts.IndexOf(ListView1.Selected.Data), 456 PasteContacts.Contacts); 457 end else Contacts.AddContacts(PasteContacts.Contacts); 458 Core.DataFile.Modified := True; 459 ReloadList; 460 UpdateInterface; 461 end; 462 finally 463 Lines.Free; 464 PasteContacts.Free; 465 end; 466 end; 467 386 468 procedure TFormContacts.ARemoveExecute(Sender: TObject); 387 469 var … … 393 475 for I := ListView1.Items.Count - 1 downto 0 do 394 476 if ListView1.Items[I].Selected then begin 395 Contacts.Delete( I);477 Contacts.Delete(Contacts.IndexOf(ListView1.Items[I].Data)); 396 478 end; 397 479 Core.DataFile.Modified := True;
Note:
See TracChangeset
for help on using the changeset viewer.