summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-05-21 08:38:40 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-05-21 08:38:40 (GMT)
commite5e40e6eb10e6760c6fac3673aa0a5afe074ae9b (patch)
tree6638c6ea58eeed115e04aa53143bf6326c3de442
parentef3560410f9ee5c851ef46298e38297a7ed42994 (diff)
downloadQt-e5e40e6eb10e6760c6fac3673aa0a5afe074ae9b.zip
Qt-e5e40e6eb10e6760c6fac3673aa0a5afe074ae9b.tar.gz
Qt-e5e40e6eb10e6760c6fac3673aa0a5afe074ae9b.tar.bz2
Revert "Deselect the current selection when the QItemSelectionModel::model is reset."
This reverts commit 2c1d1c136102a17eef9ae3c4e9f0cf01338306ae. Regressions: TESTCASE_FAIL qtreeview (pulse_win32-msvc2005_windows_xp) TESTCASE_FAIL qtreeview (pulse_win32-msvc2008_windows_xp) TESTCASE_FAIL qtreewidget (pulse_win32-msvc2005_windows_xp) TESTCASE_FAIL qtreewidget (pulse_win32-msvc2008_windows_xp) TESTFUNCTION_FAIL qitemselectionmodel::unselectable (pulse_linux-g++) TESTFUNCTION_FAIL qitemselectionmodel::unselectable (pulse_qws/linux-x86-g++) TESTFUNCTION_FAIL qsortfilterproxymodel::testMultipleProxiesWithSelection (pulse_linux-g++) TESTFUNCTION_FAIL qsortfilterproxymodel::testMultipleProxiesWithSelection (pulse_macx-g++_cocoa_32) TESTFUNCTION_FAIL qsortfilterproxymodel::testMultipleProxiesWithSelection (pulse_qws/linux-x86-g++) TESTFUNCTION_FAIL qsortfilterproxymodel::testMultipleProxiesWithSelection (pulse_win32-msvc2005_windows_xp) TESTFUNCTION_FAIL qsortfilterproxymodel::testMultipleProxiesWithSelection (pulse_win32-msvc2008_windows_xp) TESTFUNCTION_FAIL qtreeview::taskQTBUG_6450_selectAllWith1stColumnHidden (pulse_linux-g++) TESTFUNCTION_FAIL qtreeview::taskQTBUG_6450_selectAllWith1stColumnHidden (pulse_qws/linux-x86-g++) TESTFUNCTION_FAIL qtreeview::taskQTBUG_6450_selectAllWith1stColumnHidden (pulse_win32-msvc2005_windows_xp) TESTFUNCTION_FAIL qtreeview::taskQTBUG_6450_selectAllWith1stColumnHidden (pulse_win32-msvc2008_windows_xp) TESTFUNCTION_FAIL qtreewidget::task191552_rtl (pulse_linux-g++) TESTFUNCTION_FAIL qtreewidget::task203673_selection (pulse_qws/linux-x86-g++) TESTFUNCTION_FAIL qtreewidget::task203673_selection (pulse_win32-msvc2005_windows_xp) TESTFUNCTION_FAIL qtreewidget::task203673_selection (pulse_win32-msvc2008_windows_xp)
-rw-r--r--src/gui/itemviews/qitemselectionmodel.cpp25
-rw-r--r--src/gui/itemviews/qitemselectionmodel.h1
-rw-r--r--src/gui/itemviews/qitemselectionmodel_p.h3
-rw-r--r--tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp47
4 files changed, 9 insertions, 67 deletions
diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp
index fc99439..f848321 100644
--- a/src/gui/itemviews/qitemselectionmodel.cpp
+++ b/src/gui/itemviews/qitemselectionmodel.cpp
@@ -566,8 +566,6 @@ void QItemSelectionModelPrivate::initModel(QAbstractItemModel *model)
q, SLOT(_q_layoutAboutToBeChanged()));
QObject::connect(model, SIGNAL(layoutChanged()),
q, SLOT(_q_layoutChanged()));
- QObject::connect(model, SIGNAL(modelAboutToBeReset()),
- q, SLOT(_q_modelAboutToBeReset()));
}
}
@@ -898,13 +896,6 @@ void QItemSelectionModelPrivate::_q_layoutChanged()
savedPersistentCurrentIndexes.clear();
}
-void QItemSelectionModelPrivate::_q_modelAboutToBeReset()
-{
- Q_Q(QItemSelectionModel);
- q->clearSelection();
- clearCurrentIndex();
-}
-
/*!
\class QItemSelectionModel
@@ -1104,18 +1095,12 @@ void QItemSelectionModel::clear()
{
Q_D(QItemSelectionModel);
clearSelection();
- d->clearCurrentIndex();
-}
-
-void QItemSelectionModelPrivate::clearCurrentIndex()
-{
- Q_Q(QItemSelectionModel);
- QModelIndex previous = currentIndex;
- currentIndex = QModelIndex();
+ QModelIndex previous = d->currentIndex;
+ d->currentIndex = QModelIndex();
if (previous.isValid()) {
- emit q->currentChanged(currentIndex, previous);
- emit q->currentRowChanged(currentIndex, previous);
- emit q->currentColumnChanged(currentIndex, previous);
+ emit currentChanged(d->currentIndex, previous);
+ emit currentRowChanged(d->currentIndex, previous);
+ emit currentColumnChanged(d->currentIndex, previous);
}
}
diff --git a/src/gui/itemviews/qitemselectionmodel.h b/src/gui/itemviews/qitemselectionmodel.h
index 8682109..436514f 100644
--- a/src/gui/itemviews/qitemselectionmodel.h
+++ b/src/gui/itemviews/qitemselectionmodel.h
@@ -197,7 +197,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_rowsAboutToBeInserted(const QModelIndex&, int, int))
Q_PRIVATE_SLOT(d_func(), void _q_layoutAboutToBeChanged())
Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged())
- Q_PRIVATE_SLOT(d_func(), void _q_modelAboutToBeReset())
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QItemSelectionModel::SelectionFlags)
diff --git a/src/gui/itemviews/qitemselectionmodel_p.h b/src/gui/itemviews/qitemselectionmodel_p.h
index c2fe976..5afa90d 100644
--- a/src/gui/itemviews/qitemselectionmodel_p.h
+++ b/src/gui/itemviews/qitemselectionmodel_p.h
@@ -78,7 +78,6 @@ public:
void _q_columnsAboutToBeInserted(const QModelIndex &parent, int start, int end);
void _q_layoutAboutToBeChanged();
void _q_layoutChanged();
- void _q_modelAboutToBeReset();
inline void remove(QList<QItemSelectionRange> &r)
{
@@ -94,8 +93,6 @@ public:
currentSelection.clear();
}
- void clearCurrentIndex();
-
QPointer<QAbstractItemModel> model;
QItemSelection ranges;
QItemSelection currentSelection;
diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 9858829..3b2a716 100644
--- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -1536,43 +1536,6 @@ public:
inline void reset() { QStandardItemModel::reset(); }
};
-class ResetObserver : public QObject
-{
- QItemSelectionModel * const m_selectionModel;
- QItemSelection m_selection;
- Q_OBJECT
-public:
- ResetObserver(QItemSelectionModel *selectionModel)
- : m_selectionModel(selectionModel)
- {
- connect(selectionModel->model(), SIGNAL(modelAboutToBeReset()),SLOT(modelAboutToBeReset()));
- connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(selectionChanged(QItemSelection,QItemSelection)));
- connect(selectionModel->model(), SIGNAL(modelReset()),SLOT(modelReset()));
- }
-
-private slots:
- void modelAboutToBeReset()
- {
- m_selection = m_selectionModel->selection();
- foreach(const QItemSelectionRange &range, m_selection)
- {
- QVERIFY(range.isValid());
- }
- }
-
- void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
- {
- qDebug() << deselected << selected;
- QCOMPARE(m_selection, deselected);
- m_selection.clear();
- }
-
- void modelReset()
- {
- QVERIFY(m_selectionModel->selection().isEmpty());
- }
-};
-
void tst_QItemSelectionModel::resetModel()
{
MyStandardItemModel model(20, 20);
@@ -1592,13 +1555,11 @@ void tst_QItemSelectionModel::resetModel()
view.selectionModel()->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select);
- // We get this signal three times. Twice in this test method and once because the source reset causes the current selection to
- // be deselected.
- QCOMPARE(spy.count(), 3);
- QCOMPARE(spy.at(2).count(), 2);
+ QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.at(1).count(), 2);
// make sure we don't get an "old selection"
- QCOMPARE(spy.at(2).at(1).userType(), qMetaTypeId<QItemSelection>());
- QVERIFY(qvariant_cast<QItemSelection>(spy.at(2).at(1)).isEmpty());
+ QCOMPARE(spy.at(1).at(1).userType(), qMetaTypeId<QItemSelection>());
+ QVERIFY(qvariant_cast<QItemSelection>(spy.at(1).at(1)).isEmpty());
}
void tst_QItemSelectionModel::removeRows_data()