##// END OF EJS Templates
Shows min/max x-axis data in Variable widget (3)...
Alexandre Leroux -
r601:fe5ae51adf07
parent child
Show More
@@ -154,18 +154,31 QVariant VariableModel::data(const QModelIndex &index, int role) const
154 if (role == Qt::DisplayRole) {
154 if (role == Qt::DisplayRole) {
155 if (auto variable = impl->m_Variables.at(index.row()).get()) {
155 if (auto variable = impl->m_Variables.at(index.row()).get()) {
156 /// Lambda function that builds the variant to return for a time value
156 /// Lambda function that builds the variant to return for a time value
157 auto dateTimeVariant = [](double secs) {
157 /// @param getValueFun function used to get for a data series the iterator on the entry
158 auto dateTime = DateUtils::dateTime(secs);
158 /// that contains the time value to display
159 return dateTime.toString(DATETIME_FORMAT);
159 auto dateTimeVariant = [variable](const auto &getValueFun) {
160 if (auto dataSeries = variable->dataSeries()) {
161 auto it = getValueFun(*dataSeries);
162 return (it != dataSeries->cend())
163 ? DateUtils::dateTime(it->x()).toString(DATETIME_FORMAT)
164 : QVariant{};
165 }
166 else {
167 return QVariant{};
168 }
160 };
169 };
161
170
162 switch (index.column()) {
171 switch (index.column()) {
163 case NAME_COLUMN:
172 case NAME_COLUMN:
164 return variable->name();
173 return variable->name();
165 case TSTART_COLUMN:
174 case TSTART_COLUMN:
166 return dateTimeVariant(variable->range().m_TStart);
175 // Shows the min value of the data series above the range tstart
176 return dateTimeVariant([min = variable->range().m_TStart](
177 const auto &dataSeries) { return dataSeries.minData(min); });
167 case TEND_COLUMN:
178 case TEND_COLUMN:
168 return dateTimeVariant(variable->range().m_TEnd);
179 // Shows the max value of the data series under the range tend
180 return dateTimeVariant([max = variable->range().m_TEnd](
181 const auto &dataSeries) { return dataSeries.maxData(max); });
169 case UNIT_COLUMN:
182 case UNIT_COLUMN:
170 return variable->metadata().value(QStringLiteral("units"));
183 return variable->metadata().value(QStringLiteral("units"));
171 case MISSION_COLUMN:
184 case MISSION_COLUMN:
General Comments 0
You need to be logged in to leave comments. Login now