##// END OF EJS Templates
Temporal parameters of the selected variables can be updated using the...
perrinel -
r281:08349e12a7ef
parent child
Show More
@@ -1,256 +1,261
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SciQLop Software
2 -- This file is a part of the SciQLop Software
3 -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "MainWindow.h"
22 #include "MainWindow.h"
23 #include "ui_MainWindow.h"
23 #include "ui_MainWindow.h"
24
24
25 #include <DataSource/DataSourceController.h>
25 #include <DataSource/DataSourceController.h>
26 #include <DataSource/DataSourceWidget.h>
26 #include <DataSource/DataSourceWidget.h>
27 #include <SidePane/SqpSidePane.h>
27 #include <SidePane/SqpSidePane.h>
28 #include <SqpApplication.h>
28 #include <SqpApplication.h>
29 #include <Time/TimeController.h>
29 #include <Time/TimeController.h>
30 #include <TimeWidget/TimeWidget.h>
30 #include <TimeWidget/TimeWidget.h>
31 #include <Variable/Variable.h>
31 #include <Variable/Variable.h>
32 #include <Variable/VariableController.h>
32 #include <Visualization/VisualizationController.h>
33 #include <Visualization/VisualizationController.h>
33
34
34 #include <QAction>
35 #include <QAction>
35 #include <QDate>
36 #include <QDate>
36 #include <QDateTime>
37 #include <QDateTime>
37 #include <QDir>
38 #include <QDir>
38 #include <QFileDialog>
39 #include <QFileDialog>
39 #include <QToolBar>
40 #include <QToolBar>
40 #include <QToolButton>
41 #include <QToolButton>
41 #include <memory.h>
42 #include <memory.h>
42
43
43 //#include <omp.h>
44 //#include <omp.h>
44 //#include <network/filedownloader.h>
45 //#include <network/filedownloader.h>
45 //#include <qlopdatabase.h>
46 //#include <qlopdatabase.h>
46 //#include <qlopsettings.h>
47 //#include <qlopsettings.h>
47 //#include <qlopgui.h>
48 //#include <qlopgui.h>
48 //#include <spacedata.h>
49 //#include <spacedata.h>
49 //#include "qlopcore.h"
50 //#include "qlopcore.h"
50 //#include "qlopcodecmanager.h"
51 //#include "qlopcodecmanager.h"
51 //#include "cdfcodec.h"
52 //#include "cdfcodec.h"
52 //#include "amdatxtcodec.h"
53 //#include "amdatxtcodec.h"
53 //#include <qlopplotmanager.h>
54 //#include <qlopplotmanager.h>
54
55
55 #include "iostream"
56 #include "iostream"
56
57
57 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
58 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
58
59
59 namespace {
60 namespace {
60 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
61 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
61 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
62 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
62 const auto VIEWPLITTERINDEX = 2;
63 const auto VIEWPLITTERINDEX = 2;
63 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
64 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
64 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
65 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
65 }
66 }
66
67
67 class MainWindow::MainWindowPrivate {
68 class MainWindow::MainWindowPrivate {
68 public:
69 public:
69 QSize m_LastOpenLeftInspectorSize;
70 QSize m_LastOpenLeftInspectorSize;
70 QSize m_LastOpenRightInspectorSize;
71 QSize m_LastOpenRightInspectorSize;
71 };
72 };
72
73
73 MainWindow::MainWindow(QWidget *parent)
74 MainWindow::MainWindow(QWidget *parent)
74 : QMainWindow{parent},
75 : QMainWindow{parent},
75 m_Ui{new Ui::MainWindow},
76 m_Ui{new Ui::MainWindow},
76 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
77 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
77 {
78 {
78 m_Ui->setupUi(this);
79 m_Ui->setupUi(this);
79
80
80 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
81 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
81 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
82 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
82
83
83
84
84 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
85 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
85 auto openLeftInspectorAction = new QAction{QIcon{
86 auto openLeftInspectorAction = new QAction{QIcon{
86 ":/icones/previous.png",
87 ":/icones/previous.png",
87 },
88 },
88 tr("Show/hide the left inspector"), this};
89 tr("Show/hide the left inspector"), this};
89
90
90
91
91 auto spacerLeftTop = new QWidget{};
92 auto spacerLeftTop = new QWidget{};
92 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
93 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
93
94
94 auto spacerLeftBottom = new QWidget{};
95 auto spacerLeftBottom = new QWidget{};
95 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
96 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
96
97
97 leftSidePane->addWidget(spacerLeftTop);
98 leftSidePane->addWidget(spacerLeftTop);
98 leftSidePane->addAction(openLeftInspectorAction);
99 leftSidePane->addAction(openLeftInspectorAction);
99 leftSidePane->addWidget(spacerLeftBottom);
100 leftSidePane->addWidget(spacerLeftBottom);
100
101
101
102
102 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
103 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
103 auto openRightInspectorAction = new QAction{QIcon{
104 auto openRightInspectorAction = new QAction{QIcon{
104 ":/icones/next.png",
105 ":/icones/next.png",
105 },
106 },
106 tr("Show/hide the right inspector"), this};
107 tr("Show/hide the right inspector"), this};
107
108
108 auto spacerRightTop = new QWidget{};
109 auto spacerRightTop = new QWidget{};
109 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
110 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
110
111
111 auto spacerRightBottom = new QWidget{};
112 auto spacerRightBottom = new QWidget{};
112 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
113 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
113
114
114 rightSidePane->addWidget(spacerRightTop);
115 rightSidePane->addWidget(spacerRightTop);
115 rightSidePane->addAction(openRightInspectorAction);
116 rightSidePane->addAction(openRightInspectorAction);
116 rightSidePane->addWidget(spacerRightBottom);
117 rightSidePane->addWidget(spacerRightBottom);
117
118
118 openLeftInspectorAction->setCheckable(true);
119 openLeftInspectorAction->setCheckable(true);
119 openRightInspectorAction->setCheckable(true);
120 openRightInspectorAction->setCheckable(true);
120
121
121 auto openInspector = [this](bool checked, bool right, auto action) {
122 auto openInspector = [this](bool checked, bool right, auto action) {
122
123
123 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
124 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
124
125
125 auto &lastInspectorSize
126 auto &lastInspectorSize
126 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
127 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
127
128
128 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
129 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
129 : m_Ui->leftMainInspectorWidget->size();
130 : m_Ui->leftMainInspectorWidget->size();
130
131
131 // Update of the last opened geometry
132 // Update of the last opened geometry
132 if (checked) {
133 if (checked) {
133 lastInspectorSize = nextInspectorSize;
134 lastInspectorSize = nextInspectorSize;
134 }
135 }
135
136
136 auto startSize = lastInspectorSize;
137 auto startSize = lastInspectorSize;
137 auto endSize = startSize;
138 auto endSize = startSize;
138 endSize.setWidth(0);
139 endSize.setWidth(0);
139
140
140 auto splitterInspectorIndex
141 auto splitterInspectorIndex
141 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
142 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
142
143
143 auto currentSizes = m_Ui->splitter->sizes();
144 auto currentSizes = m_Ui->splitter->sizes();
144 if (checked) {
145 if (checked) {
145 // adjust sizes individually here, e.g.
146 // adjust sizes individually here, e.g.
146 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
147 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
147 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
148 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
148 m_Ui->splitter->setSizes(currentSizes);
149 m_Ui->splitter->setSizes(currentSizes);
149 }
150 }
150 else {
151 else {
151 // adjust sizes individually here, e.g.
152 // adjust sizes individually here, e.g.
152 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
153 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
153 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
154 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
154 m_Ui->splitter->setSizes(currentSizes);
155 m_Ui->splitter->setSizes(currentSizes);
155 }
156 }
156
157
157 };
158 };
158
159
159
160
160 connect(openLeftInspectorAction, &QAction::triggered,
161 connect(openLeftInspectorAction, &QAction::triggered,
161 [openInspector, openLeftInspectorAction](bool checked) {
162 [openInspector, openLeftInspectorAction](bool checked) {
162 openInspector(checked, false, openLeftInspectorAction);
163 openInspector(checked, false, openLeftInspectorAction);
163 });
164 });
164 connect(openRightInspectorAction, &QAction::triggered,
165 connect(openRightInspectorAction, &QAction::triggered,
165 [openInspector, openRightInspectorAction](bool checked) {
166 [openInspector, openRightInspectorAction](bool checked) {
166 openInspector(checked, true, openRightInspectorAction);
167 openInspector(checked, true, openRightInspectorAction);
167 });
168 });
168
169
169 this->menuBar()->addAction(tr("File"));
170 this->menuBar()->addAction(tr("File"));
170 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
171 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
171
172
172 auto timeWidget = new TimeWidget{};
173 auto timeWidget = new TimeWidget{};
173 mainToolBar->addWidget(timeWidget);
174 mainToolBar->addWidget(timeWidget);
174
175
175 // Widgets / controllers connections
176 // Widgets / controllers connections
176
177
177 // DataSource
178 // DataSource
178 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
179 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
179 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
180 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
180
181
181 // Time
182 // Time
182 connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(),
183 connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(),
183 SLOT(onTimeToUpdate(SqpDateTime)));
184 SLOT(onTimeToUpdate(SqpDateTime)));
184
185
186 qRegisterMetaType<SqpDateTime>();
187 connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpDateTime)),
188 &sqpApp->variableController(), SLOT(onDateTimeOnSelection(SqpDateTime)));
189
185 // Widgets / widgets connections
190 // Widgets / widgets connections
186 qRegisterMetaType<std::shared_ptr<Variable> >();
191 qRegisterMetaType<std::shared_ptr<Variable> >();
187
192
188 // For the following connections, we use DirectConnection to allow each widget that can
193 // For the following connections, we use DirectConnection to allow each widget that can
189 // potentially attach a menu to the variable's menu to do so before this menu is displayed.
194 // potentially attach a menu to the variable's menu to do so before this menu is displayed.
190 // The order of connections is also important, since it determines the order in which each
195 // The order of connections is also important, since it determines the order in which each
191 // widget will attach its menu
196 // widget will attach its menu
192 connect(
197 connect(
193 m_Ui->variableInspectorWidget,
198 m_Ui->variableInspectorWidget,
194 SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
199 SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
195 m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
200 m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
196 Qt::DirectConnection);
201 Qt::DirectConnection);
197
202
198 /* QLopGUI::registerMenuBar(menuBar());
203 /* QLopGUI::registerMenuBar(menuBar());
199 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
204 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
200 this->m_progressWidget = new QWidget();
205 this->m_progressWidget = new QWidget();
201 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
206 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
202 this->m_progressWidget->setLayout(this->m_progressLayout);
207 this->m_progressWidget->setLayout(this->m_progressLayout);
203 this->m_progressWidget->setWindowModality(Qt::WindowModal);
208 this->m_progressWidget->setWindowModality(Qt::WindowModal);
204 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
209 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
205 for(int i=0;i<OMP_THREADS;i++)
210 for(int i=0;i<OMP_THREADS;i++)
206 {
211 {
207 this->m_progress.append(new QProgressBar(this->m_progressWidget));
212 this->m_progress.append(new QProgressBar(this->m_progressWidget));
208 this->m_progress.last()->setMinimum(0);
213 this->m_progress.last()->setMinimum(0);
209 this->m_progress.last()->setMaximum(100);
214 this->m_progress.last()->setMaximum(100);
210 this->m_progressLayout->addWidget(this->m_progress.last());
215 this->m_progressLayout->addWidget(this->m_progress.last());
211 this->m_progressWidget->hide();
216 this->m_progressWidget->hide();
212 this->m_progressThreadIds[i] = -1;
217 this->m_progressThreadIds[i] = -1;
213 }
218 }
214 this->m_progressWidget->setWindowTitle("Loading File");
219 this->m_progressWidget->setWindowTitle("Loading File");
215 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
220 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
216 << QLopCore::self()
221 << QLopCore::self()
217 << QLopPlotManager::self()
222 << QLopPlotManager::self()
218 << QLopCodecManager::self()
223 << QLopCodecManager::self()
219 << FileDownloader::self()
224 << FileDownloader::self()
220 << QLopDataBase::self()
225 << QLopDataBase::self()
221 << SpaceData::self();
226 << SpaceData::self();
222
227
223 CDFCodec::registerToManager();
228 CDFCodec::registerToManager();
224 AMDATXTCodec::registerToManager();
229 AMDATXTCodec::registerToManager();
225
230
226
231
227 for(int i=0;i<ServicesToLoad.count();i++)
232 for(int i=0;i<ServicesToLoad.count();i++)
228 {
233 {
229 qDebug()<<ServicesToLoad.at(i)->serviceName();
234 qDebug()<<ServicesToLoad.at(i)->serviceName();
230 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
235 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
231 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
236 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
232 if(wdgt)
237 if(wdgt)
233 {
238 {
234 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
239 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
235 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
240 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
236 }
241 }
237 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
242 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
238 }*/
243 }*/
239 }
244 }
240
245
241 MainWindow::~MainWindow()
246 MainWindow::~MainWindow()
242 {
247 {
243 }
248 }
244
249
245
250
246 void MainWindow::changeEvent(QEvent *e)
251 void MainWindow::changeEvent(QEvent *e)
247 {
252 {
248 QMainWindow::changeEvent(e);
253 QMainWindow::changeEvent(e);
249 switch (e->type()) {
254 switch (e->type()) {
250 case QEvent::LanguageChange:
255 case QEvent::LanguageChange:
251 m_Ui->retranslateUi(this);
256 m_Ui->retranslateUi(this);
252 break;
257 break;
253 default:
258 default:
254 break;
259 break;
255 }
260 }
256 }
261 }
@@ -1,56 +1,55
1 #ifndef SCIQLOP_VARIABLE_H
1 #ifndef SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
3
3
4 #include <Data/SqpDateTime.h>
4 #include <Data/SqpDateTime.h>
5
5
6
6
7 #include <QLoggingCategory>
7 #include <QLoggingCategory>
8 #include <QObject>
8 #include <QObject>
9
9
10 #include <Common/spimpl.h>
10 #include <Common/spimpl.h>
11
11
12 Q_DECLARE_LOGGING_CATEGORY(LOG_Variable)
12 Q_DECLARE_LOGGING_CATEGORY(LOG_Variable)
13
13
14 class IDataSeries;
14 class IDataSeries;
15 class QString;
15 class QString;
16
16
17 /**
17 /**
18 * @brief The Variable class represents a variable in SciQlop.
18 * @brief The Variable class represents a variable in SciQlop.
19 */
19 */
20 class Variable : public QObject {
20 class Variable : public QObject {
21
21
22 Q_OBJECT
22 Q_OBJECT
23
23
24 public:
24 public:
25 explicit Variable(const QString &name, const QString &unit, const QString &mission,
25 explicit Variable(const QString &name, const QString &unit, const QString &mission,
26 const SqpDateTime &dateTime);
26 const SqpDateTime &dateTime);
27
27
28 QString name() const noexcept;
28 QString name() const noexcept;
29 QString mission() const noexcept;
29 QString mission() const noexcept;
30 QString unit() const noexcept;
30 QString unit() const noexcept;
31 SqpDateTime dateTime() const noexcept;
31 SqpDateTime dateTime() const noexcept;
32 void setDateTime(const SqpDateTime &dateTime) noexcept;
32 void setDateTime(const SqpDateTime &dateTime) noexcept;
33
33
34 /// @return the data of the variable, nullptr if there is no data
34 /// @return the data of the variable, nullptr if there is no data
35 IDataSeries *dataSeries() const noexcept;
35 IDataSeries *dataSeries() const noexcept;
36
36
37 bool contains(const SqpDateTime &dateTime);
37 bool contains(const SqpDateTime &dateTime);
38 bool intersect(const SqpDateTime &dateTime);
38 bool intersect(const SqpDateTime &dateTime);
39 void setDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept;
39 void setDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept;
40
40
41 public slots:
41 public slots:
42 void onAddDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept;
42 void onAddDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept;
43
43
44 signals:
44 signals:
45 void updated();
45 void updated();
46
46
47
48 private:
47 private:
49 class VariablePrivate;
48 class VariablePrivate;
50 spimpl::unique_impl_ptr<VariablePrivate> impl;
49 spimpl::unique_impl_ptr<VariablePrivate> impl;
51 };
50 };
52
51
53 // Required for using shared_ptr in signals/slots
52 // Required for using shared_ptr in signals/slots
54 Q_DECLARE_METATYPE(std::shared_ptr<Variable>)
53 Q_DECLARE_METATYPE(std::shared_ptr<Variable>)
55
54
56 #endif // SCIQLOP_VARIABLE_H
55 #endif // SCIQLOP_VARIABLE_H
@@ -1,57 +1,61
1 #ifndef SCIQLOP_VARIABLECONTROLLER_H
1 #ifndef SCIQLOP_VARIABLECONTROLLER_H
2 #define SCIQLOP_VARIABLECONTROLLER_H
2 #define SCIQLOP_VARIABLECONTROLLER_H
3
3
4 #include <Data/SqpDateTime.h>
4 #include <Data/SqpDateTime.h>
5
5
6 #include <QLoggingCategory>
6 #include <QLoggingCategory>
7 #include <QObject>
7 #include <QObject>
8
8
9 #include <Common/spimpl.h>
9 #include <Common/spimpl.h>
10
10
11
12 class IDataProvider;
11 class IDataProvider;
12 class QItemSelectionModel;
13 class TimeController;
13 class TimeController;
14 class Variable;
14 class Variable;
15 class VariableModel;
15 class VariableModel;
16
16
17 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableController)
17 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableController)
18
18
19 /**
19 /**
20 * @brief The VariableController class aims to handle the variables in SciQlop.
20 * @brief The VariableController class aims to handle the variables in SciQlop.
21 */
21 */
22 class VariableController : public QObject {
22 class VariableController : public QObject {
23 Q_OBJECT
23 Q_OBJECT
24 public:
24 public:
25 explicit VariableController(QObject *parent = 0);
25 explicit VariableController(QObject *parent = 0);
26 virtual ~VariableController();
26 virtual ~VariableController();
27
27
28 VariableModel *variableModel() noexcept;
28 VariableModel *variableModel() noexcept;
29 QItemSelectionModel *variableSelectionModel() noexcept;
29
30
30 void setTimeController(TimeController *timeController) noexcept;
31 void setTimeController(TimeController *timeController) noexcept;
31
32
32
33
33 signals:
34 signals:
34 /// Signal emitted when a variable has been created
35 /// Signal emitted when a variable has been created
35 void variableCreated(std::shared_ptr<Variable> variable);
36 void variableCreated(std::shared_ptr<Variable> variable);
36
37
37 public slots:
38 public slots:
38 /// Request the data loading of the variable whithin dateTime
39 /// Request the data loading of the variable whithin dateTime
39 void onRequestDataLoading(std::shared_ptr<Variable> variable, const SqpDateTime &dateTime);
40 void onRequestDataLoading(std::shared_ptr<Variable> variable, const SqpDateTime &dateTime);
40 /**
41 /**
41 * Creates a new variable and adds it to the model
42 * Creates a new variable and adds it to the model
42 * @param name the name of the new variable
43 * @param name the name of the new variable
43 * @param provider the data provider for the new variable
44 * @param provider the data provider for the new variable
44 */
45 */
45 void createVariable(const QString &name, std::shared_ptr<IDataProvider> provider) noexcept;
46 void createVariable(const QString &name, std::shared_ptr<IDataProvider> provider) noexcept;
46
47
48 /// Update the temporal parameters of every selected variable to dateTime
49 void onDateTimeOnSelection(const SqpDateTime &dateTime);
50
47 void initialize();
51 void initialize();
48 void finalize();
52 void finalize();
49
53
50 private:
54 private:
51 void waitForFinish();
55 void waitForFinish();
52
56
53 class VariableControllerPrivate;
57 class VariableControllerPrivate;
54 spimpl::unique_impl_ptr<VariableControllerPrivate> impl;
58 spimpl::unique_impl_ptr<VariableControllerPrivate> impl;
55 };
59 };
56
60
57 #endif // SCIQLOP_VARIABLECONTROLLER_H
61 #endif // SCIQLOP_VARIABLECONTROLLER_H
@@ -1,157 +1,176
1 #include <Variable/Variable.h>
1 #include <Variable/Variable.h>
2 #include <Variable/VariableCacheController.h>
2 #include <Variable/VariableCacheController.h>
3 #include <Variable/VariableController.h>
3 #include <Variable/VariableController.h>
4 #include <Variable/VariableModel.h>
4 #include <Variable/VariableModel.h>
5
5
6 #include <Data/DataProviderParameters.h>
6 #include <Data/DataProviderParameters.h>
7 #include <Data/IDataProvider.h>
7 #include <Data/IDataProvider.h>
8 #include <Data/IDataSeries.h>
8 #include <Data/IDataSeries.h>
9 #include <Time/TimeController.h>
9 #include <Time/TimeController.h>
10
10
11 #include <QDateTime>
11 #include <QDateTime>
12 #include <QMutex>
12 #include <QMutex>
13 #include <QThread>
13 #include <QThread>
14 #include <QtCore/QItemSelectionModel>
14
15
15 #include <unordered_map>
16 #include <unordered_map>
16
17
17 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
18 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
18
19
19 namespace {
20 namespace {
20
21
21 /// @todo Generates default dataseries, according to the provider passed in parameter. This method
22 /// @todo Generates default dataseries, according to the provider passed in parameter. This method
22 /// will be deleted when the timerange is recovered from SciQlop
23 /// will be deleted when the timerange is recovered from SciQlop
23 std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider,
24 std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider,
24 const SqpDateTime &dateTime) noexcept
25 const SqpDateTime &dateTime) noexcept
25 {
26 {
26 auto parameters = DataProviderParameters{dateTime};
27 auto parameters = DataProviderParameters{dateTime};
27
28
28 return provider.retrieveData(parameters);
29 return provider.retrieveData(parameters);
29 }
30 }
30
31
31 } // namespace
32 } // namespace
32
33
33 struct VariableController::VariableControllerPrivate {
34 struct VariableController::VariableControllerPrivate {
34 explicit VariableControllerPrivate(VariableController *parent)
35 explicit VariableControllerPrivate(VariableController *parent)
35 : m_WorkingMutex{},
36 : m_WorkingMutex{},
36 m_VariableModel{new VariableModel{parent}},
37 m_VariableModel{new VariableModel{parent}},
38 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
37 m_VariableCacheController{std::make_unique<VariableCacheController>()}
39 m_VariableCacheController{std::make_unique<VariableCacheController>()}
38 {
40 {
39 }
41 }
40
42
41 QMutex m_WorkingMutex;
43 QMutex m_WorkingMutex;
42 /// Variable model. The VariableController has the ownership
44 /// Variable model. The VariableController has the ownership
43 VariableModel *m_VariableModel;
45 VariableModel *m_VariableModel;
46 QItemSelectionModel *m_VariableSelectionModel;
44
47
45
48
46 TimeController *m_TimeController{nullptr};
49 TimeController *m_TimeController{nullptr};
47 std::unique_ptr<VariableCacheController> m_VariableCacheController;
50 std::unique_ptr<VariableCacheController> m_VariableCacheController;
48
51
49 std::unordered_map<std::shared_ptr<Variable>, std::shared_ptr<IDataProvider> >
52 std::unordered_map<std::shared_ptr<Variable>, std::shared_ptr<IDataProvider> >
50 m_VariableToProviderMap;
53 m_VariableToProviderMap;
51 };
54 };
52
55
53 VariableController::VariableController(QObject *parent)
56 VariableController::VariableController(QObject *parent)
54 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
57 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
55 {
58 {
56 qCDebug(LOG_VariableController()) << tr("VariableController construction")
59 qCDebug(LOG_VariableController()) << tr("VariableController construction")
57 << QThread::currentThread();
60 << QThread::currentThread();
58 }
61 }
59
62
60 VariableController::~VariableController()
63 VariableController::~VariableController()
61 {
64 {
62 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
65 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
63 << QThread::currentThread();
66 << QThread::currentThread();
64 this->waitForFinish();
67 this->waitForFinish();
65 }
68 }
66
69
67 VariableModel *VariableController::variableModel() noexcept
70 VariableModel *VariableController::variableModel() noexcept
68 {
71 {
69 return impl->m_VariableModel;
72 return impl->m_VariableModel;
70 }
73 }
71
74
75 QItemSelectionModel *VariableController::variableSelectionModel() noexcept
76 {
77 return impl->m_VariableSelectionModel;
78 }
79
72 void VariableController::setTimeController(TimeController *timeController) noexcept
80 void VariableController::setTimeController(TimeController *timeController) noexcept
73 {
81 {
74 impl->m_TimeController = timeController;
82 impl->m_TimeController = timeController;
75 }
83 }
76
84
77 void VariableController::createVariable(const QString &name,
85 void VariableController::createVariable(const QString &name,
78 std::shared_ptr<IDataProvider> provider) noexcept
86 std::shared_ptr<IDataProvider> provider) noexcept
79 {
87 {
80
88
81 if (!impl->m_TimeController) {
89 if (!impl->m_TimeController) {
82 qCCritical(LOG_VariableController())
90 qCCritical(LOG_VariableController())
83 << tr("Impossible to create variable: The time controller is null");
91 << tr("Impossible to create variable: The time controller is null");
84 return;
92 return;
85 }
93 }
86
94
87
95
88 /// @todo : for the moment :
96 /// @todo : for the moment :
89 /// - the provider is only used to retrieve data from the variable for its initialization, but
97 /// - the provider is only used to retrieve data from the variable for its initialization, but
90 /// it will be retained later
98 /// it will be retained later
91 /// - default data are generated for the variable, without taking into account the timerange set
99 /// - default data are generated for the variable, without taking into account the timerange set
92 /// in sciqlop
100 /// in sciqlop
93 auto dateTime = impl->m_TimeController->dateTime();
101 auto dateTime = impl->m_TimeController->dateTime();
94 if (auto newVariable = impl->m_VariableModel->createVariable(
102 if (auto newVariable = impl->m_VariableModel->createVariable(
95 name, dateTime, generateDefaultDataSeries(*provider, dateTime))) {
103 name, dateTime, generateDefaultDataSeries(*provider, dateTime))) {
96
104
97 // store the provider
105 // store the provider
98 impl->m_VariableToProviderMap[newVariable] = provider;
106 impl->m_VariableToProviderMap[newVariable] = provider;
99 qRegisterMetaType<std::shared_ptr<IDataSeries> >();
107 qRegisterMetaType<std::shared_ptr<IDataSeries> >();
100 qRegisterMetaType<SqpDateTime>();
108 qRegisterMetaType<SqpDateTime>();
101 connect(provider.get(), &IDataProvider::dataProvided, newVariable.get(),
109 connect(provider.get(), &IDataProvider::dataProvided, newVariable.get(),
102 &Variable::onAddDataSeries);
110 &Variable::onAddDataSeries);
103
111
104
112
105 // store in cache
113 // store in cache
106 impl->m_VariableCacheController->addDateTime(newVariable, dateTime);
114 impl->m_VariableCacheController->addDateTime(newVariable, dateTime);
107
115
108 // notify the creation
116 // notify the creation
109 emit variableCreated(newVariable);
117 emit variableCreated(newVariable);
110 }
118 }
111 }
119 }
112
120
121 void VariableController::onDateTimeOnSelection(const SqpDateTime &dateTime)
122 {
123 auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
124
125 for (const auto &selectedRow : qAsConst(selectedRows)) {
126 if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) {
127 selectedVariable->setDateTime(dateTime);
128 }
129 }
130 }
131
113
132
114 void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable,
133 void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable,
115 const SqpDateTime &dateTime)
134 const SqpDateTime &dateTime)
116 {
135 {
117 // we want to load data of the variable for the dateTime.
136 // we want to load data of the variable for the dateTime.
118 // First we check if the cache contains some of them.
137 // First we check if the cache contains some of them.
119 // For the other, we ask the provider to give them.
138 // For the other, we ask the provider to give them.
120 if (variable) {
139 if (variable) {
121
140
122 auto dateTimeListNotInCache
141 auto dateTimeListNotInCache
123 = impl->m_VariableCacheController->provideNotInCacheDateTimeList(variable, dateTime);
142 = impl->m_VariableCacheController->provideNotInCacheDateTimeList(variable, dateTime);
124
143
125 if (!dateTimeListNotInCache.empty()) {
144 if (!dateTimeListNotInCache.empty()) {
126 // Ask the provider for each data on the dateTimeListNotInCache
145 // Ask the provider for each data on the dateTimeListNotInCache
127 impl->m_VariableToProviderMap.at(variable)->requestDataLoading(
146 impl->m_VariableToProviderMap.at(variable)->requestDataLoading(
128 std::move(dateTimeListNotInCache));
147 std::move(dateTimeListNotInCache));
129 // store in cache
148 // store in cache
130 impl->m_VariableCacheController->addDateTime(variable, dateTime);
149 impl->m_VariableCacheController->addDateTime(variable, dateTime);
131 }
150 }
132 else {
151 else {
133 emit variable->updated();
152 emit variable->updated();
134 }
153 }
135 }
154 }
136 else {
155 else {
137 qCCritical(LOG_VariableController()) << tr("Impossible to load data of a variable null");
156 qCCritical(LOG_VariableController()) << tr("Impossible to load data of a variable null");
138 }
157 }
139 }
158 }
140
159
141
160
142 void VariableController::initialize()
161 void VariableController::initialize()
143 {
162 {
144 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
163 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
145 impl->m_WorkingMutex.lock();
164 impl->m_WorkingMutex.lock();
146 qCDebug(LOG_VariableController()) << tr("VariableController init END");
165 qCDebug(LOG_VariableController()) << tr("VariableController init END");
147 }
166 }
148
167
149 void VariableController::finalize()
168 void VariableController::finalize()
150 {
169 {
151 impl->m_WorkingMutex.unlock();
170 impl->m_WorkingMutex.unlock();
152 }
171 }
153
172
154 void VariableController::waitForFinish()
173 void VariableController::waitForFinish()
155 {
174 {
156 QMutexLocker locker{&impl->m_WorkingMutex};
175 QMutexLocker locker{&impl->m_WorkingMutex};
157 }
176 }
@@ -1,38 +1,48
1 #include "TimeWidget/TimeWidget.h"
1 #include "TimeWidget/TimeWidget.h"
2 #include "ui_TimeWidget.h"
2 #include "ui_TimeWidget.h"
3
3
4 #include <SqpApplication.h>
4 #include <SqpApplication.h>
5 #include <Time/TimeController.h>
5 #include <Time/TimeController.h>
6
6
7 TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget}
7 TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget}
8 {
8 {
9 ui->setupUi(this);
9 ui->setupUi(this);
10
10
11 ui->applyToolButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_DialogApplyButton));
11 ui->applyToolButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_DialogApplyButton));
12
12
13 // Connection
13 // Connection
14 connect(ui->startDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this,
14 connect(ui->startDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this,
15 &TimeWidget::onTimeUpdateRequested);
15 &TimeWidget::onTimeUpdateRequested);
16
16
17 connect(ui->endDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this,
17 connect(ui->endDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this,
18 &TimeWidget::onTimeUpdateRequested);
18 &TimeWidget::onTimeUpdateRequested);
19
19
20
20
21 connect(ui->applyToolButton, &QToolButton::clicked, &sqpApp->timeController(),
21 connect(ui->applyToolButton, &QToolButton::clicked, &sqpApp->timeController(),
22 &TimeController::onTimeNotify);
22 &TimeController::onTimeNotify);
23
24 // Initialisation
25 ui->startDateTimeEdit->setDateTime(
26 QDateTime::currentDateTime().addSecs(-3600)); // one hour berefore
27 ui->endDateTimeEdit->setDateTime(QDateTime::currentDateTime());
28
29 auto dateTime
30 = SqpDateTime{QDateTime::currentDateTime().addSecs(-3600).toMSecsSinceEpoch() / 1000.0,
31 QDateTime::currentDateTime().toMSecsSinceEpoch() / 1000.0};
32 sqpApp->timeController().onTimeToUpdate(dateTime);
23 }
33 }
24
34
25
35
26 TimeWidget::~TimeWidget()
36 TimeWidget::~TimeWidget()
27 {
37 {
28 delete ui;
38 delete ui;
29 }
39 }
30
40
31 void TimeWidget::onTimeUpdateRequested()
41 void TimeWidget::onTimeUpdateRequested()
32 {
42 {
33 auto dateTime = SqpDateTime{
43 auto dateTime = SqpDateTime{
34 static_cast<double>(ui->startDateTimeEdit->dateTime().toMSecsSinceEpoch() / 1000.),
44 static_cast<double>(ui->startDateTimeEdit->dateTime().toMSecsSinceEpoch() / 1000.),
35 static_cast<double>(ui->endDateTimeEdit->dateTime().toMSecsSinceEpoch()) / 1000.};
45 static_cast<double>(ui->endDateTimeEdit->dateTime().toMSecsSinceEpoch()) / 1000.};
36
46
37 emit timeUpdated(std::move(dateTime));
47 emit timeUpdated(std::move(dateTime));
38 }
48 }
@@ -1,88 +1,89
1 #include <Variable/VariableController.h>
1 #include <Variable/VariableController.h>
2 #include <Variable/VariableInspectorWidget.h>
2 #include <Variable/VariableInspectorWidget.h>
3 #include <Variable/VariableMenuHeaderWidget.h>
3 #include <Variable/VariableMenuHeaderWidget.h>
4 #include <Variable/VariableModel.h>
4 #include <Variable/VariableModel.h>
5
5
6 #include <ui_VariableInspectorWidget.h>
6 #include <ui_VariableInspectorWidget.h>
7
7
8 #include <QSortFilterProxyModel>
8 #include <QSortFilterProxyModel>
9 #include <QWidgetAction>
9 #include <QWidgetAction>
10
10
11 #include <SqpApplication.h>
11 #include <SqpApplication.h>
12
12
13 Q_LOGGING_CATEGORY(LOG_VariableInspectorWidget, "VariableInspectorWidget")
13 Q_LOGGING_CATEGORY(LOG_VariableInspectorWidget, "VariableInspectorWidget")
14
14
15 VariableInspectorWidget::VariableInspectorWidget(QWidget *parent)
15 VariableInspectorWidget::VariableInspectorWidget(QWidget *parent)
16 : QWidget{parent}, ui{new Ui::VariableInspectorWidget}
16 : QWidget{parent}, ui{new Ui::VariableInspectorWidget}
17 {
17 {
18 ui->setupUi(this);
18 ui->setupUi(this);
19
19
20 // Sets model for table
20 // Sets model for table
21 auto sortFilterModel = new QSortFilterProxyModel{this};
21 // auto sortFilterModel = new QSortFilterProxyModel{this};
22 sortFilterModel->setSourceModel(sqpApp->variableController().variableModel());
22 // sortFilterModel->setSourceModel(sqpApp->variableController().variableModel());
23
23
24 ui->tableView->setModel(sortFilterModel);
24 ui->tableView->setModel(sqpApp->variableController().variableModel());
25 ui->tableView->setSelectionModel(sqpApp->variableController().variableSelectionModel());
25
26
26 // Fixes column sizes
27 // Fixes column sizes
27 auto model = ui->tableView->model();
28 auto model = ui->tableView->model();
28 const auto count = model->columnCount();
29 const auto count = model->columnCount();
29 for (auto i = 0; i < count; ++i) {
30 for (auto i = 0; i < count; ++i) {
30 ui->tableView->setColumnWidth(
31 ui->tableView->setColumnWidth(
31 i, model->headerData(i, Qt::Horizontal, Qt::SizeHintRole).toSize().width());
32 i, model->headerData(i, Qt::Horizontal, Qt::SizeHintRole).toSize().width());
32 }
33 }
33
34
34 // Sets selection options
35 // Sets selection options
35 ui->tableView->setSelectionBehavior(QTableView::SelectRows);
36 ui->tableView->setSelectionBehavior(QTableView::SelectRows);
36 ui->tableView->setSelectionMode(QTableView::ExtendedSelection);
37 ui->tableView->setSelectionMode(QTableView::ExtendedSelection);
37
38
38 // Connection to show a menu when right clicking on the tree
39 // Connection to show a menu when right clicking on the tree
39 ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu);
40 ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu);
40 connect(ui->tableView, &QTableView::customContextMenuRequested, this,
41 connect(ui->tableView, &QTableView::customContextMenuRequested, this,
41 &VariableInspectorWidget::onTableMenuRequested);
42 &VariableInspectorWidget::onTableMenuRequested);
42 }
43 }
43
44
44 VariableInspectorWidget::~VariableInspectorWidget()
45 VariableInspectorWidget::~VariableInspectorWidget()
45 {
46 {
46 delete ui;
47 delete ui;
47 }
48 }
48
49
49 void VariableInspectorWidget::onTableMenuRequested(const QPoint &pos) noexcept
50 void VariableInspectorWidget::onTableMenuRequested(const QPoint &pos) noexcept
50 {
51 {
51 auto selectedRows = ui->tableView->selectionModel()->selectedRows();
52 auto selectedRows = ui->tableView->selectionModel()->selectedRows();
52
53
53 // Gets the model to retrieve the underlying selected variables
54 // Gets the model to retrieve the underlying selected variables
54 auto model = sqpApp->variableController().variableModel();
55 auto model = sqpApp->variableController().variableModel();
55 auto selectedVariables = QVector<std::shared_ptr<Variable> >{};
56 auto selectedVariables = QVector<std::shared_ptr<Variable> >{};
56 for (const auto &selectedRow : qAsConst(selectedRows)) {
57 for (const auto &selectedRow : qAsConst(selectedRows)) {
57 if (auto selectedVariable = model->variable(selectedRow.row())) {
58 if (auto selectedVariable = model->variable(selectedRow.row())) {
58 selectedVariables.push_back(selectedVariable);
59 selectedVariables.push_back(selectedVariable);
59 }
60 }
60 }
61 }
61
62
62 QMenu tableMenu{};
63 QMenu tableMenu{};
63
64
64 // Emits a signal so that potential receivers can populate the menu before displaying it
65 // Emits a signal so that potential receivers can populate the menu before displaying it
65 emit tableMenuAboutToBeDisplayed(&tableMenu, selectedVariables);
66 emit tableMenuAboutToBeDisplayed(&tableMenu, selectedVariables);
66
67
67 // Adds menu-specific actions
68 // Adds menu-specific actions
68 if (!selectedVariables.isEmpty()) {
69 if (!selectedVariables.isEmpty()) {
69 // 'Delete' action
70 // 'Delete' action
70 auto deleteFun = []() {
71 auto deleteFun = []() {
71 /// @todo ALX : call variable deletion
72 /// @todo ALX : call variable deletion
72 };
73 };
73
74
74 tableMenu.addSeparator();
75 tableMenu.addSeparator();
75 tableMenu.addAction(QIcon{":/icones/delete.png"}, tr("Delete"), deleteFun);
76 tableMenu.addAction(QIcon{":/icones/delete.png"}, tr("Delete"), deleteFun);
76 }
77 }
77
78
78 if (!tableMenu.isEmpty()) {
79 if (!tableMenu.isEmpty()) {
79 // Generates menu header (inserted before first action)
80 // Generates menu header (inserted before first action)
80 auto firstAction = tableMenu.actions().first();
81 auto firstAction = tableMenu.actions().first();
81 auto headerAction = new QWidgetAction{&tableMenu};
82 auto headerAction = new QWidgetAction{&tableMenu};
82 headerAction->setDefaultWidget(new VariableMenuHeaderWidget{selectedVariables, &tableMenu});
83 headerAction->setDefaultWidget(new VariableMenuHeaderWidget{selectedVariables, &tableMenu});
83 tableMenu.insertAction(firstAction, headerAction);
84 tableMenu.insertAction(firstAction, headerAction);
84
85
85 // Displays menu
86 // Displays menu
86 tableMenu.exec(mapToGlobal(pos));
87 tableMenu.exec(mapToGlobal(pos));
87 }
88 }
88 }
89 }
General Comments 1
Under Review
author

Auto status change to "Under Review"

You need to be logged in to leave comments. Login now