summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorLuca Beldi <v.ronin@yahoo.it>2018-08-01 16:43:31 +0100
committerLuca Beldi <v.ronin@yahoo.it>2018-08-17 07:17:12 +0000
commitd0069ff8c91e0027a0a1f3ef7767dbb13e0eacc4 (patch)
tree4305eb9240e4880edda8f355cdc057a92ce6dd6c /src/corelib
parent67352c92761fcb2e2c6a98b24e1bf5f33805cb3a (diff)
Add a method to clear the data to QStandardItemModel
After the behavior of setItemData has been changed following QTBUG-45114, QStandardItemModel was lacking an interface to clear all the data from a single index. Task-number: QTBUG-69616 Change-Id: Ide0b5bb6358439fc42c474df8b044fbace6def8d Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp17
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h3
2 files changed, 20 insertions, 0 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 3a6f67521f..e816add91d 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -1866,6 +1866,23 @@ bool QAbstractItemModel::setData(const QModelIndex &index, const QVariant &value
return false;
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+/*!
+ \since 6.0
+ Removes the data stored in all the roles for the given \a index.
+ Returns \c{true} if successful; otherwise returns \c{false}.
+ The dataChanged() signal should be emitted if the data was successfully
+ removed.
+ The base class implementation returns \c{false}
+ \sa data(), itemData(), setData(), setItemData()
+*/
+bool QAbstractItemModel::clearItemData(const QModelIndex &index)
+{
+ Q_UNUSED(index);
+ return false;
+}
+#endif
+
/*!
\fn QVariant QAbstractItemModel::data(const QModelIndex &index, int role) const = 0
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index 21171124f9..bec71b0606 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -198,6 +198,9 @@ public:
virtual QMap<int, QVariant> itemData(const QModelIndex &index) const;
virtual bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ virtual bool clearItemData(const QModelIndex &index);
+#endif
virtual QStringList mimeTypes() const;
virtual QMimeData *mimeData(const QModelIndexList &indexes) const;