- Fix to allow changing the filter while filtered

git-svn-id: trunk@1204 -
This commit is contained in:
joost 2005-09-27 16:45:55 +00:00
parent ec4d287fd8
commit 294bf06cda

View File

@ -190,6 +190,7 @@ type
procedure Execute; procedure Execute;
Procedure SQLParser(var SQL : string); Procedure SQLParser(var SQL : string);
procedure ApplyFilter;
Function AddFilter(SQLstr : string) : string; Function AddFilter(SQLstr : string) : string;
protected protected
// abstract & virtual methods of TBufDataset // abstract & virtual methods of TBufDataset
@ -208,6 +209,7 @@ type
function ApplyRecUpdate(UpdateKind : TUpdateKind) : boolean; override; function ApplyRecUpdate(UpdateKind : TUpdateKind) : boolean; override;
Function IsPrepared : Boolean; virtual; Function IsPrepared : Boolean; virtual;
procedure SetFiltered(Value: Boolean); override; procedure SetFiltered(Value: Boolean); override;
procedure SetFilterText(const Value: string); override;
public public
procedure Prepare; virtual; procedure Prepare; virtual;
procedure UnPrepare; virtual; procedure UnPrepare; virtual;
@ -576,13 +578,10 @@ begin
Result := SQLstr; Result := SQLstr;
end; end;
procedure TSQLQuery.SetFiltered(Value: Boolean); procedure TSQLQuery.ApplyFilter;
var S : String; var S : String;
begin
if Value and not FParseSQL then DatabaseErrorFmt(SNoParseSQL,['Filtering ']);
if (Filtered <> Value) and Active then
begin begin
FreeFldBuffers; FreeFldBuffers;
(Database as tsqlconnection).UnPrepareStatement(FCursor); (Database as tsqlconnection).UnPrepareStatement(FCursor);
@ -591,7 +590,7 @@ begin
s := FSQLBuf; s := FSQLBuf;
if Value then s := AddFilter(s); if Filtered then s := AddFilter(s);
(Database as tsqlconnection).PrepareStatement(Fcursor,(transaction as tsqltransaction),S,FParams); (Database as tsqlconnection).PrepareStatement(Fcursor,(transaction as tsqltransaction),S,FParams);
@ -599,7 +598,25 @@ begin
inherited InternalOpen; inherited InternalOpen;
First; First;
end; end;
procedure TSQLQuery.SetFiltered(Value: Boolean);
begin
if Value and not FParseSQL then DatabaseErrorFmt(SNoParseSQL,['Filtering ']);
if (Filtered <> Value) then
begin
inherited setfiltered(Value); inherited setfiltered(Value);
if active then ApplyFilter;
end;
end;
procedure TSQLQuery.SetFilterText(const Value: string);
begin
if Value <> Filter then
begin
inherited SetFilterText(Value);
if active then ApplyFilter;
end;
end; end;
procedure TSQLQuery.Prepare; procedure TSQLQuery.Prepare;