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