From 74e2e6e57838eb18f732040de4fc4dce180b93f2 2017-12-20 13:21:03 From: Thibaud Rabillard Date: 2017-12-20 13:21:03 Subject: [PATCH] Use correct product ID when creating an event --- diff --git a/core/include/DataSource/DataSourceItem.h b/core/include/DataSource/DataSourceItem.h index 9b82471..b872ce6 100644 --- a/core/include/DataSource/DataSourceItem.h +++ b/core/include/DataSource/DataSourceItem.h @@ -27,6 +27,8 @@ public: static const QString NAME_DATA_KEY; /// Key associated with the plugin of the item static const QString PLUGIN_DATA_KEY; + /// Key associated with a unique id of the plugin + static const QString ID_DATA_KEY; explicit DataSourceItem(DataSourceItemType type, const QString &name); explicit DataSourceItem(DataSourceItemType type, QVariantHash data = {}); diff --git a/core/src/DataSource/DataSourceItem.cpp b/core/src/DataSource/DataSourceItem.cpp index 39d6599..86730d3 100644 --- a/core/src/DataSource/DataSourceItem.cpp +++ b/core/src/DataSource/DataSourceItem.cpp @@ -6,6 +6,7 @@ const QString DataSourceItem::NAME_DATA_KEY = QStringLiteral("name"); const QString DataSourceItem::PLUGIN_DATA_KEY = QStringLiteral("plugin"); +const QString DataSourceItem::ID_DATA_KEY = QStringLiteral("uuid"); struct DataSourceItem::DataSourceItemPrivate { explicit DataSourceItemPrivate(DataSourceItemType type, QVariantHash data) diff --git a/gui/src/Catalogue/CatalogueActionManager.cpp b/gui/src/Catalogue/CatalogueActionManager.cpp index 6fd2785..7d57039 100644 --- a/gui/src/Catalogue/CatalogueActionManager.cpp +++ b/gui/src/Catalogue/CatalogueActionManager.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -50,7 +51,8 @@ struct CatalogueActionManager::CatalogueActionManagerPrivate { eventProduct->setTStart(zoneRange.m_TStart); eventProduct->setTEnd(zoneRange.m_TEnd); - eventProduct->setProductId(var->metadata().value("id", "TODO").toString()); // todo + eventProduct->setProductId( + var->metadata().value(DataSourceItem::ID_DATA_KEY, "UnknownID").toString()); productList.push_back(*eventProduct); } diff --git a/plugins/amda/src/AmdaPlugin.cpp b/plugins/amda/src/AmdaPlugin.cpp index 85c51a6..9e32132 100644 --- a/plugins/amda/src/AmdaPlugin.cpp +++ b/plugins/amda/src/AmdaPlugin.cpp @@ -37,6 +37,7 @@ void associateActions(DataSourceItem &item, const QUuid &dataSourceUid) auto actionLabel = QObject::tr( itemType == DataSourceItemType::PRODUCT ? "Load %1 product" : "Load %1 component"); addLoadAction(actionLabel.arg(item.name())); + item.setData(DataSourceItem::ID_DATA_KEY, item.data(AMDA_XML_ID_KEY)); } auto count = item.childCount(); diff --git a/plugins/mockplugin/src/MockPlugin.cpp b/plugins/mockplugin/src/MockPlugin.cpp index 88e7e0a..a3813c8 100644 --- a/plugins/mockplugin/src/MockPlugin.cpp +++ b/plugins/mockplugin/src/MockPlugin.cpp @@ -28,6 +28,7 @@ std::unique_ptr createProductItem(const QVariantHash &data, // Adds plugin name to product metadata result->setData(DataSourceItem::PLUGIN_DATA_KEY, DATA_SOURCE_NAME); + result->setData(DataSourceItem::ID_DATA_KEY, data.value(DataSourceItem::NAME_DATA_KEY)); auto productName = data.value(DataSourceItem::NAME_DATA_KEY).toString();