mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 05:39:17 +02:00
IDE, LazControls: Improve TTreeFilterEdit behavior. Fix property ExpandAllInitially. Issue #40257.
This commit is contained in:
parent
8d883d68d2
commit
6e1adda721
@ -12,7 +12,7 @@ object ObjectInspectorDlg: TObjectInspectorDlg
|
|||||||
ClientHeight = 818
|
ClientHeight = 818
|
||||||
ClientWidth = 293
|
ClientWidth = 293
|
||||||
KeyPreview = True
|
KeyPreview = True
|
||||||
LCLVersion = '2.1.0.0'
|
LCLVersion = '2.3.0.0'
|
||||||
object StatusBar: TStatusBar
|
object StatusBar: TStatusBar
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 21
|
Height = 21
|
||||||
@ -72,6 +72,7 @@ object ObjectInspectorDlg: TObjectInspectorDlg
|
|||||||
NumGlyphs = 1
|
NumGlyphs = 1
|
||||||
MaxLength = 0
|
MaxLength = 0
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
ExpandAllInitially = True
|
||||||
end
|
end
|
||||||
object CompFilterLabel: TLabel
|
object CompFilterLabel: TLabel
|
||||||
Left = 3
|
Left = 3
|
||||||
|
@ -20,7 +20,7 @@ uses
|
|||||||
// LCL
|
// LCL
|
||||||
LCLType, Graphics, ComCtrls, EditBtn,
|
LCLType, Graphics, ComCtrls, EditBtn,
|
||||||
// LazUtils
|
// LazUtils
|
||||||
LazFileUtils, LazUTF8, AvgLvlTree;
|
LazFileUtils, LazUTF8, LazLoggerBase, AvgLvlTree;
|
||||||
|
|
||||||
type
|
type
|
||||||
TImageIndexEvent = function (Str: String; Data: TObject;
|
TImageIndexEvent = function (Str: String; Data: TObject;
|
||||||
@ -476,21 +476,24 @@ var
|
|||||||
Pass, Done: Boolean;
|
Pass, Done: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
Pass := False;
|
||||||
Done := False;
|
Done := False;
|
||||||
while (Node<>nil) and not Done do
|
while Node<>nil do
|
||||||
begin
|
begin
|
||||||
// Filter with event handler if there is one.
|
// Filter with event handler if there is one.
|
||||||
if Assigned(fOnFilterNode) then
|
if Assigned(fOnFilterNode) then
|
||||||
Pass := fOnFilterNode(Node, Done);
|
Pass := fOnFilterNode(Node, Done);
|
||||||
if not (Pass and Done) then
|
if not Done then
|
||||||
Pass := DoFilterItem(Node.Text, Node.Data);
|
Pass := DoFilterItem(Node.Text, Node.Data);
|
||||||
if Pass and (fFirstPassedNode=Nil) then
|
if Pass and (fFirstPassedNode=Nil) then
|
||||||
fFirstPassedNode:=Node;
|
fFirstPassedNode:=Node;
|
||||||
// Recursive call for child nodes.
|
// Recursive call for child nodes.
|
||||||
Node.Visible:=FilterTree(Node.GetFirstChild) or Pass;
|
Node.Visible := FilterTree(Node.GetFirstChild) or Pass;
|
||||||
if Node.Visible then
|
if Node.Visible then begin // Collapse all when Filter=''.
|
||||||
Result:=True;
|
Node.Expanded := (Filter<>'') or fExpandAllInitially;
|
||||||
Node:=Node.GetNextSibling;
|
Result := True;
|
||||||
|
end;
|
||||||
|
Node := Node.GetNextSibling;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ object SearchResultsView: TSearchResultsView
|
|||||||
OnClose = FormClose
|
OnClose = FormClose
|
||||||
OnCreate = Form1Create
|
OnCreate = Form1Create
|
||||||
OnKeyDown = FormKeyDown
|
OnKeyDown = FormKeyDown
|
||||||
|
LCLVersion = '2.3.0.0'
|
||||||
object ControlBar1: TPanel
|
object ControlBar1: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 26
|
Height = 26
|
||||||
@ -80,6 +81,7 @@ object SearchResultsView: TSearchResultsView
|
|||||||
MaxLength = 0
|
MaxLength = 0
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
OnChange = SearchInListChange
|
OnChange = SearchInListChange
|
||||||
|
ExpandAllInitially = True
|
||||||
end
|
end
|
||||||
object CloseTabs: TToolBar
|
object CloseTabs: TToolBar
|
||||||
Left = 616
|
Left = 616
|
||||||
|
@ -12,7 +12,7 @@ object ToolBarConfig: TToolBarConfig
|
|||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
OnDestroy = FormDestroy
|
OnDestroy = FormDestroy
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
LCLVersion = '2.1.0.0'
|
LCLVersion = '2.3.0.0'
|
||||||
object lblMenuTree: TLabel
|
object lblMenuTree: TLabel
|
||||||
AnchorSideLeft.Control = TV
|
AnchorSideLeft.Control = TV
|
||||||
AnchorSideLeft.Side = asrCenter
|
AnchorSideLeft.Side = asrCenter
|
||||||
@ -115,6 +115,7 @@ object ToolBarConfig: TToolBarConfig
|
|||||||
BorderSpacing.Bottom = 6
|
BorderSpacing.Bottom = 6
|
||||||
ReadOnly = True
|
ReadOnly = True
|
||||||
ScrollBars = ssAutoBoth
|
ScrollBars = ssAutoBoth
|
||||||
|
ShowSeparators = False
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
OnDblClick = TVDblClick
|
OnDblClick = TVDblClick
|
||||||
OnSelectionChanged = TVSelectionChanged
|
OnSelectionChanged = TVSelectionChanged
|
||||||
@ -137,7 +138,7 @@ object ToolBarConfig: TToolBarConfig
|
|||||||
ParentFont = False
|
ParentFont = False
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
FilteredTreeview = TV
|
FilteredTreeview = TV
|
||||||
ExpandAllInitially = True
|
OnFilterNode = FilterEditFilterNode
|
||||||
end
|
end
|
||||||
object Splitter1: TSplitter
|
object Splitter1: TSplitter
|
||||||
AnchorSideLeft.Control = TV
|
AnchorSideLeft.Control = TV
|
||||||
|
@ -63,6 +63,7 @@ type
|
|||||||
Splitter1: TSplitter;
|
Splitter1: TSplitter;
|
||||||
TV: TTreeView;
|
TV: TTreeView;
|
||||||
procedure btnHelpClick(Sender: TObject);
|
procedure btnHelpClick(Sender: TObject);
|
||||||
|
function FilterEditFilterNode({%H-}ItemNode: TTreeNode; out Done: Boolean): Boolean;
|
||||||
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
|
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
@ -79,7 +80,6 @@ type
|
|||||||
{%H-}Selected: Boolean);
|
{%H-}Selected: Boolean);
|
||||||
procedure TVSelectionChanged(Sender: TObject);
|
procedure TVSelectionChanged(Sender: TObject);
|
||||||
private
|
private
|
||||||
Image: TBitMap;
|
|
||||||
defImageIndex: integer;
|
defImageIndex: integer;
|
||||||
procedure AddCommand;
|
procedure AddCommand;
|
||||||
procedure AddDivider;
|
procedure AddDivider;
|
||||||
@ -89,7 +89,6 @@ type
|
|||||||
procedure MoveUpDown(aOffset: integer);
|
procedure MoveUpDown(aOffset: integer);
|
||||||
function NewLvItem(aCaption: string): TListItem;
|
function NewLvItem(aCaption: string): TListItem;
|
||||||
procedure RemoveCommand;
|
procedure RemoveCommand;
|
||||||
procedure SetupCaptions;
|
|
||||||
procedure LoadCategories;
|
procedure LoadCategories;
|
||||||
procedure SortCategories(ACtgList: TStrings);
|
procedure SortCategories(ACtgList: TStrings);
|
||||||
procedure AddMenuItem(ParentNode: TTreeNode; CmdItem: TIDEButtonCommand);
|
procedure AddMenuItem(ParentNode: TTreeNode; CmdItem: TIDEButtonCommand);
|
||||||
@ -163,9 +162,9 @@ begin
|
|||||||
lvToolbar.SmallImages := IDEImages.Images_16;
|
lvToolbar.SmallImages := IDEImages.Images_16;
|
||||||
// default image to be used when none is available
|
// default image to be used when none is available
|
||||||
defImageIndex := IDEImages.LoadImage('execute');
|
defImageIndex := IDEImages.LoadImage('execute');
|
||||||
|
Caption := lisToolbarConfiguration;
|
||||||
Image := TBitmap.Create;
|
lblMenuTree.Caption := lisCoolbarAvailableCommands;
|
||||||
SetupCaptions;
|
lblToolbar.Caption := lisCoolbarToolbarCommands;
|
||||||
LoadCategories;
|
LoadCategories;
|
||||||
IDEDialogLayoutList.ApplyLayout(Self);
|
IDEDialogLayoutList.ApplyLayout(Self);
|
||||||
end;
|
end;
|
||||||
@ -177,7 +176,7 @@ end;
|
|||||||
|
|
||||||
procedure TToolBarConfig.FormDestroy(Sender: TObject);
|
procedure TToolBarConfig.FormDestroy(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Image.Free;
|
;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TToolBarConfig.lvToolbarDblClick(Sender: TObject);
|
procedure TToolBarConfig.lvToolbarDblClick(Sender: TObject);
|
||||||
@ -200,6 +199,12 @@ begin
|
|||||||
OpenUrl('http://wiki.freepascal.org/IDE_Window:_Toolbar_Config');
|
OpenUrl('http://wiki.freepascal.org/IDE_Window:_Toolbar_Config');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TToolBarConfig.FilterEditFilterNode(ItemNode: TTreeNode; out Done: Boolean): Boolean;
|
||||||
|
begin
|
||||||
|
Result := lvToolbar.FindCaption(0, ItemNode.Text, True, True, False) = Nil;
|
||||||
|
Done := not Result;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TToolBarConfig.UpdateButtonsState;
|
procedure TToolBarConfig.UpdateButtonsState;
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
@ -252,8 +257,7 @@ begin
|
|||||||
Node := TV.Selected;
|
Node := TV.Selected;
|
||||||
if (Node = Nil) or (Node.Data = Nil) then
|
if (Node = Nil) or (Node.Data = Nil) then
|
||||||
Exit;
|
Exit;
|
||||||
CmdCaption := TIDEButtonCommand(Node.Data).Caption;
|
CmdCaption := TIDEButtonCommand(Node.Data).GetCaptionWithShortCut;
|
||||||
DeleteAmpersands(CmdCaption);
|
|
||||||
lvItem := NewLvItem(CmdCaption);
|
lvItem := NewLvItem(CmdCaption);
|
||||||
lvItem.Data := Node.Data;
|
lvItem.Data := Node.Data;
|
||||||
if Node.ImageIndex > -1 then
|
if Node.ImageIndex > -1 then
|
||||||
@ -344,13 +348,6 @@ begin
|
|||||||
MoveUpDown(-1);
|
MoveUpDown(-1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TToolBarConfig.SetupCaptions;
|
|
||||||
begin
|
|
||||||
Caption := lisToolbarConfiguration;
|
|
||||||
lblMenuTree.Caption := lisCoolbarAvailableCommands;
|
|
||||||
lblToolbar.Caption := lisCoolbarToolbarCommands;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TToolBarConfig.LoadCategories;
|
procedure TToolBarConfig.LoadCategories;
|
||||||
var
|
var
|
||||||
i, l: integer;
|
i, l: integer;
|
||||||
@ -424,7 +421,7 @@ var
|
|||||||
Node: TTreeNode;
|
Node: TTreeNode;
|
||||||
begin
|
begin
|
||||||
if CmdItem.Caption = '-' then Exit; // divider
|
if CmdItem.Caption = '-' then Exit; // divider
|
||||||
Node := TV.Items.AddChild(ParentNode, Format('%s', [CmdItem.GetCaptionWithShortCut]));
|
Node := TV.Items.AddChild(ParentNode, CmdItem.GetCaptionWithShortCut);
|
||||||
Node.ImageIndex := CmdItem.ImageIndex;
|
Node.ImageIndex := CmdItem.ImageIndex;
|
||||||
Node.SelectedIndex := CmdItem.ImageIndex;
|
Node.SelectedIndex := CmdItem.ImageIndex;
|
||||||
Node.Data := CmdItem;
|
Node.Data := CmdItem;
|
||||||
@ -500,8 +497,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
Cmd := IDEToolButtonCategories.FindItemByMenuPathOrName(Value);
|
Cmd := IDEToolButtonCategories.FindItemByMenuPathOrName(Value);
|
||||||
AddToolBarItem(Cmd); // Add command.
|
AddToolBarItem(Cmd); // Add command.
|
||||||
if Value <> SL[I] then
|
//if Value <> SL[I] then
|
||||||
DebugLn(['TToolBarConfig.LoadSettings: SL[I]=', SL[I], ', Value=', Value]);
|
// DebugLn(['TToolBarConfig.LoadSettings: SL[I]=', SL[I], ', Value=', Value]);
|
||||||
SL[I] := Value;
|
SL[I] := Value;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user