##// END OF EJS Templates
Implements data() method
Alexandre Leroux -
r151:c81827035288
parent child
Show More
@@ -50,6 +50,38 int VariableModel::rowCount(const QModelIndex &parent) const
50
50
51 QVariant VariableModel::data(const QModelIndex &index, int role) const
51 QVariant VariableModel::data(const QModelIndex &index, int role) const
52 {
52 {
53 if (!index.isValid()) {
54 return QVariant{};
55 }
56
57 if (index.row() < 0 || index.row() >= rowCount()) {
58 return QVariant{};
59 }
60
61 if (role == Qt::DisplayRole) {
62 const auto &variable = impl->m_Variables.at(index.row());
63
64 if (variable) {
65 switch (index.column()) {
66 case NAME_COLUMN:
67 return variable->m_Name;
68 case UNIT_COLUMN:
69 return variable->m_Unit;
70 case MISSION_COLUMN:
71 return variable->m_Mission;
72 default:
73 // No action
74 break;
75 }
76
77 qWarning(LOG_VariableModel())
78 << tr("Can't get data (unknown column %1)").arg(index.column());
79 }
80 else {
81 qWarning(LOG_VariableModel()) << tr("Can't get data (no variable)");
82 }
83 }
84
53 return QVariant{};
85 return QVariant{};
54 }
86 }
55
87
General Comments 0
You need to be logged in to leave comments. Login now