mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 02:29:21 +02:00
lcl: change TFileListBox behavior to be more delphi compatible (issue #0010985 by Bart Broersma with modifications)
git-svn-id: trunk@14828 -
This commit is contained in:
parent
fdde79363f
commit
4f20c0b8a7
@ -140,42 +140,50 @@ implementation
|
|||||||
{ TCustomFileListBox }
|
{ TCustomFileListBox }
|
||||||
|
|
||||||
procedure TCustomFileListBox.UpdateFileList;
|
procedure TCustomFileListBox.UpdateFileList;
|
||||||
Var
|
var
|
||||||
Info: TSearchRec;
|
Info: TSearchRec;
|
||||||
Added: Boolean;
|
|
||||||
|
|
||||||
procedure AddFile(FileAttr: TFileAttr; SysAttr: integer);
|
function FileTypeToFileAttribute(FileType: TFileType): LongInt;
|
||||||
|
const
|
||||||
|
FileTypeToAttrMap: array[TFileAttr] of LongInt =
|
||||||
|
(
|
||||||
|
{ ftReadOnly } faReadOnly,
|
||||||
|
{ ftHidden } faHidden,
|
||||||
|
{ ftSystem } faSysFile,
|
||||||
|
{ ftVolumeID } faVolumeId,
|
||||||
|
{ ftDirectory } faDirectory,
|
||||||
|
{ ftArchive } faArchive,
|
||||||
|
{ ftNormal } 0
|
||||||
|
);
|
||||||
|
var
|
||||||
|
Iter: TFileAttr;
|
||||||
begin
|
begin
|
||||||
if (not Added) and (FileAttr in FileType)
|
Result := 0;
|
||||||
and ((Info.Attr and SysAttr)>0) then begin
|
for Iter := Low(TFileAttr) to High(TFileAttr) do
|
||||||
if (Info.Attr and faDirectory)>0 then
|
if Iter in FileType then
|
||||||
Info.Name := '['+Info.Name+']';
|
Result := Result or FileTypeToAttrMap[Iter];
|
||||||
Items.Add(Info.Name);
|
|
||||||
Added:=true;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if [csloading,csdestroying]*ComponentState<>[] then exit;
|
if [csloading, csdestroying] * ComponentState <> [] then
|
||||||
|
Exit;
|
||||||
Clear;
|
Clear;
|
||||||
If SysUtils.FindFirst(FDirectory+DirectorySeparator+AllDirectoryEntriesMask,
|
if FileType <> [] then
|
||||||
faAnyFile, Info)=0
|
begin
|
||||||
|
if SysUtils.FindFirst(IncludeTrailingPathDelimiter(FDirectory)+AllDirectoryEntriesMask,
|
||||||
|
FileTypeToFileAttribute(FileType), Info) = 0
|
||||||
then
|
then
|
||||||
Repeat
|
repeat
|
||||||
if MatchesMaskList(Info.Name,Mask) then begin
|
if MatchesMaskList(Info.Name,Mask) then
|
||||||
Added:=false;
|
begin
|
||||||
AddFile(ftReadOnly,faReadOnly);
|
if (Info.Attr and faDirectory) > 0 then
|
||||||
AddFile(ftHidden,faHidden);
|
Items.Add('['+Info.Name+']')
|
||||||
AddFile(ftSystem,faSysFile);
|
else
|
||||||
AddFile(ftVolumeID,faVolumeId);
|
|
||||||
AddFile(ftDirectory,faDirectory);
|
|
||||||
AddFile(ftArchive,faArchive);
|
|
||||||
if not Added and (ftNormal in FileType) and
|
|
||||||
(faAnyFile and Info.Attr=0) then
|
|
||||||
Items.Add(Info.Name);
|
Items.Add(Info.Name);
|
||||||
end;
|
end;
|
||||||
Until SysUtils.FindNext(Info) <> 0;
|
until SysUtils.FindNext(Info) <> 0;
|
||||||
SysUtils.FindClose(Info);
|
SysUtils.FindClose(Info);
|
||||||
|
end;
|
||||||
|
|
||||||
UpdateSelectedFileName;
|
UpdateSelectedFileName;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user