##// END OF EJS Templates
Completes visit of tab and zone...
Alexandre Leroux -
r199:aa91a995c6e9
parent child
Show More
@@ -62,6 +62,21 struct MenuBuilder {
62 }
62 }
63 }
63 }
64
64
65 /// Adds a separator to the current menu. The separator is added only if the menu already
66 /// contains entries
67 void addSeparator()
68 {
69 if (auto currMenu = currentMenu()) {
70 if (!currMenu->isEmpty()) {
71 currMenu->addSeparator();
72 }
73 }
74 else {
75 qCCritical(LOG_GenerateVariableMenuOperation())
76 << QObject::tr("No current menu to attach the separator");
77 }
78 }
79
65 /// Closes the current menu
80 /// Closes the current menu
66 void closeMenu()
81 void closeMenu()
67 {
82 {
@@ -92,8 +107,14 struct GenerateVariableMenuOperation::GenerateVariableMenuOperationPrivate {
92 }
107 }
93
108
94 template <typename ActionFun>
109 template <typename ActionFun>
95 void visitNodeLeave()
110 void visitNodeLeave(const IVisualizationWidget &container, const QString &actionName,
111 ActionFun actionFunction)
96 {
112 {
113 if (m_Variable && container.canDrop(*m_Variable)) {
114 m_MenuBuilder.addSeparator();
115 m_MenuBuilder.addAction(actionName, actionFunction);
116 }
117
97 // Closes the menu associated to the node
118 // Closes the menu associated to the node
98 m_MenuBuilder.closeMenu();
119 m_MenuBuilder.closeMenu();
99 }
120 }
@@ -139,7 +160,9 void GenerateVariableMenuOperation::visitEnter(VisualizationTabWidget *tabWidget
139 void GenerateVariableMenuOperation::visitLeave(VisualizationTabWidget *tabWidget)
160 void GenerateVariableMenuOperation::visitLeave(VisualizationTabWidget *tabWidget)
140 {
161 {
141 if (tabWidget) {
162 if (tabWidget) {
142 impl->visitNodeLeave();
163 impl->visitNodeLeave(
164 *tabWidget, QObject::tr("Open in a new zone"),
165 [ var = impl->m_Variable, tabWidget ]() { tabWidget->createZone(var); });
143 }
166 }
144 }
167 }
145
168
@@ -153,7 +176,9 void GenerateVariableMenuOperation::visitEnter(VisualizationZoneWidget *zoneWidg
153 void GenerateVariableMenuOperation::visitLeave(VisualizationZoneWidget *zoneWidget)
176 void GenerateVariableMenuOperation::visitLeave(VisualizationZoneWidget *zoneWidget)
154 {
177 {
155 if (zoneWidget) {
178 if (zoneWidget) {
156 impl->visitNodeLeave();
179 impl->visitNodeLeave(
180 *zoneWidget, QObject::tr("Open in a new graph"),
181 [ var = impl->m_Variable, zoneWidget ]() { zoneWidget->createGraph(var); });
157 }
182 }
158 }
183 }
159
184
General Comments 0
You need to be logged in to leave comments. Login now