summaryrefslogtreecommitdiffstats
path: root/src/corelib/itemmodels
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2012-09-27 11:10:44 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-30 18:29:47 +0200
commit123999af3fd0774638145cd3f0760dd42b194bd5 (patch)
tree90771ddb5bcd7e03081f33a781e6aa4d3a320abe /src/corelib/itemmodels
parenta3ec5d5729542de406e9f0457748f1dde1cf5662 (diff)
Process and forward the layout change hint through the QIdentityProxyModel.
Change-Id: I074c75080b7e74c44fc833c207d297723e5f6e06 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/itemmodels')
-rw-r--r--src/corelib/itemmodels/qidentityproxymodel.cpp52
-rw-r--r--src/corelib/itemmodels/qidentityproxymodel.h4
2 files changed, 40 insertions, 16 deletions
diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp
index d983d4dfbc..37ec1cd0a9 100644
--- a/src/corelib/itemmodels/qidentityproxymodel.cpp
+++ b/src/corelib/itemmodels/qidentityproxymodel.cpp
@@ -77,8 +77,8 @@ class QIdentityProxyModelPrivate : public QAbstractProxyModelPrivate
void _q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last);
- void _q_sourceLayoutAboutToBeChanged();
- void _q_sourceLayoutChanged();
+ void _q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint);
+ void _q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint);
void _q_sourceModelAboutToBeReset();
void _q_sourceModelReset();
@@ -366,10 +366,10 @@ void QIdentityProxyModel::setSourceModel(QAbstractItemModel* newSourceModel)
this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));
disconnect(sourceModel(), SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
this, SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int)));
- disconnect(sourceModel(), SIGNAL(layoutAboutToBeChanged()),
- this, SLOT(_q_sourceLayoutAboutToBeChanged()));
- disconnect(sourceModel(), SIGNAL(layoutChanged()),
- this, SLOT(_q_sourceLayoutChanged()));
+ disconnect(sourceModel(), SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
+ this, SLOT(_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
+ disconnect(sourceModel(), SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
+ this, SLOT(_q_sourceLayoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
}
QAbstractProxyModel::setSourceModel(newSourceModel);
@@ -407,10 +407,10 @@ void QIdentityProxyModel::setSourceModel(QAbstractItemModel* newSourceModel)
SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));
connect(sourceModel(), SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int)));
- connect(sourceModel(), SIGNAL(layoutAboutToBeChanged()),
- SLOT(_q_sourceLayoutAboutToBeChanged()));
- connect(sourceModel(), SIGNAL(layoutChanged()),
- SLOT(_q_sourceLayoutChanged()));
+ connect(sourceModel(), SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
+ SLOT(_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
+ connect(sourceModel(), SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
+ SLOT(_q_sourceLayoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
}
endResetModel();
@@ -485,7 +485,7 @@ void QIdentityProxyModelPrivate::_q_sourceHeaderDataChanged(Qt::Orientation orie
q->headerDataChanged(orientation, first, last);
}
-void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged()
+void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
{
Q_Q(QIdentityProxyModel);
@@ -497,10 +497,22 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged()
layoutChangePersistentIndexes << srcPersistentIndex;
}
- q->layoutAboutToBeChanged();
+ QList<QPersistentModelIndex> parents;
+ parents.reserve(sourceParents.size());
+ foreach (const QPersistentModelIndex &parent, sourceParents) {
+ if (!parent.isValid()) {
+ parents << QPersistentModelIndex();
+ continue;
+ }
+ const QModelIndex mappedParent = q->mapFromSource(parent);
+ Q_ASSERT(mappedParent.isValid());
+ parents << mappedParent;
+ }
+
+ q->layoutAboutToBeChanged(parents, hint);
}
-void QIdentityProxyModelPrivate::_q_sourceLayoutChanged()
+void QIdentityProxyModelPrivate::_q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
{
Q_Q(QIdentityProxyModel);
@@ -511,7 +523,19 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutChanged()
layoutChangePersistentIndexes.clear();
proxyIndexes.clear();
- q->layoutChanged();
+ QList<QPersistentModelIndex> parents;
+ parents.reserve(sourceParents.size());
+ foreach (const QPersistentModelIndex &parent, sourceParents) {
+ if (!parent.isValid()) {
+ parents << QPersistentModelIndex();
+ continue;
+ }
+ const QModelIndex mappedParent = q->mapFromSource(parent);
+ Q_ASSERT(mappedParent.isValid());
+ parents << mappedParent;
+ }
+
+ q->layoutChanged(parents, hint);
}
void QIdentityProxyModelPrivate::_q_sourceModelAboutToBeReset()
diff --git a/src/corelib/itemmodels/qidentityproxymodel.h b/src/corelib/itemmodels/qidentityproxymodel.h
index 646bbd6e5a..b402c175d2 100644
--- a/src/corelib/itemmodels/qidentityproxymodel.h
+++ b/src/corelib/itemmodels/qidentityproxymodel.h
@@ -104,8 +104,8 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(QModelIndex,QModelIndex))
Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last))
- Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged())
- Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint))
Q_PRIVATE_SLOT(d_func(), void _q_sourceModelAboutToBeReset())
Q_PRIVATE_SLOT(d_func(), void _q_sourceModelReset())
};