summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp24
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h12
2 files changed, 29 insertions, 7 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 77654158d1..9fc68711f6 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -1322,9 +1322,20 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
\sa headerData(), setHeaderData(), dataChanged()
*/
+
/*!
- \fn void QAbstractItemModel::layoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>())
- \since 4.2
+ \enum QAbstractItemModel::LayoutChangeHint
+
+ This enum describes the way the model changes layout.
+
+ \value NoLayoutChangeHint No hint is available.
+ \value VerticalSortHint Rows are being sorted.
+ \value HorizontalSortHint Columns are being sorted.
+*/
+
+/*!
+ \fn void QAbstractItemModel::layoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint)
+ \since 5.0
This signal is emitted just before the layout of a model is changed.
Components connected to this signal use it to adapt to changes in the
@@ -1335,13 +1346,15 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
The optional \a parents parameter is used to give a more specific notification
about what parts of the layout of the model are changing. An empty list indicates
- a change to the layout of the entire model.
+ a change to the layout of the entire model. The order of elements in the \a parents list is not significant. The optional \a hint parameter is used
+ to give a hint about what is happening while the model is relayouting.
\sa layoutChanged(), changePersistentIndex()
*/
/*!
- \fn void QAbstractItemModel::layoutChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>())
+ \fn void QAbstractItemModel::layoutChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint)
+ \since 5.0
This signal is emitted whenever the layout of items exposed by the model
has changed; for example, when the model has been sorted. When this signal
@@ -1355,7 +1368,8 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
The optional \a parents parameter is used to give a more specific notification
about what parts of the layout of the model are changing. An empty list indicates
- a change to the layout of the entire model.
+ a change to the layout of the entire model. The order of elements in the \a parents list is not significant. The optional \a hint parameter is used
+ to give a hint about what is happening while the model is relayouting.
Subclasses should update any persistent model indexes before emitting
layoutChanged(). In other words, when the structure changes:
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index 1d9617e8eb..00e108099d 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -156,6 +156,7 @@ template <class Key, class T> class QMap;
class Q_CORE_EXPORT QAbstractItemModel : public QObject
{
Q_OBJECT
+ Q_ENUMS(LayoutChangeHints)
friend class QPersistentModelIndexData;
friend class QAbstractItemViewPrivate;
@@ -237,11 +238,18 @@ public:
using QObject::parent;
#endif
+ enum LayoutChangeHint
+ {
+ NoLayoutChangeHint,
+ VerticalSortHint,
+ HorizontalSortHint
+ };
+
Q_SIGNALS:
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>());
void headerDataChanged(Qt::Orientation orientation, int first, int last);
- void layoutChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>());
- void layoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>());
+ void layoutChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint);
+ void layoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint);
void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last
#if !defined(qdoc)