mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 17:09:10 +02:00
+ Patch from Alexandrov Alexandru to implement calculated fields
git-svn-id: trunk@388 -
This commit is contained in:
parent
a71e25ffe0
commit
96a556f1ba
@ -83,10 +83,16 @@ begin
|
|||||||
For I:=0 to FFieldList.Count-1 do
|
For I:=0 to FFieldList.Count-1 do
|
||||||
FFieldList[i].FFieldNo:=I;
|
FFieldList[i].FFieldNo:=I;
|
||||||
}
|
}
|
||||||
|
FCalcFieldsSize := 0;
|
||||||
FBlobFieldCount := 0;
|
FBlobFieldCount := 0;
|
||||||
for i := 0 to Fields.Count - 1 do
|
for i := 0 to Fields.Count - 1 do
|
||||||
with Fields[i] do begin
|
with Fields[i] do begin
|
||||||
if Binding then begin
|
if Binding then begin
|
||||||
|
if FieldKind in [fkCalculated, fkLookup] then begin
|
||||||
|
FFieldNo := -1;
|
||||||
|
FOffset := FCalcFieldsSize;
|
||||||
|
Inc(FCalcFieldsSize, DataSize + 1);
|
||||||
|
end else begin
|
||||||
FieldDef := nil;
|
FieldDef := nil;
|
||||||
FieldIndex := FieldDefs.IndexOf(Fields[i].FieldName);
|
FieldIndex := FieldDefs.IndexOf(Fields[i].FieldName);
|
||||||
if FieldIndex <> -1 then begin
|
if FieldIndex <> -1 then begin
|
||||||
@ -98,6 +104,7 @@ begin
|
|||||||
Inc(FBlobFieldCount);
|
Inc(FBlobFieldCount);
|
||||||
end;
|
end;
|
||||||
end else FFieldNo := FieldIndex;
|
end else FFieldNo := FieldIndex;
|
||||||
|
end;
|
||||||
end else FFieldNo := 0;;
|
end else FFieldNo := 0;;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -113,8 +120,17 @@ end;
|
|||||||
|
|
||||||
Procedure TDataset.CalculateFields(Buffer: PChar);
|
Procedure TDataset.CalculateFields(Buffer: PChar);
|
||||||
|
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
begin
|
begin
|
||||||
{ no internal calced fields or caches yet }
|
FCalcBuffer := Buffer;
|
||||||
|
if (State <> dsInternalCalc) and (IsUniDirectional = False) then
|
||||||
|
begin
|
||||||
|
ClearCalcFields(CalcBuffer);
|
||||||
|
for I := 0 to Fields.Count - 1 do
|
||||||
|
with Fields[I] do
|
||||||
|
if FieldKind = fkLookup then {CalcLookupValue};
|
||||||
|
end;
|
||||||
DoOnCalcFields;
|
DoOnCalcFields;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -424,8 +440,19 @@ end;
|
|||||||
|
|
||||||
Procedure TDataset.GetCalcFields(Buffer: PChar);
|
Procedure TDataset.GetCalcFields(Buffer: PChar);
|
||||||
|
|
||||||
|
var
|
||||||
|
dss: TDataSetState;
|
||||||
begin
|
begin
|
||||||
//!! To be implemented
|
if (FCalcFieldsSize > 0) or FInternalCalcFields then
|
||||||
|
begin
|
||||||
|
dss := FState;
|
||||||
|
FState := dsCalcFields;
|
||||||
|
try
|
||||||
|
CalculateFields(Buffer);
|
||||||
|
finally
|
||||||
|
FState := dss;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TDataset.GetCanModify: Boolean;
|
Function TDataset.GetCanModify: Boolean;
|
||||||
@ -1077,7 +1104,11 @@ Procedure TDataset.ClearFields;
|
|||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//!! To be implemented
|
DataEvent(deCheckBrowseMode, 0);
|
||||||
|
FreeFieldBuffers;
|
||||||
|
InternalInitRecord(ActiveBuffer);
|
||||||
|
if State <> dsSetKey then GetCalcFields(ActiveBuffer);
|
||||||
|
DataEvent(deRecordChange, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TDataset.Close;
|
Procedure TDataset.Close;
|
||||||
@ -1269,6 +1300,7 @@ begin
|
|||||||
DoBeforeEdit;
|
DoBeforeEdit;
|
||||||
If Not TryDoing(@InternalEdit,OnEditError) then
|
If Not TryDoing(@InternalEdit,OnEditError) then
|
||||||
exit;
|
exit;
|
||||||
|
GetCalcFields(ActiveBuffer);
|
||||||
SetState(dsedit);
|
SetState(dsedit);
|
||||||
DataEvent(deRecordChange,0);
|
DataEvent(deRecordChange,0);
|
||||||
DoAfterEdit;
|
DoAfterEdit;
|
||||||
|
Loading…
Reference in New Issue
Block a user