From d54f5572faa71f415fdf33f0f394e1e8f21fdb19 Mon Sep 17 00:00:00 2001 From: bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Fri, 13 Feb 2015 17:24:40 +0000 Subject: [PATCH] ShellTreeView: refresh the tree when ObjectTypes is changed. Based upon a patch by theo. git-svn-id: trunk@47743 - --- lcl/shellctrls.pas | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lcl/shellctrls.pas b/lcl/shellctrls.pas index 73fd7c5786..021943506e 100644 --- a/lcl/shellctrls.pas +++ b/lcl/shellctrls.pas @@ -57,6 +57,7 @@ type { Setters and getters } function GetPath: string; procedure SetFileSortType(const AValue: TFileSortType); + procedure SetObjectTypes(AValue: TObjectTypes); procedure SetPath(AValue: string); procedure SetRoot(const AValue: string); procedure SetShellListView(const Value: TCustomShellListView); @@ -84,7 +85,7 @@ type procedure Refresh(ANode: TTreeNode); overload; { Properties } - property ObjectTypes: TObjectTypes read FObjectTypes write FObjectTypes; + property ObjectTypes: TObjectTypes read FObjectTypes write SetObjectTypes; property ShellListView: TCustomShellListView read FShellListView write SetShellListView; property FileSortType: TFileSortType read FFileSortType write SetFileSortType; property Root: string read FRoot write SetRoot; @@ -457,6 +458,28 @@ begin end; end; +procedure TCustomShellTreeView.SetObjectTypes(AValue: TObjectTypes); +var + CurrPath: String; +begin + if FObjectTypes = AValue then Exit; + FObjectTypes := AValue; + if (csLoading in ComponentState) then Exit; + CurrPath := GetPath; + try + BeginUpdate; + Refresh(nil); + try + SetPath(CurrPath); + except + // CurrPath may have been removed in the mean time by another process, just ignore + on E: EInvalidPath do ;// + end; + finally + EndUpdate; + end; +end; + function TCustomShellTreeView.CanExpand(Node: TTreeNode): Boolean; var OldAutoExpand: Boolean;