From 8021e2d5e7ccd09146896f788441c116f2ca6159 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 24 Nov 2011 23:21:36 +0100 Subject: Remove the backwards compatibility signal emissions when moving items. Change-Id: I29a44835d3397c1dbf37026daf0c5234dae770e0 Reviewed-by: David Faure Reviewed-by: Olivier Goffart --- src/widgets/itemviews/qabstractitemview.cpp | 10 ++++++++++ src/widgets/itemviews/qabstractitemview.h | 2 ++ src/widgets/itemviews/qabstractitemview_p.h | 3 +++ src/widgets/itemviews/qidentityproxymodel.cpp | 10 ---------- src/widgets/itemviews/qitemselectionmodel.cpp | 8 ++++++++ src/widgets/itemviews/qsortfilterproxymodel.cpp | 24 ++++++++++++++++++++++++ 6 files changed, 47 insertions(+), 10 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 8c99ed4b5a..06544e3146 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -3499,6 +3499,16 @@ void QAbstractItemViewPrivate::_q_layoutChanged() #endif } +void QAbstractItemViewPrivate::_q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int) +{ + _q_layoutChanged(); +} + +void QAbstractItemViewPrivate::_q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int) +{ + _q_layoutChanged(); +} + /*! This slot is called when the selection is changed. The previous selection (which may be empty), is specified by \a deselected, and the diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h index ae0c0369e5..25501e67c5 100644 --- a/src/widgets/itemviews/qabstractitemview.h +++ b/src/widgets/itemviews/qabstractitemview.h @@ -357,6 +357,8 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_columnsInserted(const QModelIndex&, int, int)) Q_PRIVATE_SLOT(d_func(), void _q_rowsInserted(const QModelIndex&, int, int)) Q_PRIVATE_SLOT(d_func(), void _q_rowsRemoved(const QModelIndex&, int, int)) + Q_PRIVATE_SLOT(d_func(), void _q_columnsMoved(const QModelIndex&, int, int, const QModelIndex&, int)) + Q_PRIVATE_SLOT(d_func(), void _q_rowsMoved(const QModelIndex&, int, int, const QModelIndex&, int)) Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed()) Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged()) Q_PRIVATE_SLOT(d_func(), void _q_headerDataChanged()) diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index e1cda31915..031e325cff 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -114,6 +114,9 @@ public: virtual void _q_columnsInserted(const QModelIndex &parent, int start, int end); virtual void _q_modelDestroyed(); virtual void _q_layoutChanged(); + virtual void _q_rowsMoved(const QModelIndex &source, int sourceStart, int sourceEnd, const QModelIndex &destination, int destinationStart); + virtual void _q_columnsMoved(const QModelIndex &source, int sourceStart, int sourceEnd, const QModelIndex &destination, int destinationStart); + void _q_headerDataChanged() { doDelayedItemsLayout(); } void _q_scrollerStateChanged(); diff --git a/src/widgets/itemviews/qidentityproxymodel.cpp b/src/widgets/itemviews/qidentityproxymodel.cpp index 7885aedabb..c891565794 100644 --- a/src/widgets/itemviews/qidentityproxymodel.cpp +++ b/src/widgets/itemviews/qidentityproxymodel.cpp @@ -51,16 +51,12 @@ QT_BEGIN_NAMESPACE class QIdentityProxyModelPrivate : public QAbstractProxyModelPrivate { QIdentityProxyModelPrivate() - : ignoreNextLayoutAboutToBeChanged(false), - ignoreNextLayoutChanged(false) { } Q_DECLARE_PUBLIC(QIdentityProxyModel) - bool ignoreNextLayoutAboutToBeChanged; - bool ignoreNextLayoutChanged; QList layoutChangePersistentIndexes; QModelIndexList proxyIndexes; @@ -481,9 +477,6 @@ void QIdentityProxyModelPrivate::_q_sourceHeaderDataChanged(Qt::Orientation orie void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged() { - if (ignoreNextLayoutAboutToBeChanged) - return; - Q_Q(QIdentityProxyModel); foreach(const QPersistentModelIndex &proxyPersistentIndex, q->persistentIndexList()) { @@ -499,9 +492,6 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged() void QIdentityProxyModelPrivate::_q_sourceLayoutChanged() { - if (ignoreNextLayoutChanged) - return; - Q_Q(QIdentityProxyModel); for (int i = 0; i < proxyIndexes.size(); ++i) { diff --git a/src/widgets/itemviews/qitemselectionmodel.cpp b/src/widgets/itemviews/qitemselectionmodel.cpp index 996b12f805..08470a4300 100644 --- a/src/widgets/itemviews/qitemselectionmodel.cpp +++ b/src/widgets/itemviews/qitemselectionmodel.cpp @@ -565,6 +565,14 @@ void QItemSelectionModelPrivate::initModel(QAbstractItemModel *model) q, SLOT(_q_rowsAboutToBeInserted(QModelIndex,int,int))); QObject::connect(model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), q, SLOT(_q_columnsAboutToBeInserted(QModelIndex,int,int))); + QObject::connect(model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), + q, SLOT(_q_layoutAboutToBeChanged())); + QObject::connect(model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), + q, SLOT(_q_layoutAboutToBeChanged())); + QObject::connect(model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), + q, SLOT(_q_layoutChanged())); + QObject::connect(model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), + q, SLOT(_q_layoutChanged())); QObject::connect(model, SIGNAL(layoutAboutToBeChanged()), q, SLOT(_q_layoutAboutToBeChanged())); QObject::connect(model, SIGNAL(layoutChanged()), diff --git a/src/widgets/itemviews/qsortfilterproxymodel.cpp b/src/widgets/itemviews/qsortfilterproxymodel.cpp index f8d5dcb302..74999de426 100644 --- a/src/widgets/itemviews/qsortfilterproxymodel.cpp +++ b/src/widgets/itemviews/qsortfilterproxymodel.cpp @@ -1582,6 +1582,18 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel) disconnect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_sourceLayoutChanged())); + disconnect(d->model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_sourceLayoutAboutToBeChanged())); + + disconnect(d->model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_sourceLayoutChanged())); + + disconnect(d->model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_sourceLayoutAboutToBeChanged())); + + disconnect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_sourceLayoutChanged())); + disconnect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset())); disconnect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset())); @@ -1623,6 +1635,18 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel) connect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_sourceLayoutChanged())); + connect(d->model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_sourceLayoutAboutToBeChanged())); + + connect(d->model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_sourceLayoutChanged())); + + connect(d->model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_sourceLayoutAboutToBeChanged())); + + connect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_sourceLayoutChanged())); + connect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset())); connect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset())); -- cgit v1.2.3