Doc: QIdentityProxyModel::itemData() should be reimplemented too

This is a "regression" (voluntary, known) from commit
c27d2a57a4 which changed
QAbstractProxyModel::itemData() to call the source model's itemData(),
so our data() reimplementation is no longer used.

Of course this only matters if itemData() is actually called, which
isn't the case in Qt itself. People will likely skip this if they don't
care - but if itemData() is used in the project, then this shows how
to reimplement it correctly.

Pick-to: 6.7 6.6
Change-Id: I3acea16c05d30d7526bac32fd6cce42b5ad4b617
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
David Faure 2023-11-08 12:24:46 +01:00 committed by Volker Hilsheimer
parent bf2f4678b0
commit abc7396004
1 changed files with 7 additions and 1 deletions

View File

@ -17,10 +17,16 @@ class DateFormatProxyModel : public QIdentityProxyModel
return QIdentityProxyModel::data(index, role);
const QDateTime dateTime = sourceModel()->data(SourceClass::DateRole).toDateTime();
return dateTime.toString(m_formatString);
}
QMap<int, QVariant> itemData(const QModelIndex &proxyIndex) const override
{
QMap<int, QVariant> map = QIdentityProxyModel::itemData(proxyIndex);
map[Qt::DisplayRole] = data(proxyIndex);
return map;
}
private:
QString m_formatString;
};