Forward the 3rd parameter of dataChanged

Change-Id: I94f893bf65cd150c3cb1099c91cb13882bcca79a
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
Albert Astals Cid 2013-02-19 23:51:31 +01:00 committed by The Qt Project
parent 20dbad1bbf
commit 70f6652ebd
3 changed files with 46 additions and 8 deletions

View File

@ -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)

View File

@ -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))

View File

@ -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"