##// END OF EJS Templates
Merge pull request 224 from SCIQLOP-Initialisation develop...
perrinel -
r553:f87183c47a69 merge
parent child
Show More
@@ -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.data(), dataProvider);
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);
@@ -16,7 +16,10 namespace {
16 const auto NAME_COLUMN = 0;
16 const auto NAME_COLUMN = 0;
17 const auto TSTART_COLUMN = 1;
17 const auto TSTART_COLUMN = 1;
18 const auto TEND_COLUMN = 2;
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 // Column properties
24 // Column properties
22 const auto DEFAULT_HEIGHT = 25;
25 const auto DEFAULT_HEIGHT = 25;
@@ -34,10 +37,10 struct ColumnProperties {
34 int m_Height;
37 int m_Height;
35 };
38 };
36
39
37 const auto COLUMN_PROPERTIES
40 const auto COLUMN_PROPERTIES = QHash<int, ColumnProperties>{
38 = QHash<int, ColumnProperties>{{NAME_COLUMN, {QObject::tr("Name")}},
41 {NAME_COLUMN, {QObject::tr("Name")}}, {TSTART_COLUMN, {QObject::tr("tStart"), 180}},
39 {TSTART_COLUMN, {QObject::tr("tStart"), 180}},
42 {TEND_COLUMN, {QObject::tr("tEnd"), 180}}, {UNIT_COLUMN, {QObject::tr("Unit")}},
40 {TEND_COLUMN, {QObject::tr("tEnd"), 180}}};
43 {MISSION_COLUMN, {QObject::tr("Mission")}}, {PLUGIN_COLUMN, {QObject::tr("Plugin")}}};
41
44
42 /// Format for datetimes
45 /// Format for datetimes
43 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");
@@ -163,6 +166,12 QVariant VariableModel::data(const QModelIndex &index, int role) const
163 return dateTimeVariant(variable->range().m_TStart);
166 return dateTimeVariant(variable->range().m_TStart);
164 case TEND_COLUMN:
167 case TEND_COLUMN:
165 return dateTimeVariant(variable->range().m_TEnd);
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 default:
175 default:
167 // No action
176 // No action
168 break;
177 break;
General Comments 0
You need to be logged in to leave comments. Login now