@@ -3,16 +3,21 | |||
|
3 | 3 | |
|
4 | 4 | #include <Data/IDataSeries.h> |
|
5 | 5 | |
|
6 | #include <QDateTime> | |
|
7 | ||
|
6 | 8 | Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel") |
|
7 | 9 | |
|
8 | 10 | namespace { |
|
9 | 11 | |
|
10 | 12 | // Column indexes |
|
11 | 13 | const auto NAME_COLUMN = 0; |
|
12 |
const auto |
|
|
13 |
const auto |
|
|
14 | const auto TSTART_COLUMN = 1; | |
|
15 | const auto TEND_COLUMN = 2; | |
|
14 | 16 | const auto NB_COLUMNS = 3; |
|
15 | 17 | |
|
18 | /// Format for datetimes | |
|
19 | const auto DATETIME_FORMAT = QStringLiteral("dd/MM/yyyy \nhh:mm:ss:zzz"); | |
|
20 | ||
|
16 | 21 | } // namespace |
|
17 | 22 | |
|
18 | 23 | struct VariableModel::VariableModelPrivate { |
@@ -75,13 +80,19 QVariant VariableModel::data(const QModelIndex &index, int role) const | |||
|
75 | 80 | |
|
76 | 81 | if (role == Qt::DisplayRole) { |
|
77 | 82 | if (auto variable = impl->m_Variables.at(index.row()).get()) { |
|
83 | /// Lambda function that builds the variant to return for a time value | |
|
84 | auto dateTimeVariant = [](double time) { | |
|
85 | auto dateTime = QDateTime::fromMSecsSinceEpoch(time * 1000.); | |
|
86 | return dateTime.toString(DATETIME_FORMAT); | |
|
87 | }; | |
|
88 | ||
|
78 | 89 | switch (index.column()) { |
|
79 | 90 | case NAME_COLUMN: |
|
80 | 91 | return variable->name(); |
|
81 |
case |
|
|
82 |
return variable-> |
|
|
83 |
case |
|
|
84 |
return variable-> |
|
|
92 | case TSTART_COLUMN: | |
|
93 | return dateTimeVariant(variable->dateTime().m_TStart); | |
|
94 | case TEND_COLUMN: | |
|
95 | return dateTimeVariant(variable->dateTime().m_TEnd); | |
|
85 | 96 | default: |
|
86 | 97 | // No action |
|
87 | 98 | break; |
@@ -109,9 +120,9 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int | |||
|
109 | 120 | case NAME_COLUMN: |
|
110 | 121 | return tr("Name"); |
|
111 | 122 | case UNIT_COLUMN: |
|
112 |
return tr(" |
|
|
123 | return tr("tStart"); | |
|
113 | 124 | case MISSION_COLUMN: |
|
114 |
return tr(" |
|
|
125 | return tr("tEnd"); | |
|
115 | 126 | default: |
|
116 | 127 | // No action |
|
117 | 128 | break; |
General Comments 0
You need to be logged in to leave comments.
Login now