@@ -189,9 +189,11 MainWindow::MainWindow(QWidget *parent) | |||
|
189 | 189 | // potentially attach a menu to the variable's menu to do so before this menu is displayed. |
|
190 | 190 | // The order of connections is also important, since it determines the order in which each |
|
191 | 191 | // widget will attach its menu |
|
192 | connect(m_Ui->variableInspectorWidget, | |
|
193 | SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, std::shared_ptr<Variable>)), m_Ui->view, | |
|
194 | SLOT(attachVariableMenu(QMenu *, std::shared_ptr<Variable>)), Qt::DirectConnection); | |
|
192 | connect( | |
|
193 | m_Ui->variableInspectorWidget, | |
|
194 | SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)), | |
|
195 | m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)), | |
|
196 | Qt::DirectConnection); | |
|
195 | 197 | |
|
196 | 198 | /* QLopGUI::registerMenuBar(menuBar()); |
|
197 | 199 | this->setWindowIcon(QIcon(":/sciqlopLOGO.svg")); |
@@ -29,14 +29,15 public: | |||
|
29 | 29 | |
|
30 | 30 | signals: |
|
31 | 31 | /** |
|
32 |
* Signal emitted before a menu concerning |
|
|
32 | * Signal emitted before a menu concerning variables is displayed. It is used for other widgets | |
|
33 | 33 | * to complete the menu. |
|
34 | 34 | * @param tableMenu the menu to be completed |
|
35 | * @param variable the variable concerned by the menu | |
|
35 | * @param variables the variables concerned by the menu | |
|
36 | 36 | * @remarks To make the dynamic addition of menus work, the connections to this signal must be |
|
37 | 37 | * in Qt :: DirectConnection |
|
38 | 38 | */ |
|
39 |
void tableMenuAboutToBeDisplayed(QMenu *tableMenu, |
|
|
39 | void tableMenuAboutToBeDisplayed(QMenu *tableMenu, | |
|
40 | const QVector<std::shared_ptr<Variable> > &variables); | |
|
40 | 41 | |
|
41 | 42 | private: |
|
42 | 43 | Ui::VariableInspectorWidget *ui; |
@@ -30,11 +30,12 public: | |||
|
30 | 30 | |
|
31 | 31 | public slots: |
|
32 | 32 | /** |
|
33 |
* Attaches to a menu the menu relati |
|
|
33 | * Attaches to a menu the menu relative to the visualization of variables | |
|
34 | 34 | * @param menu the parent menu of the generated menu |
|
35 | * @param variable the variable for which to generate the menu | |
|
35 | * @param variables the variables for which to generate the menu | |
|
36 | 36 | */ |
|
37 |
void attachVariableMenu(QMenu *menu, |
|
|
37 | void attachVariableMenu(QMenu *menu, | |
|
38 | const QVector<std::shared_ptr<Variable> > &variables) noexcept; | |
|
38 | 39 | |
|
39 | 40 | private: |
|
40 | 41 | Ui::VisualizationWidget *ui; |
@@ -60,7 +60,6 void VariableInspectorWidget::onTableMenuRequested(const QPoint &pos) noexcept | |||
|
60 | 60 | QMenu tableMenu{}; |
|
61 | 61 | |
|
62 | 62 | // Emits a signal so that potential receivers can populate the menu before displaying it |
|
63 | /// @todo ALX : handles list of variables in the signal | |
|
64 | 63 | emit tableMenuAboutToBeDisplayed(&tableMenu, selectedVariables); |
|
65 | 64 | |
|
66 | 65 | if (!tableMenu.isEmpty()) { |
@@ -106,10 +106,24 QString VisualizationWidget::name() const | |||
|
106 | 106 | return QStringLiteral("MainView"); |
|
107 | 107 | } |
|
108 | 108 | |
|
109 |
void VisualizationWidget::attachVariableMenu( |
|
|
110 |
|
|
|
109 | void VisualizationWidget::attachVariableMenu( | |
|
110 | QMenu *menu, const QVector<std::shared_ptr<Variable> > &variables) noexcept | |
|
111 | 111 | { |
|
112 | // Menu is generated only if there is a single variable | |
|
113 | if (variables.size() == 1) { | |
|
114 | if (auto variable = variables.first()) { | |
|
112 | 115 | // Generates the actions that make it possible to visualize the variable |
|
113 | 116 | auto generateVariableMenuOperation = GenerateVariableMenuOperation{menu, variable}; |
|
114 | 117 | accept(&generateVariableMenuOperation); |
|
115 | 118 | } |
|
119 | else { | |
|
120 | qCCritical(LOG_VisualizationWidget()) << tr( | |
|
121 | "Can't generate the menu relative to the visualization: the variable is null"); | |
|
122 | } | |
|
123 | } | |
|
124 | else { | |
|
125 | qCDebug(LOG_VisualizationWidget()) | |
|
126 | << tr("No generation of the menu related to the visualization: several variables are " | |
|
127 | "selected"); | |
|
128 | } | |
|
129 | } |
General Comments 0
You need to be logged in to leave comments.
Login now