41 |
41 |
42 |
42 |
43 #include <QtTest/QtTest> |
43 #include <QtTest/QtTest> |
44 #include <QStandardItemModel> |
44 #include <QStandardItemModel> |
45 #include <QStringListModel> |
45 #include <QStringListModel> |
|
46 #include <QSortFilterProxyModel> |
46 |
47 |
47 #include <qabstractitemmodel.h> |
48 #include <qabstractitemmodel.h> |
48 #include <qapplication.h> |
49 #include <qapplication.h> |
49 #include <qheaderview.h> |
50 #include <qheaderview.h> |
50 #include <private/qheaderview_p.h> |
51 #include <private/qheaderview_p.h> |
186 |
187 |
187 void emptySectionSpan(); |
188 void emptySectionSpan(); |
188 void task236450_hidden_data(); |
189 void task236450_hidden_data(); |
189 void task236450_hidden(); |
190 void task236450_hidden(); |
190 void task248050_hideRow(); |
191 void task248050_hideRow(); |
|
192 void QTBUG6058_reset(); |
191 |
193 |
192 protected: |
194 protected: |
193 QHeaderView *view; |
195 QHeaderView *view; |
194 QStandardItemModel *model; |
196 QStandardItemModel *model; |
195 }; |
197 }; |
1945 //the size of the section shouldn't have changed |
1947 //the size of the section shouldn't have changed |
1946 QCOMPARE(header.sectionPosition(2), 17); |
1948 QCOMPARE(header.sectionPosition(2), 17); |
1947 } |
1949 } |
1948 |
1950 |
1949 |
1951 |
|
1952 //returns 0 if everything is fine. |
|
1953 static int checkHeaderViewOrder(QHeaderView *view, const QVector<int> &expected) |
|
1954 { |
|
1955 if (view->count() != expected.count()) |
|
1956 return 1; |
|
1957 |
|
1958 for (int i = 0; i < expected.count(); i++) { |
|
1959 if (view->logicalIndex(i) != expected.at(i)) |
|
1960 return i + 10; |
|
1961 if (view->visualIndex(expected.at(i)) != i) |
|
1962 return i + 100; |
|
1963 } |
|
1964 return 0; |
|
1965 } |
|
1966 |
|
1967 |
|
1968 void tst_QHeaderView::QTBUG6058_reset() |
|
1969 { |
|
1970 QStringListModel model1( QStringList() << "0" << "1" << "2" << "3" << "4" << "5" ); |
|
1971 QStringListModel model2( QStringList() << "a" << "b" << "c" ); |
|
1972 QSortFilterProxyModel proxy; |
|
1973 |
|
1974 QHeaderView view(Qt::Vertical); |
|
1975 view.setModel(&proxy); |
|
1976 view.show(); |
|
1977 QTest::qWait(20); |
|
1978 |
|
1979 proxy.setSourceModel(&model1); |
|
1980 QApplication::processEvents(); |
|
1981 view.swapSections(0,2); |
|
1982 view.swapSections(1,4); |
|
1983 QApplication::processEvents(); |
|
1984 QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 4 << 0 << 3 << 1 << 5) , 0); |
|
1985 |
|
1986 proxy.setSourceModel(&model2); |
|
1987 QApplication::processEvents(); |
|
1988 QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 0 << 1 ) , 0); |
|
1989 |
|
1990 proxy.setSourceModel(&model1); |
|
1991 QApplication::processEvents(); |
|
1992 QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 0 << 1 << 3 << 4 << 5 ) , 0); |
|
1993 } |
|
1994 |
|
1995 |
1950 QTEST_MAIN(tst_QHeaderView) |
1996 QTEST_MAIN(tst_QHeaderView) |
1951 #include "tst_qheaderview.moc" |
1997 #include "tst_qheaderview.moc" |