diff options
author | Friedemann Kleint <[email protected]> | 2023-04-18 15:33:58 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <[email protected]> | 2023-04-19 19:31:48 +0000 |
commit | 6c2355f45772a9f623fa24662b7c3781bdca88af (patch) | |
tree | 7ffe1ec4a6c2e4caad5f3f696401b9a1023e3eb9 /src | |
parent | 8a9abb74d74279cb559a07baa0e7e1fd8f41304c (diff) |
Fix setting combo data with QSortFilterProxyModel
qtbase/c27d2a57a441f9a1ce760e71635bd4c96882249d caused the code
to go through QStandardItemPrivate::setItemData() which does
not handle the special treatment of Qt::EditRole completely.
In the constructor of QStandardItemData; map Qt::EditRole to
Qt::DisplayRole to fix this as is done in setData().
Adapt the existing tst_QStandardItemModel::getSetItemData() to check
whether both roles are received in the dataChanged() signal.
Fixes: QTBUG-112326
Change-Id: I133d058bacc3388c612c5b4fb18b54f5ef5cb56f
Reviewed-by: Samuel Gaist <[email protected]>
Reviewed-by: David Faure <[email protected]>
(cherry picked from commit 936fe007ee97ebfcab5fda749bcbbf333744ca9e)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/itemmodels/qstandarditemmodel_p.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gui/itemmodels/qstandarditemmodel_p.h b/src/gui/itemmodels/qstandarditemmodel_p.h index def6c207270..f25aa441162 100644 --- a/src/gui/itemmodels/qstandarditemmodel_p.h +++ b/src/gui/itemmodels/qstandarditemmodel_p.h @@ -32,8 +32,10 @@ class QStandardItemData { public: inline QStandardItemData() : role(-1) {} - inline QStandardItemData(int r, const QVariant &v) : role(r), value(v) {} - inline QStandardItemData(const std::pair<const int&, const QVariant&> &p) : role(p.first), value(p.second) {} + inline QStandardItemData(int r, const QVariant &v) : + role(r == Qt::EditRole ? Qt::DisplayRole : r), value(v) {} + inline QStandardItemData(const std::pair<const int&, const QVariant&> &p) : + role(p.first == Qt::EditRole ? Qt::DisplayRole : p.first), value(p.second) {} int role; QVariant value; inline bool operator==(const QStandardItemData &other) const { return role == other.role && value == other.value; } |