From a3ec5d5729542de406e9f0457748f1dde1cf5662 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 27 Sep 2012 11:08:18 +0200 Subject: Add hint API to QAIM::layout*Change signals. Usually layoutChange is used for sorting elements. The parents parameter to the signal already hints at a localization of what is being sorted, if it's just one level in the tree. The new hints enum can be used to only consider how the first column of a table gets sorted, because all other columns will be sorted the same way. Change-Id: I65dd2996894bbdb45a2f6288edbeaa49e4053256 Reviewed-by: David Faure Reviewed-by: Stephen Kelly --- src/corelib/itemmodels/qabstractitemmodel.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/corelib/itemmodels/qabstractitemmodel.cpp') 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 &parents = QList()) - \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 &parents = QList(), 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 &parents = QList()) + \fn void QAbstractItemModel::layoutChanged(const QList &parents = QList(), 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: -- cgit v1.2.3