1990 proxy.setSourceModel(&model1); |
1993 proxy.setSourceModel(&model1); |
1991 QApplication::processEvents(); |
1994 QApplication::processEvents(); |
1992 QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 0 << 1 << 3 << 4 << 5 ) , 0); |
1995 QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 0 << 1 << 3 << 4 << 5 ) , 0); |
1993 } |
1996 } |
1994 |
1997 |
|
1998 void tst_QHeaderView::QTBUG7833_sectionClicked() |
|
1999 { |
|
2000 |
|
2001 |
|
2002 |
|
2003 |
|
2004 QTableView tv; |
|
2005 QStandardItemModel *sim = new QStandardItemModel(&tv); |
|
2006 QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(&tv); |
|
2007 proxyModel->setSourceModel(sim); |
|
2008 proxyModel->setDynamicSortFilter(true); |
|
2009 proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); |
|
2010 |
|
2011 QList<QStandardItem *> row; |
|
2012 for (int i = 0; i < 12; i++) |
|
2013 row.append(new QStandardItem(QString(QLatin1Char('A' + i)))); |
|
2014 sim->appendRow(row); |
|
2015 row.clear(); |
|
2016 for (int i = 12; i > 0; i--) |
|
2017 row.append(new QStandardItem(QString(QLatin1Char('A' + i)))); |
|
2018 sim->appendRow(row); |
|
2019 |
|
2020 tv.setSortingEnabled(true); |
|
2021 tv.horizontalHeader()->setSortIndicatorShown(true); |
|
2022 tv.horizontalHeader()->setClickable(true); |
|
2023 tv.horizontalHeader()->setStretchLastSection(true); |
|
2024 tv.horizontalHeader()->setResizeMode(QHeaderView::Interactive); |
|
2025 |
|
2026 tv.setModel(proxyModel); |
|
2027 tv.setColumnHidden(5, true); |
|
2028 tv.setColumnHidden(6, true); |
|
2029 tv.horizontalHeader()->swapSections(8, 10); |
|
2030 tv.sortByColumn(1, Qt::AscendingOrder); |
|
2031 |
|
2032 QSignalSpy clickedSpy(tv.horizontalHeader(), SIGNAL(sectionClicked(int))); |
|
2033 QSignalSpy pressedSpy(tv.horizontalHeader(), SIGNAL(sectionPressed(int))); |
|
2034 |
|
2035 |
|
2036 QTest::mouseClick(tv.horizontalHeader()->viewport(), Qt::LeftButton, Qt::NoModifier, |
|
2037 QPoint(tv.horizontalHeader()->sectionViewportPosition(11) + 5, 5)); |
|
2038 QCOMPARE(clickedSpy.count(), 1); |
|
2039 QCOMPARE(pressedSpy.count(), 1); |
|
2040 QCOMPARE(clickedSpy.at(0).at(0).toInt(), 11); |
|
2041 QCOMPARE(pressedSpy.at(0).at(0).toInt(), 11); |
|
2042 |
|
2043 QTest::mouseClick(tv.horizontalHeader()->viewport(), Qt::LeftButton, Qt::NoModifier, |
|
2044 QPoint(tv.horizontalHeader()->sectionViewportPosition(8) + 5, 5)); |
|
2045 |
|
2046 QCOMPARE(clickedSpy.count(), 2); |
|
2047 QCOMPARE(pressedSpy.count(), 2); |
|
2048 QCOMPARE(clickedSpy.at(1).at(0).toInt(), 8); |
|
2049 QCOMPARE(pressedSpy.at(1).at(0).toInt(), 8); |
|
2050 |
|
2051 QTest::mouseClick(tv.horizontalHeader()->viewport(), Qt::LeftButton, Qt::NoModifier, |
|
2052 QPoint(tv.horizontalHeader()->sectionViewportPosition(0) + 5, 5)); |
|
2053 |
|
2054 QCOMPARE(clickedSpy.count(), 3); |
|
2055 QCOMPARE(pressedSpy.count(), 3); |
|
2056 QCOMPARE(clickedSpy.at(2).at(0).toInt(), 0); |
|
2057 QCOMPARE(pressedSpy.at(2).at(0).toInt(), 0); |
|
2058 } |
|
2059 |
|
2060 void tst_QHeaderView::QTBUG8650_crashOnInsertSections() |
|
2061 { |
|
2062 QStringList headerLabels; |
|
2063 QHeaderView view(Qt::Horizontal); |
|
2064 QStandardItemModel model(2,2); |
|
2065 view.setModel(&model); |
|
2066 view.moveSection(1, 0); |
|
2067 view.hideSection(0); |
|
2068 |
|
2069 QList<QStandardItem *> items; |
|
2070 items << new QStandardItem("c"); |
|
2071 model.insertColumn(0, items); |
|
2072 } |
1995 |
2073 |
1996 QTEST_MAIN(tst_QHeaderView) |
2074 QTEST_MAIN(tst_QHeaderView) |
1997 #include "tst_qheaderview.moc" |
2075 #include "tst_qheaderview.moc" |