diff options
author | Luca Beldi <v.ronin@yahoo.it> | 2018-12-06 08:48:35 +0000 |
---|---|---|
committer | Luca Beldi <v.ronin@yahoo.it> | 2018-12-24 08:07:36 +0000 |
commit | ff835a5030f3ec0aaa91ad0332739ca3259804e8 (patch) | |
tree | abb204b3fa4fb7ce0c9e7480bdfc7f15b71e09d8 /src/corelib | |
parent | 3306b162392cb4afe268e8dfecd3a0e7ba7eaca6 (diff) |
Fix QStringListModel::setData to check for actual changes
QStringListModel::setData documentation states that
"The dataChanged() signal is emitted if the item is changed."
This patch actually respects the doc. setData will check that the data
actually changed before sending the dataChanged signal.
[ChangeLog][QtCore][QStringListModel] setData will now emit the
dataChanged() signal only if the string set is different from
the one already contained in the model
Change-Id: I4308a6f3b4851203fb899c5e29a36076e0c32f2f
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/itemmodels/qstringlistmodel.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp index 0adaba9b9a..f92a0d6676 100644 --- a/src/corelib/itemmodels/qstringlistmodel.cpp +++ b/src/corelib/itemmodels/qstringlistmodel.cpp @@ -184,7 +184,10 @@ bool QStringListModel::setData(const QModelIndex &index, const QVariant &value, { if (index.row() >= 0 && index.row() < lst.size() && (role == Qt::EditRole || role == Qt::DisplayRole)) { - lst.replace(index.row(), value.toString()); + const QString valueString = value.toString(); + if (lst.at(index.row()) == valueString) + return true; + lst.replace(index.row(), valueString); QVector<int> roles; roles.reserve(2); roles.append(Qt::DisplayRole); |