LCL/TListView: Improved Delphi compatibility by giving life to the empty methods Delete and InsertItem and adding an Edit method.

git-svn-id: trunk@64309 -
This commit is contained in:
wp 2020-12-30 18:56:35 +00:00
parent db94cc7a39
commit fbb46cb85d
2 changed files with 19 additions and 5 deletions

View File

@ -1511,7 +1511,7 @@ type
procedure Change(AItem: TListItem; AChange: Integer); virtual;
procedure ColClick(AColumn: TListColumn); virtual;
procedure Delete(Item : TListItem);
procedure Delete(Item : TListItem); virtual;
procedure DoDeletion(AItem: TListItem); virtual;
procedure DoInsert(AItem: TListItem); virtual;
procedure DoItemChecked(AItem: TListItem);
@ -1521,8 +1521,9 @@ type
procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); override;
procedure DoEndEdit(AItem: TListItem; const AValue: String); virtual;
procedure Edit(AItem: TListItem); virtual;
procedure InsertItem(Item : TListItem);
procedure InsertItem(AItem : TListItem); virtual;
procedure ImageChanged(Sender : TObject);
procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;

View File

@ -587,7 +587,8 @@ end;
{------------------------------------------------------------------------------}
procedure TCustomListView.DoDeletion(AItem: TListItem);
begin
if Assigned(FOnDeletion) then FOnDeletion(Self, AItem);
if not (csDestroying in ComponentState) and Assigned(FOnDeletion) then
FOnDeletion(Self, AItem);
end;
{------------------------------------------------------------------------------}
@ -595,7 +596,11 @@ end;
{------------------------------------------------------------------------------}
procedure TCustomListView.DoInsert(AItem: TListItem);
begin
if Assigned(FOnInsert) then FOnInsert(Self, AItem);
if not (TMethod(@Self.InsertItem).Code = Pointer(@TCUstomListView.InsertItem)) then
//There is an override for InsertItem, so use that for Delphi compatibility. Issue #0038263
InsertItem(AItem)
else
if Assigned(FOnInsert) then FOnInsert(Self, AItem);
end;
{------------------------------------------------------------------------------}
@ -671,6 +676,12 @@ begin
AItem.Caption := S;
end;
procedure TCustomListView.Edit(AItem: TListItem);
begin
if Assigned(AItem) then
DoEndEdit(AItem, AItem.Caption);
end;
{------------------------------------------------------------------------------}
{ TCustomListView ItemDeleted }
{------------------------------------------------------------------------------}
@ -729,13 +740,15 @@ end;
{------------------------------------------------------------------------------}
procedure TCustomListView.Delete(Item : TListItem);
begin
Item.Delete;
end;
{------------------------------------------------------------------------------}
{ TCustomListView InsertItem }
{------------------------------------------------------------------------------}
procedure TCustomListView.InsertItem(Item : TListItem);
procedure TCustomListView.InsertItem(AItem : TListItem);
begin
if Assigned(FOnInsert) then FOnInsert(Self, AItem);
end;
function TCustomListView.IntfCustomDraw(ATarget: TCustomDrawTarget; AStage: TCustomDrawStage; AItem, ASubItem: Integer; AState: TCustomDrawState; const ARect: PRect): TCustomDrawResult;