Auto status change to "Under Review"
@@ -1,128 +1,128 | |||||
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 <SqpApplication.h> |
|
27 | #include <SqpApplication.h> | |
28 |
|
28 | |||
29 | #include <QAction> |
|
29 | #include <QAction> | |
30 | #include <QDate> |
|
30 | #include <QDate> | |
31 | #include <QDateTime> |
|
31 | #include <QDateTime> | |
32 | #include <QDir> |
|
32 | #include <QDir> | |
33 | #include <QFileDialog> |
|
33 | #include <QFileDialog> | |
34 | //#include <omp.h> |
|
34 | //#include <omp.h> | |
35 | //#include <network/filedownloader.h> |
|
35 | //#include <network/filedownloader.h> | |
36 | //#include <qlopdatabase.h> |
|
36 | //#include <qlopdatabase.h> | |
37 | //#include <qlopsettings.h> |
|
37 | //#include <qlopsettings.h> | |
38 | //#include <qlopgui.h> |
|
38 | //#include <qlopgui.h> | |
39 | //#include <spacedata.h> |
|
39 | //#include <spacedata.h> | |
40 | //#include "qlopcore.h" |
|
40 | //#include "qlopcore.h" | |
41 | //#include "qlopcodecmanager.h" |
|
41 | //#include "qlopcodecmanager.h" | |
42 | //#include "cdfcodec.h" |
|
42 | //#include "cdfcodec.h" | |
43 | //#include "amdatxtcodec.h" |
|
43 | //#include "amdatxtcodec.h" | |
44 | //#include <qlopplotmanager.h> |
|
44 | //#include <qlopplotmanager.h> | |
45 | #include <QAction> |
|
45 | #include <QAction> | |
46 | #include <QToolBar> |
|
46 | #include <QToolBar> | |
47 | #include <memory.h> |
|
47 | #include <memory.h> | |
48 | MainWindow::MainWindow(QWidget *parent) : QMainWindow{parent}, m_Ui{new Ui::MainWindow} |
|
48 | MainWindow::MainWindow(QWidget *parent) : QMainWindow{parent}, m_Ui{new Ui::MainWindow} | |
49 | { |
|
49 | { | |
50 | m_Ui->setupUi(this); |
|
50 | m_Ui->setupUi(this); | |
51 |
|
51 | |||
52 | auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); |
|
52 | auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); | |
53 | leftSidePane->addAction("ACTION L1"); |
|
53 | leftSidePane->addAction("ACTION L1"); | |
54 | leftSidePane->addAction("ACTION L2"); |
|
54 | leftSidePane->addAction("ACTION L2"); | |
55 | leftSidePane->addAction("ACTION L3"); |
|
55 | leftSidePane->addAction("ACTION L3"); | |
56 |
|
56 | |||
57 | auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane(); |
|
57 | auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane(); | |
58 | rightSidePane->addAction("ACTION R1"); |
|
58 | rightSidePane->addAction("ACTION R1"); | |
59 | rightSidePane->addAction("ACTION R2"); |
|
59 | rightSidePane->addAction("ACTION R2"); | |
60 | rightSidePane->addAction("ACTION R3"); |
|
60 | rightSidePane->addAction("ACTION R3"); | |
61 |
|
61 | |||
62 | this->menuBar()->addAction("File"); |
|
62 | this->menuBar()->addAction("File"); | |
63 | auto mainToolBar = this->addToolBar("MainToolBar"); |
|
63 | auto mainToolBar = this->addToolBar("MainToolBar"); | |
64 | mainToolBar->addAction("A1"); |
|
64 | mainToolBar->addAction("A1"); | |
65 |
|
65 | |||
66 | // Widgets / controllers connections |
|
66 | // Widgets / controllers connections | |
67 |
connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem |
|
67 | connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)), | |
68 |
m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem |
|
68 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *))); | |
69 |
|
69 | |||
70 | /* QLopGUI::registerMenuBar(menuBar()); |
|
70 | /* QLopGUI::registerMenuBar(menuBar()); | |
71 | this->setWindowIcon(QIcon(":/sciqlopLOGO.svg")); |
|
71 | this->setWindowIcon(QIcon(":/sciqlopLOGO.svg")); | |
72 | this->m_progressWidget = new QWidget(); |
|
72 | this->m_progressWidget = new QWidget(); | |
73 | this->m_progressLayout = new QVBoxLayout(this->m_progressWidget); |
|
73 | this->m_progressLayout = new QVBoxLayout(this->m_progressWidget); | |
74 | this->m_progressWidget->setLayout(this->m_progressLayout); |
|
74 | this->m_progressWidget->setLayout(this->m_progressLayout); | |
75 | this->m_progressWidget->setWindowModality(Qt::WindowModal); |
|
75 | this->m_progressWidget->setWindowModality(Qt::WindowModal); | |
76 | m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int)); |
|
76 | m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int)); | |
77 | for(int i=0;i<OMP_THREADS;i++) |
|
77 | for(int i=0;i<OMP_THREADS;i++) | |
78 | { |
|
78 | { | |
79 | this->m_progress.append(new QProgressBar(this->m_progressWidget)); |
|
79 | this->m_progress.append(new QProgressBar(this->m_progressWidget)); | |
80 | this->m_progress.last()->setMinimum(0); |
|
80 | this->m_progress.last()->setMinimum(0); | |
81 | this->m_progress.last()->setMaximum(100); |
|
81 | this->m_progress.last()->setMaximum(100); | |
82 | this->m_progressLayout->addWidget(this->m_progress.last()); |
|
82 | this->m_progressLayout->addWidget(this->m_progress.last()); | |
83 | this->m_progressWidget->hide(); |
|
83 | this->m_progressWidget->hide(); | |
84 | this->m_progressThreadIds[i] = -1; |
|
84 | this->m_progressThreadIds[i] = -1; | |
85 | } |
|
85 | } | |
86 | this->m_progressWidget->setWindowTitle("Loading File"); |
|
86 | this->m_progressWidget->setWindowTitle("Loading File"); | |
87 | const QList<QLopService*>ServicesToLoad=QList<QLopService*>() |
|
87 | const QList<QLopService*>ServicesToLoad=QList<QLopService*>() | |
88 | << QLopCore::self() |
|
88 | << QLopCore::self() | |
89 | << QLopPlotManager::self() |
|
89 | << QLopPlotManager::self() | |
90 | << QLopCodecManager::self() |
|
90 | << QLopCodecManager::self() | |
91 | << FileDownloader::self() |
|
91 | << FileDownloader::self() | |
92 | << QLopDataBase::self() |
|
92 | << QLopDataBase::self() | |
93 | << SpaceData::self(); |
|
93 | << SpaceData::self(); | |
94 |
|
94 | |||
95 | CDFCodec::registerToManager(); |
|
95 | CDFCodec::registerToManager(); | |
96 | AMDATXTCodec::registerToManager(); |
|
96 | AMDATXTCodec::registerToManager(); | |
97 |
|
97 | |||
98 |
|
98 | |||
99 | for(int i=0;i<ServicesToLoad.count();i++) |
|
99 | for(int i=0;i<ServicesToLoad.count();i++) | |
100 | { |
|
100 | { | |
101 | qDebug()<<ServicesToLoad.at(i)->serviceName(); |
|
101 | qDebug()<<ServicesToLoad.at(i)->serviceName(); | |
102 | ServicesToLoad.at(i)->initialize(); //must be called before getGUI |
|
102 | ServicesToLoad.at(i)->initialize(); //must be called before getGUI | |
103 | QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI(); |
|
103 | QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI(); | |
104 | if(wdgt) |
|
104 | if(wdgt) | |
105 | { |
|
105 | { | |
106 | wdgt->setAllowedAreas(Qt::AllDockWidgetAreas); |
|
106 | wdgt->setAllowedAreas(Qt::AllDockWidgetAreas); | |
107 | this->addDockWidget(Qt::TopDockWidgetArea,wdgt); |
|
107 | this->addDockWidget(Qt::TopDockWidgetArea,wdgt); | |
108 | } |
|
108 | } | |
109 | PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i)); |
|
109 | PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i)); | |
110 | }*/ |
|
110 | }*/ | |
111 | } |
|
111 | } | |
112 |
|
112 | |||
113 | MainWindow::~MainWindow() |
|
113 | MainWindow::~MainWindow() | |
114 | { |
|
114 | { | |
115 | } |
|
115 | } | |
116 |
|
116 | |||
117 |
|
117 | |||
118 | void MainWindow::changeEvent(QEvent *e) |
|
118 | void MainWindow::changeEvent(QEvent *e) | |
119 | { |
|
119 | { | |
120 | QMainWindow::changeEvent(e); |
|
120 | QMainWindow::changeEvent(e); | |
121 | switch (e->type()) { |
|
121 | switch (e->type()) { | |
122 | case QEvent::LanguageChange: |
|
122 | case QEvent::LanguageChange: | |
123 | m_Ui->retranslateUi(this); |
|
123 | m_Ui->retranslateUi(this); | |
124 | break; |
|
124 | break; | |
125 | default: |
|
125 | default: | |
126 | break; |
|
126 | break; | |
127 | } |
|
127 | } | |
128 | } |
|
128 | } |
@@ -1,61 +1,61 | |||||
1 | #ifndef SCIQLOP_DATASOURCECONTROLLER_H |
|
1 | #ifndef SCIQLOP_DATASOURCECONTROLLER_H | |
2 | #define SCIQLOP_DATASOURCECONTROLLER_H |
|
2 | #define SCIQLOP_DATASOURCECONTROLLER_H | |
3 |
|
3 | |||
4 | #include <QLoggingCategory> |
|
4 | #include <QLoggingCategory> | |
5 | #include <QObject> |
|
5 | #include <QObject> | |
6 | #include <QUuid> |
|
6 | #include <QUuid> | |
7 |
|
7 | |||
8 | #include <Common/spimpl.h> |
|
8 | #include <Common/spimpl.h> | |
9 |
|
9 | |||
10 | Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController) |
|
10 | Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController) | |
11 |
|
11 | |||
12 | class DataSourceItem; |
|
12 | class DataSourceItem; | |
13 |
|
13 | |||
14 | /** |
|
14 | /** | |
15 | * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This |
|
15 | * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This | |
16 | * is the intermediate class that SciQlop has to use in the way to connect a data source. Please |
|
16 | * is the intermediate class that SciQlop has to use in the way to connect a data source. Please | |
17 | * first use register method to initialize a plugin specified by its metadata name (JSON plugin |
|
17 | * first use register method to initialize a plugin specified by its metadata name (JSON plugin | |
18 | * source) then others specifics method will be able to access it. You can load a data source driver |
|
18 | * source) then others specifics method will be able to access it. You can load a data source driver | |
19 | * plugin then create a data source. |
|
19 | * plugin then create a data source. | |
20 | */ |
|
20 | */ | |
21 | class DataSourceController : public QObject { |
|
21 | class DataSourceController : public QObject { | |
22 | Q_OBJECT |
|
22 | Q_OBJECT | |
23 | public: |
|
23 | public: | |
24 | explicit DataSourceController(QObject *parent = 0); |
|
24 | explicit DataSourceController(QObject *parent = 0); | |
25 | virtual ~DataSourceController(); |
|
25 | virtual ~DataSourceController(); | |
26 |
|
26 | |||
27 | /** |
|
27 | /** | |
28 | * Registers a data source. The method delivers a unique id that can be used afterwards to |
|
28 | * Registers a data source. The method delivers a unique id that can be used afterwards to | |
29 | * access to the data source properties (structure, connection parameters, data provider, etc.) |
|
29 | * access to the data source properties (structure, connection parameters, data provider, etc.) | |
30 | * @param dataSourceName the name of the data source |
|
30 | * @param dataSourceName the name of the data source | |
31 | * @return the unique id with which the data source has been registered |
|
31 | * @return the unique id with which the data source has been registered | |
32 | */ |
|
32 | */ | |
33 | QUuid registerDataSource(const QString &dataSourceName) noexcept; |
|
33 | QUuid registerDataSource(const QString &dataSourceName) noexcept; | |
34 |
|
34 | |||
35 | /** |
|
35 | /** | |
36 | * Sets the structure of a data source. The controller takes ownership of the structure. |
|
36 | * Sets the structure of a data source. The controller takes ownership of the structure. | |
37 | * @param dataSourceUid the unique id with which the data source has been registered into the |
|
37 | * @param dataSourceUid the unique id with which the data source has been registered into the | |
38 | * controller. If it is invalid, the method has no effect. |
|
38 | * controller. If it is invalid, the method has no effect. | |
39 | * @param dataSourceItem the structure of the data source |
|
39 | * @param dataSourceItem the structure of the data source | |
40 | * @sa registerDataSource() |
|
40 | * @sa registerDataSource() | |
41 | */ |
|
41 | */ | |
42 | void setDataSourceItem(const QUuid &dataSourceUid, |
|
42 | void setDataSourceItem(const QUuid &dataSourceUid, | |
43 | std::unique_ptr<DataSourceItem> dataSourceItem) noexcept; |
|
43 | std::unique_ptr<DataSourceItem> dataSourceItem) noexcept; | |
44 |
|
44 | |||
45 | public slots: |
|
45 | public slots: | |
46 | /// Manage init/end of the controller |
|
46 | /// Manage init/end of the controller | |
47 | void initialize(); |
|
47 | void initialize(); | |
48 | void finalize(); |
|
48 | void finalize(); | |
49 |
|
49 | |||
50 | signals: |
|
50 | signals: | |
51 | /// Signal emitted when a structure has been set for a data source |
|
51 | /// Signal emitted when a structure has been set for a data source | |
52 |
void dataSourceItemSet(DataSourceItem |
|
52 | void dataSourceItemSet(DataSourceItem *dataSourceItem); | |
53 |
|
53 | |||
54 | private: |
|
54 | private: | |
55 | void waitForFinish(); |
|
55 | void waitForFinish(); | |
56 |
|
56 | |||
57 | class DataSourceControllerPrivate; |
|
57 | class DataSourceControllerPrivate; | |
58 | spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl; |
|
58 | spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl; | |
59 | }; |
|
59 | }; | |
60 |
|
60 | |||
61 | #endif // SCIQLOP_DATASOURCECONTROLLER_H |
|
61 | #endif // SCIQLOP_DATASOURCECONTROLLER_H |
@@ -1,78 +1,78 | |||||
1 | #include <DataSource/DataSourceController.h> |
|
1 | #include <DataSource/DataSourceController.h> | |
2 | #include <DataSource/DataSourceItem.h> |
|
2 | #include <DataSource/DataSourceItem.h> | |
3 |
|
3 | |||
4 | #include <QMutex> |
|
4 | #include <QMutex> | |
5 | #include <QThread> |
|
5 | #include <QThread> | |
6 |
|
6 | |||
7 | #include <QDir> |
|
7 | #include <QDir> | |
8 | #include <QStandardPaths> |
|
8 | #include <QStandardPaths> | |
9 |
|
9 | |||
10 | Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController") |
|
10 | Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController") | |
11 |
|
11 | |||
12 | class DataSourceController::DataSourceControllerPrivate { |
|
12 | class DataSourceController::DataSourceControllerPrivate { | |
13 | public: |
|
13 | public: | |
14 | QMutex m_WorkingMutex; |
|
14 | QMutex m_WorkingMutex; | |
15 | /// Data sources registered |
|
15 | /// Data sources registered | |
16 | QHash<QUuid, QString> m_DataSources; |
|
16 | QHash<QUuid, QString> m_DataSources; | |
17 | /// Data sources structures |
|
17 | /// Data sources structures | |
18 | std::map<QUuid, std::unique_ptr<DataSourceItem> > m_DataSourceItems; |
|
18 | std::map<QUuid, std::unique_ptr<DataSourceItem> > m_DataSourceItems; | |
19 | }; |
|
19 | }; | |
20 |
|
20 | |||
21 | DataSourceController::DataSourceController(QObject *parent) |
|
21 | DataSourceController::DataSourceController(QObject *parent) | |
22 | : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()} |
|
22 | : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()} | |
23 | { |
|
23 | { | |
24 | qCDebug(LOG_DataSourceController()) << tr("DataSourceController construction") |
|
24 | qCDebug(LOG_DataSourceController()) << tr("DataSourceController construction") | |
25 | << QThread::currentThread(); |
|
25 | << QThread::currentThread(); | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | DataSourceController::~DataSourceController() |
|
28 | DataSourceController::~DataSourceController() | |
29 | { |
|
29 | { | |
30 | qCDebug(LOG_DataSourceController()) << tr("DataSourceController destruction") |
|
30 | qCDebug(LOG_DataSourceController()) << tr("DataSourceController destruction") | |
31 | << QThread::currentThread(); |
|
31 | << QThread::currentThread(); | |
32 | this->waitForFinish(); |
|
32 | this->waitForFinish(); | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | QUuid DataSourceController::registerDataSource(const QString &dataSourceName) noexcept |
|
35 | QUuid DataSourceController::registerDataSource(const QString &dataSourceName) noexcept | |
36 | { |
|
36 | { | |
37 | auto dataSourceUid = QUuid::createUuid(); |
|
37 | auto dataSourceUid = QUuid::createUuid(); | |
38 | impl->m_DataSources.insert(dataSourceUid, dataSourceName); |
|
38 | impl->m_DataSources.insert(dataSourceUid, dataSourceName); | |
39 |
|
39 | |||
40 | return dataSourceUid; |
|
40 | return dataSourceUid; | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | void DataSourceController::setDataSourceItem( |
|
43 | void DataSourceController::setDataSourceItem( | |
44 | const QUuid &dataSourceUid, std::unique_ptr<DataSourceItem> dataSourceItem) noexcept |
|
44 | const QUuid &dataSourceUid, std::unique_ptr<DataSourceItem> dataSourceItem) noexcept | |
45 | { |
|
45 | { | |
46 | if (impl->m_DataSources.contains(dataSourceUid)) { |
|
46 | if (impl->m_DataSources.contains(dataSourceUid)) { | |
47 | impl->m_DataSourceItems.insert(std::make_pair(dataSourceUid, std::move(dataSourceItem))); |
|
47 | impl->m_DataSourceItems.insert(std::make_pair(dataSourceUid, std::move(dataSourceItem))); | |
48 |
|
48 | |||
49 | // Retrieves the data source item to emit the signal with it |
|
49 | // Retrieves the data source item to emit the signal with it | |
50 | auto it = impl->m_DataSourceItems.find(dataSourceUid); |
|
50 | auto it = impl->m_DataSourceItems.find(dataSourceUid); | |
51 | if (it != impl->m_DataSourceItems.end()) { |
|
51 | if (it != impl->m_DataSourceItems.end()) { | |
52 |
emit dataSourceItemSet( |
|
52 | emit dataSourceItemSet(it->second.get()); | |
53 | } |
|
53 | } | |
54 | } |
|
54 | } | |
55 | else { |
|
55 | else { | |
56 | qCWarning(LOG_DataSourceController()) << tr("Can't set data source item for uid %1 : no " |
|
56 | qCWarning(LOG_DataSourceController()) << tr("Can't set data source item for uid %1 : no " | |
57 | "data source has been registered with the uid") |
|
57 | "data source has been registered with the uid") | |
58 | .arg(dataSourceUid.toString()); |
|
58 | .arg(dataSourceUid.toString()); | |
59 | } |
|
59 | } | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | void DataSourceController::initialize() |
|
62 | void DataSourceController::initialize() | |
63 | { |
|
63 | { | |
64 | qCDebug(LOG_DataSourceController()) << tr("DataSourceController init") |
|
64 | qCDebug(LOG_DataSourceController()) << tr("DataSourceController init") | |
65 | << QThread::currentThread(); |
|
65 | << QThread::currentThread(); | |
66 | impl->m_WorkingMutex.lock(); |
|
66 | impl->m_WorkingMutex.lock(); | |
67 | qCDebug(LOG_DataSourceController()) << tr("DataSourceController init END"); |
|
67 | qCDebug(LOG_DataSourceController()) << tr("DataSourceController init END"); | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | void DataSourceController::finalize() |
|
70 | void DataSourceController::finalize() | |
71 | { |
|
71 | { | |
72 | impl->m_WorkingMutex.unlock(); |
|
72 | impl->m_WorkingMutex.unlock(); | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | void DataSourceController::waitForFinish() |
|
75 | void DataSourceController::waitForFinish() | |
76 | { |
|
76 | { | |
77 | QMutexLocker locker{&impl->m_WorkingMutex}; |
|
77 | QMutexLocker locker{&impl->m_WorkingMutex}; | |
78 | } |
|
78 | } |
@@ -1,51 +1,51 | |||||
1 | #include <DataSource/DataSourceController.h> |
|
1 | #include <DataSource/DataSourceController.h> | |
2 | #include <DataSource/DataSourceItem.h> |
|
2 | #include <DataSource/DataSourceItem.h> | |
3 |
|
3 | |||
4 | #include <QObject> |
|
4 | #include <QObject> | |
5 | #include <QtTest> |
|
5 | #include <QtTest> | |
6 |
|
6 | |||
7 | #include <memory> |
|
7 | #include <memory> | |
8 |
|
8 | |||
9 | class TestDataSourceController : public QObject { |
|
9 | class TestDataSourceController : public QObject { | |
10 | Q_OBJECT |
|
10 | Q_OBJECT | |
11 | private slots: |
|
11 | private slots: | |
12 | void testRegisterDataSource(); |
|
12 | void testRegisterDataSource(); | |
13 | void testSetDataSourceItem(); |
|
13 | void testSetDataSourceItem(); | |
14 | }; |
|
14 | }; | |
15 |
|
15 | |||
16 | void TestDataSourceController::testRegisterDataSource() |
|
16 | void TestDataSourceController::testRegisterDataSource() | |
17 | { |
|
17 | { | |
18 | DataSourceController dataSourceController{}; |
|
18 | DataSourceController dataSourceController{}; | |
19 |
|
19 | |||
20 | auto uid = dataSourceController.registerDataSource(QStringLiteral("Source1")); |
|
20 | auto uid = dataSourceController.registerDataSource(QStringLiteral("Source1")); | |
21 | QVERIFY(!uid.isNull()); |
|
21 | QVERIFY(!uid.isNull()); | |
22 | } |
|
22 | } | |
23 |
|
23 | |||
24 | void TestDataSourceController::testSetDataSourceItem() |
|
24 | void TestDataSourceController::testSetDataSourceItem() | |
25 | { |
|
25 | { | |
26 | DataSourceController dataSourceController{}; |
|
26 | DataSourceController dataSourceController{}; | |
27 |
|
27 | |||
28 | // Spy to test controllers' signals |
|
28 | // Spy to test controllers' signals | |
29 |
QSignalSpy signalSpy{&dataSourceController, SIGNAL(dataSourceItemSet( |
|
29 | QSignalSpy signalSpy{&dataSourceController, SIGNAL(dataSourceItemSet(DataSourceItem *))}; | |
30 |
|
30 | |||
31 | // Create a data source item |
|
31 | // Create a data source item | |
32 | auto source1Name = QStringLiteral("Source1"); |
|
32 | auto source1Name = QStringLiteral("Source1"); | |
33 | auto source1Values = QVector<QVariant>{source1Name}; |
|
33 | auto source1Values = QVector<QVariant>{source1Name}; | |
34 | auto source1Item |
|
34 | auto source1Item | |
35 | = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, std::move(source1Values)); |
|
35 | = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, std::move(source1Values)); | |
36 |
|
36 | |||
37 | // Add data source item to the controller and check that a signal has been emitted after setting |
|
37 | // Add data source item to the controller and check that a signal has been emitted after setting | |
38 | // data source item in the controller |
|
38 | // data source item in the controller | |
39 | auto source1Uid = dataSourceController.registerDataSource(source1Name); |
|
39 | auto source1Uid = dataSourceController.registerDataSource(source1Name); | |
40 | dataSourceController.setDataSourceItem(source1Uid, std::move(source1Item)); |
|
40 | dataSourceController.setDataSourceItem(source1Uid, std::move(source1Item)); | |
41 | QCOMPARE(signalSpy.count(), 1); |
|
41 | QCOMPARE(signalSpy.count(), 1); | |
42 |
|
42 | |||
43 | // Try to a data source item with an unregistered uid and check that no signal has been emitted |
|
43 | // Try to a data source item with an unregistered uid and check that no signal has been emitted | |
44 | auto unregisteredUid = QUuid::createUuid(); |
|
44 | auto unregisteredUid = QUuid::createUuid(); | |
45 | dataSourceController.setDataSourceItem( |
|
45 | dataSourceController.setDataSourceItem( | |
46 | unregisteredUid, std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT)); |
|
46 | unregisteredUid, std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT)); | |
47 | QCOMPARE(signalSpy.count(), 1); |
|
47 | QCOMPARE(signalSpy.count(), 1); | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | QTEST_MAIN(TestDataSourceController) |
|
50 | QTEST_MAIN(TestDataSourceController) | |
51 | #include "TestDataSourceController.moc" |
|
51 | #include "TestDataSourceController.moc" |
@@ -1,33 +1,33 | |||||
1 | #ifndef SCIQLOP_DATASOURCEWIDGET_H |
|
1 | #ifndef SCIQLOP_DATASOURCEWIDGET_H | |
2 | #define SCIQLOP_DATASOURCEWIDGET_H |
|
2 | #define SCIQLOP_DATASOURCEWIDGET_H | |
3 |
|
3 | |||
4 | #include <Common/spimpl.h> |
|
4 | #include <Common/spimpl.h> | |
5 |
|
5 | |||
6 | #include <QWidget> |
|
6 | #include <QWidget> | |
7 |
|
7 | |||
8 | class DataSourceItem; |
|
8 | class DataSourceItem; | |
9 |
|
9 | |||
10 | /** |
|
10 | /** | |
11 | * @brief The DataSourceWidget handles the graphical representation (as a tree) of the data sources |
|
11 | * @brief The DataSourceWidget handles the graphical representation (as a tree) of the data sources | |
12 | * attached to SciQlop. |
|
12 | * attached to SciQlop. | |
13 | */ |
|
13 | */ | |
14 | class DataSourceWidget : public QWidget { |
|
14 | class DataSourceWidget : public QWidget { | |
15 | Q_OBJECT |
|
15 | Q_OBJECT | |
16 |
|
16 | |||
17 | public: |
|
17 | public: | |
18 | explicit DataSourceWidget(QWidget *parent = 0); |
|
18 | explicit DataSourceWidget(QWidget *parent = 0); | |
19 |
|
19 | |||
20 | public slots: |
|
20 | public slots: | |
21 | /** |
|
21 | /** | |
22 | * Adds a data source. An item associated to the data source is created and then added to the |
|
22 | * Adds a data source. An item associated to the data source is created and then added to the | |
23 | * representation tree |
|
23 | * representation tree | |
24 | * @param dataSource the data source to add |
|
24 | * @param dataSource the data source to add. The pointer has to be not null | |
25 | */ |
|
25 | */ | |
26 |
void addDataSource(DataSourceItem |
|
26 | void addDataSource(DataSourceItem *dataSource) noexcept; | |
27 |
|
27 | |||
28 | private: |
|
28 | private: | |
29 | class DataSourceWidgetPrivate; |
|
29 | class DataSourceWidgetPrivate; | |
30 | spimpl::unique_impl_ptr<DataSourceWidgetPrivate> impl; |
|
30 | spimpl::unique_impl_ptr<DataSourceWidgetPrivate> impl; | |
31 | }; |
|
31 | }; | |
32 |
|
32 | |||
33 | #endif // SCIQLOP_DATASOURCEWIDGET_H |
|
33 | #endif // SCIQLOP_DATASOURCEWIDGET_H |
@@ -1,68 +1,75 | |||||
1 | #include <DataSource/DataSourceItem.h> |
|
1 | #include <DataSource/DataSourceItem.h> | |
2 | #include <DataSource/DataSourceTreeWidgetItem.h> |
|
2 | #include <DataSource/DataSourceTreeWidgetItem.h> | |
3 |
|
3 | |||
4 | #include <SqpApplication.h> |
|
4 | #include <SqpApplication.h> | |
5 |
|
5 | |||
6 | Q_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem, "DataSourceTreeWidgetItem") |
|
6 | Q_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem, "DataSourceTreeWidgetItem") | |
7 |
|
7 | |||
8 | namespace { |
|
8 | namespace { | |
9 |
|
9 | |||
10 | QIcon itemIcon(const DataSourceItem *dataSource) |
|
10 | QIcon itemIcon(const DataSourceItem *dataSource) | |
11 | { |
|
11 | { | |
12 | if (dataSource) { |
|
12 | if (dataSource) { | |
13 | auto dataSourceType = dataSource->type(); |
|
13 | auto dataSourceType = dataSource->type(); | |
14 | switch (dataSourceType) { |
|
14 | switch (dataSourceType) { | |
15 | case DataSourceItemType::NODE: |
|
15 | case DataSourceItemType::NODE: | |
16 | return sqpApp->style()->standardIcon(QStyle::SP_DirIcon); |
|
16 | return sqpApp->style()->standardIcon(QStyle::SP_DirIcon); | |
17 | case DataSourceItemType::PRODUCT: |
|
17 | case DataSourceItemType::PRODUCT: | |
18 | return sqpApp->style()->standardIcon(QStyle::SP_FileIcon); |
|
18 | return sqpApp->style()->standardIcon(QStyle::SP_FileIcon); | |
19 | default: |
|
19 | default: | |
20 | // No action |
|
20 | // No action | |
21 | break; |
|
21 | break; | |
22 | } |
|
22 | } | |
|
23 | ||||
|
24 | qCWarning(LOG_DataSourceTreeWidgetItem()) | |||
|
25 | << QObject::tr("Can't set data source icon : unknown data source type"); | |||
|
26 | } | |||
|
27 | else { | |||
|
28 | qCWarning(LOG_DataSourceTreeWidgetItem()) | |||
|
29 | << QObject::tr("Can't set data source icon : the data source is null"); | |||
23 | } |
|
30 | } | |
24 |
|
31 | |||
25 | // Default cases |
|
32 | // Default cases | |
26 | return QIcon{}; |
|
33 | return QIcon{}; | |
27 | } |
|
34 | } | |
28 |
|
35 | |||
29 | } // namespace |
|
36 | } // namespace | |
30 |
|
37 | |||
31 | struct DataSourceTreeWidgetItem::DataSourceTreeWidgetItemPrivate { |
|
38 | struct DataSourceTreeWidgetItem::DataSourceTreeWidgetItemPrivate { | |
32 | explicit DataSourceTreeWidgetItemPrivate(const DataSourceItem *data) : m_Data{data} {} |
|
39 | explicit DataSourceTreeWidgetItemPrivate(const DataSourceItem *data) : m_Data{data} {} | |
33 |
|
40 | |||
34 | /// Model used to retrieve data source information |
|
41 | /// Model used to retrieve data source information | |
35 | const DataSourceItem *m_Data; |
|
42 | const DataSourceItem *m_Data; | |
36 | }; |
|
43 | }; | |
37 |
|
44 | |||
38 | DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(const DataSourceItem *data, int type) |
|
45 | DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(const DataSourceItem *data, int type) | |
39 | : DataSourceTreeWidgetItem{nullptr, data, type} |
|
46 | : DataSourceTreeWidgetItem{nullptr, data, type} | |
40 | { |
|
47 | { | |
41 | } |
|
48 | } | |
42 |
|
49 | |||
43 | DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(QTreeWidget *parent, const DataSourceItem *data, |
|
50 | DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(QTreeWidget *parent, const DataSourceItem *data, | |
44 | int type) |
|
51 | int type) | |
45 | : QTreeWidgetItem{parent, type}, |
|
52 | : QTreeWidgetItem{parent, type}, | |
46 | impl{spimpl::make_unique_impl<DataSourceTreeWidgetItemPrivate>(data)} |
|
53 | impl{spimpl::make_unique_impl<DataSourceTreeWidgetItemPrivate>(data)} | |
47 | { |
|
54 | { | |
48 | // Sets the icon depending on the data source |
|
55 | // Sets the icon depending on the data source | |
49 | setIcon(0, itemIcon(impl->m_Data)); |
|
56 | setIcon(0, itemIcon(impl->m_Data)); | |
50 | } |
|
57 | } | |
51 |
|
58 | |||
52 | QVariant DataSourceTreeWidgetItem::data(int column, int role) const |
|
59 | QVariant DataSourceTreeWidgetItem::data(int column, int role) const | |
53 | { |
|
60 | { | |
54 | if (role == Qt::DisplayRole) { |
|
61 | if (role == Qt::DisplayRole) { | |
55 | return (impl->m_Data) ? impl->m_Data->data(column) : QVariant{}; |
|
62 | return (impl->m_Data) ? impl->m_Data->data(column) : QVariant{}; | |
56 | } |
|
63 | } | |
57 | else { |
|
64 | else { | |
58 | return QTreeWidgetItem::data(column, role); |
|
65 | return QTreeWidgetItem::data(column, role); | |
59 | } |
|
66 | } | |
60 | } |
|
67 | } | |
61 |
|
68 | |||
62 | void DataSourceTreeWidgetItem::setData(int column, int role, const QVariant &value) |
|
69 | void DataSourceTreeWidgetItem::setData(int column, int role, const QVariant &value) | |
63 | { |
|
70 | { | |
64 | // Data can't be changed by edition |
|
71 | // Data can't be changed by edition | |
65 | if (role != Qt::EditRole) { |
|
72 | if (role != Qt::EditRole) { | |
66 | QTreeWidgetItem::setData(column, role, value); |
|
73 | QTreeWidgetItem::setData(column, role, value); | |
67 | } |
|
74 | } | |
68 | } |
|
75 | } |
@@ -1,61 +1,63 | |||||
1 | #include <DataSource/DataSourceWidget.h> |
|
1 | #include <DataSource/DataSourceWidget.h> | |
2 |
|
2 | |||
3 | #include <ui_DataSourceWidget.h> |
|
3 | #include <ui_DataSourceWidget.h> | |
4 |
|
4 | |||
5 | #include <DataSource/DataSourceItem.h> |
|
5 | #include <DataSource/DataSourceItem.h> | |
6 | #include <DataSource/DataSourceTreeWidgetItem.h> |
|
6 | #include <DataSource/DataSourceTreeWidgetItem.h> | |
7 |
|
7 | |||
8 | namespace { |
|
8 | namespace { | |
9 |
|
9 | |||
10 | /// Number of columns displayed in the tree |
|
10 | /// Number of columns displayed in the tree | |
11 | const auto TREE_NB_COLUMNS = 1; |
|
11 | const auto TREE_NB_COLUMNS = 1; | |
12 |
|
12 | |||
13 | /// Header labels for the tree |
|
13 | /// Header labels for the tree | |
14 | const auto TREE_HEADER_LABELS = QStringList{QObject::tr("Name")}; |
|
14 | const auto TREE_HEADER_LABELS = QStringList{QObject::tr("Name")}; | |
15 |
|
15 | |||
16 | /** |
|
16 | /** | |
17 | * Creates the item associated to a data source |
|
17 | * Creates the item associated to a data source | |
18 | * @param dataSource the data source for which to create the item |
|
18 | * @param dataSource the data source for which to create the item | |
19 | * @return the new item |
|
19 | * @return the new item | |
20 | */ |
|
20 | */ | |
21 | DataSourceTreeWidgetItem *createTreeWidgetItem(DataSourceItem *dataSource) |
|
21 | DataSourceTreeWidgetItem *createTreeWidgetItem(DataSourceItem *dataSource) | |
22 | { |
|
22 | { | |
23 | // Creates item for the data source |
|
23 | // Creates item for the data source | |
24 | auto item = new DataSourceTreeWidgetItem{dataSource}; |
|
24 | auto item = new DataSourceTreeWidgetItem{dataSource}; | |
25 |
|
25 | |||
26 | // Generates items for the children of the data source |
|
26 | // Generates items for the children of the data source | |
27 | for (auto i = 0; i < dataSource->childCount(); ++i) { |
|
27 | for (auto i = 0; i < dataSource->childCount(); ++i) { | |
28 | item->addChild(createTreeWidgetItem(dataSource->child(i))); |
|
28 | item->addChild(createTreeWidgetItem(dataSource->child(i))); | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | return item; |
|
31 | return item; | |
32 | } |
|
32 | } | |
33 |
|
33 | |||
34 | } // namespace |
|
34 | } // namespace | |
35 |
|
35 | |||
36 | class DataSourceWidget::DataSourceWidgetPrivate { |
|
36 | class DataSourceWidget::DataSourceWidgetPrivate { | |
37 | public: |
|
37 | public: | |
38 | explicit DataSourceWidgetPrivate(DataSourceWidget &widget) |
|
38 | explicit DataSourceWidgetPrivate(DataSourceWidget &widget) | |
39 | : m_Ui{std::make_unique<Ui::DataSourceWidget>()} |
|
39 | : m_Ui{std::make_unique<Ui::DataSourceWidget>()} | |
40 | { |
|
40 | { | |
41 | m_Ui->setupUi(&widget); |
|
41 | m_Ui->setupUi(&widget); | |
42 |
|
42 | |||
43 | // Set tree properties |
|
43 | // Set tree properties | |
44 | m_Ui->treeWidget->setColumnCount(TREE_NB_COLUMNS); |
|
44 | m_Ui->treeWidget->setColumnCount(TREE_NB_COLUMNS); | |
45 | m_Ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS); |
|
45 | m_Ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS); | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | std::unique_ptr<Ui::DataSourceWidget> m_Ui; |
|
48 | std::unique_ptr<Ui::DataSourceWidget> m_Ui; | |
49 | }; |
|
49 | }; | |
50 |
|
50 | |||
51 | DataSourceWidget::DataSourceWidget(QWidget *parent) |
|
51 | DataSourceWidget::DataSourceWidget(QWidget *parent) | |
52 | : QWidget{parent}, impl{spimpl::make_unique_impl<DataSourceWidgetPrivate>(*this)} |
|
52 | : QWidget{parent}, impl{spimpl::make_unique_impl<DataSourceWidgetPrivate>(*this)} | |
53 | { |
|
53 | { | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 |
void DataSourceWidget::addDataSource(DataSourceItem |
|
56 | void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept | |
57 | { |
|
57 | { | |
58 | // Creates the item associated to the source and adds it to the tree widget. The tree widget |
|
58 | // Creates the item associated to the source and adds it to the tree widget. The tree widget | |
59 | // takes the ownership of the item |
|
59 | // takes the ownership of the item | |
60 | impl->m_Ui->treeWidget->addTopLevelItem(createTreeWidgetItem(&dataSource)); |
|
60 | if (dataSource) { | |
|
61 | impl->m_Ui->treeWidget->addTopLevelItem(createTreeWidgetItem(dataSource)); | |||
|
62 | } | |||
61 | } |
|
63 | } |
General Comments 3
Pull request updated. Auto status change to "Under Review"
Changed commits: * 6 added * 3 removed Changed files: * A gui/src/Visualization/VisualizationWidget.cpp * A gui/include/SidePane/SqpSidePane.h * A gui/include/Visualization/VisualizationGraphWidget.h * A gui/include/Visualization/VisualizationTabWidget.h * A gui/include/Visualization/VisualizationWidget.h * A gui/include/Visualization/VisualizationZoneWidget.h * A gui/include/Visualization/qcustomplot.h * A gui/src/SidePane/SqpSidePane.cpp * A gui/src/Visualization/VisualizationGraphWidget.cpp * A gui/src/Visualization/VisualizationTabWidget.cpp * A gui/src/Visualization/VisualizationZoneWidget.cpp * A gui/src/Visualization/qcustomplot.cpp * M gui/include/DataSource/DataSourceWidget.h * M gui/src/DataSource/DataSourceTreeWidgetItem.cpp * M gui/src/DataSource/DataSourceWidget.cpp * M app/src/Main.cpp * M app/src/MainWindow.cpp * M app/ui/MainWindow.ui * M core/include/DataSource/DataSourceController.h * M core/src/DataSource/DataSourceController.cpp * M core/tests/DataSource/TestDataSourceController.cpp * M gui/ui/visualization/VisualizationWidget.ui * M gui/vera-exclusions/exclusions.txt * M gui/src/visualization/VisualizationWidget.cpp * R cmake/sciqlop_package_qt.cmake * R core/include/Plugin/PluginManager.h * R core/include/Visualization/VisualizationController.h * R core/src/Plugin/PluginManager.cpp * R core/src/Visualization/VisualizationController.cpp * R gui/include/sidepane/SqpSidePane.h * R gui/include/visualization/VisualizationGraphWidget.h * R gui/include/visualization/VisualizationTabWidget.h * R gui/include/visualization/VisualizationWidget.h * R gui/include/visualization/VisualizationZoneWidget.h * R gui/include/visualization/qcustomplot.h * R gui/src/sidepane/SqpSidePane.cpp * R gui/src/visualization/VisualizationGraphWidget.cpp * R gui/src/visualization/VisualizationTabWidget.cpp * R gui/src/visualization/VisualizationZoneWidget.cpp * R gui/src/visualization/qcustomplot.cpp * R gui/ui/sidepane/SqpSidePane.ui * R gui/ui/visualization/VisualizationGraphWidget.ui * R gui/ui/visualization/VisualizationTabWidget.ui * R gui/ui/visualization/VisualizationZoneWidget.ui * R plugin/CMakeLists.txt * R plugin/cmake/Findsciqlop-plugin.cmake * R plugin/include/Plugin/IPlugin.h * R app/CMakeLists.txt * R app/include/MainWindow.h * R app/vera-exclusions/exclusions.txt * R cmake/sciqlop_applications.cmake * R core/CMakeLists.txt * R core/include/Common/spimpl.h * R gui/CMakeLists.txt * R gui/include/SqpApplication.h * R gui/src/SqpApplication.cpp * R app/src/mainwindow.ui
Status change > Approved
You need to be logged in to leave comments.
Login now