@@ -32,16 +32,26 @@ TDelphiAIDevDefaultsQuestionsAddEditView = class(TForm)
3232 Label9: TLabel;
3333 cBoxMenuMaster: TComboBox;
3434 mmQuestion: TMemo;
35+ Label2: TLabel;
36+ cBoxKind: TComboBox;
37+ Label3: TLabel;
38+ edtCaption: TEdit;
3539 procedure btnCloseClick (Sender: TObject);
3640 procedure btnConfirmClick (Sender: TObject);
3741 procedure FormKeyDown (Sender: TObject; var Key: Word; Shift: TShiftState);
3842 procedure FormShow (Sender: TObject);
3943 procedure FormCreate (Sender: TObject);
4044 procedure FormDestroy (Sender: TObject);
45+ procedure cBoxKindChange (Sender: TObject);
4146 private
4247 FFields: TDelphiAIDevDefaultsQuestionsFields;
48+ FLastCaption: string;
49+ FLastQuestion: string;
50+ FLastItemIndexMenuMaster: Integer;
51+ procedure FillcBoxKind ;
4352 procedure MenuMasterLoad ;
4453 procedure MenuMasterClear ;
54+ procedure ConfFieldsKind ;
4555 public
4656 property Fields: TDelphiAIDevDefaultsQuestionsFields read FFields write FFields;
4757 end ;
@@ -56,11 +66,22 @@ implementation
5666
5767{ $R *.dfm}
5868
69+ procedure TDelphiAIDevDefaultsQuestionsAddEditView.FillcBoxKind ;
70+ begin
71+ cBoxKind.Items.Clear;
72+ TUtils.DefaultsQuestionsKindFillItemsTStrings(cBoxKind.Items);
73+ end ;
74+
5975procedure TDelphiAIDevDefaultsQuestionsAddEditView.FormCreate (Sender: TObject);
6076begin
6177 Self.ModalResult := mrCancel;
6278
6379 TUtilsOTA.IDEThemingAll(TDelphiAIDevDefaultsQuestionsAddEditView, Self);
80+
81+ FLastCaption := ' ' ;
82+ FLastQuestion := ' ' ;
83+ FLastItemIndexMenuMaster := 0 ;
84+ Self.FillcBoxKind;
6485end ;
6586
6687procedure TDelphiAIDevDefaultsQuestionsAddEditView.FormDestroy (Sender: TObject);
@@ -70,13 +91,19 @@ procedure TDelphiAIDevDefaultsQuestionsAddEditView.FormDestroy(Sender: TObject);
7091
7192procedure TDelphiAIDevDefaultsQuestionsAddEditView.FormShow (Sender: TObject);
7293begin
94+ cBoxKind.ItemIndex := cBoxKind.Items.IndexOf(FFields.Kind.ToString);
95+ edtCaption.Text := FFields.Caption;
7396 mmQuestion.Lines.Text := FFields.Question;
7497 edtOrder.Text := FFields.Order.Tostring;
7598 ckVisible.Checked := FFields.Visible;
7699 ckCodeOnly.Checked := FFields.CodeOnly;
77100
101+ Self.ConfFieldsKind;
78102 Self.MenuMasterLoad;
79- mmQuestion.SetFocus;
103+ if edtCaption.CanFocus then
104+ edtCaption.SetFocus
105+ else if cBoxKind.CanFocus then
106+ cBoxKind.SetFocus;
80107end ;
81108
82109procedure TDelphiAIDevDefaultsQuestionsAddEditView.MenuMasterClear ;
@@ -107,13 +134,13 @@ procedure TDelphiAIDevDefaultsQuestionsAddEditView.MenuMasterLoad;
107134 LFields: TDelphiAIDevDefaultsQuestionsFields;
108135 LItemIndex: Integer;
109136 begin
110- // if(AFields.Kind <> TC4DWizardOpenExternalKind .MenuMasterOnly)then
111- // Exit;
137+ if (AFields.Kind <> TC4DQuestionKind .MenuMasterOnly)then
138+ Exit;
112139
113140 LFields := TDelphiAIDevDefaultsQuestionsFields.Create;
114141 LFields.Guid := AFields.Guid;
115- LFields.Question := AFields.Question ;
116- LItemIndex := cBoxMenuMaster.Items.AddObject(LFields.Question , LFields);
142+ LFields.Caption := AFields.Caption ;
143+ LItemIndex := cBoxMenuMaster.Items.AddObject(LFields.Caption , LFields);
117144
118145 // if (FFields.IdParent > 0)and(FFields.IdParent = LFields.IdParent) then
119146 // LItemIndexDefault := LItemIndex;
@@ -134,9 +161,17 @@ procedure TDelphiAIDevDefaultsQuestionsAddEditView.btnCloseClick(Sender: TObject
134161
135162procedure TDelphiAIDevDefaultsQuestionsAddEditView.btnConfirmClick (Sender: TObject);
136163begin
137- if Trim(mmQuestion.Lines.Text).IsEmpty then
138- TUtils.ShowMsgAndAbort(' No informed Description' , mmQuestion);
164+ if (cBoxKind.ItemIndex <= 0 )then
165+ TUtils.ShowMsgAndAbort(' No informed Kind' , cBoxKind);
166+
167+ if Trim(edtCaption.Text).IsEmpty then
168+ TUtils.ShowMsgAndAbort(' No informed Caption' , edtCaption);
169+
170+ if (mmQuestion.Enabled) and (Trim(mmQuestion.Lines.Text).IsEmpty )then
171+ TUtils.ShowMsgAndAbort(' No informed Question' , mmQuestion);
139172
173+ FFields.Kind := TUtils.StrToDefaultsQuestionsKind(cBoxKind.Text);
174+ FFields.Caption := edtCaption.Text;
140175 FFields.Question := mmQuestion.Lines.Text;
141176 FFields.Order := StrToIntDef(edtOrder.Text, 0 );
142177 FFields.Visible := ckVisible.Checked;
@@ -153,6 +188,56 @@ procedure TDelphiAIDevDefaultsQuestionsAddEditView.btnConfirmClick(Sender: TObje
153188 Self.ModalResult := mrOK;
154189end ;
155190
191+ procedure TDelphiAIDevDefaultsQuestionsAddEditView.cBoxKindChange (Sender: TObject);
192+ begin
193+ Self.ConfFieldsKind;
194+ end ;
195+
196+ procedure TDelphiAIDevDefaultsQuestionsAddEditView.ConfFieldsKind ;
197+ begin
198+ edtCaption.Enabled := True;
199+ mmQuestion.Enabled := True;
200+ cBoxMenuMaster.Enabled := True;
201+
202+ if (cBoxKind.Text = TC4DQuestionKind.Separators.ToString)then
203+ begin
204+ FLastCaption := edtCaption.Text;
205+ edtCaption.Text := ' -' ;
206+ edtCaption.Enabled := False;
207+
208+ FLastQuestion := mmQuestion.Lines.Text;
209+ mmQuestion.Lines.Clear;
210+ mmQuestion.Enabled := False;
211+ end
212+ else if (cBoxKind.Text = TC4DQuestionKind.MenuMasterOnly.ToString)then
213+ begin
214+ if (edtCaption.Text = ' -' )and (not FLastCaption.Trim.IsEmpty)then
215+ edtCaption.Text := FLastCaption;
216+
217+ FLastQuestion := mmQuestion.Lines.Text;
218+ mmQuestion.Lines.Clear;
219+ mmQuestion.Enabled := False;
220+
221+ FLastItemIndexMenuMaster := cBoxMenuMaster.ItemIndex;
222+ cBoxMenuMaster.ItemIndex := 0 ;
223+ cBoxMenuMaster.Enabled := False;
224+ end
225+ else
226+ begin
227+ if (edtCaption.Text = ' -' )and (not FLastCaption.Trim.IsEmpty)then
228+ edtCaption.Text := FLastCaption;
229+
230+ if (mmQuestion.Text = ' ' )and (not FLastQuestion.Trim.IsEmpty)then
231+ mmQuestion.Text := FLastQuestion;
232+ end ;
233+
234+ if (cBoxKind.Text <> TC4DQuestionKind.MenuMasterOnly.ToString)then
235+ begin
236+ if (cBoxMenuMaster.ItemIndex <= 0 )then
237+ cBoxMenuMaster.ItemIndex := FLastItemIndexMenuMaster;
238+ end ;
239+ end ;
240+
156241procedure TDelphiAIDevDefaultsQuestionsAddEditView.FormKeyDown (Sender: TObject; var Key: Word; Shift: TShiftState);
157242begin
158243 case (Key)of
0 commit comments