Skip to content

Commit 2d61f92

Browse files
committed
bk/2024-06-25-2336
1 parent b055e3e commit 2d61f92

9 files changed

+289
-78
lines changed

Package/Img/c4d_question.bmp

-306 Bytes
Binary file not shown.

Src/DefaultsQuestions/DelphiAIDev.DefaultsQuestions.AddEdit.View.dfm

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ object DelphiAIDevDefaultsQuestionsAddEditView: TDelphiAIDevDefaultsQuestionsAdd
33
Top = 0
44
BorderIcons = [biSystemMenu]
55
Caption = 'IA Developer - Defaults questions - [action]'
6-
ClientHeight = 350
6+
ClientHeight = 389
77
ClientWidth = 674
88
Color = clBtnFace
99
Font.Charset = DEFAULT_CHARSET
@@ -23,7 +23,7 @@ object DelphiAIDevDefaultsQuestionsAddEditView: TDelphiAIDevDefaultsQuestionsAdd
2323
object Bevel2: TBevel
2424
AlignWithMargins = True
2525
Left = 0
26-
Top = 311
26+
Top = 350
2727
Width = 674
2828
Height = 1
2929
Margins.Left = 0
@@ -37,7 +37,7 @@ object DelphiAIDevDefaultsQuestionsAddEditView: TDelphiAIDevDefaultsQuestionsAdd
3737
end
3838
object Panel1: TPanel
3939
Left = 0
40-
Top = 315
40+
Top = 354
4141
Width = 674
4242
Height = 35
4343
Align = alBottom
@@ -84,25 +84,25 @@ object DelphiAIDevDefaultsQuestionsAddEditView: TDelphiAIDevDefaultsQuestionsAdd
8484
Left = 0
8585
Top = 0
8686
Width = 674
87-
Height = 311
87+
Height = 350
8888
Align = alClient
8989
BevelOuter = bvNone
9090
ParentBackground = False
9191
TabOrder = 1
9292
DesignSize = (
9393
674
94-
311)
94+
350)
9595
object Label1: TLabel
9696
Left = 35
97-
Top = 54
97+
Top = 102
9898
Width = 43
9999
Height = 13
100100
Caption = 'Question'
101101
end
102102
object Bevel1: TBevel
103103
AlignWithMargins = True
104104
Left = 0
105-
Top = 307
105+
Top = 346
106106
Width = 674
107107
Height = 1
108108
Margins.Left = 0
@@ -115,21 +115,35 @@ object DelphiAIDevDefaultsQuestionsAddEditView: TDelphiAIDevDefaultsQuestionsAdd
115115
end
116116
object Label4: TLabel
117117
Left = 35
118-
Top = 191
118+
Top = 239
119119
Width = 28
120120
Height = 13
121121
Caption = 'Order'
122122
end
123123
object Label9: TLabel
124-
Left = 34
124+
Left = 183
125125
Top = 13
126126
Width = 62
127127
Height = 13
128128
Caption = 'Menu master'
129129
end
130+
object Label2: TLabel
131+
Left = 35
132+
Top = 12
133+
Width = 20
134+
Height = 13
135+
Caption = 'Kind'
136+
end
137+
object Label3: TLabel
138+
Left = 35
139+
Top = 56
140+
Width = 37
141+
Height = 13
142+
Caption = 'Caption'
143+
end
130144
object edtOrder: TEdit
131145
Left = 35
132-
Top = 206
146+
Top = 254
133147
Width = 126
134148
Height = 21
135149
MaxLength = 4
@@ -139,7 +153,7 @@ object DelphiAIDevDefaultsQuestionsAddEditView: TDelphiAIDevDefaultsQuestionsAdd
139153
end
140154
object UpDown1: TUpDown
141155
Left = 161
142-
Top = 206
156+
Top = 254
143157
Width = 17
144158
Height = 21
145159
Cursor = crHandPoint
@@ -149,7 +163,7 @@ object DelphiAIDevDefaultsQuestionsAddEditView: TDelphiAIDevDefaultsQuestionsAdd
149163
end
150164
object ckVisible: TCheckBox
151165
Left = 35
152-
Top = 238
166+
Top = 286
153167
Width = 53
154168
Height = 17
155169
Cursor = crHandPoint
@@ -158,17 +172,17 @@ object DelphiAIDevDefaultsQuestionsAddEditView: TDelphiAIDevDefaultsQuestionsAdd
158172
end
159173
object ckCodeOnly: TCheckBox
160174
Left = 35
161-
Top = 261
175+
Top = 309
162176
Width = 70
163177
Height = 17
164178
Cursor = crHandPoint
165179
Caption = 'Code Only'
166180
TabOrder = 3
167181
end
168182
object cBoxMenuMaster: TComboBox
169-
Left = 34
183+
Left = 183
170184
Top = 28
171-
Width = 597
185+
Width = 450
172186
Height = 21
173187
Margins.Left = 10
174188
Margins.Top = 15
@@ -181,11 +195,27 @@ object DelphiAIDevDefaultsQuestionsAddEditView: TDelphiAIDevDefaultsQuestionsAdd
181195
end
182196
object mmQuestion: TMemo
183197
Left = 34
184-
Top = 70
198+
Top = 118
185199
Width = 599
186200
Height = 116
187201
ScrollBars = ssVertical
188202
TabOrder = 5
189203
end
204+
object cBoxKind: TComboBox
205+
Left = 35
206+
Top = 28
207+
Width = 145
208+
Height = 21
209+
Style = csDropDownList
210+
TabOrder = 6
211+
OnChange = cBoxKindChange
212+
end
213+
object edtCaption: TEdit
214+
Left = 35
215+
Top = 72
216+
Width = 598
217+
Height = 21
218+
TabOrder = 7
219+
end
190220
end
191221
end

