diff options
author | Samuel Gaist <samuel.gaist@edeltech.ch> | 2017-10-05 16:20:36 +0200 |
---|---|---|
committer | Samuel Gaist <samuel.gaist@edeltech.ch> | 2017-10-17 12:28:23 +0000 |
commit | 1382374deaa4a854aeb542e6c8f7e1841f2abb10 (patch) | |
tree | 872b27c6d22475e70cec47d75f52ce44fe19a60c /src/gui/itemmodels/qstandarditemmodel_p.h | |
parent | d0a0a3c0418a0fdd2ed84b2a5f7e6565537715c6 (diff) |
Correct QStandardItemModel::setItemData to follow QAbstractItemModel
QStandardItemModel::setItemData replaces the content of an item data
with the new values rather than updating/inserting which is
the behavior for QAbstractItemModel. This patch aims to unify the
behavior.
[ChangeLog][QtWidgets][QStandardItemModel] Fixed setItemData()
incorrectly deleting unmodified data. That behavior is not
following QAbstractItemModel's documented behavior which is
no modification of data not provided in parameter.
Task-number: QTBUG-45114
Task-number: QTBUG-10872
Change-Id: I2be40cee372b68d9f71c976548ecda6dc3011241
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/gui/itemmodels/qstandarditemmodel_p.h')
-rw-r--r-- | src/gui/itemmodels/qstandarditemmodel_p.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/gui/itemmodels/qstandarditemmodel_p.h b/src/gui/itemmodels/qstandarditemmodel_p.h index 516cce8613..caee3ea34c 100644 --- a/src/gui/itemmodels/qstandarditemmodel_p.h +++ b/src/gui/itemmodels/qstandarditemmodel_p.h @@ -61,6 +61,7 @@ #include <QtCore/qstack.h> #include <QtCore/qvariant.h> #include <QtCore/qvector.h> +#include <QtCore/qdebug.h> QT_BEGIN_NAMESPACE @@ -69,6 +70,7 @@ 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) {} int role; QVariant value; inline bool operator==(const QStandardItemData &other) const { return role == other.role && value == other.value; } @@ -91,6 +93,15 @@ inline QDataStream &operator<<(QDataStream &out, const QStandardItemData &data) return out; } +inline QDebug &operator<<(QDebug &debug, const QStandardItemData &data) +{ + QDebugStateSaver saver(debug); + debug.nospace() << data.role + << " " + << data.value; + return debug.space(); +} + #endif // QT_NO_DATASTREAM class QStandardItemPrivate |