From fbde7d21884b1e431e031329b072d7ff0e6b2255 Mon Sep 17 00:00:00 2001 From: Don HO Date: Wed, 18 Dec 2019 13:41:13 +0100 Subject: [PATCH] Add expand all capacity into TreeView class --- .../src/WinControls/ProjectPanel/TreeView.cpp | 26 ++++++++++++++----- .../src/WinControls/ProjectPanel/TreeView.h | 12 +++++++-- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp b/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp index f4b47dd2..a89b19f5 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp +++ b/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp @@ -263,7 +263,7 @@ void TreeView::cleanSubEntries(HTREEITEM hTreeItem) } } -void TreeView::foldRecursively(HTREEITEM hParentItem) const +void TreeView::foldExpandRecursively(HTREEITEM hParentItem, bool isFold) const { if (!hParentItem) return; @@ -272,19 +272,33 @@ void TreeView::foldRecursively(HTREEITEM hParentItem) const for (; hItem != NULL; hItem = getNextSibling(hItem)) { - foldRecursively(hItem); - fold(hItem); + foldExpandRecursively(hItem, isFold); + if (isFold) + { + fold(hItem); + } + else + { + expand(hItem); + } } } -void TreeView::foldAll() const +void TreeView::foldExpandAll(bool isFold) const { for (HTREEITEM tvProj = getRoot(); tvProj != NULL; tvProj = getNextSibling(tvProj)) { - foldRecursively(tvProj); - fold(tvProj); + foldExpandRecursively(tvProj, isFold); + if (isFold) + { + fold(tvProj); + } + else + { + expand(tvProj); + } } } diff --git a/PowerEditor/src/WinControls/ProjectPanel/TreeView.h b/PowerEditor/src/WinControls/ProjectPanel/TreeView.h index 44e75516..e4be4a4e 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/TreeView.h +++ b/PowerEditor/src/WinControls/ProjectPanel/TreeView.h @@ -88,8 +88,16 @@ public: TreeView_Expand(_hSelf, hItem, TVE_COLLAPSE); }; - void foldRecursively(HTREEITEM hItem) const; - void foldAll() const; + void foldExpandRecursively(HTREEITEM hItem, bool isFold) const; + void foldExpandAll(bool isFold) const; + + void foldAll() const { + foldExpandAll(true); + }; + + void expandAll() const { + foldExpandAll(false); + }; void toggleExpandCollapse(HTREEITEM hItem) const { TreeView_Expand(_hSelf, hItem, TVE_TOGGLE);