Changeset 56 for trunk


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
Files:
7 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
  • trunk/Languages/vCardStudio.cs.po

    r55 r56  
    572572msgstr "Hodnoty:"
    573573
     574#: tformproperty.label4.caption
     575msgid "Field:"
     576msgstr "Pole:"
     577
    574578#: tformsettings.buttoncancel.caption
    575579msgctxt "tformsettings.buttoncancel.caption"
     
    832836#: ucontact.sworkaddresspostofficebox
    833837msgid "Work address post office box"
    834 msgstr "Pracovní adresa číslo schárnky"
     838msgstr "Pracovní adresa číslo schnky"
    835839
    836840#: ucontact.sworkaddressregion
  • trunk/Languages/vCardStudio.po

    r55 r56  
    560560msgstr ""
    561561
     562#: tformproperty.label4.caption
     563msgid "Field:"
     564msgstr ""
     565
    562566#: tformsettings.buttoncancel.caption
    563567msgctxt "tformsettings.buttoncancel.caption"
  • trunk/UContact.pas

    r55 r56  
    3030    cfVersion, cfAnniversary);
    3131
     32  { TContactField }
     33
    3234  TContactField = class
    3335    SysName: string;
     
    3840    ValueIndex: Integer;
    3941    DataType: TDataType;
     42    function GroupsContain(Name: string): Boolean;
     43    function Match(ASysName: string; AGroups: TStringArray): Boolean;
    4044  end;
    4145
     
    4650      Title: string; Index: TContactFieldIndex; DataType:
    4751      TDataType; ValueIndex: Integer = -1): TContactField;
     52    function GetBySysName(SysName: string): TContactField;
     53    function GetBySysNameGroups(SysName: string; Groups: TStringArray): TContactField;
    4854    function GetByIndex(Index: TContactFieldIndex): TContactField;
    4955    procedure LoadToStrings(AItems: TStrings);
     
    238244end;
    239245
     246{ TContactField }
     247
     248function TContactField.GroupsContain(Name: string): Boolean;
     249var
     250  I: Integer;
     251begin
     252  Result := False;
     253  for I := 0 to Length(Groups) - 1 do
     254    if Groups[I] = Name then begin
     255      Result := True;
     256      Break;
     257    end;
     258end;
     259
     260function TContactField.Match(ASysName: string; AGroups: TStringArray): Boolean;
     261var
     262  I: Integer;
     263begin
     264  Result := ASysName = SysName;
     265  if Result then begin
     266    for I := 0 to Length(AGroups) - 1 do begin
     267      if not GroupsContain(AGroups[I]) then begin
     268        Result := False;
     269        Break;
     270      end;
     271    end;
     272  end;
     273end;
     274
    240275{ TContactProperties }
    241276
     
    491526  Result.DataType := DataType;
    492527  Add(Result);
     528end;
     529
     530function TContactFields.GetBySysName(SysName: string): TContactField;
     531var
     532  I: Integer;
     533  C: Integer;
     534begin
     535  C := Count;
     536  I := 0;
     537  while (I < Count) and (Items[I].SysName <> SysName) do Inc(I);
     538  if I < Count then Result := Items[I]
     539    else Result := nil;
     540end;
     541
     542function TContactFields.GetBySysNameGroups(SysName: string; Groups: TStringArray
     543  ): TContactField;
     544var
     545  I: Integer;
     546  C: Integer;
     547begin
     548  C := Count;
     549  I := 0;
     550  while (I < Count) and not Items[I].Match(SysName, Groups) do Inc(I);
     551  if I < Count then Result := Items[I]
     552    else Result := nil;
    493553end;
    494554
  • trunk/UCore.pas

    r53 r56  
    356356    if Assigned(DataFile) then FreeAndNil(DataFile);
    357357    FileClosed := True;
     358    UpdateFile;
    358359  end;
    359360end;
Note: See TracChangeset for help on using the changeset viewer.