Changeset 73
- Timestamp:
- Dec 13, 2021, 11:33:11 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormContact.lfm
r71 r73 429 429 Anchors = [akTop, akLeft, akRight] 430 430 Caption = 'Address' 431 ClientHeight = 21 5432 ClientWidth = 9 20431 ClientHeight = 212 432 ClientWidth = 918 433 433 TabOrder = 6 434 434 object Label36: TLabel … … 573 573 object TabSheetWork: TTabSheet 574 574 Caption = 'Work' 575 ClientHeight = 6 28576 ClientWidth = 9 59575 ClientHeight = 630 576 ClientWidth = 961 577 577 OnHide = TabSheetWorkHide 578 578 OnShow = TabSheetWorkShow 579 579 object EditOrganization: TEdit 580 580 Left = 173 581 Height = 42581 Height = 33 582 582 Top = 64 583 583 Width = 254 … … 587 587 object LabelOrganization: TLabel 588 588 Left = 10 589 Height = 2 4589 Height = 25 590 590 Top = 70 591 Width = 1 14591 Width = 106 592 592 Caption = 'Organization:' 593 593 ParentColor = False … … 596 596 object LabelOrganization1: TLabel 597 597 Left = 451 598 Height = 2 4598 Height = 25 599 599 Top = 24 600 Width = 106600 Width = 99 601 601 Caption = 'Department:' 602 602 ParentColor = False … … 605 605 object EditDepartment: TEdit 606 606 Left = 608 607 Height = 42607 Height = 33 608 608 Top = 20 609 609 Width = 254 … … 613 613 object Label18: TLabel 614 614 Left = 10 615 Height = 2 4615 Height = 25 616 616 Top = 20 617 Width = 41617 Width = 36 618 618 Caption = 'Title:' 619 619 ParentColor = False … … 622 622 object EditTitle: TEdit 623 623 Left = 173 624 Height = 42624 Height = 33 625 625 Top = 16 626 626 Width = 254 … … 630 630 object EditWorkWeb: TEdit 631 631 Left = 173 632 Height = 42632 Height = 33 633 633 Top = 256 634 634 Width = 683 … … 638 638 object Label32: TLabel 639 639 Left = 10 640 Height = 2 4640 Height = 25 641 641 Top = 264 642 Width = 1 14642 Width = 107 643 643 Caption = 'Web address:' 644 644 ParentColor = False … … 651 651 Width = 911 652 652 Caption = 'Address' 653 ClientHeight = 2 20654 ClientWidth = 90 9653 ClientHeight = 217 654 ClientWidth = 907 655 655 TabOrder = 4 656 656 object Label31: TLabel 657 657 Left = 10 658 Height = 2 4658 Height = 25 659 659 Top = 160 660 Width = 71660 Width = 67 661 661 Caption = 'Country:' 662 662 ParentColor = False … … 665 665 object EditAddressWorkCountry: TEdit 666 666 Left = 173 667 Height = 42667 Height = 33 668 668 Top = 160 669 669 Width = 254 … … 673 673 object EditAddressWorkRegion: TEdit 674 674 Left = 173 675 Height = 42675 Height = 33 676 676 Top = 112 677 677 Width = 254 … … 681 681 object Label30: TLabel 682 682 Left = 10 683 Height = 2 4683 Height = 25 684 684 Top = 112 685 Width = 64685 Width = 59 686 686 Caption = 'Region:' 687 687 ParentColor = False … … 690 690 object Label35: TLabel 691 691 Left = 10 692 Height = 2 4692 Height = 25 693 693 Top = 66 694 Width = 1 37694 Width = 126 695 695 Caption = 'Extended street:' 696 696 ParentColor = False … … 699 699 object EditAddressWorkStreetExtended: TEdit 700 700 Left = 173 701 Height = 42701 Height = 33 702 702 Top = 64 703 703 Width = 254 … … 707 707 object Label28: TLabel 708 708 Left = 10 709 Height = 2 4709 Height = 25 710 710 Top = 18 711 Width = 54711 Width = 49 712 712 Caption = 'Street:' 713 713 ParentColor = False … … 716 716 object EditAddressWorkStreet: TEdit 717 717 Left = 173 718 Height = 42718 Height = 33 719 719 Top = 8 720 720 Width = 254 … … 724 724 object Label34: TLabel 725 725 Left = 451 726 Height = 2 4726 Height = 25 727 727 Top = 18 728 Width = 1 31728 Width = 122 729 729 Caption = 'Post office box:' 730 730 ParentColor = False … … 733 733 object EditAddressWorkPostOfficeBox: TEdit 734 734 Left = 608 735 Height = 42735 Height = 33 736 736 Top = 8 737 737 Width = 254 … … 741 741 object EditAddressWorkCity: TEdit 742 742 Left = 608 743 Height = 42743 Height = 33 744 744 Top = 56 745 745 Width = 254 … … 749 749 object Label29: TLabel 750 750 Left = 451 751 Height = 2 4751 Height = 25 752 752 Top = 64 753 Width = 3 6753 Width = 34 754 754 Caption = 'City:' 755 755 ParentColor = False … … 758 758 object EditAddressWorkPostalCode: TEdit 759 759 Left = 608 760 Height = 42760 Height = 33 761 761 Top = 142 762 762 Width = 254 … … 766 766 object Label33: TLabel 767 767 Left = 451 768 Height = 2 4768 Height = 25 769 769 Top = 150 770 Width = 103770 Width = 95 771 771 Caption = 'Postal code:' 772 772 ParentColor = False … … 776 776 object Label15: TLabel 777 777 Left = 10 778 Height = 2 4778 Height = 25 779 779 Top = 116 780 Width = 5 9780 Width = 54 781 781 Caption = 'Phone:' 782 782 ParentColor = False … … 785 785 object EditWorkPhone: TEdit 786 786 Left = 173 787 Height = 42787 Height = 33 788 788 Top = 112 789 789 Width = 254 … … 793 793 object Label16: TLabel 794 794 Left = 451 795 Height = 2 4795 Height = 25 796 796 Top = 112 797 Width = 34797 Width = 29 798 798 Caption = 'Fax:' 799 799 ParentColor = False … … 802 802 object EditWorkFax: TEdit 803 803 Left = 608 804 Height = 42804 Height = 33 805 805 Top = 112 806 806 Width = 254 … … 810 810 object EditWorkPager: TEdit 811 811 Left = 608 812 Height = 42812 Height = 33 813 813 Top = 156 814 814 Width = 254 … … 818 818 object Label17: TLabel 819 819 Left = 448 820 Height = 2 4820 Height = 25 821 821 Top = 160 822 Width = 54822 Width = 48 823 823 Caption = 'Pager:' 824 824 ParentColor = False … … 827 827 object EditWorkMobile: TEdit 828 828 Left = 173 829 Height = 42829 Height = 33 830 830 Top = 160 831 831 Width = 254 … … 835 835 object Label19: TLabel 836 836 Left = 10 837 Height = 2 4837 Height = 25 838 838 Top = 160 839 Width = 63839 Width = 59 840 840 Caption = 'Mobile:' 841 841 ParentColor = False … … 844 844 object Label8: TLabel 845 845 Left = 10 846 Height = 2 4846 Height = 25 847 847 Top = 210 848 Width = 5 8848 Width = 53 849 849 Caption = 'E-mail:' 850 850 ParentColor = False … … 853 853 object EditWorkEmail: TEdit 854 854 Left = 173 855 Height = 42855 Height = 33 856 856 Top = 210 857 857 Width = 254 -
trunk/Forms/UFormContacts.lfm
r72 r73 149 149 Action = ASelectAll 150 150 end 151 object MenuItem12: TMenuItem 152 Caption = '-' 153 end 154 object MenuItem9: TMenuItem 155 Action = ACut 156 end 157 object MenuItem10: TMenuItem 158 Action = ACopy 159 end 160 object MenuItem11: TMenuItem 161 Action = APaste 162 end 151 163 object MenuItem6: TMenuItem 152 164 Caption = '-' … … 201 213 OnExecute = ASaveToFileExecute 202 214 end 215 object ACopy: TAction 216 Caption = 'Copy' 217 ImageIndex = 11 218 OnExecute = ACopyExecute 219 ShortCut = 16451 220 end 221 object ACut: TAction 222 Caption = 'Cut' 223 ImageIndex = 12 224 OnExecute = ACutExecute 225 ShortCut = 16472 226 end 227 object APaste: TAction 228 Caption = 'Paste' 229 ImageIndex = 13 230 OnExecute = APasteExecute 231 ShortCut = 16470 232 end 203 233 end 204 234 object ListViewSort1: TListViewSort -
trunk/Forms/UFormContacts.lrj
r72 r73 15 15 {"hash":4863557,"name":"tformcontacts.aclone.caption","sourcebytes":[67,108,111,110,101],"value":"Clone"}, 16 16 {"hash":177113358,"name":"tformcontacts.aloadfromfile.caption","sourcebytes":[76,111,97,100,32,102,114,111,109,32,102,105,108,101,46,46,46],"value":"Load from file..."}, 17 {"hash":10127854,"name":"tformcontacts.asavetofile.caption","sourcebytes":[83,97,118,101,32,116,111,32,102,105,108,101,46,46,46],"value":"Save to file..."} 17 {"hash":10127854,"name":"tformcontacts.asavetofile.caption","sourcebytes":[83,97,118,101,32,116,111,32,102,105,108,101,46,46,46],"value":"Save to file..."}, 18 {"hash":304761,"name":"tformcontacts.acopy.caption","sourcebytes":[67,111,112,121],"value":"Copy"}, 19 {"hash":19140,"name":"tformcontacts.acut.caption","sourcebytes":[67,117,116],"value":"Cut"}, 20 {"hash":5671589,"name":"tformcontacts.apaste.caption","sourcebytes":[80,97,115,116,101],"value":"Paste"} 18 21 ]} -
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; -
trunk/Forms/UFormFindDuplicity.lfm
r23 r73 1 1 object FormFindDuplicity: TFormFindDuplicity 2 2 Left = 455 3 Height = 4814 Top = 3 975 Width = 7013 Height = 523 4 Top = 355 5 Width = 807 6 6 Caption = 'Find duplicities' 7 ClientHeight = 4818 ClientWidth = 7017 ClientHeight = 523 8 ClientWidth = 807 9 9 DesignTimePPI = 144 10 10 OnClose = FormClose … … 15 15 object ListView1: TListView 16 16 Left = 5 17 Height = 4 1317 Height = 455 18 18 Top = 63 19 Width = 69119 Width = 797 20 20 Align = alClient 21 21 BorderSpacing.Around = 5 … … 47 47 Height = 58 48 48 Top = 0 49 Width = 70149 Width = 807 50 50 Align = alTop 51 51 BevelOuter = bvNone 52 52 ClientHeight = 58 53 ClientWidth = 70153 ClientWidth = 807 54 54 ParentFont = False 55 55 TabOrder = 1 56 56 object ComboBoxField: TComboBox 57 Left = 1 7358 Height = 4159 Top = 1 457 Left = 160 58 Height = 33 59 Top = 16 60 60 Width = 326 61 ItemHeight = 061 ItemHeight = 25 62 62 OnChange = ComboBoxFieldChange 63 63 ParentFont = False … … 67 67 object Label1: TLabel 68 68 Left = 13 69 Height = 2 469 Height = 25 70 70 Top = 19 71 Width = 1 1172 Caption = ' Contact field:'71 Width = 125 72 Caption = 'By contact field:' 73 73 ParentColor = False 74 74 ParentFont = False 75 end 76 object ButtonMerge: TButton 77 Left = 496 78 Height = 38 79 Top = 14 80 Width = 113 81 Caption = 'Merge' 82 OnClick = ButtonMergeClick 83 TabOrder = 1 75 84 end 76 85 end -
trunk/Forms/UFormFindDuplicity.lrj
r21 r73 4 4 {"hash":106593811,"name":"tformfindduplicity.listview1.columns[1].caption","sourcebytes":[67,111,110,116,97,99,116,115],"value":"Contacts"}, 5 5 {"hash":4877396,"name":"tformfindduplicity.listview1.columns[2].caption","sourcebytes":[67,111,117,110,116],"value":"Count"}, 6 {"hash":9821370,"name":"tformfindduplicity.label1.caption","sourcebytes":[67,111,110,116,97,99,116,32,102,105,101,108,100,58],"value":"Contact field:"}, 6 {"hash":14454458,"name":"tformfindduplicity.label1.caption","sourcebytes":[66,121,32,99,111,110,116,97,99,116,32,102,105,101,108,100,58],"value":"By contact field:"}, 7 {"hash":5490901,"name":"tformfindduplicity.buttonmerge.caption","sourcebytes":[77,101,114,103,101],"value":"Merge"}, 7 8 {"hash":229436515,"name":"tformfindduplicity.ashowcontacts.caption","sourcebytes":[83,104,111,119,32,99,111,110,116,97,99,116,115],"value":"Show contacts"} 8 9 ]} -
trunk/Forms/UFormFindDuplicity.pas
r68 r73 31 31 AShowContacts: TAction; 32 32 ActionList1: TActionList; 33 ButtonMerge: TButton; 33 34 ComboBoxField: TComboBox; 34 35 Label1: TLabel; … … 38 39 PopupMenu1: TPopupMenu; 39 40 procedure AShowContactsExecute(Sender: TObject); 41 procedure ButtonMergeClick(Sender: TObject); 40 42 procedure ComboBoxFieldChange(Sender: TObject); 41 43 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); … … 109 111 var 110 112 ContactField: TContactField; 113 Items: TStringList; 114 I: Integer; 111 115 begin 112 116 if FContacts = AValue then Exit; 113 117 FContacts := AValue; 114 118 if Assigned(FContacts) then begin 115 Contacts.ContactsFile.Fields.LoadToStrings(ComboBoxField.Items); 119 Items := TStringList.Create; 120 try 121 Contacts.ContactsFile.Fields.LoadToStrings(Items); 122 123 // Remove fields which are not used in contacts 124 for I := Items.Count - 1 downto 0 do 125 if Contacts.CountByField(TContactField(Items.Objects[I]).Index) = 0 then 126 Items.Delete(I); 127 128 ComboBoxField.Items.Assign(Items); 129 finally 130 Items.Free; 131 end; 116 132 ContactField := Contacts.ContactsFile.Fields.GetByIndex(ContactFieldIndex); 117 133 ComboBoxField.ItemIndex := ComboBoxField.Items.IndexOfObject(ContactField); … … 156 172 Core.Translator.TranslateComponentRecursive(Self); 157 173 Core.ThemeManager1.UseTheme(Self); 158 ContactFieldIndex := cf TelCell;174 ContactFieldIndex := cfFullName; 159 175 end; 160 176 … … 203 219 end; 204 220 221 procedure TFormFindDuplicity.ButtonMergeClick(Sender: TObject); 222 var 223 TempContacts: TContactsFile; 224 I: Integer; 225 begin 226 TempContacts := TContactsFile.Create; 227 try 228 for I := 0 to Contacts.Count - 1 do 229 TempContacts.Contacts.Merge(Contacts[I], TContactField(ComboBoxField.Items.Objects[ComboBoxField.ItemIndex]).Index); 230 Contacts.Assign(TempContacts.Contacts); 231 Find; 232 finally 233 TempContacts.Free; 234 end; 235 end; 236 205 237 procedure TFormFindDuplicity.FormClose(Sender: TObject; 206 238 var CloseAction: TCloseAction); -
trunk/Forms/UFormMain.lfm
r62 r73 136 136 end 137 137 object MenuItem3: TMenuItem 138 Action = Core.AFile Merge138 Action = Core.AFileCombine 139 139 end 140 140 object MenuItem6: TMenuItem -
trunk/Forms/UFormProperties.pas
r72 r73 314 314 for I := ListView1.Items.Count - 1 downto 0 do 315 315 if ListView1.Items[I].Selected then begin 316 Properties.Delete( I);316 Properties.Delete(Properties.IndexOf(ListView1.Items[I].Data)); 317 317 end; 318 318 Core.DataFile.Modified := True; -
trunk/Languages/vCardStudio.cs.po
r72 r73 24 24 msgstr "Zavřít" 25 25 26 #: tcore.afile merge.caption27 msgid " Merge..."26 #: tcore.afilecombine.caption 27 msgid "Combine..." 28 28 msgstr "Sloučit..." 29 29 … … 472 472 msgstr "Klonovat" 473 473 474 #: tformcontacts.acopy.caption 475 msgid "Copy" 476 msgstr "Kopírovat" 477 478 #: tformcontacts.acut.caption 479 msgid "Cut" 480 msgstr "Vyříznout" 481 474 482 #: tformcontacts.aloadfromfile.caption 475 483 msgctxt "tformcontacts.aloadfromfile.caption" … … 482 490 msgstr "Upravit" 483 491 492 #: tformcontacts.apaste.caption 493 msgid "Paste" 494 msgstr "Vložit" 495 484 496 #: tformcontacts.aremove.caption 485 497 msgctxt "tformcontacts.aremove.caption" … … 550 562 msgstr "Ukázat kontakty" 551 563 564 #: tformfindduplicity.buttonmerge.caption 565 msgid "Merge" 566 msgstr "Sloučit" 567 552 568 #: tformfindduplicity.caption 553 569 msgctxt "tformfindduplicity.caption" … … 556 572 557 573 #: tformfindduplicity.label1.caption 558 msgid " Contact field:"559 msgstr "Po le kontaktu:"574 msgid "By contact field:" 575 msgstr "Podle pole kontaktu:" 560 576 561 577 #: tformfindduplicity.listview1.columns[0].caption … … 1097 1113 msgstr "Soubor byl upraven. Chcete jej uložit před ukončením?" 1098 1114 1115 #: ucore.scombinedcontacts 1116 msgctxt "ucore.scombinedcontacts" 1117 msgid "Combined %d contact files." 1118 msgstr "Sloučeno %d souborů kontaktů." 1119 1099 1120 #: ucore.sfilenotfound 1100 1121 msgid "File '%s' not found." … … 1112 1133 msgid "Line %d: %s" 1113 1134 msgstr "Řádek %d: %s" 1114 1115 #: ucore.smergedcontacts1116 msgid "Contacts merged. Loaded: %d, New: %d, Updated: %d"1117 msgstr "Kontakty sloučeny. Načteno: %d, Nových: %d, Aktualizovaných: %d"1118 1135 1119 1136 #: udatafile.sallfiles … … 1197 1214 msgid "Invalid line length for encoded text" 1198 1215 msgstr "Neplatná délka řádky kódovaného textu" 1199 -
trunk/Languages/vCardStudio.po
r72 r73 14 14 msgstr "" 15 15 16 #: tcore.afile merge.caption17 msgid " Merge..."16 #: tcore.afilecombine.caption 17 msgid "Combine..." 18 18 msgstr "" 19 19 … … 462 462 msgstr "" 463 463 464 #: tformcontacts.acopy.caption 465 msgid "Copy" 466 msgstr "" 467 468 #: tformcontacts.acut.caption 469 msgid "Cut" 470 msgstr "" 471 464 472 #: tformcontacts.aloadfromfile.caption 465 473 msgctxt "tformcontacts.aloadfromfile.caption" … … 472 480 msgstr "" 473 481 482 #: tformcontacts.apaste.caption 483 msgid "Paste" 484 msgstr "" 485 474 486 #: tformcontacts.aremove.caption 475 487 msgctxt "tformcontacts.aremove.caption" … … 540 552 msgstr "" 541 553 554 #: tformfindduplicity.buttonmerge.caption 555 msgid "Merge" 556 msgstr "" 557 542 558 #: tformfindduplicity.caption 543 559 msgctxt "tformfindduplicity.caption" … … 546 562 547 563 #: tformfindduplicity.label1.caption 548 msgid " Contact field:"564 msgid "By contact field:" 549 565 msgstr "" 550 566 … … 1085 1101 msgstr "" 1086 1102 1103 #: ucore.scombinedcontacts 1104 msgctxt "ucore.scombinedcontacts" 1105 msgid "Combined %d contact files." 1106 msgstr "" 1107 1087 1108 #: ucore.sfilenotfound 1088 1109 msgid "File '%s' not found." … … 1099 1120 #: ucore.sline 1100 1121 msgid "Line %d: %s" 1101 msgstr ""1102 1103 #: ucore.smergedcontacts1104 msgid "Contacts merged. Loaded: %d, New: %d, Updated: %d"1105 1122 msgstr "" 1106 1123 -
trunk/UContact.pas
r72 r73 93 93 94 94 TContactProperties = class(TFPGObjectList<TContactProperty>) 95 procedure Assign(Source: TContactProperties); 95 96 procedure AssignToList(List: TFPGObjectList<TObject>); 96 97 function GetByName(Name: string): TContactProperty; … … 110 111 Properties: TContactProperties; 111 112 Parent: TContactsFile; 113 function HasField(FieldIndex: TContactFieldIndex): Boolean; 112 114 function FullNameToFileName: string; 113 115 function GetProperty(Field: TContactField): TContactProperty; overload; … … 128 130 TContacts = class(TFPGObjectList<TContact>) 129 131 ContactsFile: TContactsFile; 132 procedure Assign(Source: TContacts); 133 procedure AddContacts(Contacts: TContacts); 134 procedure InsertContacts(Index: Integer; Contacts: TContacts); 130 135 procedure AssignToList(List: TFPGObjectList<TObject>); 131 136 function AddNew: TContact; 132 function Search(FullName: string): TContact; 137 function Search(Text: string; FieldIndex: TContactFieldIndex): TContact; 138 function CountByField(FieldIndex: TContactFieldIndex): Integer; 139 procedure Merge(Contact: TContact; FieldIndex: TContactFieldIndex); 133 140 function ToString: ansistring; override; 134 141 end; … … 148 155 function GetFileExt: string; override; 149 156 function GetFileFilter: string; override; 157 procedure SaveToStrings(Output: TStrings); 158 procedure LoadFromStrings(Lines: TStrings); 150 159 procedure SaveToFile(FileName: string); override; 151 160 procedure LoadFromFile(FileName: string); override; … … 388 397 { TContactProperties } 389 398 399 procedure TContactProperties.Assign(Source: TContactProperties); 400 var 401 I: Integer; 402 begin 403 while Count < Source.Count do 404 Add(TContactProperty.Create); 405 while Count > Source.Count do 406 Delete(Count - 1); 407 for I := 0 to Count - 1 do 408 Items[I].Assign(Source.Items[I]); 409 end; 410 390 411 procedure TContactProperties.AssignToList(List: TFPGObjectList<TObject>); 391 412 var … … 579 600 { TContacts } 580 601 602 procedure TContacts.Assign(Source: TContacts); 603 var 604 I: Integer; 605 begin 606 while Count < Source.Count do 607 Add(TContact.Create); 608 while Count > Source.Count do 609 Delete(Count - 1); 610 for I := 0 to Count - 1 do begin 611 Items[I].Assign(Source.Items[I]); 612 Items[I].Parent := ContactsFile; 613 end; 614 end; 615 616 procedure TContacts.AddContacts(Contacts: TContacts); 617 var 618 I: Integer; 619 NewContact: TContact; 620 begin 621 for I := 0 to Contacts.Count - 1 do begin 622 NewContact := TContact.Create; 623 NewContact.Assign(Contacts[I]); 624 NewContact.Parent := ContactsFile; 625 Add(NewContact); 626 end; 627 end; 628 629 procedure TContacts.InsertContacts(Index: Integer; Contacts: TContacts); 630 var 631 I: Integer; 632 NewContact: TContact; 633 begin 634 for I := 0 to Contacts.Count - 1 do begin 635 NewContact := TContact.Create; 636 NewContact.Assign(Contacts[I]); 637 NewContact.Parent := ContactsFile; 638 Insert(Index, NewContact); 639 Inc(Index); 640 end; 641 end; 642 581 643 procedure TContacts.AssignToList(List: TFPGObjectList<TObject>); 582 644 var … … 596 658 end; 597 659 598 function TContacts.Search( FullName: string): TContact;599 var 600 Contact: TContact;660 function TContacts.Search(Text: string; FieldIndex: TContactFieldIndex): TContact; 661 var 662 I: Integer; 601 663 begin 602 664 Result := nil; 603 for Contact in Selfdo604 if Contact.Fields[cfFullName] = FullNamethen begin605 Result := Contact;665 for I := 0 to Count - 1 do 666 if Items[I].Fields[FieldIndex] = Text then begin 667 Result := Items[I]; 606 668 Break; 607 669 end; 670 end; 671 672 function TContacts.CountByField(FieldIndex: TContactFieldIndex): Integer; 673 var 674 I: Integer; 675 begin 676 Result := 0; 677 for I := 0 to Count - 1 do 678 if Items[I].HasField(FieldIndex) then 679 Inc(Result); 680 end; 681 682 procedure TContacts.Merge(Contact: TContact; FieldIndex: TContactFieldIndex); 683 var 684 NewContact: TContact; 685 begin 686 NewContact := Search(Contact.Fields[FieldIndex], FieldIndex); 687 if Assigned(NewContact) then begin 688 NewContact.UpdateFrom(Contact); 689 end else begin 690 NewContact := TContact.Create; 691 NewContact.Assign(Contact); 692 NewContact.Parent := ContactsFile; 693 Add(NewContact); 694 end; 608 695 end; 609 696 … … 741 828 end; 742 829 830 function TContact.HasField(FieldIndex: TContactFieldIndex): Boolean; 831 var 832 Field: TContactField; 833 begin 834 if not Assigned(Parent) then raise Exception.Create(SContactHasNoParent); 835 Field := Parent.Fields.GetByIndex(FieldIndex); 836 if Assigned(Field) then begin 837 Result := Assigned(GetProperty(Field)); 838 end else raise Exception.Create(SFieldIndexNotDefined); 839 end; 840 743 841 function TContact.FullNameToFileName: string; 744 842 var … … 778 876 779 877 procedure TContact.Assign(Source: TContact); 780 var 781 I: Integer; 782 begin 783 while Properties.Count < Source.Properties.Count do 784 Properties.Add(TContactProperty.Create); 785 while Properties.Count > Source.Properties.Count do 786 Properties.Delete(Properties.Count - 1); 787 for I := 0 to Properties.Count - 1 do 788 Properties[I].Assign(Source.Properties[I]); 878 begin 879 Properties.Assign(Source.Properties); 789 880 end; 790 881 … … 1114 1205 end; 1115 1206 1207 procedure TContactsFile.SaveToStrings(Output: TStrings); 1208 var 1209 I: Integer; 1210 begin 1211 for I := 0 to Contacts.Count - 1 do 1212 Contacts[I].SaveToStrings(Output); 1213 end; 1214 1215 procedure TContactsFile.LoadFromStrings(Lines: TStrings); 1216 var 1217 Contact: TContact; 1218 I: Integer; 1219 NewI: Integer; 1220 begin 1221 Contacts.Clear; 1222 1223 I := 0; 1224 while I < Lines.Count do begin 1225 Contact := TContact.Create; 1226 Contact.Parent := Self; 1227 NewI := Contact.LoadFromStrings(Lines, I); 1228 if NewI <= Lines.Count then begin 1229 if NewI <> -1 then begin 1230 Contacts.Add(Contact); 1231 I := NewI; 1232 end else begin 1233 FreeAndNil(Contact); 1234 Inc(I); 1235 end; 1236 end else begin 1237 FreeAndNil(Contact); 1238 Break; 1239 end; 1240 end; 1241 end; 1242 1116 1243 function TContactsFile.NewItem(Key, Value: string): string; 1117 1244 var … … 1125 1252 procedure TContactsFile.SaveToFile(FileName: string); 1126 1253 var 1127 Output: TStringList; 1128 I: Integer; 1254 Lines: TStringList; 1129 1255 begin 1130 1256 inherited; 1131 Output:= TStringList.Create;1257 Lines := TStringList.Create; 1132 1258 try 1133 for I := 0 to Contacts.Count - 1 do 1134 Contacts[I].SaveToStrings(Output); 1135 Output.SaveToFile(FileName); 1259 SaveToStrings(Lines); 1260 Lines.SaveToFile(FileName); 1136 1261 finally 1137 Output.Free;1262 Lines.Free; 1138 1263 end 1139 1264 end; … … 1142 1267 var 1143 1268 Lines: TStringList; 1144 Contact: TContact;1145 I: Integer;1146 NewI: Integer;1147 1269 begin 1148 1270 inherited; 1149 Contacts.Clear;1150 1271 Lines := TStringList.Create; 1151 1272 Lines.LoadFromFile(FileName); … … 1159 1280 {$ENDIF} 1160 1281 try 1161 I := 0; 1162 while I < Lines.Count do begin 1163 Contact := TContact.Create; 1164 Contact.Parent := Self; 1165 NewI := Contact.LoadFromStrings(Lines, I); 1166 if NewI <= Lines.Count then begin 1167 if NewI <> -1 then begin 1168 Contacts.Add(Contact); 1169 I := NewI; 1170 end else begin 1171 FreeAndNil(Contact); 1172 Inc(I); 1173 end; 1174 end else begin 1175 FreeAndNil(Contact); 1176 Break; 1177 end; 1178 end; 1282 LoadFromStrings(Lines); 1179 1283 finally 1180 1284 Lines.Free; -
trunk/UCore.lfm
r66 r73 12 12 Top = 202 13 13 Bitmap = { 14 4C690 C000000100000001000000000000000000000000000000000000000000014 4C690E0000001000000010000000000000000000000000000000000000000000 15 15 0000000000000000000000000000000000000000000000000000000000000000 16 16 0000000000000000000000000000000000000000000000000000000000000000 … … 396 396 00FF840000FF840000FF840000FF000000000000000000000000000000000000 397 397 0000000000000000000000000000000000000000000000000000000000000000 398 0000000000000000000000000000 398 0000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 399 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 400 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 401 FF00000000FFFFFFFF00FFFFFF00FFFFFF00000000FFFFFFFF00FFFFFF00FFFF 402 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 403 FF00000000FFFFFFFF00FFFFFF00FFFFFF00000000FFFFFFFF00FFFFFF00FFFF 404 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 405 FF00000000FFFFFFFF00FFFFFF00FFFFFF00000000FFFFFFFF00FFFFFF00FFFF 406 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 407 FF00000000FF000000FFFFFFFF00000000FF000000FFFFFFFF00FFFFFF00FFFF 408 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 409 FF00FFFFFF00000000FFFFFFFF00000000FFFFFFFF00FFFFFF00FFFFFF00FFFF 410 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 411 FF00FFFFFF00000000FF000000FF000000FFFFFFFF00FFFFFF00FFFFFF00FFFF 412 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 413 FF00FFFFFF00FFFFFF00000000FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 414 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 415 FF00FFFFFF00800000FF000000FF800000FFFFFFFF00FFFFFF00FFFFFF00FFFF 416 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 417 FF00FFFFFF00800000FFFFFFFF00800000FF800000FF800000FFFFFFFF00FFFF 418 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF008000 419 00FF800000FF800000FFFFFFFF00800000FFFFFFFF00FFFFFF00800000FFFFFF 420 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00800000FFFFFF 421 FF00FFFFFF00800000FFFFFFFF00800000FFFFFFFF00FFFFFF00800000FFFFFF 422 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00800000FFFFFF 423 FF00FFFFFF00800000FFFFFFFF00800000FFFFFFFF00FFFFFF00800000FFFFFF 424 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00800000FFFFFF 425 FF00FFFFFF00800000FFFFFFFF00FFFFFF00800000FF800000FFFFFFFF00FFFF 426 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF008000 427 00FF800000FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 428 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 429 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 430 FF00FFFFFF00FFFFFF00FFFFFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 431 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 432 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 433 FF00000000FF000000FF000000FF000000FFFF00FF00FF00FF00FF00FF00FF00 434 FF00FF00FF00FF00FF00FF00FF00FF00FF00000000FF000000FF000000FF0000 435 00FF000000FF00FFFFFF00FFFFFF000000FF000000FF000000FF000000FF0000 436 00FFFF00FF00FF00FF00FF00FF00000000FF008484FF848484FF008484FF0000 437 00FF00FFFFFF000000FF000000FF00FFFFFF000000FF848484FF008484FF8484 438 84FF000000FFFF00FF00FF00FF00000000FF848484FF848484FF000000FFFF00 439 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00000000FF848484FF0084 440 84FF000000FFFF00FF00FF00FF00000000FF008484FF848484FF000000FF0000 441 00FF000000FF000000FF000000FF000000FF000000FF000000FF848484FF8484 442 84FF000000FFFF00FF00FF00FF00000000FF848484FF008484FF848484FF0084 443 84FF848484FF008484FF848484FF008484FF848484FF008484FF848484FF0084 444 84FF000000FFFF00FF00FF00FF00000000FF008484FF848484FF008484FF8484 445 84FF008484FF840000FF840000FF840000FF840000FF840000FF840000FF8400 446 00FF000000FFFF00FF00FF00FF00000000FF848484FF008484FF848484FF0084 447 84FF848484FF840000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8400 448 00FF840000FFFF00FF00FF00FF00000000FF008484FF848484FF008484FF8484 449 84FF008484FF840000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8400 450 00FFFFFFFFFF840000FFFF00FF00000000FF848484FF008484FF848484FF0084 451 84FF848484FF840000FFFFFFFFFF000000FF000000FF000000FFFFFFFFFF8400 452 00FF840000FF840000FF840000FF000000FF008484FF848484FF008484FF8484 453 84FF008484FF840000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 454 FFFFFFFFFFFFFFFFFFFF840000FF000000FF848484FF008484FF848484FF0084 455 84FF848484FF840000FFFFFFFFFF000000FF000000FF000000FF000000FF0000 456 00FF000000FFFFFFFFFF840000FFFF00FF00000000FF000000FF000000FF0000 457 00FF000000FF840000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 458 FFFFFFFFFFFFFFFFFFFF840000FFFF00FF00FF00FF00FF00FF00FF00FF00FF00 459 FF00FF00FF00840000FF840000FF840000FF840000FF840000FF840000FF8400 460 00FF840000FF840000FF840000FFFF00FF00FF00FF00FF00FF00FF00FF00FF00 461 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 462 FF00FF00FF00FF00FF00FF00FF00 399 463 } 400 464 end … … 461 525 OnExecute = ASettingsExecute 462 526 end 463 object AFile Merge: TAction527 object AFileCombine: TAction 464 528 Category = 'File' 465 Caption = ' Merge...'466 OnExecute = AFile MergeExecute529 Caption = 'Combine...' 530 OnExecute = AFileCombineExecute 467 531 end 468 532 object AFindDuplicate: TAction -
trunk/UCore.lrj
r72 r73 10 10 {"hash":58140853,"name":"tcore.ahomepage.caption","sourcebytes":[72,111,109,101,32,112,97,103,101],"value":"Home page"}, 11 11 {"hash":213582195,"name":"tcore.asettings.caption","sourcebytes":[83,101,116,116,105,110,103,115],"value":"Settings"}, 12 {"hash": 210601534,"name":"tcore.afilemerge.caption","sourcebytes":[77,101,114,103,101,46,46,46],"value":"Merge..."},12 {"hash":151054142,"name":"tcore.afilecombine.caption","sourcebytes":[67,111,109,98,105,110,101,46,46,46],"value":"Combine..."}, 13 13 {"hash":168802467,"name":"tcore.afindduplicate.caption","sourcebytes":[70,105,110,100,32,100,117,112,108,105,99,105,116,105,101,115],"value":"Find duplicities"}, 14 14 {"hash":245221587,"name":"tcore.agenerate.caption","sourcebytes":[71,101,110,101,114,97,116,101,32,99,111,110,116,97,99,116,115],"value":"Generate contacts"}, -
trunk/UCore.pas
r72 r73 11 11 12 12 type 13 14 { TMergeResult }15 16 TMergeResult = record17 Loaded: Integer;18 New: Integer;19 Updated: Integer;20 procedure Clear;21 class operator Add(const A, B: TMergeResult): TMergeResult;22 end;23 13 24 14 { TCore } … … 30 20 AGenerate: TAction; 31 21 AFindDuplicate: TAction; 32 AFile Merge: TAction;22 AFileCombine: TAction; 33 23 ASettings: TAction; 34 24 AFileOpenRecent: TAction; … … 53 43 procedure AAboutExecute(Sender: TObject); 54 44 procedure AExitExecute(Sender: TObject); 55 procedure AFile MergeExecute(Sender: TObject);45 procedure AFileCombineExecute(Sender: TObject); 56 46 procedure AFileNewExecute(Sender: TObject); 57 47 procedure AFileOpenExecute(Sender: TObject); … … 95 85 procedure FileOpen(FileName: string); 96 86 procedure FileClose; 97 function FileMerge(FileName: string): TMergeResult;98 87 procedure Initialize; 99 88 procedure UpdateInterface; … … 118 107 SFileSplitFinishedOpenDirectory = 'Total %d contact files saved. Do you want to open the directory %s?'; 119 108 SFileNotFound = 'File ''%s'' not found.'; 120 S MergedContacts = 'Contacts merged. Loaded: %d, New: %d, Updated: %d';109 SCombinedContacts = 'Combined %d contact files.'; 121 110 SLine = 'Line %d: %s'; 122 111 123 { TMergeResult }124 125 procedure TMergeResult.Clear;126 begin127 Loaded := 0;128 New := 0;129 Updated := 0;130 end;131 132 class operator TMergeResult.Add(const A, B: TMergeResult): TMergeResult;133 begin134 Result.Loaded := A.Loaded + B.Loaded;135 Result.New := A.New + B.New;136 Result.Updated := A.Updated + B.Updated;137 end;138 139 112 { TCore } 140 113 … … 144 117 end; 145 118 146 procedure TCore.AFile MergeExecute(Sender: TObject);119 procedure TCore.AFileCombineExecute(Sender: TObject); 147 120 var 148 121 TempFile: TDataFile; 149 122 I: Integer; 150 MergeResult: TMergeResult; 151 TotalMergeResult: TMergeResult; 123 LoadedFiles: Integer; 152 124 begin 153 125 TempFile := DefaultDataFileClass.Create; … … 164 136 OpenDialog1.Options := OpenDialog1.Options + [ofAllowMultiSelect]; 165 137 if OpenDialog1.Execute then begin 166 TotalMergeResult.Clear;138 LoadedFiles := 0; 167 139 for I := 0 to OpenDialog1.Files.Count - 1 do begin 168 MergeResult := FileMerge(OpenDialog1.Files[I]); 169 TotalMergeResult := TotalMergeResult + MergeResult; 140 if FileExists(OpenDialog1.Files[I]) then begin 141 TempFile := TContactsFile.Create; 142 try 143 TempFile.LoadFromFile(OpenDialog1.Files[I]); 144 TContactsFile(DataFile).Contacts.AddContacts(TContactsFile(TempFile).Contacts); 145 Inc(LoadedFiles); 146 finally 147 TempFile.Free; 148 end; 149 end; 170 150 end; 171 ShowMessage(Format(SMergedContacts, [TotalMergeResult.Loaded,172 TotalMergeResult.New, TotalMergeResult.Updated]));151 if LoadedFiles > 0 then TContactsFile(DataFile).Modified := True; 152 ShowMessage(Format(SCombinedContacts, [LoadedFiles])); 173 153 UpdateFile; 174 154 end; … … 411 391 end; 412 392 413 function TCore.FileMerge(FileName: string): TMergeResult;414 var415 TempFile: TContactsFile;416 NewContact: TContact;417 I: Integer;418 begin419 Result.Clear;420 if FileExists(FileName) then begin421 TempFile := TContactsFile.Create;422 try423 TempFile.LoadFromFile(FileName);424 Result.Loaded := TempFile.Contacts.Count;425 for I := 0 to TempFile.Contacts.Count - 1 do begin426 NewContact := TContactsFile(DataFile).Contacts.Search(TempFile.Contacts[I].Fields[cfFullName]);427 if not Assigned(NewContact) then begin428 NewContact := TContact.Create;429 NewContact.Assign(TempFile.Contacts[I]);430 NewContact.Parent := TContactsFile(DataFile);431 TContactsFile(DataFile).Contacts.Add(NewContact);432 Inc(Result.New);433 end else begin434 if NewContact.UpdateFrom(TempFile.Contacts[I]) then435 Inc(Result.Updated);436 end;437 end;438 TContactsFile(DataFile).Modified := True;439 finally440 TempFile.Free;441 end;442 end else ShowMessage(Format(SFileNotFound, [FileName]));443 end;444 445 393 procedure TCore.FileNew; 446 394 begin … … 540 488 AFileClose.Enabled := Assigned(DataFile); 541 489 AFileSplit.Enabled := Assigned(DataFile); 542 AFile Merge.Enabled := Assigned(DataFile);490 AFileCombine.Enabled := Assigned(DataFile); 543 491 AFindDuplicate.Enabled := Assigned(DataFile); 544 492 AGenerate.Enabled := Assigned(DataFile);
Note:
See TracChangeset
for help on using the changeset viewer.