void tst_QColumnView::swapPreview() { // swap the preview widget in updatePreviewWidget QColumnView view; QStringList sl; sl << QLatin1String("test"); QStringListModel model(sl); view.setModel(&model); view.setCurrentIndex(view.indexAt(QPoint(1, 1))); connect(&view, SIGNAL(updatePreviewWidget(const QModelIndex &)), this, SLOT(setPreviewWidget())); view.setCurrentIndex(view.indexAt(QPoint(1, 1))); QTest::qWait(ANIMATION_DELAY); qApp->processEvents(); }
void tst_QColumnView::indexAt() { QColumnView view; QCOMPARE(view.indexAt(QPoint(0,0)), QModelIndex()); QDirModel model; view.setModel(&model); QModelIndex home = model.index(QDir::homePath()); QModelIndex homeFile = model.index(0, 0, home); if (!homeFile.isValid()) return; view.setRootIndex(home); QRect rect = view.visualRect(QModelIndex()); QVERIFY(!rect.isValid()); rect = view.visualRect(homeFile); QVERIFY(rect.isValid()); QModelIndex child; for (int i = 0; i < model.rowCount(home); ++i) { child = model.index(i, 0, home); rect = view.visualRect(child); QVERIFY(rect.isValid()); if (i > 0) QVERIFY(rect.top() > 0); QCOMPARE(view.indexAt(rect.center()), child); view.selectionModel()->select(child, QItemSelectionModel::SelectCurrent); view.setCurrentIndex(child); qApp->processEvents(); QTest::qWait(200); // test that the second row doesn't start at 0 if (model.rowCount(child) > 0) { child = model.index(0, 0, child); QVERIFY(child.isValid()); rect = view.visualRect(child); QVERIFY(rect.isValid()); QVERIFY(rect.left() > 0); QCOMPARE(view.indexAt(rect.center()), child); break; } } }