Parcourir la source

* Allow descendents to change IsOpen

git-svn-id: trunk@38673 -
michael il y a 7 ans
Parent
commit
33a77a0bc7
2 fichiers modifiés avec 16 ajouts et 2 suppressions
  1. 8 2
      packages/fcl-report/src/fpreport.pp
  2. 8 0
      packages/fcl-report/src/fpreportdb.pp

+ 8 - 2
packages/fcl-report/src/fpreport.pp

@@ -454,6 +454,7 @@ type
     function CreateDataFields: TFPReportDataFields; virtual;
     procedure DoGetValue(const AFieldName: string; var AValue: variant); virtual;
     // Fill Datafields Collection. Should not change after Open.
+    function GetIsOpened: boolean; virtual;
     procedure DoInitDataFields; virtual;
     procedure DoOpen; virtual;
     procedure DoFirst; virtual;
@@ -482,7 +483,7 @@ type
     property FieldTypes[AFieldName: string]: TFPReportFieldKind read GetFieldType;
     property FieldCount: integer read GetFieldCount;
     property RecNo: integer read FRecNo;
-    property IsOpened: boolean read FIsOpened;
+    property IsOpened: boolean read GetIsOpened;
   published
     property OnOpen: TNotifyEvent read FOnOpen write FOnOpen;
     property OnClose: TNotifyEvent read FOnClose write FOnClose;
@@ -10246,6 +10247,11 @@ begin
   Result := FDataFields.FieldByName(AFieldName).DisplayWidth;
 end;
 
+function TFPReportData.GetIsOpened: boolean;
+begin
+  Result:=FIsOpened;
+end;
+
 function TFPReportData.GetLastFieldValue(AFieldName: string): variant;
 begin
   Result := FDataFields.FieldByName(AFieldName).FPrevValue;
@@ -10336,10 +10342,10 @@ end;
 
 procedure TFPReportData.First;
 begin
+  FRecNo := 1;
   if Assigned(FOnFirst) then
     FOnFirst(Self);
   DoFirst;
-  FRecNo := 1;
   InitFieldValues(False);
 end;
 

+ 8 - 0
packages/fcl-report/src/fpreportdb.pp

@@ -30,6 +30,7 @@ Type
     FDataSet: TDataSet;
     procedure SetDataSet(AValue: TDataSet);
   protected
+    function GetIsOpened: boolean; override;
     Procedure Notification(AComponent: TComponent; Operation: TOperation); override;
     procedure DoGetValue(const AFieldName: string; var AValue: variant); override;
     procedure DoInitDataFields; override;
@@ -65,6 +66,13 @@ begin
     FDataset.FreeNotification(Self);
 end;
 
+function TFPReportDatasetData.GetIsOpened: boolean;
+begin
+  Result:=inherited GetIsOpened;
+  if Result then
+    Result:=FDataset.Active; // Can be closed because of master-detail.
+end;
+
 procedure TFPReportDatasetData.Notification(AComponent: TComponent; Operation: TOperation);
 begin
   inherited Notification(AComponent, Operation);