Skip to content

Commit fbde7d2

Browse files
committed
Add expand all capacity into TreeView class
1 parent 998ad2a commit fbde7d2

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void TreeView::cleanSubEntries(HTREEITEM hTreeItem)
263263
}
264264
}
265265

266-
void TreeView::foldRecursively(HTREEITEM hParentItem) const
266+
void TreeView::foldExpandRecursively(HTREEITEM hParentItem, bool isFold) const
267267
{
268268
if (!hParentItem)
269269
return;
@@ -272,19 +272,33 @@ void TreeView::foldRecursively(HTREEITEM hParentItem) const
272272

273273
for (; hItem != NULL; hItem = getNextSibling(hItem))
274274
{
275-
foldRecursively(hItem);
276-
fold(hItem);
275+
foldExpandRecursively(hItem, isFold);
276+
if (isFold)
277+
{
278+
fold(hItem);
279+
}
280+
else
281+
{
282+
expand(hItem);
283+
}
277284
}
278285
}
279286

280-
void TreeView::foldAll() const
287+
void TreeView::foldExpandAll(bool isFold) const
281288
{
282289
for (HTREEITEM tvProj = getRoot();
283290
tvProj != NULL;
284291
tvProj = getNextSibling(tvProj))
285292
{
286-
foldRecursively(tvProj);
287-
fold(tvProj);
293+
foldExpandRecursively(tvProj, isFold);
294+
if (isFold)
295+
{
296+
fold(tvProj);
297+
}
298+
else
299+
{
300+
expand(tvProj);
301+
}
288302
}
289303
}
290304

PowerEditor/src/WinControls/ProjectPanel/TreeView.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,16 @@ class TreeView : public Window {
8888
TreeView_Expand(_hSelf, hItem, TVE_COLLAPSE);
8989
};
9090

91-
void foldRecursively(HTREEITEM hItem) const;
92-
void foldAll() const;
91+
void foldExpandRecursively(HTREEITEM hItem, bool isFold) const;
92+
void foldExpandAll(bool isFold) const;
93+
94+
void foldAll() const {
95+
foldExpandAll(true);
96+
};
97+
98+
void expandAll() const {
99+
foldExpandAll(false);
100+
};
93101

94102
void toggleExpandCollapse(HTREEITEM hItem) const {
95103
TreeView_Expand(_hSelf, hItem, TVE_TOGGLE);

0 commit comments

Comments
 (0)