@@ -75,6 +75,12 public: | |||||
75 | DataSourceItem *parentItem() const noexcept; |
|
75 | DataSourceItem *parentItem() const noexcept; | |
76 |
|
76 | |||
77 | /** |
|
77 | /** | |
|
78 | * Gets the item's root | |||
|
79 | * @return the top parent, the item itself if it's the root item | |||
|
80 | */ | |||
|
81 | const DataSourceItem &rootItem() const noexcept; | |||
|
82 | ||||
|
83 | /** | |||
78 | * Sets or appends a value to a key |
|
84 | * Sets or appends a value to a key | |
79 | * @param key the key |
|
85 | * @param key the key | |
80 | * @param value the value |
|
86 | * @param value the value |
@@ -11,6 +11,28 | |||||
11 |
|
11 | |||
12 | Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController") |
|
12 | Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController") | |
13 |
|
13 | |||
|
14 | namespace { | |||
|
15 | ||||
|
16 | /** | |||
|
17 | * Builds the metadata of the variable that will be generated from the loading of an item | |||
|
18 | * @param dataSourceItem the data source item from which to generate the metadata | |||
|
19 | * @return the metadata of the variable | |||
|
20 | */ | |||
|
21 | QVariantHash variableMetadata(const DataSourceItem &dataSourceItem) | |||
|
22 | { | |||
|
23 | // Variable metadata contains... | |||
|
24 | ||||
|
25 | // ... all metadata of the item | |||
|
26 | auto result = dataSourceItem.data(); | |||
|
27 | ||||
|
28 | // ... and the name of the plugin, recovered from root item | |||
|
29 | result.insert(QStringLiteral("plugin"), dataSourceItem.rootItem().name()); | |||
|
30 | ||||
|
31 | return result; | |||
|
32 | } | |||
|
33 | ||||
|
34 | } // namespace | |||
|
35 | ||||
14 | class DataSourceController::DataSourceControllerPrivate { |
|
36 | class DataSourceController::DataSourceControllerPrivate { | |
15 | public: |
|
37 | public: | |
16 | QMutex m_WorkingMutex; |
|
38 | QMutex m_WorkingMutex; | |
@@ -94,7 +116,8 void DataSourceController::loadProductItem(const QUuid &dataSourceUid, | |||||
94 | auto it = impl->m_DataProviders.find(dataSourceUid); |
|
116 | auto it = impl->m_DataProviders.find(dataSourceUid); | |
95 | auto dataProvider = (it != impl->m_DataProviders.end()) ? it->second : nullptr; |
|
117 | auto dataProvider = (it != impl->m_DataProviders.end()) ? it->second : nullptr; | |
96 |
|
118 | |||
97 |
emit variableCreationRequested(productItem.name(), productItem |
|
119 | emit variableCreationRequested(productItem.name(), variableMetadata(productItem), | |
|
120 | dataProvider); | |||
98 | } |
|
121 | } | |
99 | else { |
|
122 | else { | |
100 | qCWarning(LOG_DataSourceController()) << tr("Can't load an item that is not a product"); |
|
123 | qCWarning(LOG_DataSourceController()) << tr("Can't load an item that is not a product"); |
@@ -90,6 +90,11 DataSourceItem *DataSourceItem::parentItem() const noexcept | |||||
90 | return impl->m_Parent; |
|
90 | return impl->m_Parent; | |
91 | } |
|
91 | } | |
92 |
|
92 | |||
|
93 | const DataSourceItem &DataSourceItem::rootItem() const noexcept | |||
|
94 | { | |||
|
95 | return isRoot() ? *this : parentItem()->rootItem(); | |||
|
96 | } | |||
|
97 | ||||
93 | void DataSourceItem::setData(const QString &key, const QVariant &value, bool append) noexcept |
|
98 | void DataSourceItem::setData(const QString &key, const QVariant &value, bool append) noexcept | |
94 | { |
|
99 | { | |
95 | auto it = impl->m_Data.constFind(key); |
|
100 | auto it = impl->m_Data.constFind(key); |
@@ -18,7 +18,8 const auto TSTART_COLUMN = 1; | |||||
18 | const auto TEND_COLUMN = 2; |
|
18 | const auto TEND_COLUMN = 2; | |
19 | const auto UNIT_COLUMN = 3; |
|
19 | const auto UNIT_COLUMN = 3; | |
20 | const auto MISSION_COLUMN = 4; |
|
20 | const auto MISSION_COLUMN = 4; | |
21 |
const auto N |
|
21 | const auto PLUGIN_COLUMN = 5; | |
|
22 | const auto NB_COLUMNS = 6; | |||
22 |
|
23 | |||
23 | // Column properties |
|
24 | // Column properties | |
24 | const auto DEFAULT_HEIGHT = 25; |
|
25 | const auto DEFAULT_HEIGHT = 25; | |
@@ -39,7 +40,7 struct ColumnProperties { | |||||
39 | const auto COLUMN_PROPERTIES = QHash<int, ColumnProperties>{ |
|
40 | const auto COLUMN_PROPERTIES = QHash<int, ColumnProperties>{ | |
40 | {NAME_COLUMN, {QObject::tr("Name")}}, {TSTART_COLUMN, {QObject::tr("tStart"), 180}}, |
|
41 | {NAME_COLUMN, {QObject::tr("Name")}}, {TSTART_COLUMN, {QObject::tr("tStart"), 180}}, | |
41 | {TEND_COLUMN, {QObject::tr("tEnd"), 180}}, {UNIT_COLUMN, {QObject::tr("Unit")}}, |
|
42 | {TEND_COLUMN, {QObject::tr("tEnd"), 180}}, {UNIT_COLUMN, {QObject::tr("Unit")}}, | |
42 | {MISSION_COLUMN, {QObject::tr("Mission")}}}; |
|
43 | {MISSION_COLUMN, {QObject::tr("Mission")}}, {PLUGIN_COLUMN, {QObject::tr("Plugin")}}}; | |
43 |
|
44 | |||
44 | /// Format for datetimes |
|
45 | /// Format for datetimes | |
45 | const auto DATETIME_FORMAT = QStringLiteral("dd/MM/yyyy \nhh:mm:ss:zzz"); |
|
46 | const auto DATETIME_FORMAT = QStringLiteral("dd/MM/yyyy \nhh:mm:ss:zzz"); | |
@@ -169,6 +170,8 QVariant VariableModel::data(const QModelIndex &index, int role) const | |||||
169 | return variable->metadata().value(QStringLiteral("units")); |
|
170 | return variable->metadata().value(QStringLiteral("units")); | |
170 | case MISSION_COLUMN: |
|
171 | case MISSION_COLUMN: | |
171 | return variable->metadata().value(QStringLiteral("mission")); |
|
172 | return variable->metadata().value(QStringLiteral("mission")); | |
|
173 | case PLUGIN_COLUMN: | |||
|
174 | return variable->metadata().value(QStringLiteral("plugin")); | |||
172 | default: |
|
175 | default: | |
173 | // No action |
|
176 | // No action | |
174 | break; |
|
177 | break; |
General Comments 0
You need to be logged in to leave comments.
Login now