##// END OF EJS Templates
Merge pull request 154 from SCIQLOP-Initialisation feature/VariableModel3...
leroux -
r172:5fabd31f0a85 merge
parent child
Show More
@@ -0,0 +1,43
1 #include "Variable/Variable.h"
2
3 #include <Data/IDataSeries.h>
4
5 struct Variable::VariablePrivate {
6 explicit VariablePrivate(const QString &name, const QString &unit, const QString &mission)
7 : m_Name{name}, m_Unit{unit}, m_Mission{mission}, m_DataSeries{nullptr}
8 {
9 }
10
11 QString m_Name;
12 QString m_Unit;
13 QString m_Mission;
14 std::unique_ptr<IDataSeries> m_DataSeries;
15 };
16
17 Variable::Variable(const QString &name, const QString &unit, const QString &mission)
18 : impl{spimpl::make_unique_impl<VariablePrivate>(name, unit, mission)}
19 {
20 }
21
22 QString Variable::name() const noexcept
23 {
24 return impl->m_Name;
25 }
26
27 QString Variable::mission() const noexcept
28 {
29 return impl->m_Mission;
30 }
31
32 QString Variable::unit() const noexcept
33 {
34 return impl->m_Unit;
35 }
36
37 void Variable::addDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept
38 {
39 if (!impl->m_DataSeries) {
40 impl->m_DataSeries = std::move(dataSeries);
41 }
42 /// @todo : else, merge the two data series (if possible)
43 }
@@ -21,7 +21,7 INCLUDE("cmake/sciqlop_params.cmake")
21 #
21 #
22 # Configure the compiler
22 # Configure the compiler
23 #
23 #
24 INCLUDE("cmake/compiler/compiler.cmake")
24 #INCLUDE("cmake/compiler/compiler.cmake")
25
25
26 #
26 #
27 # Find all necessary dependencies
27 # Find all necessary dependencies
@@ -7,7 +7,7 SET(WINDEPLOYQT_ARGS --${CMAKE_BUILD_TYPE_TO_LOWER} --list mapping --no-system-d
7 #ENDFOREACH()
7 #ENDFOREACH()
8
8
9 EXECUTE_PROCESS(
9 EXECUTE_PROCESS(
10 COMMAND windeployqt ${WINDEPLOYQT_ARGS} ${SCIQLOP_EXE_LOCATION}
10 COMMAND windeployqt ${WINDEPLOYQT_ARGS} -printsupport ${SCIQLOP_EXE_LOCATION}
11 OUTPUT_VARIABLE QT_FILES
11 OUTPUT_VARIABLE QT_FILES
12 )
12 )
13
13
@@ -3,6 +3,8
3
3
4 #include <memory>
4 #include <memory>
5
5
6 #include <QObject>
7
6 class DataProviderParameters;
8 class DataProviderParameters;
7 class IDataSeries;
9 class IDataSeries;
8
10
@@ -22,4 +24,7 public:
22 retrieveData(const DataProviderParameters &parameters) const = 0;
24 retrieveData(const DataProviderParameters &parameters) const = 0;
23 };
25 };
24
26
27 // Required for using shared_ptr in signals/slots
28 Q_DECLARE_METATYPE(std::shared_ptr<IDataProvider>)
29
25 #endif // SCIQLOP_IDATAPROVIDER_H
30 #endif // SCIQLOP_IDATAPROVIDER_H
@@ -56,9 +56,11 public:
56
56
57 /**
57 /**
58 * Loads an item (product) as a variable in SciQlop
58 * Loads an item (product) as a variable in SciQlop
59 * @param dataSourceUid the unique id of the data source containing the item. It is used to get
60 * the data provider associated to the data source, and pass it to for the variable creation
59 * @param productItem the item to load
61 * @param productItem the item to load
60 */
62 */
61 void loadProductItem(const DataSourceItem &productItem) noexcept;
63 void loadProductItem(const QUuid &dataSourceUid, const DataSourceItem &productItem) noexcept;
62
64
63 public slots:
65 public slots:
64 /// Manage init/end of the controller
66 /// Manage init/end of the controller
@@ -69,6 +71,15 signals:
69 /// Signal emitted when a structure has been set for a data source
71 /// Signal emitted when a structure has been set for a data source
70 void dataSourceItemSet(DataSourceItem *dataSourceItem);
72 void dataSourceItemSet(DataSourceItem *dataSourceItem);
71
73
74 /**
75 * Signal emitted when a variable creation is asked for a product
76 * @param variableName the name of the variable
77 * @param variableProvider the provider that will be used to retrieve the data of the variable
78 * (can be null)
79 */
80 void variableCreationRequested(const QString &variableName,
81 std::shared_ptr<IDataProvider> variableProvider);
82
72 private:
83 private:
73 void waitForFinish();
84 void waitForFinish();
74
85
@@ -1,20 +1,32
1 #ifndef SCIQLOP_VARIABLE_H
1 #ifndef SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
3
3
4 #include <QString>
4 #include <Common/spimpl.h>
5
6 #include <QObject>
7
8 class IDataSeries;
9 class QString;
5
10
6 /**
11 /**
7 * @brief The Variable struct represents a variable in SciQlop.
12 * @brief The Variable class represents a variable in SciQlop.
8 */
13 */
9 struct Variable {
14 class Variable {
10 explicit Variable(const QString &name, const QString &unit, const QString &mission)
15 public:
11 : m_Name{name}, m_Unit{unit}, m_Mission{mission}
16 explicit Variable(const QString &name, const QString &unit, const QString &mission);
12 {
17
13 }
18 QString name() const noexcept;
14
19 QString mission() const noexcept;
15 QString m_Name;
20 QString unit() const noexcept;
16 QString m_Unit;
21
17 QString m_Mission;
22 void addDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept;
23
24 private:
25 class VariablePrivate;
26 spimpl::unique_impl_ptr<VariablePrivate> impl;
18 };
27 };
19
28
29 // Required for using shared_ptr in signals/slots
30 Q_DECLARE_METATYPE(std::shared_ptr<Variable>)
31
20 #endif // SCIQLOP_VARIABLE_H
32 #endif // SCIQLOP_VARIABLE_H
@@ -6,6 +6,7
6
6
7 #include <Common/spimpl.h>
7 #include <Common/spimpl.h>
8
8
9 class IDataProvider;
9 class Variable;
10 class Variable;
10 class VariableModel;
11 class VariableModel;
11
12
@@ -20,16 +21,20 public:
20 explicit VariableController(QObject *parent = 0);
21 explicit VariableController(QObject *parent = 0);
21 virtual ~VariableController();
22 virtual ~VariableController();
22
23
24 VariableModel *variableModel() noexcept;
25
26 signals:
27 /// Signal emitted when a variable has been created
28 void variableCreated(std::shared_ptr<Variable> variable);
29
30 public slots:
23 /**
31 /**
24 * Creates a new variable
32 * Creates a new variable and adds it to the model
25 * @param name the name of the new variable
33 * @param name the name of the new variable
26 * @return the variable if it was created successfully, nullptr otherwise
34 * @param provider the data provider for the new variable
27 */
35 */
28 Variable *createVariable(const QString &name) noexcept;
36 void createVariable(const QString &name, std::shared_ptr<IDataProvider> provider) noexcept;
29
37
30 VariableModel *variableModel() noexcept;
31
32 public slots:
33 void initialize();
38 void initialize();
34 void finalize();
39 void finalize();
35
40
@@ -8,6 +8,7
8
8
9 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
9 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
10
10
11 class IDataSeries;
11 class Variable;
12 class Variable;
12
13
13 /**
14 /**
@@ -20,9 +21,11 public:
20 /**
21 /**
21 * Creates a new variable in the model
22 * Creates a new variable in the model
22 * @param name the name of the new variable
23 * @param name the name of the new variable
23 * @return the variable if it was created successfully, nullptr otherwise
24 * @param defaultDataSeries the default data of the new variable
25 * @return the pointer to the new variable
24 */
26 */
25 Variable *createVariable(const QString &name) noexcept;
27 std::shared_ptr<Variable>
28 createVariable(const QString &name, std::unique_ptr<IDataSeries> defaultDataSeries) noexcept;
26
29
27 // /////////////////////////// //
30 // /////////////////////////// //
28 // QAbstractTableModel methods //
31 // QAbstractTableModel methods //
@@ -10,6 +10,7
10 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationController)
10 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationController)
11
11
12 class DataSourceItem;
12 class DataSourceItem;
13 class Variable;
13
14
14 /**
15 /**
15 * @brief The VisualizationController class aims to make the link between SciQlop and its plugins.
16 * @brief The VisualizationController class aims to make the link between SciQlop and its plugins.
@@ -25,6 +26,9 public:
25 virtual ~VisualizationController();
26 virtual ~VisualizationController();
26
27
27 public slots:
28 public slots:
29 /// Slot called when a variable has been created in SciQlop
30 void onVariableCreated(std::shared_ptr<Variable> variable) noexcept;
31
28 /// Manage init/end of the controller
32 /// Manage init/end of the controller
29 void initialize();
33 void initialize();
30 void finalize();
34 void finalize();
@@ -1,5 +1,5
1 #include <DataSource/DataSourceController.h>
1 #include "DataSource/DataSourceController.h"
2 #include <DataSource/DataSourceItem.h>
2 #include "DataSource/DataSourceItem.h"
3
3
4 #include <Data/IDataProvider.h>
4 #include <Data/IDataProvider.h>
5
5
@@ -19,7 +19,9 public:
19 /// Data sources structures
19 /// Data sources structures
20 std::map<QUuid, std::unique_ptr<DataSourceItem> > m_DataSourceItems;
20 std::map<QUuid, std::unique_ptr<DataSourceItem> > m_DataSourceItems;
21 /// Data providers registered
21 /// Data providers registered
22 std::map<QUuid, std::unique_ptr<IDataProvider> > m_DataProviders;
22 /// @remarks Data providers are stored as shared_ptr as they can be sent to a variable and
23 /// continue to live without necessarily the data source controller
24 std::map<QUuid, std::shared_ptr<IDataProvider> > m_DataProviders;
23 };
25 };
24
26
25 DataSourceController::DataSourceController(QObject *parent)
27 DataSourceController::DataSourceController(QObject *parent)
@@ -48,6 +50,7 void DataSourceController::setDataSourceItem(
48 const QUuid &dataSourceUid, std::unique_ptr<DataSourceItem> dataSourceItem) noexcept
50 const QUuid &dataSourceUid, std::unique_ptr<DataSourceItem> dataSourceItem) noexcept
49 {
51 {
50 if (impl->m_DataSources.contains(dataSourceUid)) {
52 if (impl->m_DataSources.contains(dataSourceUid)) {
53 // The data provider is implicitly converted to a shared_ptr
51 impl->m_DataSourceItems.insert(std::make_pair(dataSourceUid, std::move(dataSourceItem)));
54 impl->m_DataSourceItems.insert(std::make_pair(dataSourceUid, std::move(dataSourceItem)));
52
55
53 // Retrieves the data source item to emit the signal with it
56 // Retrieves the data source item to emit the signal with it
@@ -76,9 +79,20 void DataSourceController::setDataProvider(const QUuid &dataSourceUid,
76 }
79 }
77 }
80 }
78
81
79 void DataSourceController::loadProductItem(const DataSourceItem &productItem) noexcept
82 void DataSourceController::loadProductItem(const QUuid &dataSourceUid,
83 const DataSourceItem &productItem) noexcept
80 {
84 {
81 /// @todo ALX
85 if (productItem.type() == DataSourceItemType::PRODUCT) {
86 /// Retrieves the data provider of the data source (if any)
87 auto it = impl->m_DataProviders.find(dataSourceUid);
88 auto dataProvider = (it != impl->m_DataProviders.end()) ? it->second : nullptr;
89
90 /// @todo retrieve timerange, and pass it to the signal
91 emit variableCreationRequested(productItem.name(), dataProvider);
92 }
93 else {
94 qCWarning(LOG_DataSourceController()) << tr("Can't load an item that is not a product");
95 }
82 }
96 }
83
97
84 void DataSourceController::initialize()
98 void DataSourceController::initialize()
@@ -30,7 +30,7 DataSourceItem::DataSourceItem(DataSourceItemType type, QVector<QVariant> data)
30
30
31 QVector<DataSourceItemAction *> DataSourceItem::actions() const noexcept
31 QVector<DataSourceItemAction *> DataSourceItem::actions() const noexcept
32 {
32 {
33 QVector<DataSourceItemAction *> result{};
33 auto result = QVector<DataSourceItemAction *>{};
34
34
35 std::transform(std::cbegin(impl->m_Actions), std::cend(impl->m_Actions),
35 std::transform(std::cbegin(impl->m_Actions), std::cend(impl->m_Actions),
36 std::back_inserter(result), [](const auto &action) { return action.get(); });
36 std::back_inserter(result), [](const auto &action) { return action.get(); });
@@ -1,11 +1,34
1 #include <Variable/VariableController.h>
1 #include <Variable/VariableController.h>
2 #include <Variable/VariableModel.h>
2 #include <Variable/VariableModel.h>
3
3
4 #include <Data/DataProviderParameters.h>
5 #include <Data/IDataProvider.h>
6 #include <Data/IDataSeries.h>
7
8 #include <QDateTime>
4 #include <QMutex>
9 #include <QMutex>
5 #include <QThread>
10 #include <QThread>
6
11
7 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
12 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
8
13
14 namespace {
15
16 /// @todo Generates default dataseries, according to the provider passed in parameter. This method
17 /// will be deleted when the timerange is recovered from SciQlop
18 std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider) noexcept
19 {
20 auto parameters = DataProviderParameters{
21 // Remarks : we don't use toSecsSinceEpoch() here (method is for Qt 5.8 or above)
22 static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 00}}.toMSecsSinceEpoch()
23 / 1000.),
24 static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 01}}.toMSecsSinceEpoch())
25 / 1000.};
26
27 return provider.retrieveData(parameters);
28 }
29
30 } // namespace
31
9 struct VariableController::VariableControllerPrivate {
32 struct VariableController::VariableControllerPrivate {
10 explicit VariableControllerPrivate(VariableController *parent)
33 explicit VariableControllerPrivate(VariableController *parent)
11 : m_WorkingMutex{}, m_VariableModel{new VariableModel{parent}}
34 : m_WorkingMutex{}, m_VariableModel{new VariableModel{parent}}
@@ -31,14 +54,23 VariableController::~VariableController()
31 this->waitForFinish();
54 this->waitForFinish();
32 }
55 }
33
56
34 Variable *VariableController::createVariable(const QString &name) noexcept
57 VariableModel *VariableController::variableModel() noexcept
35 {
58 {
36 return impl->m_VariableModel->createVariable(name);
59 return impl->m_VariableModel;
37 }
60 }
38
61
39 VariableModel *VariableController::variableModel() noexcept
62 void VariableController::createVariable(const QString &name,
63 std::shared_ptr<IDataProvider> provider) noexcept
40 {
64 {
41 return impl->m_VariableModel;
65 /// @todo : for the moment :
66 /// - the provider is only used to retrieve data from the variable for its initialization, but
67 /// it will be retained later
68 /// - default data are generated for the variable, without taking into account the timerange set
69 /// in sciqlop
70 if (auto newVariable
71 = impl->m_VariableModel->createVariable(name, generateDefaultDataSeries(*provider))) {
72 emit variableCreated(newVariable);
73 }
42 }
74 }
43
75
44 void VariableController::initialize()
76 void VariableController::initialize()
@@ -1,6 +1,7
1 #include <Variable/Variable.h>
1 #include <Variable/VariableModel.h>
2 #include <Variable/VariableModel.h>
2
3
3 #include <Variable/Variable.h>
4 #include <Data/IDataSeries.h>
4
5
5 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
6 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
6
7
@@ -16,7 +17,7 const auto NB_COLUMNS = 3;
16
17
17 struct VariableModel::VariableModelPrivate {
18 struct VariableModel::VariableModelPrivate {
18 /// Variables created in SciQlop
19 /// Variables created in SciQlop
19 std::vector<std::unique_ptr<Variable> > m_Variables;
20 std::vector<std::shared_ptr<Variable> > m_Variables;
20 };
21 };
21
22
22 VariableModel::VariableModel(QObject *parent)
23 VariableModel::VariableModel(QObject *parent)
@@ -24,19 +25,23 VariableModel::VariableModel(QObject *parent)
24 {
25 {
25 }
26 }
26
27
27 Variable *VariableModel::createVariable(const QString &name) noexcept
28 std::shared_ptr<Variable>
29 VariableModel::createVariable(const QString &name,
30 std::unique_ptr<IDataSeries> defaultDataSeries) noexcept
28 {
31 {
29 auto insertIndex = rowCount();
32 auto insertIndex = rowCount();
30 beginInsertRows({}, insertIndex, insertIndex);
33 beginInsertRows({}, insertIndex, insertIndex);
31
34
32 /// @todo For the moment, the other data of the variable is initialized with default values
35 /// @todo For the moment, the other data of the variable is initialized with default values
33 auto variable
36 auto variable
34 = std::make_unique<Variable>(name, QStringLiteral("unit"), QStringLiteral("mission"));
37 = std::make_shared<Variable>(name, QStringLiteral("unit"), QStringLiteral("mission"));
35 impl->m_Variables.push_back(std::move(variable));
38 variable->addDataSeries(std::move(defaultDataSeries));
39
40 impl->m_Variables.push_back(variable);
36
41
37 endInsertRows();
42 endInsertRows();
38
43
39 return impl->m_Variables.at(insertIndex).get();
44 return variable;
40 }
45 }
41
46
42 int VariableModel::columnCount(const QModelIndex &parent) const
47 int VariableModel::columnCount(const QModelIndex &parent) const
@@ -67,11 +72,11 QVariant VariableModel::data(const QModelIndex &index, int role) const
67 if (auto variable = impl->m_Variables.at(index.row()).get()) {
72 if (auto variable = impl->m_Variables.at(index.row()).get()) {
68 switch (index.column()) {
73 switch (index.column()) {
69 case NAME_COLUMN:
74 case NAME_COLUMN:
70 return variable->m_Name;
75 return variable->name();
71 case UNIT_COLUMN:
76 case UNIT_COLUMN:
72 return variable->m_Unit;
77 return variable->unit();
73 case MISSION_COLUMN:
78 case MISSION_COLUMN:
74 return variable->m_Mission;
79 return variable->mission();
75 default:
80 default:
76 // No action
81 // No action
77 break;
82 break;
@@ -1,5 +1,7
1 #include <Visualization/VisualizationController.h>
1 #include <Visualization/VisualizationController.h>
2
2
3 #include <Variable/Variable.h>
4
3 #include <QMutex>
5 #include <QMutex>
4 #include <QThread>
6 #include <QThread>
5
7
@@ -27,6 +29,12 VisualizationController::~VisualizationController()
27 this->waitForFinish();
29 this->waitForFinish();
28 }
30 }
29
31
32 void VisualizationController::onVariableCreated(std::shared_ptr<Variable> variable) noexcept
33 {
34 /// @todo ALX : make new graph for the variable
35 qCDebug(LOG_VisualizationController()) << "new variable to display";
36 }
37
30 void VisualizationController::initialize()
38 void VisualizationController::initialize()
31 {
39 {
32 qCDebug(LOG_VisualizationController()) << tr("VisualizationController init")
40 qCDebug(LOG_VisualizationController()) << tr("VisualizationController init")
@@ -11,3 +11,6 ArrayData\.h:\d+:.*IPSIS_S06.*found: (Dim)
11
11
12 # Ignore false positive relative to an alias
12 # Ignore false positive relative to an alias
13 DataSourceItemAction\.h:\d+:.*IPSIS_S06.*found: (ExecuteFunction)
13 DataSourceItemAction\.h:\d+:.*IPSIS_S06.*found: (ExecuteFunction)
14
15 # Ignore false positive relative to unnamed namespace
16 VariableController\.cpp:\d+:.*IPSIS_F13.*
@@ -1,7 +1,9
1 #include "SqpApplication.h"
1 #include "SqpApplication.h"
2
2
3 #include <Data/IDataProvider.h>
3 #include <DataSource/DataSourceController.h>
4 #include <DataSource/DataSourceController.h>
4 #include <QThread>
5 #include <QThread>
6 #include <Variable/Variable.h>
5 #include <Variable/VariableController.h>
7 #include <Variable/VariableController.h>
6 #include <Visualization/VisualizationController.h>
8 #include <Visualization/VisualizationController.h>
7
9
@@ -14,6 +16,23 public:
14 m_VariableController{std::make_unique<VariableController>()},
16 m_VariableController{std::make_unique<VariableController>()},
15 m_VisualizationController{std::make_unique<VisualizationController>()}
17 m_VisualizationController{std::make_unique<VisualizationController>()}
16 {
18 {
19 // /////////////////////////////// //
20 // Connections between controllers //
21 // /////////////////////////////// //
22
23 // VariableController <-> DataSourceController
24 qRegisterMetaType<std::shared_ptr<IDataProvider> >();
25 connect(m_DataSourceController.get(),
26 SIGNAL(variableCreationRequested(const QString &, std::shared_ptr<IDataProvider>)),
27 m_VariableController.get(),
28 SLOT(createVariable(const QString &, std::shared_ptr<IDataProvider>)));
29
30 // VariableController <-> VisualizationController
31 qRegisterMetaType<std::shared_ptr<Variable> >();
32 connect(m_VariableController.get(), SIGNAL(variableCreated(std::shared_ptr<Variable>)),
33 m_VisualizationController.get(),
34 SLOT(onVariableCreated(std::shared_ptr<Variable>)));
35
17 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
36 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
18 m_VariableController->moveToThread(&m_VariableControllerThread);
37 m_VariableController->moveToThread(&m_VariableControllerThread);
19 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
38 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
@@ -61,7 +80,6 SqpApplication::SqpApplication(int &argc, char **argv)
61 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
80 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
62 impl->m_VisualizationController.get(), &VisualizationController::finalize);
81 impl->m_VisualizationController.get(), &VisualizationController::finalize);
63
82
64
65 impl->m_DataSourceControllerThread.start();
83 impl->m_DataSourceControllerThread.start();
66 impl->m_VariableControllerThread.start();
84 impl->m_VariableControllerThread.start();
67 impl->m_VisualizationControllerThread.start();
85 impl->m_VisualizationControllerThread.start();
@@ -20,16 +20,18 std::unique_ptr<IDataProvider> createDataProvider() noexcept
20 return std::make_unique<CosinusProvider>();
20 return std::make_unique<CosinusProvider>();
21 }
21 }
22
22
23 std::unique_ptr<DataSourceItem> createProductItem(const QString &productName)
23 std::unique_ptr<DataSourceItem> createProductItem(const QString &productName,
24 const QUuid &dataSourceUid)
24 {
25 {
25 auto result = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
26 auto result = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
26 QVector<QVariant>{productName});
27 QVector<QVariant>{productName});
27
28
28 // Add action to load product from DataSourceController
29 // Add action to load product from DataSourceController
29 result->addAction(std::make_unique<DataSourceItemAction>(
30 result->addAction(std::make_unique<DataSourceItemAction>(
30 QObject::tr("Load %1 product").arg(productName), [productName](DataSourceItem &item) {
31 QObject::tr("Load %1 product").arg(productName),
32 [productName, dataSourceUid](DataSourceItem &item) {
31 if (auto app = sqpApp) {
33 if (auto app = sqpApp) {
32 app->dataSourceController().loadProductItem(item);
34 app->dataSourceController().loadProductItem(dataSourceUid, item);
33 }
35 }
34 }));
36 }));
35
37
@@ -37,13 +39,13 std::unique_ptr<DataSourceItem> createProductItem(const QString &productName)
37 }
39 }
38
40
39 /// Creates the data source item relative to the plugin
41 /// Creates the data source item relative to the plugin
40 std::unique_ptr<DataSourceItem> createDataSourceItem() noexcept
42 std::unique_ptr<DataSourceItem> createDataSourceItem(const QUuid &dataSourceUid) noexcept
41 {
43 {
42 // Magnetic field products
44 // Magnetic field products
43 auto magneticFieldFolder = std::make_unique<DataSourceItem>(
45 auto magneticFieldFolder = std::make_unique<DataSourceItem>(
44 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Magnetic field")});
46 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Magnetic field")});
45 magneticFieldFolder->appendChild(createProductItem(QStringLiteral("FGM")));
47 magneticFieldFolder->appendChild(createProductItem(QStringLiteral("FGM"), dataSourceUid));
46 magneticFieldFolder->appendChild(createProductItem(QStringLiteral("SC")));
48 magneticFieldFolder->appendChild(createProductItem(QStringLiteral("SC"), dataSourceUid));
47
49
48 // Electric field products
50 // Electric field products
49 auto electricFieldFolder = std::make_unique<DataSourceItem>(
51 auto electricFieldFolder = std::make_unique<DataSourceItem>(
@@ -68,7 +70,7 void MockPlugin::initialize()
68 auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME);
70 auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME);
69
71
70 // Sets data source tree
72 // Sets data source tree
71 dataSourceController.setDataSourceItem(dataSourceUid, createDataSourceItem());
73 dataSourceController.setDataSourceItem(dataSourceUid, createDataSourceItem(dataSourceUid));
72
74
73 // Sets data provider
75 // Sets data provider
74 dataSourceController.setDataProvider(dataSourceUid, createDataProvider());
76 dataSourceController.setDataProvider(dataSourceUid, createDataProvider());
General Comments 0
You need to be logged in to leave comments. Login now