mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 11:09:42 +02:00
+ Added TBufDataset.Filtered, based on OnFilterRecord
git-svn-id: trunk@5500 -
This commit is contained in:
parent
c4b458b2f0
commit
17acf22a48
@ -139,8 +139,14 @@ end;
|
||||
|
||||
function TBufDataset.GetRecord(Buffer: PChar; GetMode: TGetMode; DoCheck: Boolean): TGetResult;
|
||||
|
||||
var Acceptable : Boolean;
|
||||
SaveState: TDataSetState;
|
||||
|
||||
|
||||
begin
|
||||
Result := grOK;
|
||||
repeat
|
||||
Acceptable := True;
|
||||
case GetMode of
|
||||
gmPrior :
|
||||
if not assigned(PBufRecLinkItem(FCurrentRecBuf)^.prior) then
|
||||
@ -187,9 +193,18 @@ begin
|
||||
end;
|
||||
move((pointer(FCurrentRecBuf)+sizeof(TBufRecLinkItem))^,buffer^,FRecordSize);
|
||||
GetCalcFields(Buffer);
|
||||
|
||||
if Filtered then
|
||||
begin
|
||||
FFilterBuffer := Buffer;
|
||||
SaveState := SetTempState(dsFilter);
|
||||
DoFilterRecord(Acceptable);
|
||||
RestoreState(SaveState);
|
||||
end;
|
||||
end
|
||||
else if (Result = grError) and doCheck then
|
||||
DatabaseError('No record');
|
||||
until Acceptable;
|
||||
end;
|
||||
|
||||
function TBufDataset.GetRecordUpdateBuffer : boolean;
|
||||
@ -314,6 +329,13 @@ begin
|
||||
Result := grOK;
|
||||
end;
|
||||
|
||||
function TBufDataset.GetCurrentBuffer: PChar;
|
||||
begin
|
||||
if State = dsFilter then Result := FFilterBuffer
|
||||
else Result := ActiveBuffer;
|
||||
end;
|
||||
|
||||
|
||||
function TBufDataset.GetFieldData(Field: TField; Buffer: Pointer;
|
||||
NativeFormat: Boolean): Boolean;
|
||||
begin
|
||||
@ -340,7 +362,7 @@ begin
|
||||
end
|
||||
else
|
||||
begin
|
||||
CurrBuff := ActiveBuffer;
|
||||
CurrBuff := GetCurrentBuffer;
|
||||
if not assigned(CurrBuff) then
|
||||
begin
|
||||
result := false;
|
||||
@ -746,7 +768,7 @@ Var SearchRecBuffer : PBufRecLinkItem;
|
||||
abuf : PChar;
|
||||
|
||||
begin
|
||||
abuf := ActiveBuffer;
|
||||
abuf := GetCurrentBuffer;
|
||||
// If abuf isn't assigned, the recordset probably isn't opened.
|
||||
if assigned(abuf) and (FBRecordCount>0) and (state <> dsInsert) then
|
||||
begin
|
||||
@ -907,6 +929,18 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBufDataset.DoFilterRecord(var Acceptable: Boolean);
|
||||
begin
|
||||
// check filtertext
|
||||
if Length(Filter) > 0 then
|
||||
begin
|
||||
end;
|
||||
|
||||
// check user filter
|
||||
if Acceptable and Assigned(OnFilterRecord) then
|
||||
OnFilterRecord(Self, Acceptable);
|
||||
end;
|
||||
|
||||
Function TBufDataset.Locate(const KeyFields: string; const KeyValues: Variant; options: TLocateOptions) : boolean;
|
||||
|
||||
|
||||
|
@ -1555,6 +1555,7 @@ type
|
||||
FCurrentRecBuf : PBufRecLinkItem;
|
||||
FLastRecBuf : PBufRecLinkItem;
|
||||
FFirstRecBuf : PBufRecLinkItem;
|
||||
FFilterBuffer : pchar;
|
||||
FBRecordCount : integer;
|
||||
|
||||
FPacketRecords : integer;
|
||||
@ -1572,12 +1573,14 @@ type
|
||||
FBlobBuffers : array of PBlobBuffer;
|
||||
FUpdateBlobBuffers: array of PBlobBuffer;
|
||||
|
||||
function GetCurrentBuffer: PChar;
|
||||
procedure CalcRecordSize;
|
||||
function LoadBuffer(Buffer : PChar): TGetResult;
|
||||
function GetFieldSize(FieldDef : TFieldDef) : longint;
|
||||
function GetRecordUpdateBuffer : boolean;
|
||||
procedure SetPacketRecords(aValue : integer);
|
||||
function IntAllocRecordBuffer: PChar;
|
||||
procedure DoFilterRecord(var Acceptable: Boolean);
|
||||
protected
|
||||
function GetNewBlobBuffer : PBlobBuffer;
|
||||
function GetNewWriteBlobBuffer : PBlobBuffer;
|
||||
|
@ -248,8 +248,8 @@ type
|
||||
published
|
||||
// redeclared data set properties
|
||||
property Active;
|
||||
// property Filter;
|
||||
// property Filtered;
|
||||
property Filter;
|
||||
property Filtered;
|
||||
property ServerFilter: string read FServerFilterText write SetServerFilterText;
|
||||
property ServerFiltered: Boolean read FServerFiltered write SetServerFiltered default False;
|
||||
// property FilterOptions;
|
||||
|
Loading…
Reference in New Issue
Block a user