mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 09:59:09 +02:00
ShellCtrls: subclass TListItem, so we can store a TSearchRec in the list items of a TShellListView.
This commit is contained in:
parent
e54924787c
commit
6a85abf640
@ -236,6 +236,16 @@ type
|
|||||||
|
|
||||||
TCSLVFileAddedEvent = procedure(Sender: TObject; Item: TListItem) of object;
|
TCSLVFileAddedEvent = procedure(Sender: TObject; Item: TListItem) of object;
|
||||||
|
|
||||||
|
{ TShellListItem }
|
||||||
|
|
||||||
|
TShellListItem = class(TListItem)
|
||||||
|
private
|
||||||
|
FFileInfo: TSearchRec;
|
||||||
|
public
|
||||||
|
function isFolder: Boolean;
|
||||||
|
property FileInfo: TSearchRec read FFileInfo write FFileInfo;
|
||||||
|
end;
|
||||||
|
|
||||||
TCustomShellListView = class(TCustomListView)
|
TCustomShellListView = class(TCustomListView)
|
||||||
private
|
private
|
||||||
FAutoSizeColumns: Boolean;
|
FAutoSizeColumns: Boolean;
|
||||||
@ -258,6 +268,7 @@ type
|
|||||||
class procedure WSRegisterClass; override;
|
class procedure WSRegisterClass; override;
|
||||||
procedure AdjustColWidths;
|
procedure AdjustColWidths;
|
||||||
procedure CreateHandle; override;
|
procedure CreateHandle; override;
|
||||||
|
function CreateListItem: TListItem; override;
|
||||||
procedure PopulateWithRoot();
|
procedure PopulateWithRoot();
|
||||||
procedure DoOnResize; override;
|
procedure DoOnResize; override;
|
||||||
procedure SetAutoSizeColumns(const Value: Boolean); virtual;
|
procedure SetAutoSizeColumns(const Value: Boolean); virtual;
|
||||||
@ -441,6 +452,13 @@ begin
|
|||||||
Result := (A.Code = B.Code) and (A.Data = B.Data);
|
Result := (A.Code = B.Code) and (A.Data = B.Data);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TShellListItem }
|
||||||
|
|
||||||
|
function TShellListItem.isFolder: Boolean;
|
||||||
|
begin
|
||||||
|
Result := (FFileInfo.Attr and faDirectory) = faDirectory;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TFileItem : internal helper class used for temporarily storing info in an internal TStrings component}
|
{ TFileItem : internal helper class used for temporarily storing info in an internal TStrings component}
|
||||||
|
|
||||||
constructor TFileItem.Create(const DirInfo:TSearchRec; ABasePath: String);
|
constructor TFileItem.Create(const DirInfo:TSearchRec; ABasePath: String);
|
||||||
@ -1676,6 +1694,8 @@ begin
|
|||||||
if CanAdd then
|
if CanAdd then
|
||||||
begin
|
begin
|
||||||
NewItem := Items.Add;
|
NewItem := Items.Add;
|
||||||
|
if (NewItem is TShellListItem) then
|
||||||
|
TShellListItem(NewItem).FileInfo := TFileItem(Files.Objects[i]).FileInfo;
|
||||||
CurFileName := Files.Strings[i];
|
CurFileName := Files.Strings[i];
|
||||||
CurFilePath := IncludeTrailingPathDelimiter(FRoot) + CurFileName;
|
CurFilePath := IncludeTrailingPathDelimiter(FRoot) + CurFileName;
|
||||||
// First column - Name
|
// First column - Name
|
||||||
@ -1751,6 +1771,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomShellListView.CreateListItem: TListItem;
|
||||||
|
begin
|
||||||
|
if Assigned(OnCreateItemClass) then
|
||||||
|
Result := inherited CreateListItem
|
||||||
|
else
|
||||||
|
Result := TShellListItem.Create(Items);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomShellListView.DoOnResize;
|
procedure TCustomShellListView.DoOnResize;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
Loading…
Reference in New Issue
Block a user