IDE In search results window, do not expand nodes when switching tabs. Issue #41259.

This commit is contained in:
Juha 2024-11-30 14:03:36 +02:00
parent e1aff780f0
commit d326f3e9e7
4 changed files with 19 additions and 8 deletions

View File

@ -82,8 +82,8 @@ type
fFirstPassedNode: TTreeNode; fFirstPassedNode: TTreeNode;
fOnGetImageIndex: TImageIndexEvent; fOnGetImageIndex: TImageIndexEvent;
fOnFilterNode: TFilterNodeEvent; fOnFilterNode: TFilterNodeEvent;
procedure SetFilteredTreeview(const AValue: TCustomTreeview); procedure SetFilteredTreeview(AValue: TCustomTreeview);
procedure SetShowDirHierarchy(const AValue: Boolean); procedure SetShowDirHierarchy(AValue: Boolean);
function FilterTree(Node: TTreeNode): Boolean; function FilterTree(Node: TTreeNode): Boolean;
procedure OnBeforeTreeDestroy(Sender: TObject); procedure OnBeforeTreeDestroy(Sender: TObject);
protected protected
@ -102,6 +102,7 @@ type
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
procedure SetTreeFilterSilently(ATree: TCustomTreeview; AFilter: string);
procedure StoreSelection; override; procedure StoreSelection; override;
procedure RestoreSelection; override; procedure RestoreSelection; override;
function GetExistingBranch(ARootNode: TTreeNode): TTreeFilterBranch; function GetExistingBranch(ARootNode: TTreeNode): TTreeFilterBranch;
@ -446,7 +447,7 @@ begin
FreeAndNil(fBranches); FreeAndNil(fBranches);
end; end;
procedure TTreeFilterEdit.SetFilteredTreeview(const AValue: TCustomTreeview); procedure TTreeFilterEdit.SetFilteredTreeview(AValue: TCustomTreeview);
begin begin
if fFilteredTreeview = AValue then Exit; if fFilteredTreeview = AValue then Exit;
if fFilteredTreeview <> nil then if fFilteredTreeview <> nil then
@ -463,7 +464,16 @@ begin
end; end;
end; end;
procedure TTreeFilterEdit.SetShowDirHierarchy(const AValue: Boolean); procedure TTreeFilterEdit.SetTreeFilterSilently(ATree: TCustomTreeview; AFilter: string);
begin // The tree is already filtered, the same FilterEdit is used for many.
fAlreadyFiltered:=True;
SetFilteredTreeview(ATree);
InternalSetFilter(AFilter);
fAlreadyFiltered:=False;
Text:=AFilter; // This will trigger filtering if Text differs from AFilter.
end;
procedure TTreeFilterEdit.SetShowDirHierarchy(AValue: Boolean);
begin begin
if fShowDirHierarchy=AValue then exit; if fShowDirHierarchy=AValue then exit;
if not Assigned(fFilteredTreeview) then if not Assigned(fFilteredTreeview) then

View File

@ -10,9 +10,9 @@ object SearchResultsView: TSearchResultsView
Constraints.MinHeight = 100 Constraints.MinHeight = 100
Constraints.MinWidth = 400 Constraints.MinWidth = 400
KeyPreview = True KeyPreview = True
LCLVersion = '4.99.0.0'
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

View File

@ -798,8 +798,7 @@ begin
lTree := GetCurrentTree; lTree := GetCurrentTree;
if assigned(lTree) and not (csDestroying in lTree.ComponentState) then if assigned(lTree) and not (csDestroying in lTree.ComponentState) then
begin begin
SearchInListEdit.FilteredTreeview := lTree; SearchInListEdit.SetTreeFilterSilently(lTree, lTree.SearchInListPhrases);
SearchInListEdit.Filter := lTree.SearchInListPhrases;
if FFocusTreeViewInOnChange then if FFocusTreeViewInOnChange then
ActivateControl(lTree); ActivateControl(lTree);
end; end;

View File

@ -241,8 +241,9 @@ type
procedure OnAsync(Data: PtrInt); procedure OnAsync(Data: PtrInt);
function IsTextHintStored: Boolean; function IsTextHintStored: Boolean;
protected protected
fNeedUpdate: Boolean; fAlreadyFiltered: Boolean;
fIsFirstUpdate: Boolean; fIsFirstUpdate: Boolean;
fNeedUpdate: Boolean;
fSelectedPart: TObject; // Select this node on next update fSelectedPart: TObject; // Select this node on next update
fOnFilterItem: TFilterItemEvent; fOnFilterItem: TFilterItemEvent;
fOnFilterItemEx: TFilterItemExEvent; fOnFilterItemEx: TFilterItemExEvent;
@ -1348,6 +1349,7 @@ end;
procedure TCustomControlFilterEdit.InvalidateFilter; procedure TCustomControlFilterEdit.InvalidateFilter;
begin begin
if fAlreadyFiltered then Exit;
fNeedUpdate:=true; fNeedUpdate:=true;
IdleConnected:=true; IdleConnected:=true;
end; end;