summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2023-11-08 12:24:46 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-12-11 15:35:40 +0000
commitabc739600447af06befaca8ae616dd607b99b184 (patch)
treee78cd477437d2d2aea93eb350fd17ade28d8193f /src/corelib/doc
parentbf2f4678b0c1a17ad8d18809335cfb69d2c6527a (diff)
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. Pick-to: 6.7 6.6 Change-Id: I3acea16c05d30d7526bac32fd6cce42b5ad4b617 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/doc')
-rw-r--r--src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp b/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp
index 52934b6159..4ef1891cdb 100644
--- a/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp
+++ b/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp
@@ -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;
};