summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/itemviews')
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp36
-rw-r--r--tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp7
-rw-r--r--tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qfileiconprovider/tst_qfileiconprovider.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp539
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp10
-rw-r--r--tests/auto/widgets/itemviews/qitemeditorfactory/tst_qitemeditorfactory.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qitemview/viewstotest.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp10
-rw-r--r--tests/auto/widgets/itemviews/qstandarditem/tst_qstandarditem.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qstandarditemmodel/tst_qstandarditemmodel.cpp24
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp7
-rw-r--r--tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp10
-rw-r--r--tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp4
19 files changed, 639 insertions, 48 deletions
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index 764838fc96..be7c58f20b 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -224,16 +224,29 @@ private slots:
void ctrlRubberbandSelection();
void QTBUG6407_extendedSelection();
void QTBUG6753_selectOnSelection();
+ void testDelegateDestroyEditor();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
{
public:
- MyAbstractItemDelegate() : QAbstractItemDelegate() {};
+ MyAbstractItemDelegate() : QAbstractItemDelegate() { calledVirtualDtor = false; }
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const {}
QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const { return QSize(); }
- QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
- const QModelIndex &) const { return new QWidget(parent); }
+ QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const
+ {
+ openedEditor = new QWidget(parent);
+ return openedEditor;
+ }
+ void destroyEditor(QWidget *editor, const QModelIndex &index) const
+ {
+ calledVirtualDtor = true;
+ // QAbstractItemDelegate::destroyEditor(editor,index);
+ editor->deleteLater();
+ }
+
+ mutable bool calledVirtualDtor;
+ mutable QWidget *openedEditor;
};
// Testing get/set functions
@@ -1497,5 +1510,18 @@ void tst_QAbstractItemView::QTBUG6753_selectOnSelection()
QCOMPARE(table.selectedItems().first(), table.item(item.row(), item.column()));
}
+void tst_QAbstractItemView::testDelegateDestroyEditor()
+{
+ QTableWidget table(5, 5);
+ MyAbstractItemDelegate delegate;
+ table.setItemDelegate(&delegate);
+ table.edit(table.model()->index(1, 1));
+ TestView *tv = reinterpret_cast<TestView*>(&table);
+ QVERIFY(!delegate.calledVirtualDtor);
+ tv->tst_closeEditor(delegate.openedEditor, QAbstractItemDelegate::NoHint);
+ QVERIFY(delegate.calledVirtualDtor);
+}
+
+
QTEST_MAIN(tst_QAbstractItemView)
#include "tst_qabstractitemview.moc"
diff --git a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
index abf7929a94..74e4ca627f 100644
--- a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
+++ b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -537,6 +537,9 @@ void tst_QColumnView::moveCursor()
idx = idx.sibling(idx.row() + 1, idx.column());
view.setCurrentIndex(idx);
mc = view.MoveCursor(action, Qt::NoModifier);
+#ifdef Q_OS_MAC
+ QEXPECT_FAIL("", "QTBUG-23697", Continue);
+#endif
QCOMPARE(mc, idx.sibling(idx.row() + 1, idx.column()));
}
diff --git a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
index 4ad8de1d3d..6d869cd3f0 100644
--- a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
+++ b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp b/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp
index ef183ed91c..04069a2011 100644
--- a/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp
+++ b/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tests/auto/widgets/itemviews/qfileiconprovider/tst_qfileiconprovider.cpp b/tests/auto/widgets/itemviews/qfileiconprovider/tst_qfileiconprovider.cpp
index 286a352304..f01b3679b4 100644
--- a/tests/auto/widgets/itemviews/qfileiconprovider/tst_qfileiconprovider.cpp
+++ b/tests/auto/widgets/itemviews/qfileiconprovider/tst_qfileiconprovider.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index f1a7b4588e..75a72a754f 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Thorbjørn Lund Martsum - tmartsum[at]gmail.com
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +35,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -74,6 +75,26 @@ public:
friend class tst_QHeaderView;
};
+class XResetModel : public QStandardItemModel
+{
+ virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex())
+ {
+ blockSignals(true);
+ bool r = QStandardItemModel::removeRows(row, count, parent);
+ blockSignals(false);
+ emit reset();
+ return r;
+ }
+ virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex())
+ {
+ blockSignals(true);
+ bool r = QStandardItemModel::insertRows(row, count, parent);
+ blockSignals(false);
+ emit reset();
+ return r;
+ }
+};
+
class tst_QHeaderView : public QObject
{
Q_OBJECT
@@ -172,6 +193,7 @@ private slots:
void removeSection();
void preserveHiddenSectionWidth();
void invisibleStretchLastSection();
+ void noSectionsWithNegativeSize();
void emptySectionSpan();
void task236450_hidden_data();
@@ -181,13 +203,42 @@ private slots:
void QTBUG7833_sectionClicked();
void QTBUG8650_crashOnInsertSections();
void QTBUG12268_hiddenMovedSectionSorting();
+ void QTBUG14242_hideSectionAutoSize();
void initialSortOrderRole();
+ void logicalIndexAtTest_data() { setupTestData(); }
+ void visualIndexAtTest_data() { setupTestData(); }
+ void hideShowTest_data() { setupTestData(); }
+ void swapSectionsTest_data() { setupTestData(); }
+ void moveSectionTest_data() { setupTestData(); }
+ void defaultSizeTest_data() { setupTestData(); }
+ void removeTest_data() { setupTestData(true); }
+ void insertTest_data() { setupTestData(true); }
+ void mixedTests_data() { setupTestData(true); }
+ void resizeToContentTest_data() { setupTestData(); }
+ void logicalIndexAtTest();
+ void visualIndexAtTest();
+ void hideShowTest();
+ void swapSectionsTest();
+ void moveSectionTest();
+ void defaultSizeTest();
+ void removeTest();
+ void insertTest();
+ void mixedTests();
+ void resizeToContentTest();
+
protected:
+ void setupTestData(bool use_reset_model = false);
+ void additionalInit();
+ void calculateAndCheck(int cppline, const int precalced_comparedata[]);
+
QWidget *topLevel;
QHeaderView *view;
QStandardItemModel *model;
+ QTableView *m_tableview;
+ bool m_using_reset_model;
+ QElapsedTimer timer;
};
class QtTestModel: public QAbstractTableModel
@@ -327,10 +378,12 @@ void tst_QHeaderView::initTestCase()
#ifdef Q_OS_WINCE //disable magic for WindowsCE
qApp->setAutoMaximizeThreshold(-1);
#endif
+ m_tableview = new QTableView();
}
void tst_QHeaderView::cleanupTestCase()
{
+ delete m_tableview;
}
void tst_QHeaderView::init()
@@ -370,7 +423,9 @@ void tst_QHeaderView::init()
void tst_QHeaderView::cleanup()
{
- delete view;
+ m_tableview->setUpdatesEnabled(true);
+ if (view && view->parent() != m_tableview)
+ delete view;
view = 0;
delete model;
model = 0;
@@ -1852,6 +1907,15 @@ void tst_QHeaderView::invisibleStretchLastSection()
QCOMPARE(view.sectionSize(count - 1), view.defaultSectionSize() * 2);
}
+void tst_QHeaderView::noSectionsWithNegativeSize()
+{
+ QStandardItemModel m(4, 4);
+ QHeaderView h(Qt::Horizontal);
+ h.setModel(&m);
+ h.resizeSection(1, -5);
+ QVERIFY(h.sectionSize(1) >= 0); // Sections with negative sizes not well defined.
+}
+
void tst_QHeaderView::emptySectionSpan()
{
QHeaderViewPrivate::SectionSpan span;
@@ -2054,7 +2118,7 @@ void tst_QHeaderView::QTBUG8650_crashOnInsertSections()
void tst_QHeaderView::QTBUG12268_hiddenMovedSectionSorting()
{
- QTableView view;
+ QTableView view; // ### this test fails on QTableView &view = *m_tableview; !? + shadowing view member
QStandardItemModel *model = new QStandardItemModel(4,3, &view);
for (int i = 0; i< model->rowCount(); ++i)
for (int j = 0; j< model->columnCount(); ++j)
@@ -2072,9 +2136,29 @@ void tst_QHeaderView::QTBUG12268_hiddenMovedSectionSorting()
QCOMPARE(view.horizontalHeader()->hiddenSectionCount(), 1);
}
+void tst_QHeaderView::QTBUG14242_hideSectionAutoSize()
+{
+ QTableView qtv;
+ QStandardItemModel amodel(4, 4);
+ qtv.setModel(&amodel);
+ QHeaderView *hv = qtv.verticalHeader();
+ hv->setDefaultSectionSize(25);
+ hv->setResizeMode(QHeaderView::ResizeToContents);
+ qtv.show();
+
+ hv->hideSection(0);
+ int afterlength = hv->length();
+
+ int calced_length = 0;
+ for (int u = 0; u < hv->count(); ++u)
+ calced_length += hv->sectionSize(u);
+
+ QVERIFY(calced_length == afterlength);
+}
+
void tst_QHeaderView::initialSortOrderRole()
{
- QTableView view;
+ QTableView view; // ### Shadowing member view (of type QHeaderView)
QStandardItemModel *model = new QStandardItemModel(4, 3, &view);
for (int i = 0; i< model->rowCount(); ++i)
for (int j = 0; j< model->columnCount(); ++j)
@@ -2107,5 +2191,450 @@ void tst_QHeaderView::initialSortOrderRole()
QCOMPARE(view.horizontalHeader()->sortIndicatorOrder(), Qt::AscendingOrder);
}
+const bool block_some_signals = true; // The test should also work with this set to false
+const int rowcount = 500;
+const int colcount = 10;
+
+QString istr(int n, bool comma = true)
+{
+ QString s;
+ s.setNum(n);
+ if (comma)
+ s += ", ";
+ return s;
+}
+
+void tst_QHeaderView::calculateAndCheck(int cppline, const int precalced_comparedata[])
+{
+ qint64 endtimer = timer.elapsed();
+ const bool silentmode = true;
+ if (!silentmode)
+ qDebug().nospace() << "(Time:" << endtimer << ")";
+
+ QString sline;
+ sline.setNum(cppline - 1);
+
+ const int p1 = 3133777; // just a prime (maybe not that random ;) )
+ const int p2 = 135928393; // just a random large prime - a bit less than signed 32-bit
+
+ int sum_visual = 0;
+ int sum_logical = 0;
+ int sum_size = 0;
+ int sum_hidden_size = 0;
+ int sum_lookup_visual = 0;
+ int sum_lookup_logical = 0;
+
+ int chk_visual = 1;
+ int chk_logical = 1;
+ int chk_sizes = 1;
+ int chk_hidden_size = 1;
+ int chk_lookup_visual = 1;
+ int chk_lookup_logical = 1;
+
+ int header_lenght = 0;
+ int lastindex = view->count() - 1;
+
+ // calculate information based on index
+ for (int i = 0; i <= lastindex; ++i) {
+ int visual = view->visualIndex(i);
+ int logical = view->logicalIndex(i);
+ int ssize = view->sectionSize(i);
+
+ sum_visual += visual;
+ sum_logical += logical;
+ sum_size += ssize;
+
+ if (visual >= 0) {
+ chk_visual %= p2;
+ chk_visual *= (visual + 1) * (i + 1) * p1;
+ }
+
+ if (logical >= 0) {
+ chk_logical %= p2;
+ chk_logical *= (logical + 1) * (i + 1 + (logical != i) ) * p1;
+ }
+
+ if (ssize >= 0) {
+ chk_sizes %= p2;
+ chk_sizes *= ( (ssize + 2) * (i + 1) * p1);
+ }
+
+ if (view->isSectionHidden(i)) {
+ view->showSection(i);
+ int hiddensize = view->sectionSize(i);
+ sum_hidden_size += hiddensize;
+ chk_hidden_size %= p2;
+ chk_hidden_size += ( (hiddensize + 1) * (i + 1) * p1);
+ // (hiddensize + 1) in the above to differ between hidden and size 0
+ // Though it can be changed (why isn't sections with size 0 hidden?)
+
+ view->hideSection(i);
+ }
+ }
+
+ // lookup indexes by pixel position
+ const int max_lookup_count = 500;
+ int lookup_to = view->height() + 1;
+ if (lookup_to > max_lookup_count)
+ lookup_to = max_lookup_count; // We limit this lookup - not to spend years when testing.
+ // Notice that lookupTest also has its own extra test
+ for (int u = 0; u < max_lookup_count; ++u) {
+ int visu = view->visualIndexAt(u);
+ int logi = view->logicalIndexAt(u);
+ sum_lookup_visual += logi;
+ sum_lookup_logical += visu;
+ chk_lookup_visual %= p2;
+ chk_lookup_visual *= ( (u + 1) * p1 * (visu + 2));
+ chk_lookup_logical %= p2;
+ chk_lookup_logical *= ( (u + 1) * p1 * (logi + 2));
+ }
+ header_lenght = view->length();
+
+ // visual and logical indexes.
+ int sum_to_last_index = (lastindex * (lastindex + 1)) / 2; // == 0 + 1 + 2 + 3 + ... + lastindex
+
+ const bool write_calced_data = false; // Do not write calculated output (unless the test fails)
+ if (write_calced_data) {
+ qDebug().nospace() << "(" << cppline - 1 << ")" // << " const int precalced[] = "
+ << " {" << chk_visual << ", " << chk_logical << ", " << chk_sizes << ", " << chk_hidden_size
+ << ", " << chk_lookup_visual << ", " << chk_lookup_logical << ", " << header_lenght << "};";
+ }
+
+ const bool sanity_checks = true;
+ if (sanity_checks) {
+ QString msg = QString("sanity problem at ") + sline;
+ char *verifytext = QTest::toString(msg);
+
+ QVERIFY2(m_tableview->model()->rowCount() == view->count() , verifytext);
+ QVERIFY2(view->visualIndex(lastindex + 1) <= 0, verifytext); // there is no such index in model
+ QVERIFY2(view->logicalIndex(lastindex + 1) <= 0, verifytext); // there is no such index in model.
+ QVERIFY2(view->logicalIndex(lastindex + 1) <= 0, verifytext); // there is no such index in model.
+ QVERIFY2(lastindex < 0 || view->visualIndex(0) >= 0, verifytext); // no rows or legal index
+ QVERIFY2(lastindex < 0 || view->logicalIndex(0) >= 0, verifytext); // no rows or legal index
+ QVERIFY2(lastindex < 0 || view->visualIndex(lastindex) >= 0, verifytext); // no rows or legal index
+ QVERIFY2(lastindex < 0 || view->logicalIndex(lastindex) >= 0, verifytext); // no rows or legal index
+ QVERIFY2(view->visualIndexAt(-1) == -1, verifytext);
+ QVERIFY2(view->logicalIndexAt(-1) == -1, verifytext);
+ QVERIFY2(view->visualIndexAt(view->length()) == -1, verifytext);
+ QVERIFY2(view->logicalIndexAt(view->length()) == -1, verifytext);
+ QVERIFY2(sum_visual == sum_logical, verifytext);
+ QVERIFY2(sum_to_last_index == sum_logical, verifytext);
+ }
+
+ // Semantic test
+ const bool check_semantics = true; // Otherwise there is no 'real' test
+ if (!check_semantics)
+ return;
+
+ const int *x = precalced_comparedata;
+
+ QString msg = "semantic problem at " + QString(__FILE__) + " (" + sline + ")";
+ msg += "\nThe *expected* result was : {" + istr(x[0]) + istr(x[1]) + istr(x[2]) + istr(x[3])
+ + istr(x[4]) + istr(x[5]) + istr(x[6], false) + "}";
+ msg += "\nThe calculated result was : {";
+ msg += istr(chk_visual) + istr(chk_logical) + istr(chk_sizes) + istr(chk_hidden_size)
+ + istr(chk_lookup_visual) + istr(chk_lookup_logical) + istr(header_lenght, false) + "};";
+
+ char *verifytext = QTest::toString(msg);
+
+ QVERIFY2(chk_visual == x[0], verifytext);
+ QVERIFY2(chk_logical == x[1], verifytext);
+ QVERIFY2(chk_sizes == x[2], verifytext);
+ QVERIFY2(chk_hidden_size == x[3], verifytext);
+ QVERIFY2(chk_lookup_visual == x[4], verifytext); // Here the semantic can change. See final note (*).
+ QVERIFY2(chk_lookup_logical == x[5], verifytext); // Here the semantic can change. See final note (*).
+ QVERIFY2(header_lenght == x[6], verifytext);
+}
+
+void tst_QHeaderView::setupTestData(bool also_use_reset_model)
+{
+ QTest::addColumn<bool>("updates_enabled");
+ QTest::addColumn<bool>("special_prepare");
+ QTest::addColumn<bool>("reset_model");
+
+ if (also_use_reset_model) {
+ QTest::newRow("no_updates+normal") << false << false << true;
+ QTest::newRow("hasupdates+normal") << true << false << true;
+ QTest::newRow("no_updates+special") << false << true << true;
+ QTest::newRow("no_updates+special") << true << true << true;
+ }
+
+ QTest::newRow("no_updates+normal") << false << false << false;
+ QTest::newRow("hasupdates+normal") << true << false << false;
+ QTest::newRow("no_updates+special") << false << true << false;
+ QTest::newRow("no_updates+special") << true << true << false;
+}
+
+void tst_QHeaderView::additionalInit()
+{
+ m_tableview->setVerticalHeader(view);
+
+ QFETCH(bool, updates_enabled);
+ QFETCH(bool, special_prepare);
+ QFETCH(bool, reset_model);
+
+ m_using_reset_model = reset_model;
+
+ if (m_using_reset_model) {
+ XResetModel *m = new XResetModel();
+ m_tableview->setModel(m);
+ delete model;
+ model = m;
+ } else {
+ m_tableview->setModel(model);
+ }
+
+ const int default_section_size = 25;
+ view->setDefaultSectionSize(default_section_size); // Important - otherwise there will be semantic changes
+
+ model->clear();
+
+ if (special_prepare) {
+
+ for (int u = 0; u <= rowcount; ++u) // ensures fragmented spans in e.g Qt 4.7
+ model->setRowCount(u);
+
+ model->setColumnCount(colcount);
+ view->swapSections(0, rowcount - 1);
+ view->swapSections(0, rowcount - 1); // No real change - setup visual and log-indexes
+ view->hideSection(rowcount - 1);
+ view->showSection(rowcount - 1); // No real change - (maybe init hidden vector)
+ } else {
+ model->setColumnCount(colcount);
+ model->setRowCount(rowcount);
+ }
+
+ QString s;
+ for (int i = 0; i < model->rowCount(); ++i) {
+ model->setData(model->index(i, 0), QVariant(i));
+ s.setNum(i);
+ s += ".";
+ s += 'a' + (i % 25);
+ model->setData(model->index(i, 1), QVariant(s));
+ }
+ m_tableview->setUpdatesEnabled(updates_enabled);
+ view->blockSignals(block_some_signals);
+ timer.start();
+}
+
+void tst_QHeaderView::logicalIndexAtTest()
+{
+ additionalInit();
+
+ view->swapSections(4, 9); // Make sure that visual and logical Indexes are not just the same.
+
+ int check1 = 0;
+ int check2 = 0;
+ for (int u = 0; u < model->rowCount(); ++u) {
+ view->resizeSection(u, 10 + u % 30);
+ int v = view->visualIndexAt(u * 29);
+ view->visualIndexAt(u * 29);
+ check1 += v;
+ check2 += u * v;
+ }
+ view->resizeSection(0, 0); // Make sure that we have a 0 size section - before the result set
+ view->setSectionHidden(6, true); // Make sure we have a real hidden section before result set
+
+ //qDebug() << "logicalIndexAtTest" << check1 << check2;
+ const int precalced_check1 = 106327;
+ const int precalced_check2 = 29856418;
+ QVERIFY(precalced_check1 == check1); // Here the semantic can change. See final note (*)
+ QVERIFY(precalced_check2 == check2); // Here the semantic can change. See final note (*)
+
+ const int precalced_results[] = { 1145298384, -1710423344, -650981936, 372919464, 2139446944, 854793816, 12124 };
+ calculateAndCheck(__LINE__, precalced_results);
+}
+
+void tst_QHeaderView::visualIndexAtTest()
+{
+ additionalInit();
+
+ view->swapSections(4, 9); // Make sure that visual and logical Indexes are not just the same.
+ int check1 = 0;
+ int check2 = 0;
+
+ for (int u = 0; u < model->rowCount(); ++u) {
+ view->resizeSection(u, 3 + u % 17);
+ int v = view->visualIndexAt(u * 29);
+ check1 += v;
+ check2 += u * v;
+ }
+
+ view->resizeSection(1, 0); // Make sure that we have a 0 size section - before the result set
+ view->setSectionHidden(5, true); // Make sure we have a real hidden section before result set
+
+ //qDebug() << "visualIndexAtTest" << check1 << check2;
+ const int precalced_check1 = 72665;
+ const int precalced_check2 = 14015890;
+ QVERIFY(precalced_check1 == check1); // Here the semantic can change. See final note (*)
+ QVERIFY(precalced_check2 == check2); // Here the semantic can change. See final note (*)
+
+ const int precalced_results[] = { 1145298384, -1710423344, -1457520212, 169223959, 726651072, -2105938696, 5453 };
+ calculateAndCheck(__LINE__, precalced_results);
+}
+
+void tst_QHeaderView::hideShowTest()
+{
+ additionalInit();
+
+ for (int u = model->rowCount(); u >= 0; --u)
+ if (u % 8 != 0)
+ view->hideSection(u);
+
+ for (int u = model->rowCount(); u >= 0; --u)
+ if (u % 3 == 0)
+ view->showSection(u);
+
+ view->setSectionHidden(model->rowCount(), true); // invalid hide (should be ignored)
+ view->setSectionHidden(-1, true); // invalid hide (should be ignored)
+
+ const int precalced_results[] = { -1523279360, -1523279360, -1321506816, 2105322423, 1879611280, 1879611280, 5225 };
+ calculateAndCheck(__LINE__, precalced_results);
+}
+
+void tst_QHeaderView::swapSectionsTest()
+{
+ additionalInit();
+
+ for (int u = 0; u < rowcount / 2; ++u)
+ view->swapSections(u, rowcount - u - 1);
+
+ for (int u = 0; u < rowcount; u += 2)
+ view->swapSections(u, u + 1);
+
+ view->swapSections(0, model->rowCount()); // invalid swapsection (should be ignored)
+
+ const int precalced_results[] = { -1536450048, -1774641430, -1347156568, 1, 1719705216, -240077576, 12500 };
+ calculateAndCheck(__LINE__, precalced_results);
+}
+
+void tst_QHeaderView::moveSectionTest()
+{
+ additionalInit();
+
+ for (int u = 1; u < 5; ++u)
+ view->moveSection(u, model->rowCount() - u);
+
+ view->moveSection(2, model->rowCount() / 2);
+ view->moveSection(0, 10);
+ view->moveSection(0, model->rowCount() - 10);
+
+ view->moveSection(0, model->rowCount()); // invalid move (should be ignored)
+
+ const int precalced_results[] = { 645125952, 577086896, -1347156568, 1, 1719705216, 709383416, 12500 };
+ calculateAndCheck(__LINE__, precalced_results);
+}
+
+void tst_QHeaderView::defaultSizeTest()
+{
+ additionalInit();
+
+ view->hideSection(rowcount / 2);
+ int restore_to = view->defaultSectionSize();
+ view->setDefaultSectionSize(restore_to + 5);
+
+ const int precalced_results[] = { -1523279360, -1523279360, -1739688320, -1023807777, 997629696, 997629696, 14970 };
+ calculateAndCheck(__LINE__, precalced_results);
+
+ view->setDefaultSectionSize(restore_to);
+}
+
+void tst_QHeaderView::removeTest()
+{
+ additionalInit();
+
+ view->swapSections(0, 5);
+ model->removeRows(0, 1); // remove one row
+ model->removeRows(4, 10);
+ model->setRowCount(model->rowCount() / 2 - 1);
+
+ if (m_using_reset_model) {
+ const int precalced_results[] = { 1741224292, -135269187, -569519837, 1, 1719705216, -1184395000, 6075 };
+ calculateAndCheck(__LINE__, precalced_results);
+ } else {
+ const int precalced_results[] = { 289162397, 289162397, -569519837, 1, 1719705216, 1719705216, 6075 };
+ calculateAndCheck(__LINE__, precalced_results);
+ }
+}
+
+void tst_QHeaderView::insertTest()
+{
+ additionalInit();
+
+ view->swapSections(0, model->rowCount() - 1);
+ model->insertRows(0, 1); // insert one row
+ model->insertRows(4, 10);
+ model->setRowCount(model->rowCount() * 2 - 1);
+
+ if (m_using_reset_model) {
+ const int precalced_results[] = { 2040508069, -1280266538, -150350734, 1, 1719705216, 1331312784, 25525 };
+ calculateAndCheck(__LINE__, precalced_results);
+ } else {
+ const int precalced_results[] = { -1909447021, 339092083, -150350734, 1, 1719705216, -969712728, 25525 };
+ calculateAndCheck(__LINE__, precalced_results);
+ }
+}
+
+void tst_QHeaderView::mixedTests()
+{
+ additionalInit();
+
+ model->setRowCount(model->rowCount() + 10);
+
+ for (int u = 0; u < model->rowCount(); u += 2)
+ view->swapSections(u, u + 1);
+
+ view->moveSection(0, 5);
+
+ for (int u = model->rowCount(); u >= 0; --u) {
+ if (u % 5 != 0)
+ view->hideSection(u);
+ if (u % 3 != 0)
+ view->showSection(u);
+ }
+
+ model->insertRows(3, 7);
+ model->removeRows(8, 3);
+ model->setRowCount(model->rowCount() - 10);
+
+ if (m_using_reset_model) {
+ const int precalced_results[] = { 898296472, 337096378, -543340640, 1, 703951756, 250831536, 9250 };
+ calculateAndCheck(__LINE__, precalced_results);
+ } else {
+ const int precalced_results[] = { 1911338224, 1693514365, -613398968, -1912534953, 1582159424, -1851079000, 9300 };
+ calculateAndCheck(__LINE__, precalced_results);
+ }
+}
+
+void tst_QHeaderView::resizeToContentTest()
+{
+ additionalInit();
+
+ QModelIndex idx = model->index(2, 2);
+ model->setData(idx, QVariant("A normal string"));
+
+ idx = model->index(1, 3);
+ model->setData(idx, QVariant("A normal longer string to test resize"));
+
+ QHeaderView *hh = m_tableview->horizontalHeader();
+ hh->resizeSections(QHeaderView::ResizeToContents);
+ QVERIFY(hh->sectionSize(3) > hh->sectionSize(2));
+
+ for (int u = 0; u < 10; ++u)
+ view->resizeSection(u, 1);
+
+ view->resizeSections(QHeaderView::ResizeToContents);
+ QVERIFY(view->sectionSize(1) > 1);
+ QVERIFY(view->sectionSize(2) > 1);
+
+ view->setDefaultSectionSize(25); // To make sure our precalced data are correct. We do not know font height etc.
+
+ const int precalced_results[] = { -1523279360, -1523279360, -1347156568, 1, 1719705216, 1719705216, 12500 };
+ calculateAndCheck(__LINE__, precalced_results);
+}
+
+// (*) Currently qheaderview position lookup acts a bit strange. It can return sections with size 0.
+// This could be changed in the future.
+
QTEST_MAIN(tst_QHeaderView)
#include "tst_qheaderview.moc"
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index 30bf867249..2b52f5f234 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -1033,6 +1033,9 @@ void tst_QItemDelegate::editorEvent()
QStyleOptionViewItem option;
option.rect = rect;
option.state |= QStyle::State_Enabled;
+ // mimic QStyledItemDelegate::initStyleOption logic
+ option.features |= QStyleOptionViewItem::HasCheckIndicator | QStyleOptionViewItem::HasDisplay;
+ option.checkState = Qt::CheckState(checkState);
const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1;
QPoint pos = inCheck ? qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center() + QPoint(checkMargin, 0) : QPoint(200,200);
@@ -1181,6 +1184,9 @@ void tst_QItemDelegate::QTBUG4435_keepSelectionOnCheck()
QTest::qWaitForWindowShown(&view);
QStyleOptionViewItem option;
option.rect = view.visualRect(model.index(0, 0));
+ // mimic QStyledItemDelegate::initStyleOption logic
+ option.features = QStyleOptionViewItem::HasDisplay | QStyleOptionViewItem::HasCheckIndicator;
+ option.checkState = Qt::CheckState(model.index(0, 0).data(Qt::CheckStateRole).toInt());
const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1;
QPoint pos = qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center()
+ QPoint(checkMargin, 0);
diff --git a/tests/auto/widgets/itemviews/qitemeditorfactory/tst_qitemeditorfactory.cpp b/tests/auto/widgets/itemviews/qitemeditorfactory/tst_qitemeditorfactory.cpp
index 3945e65f80..3d5201494e 100644
--- a/tests/auto/widgets/itemviews/qitemeditorfactory/tst_qitemeditorfactory.cpp
+++ b/tests/auto/widgets/itemviews/qitemeditorfactory/tst_qitemeditorfactory.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp
index 7f8337a5d8..04b32d1e56 100644
--- a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp
+++ b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tests/auto/widgets/itemviews/qitemview/viewstotest.cpp b/tests/auto/widgets/itemviews/qitemview/viewstotest.cpp
index 15f1a4d02f..33993de125 100644
--- a/tests/auto/widgets/itemviews/qitemview/viewstotest.cpp
+++ b/tests/auto/widgets/itemviews/qitemview/viewstotest.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index e56a8e1008..523516a4b4 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
index 8849b3ae6d..35e13e2f0a 100644
--- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -122,7 +122,7 @@ private slots:
void changeDataWithSorting();
void itemData();
void itemWidget();
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
void fastScroll();
#endif
void insertUnchanged();
@@ -1489,7 +1489,7 @@ void tst_QListWidget::itemWidget()
QCOMPARE(list.itemWidget(item), static_cast<QWidget*>(0));
}
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
class MyListWidget : public QListWidget
{
public:
@@ -1537,7 +1537,7 @@ void tst_QListWidget::fastScroll()
// only one item should be repainted, the rest should be scrolled in memory
QCOMPARE(widget.painted.boundingRect().size(), itemSize);
}
-#endif // Q_WS_MAC
+#endif // Q_OS_MAC
void tst_QListWidget::insertUnchanged()
{
diff --git a/tests/auto/widgets/itemviews/qstandarditem/tst_qstandarditem.cpp b/tests/auto/widgets/itemviews/qstandarditem/tst_qstandarditem.cpp
index a0e485a8c3..8ababf0ac4 100644
--- a/tests/auto/widgets/itemviews/qstandarditem/tst_qstandarditem.cpp
+++ b/tests/auto/widgets/itemviews/qstandarditem/tst_qstandarditem.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tests/auto/widgets/itemviews/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/widgets/itemviews/qstandarditemmodel/tst_qstandarditemmodel.cpp
index 78ac43f79a..1c661f9060 100644
--- a/tests/auto/widgets/itemviews/qstandarditemmodel/tst_qstandarditemmodel.cpp
+++ b/tests/auto/widgets/itemviews/qstandarditemmodel/tst_qstandarditemmodel.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -134,6 +134,8 @@ private slots:
void treeDragAndDrop();
void removeRowsAndColumns();
+ void itemRoleNames();
+
private:
QAbstractItemModel *m_model;
QPersistentModelIndex persistent;
@@ -1658,6 +1660,24 @@ void tst_QStandardItemModel::removeRowsAndColumns()
VERIFY_MODEL
}
+void tst_QStandardItemModel::itemRoleNames()
+{
+ QVector<QString> row_list = QString("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20").split(',').toVector();
+ QVector<QString> col_list = row_list;
+ QStandardItemModel model;
+ for (int c = 0; c < col_list.count(); c++)
+ for (int r = 0; r < row_list.count(); r++)
+ model.setItem(r, c, new QStandardItem(row_list[r] + "x" + col_list[c]));
+ VERIFY_MODEL
+
+ QHash<int, QByteArray> newRoleNames;
+ newRoleNames.insert(Qt::DisplayRole, "Name");
+ newRoleNames.insert(Qt::DecorationRole, "Avatar");
+ model.setItemRoleNames(newRoleNames);
+ QCOMPARE(model.roleNames(), newRoleNames);
+ VERIFY_MODEL
+}
+
QTEST_MAIN(tst_QStandardItemModel)
#include "tst_qstandarditemmodel.moc"
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index 74917fbf9a..586c2efd8f 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
index 5e2658a47f..fe1d15a84d 100644
--- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 5d0ef9d09b..e1f175ad1b 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -841,6 +841,9 @@ void tst_QTreeView::editTriggers()
}
// Check if we got an editor
+#ifdef Q_OS_MAC
+ QEXPECT_FAIL("EditKeyPressed 4", "QTBUG-23696", Continue);
+#endif
QTRY_COMPARE(qFindChild<QLineEdit *>(&view, QString()) != 0, editorOpened);
}
diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
index 14f1f8736d..07e0e4f999 100644
--- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -1838,7 +1838,7 @@ void tst_QTreeWidget::setData()
item->setBackground(j, backgroundColor);
QCOMPARE(itemChangedSpy.count(), 0);
- QColor textColor((i == i) ? Qt::green : Qt::cyan);
+ QColor textColor((i == 1) ? Qt::green : Qt::cyan);
item->setTextColor(j, textColor);
QCOMPARE(item->textColor(j), textColor);
QCOMPARE(itemChangedSpy.count(), 1);
@@ -2978,6 +2978,10 @@ void tst_QTreeWidget::task191552_rtl()
QStyleOptionViewItem opt;
opt.initFrom(&tw);
opt.rect = tw.visualItemRect(item);
+ // mimic QStyledItemDelegate::initStyleOption logic
+ opt.features = QStyleOptionViewItem::HasDisplay | QStyleOptionViewItem::HasCheckIndicator;
+ opt.checkState = Qt::Checked;
+ opt.widget = &tw;
const QRect checkRect = tw.style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, &tw);
QTest::mouseClick(tw.viewport(), Qt::LeftButton, Qt::NoModifier, checkRect.center());
QTest::qWait(200);
diff --git a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
index b747586548..0e518b3e16 100644
--- a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/