##// END OF EJS Templates
Creates struct for column properties...
Alexandre Leroux -
r255:fc3a19c89f40
parent child
Show More
@@ -15,6 +15,19 const auto TSTART_COLUMN = 1;
15 const auto TEND_COLUMN = 2;
15 const auto TEND_COLUMN = 2;
16 const auto NB_COLUMNS = 3;
16 const auto NB_COLUMNS = 3;
17
17
18 // Column properties
19
20 struct ColumnProperties {
21 ColumnProperties(const QString &name = {}) : m_Name{name} {}
22
23 QString m_Name;
24 };
25
26 const auto COLUMN_PROPERTIES
27 = QHash<int, ColumnProperties>{{NAME_COLUMN, {QObject::tr("Name")}},
28 {TSTART_COLUMN, {QObject::tr("tStart")}},
29 {TEND_COLUMN, {QObject::tr("tEnd")}}};
30
18 /// Format for datetimes
31 /// Format for datetimes
19 const auto DATETIME_FORMAT = QStringLiteral("dd/MM/yyyy \nhh:mm:ss:zzz");
32 const auto DATETIME_FORMAT = QStringLiteral("dd/MM/yyyy \nhh:mm:ss:zzz");
20
33
@@ -116,20 +129,15 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int
116 }
129 }
117
130
118 if (orientation == Qt::Horizontal) {
131 if (orientation == Qt::Horizontal) {
119 switch (section) {
132 auto propertiesIt = COLUMN_PROPERTIES.find(section);
120 case NAME_COLUMN:
133 if (propertiesIt != COLUMN_PROPERTIES.cend()) {
121 return tr("Name");
134 // Role is either DisplayRole or SizeHintRole
122 case UNIT_COLUMN:
135 return QVariant{propertiesIt->m_Name};
123 return tr("tStart");
136 }
124 case MISSION_COLUMN:
137 else {
125 return tr("tEnd");
138 qWarning(LOG_VariableModel())
126 default:
139 << tr("Can't get header data (unknown column %1)").arg(section);
127 // No action
128 break;
129 }
140 }
130
131 qWarning(LOG_VariableModel())
132 << tr("Can't get header data (unknown column %1)").arg(section);
133 }
141 }
134
142
135 return QVariant{};
143 return QVariant{};
General Comments 0
You need to be logged in to leave comments. Login now