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()
|
self.buildMenu()
|
||||||
|
|
||||||
def buildMenu(self, pos=None):
|
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.nodeMenu = QtGui.QMenu()
|
||||||
self.subMenus = []
|
self.subMenus = []
|
||||||
for section, nodes in self.chart.library.getNodeTree().items():
|
buildSubMenu(library.getNodeTree(), self.nodeMenu, self.subMenus, pos=pos)
|
||||||
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.nodeMenu.triggered.connect(self.nodeMenuTriggered)
|
self.nodeMenu.triggered.connect(self.nodeMenuTriggered)
|
||||||
return self.nodeMenu
|
return self.nodeMenu
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user