From: Stephen Kelly Date: Thu, 24 Nov 2011 22:21:36 +0000 (+0100) Subject: Remove the backwards compatibility signal emissions when moving items. X-Git-Tag: qt-v5.0.0-alpha1~2353 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8021e2d5e7ccd09146896f788441c116f2ca6159;p=profile%2Fivi%2Fqtbase.git Remove the backwards compatibility signal emissions when moving items. Change-Id: I29a44835d3397c1dbf37026daf0c5234dae770e0 Reviewed-by: David Faure Reviewed-by: Olivier Goffart --- diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index 3bdc972..89c6fbe 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -116,6 +116,11 @@ QtCore * drop a bogus QChar::NoCategory enum value; the proper QChar::Other_NotAssigned value is returned for an unassigned codepoints now. +* layoutAboutToBeChanged is no longer emitted by QAbstractItemModel::beginMoveRows. + layoutChanged is no longer emitted by QAbstractItemModel::endMoveRows. Proxy models + should now also connect to (and disconnect from) the rowsAboutToBeMoved and + rowsMoved signals. + QtGui ----- * Accessibility has been refactored. The hierachy of accessible objects is implemented via diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index cbbb20a..9945537 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -2522,8 +2522,6 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star required to do yourself. Using beginMoveRows and endMoveRows is an alternative to emitting layoutAboutToBeChanged and layoutChanged directly along with changePersistentIndexes. - layoutAboutToBeChanged is emitted by this method for compatibility - reasons. The \a sourceParent index corresponds to the parent from which the rows are moved; \a sourceFirst and \a sourceLast are the first and last @@ -2623,7 +2621,6 @@ bool QAbstractItemModel::beginMoveRows(const QModelIndex &sourceParent, int sour d->changes.push(destinationChange); emit rowsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild); - emit layoutAboutToBeChanged(); d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Vertical); return true; } @@ -2635,8 +2632,6 @@ bool QAbstractItemModel::beginMoveRows(const QModelIndex &sourceParent, int sour function \e after moving data within the model's underlying data store. - layoutChanged is emitted by this method for compatibility reasons. - \sa beginMoveRows() \since 4.6 @@ -2661,7 +2656,6 @@ void QAbstractItemModel::endMoveRows() d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Vertical); emit rowsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first); - emit layoutChanged(); } /*! @@ -2795,8 +2789,6 @@ void QAbstractItemModel::endRemoveColumns() required to do yourself. Using beginMoveRows and endMoveRows is an alternative to emitting layoutAboutToBeChanged and layoutChanged directly along with changePersistentIndexes. - layoutAboutToBeChanged is emitted by this method for compatibility - reasons. The \a sourceParent index corresponds to the parent from which the columns are moved; \a sourceFirst and \a sourceLast are the first and last @@ -2848,7 +2840,6 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal); emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild); - emit layoutAboutToBeChanged(); return true; } @@ -2859,8 +2850,6 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s function \e after moving data within the model's underlying data store. - layoutChanged is emitted by this method for compatibility reasons. - \sa beginMoveColumns() \since 4.6 @@ -2885,7 +2874,6 @@ void QAbstractItemModel::endMoveColumns() d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal); emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first); - emit layoutChanged(); } /*! diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 8c99ed4..06544e3 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 ae0c036..25501e6 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 e1cda31..031e325 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 7885aed..c891565 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 996b12f..08470a4 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 f8d5dcb..74999de 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()));