##// END OF EJS Templates
Replaces unit and mission columns by datetime columns
Alexandre Leroux -
r274:121174483c3b
parent child
Show More
@@ -3,16 +3,21
3
3
4 #include <Data/IDataSeries.h>
4 #include <Data/IDataSeries.h>
5
5
6 #include <QDateTime>
7
6 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
8 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
7
9
8 namespace {
10 namespace {
9
11
10 // Column indexes
12 // Column indexes
11 const auto NAME_COLUMN = 0;
13 const auto NAME_COLUMN = 0;
12 const auto UNIT_COLUMN = 1;
14 const auto TSTART_COLUMN = 1;
13 const auto MISSION_COLUMN = 2;
15 const auto TEND_COLUMN = 2;
14 const auto NB_COLUMNS = 3;
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 } // namespace
21 } // namespace
17
22
18 struct VariableModel::VariableModelPrivate {
23 struct VariableModel::VariableModelPrivate {
@@ -75,13 +80,19 QVariant VariableModel::data(const QModelIndex &index, int role) const
75
80
76 if (role == Qt::DisplayRole) {
81 if (role == Qt::DisplayRole) {
77 if (auto variable = impl->m_Variables.at(index.row()).get()) {
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 switch (index.column()) {
89 switch (index.column()) {
79 case NAME_COLUMN:
90 case NAME_COLUMN:
80 return variable->name();
91 return variable->name();
81 case UNIT_COLUMN:
92 case TSTART_COLUMN:
82 return variable->unit();
93 return dateTimeVariant(variable->dateTime().m_TStart);
83 case MISSION_COLUMN:
94 case TEND_COLUMN:
84 return variable->mission();
95 return dateTimeVariant(variable->dateTime().m_TEnd);
85 default:
96 default:
86 // No action
97 // No action
87 break;
98 break;
@@ -109,9 +120,9 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int
109 case NAME_COLUMN:
120 case NAME_COLUMN:
110 return tr("Name");
121 return tr("Name");
111 case UNIT_COLUMN:
122 case UNIT_COLUMN:
112 return tr("Unit");
123 return tr("tStart");
113 case MISSION_COLUMN:
124 case MISSION_COLUMN:
114 return tr("Mission");
125 return tr("tEnd");
115 default:
126 default:
116 // No action
127 // No action
117 break;
128 break;
General Comments 0
You need to be logged in to leave comments. Login now