##// 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 154 if (role == Qt::DisplayRole) {
155 155 if (auto variable = impl->m_Variables.at(index.row()).get()) {
156 156 /// Lambda function that builds the variant to return for a time value
157 auto dateTimeVariant = [](double secs) {
158 auto dateTime = DateUtils::dateTime(secs);
159 return dateTime.toString(DATETIME_FORMAT);
157 /// @param getValueFun function used to get for a data series the iterator on the entry
158 /// that contains the time value to display
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 171 switch (index.column()) {
163 172 case NAME_COLUMN:
164 173 return variable->name();
165 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 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 182 case UNIT_COLUMN:
170 183 return variable->metadata().value(QStringLiteral("units"));
171 184 case MISSION_COLUMN:
General Comments 0
You need to be logged in to leave comments. Login now