mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-18 15:39:05 +02:00
* Patch from Henrique Werlang to let datalink transmit events ony when active
This commit is contained in:
parent
b8155b93cb
commit
b70bd9f844
@ -90,7 +90,7 @@ type
|
|||||||
property OriginalException : Exception read FOriginalException;
|
property OriginalException : Exception read FOriginalException;
|
||||||
property PreviousError : Integer read FPreviousError;
|
property PreviousError : Integer read FPreviousError;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TFieldDef }
|
{ TFieldDef }
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ type
|
|||||||
protected
|
protected
|
||||||
function GetDisplayName: string; override;
|
function GetDisplayName: string; override;
|
||||||
procedure SetDisplayName(const Value: string); override;
|
procedure SetDisplayName(const Value: string); override;
|
||||||
Public
|
Public
|
||||||
property DisplayName : string read GetDisplayName write SetDisplayName;
|
property DisplayName : string read GetDisplayName write SetDisplayName;
|
||||||
published
|
published
|
||||||
property Name : string read FName write SetDisplayName;
|
property Name : string read FName write SetDisplayName;
|
||||||
@ -999,7 +999,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{ TDataSet }
|
{ TDataSet }
|
||||||
|
|
||||||
TBookmarkFlag = (bfCurrent, bfBOF, bfEOF, bfInserted);
|
TBookmarkFlag = (bfCurrent, bfBOF, bfEOF, bfInserted);
|
||||||
TBookmark = record
|
TBookmark = record
|
||||||
Data : JSValue;
|
Data : JSValue;
|
||||||
@ -1774,7 +1774,7 @@ Function ExtractFieldName(Const Fields: String; var Pos: Integer): String;
|
|||||||
// function SkipComments(var p: PChar; EscapeSlash, EscapeRepeat : Boolean) : boolean;
|
// function SkipComments(var p: PChar; EscapeSlash, EscapeRepeat : Boolean) : boolean;
|
||||||
|
|
||||||
// operator Enumerator(ADataSet: TDataSet): TDataSetEnumerator;
|
// operator Enumerator(ADataSet: TDataSet): TDataSetEnumerator;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses DBConst,TypInfo;
|
uses DBConst,TypInfo;
|
||||||
@ -1954,7 +1954,7 @@ end;
|
|||||||
{ EUpdateError }
|
{ EUpdateError }
|
||||||
constructor EUpdateError.Create(NativeError, Context : String;
|
constructor EUpdateError.Create(NativeError, Context : String;
|
||||||
ErrCode, PrevError : integer; E: Exception);
|
ErrCode, PrevError : integer; E: Exception);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Inherited CreateFmt(NativeError,[Context]);
|
Inherited CreateFmt(NativeError,[Context]);
|
||||||
FContext := Context;
|
FContext := Context;
|
||||||
@ -2456,7 +2456,7 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
OldState: TDatasetState;
|
OldState: TDatasetState;
|
||||||
begin
|
begin
|
||||||
FCalcBuffer := Buffer;
|
FCalcBuffer := Buffer;
|
||||||
if FState <> dsInternalCalc then
|
if FState <> dsInternalCalc then
|
||||||
begin
|
begin
|
||||||
OldState := FState;
|
OldState := FState;
|
||||||
@ -2548,7 +2548,7 @@ procedure TDataSet.DataEvent(Event: TDataEvent; Info: JSValue);
|
|||||||
begin
|
begin
|
||||||
if aField.FieldKind in [fkData, fkInternalCalc] then
|
if aField.FieldKind in [fkData, fkInternalCalc] then
|
||||||
SetModified(True);
|
SetModified(True);
|
||||||
|
|
||||||
if State <> dsSetKey then begin
|
if State <> dsSetKey then begin
|
||||||
if aField.FieldKind = fkData then begin
|
if aField.FieldKind = fkData then begin
|
||||||
if FInternalCalcFields then
|
if FInternalCalcFields then
|
||||||
@ -2559,7 +2559,7 @@ procedure TDataSet.DataEvent(Event: TDataEvent; Info: JSValue);
|
|||||||
aField.Change;
|
aField.Change;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure HandleScrollOrChange;
|
procedure HandleScrollOrChange;
|
||||||
var
|
var
|
||||||
A: Integer;
|
A: Integer;
|
||||||
@ -2587,7 +2587,7 @@ begin
|
|||||||
deFieldChange : HandleFieldChange(TField(Info));
|
deFieldChange : HandleFieldChange(TField(Info));
|
||||||
deDataSetChange,
|
deDataSetChange,
|
||||||
deDataSetScroll : HandleScrollOrChange;
|
deDataSetScroll : HandleScrollOrChange;
|
||||||
deLayoutChange : FEnableControlsEvent:=deLayoutChange;
|
deLayoutChange : FEnableControlsEvent:=deLayoutChange;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if not ControlsDisabled and (FState <> dsBlockRead) then begin
|
if not ControlsDisabled and (FState <> dsBlockRead) then begin
|
||||||
@ -3248,10 +3248,10 @@ end;
|
|||||||
|
|
||||||
function TDataSet.GetIndexDefs(IndexDefs: TIndexDefs; IndexTypes: TIndexOptions
|
function TDataSet.GetIndexDefs(IndexDefs: TIndexDefs; IndexTypes: TIndexOptions
|
||||||
): TIndexDefs;
|
): TIndexDefs;
|
||||||
|
|
||||||
var i,f : integer;
|
var i,f : integer;
|
||||||
IndexFields : TStrings;
|
IndexFields : TStrings;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
IndexDefs.Update;
|
IndexDefs.Update;
|
||||||
Result := TIndexDefs.Create(Self);
|
Result := TIndexDefs.Create(Self);
|
||||||
@ -3399,15 +3399,15 @@ begin
|
|||||||
FBlockReadSize := AValue;
|
FBlockReadSize := AValue;
|
||||||
if AValue > 0 then
|
if AValue > 0 then
|
||||||
begin
|
begin
|
||||||
CheckActive;
|
CheckActive;
|
||||||
SetState(dsBlockRead);
|
SetState(dsBlockRead);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
//update state only when in dsBlockRead
|
//update state only when in dsBlockRead
|
||||||
if FState = dsBlockRead then
|
if FState = dsBlockRead then
|
||||||
SetState(dsBrowse);
|
SetState(dsBrowse);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDataSet.SetFieldDefs(AFieldDefs: TFieldDefs);
|
procedure TDataSet.SetFieldDefs(AFieldDefs: TFieldDefs);
|
||||||
@ -5750,7 +5750,7 @@ begin
|
|||||||
if not Assigned(FLookupDataSet) or (Length(FLookupKeyfields) = 0)
|
if not Assigned(FLookupDataSet) or (Length(FLookupKeyfields) = 0)
|
||||||
or (Length(FLookupresultField) = 0) or (Length(FKeyFields) = 0) then
|
or (Length(FLookupresultField) = 0) or (Length(FKeyFields) = 0) then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
tmpActive := FLookupDataSet.Active;
|
tmpActive := FLookupDataSet.Active;
|
||||||
try
|
try
|
||||||
FLookupDataSet.Active := True;
|
FLookupDataSet.Active := True;
|
||||||
@ -6661,7 +6661,7 @@ begin
|
|||||||
Fmt:=FDisplayFormat
|
Fmt:=FDisplayFormat
|
||||||
else
|
else
|
||||||
Fmt:=FEditFormat;
|
Fmt:=FEditFormat;
|
||||||
|
|
||||||
Digits := 0;
|
Digits := 0;
|
||||||
if not FCurrency then
|
if not FCurrency then
|
||||||
ff := ffGeneral
|
ff := ffGeneral
|
||||||
@ -6705,7 +6705,7 @@ var f : Double;
|
|||||||
begin
|
begin
|
||||||
If (AValue='') then
|
If (AValue='') then
|
||||||
Clear
|
Clear
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
If not TryStrToFloat(AValue,F) then
|
If not TryStrToFloat(AValue,F) then
|
||||||
DatabaseErrorFmt(SNotAFloat, [AValue]);
|
DatabaseErrorFmt(SNotAFloat, [AValue]);
|
||||||
@ -7494,7 +7494,7 @@ procedure TFields.Clear;
|
|||||||
var
|
var
|
||||||
AField: TField;
|
AField: TField;
|
||||||
begin
|
begin
|
||||||
while FFieldList.Count > 0 do
|
while FFieldList.Count > 0 do
|
||||||
begin
|
begin
|
||||||
AField := TField(FFieldList.Last);
|
AField := TField(FFieldList.Last);
|
||||||
AField.FDataSet := Nil;
|
AField.FDataSet := Nil;
|
||||||
@ -7609,12 +7609,8 @@ Var
|
|||||||
B : Boolean;
|
B : Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
B:=Assigned(DataSource) and Not (DataSource.State in [dsInactive,dsOpening]);
|
B:=Assigned(DataSource) and not (DataSource.State in [dsInactive, dsOpening]);
|
||||||
If B<>FActive then
|
SetActive(B);
|
||||||
begin
|
|
||||||
FActive:=B;
|
|
||||||
ActiveChanged;
|
|
||||||
end;
|
|
||||||
B:=Assigned(DataSource) and (DataSource.State in dsEditModes) and Not FReadOnly;
|
B:=Assigned(DataSource) and (DataSource.State in dsEditModes) and Not FReadOnly;
|
||||||
If B<>FEditing Then
|
If B<>FEditing Then
|
||||||
begin
|
begin
|
||||||
@ -7637,7 +7633,7 @@ begin
|
|||||||
else if DataSource.DataSet.FActiveRecord < FFirstRecord + Index then
|
else if DataSource.DataSet.FActiveRecord < FFirstRecord + Index then
|
||||||
Result := DataSource.DataSet.FActiveRecord - (FFirstRecord + Index)
|
Result := DataSource.DataSet.FActiveRecord - (FFirstRecord + Index)
|
||||||
else Result := 0;
|
else Result := 0;
|
||||||
|
|
||||||
Inc(FFirstRecord, Index + Result);
|
Inc(FFirstRecord, Index + Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -7663,30 +7659,31 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
Procedure TDataLink.DataEvent(Event: TDataEvent; Info: JSValue);
|
Procedure TDataLink.DataEvent(Event: TDataEvent; Info: JSValue);
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Case Event of
|
if Event = deUpdateState then
|
||||||
deFieldChange, deRecordChange:
|
CheckActiveAndEditing
|
||||||
If Not FUpdatingRecord then
|
else if Active then
|
||||||
RecordChanged(TField(Info));
|
case Event of
|
||||||
deDataSetChange: begin
|
deFieldChange, deRecordChange:
|
||||||
SetActive(DataSource.DataSet.Active);
|
if not FUpdatingRecord then
|
||||||
CalcRange;
|
RecordChanged(TField(Info));
|
||||||
CalcFirstRecord(Integer(Info));
|
deDataSetChange:
|
||||||
DatasetChanged;
|
begin
|
||||||
|
SetActive(DataSource.DataSet.Active);
|
||||||
|
CalcRange;
|
||||||
|
CalcFirstRecord(Integer(Info));
|
||||||
|
DatasetChanged;
|
||||||
|
end;
|
||||||
|
deDataSetScroll: DatasetScrolled(CalcFirstRecord(Integer(Info)));
|
||||||
|
deLayoutChange:
|
||||||
|
begin
|
||||||
|
CalcFirstRecord(Integer(Info));
|
||||||
|
LayoutChanged;
|
||||||
|
end;
|
||||||
|
deUpdateRecord: UpdateRecord;
|
||||||
|
deCheckBrowseMode: CheckBrowseMode;
|
||||||
|
deFocusControl: FocusControl(Info);
|
||||||
end;
|
end;
|
||||||
deDataSetScroll: DatasetScrolled(CalcFirstRecord(Integer(Info)));
|
|
||||||
deLayoutChange: begin
|
|
||||||
CalcFirstRecord(Integer(Info));
|
|
||||||
LayoutChanged;
|
|
||||||
end;
|
|
||||||
deUpdateRecord: UpdateRecord;
|
|
||||||
deUpdateState: CheckActiveAndEditing;
|
|
||||||
deCheckBrowseMode: CheckBrowseMode;
|
|
||||||
deFocusControl:
|
|
||||||
FocusControl(Info);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -7728,7 +7725,7 @@ begin
|
|||||||
If Assigned(Datasource) then
|
If Assigned(Datasource) then
|
||||||
Result:=DataSource.DataSet
|
Result:=DataSource.DataSet
|
||||||
else
|
else
|
||||||
Result:=Nil;
|
Result:=Nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -7923,7 +7920,7 @@ begin
|
|||||||
if Active and (FFields.Count > 0) then
|
if Active and (FFields.Count > 0) then
|
||||||
DoMasterChange
|
DoMasterChange
|
||||||
else
|
else
|
||||||
DoMasterDisable;
|
DoMasterDisable;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -7954,7 +7951,7 @@ begin
|
|||||||
if (DataSource.State <> dsSetKey) and FDetailDataSet.Active and
|
if (DataSource.State <> dsSetKey) and FDetailDataSet.Active and
|
||||||
(FFields.Count > 0) and ((Field = nil) or
|
(FFields.Count > 0) and ((Field = nil) or
|
||||||
(FFields.IndexOf(Field) >= 0)) then
|
(FFields.IndexOf(Field) >= 0)) then
|
||||||
DoMasterChange;
|
DoMasterChange;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMasterDatalink.SetFieldNames(const Value: string);
|
procedure TMasterDatalink.SetFieldNames(const Value: string);
|
||||||
@ -7967,14 +7964,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TMasterDataLink.DoMasterDisable;
|
Procedure TMasterDataLink.DoMasterDisable;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnMasterDisable) then
|
if Assigned(FOnMasterDisable) then
|
||||||
FOnMasterDisable(Self);
|
FOnMasterDisable(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TMasterDataLink.DoMasterChange;
|
Procedure TMasterDataLink.DoMasterChange;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If Assigned(FOnMasterChange) then
|
If Assigned(FOnMasterChange) then
|
||||||
@ -7997,7 +7994,7 @@ begin
|
|||||||
P:=TParams(GetObjectProp(ADataset,'Params',TParams));
|
P:=TParams(GetObjectProp(ADataset,'Params',TParams));
|
||||||
if (P<>Nil) then
|
if (P<>Nil) then
|
||||||
Params:=P;
|
Params:=P;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -8009,7 +8006,7 @@ begin
|
|||||||
RefreshParamNames;
|
RefreshParamNames;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TMasterParamsDataLink.RefreshParamNames;
|
Procedure TMasterParamsDataLink.RefreshParamNames;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
FN : String;
|
FN : String;
|
||||||
@ -8041,7 +8038,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
FieldNames:=FN;
|
FieldNames:=FN;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TMasterParamsDataLink.CopyParamsFromMaster(CopyBound : Boolean);
|
Procedure TMasterParamsDataLink.CopyParamsFromMaster(CopyBound : Boolean);
|
||||||
@ -8051,7 +8048,7 @@ begin
|
|||||||
FParams.CopyParamValuesFromDataset(Dataset,CopyBound);
|
FParams.CopyParamValuesFromDataset(Dataset,CopyBound);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TMasterParamsDataLink.DoMasterDisable;
|
Procedure TMasterParamsDataLink.DoMasterDisable;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Inherited;
|
Inherited;
|
||||||
@ -8059,7 +8056,7 @@ begin
|
|||||||
// If master dataset is reopened, relationship will be reestablished
|
// If master dataset is reopened, relationship will be reestablished
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TMasterParamsDataLink.DoMasterChange;
|
Procedure TMasterParamsDataLink.DoMasterChange;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Inherited;
|
Inherited;
|
||||||
|
Loading…
Reference in New Issue
Block a user