Remove the backwards compatibility signal emissions when moving items.
authorStephen Kelly <stephen.kelly@kdab.com>
Thu, 24 Nov 2011 22:21:36 +0000 (23:21 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 8 Dec 2011 22:22:39 +0000 (23:22 +0100)
Change-Id: I29a44835d3397c1dbf37026daf0c5234dae770e0
Reviewed-by: David Faure <faure@kde.org>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
dist/changes-5.0.0
src/corelib/kernel/qabstractitemmodel.cpp
src/widgets/itemviews/qabstractitemview.cpp
src/widgets/itemviews/qabstractitemview.h
src/widgets/itemviews/qabstractitemview_p.h
src/widgets/itemviews/qidentityproxymodel.cpp
src/widgets/itemviews/qitemselectionmodel.cpp
src/widgets/itemviews/qsortfilterproxymodel.cpp

index 3bdc972..89c6fbe 100644 (file)
@@ -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
index cbbb20a..9945537 100644 (file)
@@ -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();
 }
 
 /*!
index 8c99ed4..06544e3 100644 (file)
@@ -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
index ae0c036..25501e6 100644 (file)
@@ -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())
index e1cda31..031e325 100644 (file)
@@ -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();
 
index 7885aed..c891565 100644 (file)
@@ -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<QPersistentModelIndex> 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) {
index 996b12f..08470a4 100644 (file)
@@ -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()),
index f8d5dcb..74999de 100644 (file)
@@ -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()));