mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-23 00:09:27 +01:00
LCL: added TFileDialog.ExtractAllFilterMasks
git-svn-id: trunk@29600 -
This commit is contained in:
parent
a28c311a69
commit
c5dcc6c2c8
@ -3125,6 +3125,9 @@ If a valid directory is given, the selected directory in the tree will be set to
|
|||||||
<element name="TColorDialog.WSRegisterClass" link="#LCL.LCLClasses.TLCLComponent.WSRegisterClass"/>
|
<element name="TColorDialog.WSRegisterClass" link="#LCL.LCLClasses.TLCLComponent.WSRegisterClass"/>
|
||||||
<element name="TColorButton.WSRegisterClass" link="#LCL.LCLClasses.TLCLComponent.WSRegisterClass"/>
|
<element name="TColorButton.WSRegisterClass" link="#LCL.LCLClasses.TLCLComponent.WSRegisterClass"/>
|
||||||
<element name="TFontDialog.WSRegisterClass" link="#LCL.LCLClasses.TLCLComponent.WSRegisterClass"/>
|
<element name="TFontDialog.WSRegisterClass" link="#LCL.LCLClasses.TLCLComponent.WSRegisterClass"/>
|
||||||
|
<element name="TFileDialog.ExtractAllFilterMasks">
|
||||||
|
<short>Extracts all file masks from a filter</short>
|
||||||
|
</element>
|
||||||
</module>
|
</module>
|
||||||
<!-- Dialogs -->
|
<!-- Dialogs -->
|
||||||
</package>
|
</package>
|
||||||
|
|||||||
21
ide/main.pp
21
ide/main.pp
@ -2673,20 +2673,25 @@ var
|
|||||||
AFilename: string;
|
AFilename: string;
|
||||||
I: Integer;
|
I: Integer;
|
||||||
OpenFlags: TOpenFlags;
|
OpenFlags: TOpenFlags;
|
||||||
|
Filter: String;
|
||||||
|
AllExt: String;
|
||||||
begin
|
begin
|
||||||
OpenDialog:=TOpenDialog.Create(nil);
|
OpenDialog:=TOpenDialog.Create(nil);
|
||||||
try
|
try
|
||||||
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
||||||
OpenDialog.Title:=lisOpenFile;
|
OpenDialog.Title:=lisOpenFile;
|
||||||
OpenDialog.Options:=OpenDialog.Options+[ofAllowMultiSelect];
|
OpenDialog.Options:=OpenDialog.Options+[ofAllowMultiSelect];
|
||||||
OpenDialog.Filter := lisLazarusFile + ' (*.lpi;*.lpr;*.lpk;*.pas;*.pp;*.inc;*.lfm;*.dfm)|' +
|
Filter := lisLazarusUnit + ' (*.pas;*.pp)|*.pas;*.pp'
|
||||||
'*.lpi;*.lpr;*.lpk;*.pas;*.pp;*.inc;*.lfm;*.dfm'
|
+ '|' + lisLazarusProject + ' (*.lpi)|*.lpi'
|
||||||
+ '|' + lisLazarusUnit + ' (*.pas;*.pp)|*.pas;*.pp'
|
+ '|' + lisLazarusForm + ' (*.lfm;*.dfm)|*.lfm;*.dfm'
|
||||||
+ '|' + lisLazarusProject + ' (*.lpi)|*.lpi'
|
+ '|' + lisLazarusPackage + ' (*.lpk)|*.lpk'
|
||||||
+ '|' + lisLazarusForm + ' (*.lfm;*.dfm)|*.lfm;*.dfm'
|
+ '|' + lisLazarusProjectSource + ' (*.lpr)|*.lpr'
|
||||||
+ '|' + lisLazarusPackage + ' (*.lpk)|*.lpk'
|
+ '|' + dlgAllFiles + ' (' + GetAllFilesMask + ')|' + GetAllFilesMask;
|
||||||
+ '|' + lisLazarusProjectSource + ' (*.lpr)|*.lpr'
|
AllExt:=TFileDialog.ExtractAllFilterMasks(Filter);
|
||||||
+ '|' + dlgAllFiles + ' (' + GetAllFilesMask + ')|' + GetAllFilesMask;
|
debugln(['TMainIDE.mnuOpenClicked ',AllExt]);
|
||||||
|
// append an all filter
|
||||||
|
Filter:= lisLazarusFile + ' ('+AllExt+')|' + AllExt + '|' + Filter;
|
||||||
|
OpenDialog.Filter := Filter;
|
||||||
if OpenDialog.Execute and (OpenDialog.Files.Count>0) then begin
|
if OpenDialog.Execute and (OpenDialog.Files.Count>0) then begin
|
||||||
OpenFlags:=[ofAddToRecent];
|
OpenFlags:=[ofAddToRecent];
|
||||||
//debugln('TMainIDE.mnuOpenClicked OpenDialog.Files.Count=',dbgs(OpenDialog.Files.Count));
|
//debugln('TMainIDE.mnuOpenClicked OpenDialog.Files.Count=',dbgs(OpenDialog.Files.Count));
|
||||||
|
|||||||
@ -132,6 +132,8 @@ type
|
|||||||
property Files: TStrings read FFiles;
|
property Files: TStrings read FFiles;
|
||||||
property HistoryList: TStrings read FHistoryList write SetHistoryList;
|
property HistoryList: TStrings read FHistoryList write SetHistoryList;
|
||||||
procedure IntfFileTypeChanged(NewFilterIndex: Integer);
|
procedure IntfFileTypeChanged(NewFilterIndex: Integer);
|
||||||
|
class function ExtractAllFilterMasks(aFilter: string;
|
||||||
|
SkipAllFilesMask: boolean = true): string;
|
||||||
published
|
published
|
||||||
property Title;
|
property Title;
|
||||||
property DefaultExt: string read FDefaultExt write SetDefaultExt;
|
property DefaultExt: string read FDefaultExt write SetDefaultExt;
|
||||||
|
|||||||
@ -76,6 +76,76 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TFileDialog.ExtractAllFilterMasks(aFilter: string;
|
||||||
|
SkipAllFilesMask: boolean): string;
|
||||||
|
{ The filter is a list of pairs of captions and masks separated by pipe |
|
||||||
|
The masks are separated by semicolon ;
|
||||||
|
For example:
|
||||||
|
Pascal Files|*.pas;*.pp|All files|*.*
|
||||||
|
}
|
||||||
|
var
|
||||||
|
AllFilesMask: string;
|
||||||
|
|
||||||
|
procedure AddMask(MaskStart: PChar; MaskLen: integer; var Masks: string);
|
||||||
|
var
|
||||||
|
p: PChar;
|
||||||
|
NewMask: string;
|
||||||
|
Start: PChar;
|
||||||
|
begin
|
||||||
|
if (AllFilesMask<>'')
|
||||||
|
and (CompareFilenames(@AllFilesMask[1],length(AllFilesMask),MaskStart,MaskLen,false)=0)
|
||||||
|
then exit; // skip all files mask
|
||||||
|
|
||||||
|
if Masks<>'' then
|
||||||
|
begin
|
||||||
|
p:=PChar(Masks);
|
||||||
|
repeat
|
||||||
|
Start:=p;
|
||||||
|
while not (p^ in [#0,';']) do inc(p);
|
||||||
|
if (CompareFilenames(Start,p-Start,MaskStart,MaskLen,false)=0) then
|
||||||
|
exit;
|
||||||
|
if p^=#0 then break;
|
||||||
|
inc(p);
|
||||||
|
until false;
|
||||||
|
end;
|
||||||
|
if Masks<>'' then
|
||||||
|
Masks:=Masks+';';
|
||||||
|
SetLength(NewMask,MaskLen);
|
||||||
|
System.Move(MaskStart^,NewMask[1],length(NewMask));
|
||||||
|
Masks:=Masks+NewMask;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
p: PChar;
|
||||||
|
MaskStart: PChar;
|
||||||
|
begin
|
||||||
|
Result:='';
|
||||||
|
if aFilter='' then exit;
|
||||||
|
if SkipAllFilesMask then
|
||||||
|
AllFilesMask:=GetAllFilesMask
|
||||||
|
else
|
||||||
|
AllFilesMask:='';
|
||||||
|
//debugln(['TFileDialog.ExtractAllFilterMasks Filter=',aFilter]);
|
||||||
|
p:=PChar(aFilter);
|
||||||
|
while p^<>#0 do
|
||||||
|
begin
|
||||||
|
// skip caption
|
||||||
|
while not (p^ in ['|',#0]) do inc(p);
|
||||||
|
if p^=#0 then break;
|
||||||
|
// parse masks
|
||||||
|
repeat
|
||||||
|
inc(p);
|
||||||
|
MaskStart:=p;
|
||||||
|
while not (p^ in [';','|',#0]) do inc(p);
|
||||||
|
//debugln(['TFileDialog.ExtractAllFilterMasks Mask=',copy(aFilter,MaskStart-PChar(aFilter)+1,p-MaskStart)]);
|
||||||
|
if p>MaskStart then
|
||||||
|
AddMask(MaskStart,p-MaskStart,Result);
|
||||||
|
if p^='|' then break;
|
||||||
|
until p^=#0;
|
||||||
|
inc(p);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
procedure TFileDialog.SetDefaultExt(const AValue: string);
|
procedure TFileDialog.SetDefaultExt(const AValue: string);
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
@ -99,9 +169,9 @@ begin
|
|||||||
RegisterFileDialog;
|
RegisterFileDialog;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------
|
||||||
{ TFileDialog DoExecute }
|
TFileDialog DoExecute
|
||||||
{------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TFileDialog.DoExecute : boolean;
|
function TFileDialog.DoExecute : boolean;
|
||||||
begin
|
begin
|
||||||
Result:= inherited DoExecute;
|
Result:= inherited DoExecute;
|
||||||
|
|||||||
@ -19,6 +19,9 @@
|
|||||||
<ShowHints Value="False"/>
|
<ShowHints Value="False"/>
|
||||||
<ShowGenInfo Value="False"/>
|
<ShowGenInfo Value="False"/>
|
||||||
</Verbosity>
|
</Verbosity>
|
||||||
|
<CompilerMessages>
|
||||||
|
<UseMsgFile Value="True"/>
|
||||||
|
</CompilerMessages>
|
||||||
<CustomOptions Value="$(IDEBuildOptions)"/>
|
<CustomOptions Value="$(IDEBuildOptions)"/>
|
||||||
<CompilerPath Value="$(CompPath)"/>
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
</Other>
|
</Other>
|
||||||
@ -1196,13 +1199,14 @@
|
|||||||
<Item291>
|
<Item291>
|
||||||
<Filename Value="registerlcl.pas"/>
|
<Filename Value="registerlcl.pas"/>
|
||||||
<HasRegisterProc Value="True"/>
|
<HasRegisterProc Value="True"/>
|
||||||
<UnitName Value="registerlcl"/>
|
<UnitName Value="RegisterLCL"/>
|
||||||
</Item291>
|
</Item291>
|
||||||
<Item292>
|
<Item292>
|
||||||
<Filename Value="include/lclcolordialog.inc"/>
|
<Filename Value="include/lclcolordialog.inc"/>
|
||||||
<Type Value="Include"/>
|
<Type Value="Include"/>
|
||||||
</Item292>
|
</Item292>
|
||||||
</Files>
|
</Files>
|
||||||
|
<LazDoc Paths="../docs/xml/lcl"/>
|
||||||
<i18n>
|
<i18n>
|
||||||
<EnableI18N Value="True"/>
|
<EnableI18N Value="True"/>
|
||||||
<OutDir Value="languages"/>
|
<OutDir Value="languages"/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user