##// 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 15 const auto TEND_COLUMN = 2;
16 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 31 /// Format for datetimes
19 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 131 if (orientation == Qt::Horizontal) {
119 switch (section) {
120 case NAME_COLUMN:
121 return tr("Name");
122 case UNIT_COLUMN:
123 return tr("tStart");
124 case MISSION_COLUMN:
125 return tr("tEnd");
126 default:
127 // No action
128 break;
132 auto propertiesIt = COLUMN_PROPERTIES.find(section);
133 if (propertiesIt != COLUMN_PROPERTIES.cend()) {
134 // Role is either DisplayRole or SizeHintRole
135 return QVariant{propertiesIt->m_Name};
136 }
137 else {
138 qWarning(LOG_VariableModel())
139 << tr("Can't get header data (unknown column %1)").arg(section);
129 140 }
130
131 qWarning(LOG_VariableModel())
132 << tr("Can't get header data (unknown column %1)").arg(section);
133 141 }
134 142
135 143 return QVariant{};
General Comments 0
You need to be logged in to leave comments. Login now