Src/DefaultsQuestions/DelphiAIDev.DefaultsQuestions.AddEdit.View.pas

Lines changed: 92 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
5975
procedure TDelphiAIDevDefaultsQuestionsAddEditView.FormCreate(Sender: TObject);
6076
begin
6177
Self.ModalResult := mrCancel;
6278

6379
TUtilsOTA.IDEThemingAll(TDelphiAIDevDefaultsQuestionsAddEditView, Self);
80+
81+
FLastCaption := '';
82+
FLastQuestion := '';
83+
FLastItemIndexMenuMaster := 0;
84+
Self.FillcBoxKind;
6485
end;
6586

6687
procedure TDelphiAIDevDefaultsQuestionsAddEditView.FormDestroy(Sender: TObject);
@@ -70,13 +91,19 @@ procedure TDelphiAIDevDefaultsQuestionsAddEditView.FormDestroy(Sender: TObject);
7091

7192
procedure TDelphiAIDevDefaultsQuestionsAddEditView.FormShow(Sender: TObject);
7293
begin
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;
80107
end;
81108

82109
procedure 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

135162
procedure TDelphiAIDevDefaultsQuestionsAddEditView.btnConfirmClick(Sender: TObject);
136163
begin
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;
154189
end;
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+
156241
procedure TDelphiAIDevDefaultsQuestionsAddEditView.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
157242
begin
158243
case(Key)of

Src/DefaultsQuestions/DelphiAIDev.DefaultsQuestions.Fields.pas

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,28 @@
22

33
interface
44

5+
uses
6+
DelphiAIDev.Types;
7+
58
type
69
TDelphiAIDevDefaultsQuestionsFields = class
710
private
811
FGuid: string;
912
FGuidMenuMaster: string;
1013
FQuestion: string;
14+
FKind: TC4DQuestionKind;
1115
FOrder: Integer;
1216
FVisible: Boolean;
1317
FCodeOnly: Boolean;
18+
FCaption: string;
1419
public
1520
constructor Create;
1621
procedure Clear;
1722
property Guid: string read FGuid write FGuid;
1823
property GuidMenuMaster: string read FGuidMenuMaster write FGuidMenuMaster;
24+
property Caption: string read FCaption write FCaption;
1925
property Question: string read FQuestion write FQuestion;
26+
property Kind: TC4DQuestionKind read FKind write FKind;
2027
property Order: Integer read FOrder write FOrder;
2128
property Visible: Boolean read FVisible write FVisible;
2229
property CodeOnly: Boolean read FCodeOnly write FCodeOnly;
@@ -33,7 +40,9 @@ procedure TDelphiAIDevDefaultsQuestionsFields.Clear;
3340
begin
3441
FGuid := '';
3542
FGuidMenuMaster := '';
43+
FCaption := '';
3644
FQuestion := '';
45+
FKind := TC4DQuestionKind.ItemMenuNormal;
3746
FOrder := 0;
3847
FVisible := True;
3948
FCodeOnly := False;

0 commit comments

Comments
 (0)