Add parameter for function call in QIdentityProxyModel

This change ensures that the correct model index is passed to the sourceModel()->data() function when retrieving the DateRole value.

Pick-to: 6.5
Fixes: QTBUG-70792
Change-Id: I66c9f2404533625f05dd51db2d9263287db6ee91
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
(cherry picked from commit f0d6bfb2426392060575dc61bfa698df7964bf5e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Dheerendra Purohit 2024-10-18 19:02:52 +05:30 committed by Qt Cherry-pick Bot
parent a3376af2c7
commit f03d386039

View File

@ -16,7 +16,8 @@ class DateFormatProxyModel : public QIdentityProxyModel
if (role != Qt::DisplayRole) if (role != Qt::DisplayRole)
return QIdentityProxyModel::data(index, role); return QIdentityProxyModel::data(index, role);
const QDateTime dateTime = sourceModel()->data(SourceClass::DateRole).toDateTime(); const QModelIndex sourceIndex = mapToSource(index);
const QDateTime dateTime = sourceModel()->data(sourceIndex, SourceClass::DateRole).toDateTime();
return dateTime.toString(m_formatString); return dateTime.toString(m_formatString);
} }