Răsfoiți Sursa

* TDataset.BlockReadSize, patch by Luiz, mantis 19897 (library part. test in that report not included)

git-svn-id: trunk@18099 -
marco 14 ani în urmă
părinte
comite
aeb7dac66e
2 a modificat fișierele cu 22 adăugiri și 1 ștergeri
  1. 19 1
      packages/fcl-db/src/base/dataset.inc
  2. 3 0
      packages/fcl-db/src/base/db.pas

+ 19 - 1
packages/fcl-db/src/base/dataset.inc

@@ -257,7 +257,7 @@ begin
     deLayoutChange  : FEnableControlsEvent:=deLayoutChange;    
   end;
 
-  if not ControlsDisabled then begin
+  if not ControlsDisabled and (FState <> dsBlockRead) then begin
     for i := 0 to FDataSources.Count - 1 do
       TDataSource(FDataSources[i]).ProcessEvent(Event, Info);
   end;
@@ -864,6 +864,24 @@ begin
     end;
 end;
 
+procedure TDataSet.SetBlockReadSize(AValue: Integer);
+begin
+  // the state is changed even when setting the same BlockReadSize (follows Delphi behavior)
+  // e.g., state is dsBrowse and BlockReadSize is 1. Setting BlockReadSize to 1 will change state to dsBlockRead
+  FBlockReadSize := AValue;
+  if AValue > 0 then
+  begin
+    CheckActive; 
+    SetState(dsBlockRead);
+  end	
+  else
+  begin
+    //update state only when in dsBlockRead 
+    if FState = dsBlockRead then
+      SetState(dsBrowse);
+  end;	
+end;
+
 Procedure TDataSet.SetFieldDefs(AFieldDefs: TFieldDefs);
 
 begin

+ 3 - 0
packages/fcl-db/src/base/db.pas

@@ -1343,6 +1343,7 @@ type
     FBeforeRefresh: TDataSetNotifyEvent;
     FBeforeScroll: TDataSetNotifyEvent;
     FBlobFieldCount: Longint;
+    FBlockReadSize: Integer;
     FBookmarkSize: Longint;
     FBuffers : TBufferArray;
     FBufferCount: Longint;
@@ -1387,6 +1388,7 @@ type
     Function GetActive : boolean;
     Procedure UnRegisterDataSource(ADatasource : TDatasource);
     Procedure UpdateFieldDefs;
+    procedure SetBlockReadSize(AValue: Integer);
     Procedure SetFieldDefs(AFieldDefs: TFieldDefs);
     procedure DoInsertAppendRecord(const Values: array of const; DoAppend : boolean);
   protected
@@ -1591,6 +1593,7 @@ type
     procedure UpdateCursorPos;
     procedure UpdateRecord;
     function UpdateStatus: TUpdateStatus; virtual;
+    property BlockReadSize: Integer read FBlockReadSize write SetBlockReadSize;
     property BOF: Boolean read FBOF;
     property Bookmark: TBookmarkStr read GetBookmarkStr write SetBookmarkStr;
     property CanModify: Boolean read GetCanModify;