Git commit 26201fd95cf69f6fda1d443714beebec3b5be40d by Torgny Nyblom. Committed on 31/08/2013 at 10:46. Pushed by tnyblom into branch 'KDE/4.11'.
Revert "KLinkItemSelectionModel: Synchronize currentIndex" This reverts commit 14e2ff5b7359d572cd520fd7da3791230ded169a. On request revert this for allowing a proper fix in 4.11.2. CCMAIL:[email protected] CCMAIL:[email protected] CCMAIL:[email protected] M +0 -17 kdeui/itemviews/klinkitemselectionmodel.cpp M +0 -2 kdeui/itemviews/klinkitemselectionmodel.h M +14 -53 kdeui/tests/klinkitemselectionmodeltest.cpp M +0 -16 kdeui/tests/klinkitemselectionmodeltest.h http://commits.kde.org/kdelibs/26201fd95cf69f6fda1d443714beebec3b5be40d diff --git a/kdeui/itemviews/klinkitemselectionmodel.cpp b/kdeui/itemviews/klinkitemselectionmodel.cpp index be8395f..ee55d4f 100644 --- a/kdeui/itemviews/klinkitemselectionmodel.cpp +++ b/kdeui/itemviews/klinkitemselectionmodel.cpp @@ -56,8 +56,6 @@ public: } void sourceSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); - void sourceCurrentChanged(const QModelIndex& current); - void slotCurrentChanged(const QModelIndex& current); QAbstractItemModel * const m_model; QItemSelectionModel * const m_linkedItemSelectionModel; @@ -70,8 +68,6 @@ KLinkItemSelectionModel::KLinkItemSelectionModel(QAbstractItemModel *model, QIte d_ptr(new KLinkItemSelectionModelPrivate(this, model, proxySelector)) { connect(proxySelector, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(sourceSelectionChanged(QItemSelection,QItemSelection))); - connect(proxySelector, SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(sourceCurrentChanged(QModelIndex))); - connect(this, SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(slotCurrentChanged(QModelIndex))); } KLinkItemSelectionModel::~KLinkItemSelectionModel() @@ -148,12 +144,6 @@ void KLinkItemSelectionModel::select(const QItemSelection &selection, QItemSelec d->m_ignoreCurrentChanged = false; } -void KLinkItemSelectionModelPrivate::slotCurrentChanged(const QModelIndex& current) -{ - const QModelIndex mappedCurrent = m_indexMapper->mapLeftToRight(current); - m_linkedItemSelectionModel->setCurrentIndex(mappedCurrent, QItemSelectionModel::NoUpdate); -} - void KLinkItemSelectionModelPrivate::sourceSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) { Q_Q(KLinkItemSelectionModel); @@ -173,11 +163,4 @@ void KLinkItemSelectionModelPrivate::sourceSelectionChanged(const QItemSelection q->QItemSelectionModel::select(mappedSelection, QItemSelectionModel::Select); } -void KLinkItemSelectionModelPrivate::sourceCurrentChanged(const QModelIndex& current) -{ - Q_Q(KLinkItemSelectionModel); - const QModelIndex mappedCurrent = m_indexMapper->mapRightToLeft(current); - q->setCurrentIndex(mappedCurrent, QItemSelectionModel::NoUpdate); -} - #include "klinkitemselectionmodel.moc" diff --git a/kdeui/itemviews/klinkitemselectionmodel.h b/kdeui/itemviews/klinkitemselectionmodel.h index 13393de..392da46 100644 --- a/kdeui/itemviews/klinkitemselectionmodel.h +++ b/kdeui/itemviews/klinkitemselectionmodel.h @@ -110,8 +110,6 @@ protected: private: Q_DECLARE_PRIVATE(KLinkItemSelectionModel) Q_PRIVATE_SLOT( d_func(), void sourceSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)) - Q_PRIVATE_SLOT( d_func(), void sourceCurrentChanged(const QModelIndex ¤t)) - Q_PRIVATE_SLOT( d_func(), void slotCurrentChanged(const QModelIndex ¤t)) }; #endif diff --git a/kdeui/tests/klinkitemselectionmodeltest.cpp b/kdeui/tests/klinkitemselectionmodeltest.cpp index 91540fd..c3f7132 100644 --- a/kdeui/tests/klinkitemselectionmodeltest.cpp +++ b/kdeui/tests/klinkitemselectionmodeltest.cpp @@ -29,73 +29,34 @@ QTEST_KDEMAIN(KLinkItemSelectionModelTest, GUI) -void KLinkItemSelectionModelTest::init() +void KLinkItemSelectionModelTest::testToggle() { - // Init m_mainModel - m_mainModel = new QStandardItemModel; + // Init mainModel + QStandardItemModel mainModel; for (int x=0; x < 10; ++x) { - m_mainModel->appendRow(new QStandardItem(QString::number(x))); + mainModel.appendRow(new QStandardItem(QString::number(x))); } - m_mainSelectionModel = new QItemSelectionModel(m_mainModel); + QItemSelectionModel mainSelectionModel(&mainModel); // Init subModel - m_subModel = new QSortFilterProxyModel; - m_subModel->setFilterRegExp(QRegExp("^[5-9]")); - m_subModel->setSourceModel(m_mainModel); - m_subSelectionModel = new KLinkItemSelectionModel(m_subModel, m_mainSelectionModel); -} - -void KLinkItemSelectionModelTest::cleanup() -{ - delete m_mainSelectionModel; - m_mainSelectionModel = 0; - delete m_mainModel; - m_mainModel = 0; - delete m_subSelectionModel; - m_subSelectionModel = 0; - delete m_subModel; - m_subModel = 0; -} + QSortFilterProxyModel subModel; + subModel.setFilterRegExp(QRegExp("^[5-9]")); + subModel.setSourceModel(&mainModel); + KLinkItemSelectionModel subSelectionModel(&subModel, &mainSelectionModel); -void KLinkItemSelectionModelTest::testToggle() -{ // Select last index in subModel - QModelIndex subIndex = m_subModel->index(m_subModel->rowCount() - 1, 0); - m_subSelectionModel->select(subIndex, QItemSelectionModel::Toggle); + QModelIndex subIndex = subModel.index(subModel.rowCount() - 1, 0); + subSelectionModel.select(subIndex, QItemSelectionModel::Toggle); // Check selections - QModelIndexList subList = m_subSelectionModel->selectedIndexes(); + QModelIndexList subList = subSelectionModel.selectedIndexes(); QCOMPARE(subList.count(), 1); QCOMPARE(subList.first(), subIndex); - QModelIndexList mainList = m_mainSelectionModel->selectedIndexes(); - QModelIndex mainIndex = m_mainModel->index(m_mainModel->rowCount() - 1, 0); + QModelIndexList mainList = mainSelectionModel.selectedIndexes(); + QModelIndex mainIndex = mainModel.index(mainModel.rowCount() - 1, 0); QCOMPARE(mainList.count(), 1); QCOMPARE(mainList.first(), mainIndex); } -void KLinkItemSelectionModelTest::testMainSetCurrent() -{ - // Set last index of mainModel as current - QModelIndex mainIndex = m_mainModel->index(m_mainModel->rowCount() - 1, 0); - m_mainSelectionModel->setCurrentIndex(mainIndex, QItemSelectionModel::Current); - - // Last index of subModel should be current as well - QModelIndex subIndex = m_subSelectionModel->currentIndex(); - QVERIFY(subIndex.isValid()); - QCOMPARE(subIndex, m_subModel->index(m_subModel->rowCount() - 1, 0)); -} - -void KLinkItemSelectionModelTest::testSubSetCurrent() -{ - // Set last index of subModel as current - QModelIndex subIndex = m_subModel->index(m_subModel->rowCount() - 1, 0); - m_subSelectionModel->setCurrentIndex(subIndex, QItemSelectionModel::Current); - - // Last index of mainModel should be current as well - QModelIndex mainIndex = m_mainSelectionModel->currentIndex(); - QVERIFY(mainIndex.isValid()); - QCOMPARE(mainIndex, m_mainModel->index(m_mainModel->rowCount() - 1, 0)); -} - #include <klinkitemselectionmodeltest.moc> diff --git a/kdeui/tests/klinkitemselectionmodeltest.h b/kdeui/tests/klinkitemselectionmodeltest.h index 6e9c178..f3e0fd1 100644 --- a/kdeui/tests/klinkitemselectionmodeltest.h +++ b/kdeui/tests/klinkitemselectionmodeltest.h @@ -21,28 +21,12 @@ #include <QtCore/QObject> -class QItemSelectionModel; -class QStandardItemModel; -class QSortFilterProxyModel; - -class KLinkItemSelectionModel; - class KLinkItemSelectionModelTest : public QObject { Q_OBJECT private Q_SLOTS: - void init(); - void cleanup(); void testToggle(); - void testMainSetCurrent(); - void testSubSetCurrent(); - -private: - QStandardItemModel *m_mainModel; - QItemSelectionModel *m_mainSelectionModel; - QSortFilterProxyModel *m_subModel; - KLinkItemSelectionModel *m_subSelectionModel; }; #endif /* KLINKITEMSELECTIONMODELTEST_H */ _______________________________________________ release-team mailing list [email protected] https://mail.kde.org/mailman/listinfo/release-team
