- use BeginUpdate and EndUpdate from TCollection instead of own in TListColumns implementation

- commit forgotten file

git-svn-id: trunk@13383 -
This commit is contained in:
paul 2007-12-19 04:40:13 +00:00
parent 550b78239f
commit 0897bb06ff
4 changed files with 11 additions and 26 deletions

View File

@ -766,19 +766,16 @@ type
TListColumns = class(TCollection)
private
FOwner: TCustomListView;
FUpdateCount: integer;
FItemNeedsUpdate: TCollectionItem;
FNeedsUpdate: boolean;
function GetItem(const AIndex: Integer): TListColumn;
procedure WSCreateColumns;
procedure SetItem(const AIndex: Integer; const AValue: TListColumn);
protected
public
constructor Create(TheOwner: TCustomListView);
destructor Destroy; override;
procedure Update(Item: TCollectionItem); override;
function Add: TListColumn;
procedure BeginUpdate; override;
procedure EndUpdate; override;
property Owner: TCustomListView read FOwner;
property Items[const AIndex: Integer]: TListColumn
read GetItem write SetItem; default;

View File

@ -28,27 +28,6 @@ begin
OwnerFormDesignerModified(Owner);
end;
procedure TListColumns.BeginUpdate;
begin
{$IFNDEF VER2_0}
inherited;
// if 2.0 is not supported anymore, maybe FUpdateCount can be removed and
// the Changed notification can be used.
{$ENDIF}
inc(FUpdateCount);
end;
procedure TListColumns.EndUpdate;
begin
{$IFNDEF VER2_0}
inherited;
{$ENDIF}
if FUpdateCount<=0 then
RaiseGDBException('TListColumns.EndUpdate');
dec(FUpdateCount);
if (FUpdateCount=0) and FNeedsUpdate then Update(FItemNeedsUpdate);
end;
procedure TListColumns.Assign(Source: TPersistent);
var
I: Integer;
@ -89,6 +68,13 @@ begin
EndUpdate;
end;
procedure TListColumns.Update(Item: TCollectionItem);
begin
if (Item = nil) and FNeedsUpdate then
Item := FItemNeedsUpdate;
inherited Update(Item);
end;
function TListColumns.GetItem(const AIndex: Integer): TListColumn;
begin
Result := TListColumn(inherited GetItem(AIndex));

View File

@ -79,7 +79,8 @@ begin
if Count <= Aindex then Exit;
// Move column to the last, otherwise our items get shuffeled
ColumnMove(ALV, AIndex, Count - 1, nil);
if AIndex <> Count - 1 then
ColumnMove(ALV, AIndex, Count - 1, nil);
ListView_DeleteColumn(hLV, Count - 1);
end;

View File

@ -485,6 +485,7 @@ type
protected
procedure AssignItemDataToCache(const AIndex: Integer; const AData: Pointer); virtual; // called to store item data while the handle isn't created
procedure AssignCacheToItemData(const AIndex: Integer; const AData: Pointer); virtual; // called to restore the itemdata after a handle is created
procedure BeginAutoDrag; override;
procedure Loaded; override;
procedure InitializeWnd; override;
procedure FinalizeWnd; override;