Doc: QIdentityProxyModel::itemData() should be reimplemented too
This is a "regression" (voluntary, known) from commit c27d2a57a441f9a1ce760e71635bd4c96882249d 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. Change-Id: I3acea16c05d30d7526bac32fd6cce42b5ad4b617 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit abc739600447af06befaca8ae616dd607b99b184) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit bbd868ff682c991bbd6cb88a9cf363e04871472b)
This commit is contained in:
parent
c3c461d8ee
commit
03ac42cd8e
@ -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;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user