##// END OF EJS Templates
Amda provider update (3)...
Alexandre Leroux -
r414:4f3a3edcd1d8
parent child
Show More
@@ -88,7 +88,8 void DataSourceController::setDataProvider(const QUuid &dataSourceUid,
88 void DataSourceController::loadProductItem(const QUuid &dataSourceUid,
88 void DataSourceController::loadProductItem(const QUuid &dataSourceUid,
89 const DataSourceItem &productItem) noexcept
89 const DataSourceItem &productItem) noexcept
90 {
90 {
91 if (productItem.type() == DataSourceItemType::PRODUCT) {
91 if (productItem.type() == DataSourceItemType::PRODUCT
92 || productItem.type() == DataSourceItemType::COMPONENT) {
92 /// Retrieves the data provider of the data source (if any)
93 /// Retrieves the data provider of the data source (if any)
93 auto it = impl->m_DataProviders.find(dataSourceUid);
94 auto it = impl->m_DataProviders.find(dataSourceUid);
94 auto dataProvider = (it != impl->m_DataProviders.end()) ? it->second : nullptr;
95 auto dataProvider = (it != impl->m_DataProviders.end()) ? it->second : nullptr;
@@ -20,16 +20,21 const auto JSON_FILE_PATH = QStringLiteral(":/samples/AmdaSample.json");
20
20
21 void associateActions(DataSourceItem &item, const QUuid &dataSourceUid)
21 void associateActions(DataSourceItem &item, const QUuid &dataSourceUid)
22 {
22 {
23 if (item.type() == DataSourceItemType::PRODUCT) {
23 auto addLoadAction = [&item, dataSourceUid](const QString &label) {
24 auto itemName = item.name();
24 item.addAction(
25
25 std::make_unique<DataSourceItemAction>(label, [dataSourceUid](DataSourceItem &item) {
26 item.addAction(std::make_unique<DataSourceItemAction>(
27 QObject::tr("Load %1 product").arg(itemName),
28 [itemName, dataSourceUid](DataSourceItem &item) {
29 if (auto app = sqpApp) {
26 if (auto app = sqpApp) {
30 app->dataSourceController().loadProductItem(dataSourceUid, item);
27 app->dataSourceController().loadProductItem(dataSourceUid, item);
31 }
28 }
32 }));
29 }));
30 };
31
32 const auto itemType = item.type();
33 if (itemType == DataSourceItemType::PRODUCT) {
34 addLoadAction(QObject::tr("Load %1 product").arg(item.name()));
35 }
36 else if (itemType == DataSourceItemType::COMPONENT) {
37 addLoadAction(QObject::tr("Load %1 component").arg(item.name()));
33 }
38 }
34
39
35 auto count = item.childCount();
40 auto count = item.childCount();
General Comments 0
You need to be logged in to leave comments. Login now