QAIM: return false if nothing was (or could be) done in setItemData

Setting item data on an invalid index, or with an empty map, surely is
not a successful operation.

[ChangeLog][Core][QAbstractItemModel] Calling setItemData with an
invalid index or empty map of data returns false.

Change-Id: Id087581243c8fa39a8cc78b811ecd087deea4466
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
Volker Hilsheimer 2025-03-06 10:15:39 +01:00
parent 39015c049b
commit 9c87c99180

View File

@ -2086,6 +2086,9 @@ bool QAbstractItemModel::clearItemData(const QModelIndex &index)
*/
bool QAbstractItemModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles)
{
if (!index.isValid() || roles.isEmpty())
return false;
// ### TODO: Consider change the semantics of this function,
// or deprecating/removing it altogether.
//