mirror of https://github.com/qt/qtbase.git
QRM: return the section number as header data for array rows
All items in an array have the same type, it's not useful to return the same type name for the header of each column. Instead, just return the section number. Pick-to: 6.10 Change-Id: Ia01e177e363cec55c44fcf3f92b1b3bfc502abe8 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
This commit is contained in:
parent
9d0eddb70c
commit
d183bbe184
|
@ -1231,9 +1231,13 @@ public:
|
|||
result = QString::fromUtf8(prop.name());
|
||||
}
|
||||
} else if constexpr (static_column_count >= 1) {
|
||||
const QMetaType metaType = QRangeModelImplBase::meta_type_at<row_type>(section);
|
||||
if (metaType.isValid())
|
||||
result = QString::fromUtf8(metaType.name());
|
||||
if constexpr (QRangeModelDetails::array_like_v<row_type>) {
|
||||
return section;
|
||||
} else {
|
||||
const QMetaType metaType = QRangeModelImplBase::meta_type_at<row_type>(section);
|
||||
if (metaType.isValid())
|
||||
result = QString::fromUtf8(metaType.name());
|
||||
}
|
||||
}
|
||||
if (!result.isValid())
|
||||
result = this->itemModel().QAbstractItemModel::headerData(section, orientation, role);
|
||||
|
|
|
@ -234,6 +234,17 @@ public slots:
|
|||
return new QRangeModel(data);
|
||||
}
|
||||
|
||||
QRangeModel *makeListOfArrays()
|
||||
{
|
||||
QList<std::array<double, 2000>> data = {
|
||||
{0.0},
|
||||
{1.1},
|
||||
{2.2},
|
||||
};
|
||||
|
||||
return new QRangeModel(std::move(data));
|
||||
}
|
||||
|
||||
QRangeModel *makeCustomFromEnum()
|
||||
{
|
||||
return new QRangeModel(QMetaEnumerator(Qt::ItemDataRole{}));
|
||||
|
|
Loading…
Reference in New Issue