mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-01 22:19:39 +01:00
filebrowser: skip removable devices without media, added Filtercombobox to filter Filelist from Johannes Müller, bug #14806
git-svn-id: trunk@23215 -
This commit is contained in:
parent
6c94ef0bf7
commit
82cba50749
@ -1,36 +1,36 @@
|
||||
object FileBrowserForm: TFileBrowserForm
|
||||
Left = 282
|
||||
Height = 434
|
||||
Top = 402
|
||||
Width = 385
|
||||
Left = 284
|
||||
Height = 467
|
||||
Top = 288
|
||||
Width = 345
|
||||
ActiveControl = Panel1
|
||||
Caption = 'File Browser'
|
||||
ClientHeight = 434
|
||||
ClientWidth = 385
|
||||
ClientHeight = 467
|
||||
ClientWidth = 345
|
||||
OnActivate = FormActivate
|
||||
OnClose = FormClose
|
||||
OnCreate = FormCreate
|
||||
OnShow = FormShow
|
||||
LCLVersion = '0.9.27'
|
||||
LCLVersion = '0.9.29'
|
||||
object FileListBox: TFileListBox
|
||||
Left = 0
|
||||
Height = 186
|
||||
Top = 248
|
||||
Width = 385
|
||||
Height = 214
|
||||
Top = 253
|
||||
Width = 345
|
||||
Align = alClient
|
||||
Directory = '/home/graemeg'
|
||||
FileType = [ftArchive, ftNormal]
|
||||
ItemHeight = 23
|
||||
ItemHeight = 0
|
||||
OnDblClick = FileListBoxDblClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object TV: TTreeView
|
||||
Left = 0
|
||||
Height = 201
|
||||
Height = 185
|
||||
Top = 42
|
||||
Width = 385
|
||||
Width = 345
|
||||
Align = alTop
|
||||
DefaultItemHeight = 19
|
||||
DefaultItemHeight = 15
|
||||
ReadOnly = True
|
||||
ScrollBars = ssAutoBoth
|
||||
TabOrder = 1
|
||||
@ -42,17 +42,17 @@ object FileBrowserForm: TFileBrowserForm
|
||||
Left = 0
|
||||
Height = 42
|
||||
Top = 0
|
||||
Width = 385
|
||||
Width = 345
|
||||
Align = alTop
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 42
|
||||
ClientWidth = 385
|
||||
ClientWidth = 345
|
||||
TabOrder = 2
|
||||
object cbHidden: TCheckBox
|
||||
Left = 200
|
||||
Height = 22
|
||||
Top = 8
|
||||
Width = 134
|
||||
Left = 208
|
||||
Height = 17
|
||||
Top = 18
|
||||
Width = 101
|
||||
Caption = 'Show hidden files'
|
||||
OnChange = cbHiddenChange
|
||||
TabOrder = 0
|
||||
@ -66,14 +66,32 @@ object FileBrowserForm: TFileBrowserForm
|
||||
OnClick = btnConfigureClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object btnReload: TButton
|
||||
Left = 104
|
||||
Height = 28
|
||||
Top = 7
|
||||
Width = 90
|
||||
Caption = 'Reload'
|
||||
OnClick = btnReloadClick
|
||||
TabOrder = 2
|
||||
end
|
||||
end
|
||||
object Splitter1: TSplitter
|
||||
Cursor = crVSplit
|
||||
Left = 0
|
||||
Height = 5
|
||||
Top = 243
|
||||
Width = 385
|
||||
Top = 227
|
||||
Width = 345
|
||||
Align = alTop
|
||||
ResizeAnchor = akTop
|
||||
end
|
||||
object FilterComboBox: TFilterComboBox
|
||||
Left = 0
|
||||
Height = 21
|
||||
Top = 232
|
||||
Width = 345
|
||||
Align = alTop
|
||||
TabOrder = 4
|
||||
OnChange = FilterComboBoxChange
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,28 +1,32 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
{ Das ist eine automatisch erzeugte Lazarus-Ressourcendatei }
|
||||
|
||||
LazarusResources.Add('TFileBrowserForm','FORMDATA',[
|
||||
'TPF0'#16'TFileBrowserForm'#15'FileBrowserForm'#4'Left'#3#26#1#6'Height'#3#178
|
||||
+#1#3'Top'#3#146#1#5'Width'#3#129#1#13'ActiveControl'#7#6'Panel1'#7'Caption'#6
|
||||
+#12'File Browser'#12'ClientHeight'#3#178#1#11'ClientWidth'#3#129#1#10'OnActi'
|
||||
+'vate'#7#12'FormActivate'#7'OnClose'#7#9'FormClose'#8'OnCreate'#7#10'FormCre'
|
||||
+'ate'#6'OnShow'#7#8'FormShow'#10'LCLVersion'#6#6'0.9.27'#0#12'TFileListBox'
|
||||
+#11'FileListBox'#4'Left'#2#0#6'Height'#3#186#0#3'Top'#3#248#0#5'Width'#3#129
|
||||
+#1#5'Align'#7#8'alClient'#9'Directory'#6#13'/home/graemeg'#8'FileType'#11#9
|
||||
+'ftArchive'#8'ftNormal'#0#10'ItemHeight'#2#23#10'OnDblClick'#7#19'FileListBo'
|
||||
+'xDblClick'#8'TabOrder'#2#0#0#0#9'TTreeView'#2'TV'#4'Left'#2#0#6'Height'#3
|
||||
+#201#0#3'Top'#2'*'#5'Width'#3#129#1#5'Align'#7#5'alTop'#17'DefaultItemHeight'
|
||||
+#2#19#8'ReadOnly'#9#10'ScrollBars'#7#10'ssAutoBoth'#8'TabOrder'#2#1#10'OnExp'
|
||||
+'anded'#7#10'TVExpanded'#18'OnSelectionChanged'#7#18'TVSelectionChanged'#7'O'
|
||||
+'ptions'#11#17'tvoAutoItemHeight'#16'tvoHideSelection'#21'tvoKeepCollapsedNo'
|
||||
+'des'#11'tvoReadOnly'#14'tvoShowButtons'#12'tvoShowLines'#11'tvoShowRoot'#11
|
||||
+'tvoToolTips'#0#0#0#6'TPanel'#6'Panel1'#4'Left'#2#0#6'Height'#2'*'#3'Top'#2#0
|
||||
+#5'Width'#3#129#1#5'Align'#7#5'alTop'#10'BevelOuter'#7#6'bvNone'#12'ClientHe'
|
||||
+'ight'#2'*'#11'ClientWidth'#3#129#1#8'TabOrder'#2#2#0#9'TCheckBox'#8'cbHidde'
|
||||
+'n'#4'Left'#3#200#0#6'Height'#2#22#3'Top'#2#8#5'Width'#3#134#0#7'Caption'#6
|
||||
+#17'Show hidden files'#8'OnChange'#7#14'cbHiddenChange'#8'TabOrder'#2#0#0#0#7
|
||||
+'TButton'#12'btnConfigure'#4'Left'#2#8#6'Height'#2#28#3'Top'#2#7#5'Width'#2
|
||||
+'Z'#7'Caption'#6#9'Configure'#7'OnClick'#7#17'btnConfigureClick'#8'TabOrder'
|
||||
+#2#1#0#0#0#9'TSplitter'#9'Splitter1'#6'Cursor'#7#8'crVSplit'#4'Left'#2#0#6'H'
|
||||
+'eight'#2#5#3'Top'#3#243#0#5'Width'#3#129#1#5'Align'#7#5'alTop'#12'ResizeAnc'
|
||||
+'hor'#7#5'akTop'#0#0#0
|
||||
'TPF0'#16'TFileBrowserForm'#15'FileBrowserForm'#4'Left'#3#28#1#6'Height'#3#211
|
||||
+#1#3'Top'#3' '#1#5'Width'#3'Y'#1#13'ActiveControl'#7#6'Panel1'#7'Caption'#6
|
||||
+#12'File Browser'#12'ClientHeight'#3#211#1#11'ClientWidth'#3'Y'#1#10'OnActiv'
|
||||
+'ate'#7#12'FormActivate'#7'OnClose'#7#9'FormClose'#8'OnCreate'#7#10'FormCrea'
|
||||
+'te'#6'OnShow'#7#8'FormShow'#10'LCLVersion'#6#6'0.9.29'#0#12'TFileListBox'#11
|
||||
+'FileListBox'#4'Left'#2#0#6'Height'#3#214#0#3'Top'#3#253#0#5'Width'#3'Y'#1#5
|
||||
+'Align'#7#8'alClient'#9'Directory'#6#13'/home/graemeg'#8'FileType'#11#9'ftAr'
|
||||
+'chive'#8'ftNormal'#0#10'ItemHeight'#2#0#10'OnDblClick'#7#19'FileListBoxDblC'
|
||||
+'lick'#8'TabOrder'#2#0#0#0#9'TTreeView'#2'TV'#4'Left'#2#0#6'Height'#3#185#0#3
|
||||
+'Top'#2'*'#5'Width'#3'Y'#1#5'Align'#7#5'alTop'#17'DefaultItemHeight'#2#15#8
|
||||
+'ReadOnly'#9#10'ScrollBars'#7#10'ssAutoBoth'#8'TabOrder'#2#1#10'OnExpanded'#7
|
||||
+#10'TVExpanded'#18'OnSelectionChanged'#7#18'TVSelectionChanged'#7'Options'#11
|
||||
+#17'tvoAutoItemHeight'#16'tvoHideSelection'#21'tvoKeepCollapsedNodes'#11'tvo'
|
||||
+'ReadOnly'#14'tvoShowButtons'#12'tvoShowLines'#11'tvoShowRoot'#11'tvoToolTip'
|
||||
+'s'#0#0#0#6'TPanel'#6'Panel1'#4'Left'#2#0#6'Height'#2'*'#3'Top'#2#0#5'Width'
|
||||
+#3'Y'#1#5'Align'#7#5'alTop'#10'BevelOuter'#7#6'bvNone'#12'ClientHeight'#2'*'
|
||||
+#11'ClientWidth'#3'Y'#1#8'TabOrder'#2#2#0#9'TCheckBox'#8'cbHidden'#4'Left'#3
|
||||
+#208#0#6'Height'#2#17#3'Top'#2#18#5'Width'#2'e'#7'Caption'#6#17'Show hidden '
|
||||
+'files'#8'OnChange'#7#14'cbHiddenChange'#8'TabOrder'#2#0#0#0#7'TButton'#12'b'
|
||||
+'tnConfigure'#4'Left'#2#8#6'Height'#2#28#3'Top'#2#7#5'Width'#2'Z'#7'Caption'
|
||||
+#6#9'Configure'#7'OnClick'#7#17'btnConfigureClick'#8'TabOrder'#2#1#0#0#7'TBu'
|
||||
+'tton'#9'btnReload'#4'Left'#2'h'#6'Height'#2#28#3'Top'#2#7#5'Width'#2'Z'#7'C'
|
||||
+'aption'#6#6'Reload'#7'OnClick'#7#14'btnReloadClick'#8'TabOrder'#2#2#0#0#0#9
|
||||
+'TSplitter'#9'Splitter1'#6'Cursor'#7#8'crVSplit'#4'Left'#2#0#6'Height'#2#5#3
|
||||
+'Top'#3#227#0#5'Width'#3'Y'#1#5'Align'#7#5'alTop'#12'ResizeAnchor'#7#5'akTop'
|
||||
+#0#0#15'TFilterComboBox'#14'FilterComboBox'#4'Left'#2#0#6'Height'#2#21#3'Top'
|
||||
+#3#232#0#5'Width'#3'Y'#1#5'Align'#7#5'alTop'#8'TabOrder'#2#4#8'OnChange'#7#20
|
||||
+'FilterComboBoxChange'#0#0#0
|
||||
]);
|
||||
|
||||
@ -26,14 +26,18 @@ type
|
||||
|
||||
TFileBrowserForm = class(TForm)
|
||||
btnConfigure: TButton;
|
||||
btnReload: TButton;
|
||||
cbHidden: TCheckBox;
|
||||
FileListBox: TFileListBox;
|
||||
FilterComboBox: TFilterComboBox;
|
||||
Panel1: TPanel;
|
||||
Splitter1: TSplitter;
|
||||
TV: TTreeView;
|
||||
procedure btnConfigureClick(Sender: TObject);
|
||||
procedure btnReloadClick(Sender: TObject);
|
||||
procedure cbHiddenChange(Sender: TObject);
|
||||
procedure FileListBoxDblClick(Sender: TObject);
|
||||
procedure FilterComboBoxChange(Sender: TObject);
|
||||
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
@ -88,6 +92,12 @@ uses
|
||||
Windows;
|
||||
{$ENDIF}
|
||||
|
||||
const
|
||||
cFilter = 'All Files (' + AllFilesMask + ')|' + AllFilesMask +
|
||||
'|Source(*.pas;*.pp)|*.pas;*.pp' +
|
||||
'|Projectfiles(*.pas;*.pp;*.inc;*.lfm;*.lpr;*.lrs;*.lpi;*.lpk)|' +
|
||||
'*.pas;*.pp;*.inc;*.lfm;*.lpr;*.lrs;*.lpi;*.lpk;|';
|
||||
|
||||
|
||||
{function HasSubDirs returns True if the directory passed has subdirectories}
|
||||
function HasSubDirs(const Dir: string; AShowHidden: Boolean): Boolean;
|
||||
@ -155,6 +165,19 @@ begin
|
||||
FOnConfigure(Self);
|
||||
end;
|
||||
|
||||
procedure TFileBrowserForm.btnReloadClick(Sender: TObject);
|
||||
var
|
||||
d: string;
|
||||
begin
|
||||
// save current directory location
|
||||
d := ChompPathDelim(SelectedDir);
|
||||
// rebuild tree
|
||||
TV.Items.Clear;
|
||||
InitializeTreeview;
|
||||
// restore directory
|
||||
Directory := d;
|
||||
end;
|
||||
|
||||
procedure TFileBrowserForm.cbHiddenChange(Sender: TObject);
|
||||
begin
|
||||
ShowHidden := cbHidden.Checked;
|
||||
@ -170,6 +193,11 @@ begin
|
||||
FOnOpenFile(Self, FileListBox.FileName);
|
||||
end;
|
||||
|
||||
procedure TFileBrowserForm.FilterComboBoxChange(Sender: TObject);
|
||||
begin
|
||||
FileListBox.Mask := FilterComboBox.Mask;
|
||||
end;
|
||||
|
||||
procedure TFileBrowserForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
begin
|
||||
if Assigned(FOnSaveLayout) then
|
||||
@ -181,6 +209,7 @@ procedure TFileBrowserForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
FShowHidden := False;
|
||||
InitializeTreeview;
|
||||
FilterComboBox.Filter := cFilter;
|
||||
end;
|
||||
|
||||
procedure TFileBrowserForm.FormShow(Sender: TObject);
|
||||
@ -356,12 +385,13 @@ var
|
||||
n: integer;
|
||||
drvs: string;
|
||||
begin
|
||||
// making drive list, skipping drives A: and B:
|
||||
// making drive list, skipping drives A: and B: and Removable Devices without media
|
||||
n := 2;
|
||||
while n <= MAX_DRIVES do
|
||||
begin
|
||||
drvs := chr(n + Ord('A')) + ':\';
|
||||
if Windows.GetDriveType(PChar(drvs)) <> 1 then
|
||||
if (Windows.GetDriveType(PChar(drvs)) <> 1) and
|
||||
(GetDiskFreeSpaceEx(PChar(drvs), nil, nil, nil)) then
|
||||
TV.Items.Add(nil, drvs);
|
||||
Inc(n);
|
||||
end;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user