@@ -18,10 +18,6 class MockPlugin : public QObject, public IPlugin { | |||
|
18 | 18 | public: |
|
19 | 19 | /// @sa IPlugin::initialize() |
|
20 | 20 | void initialize() override; |
|
21 | ||
|
22 | private: | |
|
23 | /// Creates the data source item relative to the plugin | |
|
24 | std::unique_ptr<DataSourceItem> createDataSourceItem() const noexcept; | |
|
25 | 21 | }; |
|
26 | 22 | |
|
27 | 23 | #endif // SCIQLOP_MOCKPLUGIN_H |
@@ -1,4 +1,5 | |||
|
1 |
#include |
|
|
1 | #include "MockPlugin.h" | |
|
2 | #include "CosinusProvider.h" | |
|
2 | 3 | |
|
3 | 4 | #include <DataSource/DataSourceController.h> |
|
4 | 5 | #include <DataSource/DataSourceItem.h> |
@@ -12,23 +13,14 namespace { | |||
|
12 | 13 | /// Name of the data source |
|
13 | 14 | const auto DATA_SOURCE_NAME = QStringLiteral("MMS"); |
|
14 | 15 | |
|
15 | } // namespace | |
|
16 | ||
|
17 | void MockPlugin::initialize() | |
|
16 | /// Creates the data provider relative to the plugin | |
|
17 | std::unique_ptr<IDataProvider> createDataProvider() noexcept | |
|
18 | 18 | { |
|
19 | if (auto app = sqpApp) { | |
|
20 | // Registers to the data source controller | |
|
21 | auto &dataSourceController = app->dataSourceController(); | |
|
22 | auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME); | |
|
23 | ||
|
24 | dataSourceController.setDataSourceItem(dataSourceUid, createDataSourceItem()); | |
|
25 | } | |
|
26 | else { | |
|
27 | qCWarning(LOG_MockPlugin()) << tr("Can't access to SciQlop application"); | |
|
28 | } | |
|
19 | return std::make_unique<CosinusProvider>(); | |
|
29 | 20 | } |
|
30 | 21 | |
|
31 | std::unique_ptr<DataSourceItem> MockPlugin::createDataSourceItem() const noexcept | |
|
22 | /// Creates the data source item relative to the plugin | |
|
23 | std::unique_ptr<DataSourceItem> createDataSourceItem() noexcept | |
|
32 | 24 | { |
|
33 | 25 | // Magnetic field products |
|
34 | 26 | auto fgmProduct = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, |
@@ -51,5 +43,25 std::unique_ptr<DataSourceItem> MockPlugin::createDataSourceItem() const noexcep | |||
|
51 | 43 | root->appendChild(std::move(magneticFieldFolder)); |
|
52 | 44 | root->appendChild(std::move(electricFieldFolder)); |
|
53 | 45 | |
|
54 |
return |
|
|
46 | return root; | |
|
47 | } | |
|
48 | ||
|
49 | } // namespace | |
|
50 | ||
|
51 | void MockPlugin::initialize() | |
|
52 | { | |
|
53 | if (auto app = sqpApp) { | |
|
54 | // Registers to the data source controller | |
|
55 | auto &dataSourceController = app->dataSourceController(); | |
|
56 | auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME); | |
|
57 | ||
|
58 | // Sets data source tree | |
|
59 | dataSourceController.setDataSourceItem(dataSourceUid, createDataSourceItem()); | |
|
60 | ||
|
61 | // Sets data provider | |
|
62 | dataSourceController.setDataProvider(dataSourceUid, createDataProvider()); | |
|
63 | } | |
|
64 | else { | |
|
65 | qCWarning(LOG_MockPlugin()) << tr("Can't access to SciQlop application"); | |
|
66 | } | |
|
55 | 67 | } |
General Comments 0
You need to be logged in to leave comments.
Login now