@@ -2,6 +2,7 | |||||
2 | #include "AmdaDefs.h" |
|
2 | #include "AmdaDefs.h" | |
3 | #include "AmdaParser.h" |
|
3 | #include "AmdaParser.h" | |
4 | #include "AmdaProvider.h" |
|
4 | #include "AmdaProvider.h" | |
|
5 | #include "AmdaServer.h" | |||
5 |
|
6 | |||
6 | #include <DataSource/DataSourceController.h> |
|
7 | #include <DataSource/DataSourceController.h> | |
7 | #include <DataSource/DataSourceItem.h> |
|
8 | #include <DataSource/DataSourceItem.h> | |
@@ -13,9 +14,6 Q_LOGGING_CATEGORY(LOG_AmdaPlugin, "AmdaPlugin") | |||||
13 |
|
14 | |||
14 | namespace { |
|
15 | namespace { | |
15 |
|
16 | |||
16 | /// Name of the data source |
|
|||
17 | const auto DATA_SOURCE_NAME = QStringLiteral("AMDA"); |
|
|||
18 |
|
||||
19 | /// Path of the file used to generate the data source item for AMDA |
|
17 | /// Path of the file used to generate the data source item for AMDA | |
20 | const auto JSON_FILE_PATH = QStringLiteral(":/samples/AmdaSampleV3.json"); |
|
18 | const auto JSON_FILE_PATH = QStringLiteral(":/samples/AmdaSampleV3.json"); | |
21 |
|
19 | |||
@@ -33,7 +31,7 void associateActions(DataSourceItem &item, const QUuid &dataSourceUid) | |||||
33 | const auto itemType = item.type(); |
|
31 | const auto itemType = item.type(); | |
34 | if (itemType == DataSourceItemType::PRODUCT || itemType == DataSourceItemType::COMPONENT) { |
|
32 | if (itemType == DataSourceItemType::PRODUCT || itemType == DataSourceItemType::COMPONENT) { | |
35 | // Adds plugin name to item metadata |
|
33 | // Adds plugin name to item metadata | |
36 |
item.setData(DataSourceItem::PLUGIN_DATA_KEY, |
|
34 | item.setData(DataSourceItem::PLUGIN_DATA_KEY, AmdaServer::instance().name()); | |
37 |
|
35 | |||
38 | // Adds load action |
|
36 | // Adds load action | |
39 | auto actionLabel = QObject::tr( |
|
37 | auto actionLabel = QObject::tr( | |
@@ -54,14 +52,17 void associateActions(DataSourceItem &item, const QUuid &dataSourceUid) | |||||
54 | void AmdaPlugin::initialize() |
|
52 | void AmdaPlugin::initialize() | |
55 | { |
|
53 | { | |
56 | if (auto app = sqpApp) { |
|
54 | if (auto app = sqpApp) { | |
|
55 | auto dataSourceName = AmdaServer::instance().name(); | |||
|
56 | ||||
57 | // Registers to the data source controller |
|
57 | // Registers to the data source controller | |
58 | auto &dataSourceController = app->dataSourceController(); |
|
58 | auto &dataSourceController = app->dataSourceController(); | |
59 |
auto dataSourceUid = dataSourceController.registerDataSource( |
|
59 | auto dataSourceUid = dataSourceController.registerDataSource(dataSourceName); | |
60 |
|
60 | |||
61 | // Sets data source tree |
|
61 | // Sets data source tree | |
62 | if (auto dataSourceItem = AmdaParser::readJson(JSON_FILE_PATH)) { |
|
62 | if (auto dataSourceItem = AmdaParser::readJson(JSON_FILE_PATH)) { | |
63 | associateActions(*dataSourceItem, dataSourceUid); |
|
63 | dataSourceItem->setData(DataSourceItem::NAME_DATA_KEY, dataSourceName); | |
64 |
|
64 | |||
|
65 | associateActions(*dataSourceItem, dataSourceUid); | |||
65 | dataSourceController.setDataSourceItem(dataSourceUid, std::move(dataSourceItem)); |
|
66 | dataSourceController.setDataSourceItem(dataSourceUid, std::move(dataSourceItem)); | |
66 | } |
|
67 | } | |
67 | else { |
|
68 | else { |
General Comments 0
You need to be logged in to leave comments.
Login now