##// END OF EJS Templates
Updates headerData() method to return column width/size for role Qt::SizeHintRole
Alexandre Leroux -
r277:14a68137a7a1
parent child
Show More
@@ -4,6 +4,7
4 #include <Data/IDataSeries.h>
4 #include <Data/IDataSeries.h>
5
5
6 #include <QDateTime>
6 #include <QDateTime>
7 #include <QSize>
7
8
8 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
9 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
9
10
@@ -132,7 +133,7 QVariant VariableModel::data(const QModelIndex &index, int role) const
132
133
133 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int role) const
134 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int role) const
134 {
135 {
135 if (role != Qt::DisplayRole) {
136 if (role != Qt::DisplayRole && role != Qt::SizeHintRole) {
136 return QVariant{};
137 return QVariant{};
137 }
138 }
138
139
@@ -140,7 +141,9 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int
140 auto propertiesIt = COLUMN_PROPERTIES.find(section);
141 auto propertiesIt = COLUMN_PROPERTIES.find(section);
141 if (propertiesIt != COLUMN_PROPERTIES.cend()) {
142 if (propertiesIt != COLUMN_PROPERTIES.cend()) {
142 // Role is either DisplayRole or SizeHintRole
143 // Role is either DisplayRole or SizeHintRole
143 return QVariant{propertiesIt->m_Name};
144 return (role == Qt::DisplayRole)
145 ? QVariant{propertiesIt->m_Name}
146 : QVariant{QSize{propertiesIt->m_Width, propertiesIt->m_Height}};
144 }
147 }
145 else {
148 else {
146 qWarning(LOG_VariableModel())
149 qWarning(LOG_VariableModel())
General Comments 0
You need to be logged in to leave comments. Login now