##// END OF EJS Templates
Merge branch 'feature/VariableColumns' into develop
Alexandre Leroux -
r521:780b372cbdd1 merge
parent child
Show More
@@ -75,6 +75,12 public:
75 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 84 * Sets or appends a value to a key
79 85 * @param key the key
80 86 * @param value the value
@@ -11,6 +11,28
11 11
12 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 36 class DataSourceController::DataSourceControllerPrivate {
15 37 public:
16 38 QMutex m_WorkingMutex;
@@ -94,7 +116,8 void DataSourceController::loadProductItem(const QUuid &dataSourceUid,
94 116 auto it = impl->m_DataProviders.find(dataSourceUid);
95 117 auto dataProvider = (it != impl->m_DataProviders.end()) ? it->second : nullptr;
96 118
97 emit variableCreationRequested(productItem.name(), productItem.data(), dataProvider);
119 emit variableCreationRequested(productItem.name(), variableMetadata(productItem),
120 dataProvider);
98 121 }
99 122 else {
100 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 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 98 void DataSourceItem::setData(const QString &key, const QVariant &value, bool append) noexcept
94 99 {
95 100 auto it = impl->m_Data.constFind(key);
@@ -16,7 +16,10 namespace {
16 16 const auto NAME_COLUMN = 0;
17 17 const auto TSTART_COLUMN = 1;
18 18 const auto TEND_COLUMN = 2;
19 const auto NB_COLUMNS = 3;
19 const auto UNIT_COLUMN = 3;
20 const auto MISSION_COLUMN = 4;
21 const auto PLUGIN_COLUMN = 5;
22 const auto NB_COLUMNS = 6;
20 23
21 24 // Column properties
22 25 const auto DEFAULT_HEIGHT = 25;
@@ -34,10 +37,10 struct ColumnProperties {
34 37 int m_Height;
35 38 };
36 39
37 const auto COLUMN_PROPERTIES
38 = QHash<int, ColumnProperties>{{NAME_COLUMN, {QObject::tr("Name")}},
39 {TSTART_COLUMN, {QObject::tr("tStart"), 180}},
40 {TEND_COLUMN, {QObject::tr("tEnd"), 180}}};
40 const auto COLUMN_PROPERTIES = QHash<int, ColumnProperties>{
41 {NAME_COLUMN, {QObject::tr("Name")}}, {TSTART_COLUMN, {QObject::tr("tStart"), 180}},
42 {TEND_COLUMN, {QObject::tr("tEnd"), 180}}, {UNIT_COLUMN, {QObject::tr("Unit")}},
43 {MISSION_COLUMN, {QObject::tr("Mission")}}, {PLUGIN_COLUMN, {QObject::tr("Plugin")}}};
41 44
42 45 /// Format for datetimes
43 46 const auto DATETIME_FORMAT = QStringLiteral("dd/MM/yyyy \nhh:mm:ss:zzz");
@@ -163,6 +166,12 QVariant VariableModel::data(const QModelIndex &index, int role) const
163 166 return dateTimeVariant(variable->range().m_TStart);
164 167 case TEND_COLUMN:
165 168 return dateTimeVariant(variable->range().m_TEnd);
169 case UNIT_COLUMN:
170 return variable->metadata().value(QStringLiteral("units"));
171 case MISSION_COLUMN:
172 return variable->metadata().value(QStringLiteral("mission"));
173 case PLUGIN_COLUMN:
174 return variable->metadata().value(QStringLiteral("plugin"));
166 175 default:
167 176 // No action
168 177 break;
General Comments 0
You need to be logged in to leave comments. Login now