##// END OF EJS Templates
Merge pull request 146 from SCIQLOP-Initialisation develop...
leroux -
r117:27ad8f53ca07 merge
parent child
Show More
@@ -0,0 +1,20
1 #ifndef SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
3
4 #include <QString>
5
6 /**
7 * @brief The Variable struct represents a variable in SciQlop.
8 */
9 struct Variable {
10 explicit Variable(const QString &name, const QString &unit, const QString &mission)
11 : m_Name{name}, m_Unit{unit}, m_Mission{mission}
12 {
13 }
14
15 QString m_Name;
16 QString m_Unit;
17 QString m_Mission;
18 };
19
20 #endif // SCIQLOP_VARIABLE_H
@@ -0,0 +1,39
1 #ifndef SCIQLOP_VARIABLECONTROLLER_H
2 #define SCIQLOP_VARIABLECONTROLLER_H
3
4 #include <QLoggingCategory>
5 #include <QObject>
6
7 #include <Common/spimpl.h>
8
9 class Variable;
10 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableController)
11
12 /**
13 * @brief The VariableController class aims to handle the variables in SciQlop.
14 */
15 class VariableController : public QObject {
16 Q_OBJECT
17 public:
18 explicit VariableController(QObject *parent = 0);
19 virtual ~VariableController();
20
21 /**
22 * Creates a new variable
23 * @param name the name of the new variable
24 * @return the variable if it was created successfully, nullptr otherwise
25 */
26 Variable *createVariable(const QString &name) noexcept;
27
28 public slots:
29 void initialize();
30 void finalize();
31
32 private:
33 void waitForFinish();
34
35 class VariableControllerPrivate;
36 spimpl::unique_impl_ptr<VariableControllerPrivate> impl;
37 };
38
39 #endif // SCIQLOP_VARIABLECONTROLLER_H
@@ -0,0 +1,31
1 #ifndef SCIQLOP_VARIABLEMODEL_H
2 #define SCIQLOP_VARIABLEMODEL_H
3
4 #include <Common/spimpl.h>
5
6 #include <QLoggingCategory>
7
8 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
9
10 class Variable;
11
12 /**
13 * @brief The VariableModel class aims to hold the variables that have been created in SciQlop
14 */
15 class VariableModel {
16 public:
17 explicit VariableModel();
18
19 /**
20 * Creates a new variable in the model
21 * @param name the name of the new variable
22 * @return the variable if it was created successfully, nullptr otherwise
23 */
24 Variable *createVariable(const QString &name) noexcept;
25
26 private:
27 class VariableModelPrivate;
28 spimpl::unique_impl_ptr<VariableModelPrivate> impl;
29 };
30
31 #endif // SCIQLOP_VARIABLEMODEL_H
@@ -0,0 +1,53
1 #include <Variable/VariableController.h>
2 #include <Variable/VariableModel.h>
3
4 #include <QMutex>
5 #include <QThread>
6
7 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
8
9 struct VariableController::VariableControllerPrivate {
10 explicit VariableControllerPrivate()
11 : m_WorkingMutex{}, m_VariableModel{std::make_unique<VariableModel>()}
12 {
13 }
14
15 QMutex m_WorkingMutex;
16 std::unique_ptr<VariableModel> m_VariableModel;
17 };
18
19 VariableController::VariableController(QObject *parent)
20 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>()}
21 {
22 qCDebug(LOG_VariableController())
23 << tr("VariableController construction") << QThread::currentThread();
24 }
25
26 VariableController::~VariableController()
27 {
28 qCDebug(LOG_VariableController())
29 << tr("VariableController destruction") << QThread::currentThread();
30 this->waitForFinish();
31 }
32
33 Variable *VariableController::createVariable(const QString &name) noexcept
34 {
35 return impl->m_VariableModel->createVariable(name);
36 }
37
38 void VariableController::initialize()
39 {
40 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
41 impl->m_WorkingMutex.lock();
42 qCDebug(LOG_VariableController()) << tr("VariableController init END");
43 }
44
45 void VariableController::finalize()
46 {
47 impl->m_WorkingMutex.unlock();
48 }
49
50 void VariableController::waitForFinish()
51 {
52 QMutexLocker locker{&impl->m_WorkingMutex};
53 }
@@ -0,0 +1,24
1 #include <Variable/VariableModel.h>
2
3 #include <Variable/Variable.h>
4
5 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
6
7 struct VariableModel::VariableModelPrivate {
8 /// Variables created in SciQlop
9 std::vector<std::unique_ptr<Variable> > m_Variables;
10 };
11
12 VariableModel::VariableModel() : impl{spimpl::make_unique_impl<VariableModelPrivate>()}
13 {
14 }
15
16 Variable *VariableModel::createVariable(const QString &name) noexcept
17 {
18 /// @todo For the moment, the other data of the variable is initialized with default values
19 auto variable
20 = std::make_unique<Variable>(name, QStringLiteral("unit"), QStringLiteral("mission"));
21 impl->m_Variables.push_back(std::move(variable));
22
23 return impl->m_Variables.back().get();
24 }
@@ -0,0 +1,26
1 #ifndef SCIQLOP_VARIABLEINSPECTORWIDGET_H
2 #define SCIQLOP_VARIABLEINSPECTORWIDGET_H
3
4 #include <QWidget>
5
6 namespace Ui {
7 class VariableInspectorWidget;
8 } // Ui
9
10 /**
11 * @brief The VariableInspectorWidget class representes represents the variable inspector, from
12 * which it is possible to view the loaded variables, handle them or trigger their display in
13 * visualization
14 */
15 class VariableInspectorWidget : public QWidget {
16 Q_OBJECT
17
18 public:
19 explicit VariableInspectorWidget(QWidget *parent = 0);
20 virtual ~VariableInspectorWidget();
21
22 private:
23 Ui::VariableInspectorWidget *ui;
24 };
25
26 #endif // SCIQLOP_VARIABLEINSPECTORWIDGET_H
@@ -0,0 +1,14
1 #include <Variable/VariableInspectorWidget.h>
2
3 #include <ui_VariableInspectorWidget.h>
4
5 VariableInspectorWidget::VariableInspectorWidget(QWidget *parent)
6 : QWidget{parent}, ui{new Ui::VariableInspectorWidget}
7 {
8 ui->setupUi(this);
9 }
10
11 VariableInspectorWidget::~VariableInspectorWidget()
12 {
13 delete ui;
14 }
@@ -0,0 +1,31
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>VariableInspectorWidget</class>
4 <widget class="QWidget" name="VariableInspectorWidget">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>400</width>
10 <height>300</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Variables</string>
15 </property>
16 <layout class="QGridLayout" name="gridLayout">
17 <item row="0" column="0">
18 <widget class="QTableView" name="tableView">
19 <property name="sortingEnabled">
20 <bool>true</bool>
21 </property>
22 <attribute name="horizontalHeaderStretchLastSection">
23 <bool>true</bool>
24 </attribute>
25 </widget>
26 </item>
27 </layout>
28 </widget>
29 <resources/>
30 <connections/>
31 </ui>
@@ -1,158 +1,164
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
2 <ui version="4.0">
3 <class>MainWindow</class>
3 <class>MainWindow</class>
4 <widget class="QMainWindow" name="MainWindow">
4 <widget class="QMainWindow" name="MainWindow">
5 <property name="geometry">
5 <property name="geometry">
6 <rect>
6 <rect>
7 <x>0</x>
7 <x>0</x>
8 <y>0</y>
8 <y>0</y>
9 <width>800</width>
9 <width>800</width>
10 <height>600</height>
10 <height>600</height>
11 </rect>
11 </rect>
12 </property>
12 </property>
13 <property name="windowTitle">
13 <property name="windowTitle">
14 <string>QLop</string>
14 <string>QLop</string>
15 </property>
15 </property>
16 <property name="dockNestingEnabled">
16 <property name="dockNestingEnabled">
17 <bool>true</bool>
17 <bool>true</bool>
18 </property>
18 </property>
19 <widget class="QWidget" name="centralWidget">
19 <widget class="QWidget" name="centralWidget">
20 <property name="enabled">
20 <property name="enabled">
21 <bool>true</bool>
21 <bool>true</bool>
22 </property>
22 </property>
23 <property name="sizePolicy">
23 <property name="sizePolicy">
24 <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
24 <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
25 <horstretch>0</horstretch>
25 <horstretch>0</horstretch>
26 <verstretch>0</verstretch>
26 <verstretch>0</verstretch>
27 </sizepolicy>
27 </sizepolicy>
28 </property>
28 </property>
29 <property name="maximumSize">
29 <property name="maximumSize">
30 <size>
30 <size>
31 <width>16777215</width>
31 <width>16777215</width>
32 <height>16777215</height>
32 <height>16777215</height>
33 </size>
33 </size>
34 </property>
34 </property>
35 <layout class="QHBoxLayout" name="horizontalLayout">
35 <layout class="QHBoxLayout" name="horizontalLayout">
36 <property name="spacing">
36 <property name="spacing">
37 <number>0</number>
37 <number>0</number>
38 </property>
38 </property>
39 <property name="leftMargin">
39 <property name="leftMargin">
40 <number>0</number>
40 <number>0</number>
41 </property>
41 </property>
42 <property name="topMargin">
42 <property name="topMargin">
43 <number>0</number>
43 <number>0</number>
44 </property>
44 </property>
45 <property name="rightMargin">
45 <property name="rightMargin">
46 <number>0</number>
46 <number>0</number>
47 </property>
47 </property>
48 <property name="bottomMargin">
48 <property name="bottomMargin">
49 <number>0</number>
49 <number>0</number>
50 </property>
50 </property>
51 <item>
51 <item>
52 <widget class="QSplitter" name="splitter">
52 <widget class="QSplitter" name="splitter">
53 <property name="orientation">
53 <property name="orientation">
54 <enum>Qt::Horizontal</enum>
54 <enum>Qt::Horizontal</enum>
55 </property>
55 </property>
56 <widget class="QWidget" name="leftMainInspectorWidget" native="true">
56 <widget class="QWidget" name="leftMainInspectorWidget" native="true">
57 <layout class="QVBoxLayout" name="verticalLayout">
57 <layout class="QVBoxLayout" name="verticalLayout">
58 <property name="spacing">
58 <property name="spacing">
59 <number>0</number>
59 <number>0</number>
60 </property>
60 </property>
61 <property name="leftMargin">
61 <property name="leftMargin">
62 <number>0</number>
62 <number>0</number>
63 </property>
63 </property>
64 <property name="topMargin">
64 <property name="topMargin">
65 <number>0</number>
65 <number>0</number>
66 </property>
66 </property>
67 <property name="rightMargin">
67 <property name="rightMargin">
68 <number>0</number>
68 <number>0</number>
69 </property>
69 </property>
70 <property name="bottomMargin">
70 <property name="bottomMargin">
71 <number>0</number>
71 <number>0</number>
72 </property>
72 </property>
73 <item>
73 <item>
74 <widget class="DataSourceWidget" name="dataSourceWidget" native="true"/>
74 <widget class="DataSourceWidget" name="dataSourceWidget" native="true"/>
75 </item>
75 </item>
76 <item>
76 <item>
77 <widget class="QWidget" name="dateTimeWidget" native="true"/>
77 <widget class="QWidget" name="dateTimeWidget" native="true"/>
78 </item>
78 </item>
79 <item>
79 <item>
80 <widget class="QWidget" name="variableInspectorWidget" native="true"/>
80 <widget class="VariableInspectorWidget" name="variableInspectorWidget" native="true"/>
81 </item>
81 </item>
82 </layout>
82 </layout>
83 </widget>
83 </widget>
84 <widget class="SqpSidePane" name="leftInspectorSidePane" native="true"/>
84 <widget class="SqpSidePane" name="leftInspectorSidePane" native="true"/>
85 <widget class="VisualizationWidget" name="view" native="true">
85 <widget class="VisualizationWidget" name="view" native="true">
86 <property name="sizePolicy">
86 <property name="sizePolicy">
87 <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
87 <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
88 <horstretch>0</horstretch>
88 <horstretch>0</horstretch>
89 <verstretch>0</verstretch>
89 <verstretch>0</verstretch>
90 </sizepolicy>
90 </sizepolicy>
91 </property>
91 </property>
92 </widget>
92 </widget>
93 <widget class="SqpSidePane" name="rightInspectorSidePane" native="true"/>
93 <widget class="SqpSidePane" name="rightInspectorSidePane" native="true"/>
94 <widget class="QWidget" name="rightMainInspectorWidget" native="true">
94 <widget class="QWidget" name="rightMainInspectorWidget" native="true">
95 <layout class="QVBoxLayout" name="verticalLayout_3">
95 <layout class="QVBoxLayout" name="verticalLayout_3">
96 <property name="spacing">
96 <property name="spacing">
97 <number>0</number>
97 <number>0</number>
98 </property>
98 </property>
99 <property name="leftMargin">
99 <property name="leftMargin">
100 <number>0</number>
100 <number>0</number>
101 </property>
101 </property>
102 <property name="topMargin">
102 <property name="topMargin">
103 <number>0</number>
103 <number>0</number>
104 </property>
104 </property>
105 <property name="rightMargin">
105 <property name="rightMargin">
106 <number>0</number>
106 <number>0</number>
107 </property>
107 </property>
108 <property name="bottomMargin">
108 <property name="bottomMargin">
109 <number>0</number>
109 <number>0</number>
110 </property>
110 </property>
111 <item>
111 <item>
112 <widget class="QWidget" name="commonPropertyInspectorWidget" native="true"/>
112 <widget class="QWidget" name="commonPropertyInspectorWidget" native="true"/>
113 </item>
113 </item>
114 <item>
114 <item>
115 <widget class="DataSourceWidget" name="catalogWidget" native="true"/>
115 <widget class="DataSourceWidget" name="catalogWidget" native="true"/>
116 </item>
116 </item>
117 </layout>
117 </layout>
118 </widget>
118 </widget>
119 </widget>
119 </widget>
120 </item>
120 </item>
121 </layout>
121 </layout>
122 </widget>
122 </widget>
123 <widget class="QMenuBar" name="menuBar">
123 <widget class="QMenuBar" name="menuBar">
124 <property name="geometry">
124 <property name="geometry">
125 <rect>
125 <rect>
126 <x>0</x>
126 <x>0</x>
127 <y>0</y>
127 <y>0</y>
128 <width>800</width>
128 <width>800</width>
129 <height>28</height>
129 <height>26</height>
130 </rect>
130 </rect>
131 </property>
131 </property>
132 </widget>
132 </widget>
133 <widget class="QStatusBar" name="statusBar"/>
133 <widget class="QStatusBar" name="statusBar"/>
134 </widget>
134 </widget>
135 <layoutdefault spacing="6" margin="11"/>
135 <layoutdefault spacing="6" margin="11"/>
136 <customwidgets>
136 <customwidgets>
137 <customwidget>
137 <customwidget>
138 <class>VisualizationWidget</class>
138 <class>VisualizationWidget</class>
139 <extends>QWidget</extends>
139 <extends>QWidget</extends>
140 <header location="global">Visualization/VisualizationWidget.h</header>
140 <header location="global">Visualization/VisualizationWidget.h</header>
141 <container>1</container>
141 <container>1</container>
142 </customwidget>
142 </customwidget>
143 <customwidget>
143 <customwidget>
144 <class>SqpSidePane</class>
144 <class>SqpSidePane</class>
145 <extends>QWidget</extends>
145 <extends>QWidget</extends>
146 <header location="global">SidePane/SqpSidePane.h</header>
146 <header location="global">SidePane/SqpSidePane.h</header>
147 <container>1</container>
147 <container>1</container>
148 </customwidget>
148 </customwidget>
149 <customwidget>
149 <customwidget>
150 <class>DataSourceWidget</class>
150 <class>DataSourceWidget</class>
151 <extends>QWidget</extends>
151 <extends>QWidget</extends>
152 <header location="global">DataSource/DataSourceWidget.h</header>
152 <header location="global">DataSource/DataSourceWidget.h</header>
153 <container>1</container>
153 <container>1</container>
154 </customwidget>
154 </customwidget>
155 <customwidget>
156 <class>VariableInspectorWidget</class>
157 <extends>QWidget</extends>
158 <header location="global">Variable/VariableInspectorWidget.h</header>
159 <container>1</container>
160 </customwidget>
155 </customwidgets>
161 </customwidgets>
156 <resources/>
162 <resources/>
157 <connections/>
163 <connections/>
158 </ui>
164 </ui>
@@ -1,33 +1,34
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>
5
6 #include <QWidget>
4 #include <QWidget>
7
5
6 namespace Ui {
7 class DataSourceWidget;
8 } // Ui
9
8 class DataSourceItem;
10 class DataSourceItem;
9
11
10 /**
12 /**
11 * @brief The DataSourceWidget handles the graphical representation (as a tree) of the data sources
13 * @brief The DataSourceWidget handles the graphical representation (as a tree) of the data sources
12 * attached to SciQlop.
14 * attached to SciQlop.
13 */
15 */
14 class DataSourceWidget : public QWidget {
16 class DataSourceWidget : public QWidget {
15 Q_OBJECT
17 Q_OBJECT
16
18
17 public:
19 public:
18 explicit DataSourceWidget(QWidget *parent = 0);
20 explicit DataSourceWidget(QWidget *parent = 0);
19
21
20 public slots:
22 public slots:
21 /**
23 /**
22 * Adds a data source. An item associated to the data source is created and then added to the
24 * Adds a data source. An item associated to the data source is created and then added to the
23 * representation tree
25 * representation tree
24 * @param dataSource the data source to add. The pointer has to be not null
26 * @param dataSource the data source to add. The pointer has to be not null
25 */
27 */
26 void addDataSource(DataSourceItem *dataSource) noexcept;
28 void addDataSource(DataSourceItem *dataSource) noexcept;
27
29
28 private:
30 private:
29 class DataSourceWidgetPrivate;
31 Ui::DataSourceWidget *ui;
30 spimpl::unique_impl_ptr<DataSourceWidgetPrivate> impl;
31 };
32 };
32
33
33 #endif // SCIQLOP_DATASOURCEWIDGET_H
34 #endif // SCIQLOP_DATASOURCEWIDGET_H
@@ -1,46 +1,48
1 #ifndef SCIQLOP_SQPAPPLICATION_H
1 #ifndef SCIQLOP_SQPAPPLICATION_H
2 #define SCIQLOP_SQPAPPLICATION_H
2 #define SCIQLOP_SQPAPPLICATION_H
3
3
4 #include "SqpApplication.h"
4 #include "SqpApplication.h"
5
5
6 #include <QApplication>
6 #include <QApplication>
7 #include <QLoggingCategory>
7 #include <QLoggingCategory>
8
8
9 #include <Common/spimpl.h>
9 #include <Common/spimpl.h>
10
10
11 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
11 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
12
12
13 #if defined(sqpApp)
13 #if defined(sqpApp)
14 #undef sqpApp
14 #undef sqpApp
15 #endif
15 #endif
16 #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance()))
16 #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance()))
17
17
18 class DataSourceController;
18 class DataSourceController;
19 class VariableController;
19 class VisualizationController;
20 class VisualizationController;
20
21
21 /**
22 /**
22 * @brief The SqpApplication class aims to make the link between SciQlop
23 * @brief The SqpApplication class aims to make the link between SciQlop
23 * and its plugins. This is the intermediate class that SciQlop has to use
24 * and its plugins. This is the intermediate class that SciQlop has to use
24 * in the way to connect a data source. Please first use load method to initialize
25 * in the way to connect a data source. Please first use load method to initialize
25 * a plugin specified by its metadata name (JSON plugin source) then others specifics
26 * a plugin specified by its metadata name (JSON plugin source) then others specifics
26 * method will be able to access it.
27 * method will be able to access it.
27 * You can load a data source driver plugin then create a data source.
28 * You can load a data source driver plugin then create a data source.
28 */
29 */
29
30
30 class SqpApplication : public QApplication {
31 class SqpApplication : public QApplication {
31 Q_OBJECT
32 Q_OBJECT
32 public:
33 public:
33 explicit SqpApplication(int &argc, char **argv);
34 explicit SqpApplication(int &argc, char **argv);
34 virtual ~SqpApplication();
35 virtual ~SqpApplication();
35 void initialize();
36 void initialize();
36
37
37 /// Accessors for the differents sciqlop controllers
38 /// Accessors for the differents sciqlop controllers
38 DataSourceController &dataSourceController() const noexcept;
39 DataSourceController &dataSourceController() noexcept;
39 VisualizationController &visualizationController() const noexcept;
40 VariableController &variableController() noexcept;
41 VisualizationController &visualizationController() noexcept;
40
42
41 private:
43 private:
42 class SqpApplicationPrivate;
44 class SqpApplicationPrivate;
43 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
45 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
44 };
46 };
45
47
46 #endif // SCIQLOP_SQPAPPLICATION_H
48 #endif // SCIQLOP_SQPAPPLICATION_H
@@ -1,63 +1,52
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 DataSourceWidget::DataSourceWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::DataSourceWidget}
37 public:
38 explicit DataSourceWidgetPrivate(DataSourceWidget &widget)
39 : m_Ui{std::make_unique<Ui::DataSourceWidget>()}
40 {
37 {
41 m_Ui->setupUi(&widget);
38 ui->setupUi(this);
42
39
43 // Set tree properties
40 // Set tree properties
44 m_Ui->treeWidget->setColumnCount(TREE_NB_COLUMNS);
41 ui->treeWidget->setColumnCount(TREE_NB_COLUMNS);
45 m_Ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS);
42 ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS);
46 }
47
48 std::unique_ptr<Ui::DataSourceWidget> m_Ui;
49 };
50
51 DataSourceWidget::DataSourceWidget(QWidget *parent)
52 : QWidget{parent}, impl{spimpl::make_unique_impl<DataSourceWidgetPrivate>(*this)}
53 {
54 }
43 }
55
44
56 void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept
45 void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept
57 {
46 {
58 // Creates the item associated to the source and adds it to the tree widget. The tree widget
47 // Creates the item associated to the source and adds it to the tree widget. The tree widget
59 // takes the ownership of the item
48 // takes the ownership of the item
60 if (dataSource) {
49 if (dataSource) {
61 impl->m_Ui->treeWidget->addTopLevelItem(createTreeWidgetItem(dataSource));
50 ui->treeWidget->addTopLevelItem(createTreeWidgetItem(dataSource));
62 }
51 }
63 }
52 }
@@ -1,72 +1,91
1 #include "SqpApplication.h"
1 #include "SqpApplication.h"
2
2
3 #include <DataSource/DataSourceController.h>
3 #include <DataSource/DataSourceController.h>
4 #include <QThread>
4 #include <QThread>
5 #include <Variable/VariableController.h>
5 #include <Visualization/VisualizationController.h>
6 #include <Visualization/VisualizationController.h>
6
7
7 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
8 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
8
9
9 class SqpApplication::SqpApplicationPrivate {
10 class SqpApplication::SqpApplicationPrivate {
10 public:
11 public:
11 SqpApplicationPrivate()
12 SqpApplicationPrivate()
12 : m_DataSourceController{std::make_unique<DataSourceController>()},
13 : m_DataSourceController{std::make_unique<DataSourceController>()},
14 m_VariableController{std::make_unique<VariableController>()},
13 m_VisualizationController{std::make_unique<VisualizationController>()}
15 m_VisualizationController{std::make_unique<VisualizationController>()}
14 {
16 {
15 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
17 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
18 m_VariableController->moveToThread(&m_VariableControllerThread);
16 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
19 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
17 }
20 }
18
21
19 virtual ~SqpApplicationPrivate()
22 virtual ~SqpApplicationPrivate()
20 {
23 {
21 qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction");
24 qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction");
22 m_DataSourceControllerThread.quit();
25 m_DataSourceControllerThread.quit();
23 m_DataSourceControllerThread.wait();
26 m_DataSourceControllerThread.wait();
24
27
28 m_VariableControllerThread.quit();
29 m_VariableControllerThread.wait();
30
25 m_VisualizationControllerThread.quit();
31 m_VisualizationControllerThread.quit();
26 m_VisualizationControllerThread.wait();
32 m_VisualizationControllerThread.wait();
27 }
33 }
28
34
29 std::unique_ptr<DataSourceController> m_DataSourceController;
35 std::unique_ptr<DataSourceController> m_DataSourceController;
36 std::unique_ptr<VariableController> m_VariableController;
30 std::unique_ptr<VisualizationController> m_VisualizationController;
37 std::unique_ptr<VisualizationController> m_VisualizationController;
31 QThread m_DataSourceControllerThread;
38 QThread m_DataSourceControllerThread;
39 QThread m_VariableControllerThread;
32 QThread m_VisualizationControllerThread;
40 QThread m_VisualizationControllerThread;
33 };
41 };
34
42
35
43
36 SqpApplication::SqpApplication(int &argc, char **argv)
44 SqpApplication::SqpApplication(int &argc, char **argv)
37 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
45 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
38 {
46 {
39 qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction");
47 qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction");
40
48
41 connect(&impl->m_DataSourceControllerThread, &QThread::started,
49 connect(&impl->m_DataSourceControllerThread, &QThread::started,
42 impl->m_DataSourceController.get(), &DataSourceController::initialize);
50 impl->m_DataSourceController.get(), &DataSourceController::initialize);
43 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
51 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
44 impl->m_DataSourceController.get(), &DataSourceController::finalize);
52 impl->m_DataSourceController.get(), &DataSourceController::finalize);
45
53
54 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
55 &VariableController::initialize);
56 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
57 &VariableController::finalize);
58
46 connect(&impl->m_VisualizationControllerThread, &QThread::started,
59 connect(&impl->m_VisualizationControllerThread, &QThread::started,
47 impl->m_VisualizationController.get(), &VisualizationController::initialize);
60 impl->m_VisualizationController.get(), &VisualizationController::initialize);
48 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
61 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
49 impl->m_VisualizationController.get(), &VisualizationController::finalize);
62 impl->m_VisualizationController.get(), &VisualizationController::finalize);
50
63
51
64
52 impl->m_DataSourceControllerThread.start();
65 impl->m_DataSourceControllerThread.start();
66 impl->m_VariableControllerThread.start();
53 impl->m_VisualizationControllerThread.start();
67 impl->m_VisualizationControllerThread.start();
54 }
68 }
55
69
56 SqpApplication::~SqpApplication()
70 SqpApplication::~SqpApplication()
57 {
71 {
58 }
72 }
59
73
60 void SqpApplication::initialize()
74 void SqpApplication::initialize()
61 {
75 {
62 }
76 }
63
77
64 DataSourceController &SqpApplication::dataSourceController() const noexcept
78 DataSourceController &SqpApplication::dataSourceController() noexcept
65 {
79 {
66 return *impl->m_DataSourceController;
80 return *impl->m_DataSourceController;
67 }
81 }
68
82
69 VisualizationController &SqpApplication::visualizationController() const noexcept
83 VariableController &SqpApplication::variableController() noexcept
84 {
85 return *impl->m_VariableController;
86 }
87
88 VisualizationController &SqpApplication::visualizationController() noexcept
70 {
89 {
71 return *impl->m_VisualizationController;
90 return *impl->m_VisualizationController;
72 }
91 }
General Comments 0
You need to be logged in to leave comments. Login now