Changeset 138 for trunk/Forms
- Timestamp:
- Aug 23, 2022, 10:06:54 AM (2 years ago)
- Location:
- trunk/Forms
- Files:
-
- 3 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormContacts.lfm
r128 r138 13 13 OnResize = FormResize 14 14 OnShow = FormShow 15 LCLVersion = '2.2. 0.4'15 LCLVersion = '2.2.2.0' 16 16 object ListView1: TListView 17 17 Left = 0 18 Height = 8 1018 Height = 809 19 19 Top = 0 20 20 Width = 1210 … … 68 68 Left = 0 69 69 Height = 39 70 Top = 84 270 Top = 841 71 71 Width = 1210 72 72 Align = alBottom … … 116 116 Left = 0 117 117 Height = 32 118 Top = 8 10118 Top = 809 119 119 Width = 1210 120 120 OnChange = ListViewFilter1Change … … 123 123 object StatusBar1: TStatusBar 124 124 Left = 0 125 Height = 2 7126 Top = 88 1125 Height = 28 126 Top = 880 127 127 Width = 1210 128 128 Panels = < … … 171 171 object MenuItem8: TMenuItem 172 172 Action = ASaveToFile 173 end 174 object Separator1: TMenuItem 175 Caption = '-' 176 end 177 object MenuItemColumns: TMenuItem 178 Action = AColumns 173 179 end 174 180 end … … 233 239 ShortCut = 16470 234 240 end 241 object AColumns: TAction 242 Caption = 'Columns' 243 OnExecute = AColumnsExecute 244 end 235 245 end 236 246 object ListViewSort1: TListViewSort -
trunk/Forms/UFormContacts.lrj
r82 r138 18 18 {"hash":304761,"name":"tformcontacts.acopy.caption","sourcebytes":[67,111,112,121],"value":"Copy"}, 19 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"} 20 {"hash":5671589,"name":"tformcontacts.apaste.caption","sourcebytes":[80,97,115,116,101],"value":"Paste"}, 21 {"hash":174310419,"name":"tformcontacts.acolumns.caption","sourcebytes":[67,111,108,117,109,110,115],"value":"Columns"} 21 22 ]} -
trunk/Forms/UFormContacts.pas
r134 r138 5 5 uses 6 6 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 7 Menus, ActnList, UVCard, UListViewSort, LazUTF8, Clipbrd, 8 Generics.Collections ;7 Menus, ActnList, UVCard, UListViewSort, LazUTF8, Clipbrd, URegistry, 8 Generics.Collections, Types; 9 9 10 10 type … … 16 16 AClone: TAction; 17 17 ACopy: TAction; 18 AColumns: TAction; 18 19 ACut: TAction; 19 20 APaste: TAction; … … 31 32 MenuItem11: TMenuItem; 32 33 MenuItem12: TMenuItem; 34 Separator1: TMenuItem; 35 MenuItemColumns: TMenuItem; 33 36 MenuItem2: TMenuItem; 34 37 MenuItem3: TMenuItem; … … 53 56 procedure AAddExecute(Sender: TObject); 54 57 procedure ACloneExecute(Sender: TObject); 58 procedure AColumnsExecute(Sender: TObject); 55 59 procedure ACopyExecute(Sender: TObject); 56 60 procedure ACutExecute(Sender: TObject); … … 83 87 procedure DoUpdateInterface; 84 88 procedure UpdateColumns; 89 procedure LoadFromRegistry(Context: TRegistryContext); 90 procedure SaveToRegistry(Context: TRegistryContext); 85 91 public 86 92 ListViewColumns: TContactFieldIndexes; 87 93 FilterItems: TContactFilterItems; 88 property Contacts: TContacts read FContacts write SetContacts;94 Context: TRegistryContext; 89 95 procedure ReloadList; 90 96 procedure BeginUpdate; 91 97 procedure EndUpdate; 92 98 procedure UpdateInterface; 99 property Contacts: TContacts read FContacts write SetContacts; 93 100 end; 94 101 … … 102 109 103 110 uses 104 UFormContact, UCore, UVCardFile ;111 UFormContact, UCore, UVCardFile, UFormColumns; 105 112 106 113 resourcestring … … 315 322 end; 316 323 324 procedure TFormContacts.LoadFromRegistry(Context: TRegistryContext); 325 var 326 I: Integer; 327 Registry: TRegistryEx; 328 ContactFieldIndex: TContactFieldIndex; 329 begin 330 Registry := TRegistryEx.Create; 331 with Registry do 332 try 333 RootKey := Context.RootKey; 334 OpenKey(Context.Key, True); 335 ListViewColumns.Clear; 336 I := 0; 337 while ValueExists('Column' + IntToStr(I)) do begin 338 ContactFieldIndex := TContactFieldIndex(ReadIntegerWithDefault('Column' + IntToStr(I), -1)); 339 ListViewColumns.Add(ContactFieldIndex); 340 Inc(I); 341 end; 342 343 if ListViewColumns.Count = 0 then begin 344 with ListViewColumns do begin 345 Add(cfFullName); 346 Add(cfFirstName); 347 Add(cfMiddleName); 348 Add(cfLastName); 349 Add(cfTel); 350 Add(cfTelCell); 351 Add(cfTelHome); 352 Add(cfTelWork); 353 Add(cfEmailWork); 354 Add(cfOrganization); 355 end; 356 end; 357 finally 358 Free; 359 end; 360 end; 361 362 procedure TFormContacts.SaveToRegistry(Context: TRegistryContext); 363 var 364 I: Integer; 365 Registry: TRegistryEx; 366 begin 367 Registry := TRegistryEx.Create; 368 with Registry do 369 try 370 RootKey := Context.RootKey; 371 OpenKey(Context.Key, True); 372 for I := 0 to ListViewColumns.Count - 1 do 373 WriteInteger('Column' + IntToStr(I), Integer(ListViewColumns[I])); 374 375 // Remove old columns 376 I := ListViewColumns.Count; 377 while ValueExists('Column' + IntToStr(I)) do begin 378 DeleteValue('Column' + IntToStr(I)); 379 Inc(I); 380 end; 381 finally 382 Free; 383 end; 384 end; 385 317 386 procedure TFormContacts.FormShow(Sender: TObject); 318 387 begin … … 320 389 Core.ThemeManager1.UseTheme(Self); 321 390 Core.PersistentForm1.Load(Self); 391 LoadFromRegistry(Context); 322 392 ReloadList; 323 393 UpdateInterface; … … 385 455 end; 386 456 457 procedure TFormContacts.AColumnsExecute(Sender: TObject); 458 var 459 FormColumns: TFormColumns; 460 I: Integer; 461 Field: TContactField; 462 begin 463 FormColumns := TFormColumns.Create(nil); 464 with FormColumns do 465 try 466 for I := 0 to ListViewColumns.Count - 1 do begin 467 Field := TContact.GetFields.GetByIndex(ListViewColumns[I]); 468 if Assigned(Field) then 469 ActiveColumns.AddObject(Field.Title, Field); 470 end; 471 for I := 0 to TContact.GetFields.Count - 1 do begin 472 Field := TContact.GetFields[I]; 473 if ListViewColumns.IndexOf(Field.Index) = -1 then 474 AvailableColumns.AddObject(Field.Title, Field); 475 end; 476 if ShowModal = mrOK then begin 477 ListViewColumns.Clear; 478 for I := 0 to ActiveColumns.Count - 1 do begin 479 ListViewColumns.Add(TContactField(ActiveColumns.Objects[I]).Index); 480 end; 481 UpdateColumns; 482 ReloadList; 483 end; 484 finally 485 Free; 486 end; 487 end; 488 387 489 procedure TFormContacts.ACopyExecute(Sender: TObject); 388 490 var … … 571 673 ); 572 674 begin 675 SaveToRegistry(Context); 573 676 Core.PersistentForm1.Save(Self); 574 677 end; … … 579 682 begin 580 683 FilterItems := TContactFilterItems.Create; 581 582 684 ListViewColumns := TContactFieldIndexes.Create; 583 with ListViewColumns do begin584 Add(cfFullName);585 Add(cfFirstName);586 Add(cfMiddleName);587 Add(cfLastName);588 Add(cfTel);589 Add(cfTelCell);590 Add(cfTelHome);591 Add(cfTelWork);592 Add(cfEmailWork);593 end;594 685 595 686 FContacts := nil; -
trunk/Forms/UFormMain.lfm
r126 r138 15 15 OnResize = FormResize 16 16 OnShow = FormShow 17 LCLVersion = '2.2. 0.4'17 LCLVersion = '2.2.2.0' 18 18 object CoolBar1: TCoolBar 19 19 Left = 0 … … 177 177 OnClick = MenuItemToolbarClick 178 178 end 179 object MenuItemColumns: TMenuItem 180 Caption = 'Columns' 181 OnClick = MenuItemColumnsClick 182 end 179 183 end 180 184 object MenuItemTools: TMenuItem -
trunk/Forms/UFormMain.lrj
r81 r138 6 6 {"hash":380871,"name":"tformmain.menuitemview.caption","sourcebytes":[86,105,101,119],"value":"View"}, 7 7 {"hash":8267778,"name":"tformmain.menuitemtoolbar.caption","sourcebytes":[77,97,105,110,32,116,111,111,108,98,97,114],"value":"Main toolbar"}, 8 {"hash":174310419,"name":"tformmain.menuitemcolumns.caption","sourcebytes":[67,111,108,117,109,110,115],"value":"Columns"}, 8 9 {"hash":5989939,"name":"tformmain.menuitemtools.caption","sourcebytes":[84,111,111,108,115],"value":"Tools"}, 9 10 {"hash":322608,"name":"tformmain.menuitemhelp.caption","sourcebytes":[72,101,108,112],"value":"Help"} -
trunk/Forms/UFormMain.pas
r129 r138 19 19 MenuItem12: TMenuItem; 20 20 MenuItem13: TMenuItem; 21 MenuItemColumns: TMenuItem; 21 22 MenuItem3: TMenuItem; 22 23 MenuItem4: TMenuItem; … … 59 60 procedure FormResize(Sender: TObject); 60 61 procedure FormShow(Sender: TObject); 62 procedure MenuItemColumnsClick(Sender: TObject); 61 63 procedure MenuItemToolbarClick(Sender: TObject); 62 64 private … … 76 78 77 79 uses 78 UCore, UFormContacts, UVCard, UVCardFile ;80 UCore, UFormContacts, UVCard, UVCardFile, URegistry; 79 81 80 82 resourcestring … … 121 123 CoolBar1.AutosizeBands; 122 124 125 FormContacts.Context := TRegistryContext.Create(Core.ApplicationInfo1.RegistryRoot, 126 Core.ApplicationInfo1.RegistryKey + '\ContactsColumns'); 123 127 FormContacts.Contacts := TVCardFile(Core.DataFile).VCard.Contacts; 124 128 FormContacts.ManualDock(Self, nil, alClient); … … 128 132 FormContacts.EndUpdate; 129 133 end; 134 end; 135 136 procedure TFormMain.MenuItemColumnsClick(Sender: TObject); 137 begin 138 FormContacts.AColumns.Execute; 130 139 end; 131 140
Note:
See TracChangeset
for help on using the changeset viewer.