summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/itemmodels/qidentityproxymodel.cpp14
-rw-r--r--src/corelib/itemmodels/qidentityproxymodel.h2
-rw-r--r--tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp38
3 files changed, 46 insertions, 8 deletions
diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp
index 3dbe93b21a..c36473a21f 100644
--- a/src/corelib/itemmodels/qidentityproxymodel.cpp
+++ b/src/corelib/itemmodels/qidentityproxymodel.cpp
@@ -74,7 +74,7 @@ class QIdentityProxyModelPrivate : public QAbstractProxyModelPrivate
void _q_sourceColumnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest);
void _q_sourceColumnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest);
- void _q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ void _q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last);
void _q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint);
@@ -371,8 +371,8 @@ void QIdentityProxyModel::setSourceModel(QAbstractItemModel* newSourceModel)
this, SLOT(_q_sourceModelAboutToBeReset()));
disconnect(sourceModel(), SIGNAL(modelReset()),
this, SLOT(_q_sourceModelReset()));
- disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
- this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));
+ disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+ this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)));
disconnect(sourceModel(), SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
this, SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int)));
disconnect(sourceModel(), SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
@@ -412,8 +412,8 @@ void QIdentityProxyModel::setSourceModel(QAbstractItemModel* newSourceModel)
SLOT(_q_sourceModelAboutToBeReset()));
connect(sourceModel(), SIGNAL(modelReset()),
SLOT(_q_sourceModelReset()));
- connect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
- SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));
+ connect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+ SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)));
connect(sourceModel(), SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int)));
connect(sourceModel(), SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
@@ -480,12 +480,12 @@ void QIdentityProxyModelPrivate::_q_sourceColumnsRemoved(const QModelIndex &pare
q->endRemoveColumns();
}
-void QIdentityProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+void QIdentityProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
{
Q_ASSERT(topLeft.isValid() ? topLeft.model() == model : true);
Q_ASSERT(bottomRight.isValid() ? bottomRight.model() == model : true);
Q_Q(QIdentityProxyModel);
- q->dataChanged(q->mapFromSource(topLeft), q->mapFromSource(bottomRight));
+ q->dataChanged(q->mapFromSource(topLeft), q->mapFromSource(bottomRight), roles);
}
void QIdentityProxyModelPrivate::_q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last)
diff --git a/src/corelib/itemmodels/qidentityproxymodel.h b/src/corelib/itemmodels/qidentityproxymodel.h
index da40836dd0..4125683f77 100644
--- a/src/corelib/itemmodels/qidentityproxymodel.h
+++ b/src/corelib/itemmodels/qidentityproxymodel.h
@@ -102,7 +102,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))
Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int))
- Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(QModelIndex,QModelIndex))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(QModelIndex,QModelIndex,QVector<int>))
Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last))
Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint))
diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
index c7e4664007..f750b7a9d4 100644
--- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
@@ -46,6 +46,20 @@
#include "dynamictreemodel.h"
#include "qidentityproxymodel.h"
+class DataChangedModel : public QAbstractListModel
+{
+public:
+ int rowCount(const QModelIndex &parent) const { return parent.isValid() ? 0 : 1; }
+ QVariant data(const QModelIndex&, int) const { return QVariant(); }
+ QModelIndex index(int row, int column, const QModelIndex &) const { return createIndex(row, column); }
+
+ void changeData()
+ {
+ const QModelIndex idx = index(0, 0, QModelIndex());
+ Q_EMIT dataChanged(idx, idx, QVector<int>() << 1);
+ }
+};
+
class tst_QIdentityProxyModel : public QObject
{
Q_OBJECT
@@ -63,6 +77,7 @@ private slots:
void removeRows();
void moveRows();
void reset();
+ void dataChanged();
protected:
void verifyIdentity(QAbstractItemModel *model, const QModelIndex &parent = QModelIndex());
@@ -79,6 +94,7 @@ tst_QIdentityProxyModel::tst_QIdentityProxyModel()
void tst_QIdentityProxyModel::initTestCase()
{
+ qRegisterMetaType<QVector<int> >();
m_model = new QStandardItemModel(0, 1);
m_proxy = new QIdentityProxyModel();
}
@@ -326,5 +342,27 @@ void tst_QIdentityProxyModel::reset()
m_proxy->setSourceModel(0);
}
+void tst_QIdentityProxyModel::dataChanged()
+{
+ DataChangedModel model;
+ m_proxy->setSourceModel(&model);
+
+ verifyIdentity(&model);
+
+ QSignalSpy modelSpy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+ QSignalSpy proxySpy(m_proxy, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+
+ QVERIFY(modelSpy.isValid());
+ QVERIFY(proxySpy.isValid());
+
+ model.changeData();
+
+ QCOMPARE(modelSpy.first().at(2).value<QVector<int> >(), QVector<int>() << 1);
+ QVERIFY(modelSpy.first().at(2) == proxySpy.first().at(2));
+
+ verifyIdentity(&model);
+ m_proxy->setSourceModel(0);
+}
+
QTEST_MAIN(tst_QIdentityProxyModel)
#include "tst_qidentityproxymodel.moc"