* Allow designing of aggregates (bug ID #33264)

git-svn-id: trunk@57455 -
This commit is contained in:
michael 2018-03-06 10:00:26 +00:00
parent b796e9c3bd
commit 99ef8d5cec
2 changed files with 263 additions and 38 deletions

View File

@ -1,24 +1,23 @@
object ReportVariablesForm: TReportVariablesForm object ReportVariablesForm: TReportVariablesForm
Left = 656 Left = 656
Height = 365 Height = 390
Top = 245 Top = 245
Width = 445 Width = 616
Caption = 'Report variables' Caption = 'Report variables'
ClientHeight = 365 ClientHeight = 390
ClientWidth = 445 ClientWidth = 616
OnCloseQuery = FormCloseQuery OnCloseQuery = FormCloseQuery
OnCreate = FormCreate OnCreate = FormCreate
LCLVersion = '1.9.0.0' LCLVersion = '1.9.0.0'
object LBVariables: TListBox object LBVariables: TListBox
Left = 16 Left = 16
Height = 277 Height = 302
Top = 32 Top = 32
Width = 216 Width = 208
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
ItemHeight = 0 ItemHeight = 0
OnSelectionChange = LBVariablesSelectionChange OnSelectionChange = LBVariablesSelectionChange
Options = [lboDrawFocusRect] ScrollWidth = 206
ScrollWidth = 214
TabOrder = 0 TabOrder = 0
TopIndex = -1 TopIndex = -1
end end
@ -33,8 +32,8 @@ object ReportVariablesForm: TReportVariablesForm
object BPVariables: TButtonPanel object BPVariables: TButtonPanel
Left = 6 Left = 6
Height = 42 Height = 42
Top = 317 Top = 342
Width = 433 Width = 604
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton' HelpButton.Name = 'HelpButton'
@ -49,7 +48,7 @@ object ReportVariablesForm: TReportVariablesForm
object SBDelete: TSpeedButton object SBDelete: TSpeedButton
AnchorSideRight.Control = LBVariables AnchorSideRight.Control = LBVariables
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 209 Left = 201
Height = 22 Height = 22
Top = 5 Top = 5
Width = 23 Width = 23
@ -59,7 +58,7 @@ object ReportVariablesForm: TReportVariablesForm
end end
object SBAdd: TSpeedButton object SBAdd: TSpeedButton
AnchorSideRight.Control = SBDelete AnchorSideRight.Control = SBDelete
Left = 186 Left = 178
Height = 22 Height = 22
Top = 5 Top = 5
Width = 23 Width = 23
@ -68,18 +67,18 @@ object ReportVariablesForm: TReportVariablesForm
ShowCaption = False ShowCaption = False
end end
object EName: TEdit object EName: TEdit
Left = 302 Left = 305
Height = 27 Height = 27
Top = 40 Top = 32
Width = 120 Width = 288
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
TabOrder = 2 TabOrder = 2
Text = 'EName' Text = 'EName'
end end
object CBType: TComboBox object CBType: TComboBox
Left = 302 Left = 305
Height = 31 Height = 27
Top = 72 Top = 64
Width = 120 Width = 120
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
ItemHeight = 0 ItemHeight = 0
@ -95,9 +94,9 @@ object ReportVariablesForm: TReportVariablesForm
TabOrder = 3 TabOrder = 3
end end
object LEName: TLabel object LEName: TLabel
Left = 238 Left = 241
Height = 27 Height = 27
Top = 40 Top = 32
Width = 58 Width = 58
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
@ -107,21 +106,21 @@ object ReportVariablesForm: TReportVariablesForm
ParentColor = False ParentColor = False
end end
object LCBType: TLabel object LCBType: TLabel
Left = 237 Left = 240
Height = 29 Height = 29
Top = 72 Top = 64
Width = 59 Width = 59
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
AutoSize = False AutoSize = False
Caption = 'Type' Caption = 'Data Type'
Layout = tlCenter Layout = tlCenter
ParentColor = False ParentColor = False
end end
object LValue: TLabel object LValue: TLabel
Left = 238 Left = 241
Height = 27 Height = 27
Top = 104 Top = 96
Width = 58 Width = 58
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
@ -131,34 +130,34 @@ object ReportVariablesForm: TReportVariablesForm
ParentColor = False ParentColor = False
end end
object CBBoolean: TCheckBox object CBBoolean: TCheckBox
Left = 302 Left = 576
Height = 22 Height = 22
Top = 256 Top = 69
Width = 22 Width = 22
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
TabOrder = 4 TabOrder = 4
end end
object EString: TEdit object EString: TEdit
Left = 302 Left = 305
Height = 27 Height = 27
Top = 106 Top = 98
Width = 120 Width = 288
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
TabOrder = 5 TabOrder = 5
Text = 'EString' Text = 'EString'
end end
object SEinteger: TSpinEdit object SEinteger: TSpinEdit
Left = 302 Left = 400
Height = 27 Height = 27
Top = 184 Top = 112
Width = 86 Width = 86
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
TabOrder = 6 TabOrder = 6
end end
object SEFloat: TFloatSpinEdit object SEFloat: TFloatSpinEdit
Left = 302 Left = 496
Height = 27 Height = 27
Top = 152 Top = 112
Width = 88 Width = 88
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
Increment = 1 Increment = 1
@ -168,9 +167,9 @@ object ReportVariablesForm: TReportVariablesForm
Value = 0 Value = 0
end end
object DEDateTime: TDateEdit object DEDateTime: TDateEdit
Left = 302 Left = 448
Height = 27 Height = 27
Top = 216 Top = 66
Width = 120 Width = 120
CalendarDisplaySettings = [dsShowHeadings, dsShowDayNames] CalendarDisplaySettings = [dsShowHeadings, dsShowDayNames]
DateOrder = doNone DateOrder = doNone
@ -181,6 +180,106 @@ object ReportVariablesForm: TReportVariablesForm
TabOrder = 8 TabOrder = 8
Text = 'DEDateTime' Text = 'DEDateTime'
end end
object CBAggregate: TCheckBox
Left = 305
Height = 22
Top = 136
Width = 22
Anchors = [akTop, akRight]
OnChange = CBAggregateChange
TabOrder = 9
end
object LCBExpression: TLabel
Left = 225
Height = 23
Top = 136
Width = 74
Alignment = taRightJustify
Anchors = [akTop, akRight]
AutoSize = False
Caption = 'Aggregate'
FocusControl = CBAggregate
ParentColor = False
end
object LValue1: TLabel
Left = 225
Height = 27
Top = 168
Width = 74
Alignment = taRightJustify
Anchors = [akTop, akRight]
AutoSize = False
Caption = 'Expression'
FocusControl = EExpression
Layout = tlCenter
ParentColor = False
end
object EExpression: TEdit
Left = 305
Height = 27
Top = 168
Width = 288
Anchors = [akTop, akRight]
TabOrder = 10
Text = 'EExpression'
end
object LCBResetExpression: TLabel
Left = 225
Height = 27
Top = 232
Width = 74
Alignment = taRightJustify
Anchors = [akTop, akRight]
AutoSize = False
Caption = 'Reset'
FocusControl = CBResetExpression
Layout = tlCenter
ParentColor = False
end
object CBResetExpression: TComboBox
Left = 306
Height = 29
Top = 232
Width = 288
Anchors = [akTop, akRight]
ItemHeight = 0
Items.Strings = (
'PageNo'
'ColNo'
)
OnSelect = CBTypeSelect
TabOrder = 11
end
object CBResetType: TComboBox
Left = 305
Height = 27
Top = 200
Width = 120
Anchors = [akTop, akRight]
ItemHeight = 0
Items.Strings = (
'None'
'Group'
'Page'
'Column'
)
OnChange = CBResetTypeChange
OnSelect = CBTypeSelect
Style = csDropDownList
TabOrder = 12
end
object LCBType1: TLabel
Left = 232
Height = 29
Top = 198
Width = 67
Alignment = taRightJustify
Anchors = [akTop, akRight]
AutoSize = False
Caption = 'Reset Type'
Layout = tlCenter
ParentColor = False
end
object ALVariables: TActionList object ALVariables: TActionList
Images = ILVariables Images = ILVariables
left = 192 left = 192

View File

@ -40,10 +40,18 @@ type
BPVariables: TButtonPanel; BPVariables: TButtonPanel;
CBType: TComboBox; CBType: TComboBox;
CBBoolean: TCheckBox; CBBoolean: TCheckBox;
CBAggregate: TCheckBox;
CBResetExpression: TComboBox;
CBResetType: TComboBox;
DEDateTime: TDateEdit; DEDateTime: TDateEdit;
EString: TEdit; EString: TEdit;
EName: TEdit; EName: TEdit;
EExpression: TEdit;
ILVariables: TImageList; ILVariables: TImageList;
LCBExpression: TLabel;
LCBType1: TLabel;
LValue1: TLabel;
LCBResetExpression: TLabel;
SEFloat: TFloatSpinEdit; SEFloat: TFloatSpinEdit;
LEName: TLabel; LEName: TLabel;
LCBType: TLabel; LCBType: TLabel;
@ -55,6 +63,8 @@ type
SEinteger: TSpinEdit; SEinteger: TSpinEdit;
procedure ADeleteVariableExecute(Sender: TObject); procedure ADeleteVariableExecute(Sender: TObject);
procedure ADeleteVariableUpdate(Sender: TObject); procedure ADeleteVariableUpdate(Sender: TObject);
procedure CBAggregateChange(Sender: TObject);
procedure CBResetTypeChange(Sender: TObject);
procedure CBTypeSelect(Sender: TObject); procedure CBTypeSelect(Sender: TObject);
procedure DoAddVariable(Sender: TObject); procedure DoAddVariable(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean); procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
@ -63,10 +73,18 @@ type
private private
FCurrentVariable: TFPReportVariable; FCurrentVariable: TFPReportVariable;
FValueControls : Array[TResultType] of TControl; FValueControls : Array[TResultType] of TControl;
procedure CheckExpression;
procedure CheckResetType;
procedure FillExpressionsList;
function GetCurrentIsExpression: Boolean;
function GetCurrentResetType: TFPReportResetType;
function GetType: TResultType; function GetType: TResultType;
procedure SetCurrentIsExpression(AValue: Boolean);
procedure SetCurrentResetType(AValue: TFPReportResetType);
procedure SetCurrentVariable(AValue: TFPReportVariable); procedure SetCurrentVariable(AValue: TFPReportVariable);
procedure SetType(AValue: TResultType); procedure SetType(AValue: TResultType);
Protected Protected
procedure SetReport(AValue: TFPCustomReport); override;
procedure SetVariables(AValue: TFPReportVariables); override; procedure SetVariables(AValue: TFPReportVariables); override;
procedure ShowCurrentTypeEditor; virtual; procedure ShowCurrentTypeEditor; virtual;
procedure SetCurrentVariableFromList; virtual; procedure SetCurrentVariableFromList; virtual;
@ -75,6 +93,8 @@ type
procedure VariablesToForm; virtual; procedure VariablesToForm; virtual;
Property CurrentVariable : TFPReportVariable Read FCurrentVariable Write SetCurrentVariable; Property CurrentVariable : TFPReportVariable Read FCurrentVariable Write SetCurrentVariable;
Property CurrentType : TResultType Read GetType Write SetType; Property CurrentType : TResultType Read GetType Write SetType;
property CurrentIsExpression : Boolean Read GetCurrentIsExpression Write SetCurrentIsExpression;
Property CurrentResetType : TFPReportResetType Read GetCurrentResetType Write SetCurrentResetType;
end; end;
implementation implementation
@ -178,6 +198,16 @@ begin
(Sender as TAction).Enabled:=(FCurrentVariable<>Nil); (Sender as TAction).Enabled:=(FCurrentVariable<>Nil);
end; end;
procedure TReportVariablesForm.CBAggregateChange(Sender: TObject);
begin
CheckExpression;
end;
procedure TReportVariablesForm.CBResetTypeChange(Sender: TObject);
begin
CheckResetType;
end;
procedure TReportVariablesForm.CBTypeSelect(Sender: TObject); procedure TReportVariablesForm.CBTypeSelect(Sender: TObject);
begin begin
ShowCurrentTypeEditor; ShowCurrentTypeEditor;
@ -222,6 +252,54 @@ begin
Result:=TResultType(CBType.ItemIndex); Result:=TResultType(CBType.ItemIndex);
end; end;
function TReportVariablesForm.GetCurrentIsExpression: Boolean;
begin
Result:=CBAggregate.Checked;
end;
function TReportVariablesForm.GetCurrentResetType: TFPReportResetType;
begin
if CBResetType.ItemIndex=-1 then
Result:=rtNone
else
Result:=TFPReportResetType(CBResetType.ItemIndex)
end;
procedure TReportVariablesForm.SetCurrentIsExpression(AValue: Boolean);
begin
CBAggregate.Checked:=AValue;
CheckExpression;
end;
procedure TReportVariablesForm.SetCurrentResetType(AValue: TFPReportResetType);
begin
CBResetType.ItemIndex:=Ord(AValue);
CheckResetType;
end;
procedure TReportVariablesForm.CheckResetType;
begin
CBResetType.Enabled:=CBAggregate.Checked;
CBResetExpression.Enabled:=CBAggregate.Checked and (CurrentResetType in [rtGroup]);
Case CurrentResetType of
rtPage: CBResetExpression.Text:='PageNo';
rtColumn: CBResetExpression.Text:='ColNo';
rtGroup,
rtNone : if not CBResetExpression.Enabled then
CBResetExpression.Text:=''
end;
end;
procedure TReportVariablesForm.CheckExpression;
begin
EExpression.Enabled:=CBAggregate.Checked;
if not EExpression.Enabled then
EExpression.Text:='';
CheckResetType;
end;
procedure TReportVariablesForm.SetType(AValue: TResultType); procedure TReportVariablesForm.SetType(AValue: TResultType);
begin begin
@ -229,6 +307,31 @@ begin
ShowCurrentTypeEditor; ShowCurrentTypeEditor;
end; end;
procedure TReportVariablesForm.SetReport(AValue: TFPCustomReport);
begin
inherited SetReport(AValue);
FillExpressionsList;
end;
procedure TReportVariablesForm.FillExpressionsList;
Var
R : TFPReport;
S : String;
I,J : Integer;
begin
R:=TFPReport(Report);
For I:=0 to R.PageCount-1 do
For J:=0 to R.Pages[I].BandCount-1 do
If R.Pages[I].Bands[J] is TFPReportCustomGroupHeaderBand then
begin
S:=TFPReportGroupHeaderBand(R.Pages[I].Bands[J]).GroupCondition;
if (S<>'') then
CBResetExpression.Items.Add(S);
end;
end;
procedure TReportVariablesForm.ShowCurrentTypeEditor; procedure TReportVariablesForm.ShowCurrentTypeEditor;
Var Var
@ -255,6 +358,7 @@ begin
end; end;
FCurrentVariable.DataType:=CurrentType; FCurrentVariable.DataType:=CurrentType;
With FCurrentVariable do With FCurrentVariable do
begin
Case DataType of Case DataType of
rtBoolean : AsBoolean:=CBBoolean.Checked; rtBoolean : AsBoolean:=CBBoolean.Checked;
rtInteger : AsInteger:=SEinteger.Value; rtInteger : AsInteger:=SEinteger.Value;
@ -263,7 +367,20 @@ begin
rtString : AsString := EString.Text; rtString : AsString := EString.Text;
else else
Raise Exception.Create('Unknown datatype !'); Raise Exception.Create('Unknown datatype !');
end end;
If CurrentIsExpression then
begin
FCurrentVariable.Expression:=EExpression.Text;
FCurrentVariable.ResetType:=CurrentResetType;
FCurrentVariable.ResetValueExpression:=CBResetExpression.Text;
end
else
begin
FCurrentVariable.Expression:='';
FCurrentVariable.ResetType:=rtNone;
FCurrentVariable.ResetValueExpression:='';
end
end;
end; end;
procedure TReportVariablesForm.ShowCurrentVariable; procedure TReportVariablesForm.ShowCurrentVariable;
@ -275,6 +392,8 @@ begin
HV:=Assigned(FCurrentVariable); HV:=Assigned(FCurrentVariable);
EName.Enabled:=HV; EName.Enabled:=HV;
CBType.Enabled:=HV; CBType.Enabled:=HV;
CurrentIsExpression:=HV and (FCurrentVariable.Expression<>'');
CBAggregate.Enabled:=HV;
if not HV then if not HV then
begin begin
EName.Text:=''; EName.Text:='';
@ -295,7 +414,14 @@ begin
rtString : EString.Text:=AsString; rtString : EString.Text:=AsString;
else else
Raise Exception.Create('Unknown datatype !'); Raise Exception.Create('Unknown datatype !');
end end;
CurrentIsExpression:=FCurrentVariable.Expression<>'';
If CurrentIsExpression then
begin
EExpression.Text:=FCurrentVariable.Expression;
CurrentResetType:=FCurrentVariable.ResetType;
CBResetExpression.Text:=FCurrentVariable.ResetValueExpression;
end;
end; end;
end; end;