mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-03 01:09:50 +01:00
Restriction browser: Use TreeFilterEdit for better filtering
git-svn-id: trunk@34895 -
This commit is contained in:
parent
6ae55bb20e
commit
36861c1f8e
@ -147,13 +147,15 @@ end;
|
|||||||
|
|
||||||
function GetRestrictedProperties: TOIRestrictedProperties;
|
function GetRestrictedProperties: TOIRestrictedProperties;
|
||||||
begin
|
begin
|
||||||
if RestrictedManager = nil then RestrictedManager := TRestrictedManager.Create;
|
if RestrictedManager = nil then
|
||||||
|
RestrictedManager := TRestrictedManager.Create;
|
||||||
Result := RestrictedManager.GetRestrictedProperties;
|
Result := RestrictedManager.GetRestrictedProperties;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetRestrictedList: TRestrictedList;
|
function GetRestrictedList: TRestrictedList;
|
||||||
begin
|
begin
|
||||||
if RestrictedManager = nil then RestrictedManager := TRestrictedManager.Create;
|
if RestrictedManager = nil then
|
||||||
|
RestrictedManager := TRestrictedManager.Create;
|
||||||
Result := RestrictedManager.GetRestrictedList;
|
Result := RestrictedManager.GetRestrictedList;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@ -2231,6 +2231,7 @@ resourcestring
|
|||||||
lisShowUnits = 'Show units';
|
lisShowUnits = 'Show units';
|
||||||
lisShowIdentifiers = 'Show identifiers';
|
lisShowIdentifiers = 'Show identifiers';
|
||||||
lisFilter = 'Filter';
|
lisFilter = 'Filter';
|
||||||
|
lisIssues = 'Issues';
|
||||||
lisUseMessageFile = 'Use message file:';
|
lisUseMessageFile = 'Use message file:';
|
||||||
lisRegularExpression = 'Regular expression';
|
lisRegularExpression = 'Regular expression';
|
||||||
lisInvalidFilter = 'Invalid filter';
|
lisInvalidFilter = 'Invalid filter';
|
||||||
|
|||||||
@ -1,67 +1,91 @@
|
|||||||
object RestrictionBrowserView: TRestrictionBrowserView
|
object RestrictionBrowserView: TRestrictionBrowserView
|
||||||
Left = 272
|
Left = 272
|
||||||
Height = 340
|
Height = 405
|
||||||
Top = 259
|
Top = 259
|
||||||
Width = 660
|
Width = 674
|
||||||
ActiveControl = NameFilterEdit
|
|
||||||
Caption = 'RestrictionBrowserView'
|
Caption = 'RestrictionBrowserView'
|
||||||
ClientHeight = 340
|
ClientHeight = 405
|
||||||
ClientWidth = 660
|
ClientWidth = 674
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
LCLVersion = '0.9.27'
|
LCLVersion = '0.9.31'
|
||||||
object IssueMemo: TMemo
|
object IssueMemo: TMemo
|
||||||
Left = 264
|
Left = 311
|
||||||
Height = 306
|
Height = 405
|
||||||
Top = 18
|
Top = 0
|
||||||
Width = 390
|
Width = 363
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Align = alClient
|
||||||
ReadOnly = True
|
ReadOnly = True
|
||||||
ScrollBars = ssAutoVertical
|
ScrollBars = ssAutoVertical
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object IssueFilterGroupBox: TGroupBox
|
object Panel1: TPanel
|
||||||
Left = 6
|
Left = 0
|
||||||
Height = 96
|
Height = 405
|
||||||
Top = 12
|
Top = 0
|
||||||
Width = 250
|
Width = 306
|
||||||
Caption = 'IssueFilterGroupBox'
|
Align = alLeft
|
||||||
ClientHeight = 77
|
ClientHeight = 405
|
||||||
ClientWidth = 246
|
ClientWidth = 306
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
object NameLabel: TLabel
|
object IssueFilterGroupBox: TGroupBox
|
||||||
Left = 10
|
Left = 1
|
||||||
Height = 14
|
Height = 96
|
||||||
Top = 44
|
Top = 1
|
||||||
Width = 53
|
Width = 304
|
||||||
Caption = 'NameLabel'
|
Align = alTop
|
||||||
ParentColor = False
|
Caption = 'IssueFilterGroupBox'
|
||||||
end
|
ClientHeight = 77
|
||||||
object NameFilterEdit: TEdit
|
ClientWidth = 298
|
||||||
Left = 70
|
|
||||||
Height = 23
|
|
||||||
Top = 38
|
|
||||||
Width = 164
|
|
||||||
OnChange = NameFilterEditChange
|
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
object NameLabel: TLabel
|
||||||
|
Left = 10
|
||||||
|
Height = 15
|
||||||
|
Top = 44
|
||||||
|
Width = 64
|
||||||
|
Caption = 'NameLabel'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object FilterEdit: TTreeFilterEdit
|
||||||
|
AnchorSideLeft.Control = NameLabel
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
Left = 80
|
||||||
|
Height = 22
|
||||||
|
Top = 41
|
||||||
|
Width = 156
|
||||||
|
ButtonWidth = 23
|
||||||
|
NumGlyphs = 0
|
||||||
|
BorderSpacing.Left = 6
|
||||||
|
MaxLength = 0
|
||||||
|
TabOrder = 0
|
||||||
|
ExpandAllInitially = False
|
||||||
|
FilteredTreeview = IssueTreeView
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object IssueTreeView: TTreeView
|
||||||
|
Left = 1
|
||||||
|
Height = 307
|
||||||
|
Top = 97
|
||||||
|
Width = 304
|
||||||
|
Align = alClient
|
||||||
|
Anchors = [akTop, akLeft, akBottom]
|
||||||
|
DefaultItemHeight = 16
|
||||||
|
HideSelection = False
|
||||||
|
Indent = 2
|
||||||
|
ReadOnly = True
|
||||||
|
RightClickSelect = True
|
||||||
|
RowSelect = True
|
||||||
|
ScrollBars = ssAutoBoth
|
||||||
|
ShowButtons = False
|
||||||
|
ShowLines = False
|
||||||
|
TabOrder = 1
|
||||||
|
OnSelectionChanged = IssueTreeViewSelectionChanged
|
||||||
|
Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoRowSelect, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object IssueTreeView: TTreeView
|
object Splitter1: TSplitter
|
||||||
Left = 6
|
Left = 306
|
||||||
Height = 210
|
Height = 405
|
||||||
Top = 114
|
Top = 0
|
||||||
Width = 250
|
Width = 5
|
||||||
Anchors = [akTop, akLeft, akBottom]
|
|
||||||
DefaultItemHeight = 19
|
|
||||||
HideSelection = False
|
|
||||||
Indent = 2
|
|
||||||
ReadOnly = True
|
|
||||||
RightClickSelect = True
|
|
||||||
RowSelect = True
|
|
||||||
ScrollBars = ssAutoBoth
|
|
||||||
ShowButtons = False
|
|
||||||
ShowLines = False
|
|
||||||
TabOrder = 2
|
|
||||||
OnSelectionChanged = IssueTreeViewSelectionChanged
|
|
||||||
Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoRowSelect, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -31,7 +31,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, InterfaceBase, LCLProc, Contnrs, Forms, Controls, Graphics,
|
Classes, SysUtils, InterfaceBase, LCLProc, Contnrs, Forms, Controls, Graphics,
|
||||||
Dialogs, StdCtrls, ComCtrls, Masks, ExtCtrls, Buttons,
|
Dialogs, StdCtrls, ComCtrls, TreeFilterEdit, ExtCtrls, Buttons,
|
||||||
IDEImagesIntf, ObjectInspector,
|
IDEImagesIntf, ObjectInspector,
|
||||||
CompatibilityRestrictions, IDEOptionDefs, LazarusIDEStrConsts,
|
CompatibilityRestrictions, IDEOptionDefs, LazarusIDEStrConsts,
|
||||||
EnvironmentOpts, ComponentReg, LazConf;
|
EnvironmentOpts, ComponentReg, LazConf;
|
||||||
@ -40,11 +40,13 @@ type
|
|||||||
{ TRestrictionBrowserView }
|
{ TRestrictionBrowserView }
|
||||||
|
|
||||||
TRestrictionBrowserView = class(TForm)
|
TRestrictionBrowserView = class(TForm)
|
||||||
NameFilterEdit: TEdit;
|
FilterEdit: TTreeFilterEdit;
|
||||||
IssueFilterGroupBox: TGroupBox;
|
IssueFilterGroupBox: TGroupBox;
|
||||||
IssueMemo: TMemo;
|
IssueMemo: TMemo;
|
||||||
NameLabel: TLabel;
|
|
||||||
IssueTreeView: TTreeView;
|
IssueTreeView: TTreeView;
|
||||||
|
NameLabel: TLabel;
|
||||||
|
Panel1: TPanel;
|
||||||
|
Splitter1: TSplitter;
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure IssueTreeViewSelectionChanged(Sender: TObject);
|
procedure IssueTreeViewSelectionChanged(Sender: TObject);
|
||||||
procedure NameFilterEditChange(Sender: TObject);
|
procedure NameFilterEditChange(Sender: TObject);
|
||||||
@ -53,8 +55,8 @@ type
|
|||||||
FClasses: TClassList;
|
FClasses: TClassList;
|
||||||
FCanUpdate: Boolean;
|
FCanUpdate: Boolean;
|
||||||
procedure GetComponentClass(const AClass: TComponentClass);
|
procedure GetComponentClass(const AClass: TComponentClass);
|
||||||
public
|
|
||||||
procedure UpdateIssueList;
|
procedure UpdateIssueList;
|
||||||
|
public
|
||||||
procedure SetIssueName(const AIssueName: String);
|
procedure SetIssueName(const AIssueName: String);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -73,14 +75,11 @@ var
|
|||||||
X: Integer;
|
X: Integer;
|
||||||
begin
|
begin
|
||||||
FIssueList := GetRestrictedList;
|
FIssueList := GetRestrictedList;
|
||||||
|
|
||||||
Name := NonModalIDEWindowNames[nmiwIssueBrowser];
|
Name := NonModalIDEWindowNames[nmiwIssueBrowser];
|
||||||
Caption := lisMenuViewRestrictionBrowser;
|
Caption := lisMenuViewRestrictionBrowser;
|
||||||
|
IssueFilterGroupBox.Caption := lisIssues;
|
||||||
IssueFilterGroupBox.Caption := lisFilter;
|
|
||||||
NameLabel.Caption := lisCodeToolsDefsName;
|
NameLabel.Caption := lisCodeToolsDefsName;
|
||||||
IssueTreeView.Images := IDEImages.Images_16;
|
IssueTreeView.Images := IDEImages.Images_16;
|
||||||
|
|
||||||
X := 10;
|
X := 10;
|
||||||
// create widget set filter buttons
|
// create widget set filter buttons
|
||||||
for P := Low(TLCLPlatform) to High(TLCLPlatform) do
|
for P := Low(TLCLPlatform) to High(TLCLPlatform) do
|
||||||
@ -95,26 +94,23 @@ begin
|
|||||||
GroupIndex := Integer(P) + 1;
|
GroupIndex := Integer(P) + 1;
|
||||||
Down := True;
|
Down := True;
|
||||||
AllowAllUp := True;
|
AllowAllUp := True;
|
||||||
|
|
||||||
try
|
try
|
||||||
IDEImages.Images_16.GetBitmap(
|
IDEImages.Images_16.GetBitmap(
|
||||||
IDEImages.LoadImage(16, 'issue_'+LCLPlatformDirNames[P]), Glyph);
|
IDEImages.LoadImage(16, 'issue_'+LCLPlatformDirNames[P]), Glyph);
|
||||||
except
|
except
|
||||||
DebugLn('Restriction Browser: Unable to load image for ' + LCLPlatformDirNames[P] + '!');
|
DebugLn('Restriction Browser: Unable to load image for ' + LCLPlatformDirNames[P] + '!');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ShowHint := True;
|
ShowHint := True;
|
||||||
Hint := LCLPlatformDisplayNames[P];
|
Hint := LCLPlatformDisplayNames[P];
|
||||||
OnClick := @NameFilterEditChange;
|
OnClick := @NameFilterEditChange;
|
||||||
|
|
||||||
Parent := IssueFilterGroupBox;
|
Parent := IssueFilterGroupBox;
|
||||||
Inc(X, Width);
|
Inc(X, Width);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FCanUpdate := True;
|
FCanUpdate := True;
|
||||||
UpdateIssueList;
|
UpdateIssueList;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TRestrictionBrowserView.IssueTreeViewSelectionChanged(Sender: TObject);
|
procedure TRestrictionBrowserView.IssueTreeViewSelectionChanged(Sender: TObject);
|
||||||
var
|
var
|
||||||
Issue: TRestriction;
|
Issue: TRestriction;
|
||||||
@ -124,7 +120,6 @@ begin
|
|||||||
IssueMemo.Clear;
|
IssueMemo.Clear;
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Issue := PRestriction(IssueTreeView.Selected.Data)^;
|
Issue := PRestriction(IssueTreeView.Selected.Data)^;
|
||||||
IssueMemo.Text := Issue.Short + LineEnding + LineEnding + Issue.Description;
|
IssueMemo.Text := Issue.Short + LineEnding + LineEnding + Issue.Description;
|
||||||
end;
|
end;
|
||||||
@ -141,130 +136,48 @@ end;
|
|||||||
|
|
||||||
procedure TRestrictionBrowserView.UpdateIssueList;
|
procedure TRestrictionBrowserView.UpdateIssueList;
|
||||||
var
|
var
|
||||||
IssueClass: String;
|
|
||||||
IssueProperty: String;
|
|
||||||
IssueMask: TMaskList;
|
|
||||||
S, M: String;
|
|
||||||
I, ID: PtrInt;
|
I, ID: PtrInt;
|
||||||
Issues: TStringList;
|
Issues: TStringList;
|
||||||
Issue: TRestriction;
|
|
||||||
C: TClass;
|
|
||||||
AddParentClass: Boolean;
|
|
||||||
P: TLCLPlatform;
|
P: TLCLPlatform;
|
||||||
WidgetSetFilter: TLCLPlatforms;
|
WidgetSetFilter: TLCLPlatforms;
|
||||||
Component: TComponent;
|
Component: TComponent;
|
||||||
begin
|
begin
|
||||||
if not FCanUpdate then Exit;
|
if not FCanUpdate then Exit;
|
||||||
S := Trim(NameFilterEdit.Text);
|
|
||||||
IssueClass := '';
|
|
||||||
IssueProperty := '';
|
|
||||||
|
|
||||||
WidgetSetFilter := [];
|
WidgetSetFilter := [];
|
||||||
for P := Low(TLCLPlatform) to High(TLCLPlatform) do
|
for P := Low(TLCLPlatform) to High(TLCLPlatform) do
|
||||||
begin
|
begin
|
||||||
Component := FindComponent('SpeedButton' + LCLPlatformDirNames[P]);
|
Component := FindComponent('SpeedButton' + LCLPlatformDirNames[P]);
|
||||||
if Component is TSpeedButton then
|
Assert(Component is TSpeedButton, 'Component '+Component.Name+' is not TSpeedButton');
|
||||||
if (Component as TSpeedButton).Down then Include(WidgetSetFilter, P);
|
if (Component as TSpeedButton).Down then
|
||||||
|
Include(WidgetSetFilter, P);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
I := Pos('.', S);
|
|
||||||
if I = 0 then IssueClass := S
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
IssueClass := Copy(S, 0, I - 1);
|
|
||||||
IssueProperty := Copy(S, I + 1, MaxInt);
|
|
||||||
end;
|
|
||||||
|
|
||||||
if (IssueProperty = '') and (IssueClass = '') then
|
|
||||||
M := '*'
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
if IssueClass = '' then
|
|
||||||
M := '*.' + IssueProperty + '*'
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
// find parent classes
|
|
||||||
M := '';
|
|
||||||
FClasses := TClassList.Create;
|
|
||||||
try
|
|
||||||
IDEComponentPalette.IterateRegisteredClasses(@GetComponentClass);
|
|
||||||
|
|
||||||
FClasses.Add(TCustomForm);
|
|
||||||
FClasses.Add(TForm);
|
|
||||||
FClasses.Add(TDataModule);
|
|
||||||
FClasses.Add(TFrame);
|
|
||||||
|
|
||||||
for I := 0 to FClasses.Count - 1 do
|
|
||||||
begin
|
|
||||||
C := FClasses[I];
|
|
||||||
AddParentClass := False;
|
|
||||||
while C <> nil do
|
|
||||||
begin
|
|
||||||
if AddParentClass or (Copy(C.ClassName, 0, Length(IssueClass)) = IssueClass) then
|
|
||||||
begin
|
|
||||||
if M <> '' then M := M + ';';
|
|
||||||
M := M + C.ClassName + ';' + C.ClassName + '.' + IssueProperty + '*';
|
|
||||||
AddParentClass := True;
|
|
||||||
end;
|
|
||||||
|
|
||||||
C := C.ClassParent;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if FClasses.Count = 0 then
|
|
||||||
M := IssueClass + '*;' + IssueClass + '*.' + IssueProperty + '*';
|
|
||||||
|
|
||||||
if (Copy('TWidgetSet', 0, Length(IssueClass)) = IssueClass) then
|
|
||||||
M := M + ';TWidgetSet';
|
|
||||||
finally
|
|
||||||
FClasses.Free;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
IssueMask := TMaskList.Create(M);
|
|
||||||
Issues := TStringList.Create;
|
Issues := TStringList.Create;
|
||||||
try
|
try
|
||||||
for I := 0 to High(FIssueList) do
|
for I := 0 to High(FIssueList) do
|
||||||
begin
|
if FIssueList[I].WidgetSet in WidgetSetFilter then
|
||||||
Issue := FIssueList[I];
|
Issues.AddObject(FIssueList[I].Name, TObject(I));
|
||||||
if Issue.WidgetSet in WidgetSetFilter then
|
|
||||||
if IssueMask.Matches(Issue.Name) then
|
|
||||||
Issues.AddObject(Issue.Name, TObject(I));
|
|
||||||
end;
|
|
||||||
|
|
||||||
Issues.Sort;
|
Issues.Sort;
|
||||||
|
|
||||||
IssueTreeView.BeginUpdate;
|
IssueTreeView.BeginUpdate;
|
||||||
try
|
try
|
||||||
IssueTreeView.Items.Clear;
|
IssueTreeView.Items.Clear;
|
||||||
|
|
||||||
for I := 0 to Issues.Count - 1 do
|
for I := 0 to Issues.Count - 1 do
|
||||||
begin
|
begin
|
||||||
with IssueTreeView.Items.AddChild(nil, Issues[I]) do
|
with IssueTreeView.Items.AddChild(nil, Issues[I]) do
|
||||||
begin
|
begin
|
||||||
ID := PtrInt(Issues.Objects[I]);
|
ID := PtrInt(Issues.Objects[I]);
|
||||||
|
|
||||||
ImageIndex := IDEImages.LoadImage(16,
|
ImageIndex := IDEImages.LoadImage(16,
|
||||||
'issue_'+LCLPlatformDirNames[FIssueList[ID].WidgetSet]);
|
'issue_'+LCLPlatformDirNames[FIssueList[ID].WidgetSet]);
|
||||||
StateIndex := ImageIndex;
|
StateIndex := ImageIndex;
|
||||||
SelectedIndex := ImageIndex;
|
SelectedIndex := ImageIndex;
|
||||||
|
|
||||||
Data := @FIssueList[ID];
|
Data := @FIssueList[ID];
|
||||||
end;
|
end;
|
||||||
if NameFilterEdit.Text = Issues[I] then
|
|
||||||
begin
|
|
||||||
IssueTreeView.Selected := IssueTreeView.Items[I];
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
IssueTreeView.EndUpdate;
|
IssueTreeView.EndUpdate;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
Issues.Free;
|
Issues.Free;
|
||||||
IssueMask.Free;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if IssueTreeView.Items.Count > 0 then
|
if IssueTreeView.Items.Count > 0 then
|
||||||
begin
|
begin
|
||||||
if IssueTreeView.Selected = nil then
|
if IssueTreeView.Selected = nil then
|
||||||
@ -281,15 +194,14 @@ var
|
|||||||
begin
|
begin
|
||||||
FCanUpdate := False;
|
FCanUpdate := False;
|
||||||
try
|
try
|
||||||
NameFilterEdit.Text := AIssueName;
|
FilterEdit.Text := AIssueName;
|
||||||
|
|
||||||
if AIssueName <> '' then
|
if AIssueName <> '' then
|
||||||
begin
|
begin
|
||||||
for P := Low(TLCLPlatform) to High(TLCLPlatform) do
|
for P := Low(TLCLPlatform) to High(TLCLPlatform) do
|
||||||
begin
|
begin
|
||||||
Component := FindComponent('SpeedButton' + LCLPlatformDirNames[P]);
|
Component := FindComponent('SpeedButton' + LCLPlatformDirNames[P]);
|
||||||
if Component is TSpeedButton then
|
Assert(Component is TSpeedButton, 'Component '+Component.Name+' is not TSpeedButton');
|
||||||
(Component as TSpeedButton).Down := True;
|
(Component as TSpeedButton).Down := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user