From 2ddd71c0ce57c250d188e115f3caa07c8d4a2daf Mon Sep 17 00:00:00 2001 From: jesus Date: Sat, 19 Jan 2008 20:06:09 +0000 Subject: [PATCH] grids, fixed slow sorting tip from Ts. Petrov, issue #10642 git-svn-id: trunk@13804 - --- lcl/dbgrids.pas | 22 ++++------------------ lcl/grids.pas | 5 ++++- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/lcl/dbgrids.pas b/lcl/dbgrids.pas index 5a71b2bce1..56973b3427 100644 --- a/lcl/dbgrids.pas +++ b/lcl/dbgrids.pas @@ -305,11 +305,9 @@ type FGridStatus: TDBGridStatus; FOldControlStyle: TControlStyle; FCheckedBitmap, FUnCheckedBitmap, FGrayedBitmap: TBitmap; - FNeedUpdateWidths: boolean; FSelectedRows: TBookmarkList; FOnPrepareCanvas: TPrepareDbGridCanvasEvent; procedure EmptyGrid; - procedure CheckWidths; function GetCurrentColumn: TColumn; function GetCurrentField: TField; function GetDataSource: TDataSource; @@ -368,6 +366,7 @@ type procedure BeginLayout; procedure CellClick(const aCol,aRow: Integer); override; procedure ChangeBounds(ALeft, ATop, AWidth, AHeight: integer); override; + procedure InvalidateSizes; procedure ColRowMoved(IsColumn: Boolean; FromIndex,ToIndex: Integer); override; function ColumnEditorStyle(aCol: Integer; F: TField): TColumnButtonStyle; function CreateColumns: TGridColumns; override; @@ -416,7 +415,6 @@ type procedure Loaded; override; procedure MoveSelection; override; procedure MouseDown(Button: TMouseButton; Shift:TShiftState; X,Y:Integer); override; - procedure Paint; override; procedure PrepareCanvas(aCol,aRow: Integer; aState:TGridDrawState); override; procedure RemoveAutomaticColumns; procedure SelectEditor; override; @@ -431,7 +429,6 @@ type property GridStatus: TDBGridStatus read FGridStatus write FGridStatus; property DataSource: TDataSource read GetDataSource write SetDataSource; - property NeedUpdateWidths: boolean write FNeedUpdateWidths; property Options: TDBGridOptions read FOptions write SetOptions; property OptionsExtra: TDBGridExtraOptions read FExtraOptions write SetExtraOptions; property ReadOnly: Boolean read FReadOnly write FReadOnly default false; @@ -721,14 +718,9 @@ begin ColWidths[0]:=12; end; -procedure TCustomDBGrid.CheckWidths; +procedure TCustomDBGrid.InvalidateSizes; begin - if FNeedUpdateWidths then begin - BeginUpdate; - VisualChange; - EndUpdate(uoNone); - FNeedUpdateWidths := False; - end; + GridFlags := GridFlags + [gfVisualChange]; end; function TCustomDBGrid.GetCurrentColumn: TColumn; @@ -2004,12 +1996,6 @@ begin {$IfDef dbgGrid} DebugLn('DBGrid.MouseDown END'); {$Endif} end; -procedure TCustomDBGrid.Paint; -begin - CheckWidths; - inherited Paint; -end; - procedure TCustomDBGrid.PrepareCanvas(aCol, aRow: Integer; aState: TGridDrawState); begin @@ -3204,7 +3190,7 @@ begin else result := AGrid.DefaultColWidth end else begin - aGrid.NeedUpdateWidths := True; + aGrid.InvalidateSizes; result := DEFCOLWIDTH; end; diff --git a/lcl/grids.pas b/lcl/grids.pas index e874bda1c6..7243a6c473 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -2296,6 +2296,9 @@ begin {$ifdef DbgVisualChange} DebugLn('TCustomGrid.VisualChange INIT ',DbgSName(Self)); {$endif} + if FUpdateCount<>0 then + exit; + Include(FGridFlags, gfVisualChange); UpdateCachedSizes; @@ -5639,7 +5642,7 @@ begin if FUpdateCount=0 then begin {$IfDef dbgPaint} DebugLn('Invalidate');{$Endif} inherited Invalidate; -end; + end; end; procedure TCustomGrid.EditingDone;