Add expand all capacity into TreeView class

This commit is contained in:
Don HO 2019-12-18 13:41:13 +01:00
parent 998ad2aa87
commit fbde7d2188
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
2 changed files with 30 additions and 8 deletions

View File

@ -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);
}
}
}

View File

@ -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);