Changeset 31 for trunk/Forms


Ignore:
Timestamp:
Nov 25, 2021, 1:18:44 AM (3 years ago)
Author:
chronos
Message:
  • Modified: Store contact properties in general way to support also user defined properties and unknown attributes.
  • Added: Show contact image in contact edit window.
Location:
trunk/Forms
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormContact.lfm

    r30 r31  
    11object FormContact: TFormContact
    22  Left = 604
    3   Height = 588
    4   Top = 429
    5   Width = 914
     3  Height = 656
     4  Top = 361
     5  Width = 915
    66  Caption = 'Contact'
    7   ClientHeight = 588
    8   ClientWidth = 914
     7  ClientHeight = 656
     8  ClientWidth = 915
    99  DesignTimePPI = 144
    1010  OnClose = FormClose
     
    1414  object PageControlContact: TPageControl
    1515    Left = 10
    16     Height = 508
     16    Height = 576
    1717    Top = 10
    18     Width = 892
     18    Width = 893
    1919    ActivePage = TabSheetAll
    2020    Anchors = [akTop, akLeft, akRight, akBottom]
     
    2424    object TabSheetGeneral: TTabSheet
    2525      Caption = 'General'
    26       ClientHeight = 468
    27       ClientWidth = 882
     26      ClientHeight = 536
     27      ClientWidth = 883
    2828      ParentFont = False
    2929      object Label1: TLabel
     
    113113      end
    114114      object MemoNotes: TMemo
    115         Left = 16
    116         Height = 146
     115        Left = 240
     116        Height = 282
    117117        Top = 230
    118         Width = 846
     118        Width = 623
    119119        Anchors = [akTop, akLeft, akRight, akBottom]
    120120        ParentFont = False
     121        ParentShowHint = False
     122        ScrollBars = ssAutoBoth
    121123        TabOrder = 5
    122124      end
    123125      object Label6: TLabel
    124         Left = 19
     126        Left = 240
    125127        Height = 24
    126128        Top = 202
     
    181183        ParentFont = False
    182184      end
     185      object ImagePhoto: TImage
     186        Left = 16
     187        Height = 208
     188        Top = 232
     189        Width = 207
     190        Proportional = True
     191        Stretch = True
     192      end
     193      object Label23: TLabel
     194        Left = 16
     195        Height = 24
     196        Top = 200
     197        Width = 55
     198        Caption = 'Photo:'
     199        ParentColor = False
     200        ParentFont = False
     201      end
    183202    end
    184203    object TabSheetDetails: TTabSheet
    185204      Caption = 'Details'
    186       ClientHeight = 468
    187       ClientWidth = 882
     205      ClientHeight = 536
     206      ClientWidth = 883
    188207      ParentFont = False
    189208      object Label7: TLabel
     
    428447    object TabSheetAll: TTabSheet
    429448      Caption = 'All fields'
    430       ClientHeight = 468
    431       ClientWidth = 882
     449      ClientHeight = 536
     450      ClientWidth = 883
    432451      OnShow = TabSheetAllShow
    433452      ParentFont = False
    434453      object ListView1: TListView
    435454        Left = 10
    436         Height = 441
     455        Height = 509
    437456        Top = 19
    438         Width = 864
     457        Width = 865
    439458        Anchors = [akTop, akLeft, akRight, akBottom]
    440459        Columns = <       
    441460          item
    442             Caption = 'Item'
    443             Width = 240
     461            Caption = 'Name'
     462            Width = 100
     463          end       
     464          item
     465            Caption = 'Attributes'
     466            Width = 200
    444467          end       
    445468          item
    446469            Caption = 'Value'
    447             Width = 609
     470            Width = 550
    448471          end>
    449472        OwnerData = True
     
    460483  end
    461484  object ButtonCancel: TButton
    462     Left = 787
     485    Left = 788
    463486    Height = 37
    464     Top = 538
     487    Top = 606
    465488    Width = 115
    466489    Anchors = [akRight, akBottom]
     
    471494  end
    472495  object ButtonOk: TButton
    473     Left = 652
     496    Left = 653
    474497    Height = 37
    475     Top = 538
     498    Top = 606
    476499    Width = 119
    477500    Anchors = [akRight, akBottom]
  • trunk/Forms/UFormContact.lrj

    r21 r31  
    1111{"hash":166819690,"name":"tformcontact.label21.caption","sourcebytes":[69,45,109,97,105,108,32,40,87,111,114,107,41,58],"value":"E-mail (Work):"},
    1212{"hash":162456010,"name":"tformcontact.label22.caption","sourcebytes":[66,105,114,116,104,100,97,121,58],"value":"Birthday:"},
     13{"hash":91188010,"name":"tformcontact.label23.caption","sourcebytes":[80,104,111,116,111,58],"value":"Photo:"},
    1314{"hash":181043315,"name":"tformcontact.tabsheetdetails.caption","sourcebytes":[68,101,116,97,105,108,115],"value":"Details"},
    1415{"hash":170160314,"name":"tformcontact.label7.caption","sourcebytes":[80,104,111,110,101,32,40,72,111,109,101,41,58],"value":"Phone (Home):"},
     
    2728{"hash":101155194,"name":"tformcontact.labelorganization.caption","sourcebytes":[79,114,103,97,110,105,122,97,116,105,111,110,58],"value":"Organization:"},
    2829{"hash":113983571,"name":"tformcontact.tabsheetall.caption","sourcebytes":[65,108,108,32,102,105,101,108,100,115],"value":"All fields"},
    29 {"hash":330429,"name":"tformcontact.listview1.columns[0].caption","sourcebytes":[73,116,101,109],"value":"Item"},
    30 {"hash":6063029,"name":"tformcontact.listview1.columns[1].caption","sourcebytes":[86,97,108,117,101],"value":"Value"},
     30{"hash":346165,"name":"tformcontact.listview1.columns[0].caption","sourcebytes":[78,97,109,101],"value":"Name"},
     31{"hash":150815091,"name":"tformcontact.listview1.columns[1].caption","sourcebytes":[65,116,116,114,105,98,117,116,101,115],"value":"Attributes"},
     32{"hash":6063029,"name":"tformcontact.listview1.columns[2].caption","sourcebytes":[86,97,108,117,101],"value":"Value"},
    3133{"hash":77089212,"name":"tformcontact.buttoncancel.caption","sourcebytes":[67,97,110,99,101,108],"value":"Cancel"},
    3234{"hash":1339,"name":"tformcontact.buttonok.caption","sourcebytes":[79,75],"value":"OK"},
  • trunk/Forms/UFormContact.pas

    r29 r31  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ComCtrls, ActnList, Menus, UContact;
     9  ComCtrls, ActnList, Menus, ExtCtrls, UContact, base64;
    1010
    1111type
     
    4040    EditName: TEdit;
    4141    EditCellPhone: TEdit;
     42    ImagePhoto: TImage;
    4243    Label1: TLabel;
    4344    Label10: TLabel;
     
    5556    Label21: TLabel;
    5657    Label22: TLabel;
     58    Label23: TLabel;
    5759    LabelOrganization: TLabel;
    5860    Label3: TLabel;
     
    110112procedure TFormContact.ListView1Data(Sender: TObject; Item: TListItem);
    111113begin
    112   if Item.Index < Contact.Parent.Fields.Count then
    113   with TContactField(Contact.Parent.Fields[Item.Index]) do begin
    114     Item.Caption := Name;
    115     Item.SubItems.Add(Contact.Fields[Index]);
     114  if Item.Index < Contact.Properties.Count then
     115  with Contact.Properties[Item.Index] do begin
     116    Item.Caption := Contact.Properties[Item.Index].Name;
     117    Item.SubItems.Add(Attributes.DelimitedText);
     118    Item.SubItems.Add(Contact.Properties[Item.Index].Values.DelimitedText);
     119    Item.Data := Contact.Properties[Item.Index];
    116120  end;
    117121end;
     
    125129begin
    126130  if Assigned(Contact) then begin
    127     ListView1.Items.Count := Contact.Parent.Fields.Count;
     131    ListView1.Items.Count := Contact.Properties.Count;
    128132  end else ListView1.Items.Count := 0;
    129133  ListView1.Refresh;
     
    139143begin
    140144  if Assigned(ListView1.Selected) then begin
    141     Contact.Fields[TContactFieldIndex(ListView1.Selected.Index)] :=
    142       InputBox(SFieldEdit, SEditFieldValue, Contact.Fields[TContactFieldIndex(ListView1.Selected.Index)]);
     145    TContactProperty(ListView1.Selected.Data).Values.DelimitedText :=
     146      InputBox(SFieldEdit, SEditFieldValue, TContactProperty(ListView1.Selected.Data).Values.DelimitedText);
    143147  end;
    144148end;
     
    152156
    153157procedure TFormContact.LoadData(Contact: TContact);
     158var
     159  Photo: string;
     160  JpegImage: TJpegImage;
     161  Stream: TMemoryStream;
     162  PhotoProperty: TContactProperty;
    154163begin
    155164  Self.Contact := Contact;
    156   EditName.Text := Contact.FirstName;
    157   EditSurname.Text := Contact.LastName;
    158   EditCellPhone.Text := Contact.TelCell;
    159   EditPhoneHome.Text := Contact.TelHome;
    160   EditPhoneWork.Text := Contact.TelWork;
    161   EditEmail.Text := Contact.EmailHome;
    162   MemoNotes.Lines.Text := Contact.Note;
    163   EditTitle.Text := Contact.Title;
    164   EditOrganization.Text := Contact.Organization;
    165   EditAddress.Text := Contact.AdrHome;
    166   EditEmailHome.Text := Contact.EmailHome;
     165  EditName.Text := Contact.Fields[cfFirstName];
     166  EditSurname.Text := Contact.Fields[cfLastName];
     167  EditCellPhone.Text := Contact.Fields[cfTelCell];
     168  EditPhoneHome.Text := Contact.Fields[cfTelHome];
     169  EditPhoneWork.Text := Contact.Fields[cfTelWork];
     170  EditEmail.Text := Contact.Fields[cfEmail];
     171  MemoNotes.Lines.Text := Contact.Fields[cfNote];
     172  EditTitle.Text := Contact.Fields[cfTitle];
     173  EditOrganization.Text := Contact.Fields[cfOrganization];
     174  EditAddress.Text := Contact.Fields[cfAdrHome];
     175  EditEmailHome.Text := Contact.Fields[cfEmailHome];
     176
     177  ImagePhoto.Picture.Bitmap.Clear;
     178  PhotoProperty := Contact.GetProperty(cfPhoto);
     179  if Assigned(PhotoProperty) then begin
     180    Photo := Contact.Fields[cfPhoto];
     181    if (Photo <> '') and (PhotoProperty.Encoding <> '') then begin
     182      Photo := PhotoProperty.GetDecodedValue;
     183      Stream := TMemoryStream.Create;
     184      Stream.Write(Photo[1], Length(Photo));
     185      Stream.Position := 0;
     186      JpegImage := TJPEGImage.Create;
     187      JpegImage.LoadFromStream(Stream);
     188      ImagePhoto.Picture.Bitmap.SetSize(JpegImage.Width, JpegImage.Height);
     189      ImagePhoto.Picture.Bitmap.Canvas.Draw(0, 0, JpegImage);
     190      JpegImage.Free;
     191      Stream.Free;
     192    end;
     193  end;
    167194end;
    168195
    169196procedure TFormContact.SaveData(Contact: TContact);
    170197begin
    171   Contact.FirstName := EditName.Text;
    172   Contact.LastName := EditSurname.Text;
    173   Contact.TelCell := EditCellPhone.Text;
    174   Contact.TelHome := EditPhoneHome.Text;
    175   Contact.TelWork := EditPhoneWork.Text;
    176   Contact.EmailHome := EditEmail.Text;
    177   Contact.Note := MemoNotes.Lines.Text;
    178   Contact.Title := EditTitle.Text;
    179   Contact.Organization := EditOrganization.Text;
    180   Contact.AdrHome := EditAddress.Text;
    181   Contact.EmailHome := EditEmailHome.Text;
     198  Contact.Fields[cfFirstName] := EditName.Text;
     199  Contact.Fields[cfLastName] := EditSurname.Text;
     200  Contact.Fields[cfTelCell] := EditCellPhone.Text;
     201  Contact.Fields[cfTelHome] := EditPhoneHome.Text;
     202  Contact.Fields[cfTelWork] := EditPhoneWork.Text;
     203  Contact.Fields[cfEmail] := EditEmail.Text;
     204  Contact.Fields[cfNote] := MemoNotes.Lines.Text;
     205  Contact.Fields[cfTitle] := EditTitle.Text;
     206  Contact.Fields[cfOrganization] := EditOrganization.Text;
     207  Contact.Fields[cfAdrHome] := EditAddress.Text;
     208  Contact.Fields[cfEmailHome] := EditEmailHome.Text;
    182209end;
    183210
  • trunk/Forms/UFormContacts.pas

    r29 r31  
    7070  if Assigned(Contacts) and (Item.Index < Contacts.Count) then
    7171  with TContact(Contacts[Item.Index]) do begin
    72     Item.Caption := FullName;
    73     Item.SubItems.Add(FirstName);
    74     Item.SubItems.Add(MiddleName);
    75     Item.SubItems.Add(LastName);
    76     Item.SubItems.Add(TelCell);
    77     Item.SubItems.Add(TelHome);
     72    Item.Caption := Fields[cfFullName];
     73    Item.SubItems.Add(Fields[cfFirstName]);
     74    Item.SubItems.Add(Fields[cfMiddleName]);
     75    Item.SubItems.Add(Fields[cfLastName]);
     76    Item.SubItems.Add(Fields[cfTelCell]);
     77    Item.SubItems.Add(Fields[cfTelHome]);
    7878    Item.Data := Contacts[Item.Index];
    7979  end;
  • trunk/Forms/UFormError.pas

    r30 r31  
    1717    procedure FormCreate(Sender: TObject);
    1818    procedure FormShow(Sender: TObject);
    19   private
    20 
    21   public
    22 
    2319  end;
    2420
  • trunk/Forms/UFormGenerate.pas

    r29 r31  
    4646  for I := 1 to SpinEditCount.Value do begin
    4747    Contact := Contacts.AddNew;
    48     Contact.FirstName := 'First ' + IntToStr(Random(10000));
    49     Contact.LastName := 'Last ' + IntToStr(Random(10000));
    50     Contact.FullName := 'FullName ' + IntToStr(Random(100));
    51     Contact.TelCell := IntToStr(Random(1000000000));
    52     Contact.TelHome := IntToStr(Random(1000000000));
     48    Contact.Fields[cfFirstName] := 'First ' + IntToStr(Random(10000));
     49    Contact.Fields[cfLastName] := 'Last ' + IntToStr(Random(10000));
     50    Contact.Fields[cfFullName] := 'FullName ' + IntToStr(Random(100));
     51    Contact.Fields[cfTelCell] := IntToStr(Random(1000000000));
     52    Contact.Fields[cfTelHome] := IntToStr(Random(1000000000));
    5353  end;
    5454  Close;
Note: See TracChangeset for help on using the changeset viewer.