Changeset 56 for trunk/Forms/UFormProperty.pas
- Timestamp:
- Dec 8, 2021, 4:44:21 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormProperty.pas
r42 r56 15 15 ButtonCancel: TButton; 16 16 ButtonOk: TButton; 17 ComboBoxField: TComboBox; 17 18 EditName: TEdit; 18 19 EditAttributes: TEdit; … … 21 22 Label2: TLabel; 22 23 Label3: TLabel; 24 Label4: TLabel; 23 25 procedure ButtonOkClick(Sender: TObject); 26 procedure ComboBoxFieldChange(Sender: TObject); 27 procedure EditAttributesChange(Sender: TObject); 28 procedure EditNameChange(Sender: TObject); 24 29 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 25 30 procedure FormCreate(Sender: TObject); … … 27 32 private 28 33 FContactProperty: TContactProperty; 34 procedure UpdateField; 29 35 procedure SetContactProperty(AValue: TContactProperty); 30 36 procedure LoadData; … … 51 57 end; 52 58 59 procedure TFormProperty.ComboBoxFieldChange(Sender: TObject); 60 var 61 Field: TContactField; 62 Attributes: TStringList; 63 I: Integer; 64 begin 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; 82 end; 83 84 procedure TFormProperty.EditAttributesChange(Sender: TObject); 85 begin 86 UpdateField; 87 end; 88 89 procedure TFormProperty.EditNameChange(Sender: TObject); 90 begin 91 UpdateField; 92 end; 93 53 94 procedure TFormProperty.FormClose(Sender: TObject; var CloseAction: TCloseAction); 54 95 begin … … 61 102 Core.ThemeManager1.UseTheme(Self); 62 103 FContactProperty := nil; 104 TContactsFile(Core.DataFile).Fields.LoadToStrings(ComboBoxField.Items); 63 105 end; 64 106 … … 66 108 begin 67 109 Core.PersistentForm1.Load(Self); 110 end; 111 112 procedure TFormProperty.UpdateField; 113 var 114 Field: TContactField; 115 Groups: TStringList; 116 GroupsArray: TStringArray; 117 I: Integer; 118 begin 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); 68 135 end; 69 136
Note:
See TracChangeset
for help on using the changeset viewer.