mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 13:49:32 +02:00
IDE: improve filtering in all options window
git-svn-id: trunk@42212 -
This commit is contained in:
parent
733b4108c6
commit
104bb46440
@ -83,6 +83,7 @@ object frmAllCompilerOptions: TfrmAllCompilerOptions
|
||||
Width = 143
|
||||
BorderSpacing.Left = 29
|
||||
Caption = 'Show only modified'
|
||||
OnClick = cbShowModifiedClick
|
||||
TabOrder = 3
|
||||
end
|
||||
object cbUseComments: TCheckBox
|
||||
|
@ -7,7 +7,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
||||
contnrs, Buttons, ButtonPanel, EditBtn,
|
||||
EnvironmentOpts, Compiler, LazarusIDEStrConsts;
|
||||
FileProcs, EnvironmentOpts, Compiler, LazarusIDEStrConsts;
|
||||
|
||||
type
|
||||
|
||||
@ -21,6 +21,7 @@ type
|
||||
edOptionsFilter: TEdit;
|
||||
sbAllOptions: TScrollBox;
|
||||
procedure btnResetOptionsFilterClick(Sender: TObject);
|
||||
procedure cbShowModifiedClick(Sender: TObject);
|
||||
procedure edOptionsFilterChange(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
private
|
||||
@ -29,6 +30,7 @@ type
|
||||
FOptionsReader: TCompilerOptReader;
|
||||
FGeneratedControls: TComponentList;
|
||||
FEffectiveFilter: string;
|
||||
FInitialRender: Boolean;
|
||||
procedure SetIdleConnected(AValue: Boolean);
|
||||
procedure OnIdle(Sender: TObject; var Done: Boolean);
|
||||
procedure CheckBoxClick(Sender: TObject);
|
||||
@ -84,13 +86,14 @@ begin
|
||||
btnResetOptionsFilter.Enabled := False;
|
||||
btnResetOptionsFilter.Hint := 'Clear the filter for options';
|
||||
FEffectiveFilter:=#1; // Set an impossible value first, makes sure options are filtered.
|
||||
FInitialRender := True;
|
||||
IdleConnected := True;
|
||||
end;
|
||||
|
||||
procedure TfrmAllCompilerOptions.edOptionsFilterChange(Sender: TObject);
|
||||
begin
|
||||
btnResetOptionsFilter.Enabled := edOptionsFilter.Text<>'';
|
||||
// ToDo : Filter the list of options
|
||||
// Filter the list of options in OnIdle handler
|
||||
IdleConnected := True;
|
||||
end;
|
||||
|
||||
@ -100,6 +103,11 @@ begin
|
||||
btnResetOptionsFilter.Enabled := False;
|
||||
end;
|
||||
|
||||
procedure TfrmAllCompilerOptions.cbShowModifiedClick(Sender: TObject);
|
||||
begin
|
||||
;
|
||||
end;
|
||||
|
||||
procedure TfrmAllCompilerOptions.SetIdleConnected(AValue: Boolean);
|
||||
begin
|
||||
if FIdleConnected = AValue then exit;
|
||||
@ -116,10 +124,14 @@ begin
|
||||
Screen.Cursor := crHourGlass;
|
||||
try
|
||||
edOptionsFilter.Enabled := False;
|
||||
FOptionsReader.CompilerExecutable := EnvironmentOptions.CompilerFilename;
|
||||
if FOptionsReader.ReadAndParseOptions <> mrOK then
|
||||
ShowMessage(FOptionsReader.ErrorMsg);
|
||||
FOptionsReader.FromCustomOptions(FCustomOptions);
|
||||
with FOptionsReader do
|
||||
if RootOptGroup.CompilerOpts.Count = 0 then
|
||||
begin
|
||||
CompilerExecutable := EnvironmentOptions.CompilerFilename;
|
||||
if ReadAndParseOptions <> mrOK then
|
||||
ShowMessage(ErrorMsg);
|
||||
FromCustomOptions(FCustomOptions);
|
||||
end;
|
||||
RenderAndFilterOptions;
|
||||
edOptionsFilter.Enabled := True;
|
||||
finally
|
||||
@ -306,7 +318,12 @@ begin
|
||||
FGeneratedControls.Clear;
|
||||
yLoc := 0;
|
||||
RenderOneLevel(FOptionsReader.RootOptGroup);
|
||||
FEffectiveFilter:=edOptionsFilter.Text;
|
||||
FEffectiveFilter := edOptionsFilter.Text;
|
||||
{$IFDEF AllOptsFocusFilter}
|
||||
if not FInitialRender then
|
||||
FocusControl(edOptionsFilter);
|
||||
{$ENDIF}
|
||||
FInitialRender := False;
|
||||
finally
|
||||
Container.EnableAutoSizing;
|
||||
Container.Invalidate;
|
||||
|
@ -123,6 +123,7 @@ type
|
||||
fOwnerGroup: TCompilerOptGroup;
|
||||
fVisible: Boolean; // Used for filtering.
|
||||
fIgnored: Boolean; // Pretend this option does not exist.
|
||||
procedure Filter(aFilt: string);
|
||||
protected
|
||||
procedure ParseOption(aDescr: string; aIndent: integer); virtual;
|
||||
public
|
||||
@ -462,6 +463,27 @@ begin
|
||||
fIgnored := True;
|
||||
end;
|
||||
|
||||
procedure TCompilerOpt.Filter(aFilt: string);
|
||||
//var
|
||||
// iOpt, iDes: SizeInt;
|
||||
begin
|
||||
Visible := not fIgnored
|
||||
and ( (aFilt='') or (Pos(aFilt,UTF8LowerCase(fOption))>0)
|
||||
or (Pos(aFilt,UTF8LowerCase(fDescription))>0) );
|
||||
{
|
||||
if aFilt = '' then
|
||||
Visible := not fIgnored
|
||||
else begin
|
||||
iOpt := Pos(aFilt,UTF8LowerCase(fOption));
|
||||
iDes := Pos(aFilt,UTF8LowerCase(fDescription));
|
||||
Visible := not fIgnored and ( (iOpt>0) or (iDes>0) );
|
||||
if Visible then
|
||||
DebugLn(['TCompilerOpt.Filter match "', aFilt, '": iOpt=', iOpt,
|
||||
', iDes=', iDes, ', Ignore=', fIgnored, ', Opt'=fOption, ', Descr=', fDescription]);
|
||||
end;
|
||||
}
|
||||
end;
|
||||
|
||||
{ TCompilerOptGroup }
|
||||
|
||||
constructor TCompilerOptGroup.Create(aOwnerGroup: TCompilerOptGroup);
|
||||
@ -906,12 +928,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function FilterOneOpt(aOpt: TCompilerOpt; aFilt: string): Boolean;
|
||||
begin
|
||||
Result := (aFilt='') or (Pos(aFilt,UTF8LowerCase(aOpt.Option))>0)
|
||||
or (Pos(aFilt,UTF8LowerCase(aOpt.Description))>0);
|
||||
end;
|
||||
|
||||
function TCompilerOptReader.FilterOptions(aFilter: string): Boolean;
|
||||
// Filter all options recursively, setting their Visible flag as needed.
|
||||
// Returns True if Option(group) or child options have visible items.
|
||||
@ -922,7 +938,7 @@ function TCompilerOptReader.FilterOptions(aFilter: string): Boolean;
|
||||
i: Integer;
|
||||
begin
|
||||
// Filter the root item
|
||||
aRoot.Visible := FilterOneOpt(aRoot, aFilter);
|
||||
aRoot.Filter(aFilter); // Sets Visible flag
|
||||
// Filter children in a group
|
||||
if aRoot is TCompilerOptGroup then
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user