Changed: Expand/collapse all tree node childs with right click

--HG--
branch : develop
This commit is contained in:
Nimetu 2017-10-02 13:52:44 +03:00
parent 575f58d749
commit 6b7617f8e1
2 changed files with 19 additions and 1 deletions

View file

@ -97,6 +97,7 @@ namespace NLGUI
void addChildSortedByBitmap(SNode *pNode); void addChildSortedByBitmap(SNode *pNode);
void setParentTree(CGroupTree *parent); void setParentTree(CGroupTree *parent);
void setFather(SNode *father); void setFather(SNode *father);
void openAll();
void closeAll(); void closeAll();
void makeOrphan(); void makeOrphan();
bool parse (xmlNodePtr cur, CGroupTree *parentGroup); bool parse (xmlNodePtr cur, CGroupTree *parentGroup);

View file

@ -271,6 +271,14 @@ namespace NLGUI
pNode->setFather(this); pNode->setFather(this);
} }
// ----------------------------------------------------------------------------
void CGroupTree::SNode::openAll()
{
Opened = true;
for (uint i = 0; i < Children.size(); ++i)
Children[i]->openAll();
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CGroupTree::SNode::closeAll() void CGroupTree::SNode::closeAll()
{ {
@ -1082,7 +1090,9 @@ namespace NLGUI
} }
} }
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) bool toggleOne = (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown);
bool toggleAll = (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown);
if (toggleOne || toggleAll)
{ {
// line selection // line selection
if (bText) if (bText)
@ -1118,6 +1128,13 @@ namespace NLGUI
{ {
// open/close the node // open/close the node
changedNode->Opened = !changedNode->Opened; changedNode->Opened = !changedNode->Opened;
if (toggleAll)
{
if (changedNode->Opened)
changedNode->openAll();
else
changedNode->closeAll();
}
} }
// else must close all necessary nodes. // else must close all necessary nodes.
else else