From 8b41a29b2d90757d1efa168b342bc84c748adf46 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 27 Sep 2012 11:12:15 +0200 Subject: Forward the layout change hint through QSortFilterProxyModel. Change-Id: Ic9ae7f011f63c4a53fec4d9425ac6cd6776153ee Reviewed-by: Marc Mutz --- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 36 ++++++++++++------------ src/corelib/itemmodels/qsortfilterproxymodel.h | 4 +-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 042c6ce7c2..8551db0c28 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -207,8 +207,8 @@ public: void _q_sourceAboutToBeReset(); void _q_sourceReset(); - void _q_sourceLayoutAboutToBeChanged(const QList &sourceParents); - void _q_sourceLayoutChanged(const QList &sourceParents); + void _q_sourceLayoutAboutToBeChanged(const QList &sourceParents, QAbstractItemModel::LayoutChangeHint hint); + void _q_sourceLayoutChanged(const QList &sourceParents, QAbstractItemModel::LayoutChangeHint hint); void _q_sourceRowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end); @@ -434,7 +434,7 @@ bool QSortFilterProxyModelPrivate::can_create_mapping(const QModelIndex &source_ void QSortFilterProxyModelPrivate::sort() { Q_Q(QSortFilterProxyModel); - emit q->layoutAboutToBeChanged(); + emit q->layoutAboutToBeChanged(QList(), QAbstractItemModel::VerticalSortHint); QModelIndexPairList source_indexes = store_persistent_indexes(); IndexMap::const_iterator it = source_index_mapping.constBegin(); for (; it != source_index_mapping.constEnd(); ++it) { @@ -444,7 +444,7 @@ void QSortFilterProxyModelPrivate::sort() build_source_to_proxy_mapping(m->source_rows, m->proxy_rows); } update_persistent_indexes(source_indexes); - emit q->layoutChanged(); + emit q->layoutChanged(QList(), QAbstractItemModel::VerticalSortHint); } /*! @@ -1188,7 +1188,7 @@ void QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &sourc // Re-sort the rows of this level QList parents; parents << q->mapFromSource(source_parent); - emit q->layoutAboutToBeChanged(parents); + emit q->layoutAboutToBeChanged(parents, QAbstractItemModel::VerticalSortHint); QModelIndexPairList source_indexes = store_persistent_indexes(); remove_source_items(m->proxy_rows, m->source_rows, source_rows_resort, source_parent, Qt::Vertical, false); @@ -1196,7 +1196,7 @@ void QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &sourc insert_source_items(m->proxy_rows, m->source_rows, source_rows_resort, source_parent, Qt::Vertical, false); update_persistent_indexes(source_indexes); - emit q->layoutChanged(parents); + emit q->layoutChanged(parents, QAbstractItemModel::VerticalSortHint); // Make sure we also emit dataChanged for the rows source_rows_change += source_rows_resort; } @@ -1293,7 +1293,7 @@ void QSortFilterProxyModelPrivate::_q_sourceReset() sort(); } -void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList &sourceParents) +void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList &sourceParents, QAbstractItemModel::LayoutChangeHint hint) { Q_Q(QSortFilterProxyModel); saved_persistent_indexes.clear(); @@ -1314,14 +1314,14 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QListlayoutAboutToBeChanged(parents); + emit q->layoutAboutToBeChanged(parents, hint); if (persistent.indexes.isEmpty()) return; saved_persistent_indexes = store_persistent_indexes(); } -void QSortFilterProxyModelPrivate::_q_sourceLayoutChanged(const QList &sourceParents) +void QSortFilterProxyModelPrivate::_q_sourceLayoutChanged(const QList &sourceParents, QAbstractItemModel::LayoutChangeHint hint) { Q_Q(QSortFilterProxyModel); @@ -1353,7 +1353,7 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutChanged(const QListlayoutChanged(parents); + emit q->layoutChanged(parents, hint); } void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeInserted( @@ -1768,11 +1768,11 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel) disconnect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int))); - disconnect(d->model, SIGNAL(layoutAboutToBeChanged(QList)), - this, SLOT(_q_sourceLayoutAboutToBeChanged(QList))); + disconnect(d->model, SIGNAL(layoutAboutToBeChanged(QList,QAbstractItemModel::LayoutChangeHint)), + this, SLOT(_q_sourceLayoutAboutToBeChanged(QList,QAbstractItemModel::LayoutChangeHint))); - disconnect(d->model, SIGNAL(layoutChanged(QList)), - this, SLOT(_q_sourceLayoutChanged(QList))); + disconnect(d->model, SIGNAL(layoutChanged(QList,QAbstractItemModel::LayoutChangeHint)), + this, SLOT(_q_sourceLayoutChanged(QList,QAbstractItemModel::LayoutChangeHint))); disconnect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset())); disconnect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset())); @@ -1821,11 +1821,11 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel) connect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int))); - connect(d->model, SIGNAL(layoutAboutToBeChanged(QList)), - this, SLOT(_q_sourceLayoutAboutToBeChanged(QList))); + connect(d->model, SIGNAL(layoutAboutToBeChanged(QList,QAbstractItemModel::LayoutChangeHint)), + this, SLOT(_q_sourceLayoutAboutToBeChanged(QList,QAbstractItemModel::LayoutChangeHint))); - connect(d->model, SIGNAL(layoutChanged(QList)), - this, SLOT(_q_sourceLayoutChanged(QList))); + connect(d->model, SIGNAL(layoutChanged(QList,QAbstractItemModel::LayoutChangeHint)), + this, SLOT(_q_sourceLayoutChanged(QList,QAbstractItemModel::LayoutChangeHint))); connect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset())); connect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset())); diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.h b/src/corelib/itemmodels/qsortfilterproxymodel.h index 855e145dee..905c401886 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.h +++ b/src/corelib/itemmodels/qsortfilterproxymodel.h @@ -178,8 +178,8 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int start, int end)) Q_PRIVATE_SLOT(d_func(), void _q_sourceAboutToBeReset()) Q_PRIVATE_SLOT(d_func(), void _q_sourceReset()) - Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged(const QList &sourceParents)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged(const QList &sourceParents)) + Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged(const QList &sourceParents, QAbstractItemModel::LayoutChangeHint hint)) + Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged(const QList &sourceParents, QAbstractItemModel::LayoutChangeHint hint)) Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end)) Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(const QModelIndex &source_parent, int start, int end)) Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end)) -- cgit v1.2.3