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