##// END OF EJS Templates
Implements visit of graph...
Alexandre Leroux -
r198:946a2291304e
parent child
Show More
@@ -31,6 +31,23 struct MenuBuilder {
31 }
31 }
32
32
33 /**
33 /**
34 * Adds action to the current menu
35 * @param actionName the name of the action
36 * @param actionFunction the function that will be executed when the action is triggered
37 */
38 template <typename ActionFun>
39 void addAction(const QString &actionName, ActionFun actionFunction)
40 {
41 if (auto currMenu = currentMenu()) {
42 currMenu->addAction(actionName, actionFunction);
43 }
44 else {
45 qCCritical(LOG_GenerateVariableMenuOperation())
46 << QObject::tr("No current menu to attach the action");
47 }
48 }
49
50 /**
34 * Adds a new menu to the current menu
51 * Adds a new menu to the current menu
35 * @param name the name of the menu
52 * @param name the name of the menu
36 */
53 */
@@ -81,6 +98,15 struct GenerateVariableMenuOperation::GenerateVariableMenuOperationPrivate {
81 m_MenuBuilder.closeMenu();
98 m_MenuBuilder.closeMenu();
82 }
99 }
83
100
101 template <typename ActionFun>
102 void visitLeaf(const IVisualizationWidget &container, const QString &actionName,
103 ActionFun actionFunction)
104 {
105 if (m_Variable && container.canDrop(*m_Variable)) {
106 m_MenuBuilder.addAction(actionName, actionFunction);
107 }
108 }
109
84 std::shared_ptr<Variable> m_Variable;
110 std::shared_ptr<Variable> m_Variable;
85 MenuBuilder m_MenuBuilder;
111 MenuBuilder m_MenuBuilder;
86 };
112 };
@@ -133,5 +159,9 void GenerateVariableMenuOperation::visitLeave(VisualizationZoneWidget *zoneWidg
133
159
134 void GenerateVariableMenuOperation::visit(VisualizationGraphWidget *graphWidget)
160 void GenerateVariableMenuOperation::visit(VisualizationGraphWidget *graphWidget)
135 {
161 {
136 /// @todo ALX
162 if (graphWidget) {
163 impl->visitLeaf(
164 *graphWidget, QObject::tr("Open in %1").arg(graphWidget->name()),
165 [ var = impl->m_Variable, graphWidget ]() { graphWidget->addVariable(var); });
166 }
137 }
167 }
General Comments 0
You need to be logged in to leave comments. Login now