Ignore:
Timestamp:
Nov 29, 2021, 2:17:26 PM (3 years ago)
Author:
chronos
Message:
  • Added: New more general contact properties list and item form.
  • Modified: Show Private and Work addresses in separate tab.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormContact.pas

    r38 r39  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ComCtrls, ActnList, Menus, ExtCtrls, UContact, base64;
     9  ComCtrls, ActnList, Menus, ExtCtrls, UContact, base64, UFormProperties;
    1010
    1111type
     
    1818    ButtonCancel: TButton;
    1919    ButtonOk: TButton;
     20    EditAddressHomeCity: TEdit;
     21    EditAddressHomeCountry: TEdit;
     22    EditAddressHomePostalCode: TEdit;
     23    EditAddressHomePostOfficeBox: TEdit;
     24    EditAddressHomeRegion: TEdit;
     25    EditAddressHomeStreetExtended: TEdit;
     26    EditAddressWorkStreet: TEdit;
     27    EditAddressWorkCity: TEdit;
     28    EditAddressWorkRegion: TEdit;
     29    EditAddressWorkCountry: TEdit;
     30    EditAddressHomeStreet: TEdit;
     31    EditWebWork: TEdit;
     32    EditAddressWorkPostalCode: TEdit;
     33    EditAddressWorkPostOfficeBox: TEdit;
     34    EditAddressWorkStreetExtended: TEdit;
    2035    EditDepartment: TEdit;
    2136    EditFullName: TEdit;
     37    EditOrganization: TEdit;
     38    EditTitle: TEdit;
    2239    EditTitleBefore: TEdit;
    2340    EditMiddleName: TEdit;
    2441    EditTitleAfter: TEdit;
    25     EditWebPage: TEdit;
    26     EditWebPageHome: TEdit;
    27     EditWebPageWork: TEdit;
    2842    EditEmailHome: TEdit;
    2943    EditEmailWork: TEdit;
    3044    EditBirthday: TEdit;
    31     EditTitle: TEdit;
    32     EditAddress: TEdit;
    33     EditOrganization: TEdit;
    3445    EditPhoneHome: TEdit;
    3546    EditPhoneWork: TEdit;
     
    4556    EditFirstName: TEdit;
    4657    EditCellPhone: TEdit;
     58    EditWebHome: TEdit;
    4759    ImagePhoto: TImage;
    4860    Label1: TLabel;
     
    5264    Label13: TLabel;
    5365    Label14: TLabel;
    54     Label15: TLabel;
    55     Label16: TLabel;
    56     Label17: TLabel;
    5766    Label18: TLabel;
    58     Label19: TLabel;
    5967    Label2: TLabel;
    6068    Label20: TLabel;
     
    6674    Label26: TLabel;
    6775    Label27: TLabel;
    68     LabelOrganization: TLabel;
     76    Label28: TLabel;
     77    Label29: TLabel;
    6978    Label3: TLabel;
     79    Label30: TLabel;
     80    Label31: TLabel;
     81    Label32: TLabel;
     82    Label33: TLabel;
     83    Label34: TLabel;
     84    Label35: TLabel;
     85    Label36: TLabel;
     86    Label37: TLabel;
     87    Label38: TLabel;
     88    Label39: TLabel;
    7089    Label4: TLabel;
     90    Label40: TLabel;
     91    Label41: TLabel;
     92    Label42: TLabel;
     93    Label43: TLabel;
    7194    Label5: TLabel;
    7295    Label6: TLabel;
     
    7497    Label8: TLabel;
    7598    Label9: TLabel;
     99    LabelOrganization: TLabel;
    76100    LabelOrganization1: TLabel;
    77     ListView1: TListView;
    78101    MemoNotes: TMemo;
    79102    MenuItem1: TMenuItem;
    80103    PageControlContact: TPageControl;
    81104    PopupMenu1: TPopupMenu;
     105    TabSheetWork: TTabSheet;
    82106    TabSheetGeneral: TTabSheet;
    83     TabSheetDetails: TTabSheet;
     107    TabSheetPrivate: TTabSheet;
    84108    TabSheetAll: TTabSheet;
    85     procedure AEditFieldExecute(Sender: TObject);
     109    procedure ButtonOkClick(Sender: TObject);
    86110    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    87111    procedure FormCreate(Sender: TObject);
     112    procedure FormDestroy(Sender: TObject);
    88113    procedure FormShow(Sender: TObject);
    89114    procedure ListView1Data(Sender: TObject; Item: TListItem);
    90115    procedure TabSheetAllShow(Sender: TObject);
     116    procedure TabSheetGeneralShow(Sender: TObject);
    91117  private
    92     Contact: TContact;
     118    FContact: TContact;
     119    FormProperties: TFormProperties;
     120    procedure SetContact(AValue: TContact);
    93121  public
    94     procedure ReloadFields;
    95     procedure LoadData(Contact: TContact);
    96     procedure SaveData(Contact: TContact);
     122    procedure LoadData;
     123    procedure SaveData;
     124    property Contact: TContact read FContact write SetContact;
    97125  end;
    98126
     
    118146  Core.PersistentForm1.Load(Self);
    119147  PageControlContact.TabIndex := 0;
     148
     149  FormProperties.ManualDock(TabSheetAll, nil, alClient);
     150  FormProperties.Align := alClient;
     151  FormProperties.Show;
    120152end;
    121153
     
    133165procedure TFormContact.TabSheetAllShow(Sender: TObject);
    134166begin
    135   ReloadFields;
    136 end;
    137 
    138 procedure TFormContact.ReloadFields;
    139 begin
    140   if Assigned(Contact) then begin
    141     ListView1.Items.Count := Contact.Properties.Count;
    142   end else ListView1.Items.Count := 0;
    143   ListView1.Refresh;
     167  SaveData;
     168  FormProperties.ReloadList;
     169  FormProperties.UpdateInterface;
     170end;
     171
     172procedure TFormContact.TabSheetGeneralShow(Sender: TObject);
     173begin
     174  LoadData;
     175end;
     176
     177procedure TFormContact.SetContact(AValue: TContact);
     178begin
     179  if FContact = AValue then Exit;
     180  FContact := AValue;
     181  LoadData;
    144182end;
    145183
     
    150188end;
    151189
    152 procedure TFormContact.AEditFieldExecute(Sender: TObject);
    153 begin
    154   if Assigned(ListView1.Selected) then begin
    155     TContactProperty(ListView1.Selected.Data).Values.DelimitedText :=
    156       InputBox(SFieldEdit, SEditFieldValue, TContactProperty(ListView1.Selected.Data).Values.DelimitedText);
    157   end;
     190procedure TFormContact.ButtonOkClick(Sender: TObject);
     191begin
     192  SaveData;
    158193end;
    159194
     
    162197  Core.Translator.TranslateComponentRecursive(Self);
    163198  Core.ThemeManager1.UseTheme(Self);
    164   Contact := nil;
    165 end;
    166 
    167 procedure TFormContact.LoadData(Contact: TContact);
     199  FContact := nil;
     200  FormProperties := TFormProperties.Create(nil);
     201end;
     202
     203procedure TFormContact.FormDestroy(Sender: TObject);
     204begin
     205  FreeAndNil(FormProperties);
     206end;
     207
     208procedure TFormContact.LoadData;
    168209var
    169210  Photo: string;
     
    172213  PhotoProperty: TContactProperty;
    173214begin
    174   Self.Contact := Contact;
     215  FormProperties.Properties := Contact.Properties;
     216
    175217  EditFullName.Text := Contact.Fields[cfFullName];
    176218  EditFirstName.Text := Contact.Fields[cfFirstName];
     
    184226  EditEmail.Text := Contact.Fields[cfEmail];
    185227  MemoNotes.Lines.Text := Contact.Fields[cfNote];
     228
     229  // Work
    186230  EditTitle.Text := Contact.Fields[cfTitle];
    187231  EditOrganization.Text := Contact.Fields[cfOrganization];
    188232  EditDepartment.Text := Contact.Fields[cfDepartment];
    189   EditAddress.Text := Contact.Fields[cfHomeAddress];
     233  EditAddressWorkPostOfficeBox.Text := Contact.Fields[cfWorkAddressPostOfficeBox];
     234  EditAddressWorkStreet.Text := Contact.Fields[cfWorkAddressStreet];
     235  EditAddressWorkStreetExtended.Text := Contact.Fields[cfWorkAddressStreetExtended];
     236  EditAddressWorkCity.Text := Contact.Fields[cfWorkAddressCity];
     237  EditAddressWorkRegion.Text := Contact.Fields[cfWorkAddressRegion];
     238  EditAddressWorkCountry.Text := Contact.Fields[cfWorkAddressCountry];
     239  EditAddressWorkPostalCode.Text := Contact.Fields[cfWorkAddressPostalCode];
     240  EditWebHome.Text := Contact.Fields[cfUrlWork];
     241
     242  // Private
     243  EditAddressHomePostOfficeBox.Text := Contact.Fields[cfHomeAddressPostOfficeBox];
     244  EditAddressHomeStreet.Text := Contact.Fields[cfHomeAddressStreet];
     245  EditAddressHomeStreetExtended.Text := Contact.Fields[cfHomeAddressStreetExtended];
     246  EditAddressHomeCity.Text := Contact.Fields[cfHomeAddressCity];
     247  EditAddressHomeRegion.Text := Contact.Fields[cfHomeAddressRegion];
     248  EditAddressHomeCountry.Text := Contact.Fields[cfHomeAddressCountry];
     249  EditAddressHomePostalCode.Text := Contact.Fields[cfHomeAddressPostalCode];
     250  EditWebHome.Text := Contact.Fields[cfUrlHome];
     251  EditBirthday.Text := Contact.Fields[cfDayOfBirth];
     252
    190253  EditEmailHome.Text := Contact.Fields[cfEmail];
    191   EditWebPage.Text := Contact.Fields[cfUrl];
    192   EditBirthday.Text := Contact.Fields[cfDayOfBirth];
    193 
    194254  ImagePhoto.Picture.Bitmap.Clear;
    195255  PhotoProperty := Contact.GetProperty(cfPhoto);
     
    226286end;
    227287
    228 procedure TFormContact.SaveData(Contact: TContact);
     288procedure TFormContact.SaveData;
    229289begin
    230290  Contact.Fields[cfFullName] := EditFullName.Text;
     
    239299  Contact.Fields[cfEmail] := EditEmail.Text;
    240300  Contact.Fields[cfNote] := MemoNotes.Lines.Text;
     301  Contact.Fields[cfEmail] := EditEmailHome.Text;
     302  Contact.Fields[cfDayOfBirth] := EditBirthday.Text;
     303
     304  // Work
    241305  Contact.Fields[cfTitle] := EditTitle.Text;
    242306  Contact.Fields[cfOrganization] := EditOrganization.Text;
    243307  Contact.Fields[cfDepartment] := EditDepartment.Text;
    244   Contact.Fields[cfHomeAddress] := EditAddress.Text;
    245   Contact.Fields[cfEmail] := EditEmailHome.Text;
    246   Contact.Fields[cfUrl] := EditWebPage.Text;
    247   Contact.Fields[cfDayOfBirth] := EditBirthday.Text;
     308  Contact.Fields[cfWorkAddressPostOfficeBox] := EditAddressWorkPostOfficeBox.Text;
     309  Contact.Fields[cfWorkAddressStreet] := EditAddressWorkStreet.Text;
     310  Contact.Fields[cfWorkAddressStreetExtended] := EditAddressWorkStreetExtended.Text;
     311  Contact.Fields[cfWorkAddressCity] := EditAddressWorkCity.Text;
     312  Contact.Fields[cfWorkAddressRegion] := EditAddressWorkRegion.Text;
     313  Contact.Fields[cfWorkAddressCountry] := EditAddressWorkCountry.Text;
     314  Contact.Fields[cfWorkAddressPostalCode] := EditAddressWorkPostalCode.Text;
     315  Contact.Fields[cfUrlWork] := EditWebWork.Text;
     316
     317  // Private
     318  Contact.Fields[cfHomeAddressPostOfficeBox] := EditAddressHomePostOfficeBox.Text;
     319  Contact.Fields[cfHomeAddressStreet] := EditAddressHomeStreet.Text;
     320  Contact.Fields[cfHomeAddressStreetExtended] := EditAddressHomeStreetExtended.Text;
     321  Contact.Fields[cfHomeAddressCity] := EditAddressHomeCity.Text;
     322  Contact.Fields[cfHomeAddressRegion] := EditAddressHomeRegion.Text;
     323  Contact.Fields[cfHomeAddressCountry] := EditAddressHomeCountry.Text;
     324  Contact.Fields[cfHomeAddressPostalCode] := EditAddressHomePostalCode.Text;
     325  Contact.Fields[cfUrlHome] := EditWebHome.Text;
    248326end;
    249327
Note: See TracChangeset for help on using the changeset viewer.