Changeset 56 for trunk/Forms


Ignore:
Timestamp:
Dec 8, 2021, 4:44:21 PM (3 years ago)
Author:
chronos
Message:
  • Added: Show textual name of contact field in contact field form and prefill field name and attributes. Update that name back according used field name and attributes.
Location:
trunk/Forms
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormProperty.lfm

    r39 r56  
    11object FormProperty: TFormProperty
    22  Left = 760
    3   Height = 525
    4   Top = 469
    5   Width = 802
     3  Height = 418
     4  Top = 576
     5  Width = 726
    66  Caption = 'Field'
    7   ClientHeight = 525
    8   ClientWidth = 802
     7  ClientHeight = 418
     8  ClientWidth = 726
    99  DesignTimePPI = 144
    1010  OnClose = FormClose
     
    1313  LCLVersion = '2.0.12.0'
    1414  object ButtonOk: TButton
    15     Left = 536
     15    Left = 460
    1616    Height = 37
    17     Top = 472
     17    Top = 365
    1818    Width = 119
    1919    Anchors = [akRight, akBottom]
     
    2525  end
    2626  object ButtonCancel: TButton
    27     Left = 672
     27    Left = 596
    2828    Height = 37
    29     Top = 472
     29    Top = 365
    3030    Width = 115
    3131    Anchors = [akRight, akBottom]
     
    3838    Left = 24
    3939    Height = 24
    40     Top = 20
     40    Top = 80
    4141    Width = 56
    4242    Caption = 'Name:'
     
    4444  end
    4545  object EditName: TEdit
    46     Left = 166
     46    Left = 168
    4747    Height = 42
    48     Top = 20
    49     Width = 322
     48    Top = 72
     49    Width = 532
     50    Anchors = [akTop, akLeft, akRight]
     51    OnChange = EditNameChange
    5052    TabOrder = 2
    5153  end
     
    5355    Left = 24
    5456    Height = 24
    55     Top = 72
     57    Top = 128
    5658    Width = 88
    5759    Caption = 'Attributes:'
     
    5961  end
    6062  object EditAttributes: TEdit
    61     Left = 166
     63    Left = 168
    6264    Height = 42
    63     Top = 72
    64     Width = 322
     65    Top = 124
     66    Width = 532
     67    Anchors = [akTop, akLeft, akRight]
     68    OnChange = EditAttributesChange
    6569    TabOrder = 3
    6670  end
     
    6872    Left = 24
    6973    Height = 24
    70     Top = 128
     74    Top = 180
    7175    Width = 60
    7276    Caption = 'Values:'
     
    7478  end
    7579  object EditValues: TEdit
    76     Left = 166
     80    Left = 168
    7781    Height = 42
    78     Top = 120
    79     Width = 322
     82    Top = 172
     83    Width = 532
     84    Anchors = [akTop, akLeft, akRight]
    8085    TabOrder = 4
    8186  end
     87  object Label4: TLabel
     88    Left = 24
     89    Height = 24
     90    Top = 32
     91    Width = 45
     92    Caption = 'Field:'
     93    ParentColor = False
     94  end
     95  object ComboBoxField: TComboBox
     96    Left = 168
     97    Height = 42
     98    Top = 24
     99    Width = 532
     100    Anchors = [akTop, akLeft, akRight]
     101    ItemHeight = 0
     102    OnChange = ComboBoxFieldChange
     103    Style = csDropDownList
     104    TabOrder = 5
     105  end
    82106end
  • trunk/Forms/UFormProperty.lrj

    r39 r56  
    55{"hash":5538698,"name":"tformproperty.label1.caption","sourcebytes":[78,97,109,101,58],"value":"Name:"},
    66{"hash":265557994,"name":"tformproperty.label2.caption","sourcebytes":[65,116,116,114,105,98,117,116,101,115,58],"value":"Attributes:"},
    7 {"hash":209959994,"name":"tformproperty.label3.caption","sourcebytes":[86,97,108,117,101,115,58],"value":"Values:"}
     7{"hash":209959994,"name":"tformproperty.label3.caption","sourcebytes":[86,97,108,117,101,115,58],"value":"Values:"},
     8{"hash":80724602,"name":"tformproperty.label4.caption","sourcebytes":[70,105,101,108,100,58],"value":"Field:"}
    89]}
  • trunk/Forms/UFormProperty.pas

    r42 r56  
    1515    ButtonCancel: TButton;
    1616    ButtonOk: TButton;
     17    ComboBoxField: TComboBox;
    1718    EditName: TEdit;
    1819    EditAttributes: TEdit;
     
    2122    Label2: TLabel;
    2223    Label3: TLabel;
     24    Label4: TLabel;
    2325    procedure ButtonOkClick(Sender: TObject);
     26    procedure ComboBoxFieldChange(Sender: TObject);
     27    procedure EditAttributesChange(Sender: TObject);
     28    procedure EditNameChange(Sender: TObject);
    2429    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    2530    procedure FormCreate(Sender: TObject);
     
    2732  private
    2833    FContactProperty: TContactProperty;
     34    procedure UpdateField;
    2935    procedure SetContactProperty(AValue: TContactProperty);
    3036    procedure LoadData;
     
    5157end;
    5258
     59procedure TFormProperty.ComboBoxFieldChange(Sender: TObject);
     60var
     61  Field: TContactField;
     62  Attributes: TStringList;
     63  I: Integer;
     64begin
     65  if ComboBoxField.ItemIndex <> -1 then begin
     66    Field := TContactsFile(Core.DataFile).Fields[ComboBoxField.ItemIndex];
     67    if Assigned(Field) then begin
     68      EditName.Text := Field.SysName;
     69      Attributes := TStringList.Create;
     70      try
     71        Attributes.NameValueSeparator := '=';
     72        Attributes.Delimiter := ';';
     73        Attributes.StrictDelimiter := True;
     74        for I := 0 to Length(Field.Groups) - 1 do
     75          Attributes.Add(Field.Groups[I]);
     76        EditAttributes.Text := Attributes.DelimitedText;
     77      finally
     78        Attributes.Free;
     79      end;
     80    end;
     81  end;
     82end;
     83
     84procedure TFormProperty.EditAttributesChange(Sender: TObject);
     85begin
     86  UpdateField;
     87end;
     88
     89procedure TFormProperty.EditNameChange(Sender: TObject);
     90begin
     91  UpdateField;
     92end;
     93
    5394procedure TFormProperty.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    5495begin
     
    61102  Core.ThemeManager1.UseTheme(Self);
    62103  FContactProperty := nil;
     104  TContactsFile(Core.DataFile).Fields.LoadToStrings(ComboBoxField.Items);
    63105end;
    64106
     
    66108begin
    67109  Core.PersistentForm1.Load(Self);
     110end;
     111
     112procedure TFormProperty.UpdateField;
     113var
     114  Field: TContactField;
     115  Groups: TStringList;
     116  GroupsArray: TStringArray;
     117  I: Integer;
     118begin
     119  Groups := TStringList.Create;
     120  try
     121    Groups.NameValueSeparator := '=';
     122    Groups.Delimiter := ';';
     123    Groups.StrictDelimiter := True;
     124    Groups.DelimitedText := EditAttributes.Text;
     125    SetLength(GroupsArray, Groups.Count);
     126    for I := 0 to Groups.Count - 1 do
     127      GroupsArray[I] := Groups[I];
     128  finally
     129    Groups.Free;
     130  end;
     131  Field := TContactsFile(Core.DataFile).Fields.GetBySysNameGroups(EditName.Text,
     132    GroupsArray);
     133  if Assigned(Field) then
     134    ComboBoxField.ItemIndex := TContactsFile(Core.DataFile).Fields.IndexOf(Field);
    68135end;
    69136
Note: See TracChangeset for help on using the changeset viewer.