Add recursive submenu support for node library.
This commit is contained in:
parent
1aeb197b03
commit
3091330420
@ -823,16 +823,20 @@ class FlowchartWidget(dockarea.DockArea):
|
||||
self.buildMenu()
|
||||
|
||||
def buildMenu(self, pos=None):
|
||||
def buildSubMenu(node, rootMenu, subMenus, pos=None):
|
||||
for section, node in node.items():
|
||||
menu = QtGui.QMenu(section)
|
||||
rootMenu.addMenu(menu)
|
||||
if isinstance(node, OrderedDict):
|
||||
buildSubMenu(node, menu, subMenus, pos=pos)
|
||||
subMenus.append(menu)
|
||||
else:
|
||||
act = rootMenu.addAction(section)
|
||||
act.nodeType = section
|
||||
act.pos = pos
|
||||
self.nodeMenu = QtGui.QMenu()
|
||||
self.subMenus = []
|
||||
for section, nodes in self.chart.library.getNodeTree().items():
|
||||
menu = QtGui.QMenu(section)
|
||||
self.nodeMenu.addMenu(menu)
|
||||
for name in nodes:
|
||||
act = menu.addAction(name)
|
||||
act.nodeType = name
|
||||
act.pos = pos
|
||||
self.subMenus.append(menu)
|
||||
self.subMenus = []
|
||||
buildSubMenu(library.getNodeTree(), self.nodeMenu, self.subMenus, pos=pos)
|
||||
self.nodeMenu.triggered.connect(self.nodeMenuTriggered)
|
||||
return self.nodeMenu
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user