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