@@ -25,6 +25,8 class SCIQLOP_CORE_EXPORT DataSourceItem { | |||||
25 | public: |
|
25 | public: | |
26 | /// Key associated with the name of the item |
|
26 | /// Key associated with the name of the item | |
27 | static const QString NAME_DATA_KEY; |
|
27 | static const QString NAME_DATA_KEY; | |
|
28 | /// Key associated with the plugin of the item | |||
|
29 | static const QString PLUGIN_DATA_KEY; | |||
28 |
|
30 | |||
29 | explicit DataSourceItem(DataSourceItemType type, const QString &name); |
|
31 | explicit DataSourceItem(DataSourceItemType type, const QString &name); | |
30 | explicit DataSourceItem(DataSourceItemType type, QVariantHash data = {}); |
|
32 | explicit DataSourceItem(DataSourceItemType type, QVariantHash data = {}); |
@@ -12,28 +12,6 | |||||
12 |
|
12 | |||
13 | Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController") |
|
13 | Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController") | |
14 |
|
14 | |||
15 | namespace { |
|
|||
16 |
|
||||
17 | /** |
|
|||
18 | * Builds the metadata of the variable that will be generated from the loading of an item |
|
|||
19 | * @param dataSourceItem the data source item from which to generate the metadata |
|
|||
20 | * @return the metadata of the variable |
|
|||
21 | */ |
|
|||
22 | QVariantHash variableMetadata(const DataSourceItem &dataSourceItem) |
|
|||
23 | { |
|
|||
24 | // Variable metadata contains... |
|
|||
25 |
|
||||
26 | // ... all metadata of the item |
|
|||
27 | auto result = dataSourceItem.data(); |
|
|||
28 |
|
||||
29 | // ... and the name of the plugin, recovered from root item |
|
|||
30 | result.insert(QStringLiteral("plugin"), dataSourceItem.rootItem().name()); |
|
|||
31 |
|
||||
32 | return result; |
|
|||
33 | } |
|
|||
34 |
|
||||
35 | } // namespace |
|
|||
36 |
|
||||
37 | class DataSourceController::DataSourceControllerPrivate { |
|
15 | class DataSourceController::DataSourceControllerPrivate { | |
38 | public: |
|
16 | public: | |
39 | QMutex m_WorkingMutex; |
|
17 | QMutex m_WorkingMutex; | |
@@ -131,8 +109,7 void DataSourceController::loadProductItem(const QUuid &dataSourceUid, | |||||
131 | auto it = impl->m_DataProviders.find(dataSourceUid); |
|
109 | auto it = impl->m_DataProviders.find(dataSourceUid); | |
132 | auto dataProvider = (it != impl->m_DataProviders.end()) ? it->second : nullptr; |
|
110 | auto dataProvider = (it != impl->m_DataProviders.end()) ? it->second : nullptr; | |
133 |
|
111 | |||
134 |
emit variableCreationRequested(productItem.name(), |
|
112 | emit variableCreationRequested(productItem.name(), productItem.data(), dataProvider); | |
135 | dataProvider); |
|
|||
136 | } |
|
113 | } | |
137 | else { |
|
114 | else { | |
138 | qCWarning(LOG_DataSourceController()) << tr("Can't load an item that is not a product"); |
|
115 | qCWarning(LOG_DataSourceController()) << tr("Can't load an item that is not a product"); |
@@ -5,6 +5,7 | |||||
5 | #include <QVector> |
|
5 | #include <QVector> | |
6 |
|
6 | |||
7 | const QString DataSourceItem::NAME_DATA_KEY = QStringLiteral("name"); |
|
7 | const QString DataSourceItem::NAME_DATA_KEY = QStringLiteral("name"); | |
|
8 | const QString DataSourceItem::PLUGIN_DATA_KEY = QStringLiteral("plugin"); | |||
8 |
|
9 | |||
9 | struct DataSourceItem::DataSourceItemPrivate { |
|
10 | struct DataSourceItem::DataSourceItemPrivate { | |
10 | explicit DataSourceItemPrivate(DataSourceItemType type, QVariantHash data) |
|
11 | explicit DataSourceItemPrivate(DataSourceItemType type, QVariantHash data) |
@@ -31,11 +31,14 void associateActions(DataSourceItem &item, const QUuid &dataSourceUid) | |||||
31 | }; |
|
31 | }; | |
32 |
|
32 | |||
33 | const auto itemType = item.type(); |
|
33 | const auto itemType = item.type(); | |
34 | if (itemType == DataSourceItemType::PRODUCT) { |
|
34 | if (itemType == DataSourceItemType::PRODUCT || itemType == DataSourceItemType::COMPONENT) { | |
35 | addLoadAction(QObject::tr("Load %1 product").arg(item.name())); |
|
35 | // Adds plugin name to item metadata | |
36 | } |
|
36 | item.setData(DataSourceItem::PLUGIN_DATA_KEY, DATA_SOURCE_NAME); | |
37 | else if (itemType == DataSourceItemType::COMPONENT) { |
|
37 | ||
38 | addLoadAction(QObject::tr("Load %1 component").arg(item.name())); |
|
38 | // Adds load action | |
|
39 | auto actionLabel = QObject::tr( | |||
|
40 | itemType == DataSourceItemType::PRODUCT ? "Load %1 product" : "Load %1 component"); | |||
|
41 | addLoadAction(actionLabel.arg(item.name())); | |||
39 | } |
|
42 | } | |
40 |
|
43 | |||
41 | auto count = item.childCount(); |
|
44 | auto count = item.childCount(); |
@@ -25,6 +25,10 std::unique_ptr<DataSourceItem> createProductItem(const QVariantHash &data, | |||||
25 | const QUuid &dataSourceUid) |
|
25 | const QUuid &dataSourceUid) | |
26 | { |
|
26 | { | |
27 | auto result = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, data); |
|
27 | auto result = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, data); | |
|
28 | ||||
|
29 | // Adds plugin name to product metadata | |||
|
30 | result->setData(DataSourceItem::PLUGIN_DATA_KEY, DATA_SOURCE_NAME); | |||
|
31 | ||||
28 | auto productName = data.value(DataSourceItem::NAME_DATA_KEY).toString(); |
|
32 | auto productName = data.value(DataSourceItem::NAME_DATA_KEY).toString(); | |
29 |
|
33 | |||
30 | // Add action to load product from DataSourceController |
|
34 | // Add action to load product from DataSourceController |
General Comments 0
You need to be logged in to leave comments.
Login now