##// END OF EJS Templates
Connects data source widget to data source controller
Alexandre Leroux -
r84:05a4d7964d8e
parent child
Show More
@@ -1,118 +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
25 #include <DataSource/DataSourceController.h>
26 #include <DataSource/DataSourceWidget.h>
27 #include <SqpApplication.h>
28
24 #include <QAction>
29 #include <QAction>
25 #include <QDate>
30 #include <QDate>
26 #include <QDateTime>
31 #include <QDateTime>
27 #include <QDir>
32 #include <QDir>
28 #include <QFileDialog>
33 #include <QFileDialog>
29 //#include <omp.h>
34 //#include <omp.h>
30 //#include <network/filedownloader.h>
35 //#include <network/filedownloader.h>
31 //#include <qlopdatabase.h>
36 //#include <qlopdatabase.h>
32 //#include <qlopsettings.h>
37 //#include <qlopsettings.h>
33 //#include <qlopgui.h>
38 //#include <qlopgui.h>
34 //#include <spacedata.h>
39 //#include <spacedata.h>
35 //#include "qlopcore.h"
40 //#include "qlopcore.h"
36 //#include "qlopcodecmanager.h"
41 //#include "qlopcodecmanager.h"
37 //#include "cdfcodec.h"
42 //#include "cdfcodec.h"
38 //#include "amdatxtcodec.h"
43 //#include "amdatxtcodec.h"
39 //#include <qlopplotmanager.h>
44 //#include <qlopplotmanager.h>
40 #include <QAction>
45 #include <QAction>
41 #include <QToolBar>
46 #include <QToolBar>
42 #include <memory.h>
47 #include <memory.h>
43 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_Ui(new Ui::MainWindow)
48 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_Ui(new Ui::MainWindow)
44 {
49 {
45 m_Ui->setupUi(this);
50 m_Ui->setupUi(this);
46
51
47 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
52 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
48 leftSidePane->addAction("ACTION L1");
53 leftSidePane->addAction("ACTION L1");
49 leftSidePane->addAction("ACTION L2");
54 leftSidePane->addAction("ACTION L2");
50 leftSidePane->addAction("ACTION L3");
55 leftSidePane->addAction("ACTION L3");
51
56
52 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
57 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
53 rightSidePane->addAction("ACTION R1");
58 rightSidePane->addAction("ACTION R1");
54 rightSidePane->addAction("ACTION R2");
59 rightSidePane->addAction("ACTION R2");
55 rightSidePane->addAction("ACTION R3");
60 rightSidePane->addAction("ACTION R3");
56
61
57 this->menuBar()->addAction("File");
62 this->menuBar()->addAction("File");
58 auto mainToolBar = this->addToolBar("MainToolBar");
63 auto mainToolBar = this->addToolBar("MainToolBar");
59 mainToolBar->addAction("A1");
64 mainToolBar->addAction("A1");
65
66 // Widgets / controllers connections
67 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem &)),
68 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem &)));
69
60 /* QLopGUI::registerMenuBar(menuBar());
70 /* QLopGUI::registerMenuBar(menuBar());
61 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
71 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
62 this->m_progressWidget = new QWidget();
72 this->m_progressWidget = new QWidget();
63 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
73 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
64 this->m_progressWidget->setLayout(this->m_progressLayout);
74 this->m_progressWidget->setLayout(this->m_progressLayout);
65 this->m_progressWidget->setWindowModality(Qt::WindowModal);
75 this->m_progressWidget->setWindowModality(Qt::WindowModal);
66 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
76 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
67 for(int i=0;i<OMP_THREADS;i++)
77 for(int i=0;i<OMP_THREADS;i++)
68 {
78 {
69 this->m_progress.append(new QProgressBar(this->m_progressWidget));
79 this->m_progress.append(new QProgressBar(this->m_progressWidget));
70 this->m_progress.last()->setMinimum(0);
80 this->m_progress.last()->setMinimum(0);
71 this->m_progress.last()->setMaximum(100);
81 this->m_progress.last()->setMaximum(100);
72 this->m_progressLayout->addWidget(this->m_progress.last());
82 this->m_progressLayout->addWidget(this->m_progress.last());
73 this->m_progressWidget->hide();
83 this->m_progressWidget->hide();
74 this->m_progressThreadIds[i] = -1;
84 this->m_progressThreadIds[i] = -1;
75 }
85 }
76 this->m_progressWidget->setWindowTitle("Loading File");
86 this->m_progressWidget->setWindowTitle("Loading File");
77 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
87 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
78 << QLopCore::self()
88 << QLopCore::self()
79 << QLopPlotManager::self()
89 << QLopPlotManager::self()
80 << QLopCodecManager::self()
90 << QLopCodecManager::self()
81 << FileDownloader::self()
91 << FileDownloader::self()
82 << QLopDataBase::self()
92 << QLopDataBase::self()
83 << SpaceData::self();
93 << SpaceData::self();
84
94
85 CDFCodec::registerToManager();
95 CDFCodec::registerToManager();
86 AMDATXTCodec::registerToManager();
96 AMDATXTCodec::registerToManager();
87
97
88
98
89 for(int i=0;i<ServicesToLoad.count();i++)
99 for(int i=0;i<ServicesToLoad.count();i++)
90 {
100 {
91 qDebug()<<ServicesToLoad.at(i)->serviceName();
101 qDebug()<<ServicesToLoad.at(i)->serviceName();
92 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
102 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
93 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
103 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
94 if(wdgt)
104 if(wdgt)
95 {
105 {
96 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
106 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
97 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
107 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
98 }
108 }
99 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));
100 }*/
110 }*/
101 }
111 }
102
112
103 MainWindow::~MainWindow()
113 MainWindow::~MainWindow()
104 {
114 {
105 }
115 }
106
116
107
117
108 void MainWindow::changeEvent(QEvent *e)
118 void MainWindow::changeEvent(QEvent *e)
109 {
119 {
110 QMainWindow::changeEvent(e);
120 QMainWindow::changeEvent(e);
111 switch (e->type()) {
121 switch (e->type()) {
112 case QEvent::LanguageChange:
122 case QEvent::LanguageChange:
113 m_Ui->retranslateUi(this);
123 m_Ui->retranslateUi(this);
114 break;
124 break;
115 default:
125 default:
116 break;
126 break;
117 }
127 }
118 }
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(const DataSourceItem &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
General Comments 0
You need to be logged in to leave comments. Login now