summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-09 17:59:51 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-09 17:59:51 +0200
commit22e96c4d342de3bfe4fc27f4cd7233edcfe737cc (patch)
tree6bdd02cdd8603cf16383fb339a2cfdbce82491da /tests/auto
parentbd79c4e28c307ba87aca02155b845774c7ffec1f (diff)
parentfa95eb055401f5264cbc6aca761cb9b5feb4affc (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp16
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp52
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp55
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp2
-rw-r--r--tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp1
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp297
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp5
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp159
8 files changed, 299 insertions, 288 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index e982660bef..f589fe1d6d 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -898,13 +898,11 @@ void tst_QUrl::resolving_data()
// Some parsers allow the scheme name to be present in a relative URI
// reference if it is the same as the base URI scheme. This is
- // considered to be a loophole in prior specifications of partial URI
- // [RFC1630]. Its use should be avoided, but is allowed for backward
- // compatibility.
- // For strict parsers :
-// QTest::newRow("http:g [for strict parsers]") << QString::fromLatin1("http://a/b/c/d;p?q") << QString::fromLatin1("http:g") << QString::fromLatin1("http:g");
- // For backward compatibility :
- QTest::newRow("http:g [for backward compatibility]") << QString::fromLatin1("http://a/b/c/d;p?q") << QString::fromLatin1("http:g") << QString::fromLatin1("http://a/b/c/g");
+ // considered to be a loophole in prior specifications of partial URI [RFC1630],
+ //QTest::newRow("http:g [for backward compatibility]") << QString::fromLatin1("http://a/b/c/d;p?q") << QString::fromLatin1("http:g") << QString::fromLatin1("http://a/b/c/g");
+ // However we don't do that anymore, as per RFC3986, in order for the data:subpage testcase below to work.
+ QTest::newRow("http:g") << QString::fromLatin1("http://a/b/c/d;p?q") << QString::fromLatin1("http:g") << QString::fromLatin1("http:g");
+ QTest::newRow("data:subpage") << QString::fromLatin1("data:text/plain, main page") << QString::fromLatin1("data:text/plain, subpage") << QString::fromLatin1("data:text/plain, subpage");
// Resolve relative with relative
QTest::newRow("../a (1)") << QString::fromLatin1("b") << QString::fromLatin1("../a") << QString::fromLatin1("a");
@@ -916,6 +914,10 @@ void tst_QUrl::resolving_data()
QTest::newRow("../a (6)") << QString::fromLatin1("/b/a") << QString::fromLatin1("../a") << QString::fromLatin1("/a");
QTest::newRow("../a (7)") << QString::fromLatin1("/b/c/a") << QString::fromLatin1("../a") << QString::fromLatin1("/b/a");
QTest::newRow("../a (8)") << QString::fromLatin1("/b") << QString::fromLatin1("/a") << QString::fromLatin1("/a");
+
+ // More tests from KDE
+ QTest::newRow("brackets") << QString::fromLatin1("http://www.calorieking.com/personal/diary/") << QString::fromLatin1("/personal/diary/rpc.php?C=jsrs1&F=getDiaryDay&P0=[2006-3-8]&U=1141858921458") << QString::fromLatin1("http://www.calorieking.com/personal/diary/rpc.php?C=jsrs1&F=getDiaryDay&P0=[2006-3-8]&U=1141858921458");
+ QTest::newRow("javascript")<< QString::fromLatin1("http://www.youtube.com/?v=JvOSnRD5aNk") << QString::fromLatin1("javascript:window.location+\"__flashplugin_unique__\"") << QString::fromLatin1("javascript:window.location+%22__flashplugin_unique__%22");
}
void tst_QUrl::resolving()
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 8e2d583961..04a7129f01 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -143,6 +143,7 @@ private slots:
void noMapAfterSourceDelete();
void forwardDropApi();
void canDropMimeData();
+ void filterHint();
protected:
void buildHierarchy(const QStringList &data, QAbstractItemModel *model);
@@ -3802,6 +3803,12 @@ void tst_QSortFilterProxyModel::moveSourceRows()
QCOMPARE(filterBeforeParents.size(), 1);
QCOMPARE(filterAfterParents.size(), 1);
+ QCOMPARE(
+ filterBeforeParentLayoutSpy.first().at(1).value<QAbstractItemModel::LayoutChangeHint>(),
+ QAbstractItemModel::NoLayoutChangeHint);
+ QCOMPARE(filterAfterParentLayoutSpy.first().at(1).value<QAbstractItemModel::LayoutChangeHint>(),
+ QAbstractItemModel::NoLayoutChangeHint);
+
QCOMPARE(filterBothBeforeParentLayoutSpy.size(), 0);
QCOMPARE(filterBothAfterParentLayoutSpy.size(), 0);
}
@@ -4123,5 +4130,50 @@ void tst_QSortFilterProxyModel::resortingDoesNotBreakTreeModels()
QCOMPARE(proxy.rowCount(pi1), 1);
}
+void tst_QSortFilterProxyModel::filterHint()
+{
+ // test that a filtering model does not emit layoutChanged with a hint
+ QStringListModel model(QStringList() << "one"
+ << "two"
+ << "three"
+ << "four"
+ << "five"
+ << "six");
+ QSortFilterProxyModel proxy1;
+ proxy1.setSourceModel(&model);
+ proxy1.setSortRole(Qt::DisplayRole);
+ proxy1.setDynamicSortFilter(true);
+ proxy1.sort(0);
+
+ QSortFilterProxyModel proxy2;
+ proxy2.setSourceModel(&proxy1);
+ proxy2.setFilterRole(Qt::DisplayRole);
+ proxy2.setFilterRegExp("^[^ ]*$");
+ proxy2.setDynamicSortFilter(true);
+
+ QSignalSpy proxy1BeforeSpy(&proxy1, &QSortFilterProxyModel::layoutAboutToBeChanged);
+ QSignalSpy proxy1AfterSpy(&proxy1, &QSortFilterProxyModel::layoutChanged);
+ QSignalSpy proxy2BeforeSpy(&proxy2, &QSortFilterProxyModel::layoutAboutToBeChanged);
+ QSignalSpy proxy2AfterSpy(&proxy2, &QSortFilterProxyModel::layoutChanged);
+
+ model.setData(model.index(2), QStringLiteral("modified three"), Qt::DisplayRole);
+
+ // The first proxy was re-sorted as one item as changed.
+ QCOMPARE(proxy1BeforeSpy.size(), 1);
+ QCOMPARE(proxy1BeforeSpy.first().at(1).value<QAbstractItemModel::LayoutChangeHint>(),
+ QAbstractItemModel::VerticalSortHint);
+ QCOMPARE(proxy1AfterSpy.size(), 1);
+ QCOMPARE(proxy1AfterSpy.first().at(1).value<QAbstractItemModel::LayoutChangeHint>(),
+ QAbstractItemModel::VerticalSortHint);
+
+ // But the second proxy must not have the VerticalSortHint since an item was filtered
+ QCOMPARE(proxy2BeforeSpy.size(), 1);
+ QCOMPARE(proxy2BeforeSpy.first().at(1).value<QAbstractItemModel::LayoutChangeHint>(),
+ QAbstractItemModel::NoLayoutChangeHint);
+ QCOMPARE(proxy2AfterSpy.size(), 1);
+ QCOMPARE(proxy2AfterSpy.first().at(1).value<QAbstractItemModel::LayoutChangeHint>(),
+ QAbstractItemModel::NoLayoutChangeHint);
+}
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_qsortfilterproxymodel.moc"
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 262d8ad44b..75fa424ab1 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -275,6 +275,7 @@ private slots:
void metaEnums();
void compareSanity_data();
void compareSanity();
+ void compareRich();
void accessSequentialContainerKey();
@@ -4775,6 +4776,60 @@ void tst_QVariant::compareSanity()
}
}
+static void richComparison(const QVariant& less, const QVariant& more)
+{
+ QVERIFY(less.type() == more.type());
+
+ QVERIFY(less < more);
+ QVERIFY(!(more < less));
+
+ QVERIFY(more > less);
+ QVERIFY(!(less > more));
+
+ QVERIFY(less <= more);
+ QVERIFY(!(more <= less));
+ QVERIFY(less <= less);
+
+ QVERIFY(more >= less);
+ QVERIFY(!(less >= more));
+ QVERIFY(more >= more);
+}
+
+void tst_QVariant::compareRich()
+{
+ richComparison(QUuid("{49d8ad2a-2ee8-4c3d-949f-1b5a3765ddf0}"),
+ QUuid("{f6d56824-16e9-4543-a375-add2877c2d05}"));
+ richComparison(QByteArray::fromRawData("a", 1),
+ QByteArray::fromRawData("b", 1));
+ richComparison(QStringLiteral("a"), QStringLiteral("b"));
+ richComparison(QLatin1String("a"), QLatin1String("b"));
+ richComparison(QChar('a'), QChar('b'));
+ richComparison(QDate(2016, 7, 23), QDate(2016, 7, 24));
+ richComparison(QTime(0, 0), QTime(0, 1));
+ richComparison(QDateTime(QDate(2016, 7, 23), QTime(0, 0)),
+ QDateTime(QDate(2016, 7, 23), QTime(0, 1)));
+
+ richComparison(QStringList(), QStringList() << QStringLiteral("a"));
+ richComparison(QStringList(), QStringList() << QStringLiteral("a")
+ << QStringLiteral("b"));
+ richComparison(QStringList() << QStringLiteral("a"),
+ QStringList() << QStringLiteral("b"));
+ richComparison(QStringList() << QStringLiteral("a"),
+ QStringList() << QStringLiteral("b")
+ << QStringLiteral("c"));
+ richComparison(QStringList() << QStringLiteral("a")
+ << QStringLiteral("c"),
+ QStringList() << QStringLiteral("b"));
+ richComparison(QStringList() << QStringLiteral("a")
+ << QStringLiteral("c"),
+ QStringList() << QStringLiteral("b")
+ << QStringLiteral("d"));
+ richComparison(QStringList() << QStringLiteral("a")
+ << QStringLiteral("c"),
+ QStringList() << QStringLiteral("a")
+ << QStringLiteral("d"));
+}
+
void tst_QVariant::accessSequentialContainerKey()
{
QString nameResult;
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 36784435b8..7a37fdfa46 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -123,7 +123,7 @@ template <>
class Arg<QStringRef> : ArgBase
{
QStringRef ref() const
- { return this->pinned.isNull() ? QStringRef() : this->pinned.midRef(0) ; }
+ { return QStringRef(&pinned); }
public:
explicit Arg(const char *str) : ArgBase(str) {}
diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
index 00e01094a4..8cc06a77ba 100644
--- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
@@ -181,6 +181,7 @@ private slots:
void slotConnected()
{
QCOMPARE(state(), QLocalSocket::ConnectedState);
+ QVERIFY(isOpen());
}
void slotDisconnected()
{
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index 1050fa2561..7412637354 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -77,108 +77,6 @@ static inline void moveCursorAway(const QWidget *topLevel)
#endif
}
-class TestView : public QAbstractItemView
-{
- Q_OBJECT
-public:
- inline void tst_dataChanged(const QModelIndex &tl, const QModelIndex &br)
- { dataChanged(tl, br); }
- inline void tst_setHorizontalStepsPerItem(int steps)
- { setHorizontalStepsPerItem(steps); }
- inline int tst_horizontalStepsPerItem() const
- { return horizontalStepsPerItem(); }
- inline void tst_setVerticalStepsPerItem(int steps)
- { setVerticalStepsPerItem(steps); }
- inline int tst_verticalStepsPerItem() const
- { return verticalStepsPerItem(); }
-
- inline void tst_rowsInserted(const QModelIndex &parent, int start, int end)
- { rowsInserted(parent, start, end); }
- inline void tst_rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
- { rowsAboutToBeRemoved(parent, start, end); }
- inline void tst_selectionChanged(const QItemSelection &selected,
- const QItemSelection &deselected)
- { selectionChanged(selected, deselected); }
- inline void tst_currentChanged(const QModelIndex &current, const QModelIndex &previous)
- { currentChanged(current, previous); }
- inline void tst_updateEditorData()
- { updateEditorData(); }
- inline void tst_updateEditorGeometries()
- { updateEditorGeometries(); }
- inline void tst_updateGeometries()
- { updateGeometries(); }
- inline void tst_verticalScrollbarAction(int action)
- { verticalScrollbarAction(action); }
- inline void tst_horizontalScrollbarAction(int action)
- { horizontalScrollbarAction(action); }
- inline void tst_verticalScrollbarValueChanged(int value)
- { verticalScrollbarValueChanged(value); }
- inline void tst_horizontalScrollbarValueChanged(int value)
- { horizontalScrollbarValueChanged(value); }
- inline void tst_closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
- { closeEditor(editor, hint); }
- inline void tst_commitData(QWidget *editor)
- { commitData(editor); }
- inline void tst_editorDestroyed(QObject *editor)
- { editorDestroyed(editor); }
- enum tst_CursorAction {
- MoveUp = QAbstractItemView::MoveUp,
- MoveDown = QAbstractItemView::MoveDown,
- MoveLeft = QAbstractItemView::MoveLeft,
- MoveRight = QAbstractItemView::MoveRight,
- MoveHome = QAbstractItemView::MoveHome,
- MoveEnd = QAbstractItemView::MoveEnd,
- MovePageUp = QAbstractItemView::MovePageUp,
- MovePageDown = QAbstractItemView::MovePageDown,
- MoveNext = QAbstractItemView::MoveNext,
- MovePrevious = QAbstractItemView::MovePrevious
- };
- inline QModelIndex tst_moveCursor(tst_CursorAction cursorAction,
- Qt::KeyboardModifiers modifiers)
- { return moveCursor(QAbstractItemView::CursorAction(cursorAction), modifiers); }
- inline int tst_horizontalOffset() const
- { return horizontalOffset(); }
- inline int tst_verticalOffset() const
- { return verticalOffset(); }
- inline bool tst_isIndexHidden(const QModelIndex &index) const
- { return isIndexHidden(index); }
- inline void tst_setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)
- { setSelection(rect, command); }
- inline QRegion tst_visualRegionForSelection(const QItemSelection &selection) const
- { return visualRegionForSelection(selection); }
- inline QModelIndexList tst_selectedIndexes() const
- { return selectedIndexes(); }
- inline bool tst_edit(const QModelIndex &index, EditTrigger trigger, QEvent *event)
- { return edit(index, trigger, event); }
- inline QItemSelectionModel::SelectionFlags tst_selectionCommand(const QModelIndex &index,
- const QEvent *event = 0) const
- { return selectionCommand(index, event); }
-#ifndef QT_NO_DRAGANDDROP
- inline void tst_startDrag(Qt::DropActions supportedActions)
- { startDrag(supportedActions); }
-#endif
- inline QStyleOptionViewItem tst_viewOptions() const
- { return viewOptions(); }
- enum tst_State {
- NoState = QAbstractItemView::NoState,
- DraggingState = QAbstractItemView::DraggingState,
- DragSelectingState = QAbstractItemView::DragSelectingState,
- EditingState = QAbstractItemView::EditingState,
- ExpandingState = QAbstractItemView::ExpandingState,
- CollapsingState = QAbstractItemView::CollapsingState
- };
- inline tst_State tst_state() const
- { return (tst_State)state(); }
- inline void tst_setState(tst_State state)
- { setState(QAbstractItemView::State(state)); }
- inline void tst_startAutoScroll()
- { startAutoScroll(); }
- inline void tst_stopAutoScroll()
- { stopAutoScroll(); }
- inline void tst_doAutoScroll()
- { doAutoScroll(); }
-};
-
class GeometriesTestView : public QTableView
{
Q_OBJECT
@@ -194,7 +92,7 @@ class tst_QAbstractItemView : public QObject
Q_OBJECT
public:
- void basic_tests(TestView *view);
+ void basic_tests(QAbstractItemView *view);
private slots:
void cleanup();
@@ -278,7 +176,7 @@ public:
void tst_QAbstractItemView::getSetCheck()
{
QListView view;
- TestView *obj1 = reinterpret_cast<TestView*>(&view);
+ QAbstractItemView *obj1 = &view;
// QAbstractItemDelegate * QAbstractItemView::itemDelegate()
// void QAbstractItemView::setItemDelegate(QAbstractItemDelegate *)
MyAbstractItemDelegate *var1 = new MyAbstractItemDelegate;
@@ -329,18 +227,18 @@ void tst_QAbstractItemView::getSetCheck()
// State QAbstractItemView::state()
// void QAbstractItemView::setState(State)
- obj1->tst_setState(TestView::tst_State(TestView::NoState));
- QCOMPARE(TestView::tst_State(TestView::NoState), obj1->tst_state());
- obj1->tst_setState(TestView::tst_State(TestView::DraggingState));
- QCOMPARE(TestView::tst_State(TestView::DraggingState), obj1->tst_state());
- obj1->tst_setState(TestView::tst_State(TestView::DragSelectingState));
- QCOMPARE(TestView::tst_State(TestView::DragSelectingState), obj1->tst_state());
- obj1->tst_setState(TestView::tst_State(TestView::EditingState));
- QCOMPARE(TestView::tst_State(TestView::EditingState), obj1->tst_state());
- obj1->tst_setState(TestView::tst_State(TestView::ExpandingState));
- QCOMPARE(TestView::tst_State(TestView::ExpandingState), obj1->tst_state());
- obj1->tst_setState(TestView::tst_State(TestView::CollapsingState));
- QCOMPARE(TestView::tst_State(TestView::CollapsingState), obj1->tst_state());
+ obj1->setState(QAbstractItemView::NoState);
+ QCOMPARE(QAbstractItemView::NoState, obj1->state());
+ obj1->setState(QAbstractItemView::DraggingState);
+ QCOMPARE(QAbstractItemView::DraggingState, obj1->state());
+ obj1->setState(QAbstractItemView::DragSelectingState);
+ QCOMPARE(QAbstractItemView::DragSelectingState, obj1->state());
+ obj1->setState(QAbstractItemView::EditingState);
+ QCOMPARE(QAbstractItemView::EditingState, obj1->state());
+ obj1->setState(QAbstractItemView::ExpandingState);
+ QCOMPARE(QAbstractItemView::ExpandingState, obj1->state());
+ obj1->setState(QAbstractItemView::CollapsingState);
+ QCOMPARE(QAbstractItemView::CollapsingState, obj1->state());
// QWidget QAbstractScrollArea::viewport()
// void setViewport(QWidget*)
@@ -394,7 +292,7 @@ void tst_QAbstractItemView::emptyModels()
QVERIFY(!view->selectionModel());
//QVERIFY(view->itemDelegate() != 0);
- basic_tests(reinterpret_cast<TestView*>(view.data()));
+ basic_tests(view.data());
}
void tst_QAbstractItemView::setModel_data()
@@ -431,10 +329,10 @@ void tst_QAbstractItemView::setModel()
QStandardItemModel model(20,20);
view->setModel(0);
view->setModel(&model);
- basic_tests(reinterpret_cast<TestView*>(view.data()));
+ basic_tests(view.data());
}
-void tst_QAbstractItemView::basic_tests(TestView *view)
+void tst_QAbstractItemView::basic_tests(QAbstractItemView *view)
{
// setSelectionModel
// Will assert as it should
@@ -559,73 +457,73 @@ void tst_QAbstractItemView::basic_tests(TestView *view)
view->setCurrentIndex(QModelIndex());
// protected methods
- view->tst_dataChanged(QModelIndex(), QModelIndex());
- view->tst_rowsInserted(QModelIndex(), -1, -1);
- view->tst_rowsAboutToBeRemoved(QModelIndex(), -1, -1);
- view->tst_selectionChanged(QItemSelection(), QItemSelection());
+ view->dataChanged(QModelIndex(), QModelIndex());
+ view->rowsInserted(QModelIndex(), -1, -1);
+ view->rowsAboutToBeRemoved(QModelIndex(), -1, -1);
+ view->selectionChanged(QItemSelection(), QItemSelection());
if (view->model()){
- view->tst_currentChanged(QModelIndex(), QModelIndex());
- view->tst_currentChanged(QModelIndex(), view->model()->index(0,0));
+ view->currentChanged(QModelIndex(), QModelIndex());
+ view->currentChanged(QModelIndex(), view->model()->index(0,0));
}
- view->tst_updateEditorData();
- view->tst_updateEditorGeometries();
- view->tst_updateGeometries();
- view->tst_verticalScrollbarAction(QAbstractSlider::SliderSingleStepAdd);
- view->tst_horizontalScrollbarAction(QAbstractSlider::SliderSingleStepAdd);
- view->tst_verticalScrollbarValueChanged(10);
- view->tst_horizontalScrollbarValueChanged(10);
- view->tst_closeEditor(0, QAbstractItemDelegate::NoHint);
- view->tst_commitData(0);
- view->tst_editorDestroyed(0);
-
- view->tst_setHorizontalStepsPerItem(2);
- view->tst_horizontalStepsPerItem();
- view->tst_setVerticalStepsPerItem(2);
- view->tst_verticalStepsPerItem();
+ view->updateEditorData();
+ view->updateEditorGeometries();
+ view->updateGeometries();
+ view->verticalScrollbarAction(QAbstractSlider::SliderSingleStepAdd);
+ view->horizontalScrollbarAction(QAbstractSlider::SliderSingleStepAdd);
+ view->verticalScrollbarValueChanged(10);
+ view->horizontalScrollbarValueChanged(10);
+ view->closeEditor(0, QAbstractItemDelegate::NoHint);
+ view->commitData(0);
+ view->editorDestroyed(0);
+
+ view->setHorizontalStepsPerItem(2);
+ view->horizontalStepsPerItem();
+ view->setVerticalStepsPerItem(2);
+ view->verticalStepsPerItem();
// Will assert as it should
// view->setIndexWidget(QModelIndex(), 0);
- view->tst_moveCursor(TestView::MoveUp, Qt::NoModifier);
- view->tst_horizontalOffset();
- view->tst_verticalOffset();
+ view->moveCursor(QAbstractItemView::MoveUp, Qt::NoModifier);
+ view->horizontalOffset();
+ view->verticalOffset();
-// view->tst_isIndexHidden(QModelIndex()); // will (correctly) assert
+// view->isIndexHidden(QModelIndex()); // will (correctly) assert
if(view->model())
- view->tst_isIndexHidden(view->model()->index(0,0));
+ view->isIndexHidden(view->model()->index(0,0));
- view->tst_setSelection(QRect(0, 0, 10, 10), QItemSelectionModel::ClearAndSelect);
- view->tst_setSelection(QRect(-1, -1, -1, -1), QItemSelectionModel::ClearAndSelect);
- view->tst_visualRegionForSelection(QItemSelection());
- view->tst_selectedIndexes();
+ view->setSelection(QRect(0, 0, 10, 10), QItemSelectionModel::ClearAndSelect);
+ view->setSelection(QRect(-1, -1, -1, -1), QItemSelectionModel::ClearAndSelect);
+ view->visualRegionForSelection(QItemSelection());
+ view->selectedIndexes();
- view->tst_edit(QModelIndex(), QAbstractItemView::NoEditTriggers, 0);
+ view->edit(QModelIndex(), QAbstractItemView::NoEditTriggers, 0);
- view->tst_selectionCommand(QModelIndex(), 0);
+ view->selectionCommand(QModelIndex(), 0);
#ifndef QT_NO_DRAGANDDROP
if (!view->model())
- view->tst_startDrag(Qt::CopyAction);
-
- view->tst_viewOptions();
-
- view->tst_setState(TestView::NoState);
- QVERIFY(view->tst_state()==TestView::NoState);
- view->tst_setState(TestView::DraggingState);
- QVERIFY(view->tst_state()==TestView::DraggingState);
- view->tst_setState(TestView::DragSelectingState);
- QVERIFY(view->tst_state()==TestView::DragSelectingState);
- view->tst_setState(TestView::EditingState);
- QVERIFY(view->tst_state()==TestView::EditingState);
- view->tst_setState(TestView::ExpandingState);
- QVERIFY(view->tst_state()==TestView::ExpandingState);
- view->tst_setState(TestView::CollapsingState);
- QVERIFY(view->tst_state()==TestView::CollapsingState);
+ view->startDrag(Qt::CopyAction);
+
+ view->viewOptions();
+
+ view->setState(QAbstractItemView::NoState);
+ QVERIFY(view->state()==QAbstractItemView::NoState);
+ view->setState(QAbstractItemView::DraggingState);
+ QVERIFY(view->state()==QAbstractItemView::DraggingState);
+ view->setState(QAbstractItemView::DragSelectingState);
+ QVERIFY(view->state()==QAbstractItemView::DragSelectingState);
+ view->setState(QAbstractItemView::EditingState);
+ QVERIFY(view->state()==QAbstractItemView::EditingState);
+ view->setState(QAbstractItemView::ExpandingState);
+ QVERIFY(view->state()==QAbstractItemView::ExpandingState);
+ view->setState(QAbstractItemView::CollapsingState);
+ QVERIFY(view->state()==QAbstractItemView::CollapsingState);
#endif
- view->tst_startAutoScroll();
- view->tst_stopAutoScroll();
- view->tst_doAutoScroll();
+ view->startAutoScroll();
+ view->stopAutoScroll();
+ view->doAutoScroll();
// testing mouseFoo and key functions
// QTest::mousePress(view, Qt::LeftButton, Qt::NoModifier, QPoint(0,0));
@@ -760,11 +658,11 @@ void tst_QAbstractItemView::selectAll()
QTableView view;
view.setModel(&model);
- TestView *tst_view = (TestView*)&view;
+ QAbstractItemView *tst_view = &view;
- QCOMPARE(tst_view->tst_selectedIndexes().count(), 0);
+ QCOMPARE(tst_view->selectedIndexes().count(), 0);
view.selectAll();
- QCOMPARE(tst_view->tst_selectedIndexes().count(), 4*4);
+ QCOMPARE(tst_view->selectedIndexes().count(), 4*4);
}
void tst_QAbstractItemView::ctrlA()
@@ -773,11 +671,11 @@ void tst_QAbstractItemView::ctrlA()
QTableView view;
view.setModel(&model);
- TestView *tst_view = (TestView*)&view;
+ QAbstractItemView *tst_view = &view;
- QCOMPARE(tst_view->tst_selectedIndexes().count(), 0);
+ QCOMPARE(tst_view->selectedIndexes().count(), 0);
QTest::keyClick(&view, Qt::Key_A, Qt::ControlModifier);
- QCOMPARE(tst_view->tst_selectedIndexes().count(), 4*4);
+ QCOMPARE(tst_view->selectedIndexes().count(), 4*4);
}
void tst_QAbstractItemView::persistentEditorFocus()
@@ -1590,9 +1488,9 @@ void tst_QAbstractItemView::testDelegateDestroyEditor()
MyAbstractItemDelegate delegate;
table.setItemDelegate(&delegate);
table.edit(table.model()->index(1, 1));
- TestView *tv = reinterpret_cast<TestView*>(&table);
+ QAbstractItemView *tv = &table;
QVERIFY(!delegate.calledVirtualDtor);
- tv->tst_closeEditor(delegate.openedEditor, QAbstractItemDelegate::NoHint);
+ tv->closeEditor(delegate.openedEditor, QAbstractItemDelegate::NoHint);
QVERIFY(delegate.calledVirtualDtor);
}
@@ -2069,11 +1967,18 @@ void tst_QAbstractItemView::QTBUG50535_update_on_new_selection_model()
{
public:
ListView()
- : m_paintEventsCount(0)
+ : m_paintEventsCount(0), m_deselectedMustBeEmpty(false), m_selectionChangedOk(true)
{
}
+ void setSelectionModel(QItemSelectionModel *model) Q_DECL_OVERRIDE
+ {
+ m_deselectedMustBeEmpty = !selectionModel() || !model || selectionModel()->model() != model->model();
+ QListView::setSelectionModel(model);
+ m_deselectedMustBeEmpty = false;
+ }
int m_paintEventsCount;
+ bool selectionChangedOk() const { return m_selectionChangedOk; }
protected:
bool viewportEvent(QEvent *event) Q_DECL_OVERRIDE
@@ -2082,6 +1987,24 @@ void tst_QAbstractItemView::QTBUG50535_update_on_new_selection_model()
++m_paintEventsCount;
return QListView::viewportEvent(event);
}
+
+ void selectionChanged(const QItemSelection &selected,
+ const QItemSelection &deselected) Q_DECL_OVERRIDE
+ {
+ if (m_deselectedMustBeEmpty && !deselected.isEmpty())
+ m_selectionChangedOk = false;
+
+ // Make sure both selections belong to the same model
+ foreach (const QModelIndex &nmi, selected.indexes()) {
+ foreach (const QModelIndex &omi, deselected.indexes()) {
+ m_selectionChangedOk = m_selectionChangedOk && (nmi.model() == omi.model());
+ }
+ }
+ QListView::selectionChanged(selected, deselected);
+ }
+ private:
+ bool m_deselectedMustBeEmpty;
+ bool m_selectionChangedOk;
};
// keep the current/selected row in the "low range", i.e. be sure it's visible, otherwise we
@@ -2092,7 +2015,7 @@ void tst_QAbstractItemView::QTBUG50535_update_on_new_selection_model()
view.selectionModel()->setCurrentIndex(model.index(1, 0), QItemSelectionModel::SelectCurrent);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
-
+ QVERIFY(view.selectionChangedOk());
QItemSelectionModel selectionModel(&model);
selectionModel.setCurrentIndex(model.index(2, 0), QItemSelectionModel::Current);
@@ -2100,6 +2023,7 @@ void tst_QAbstractItemView::QTBUG50535_update_on_new_selection_model()
int oldPaintEventsCount = view.m_paintEventsCount;
view.setSelectionModel(&selectionModel);
QTRY_VERIFY(view.m_paintEventsCount > oldPaintEventsCount);
+ QVERIFY(view.selectionChangedOk());
QItemSelectionModel selectionModel2(&model);
@@ -2109,6 +2033,19 @@ void tst_QAbstractItemView::QTBUG50535_update_on_new_selection_model()
oldPaintEventsCount = view.m_paintEventsCount;
view.setSelectionModel(&selectionModel2);
QTRY_VERIFY(view.m_paintEventsCount > oldPaintEventsCount);
+ QVERIFY(view.selectionChangedOk());
+
+ // Tests QAbstractItemView::selectionChanged
+ QStandardItemModel model1;
+ for (int i = 0; i < 10; ++i)
+ model1.appendRow(new QStandardItem(QString::number(i)));
+ view.setModel(&model1);
+
+ QItemSelectionModel selectionModel1(&model1);
+ selectionModel1.select(model1.index(0, 0), QItemSelectionModel::ClearAndSelect);
+ selectionModel1.setCurrentIndex(model1.index(1, 0), QItemSelectionModel::Current);
+ view.setSelectionModel(&selectionModel1);
+ QVERIFY(view.selectionChangedOk());
}
void tst_QAbstractItemView::testSelectionModelInSyncWithView()
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index bc8b08997f..32a324b888 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -2991,6 +2991,11 @@ void tst_QHeaderView::stretchAndRestoreLastSection()
header.swapSections(1, 11);
QCOMPARE(header.sectionSize(1), someOtherSectionSize);
+ // Clear and re-add. This triggers a different code path than seColumnCount(0)
+ m.clear();
+ m.setColumnCount(3);
+ QVERIFY(header.sectionSize(2) >= biggerSizeThanAnySection);
+
// Test import/export of the original (not stretched) sectionSize.
m.setColumnCount(0);
m.setColumnCount(10);
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 81ce1deca4..c7b7ffaf95 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -31,7 +31,7 @@
#include <QtTest/QtTest>
#include <QtGui/QtGui>
#include <QtWidgets/QtWidgets>
-#include <private/qabstractitemview_p.h>
+#include <private/qtreeview_p.h>
#ifndef QT_NO_DRAGANDDROP
Q_DECLARE_METATYPE(QAbstractItemView::DragDropMode)
@@ -57,49 +57,6 @@ static void initStandardTreeModel(QStandardItemModel *model)
model->insertRow(2, item);
}
-class tst_QTreeView;
-struct PublicView : public QTreeView
-{
- friend class tst_QTreeView;
- inline void executeDelayedItemsLayout()
- { QTreeView::executeDelayedItemsLayout(); }
-
- enum PublicCursorAction {
- MoveUp = QAbstractItemView::MoveUp,
- MoveDown = QAbstractItemView::MoveDown,
- MoveLeft = QAbstractItemView::MoveLeft,
- MoveRight = QAbstractItemView::MoveRight,
- MoveHome = QAbstractItemView::MoveHome,
- MoveEnd = QAbstractItemView::MoveEnd,
- MovePageUp = QAbstractItemView::MovePageUp,
- MovePageDown = QAbstractItemView::MovePageDown,
- MoveNext = QAbstractItemView::MoveNext,
- MovePrevious = QAbstractItemView::MovePrevious
- };
-
- // enum PublicCursorAction and moveCursor() are protected in QTreeView.
- inline QModelIndex doMoveCursor(PublicCursorAction ca, Qt::KeyboardModifiers kbm)
- { return QTreeView::moveCursor((CursorAction)ca, kbm); }
-
- inline void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)
- {
- QTreeView::setSelection(rect, command);
- }
- inline int state()
- {
- return QTreeView::state();
- }
-
- inline int rowHeight(QModelIndex idx) { return QTreeView::rowHeight(idx); }
- inline int indexRowSizeHint(const QModelIndex &index) const { return QTreeView::indexRowSizeHint(index); }
-
- inline QModelIndexList selectedIndexes() const { return QTreeView::selectedIndexes(); }
-
- inline QStyleOptionViewItem viewOptions() const { return QTreeView::viewOptions(); }
- inline int sizeHintForColumn(int column) const { return QTreeView::sizeHintForColumn(column); }
- QAbstractItemViewPrivate* aiv_priv() { return static_cast<QAbstractItemViewPrivate*>(d_ptr.data()); }
-};
-
// Make a widget frameless to prevent size constraints of title bars
// from interfering (Windows).
static inline void setFrameless(QWidget *w)
@@ -631,33 +588,34 @@ void tst_QTreeView::dragDropModeFromDragEnabledAndAcceptDrops_data()
QTest::addColumn<bool>("dragEnabled");
QTest::addColumn<bool>("acceptDrops");
QTest::addColumn<QAbstractItemView::DragDropMode>("dragDropMode");
- QTest::addColumn<QAbstractItemView::DragDropMode>("setBehavior");
-
- QTest::newRow("NoDragDrop -1") << false << false << QAbstractItemView::NoDragDrop << QAbstractItemView::DragDropMode(-1);
- QTest::newRow("NoDragDrop 0") << false << false << QAbstractItemView::NoDragDrop << QAbstractItemView::NoDragDrop;
- QTest::newRow("NoDragDrop 1") << false << false << QAbstractItemView::NoDragDrop << QAbstractItemView::DragOnly;
- QTest::newRow("NoDragDrop 2") << false << false << QAbstractItemView::NoDragDrop << QAbstractItemView::DropOnly;
- QTest::newRow("NoDragDrop 3") << false << false << QAbstractItemView::NoDragDrop << QAbstractItemView::DragDrop;
- QTest::newRow("NoDragDrop 4") << false << false << QAbstractItemView::NoDragDrop << QAbstractItemView::InternalMove;
- QTest::newRow("DragOnly -1") << true << false << QAbstractItemView::DragOnly << QAbstractItemView::DragDropMode(-1);
- QTest::newRow("DragOnly 0") << true << false << QAbstractItemView::DragOnly << QAbstractItemView::NoDragDrop;
- QTest::newRow("DragOnly 1") << true << false << QAbstractItemView::DragOnly << QAbstractItemView::DragOnly;
- QTest::newRow("DragOnly 2") << true << false << QAbstractItemView::DragOnly << QAbstractItemView::DropOnly;
- QTest::newRow("DragOnly 3") << true << false << QAbstractItemView::DragOnly << QAbstractItemView::DragDrop;
- QTest::newRow("DragOnly 4") << true << false << QAbstractItemView::DragOnly << QAbstractItemView::InternalMove;
- QTest::newRow("DropOnly -1") << false << true << QAbstractItemView::DropOnly << QAbstractItemView::DragDropMode(-1);
- QTest::newRow("DropOnly 0") << false << true << QAbstractItemView::DropOnly << QAbstractItemView::NoDragDrop;
- QTest::newRow("DropOnly 1") << false << true << QAbstractItemView::DropOnly << QAbstractItemView::DragOnly;
- QTest::newRow("DropOnly 2") << false << true << QAbstractItemView::DropOnly << QAbstractItemView::DropOnly;
- QTest::newRow("DropOnly 3") << false << true << QAbstractItemView::DropOnly << QAbstractItemView::DragDrop;
- QTest::newRow("DropOnly 4") << false << true << QAbstractItemView::DropOnly << QAbstractItemView::InternalMove;
- QTest::newRow("DragDrop -1") << true << true << QAbstractItemView::DragDrop << QAbstractItemView::DragDropMode(-1);
- QTest::newRow("DragDrop 0") << true << true << QAbstractItemView::DragDrop << QAbstractItemView::DragDropMode(-1);
- QTest::newRow("DragDrop 1") << true << true << QAbstractItemView::DragDrop << QAbstractItemView::NoDragDrop;
- QTest::newRow("DragDrop 2") << true << true << QAbstractItemView::DragDrop << QAbstractItemView::DragOnly;
- QTest::newRow("DragDrop 3") << true << true << QAbstractItemView::DragDrop << QAbstractItemView::DropOnly;
- QTest::newRow("DragDrop 4") << true << true << QAbstractItemView::DragDrop << QAbstractItemView::DragDrop;
- QTest::newRow("DragDrop 5") << true << true << QAbstractItemView::InternalMove << QAbstractItemView::InternalMove;
+ QTest::addColumn<bool>("setBehavior");
+ QTest::addColumn<QAbstractItemView::DragDropMode>("behavior");
+
+ QTest::newRow("NoDragDrop -1") << false << false << QAbstractItemView::NoDragDrop << false << QAbstractItemView::DragDropMode();
+ QTest::newRow("NoDragDrop 0") << false << false << QAbstractItemView::NoDragDrop << true << QAbstractItemView::NoDragDrop;
+ QTest::newRow("NoDragDrop 1") << false << false << QAbstractItemView::NoDragDrop << true << QAbstractItemView::DragOnly;
+ QTest::newRow("NoDragDrop 2") << false << false << QAbstractItemView::NoDragDrop << true << QAbstractItemView::DropOnly;
+ QTest::newRow("NoDragDrop 3") << false << false << QAbstractItemView::NoDragDrop << true << QAbstractItemView::DragDrop;
+ QTest::newRow("NoDragDrop 4") << false << false << QAbstractItemView::NoDragDrop << true << QAbstractItemView::InternalMove;
+ QTest::newRow("DragOnly -1") << true << false << QAbstractItemView::DragOnly << false << QAbstractItemView::DragDropMode();
+ QTest::newRow("DragOnly 0") << true << false << QAbstractItemView::DragOnly << true << QAbstractItemView::NoDragDrop;
+ QTest::newRow("DragOnly 1") << true << false << QAbstractItemView::DragOnly << true << QAbstractItemView::DragOnly;
+ QTest::newRow("DragOnly 2") << true << false << QAbstractItemView::DragOnly << true << QAbstractItemView::DropOnly;
+ QTest::newRow("DragOnly 3") << true << false << QAbstractItemView::DragOnly << true << QAbstractItemView::DragDrop;
+ QTest::newRow("DragOnly 4") << true << false << QAbstractItemView::DragOnly << true << QAbstractItemView::InternalMove;
+ QTest::newRow("DropOnly -1") << false << true << QAbstractItemView::DropOnly << false << QAbstractItemView::DragDropMode();
+ QTest::newRow("DropOnly 0") << false << true << QAbstractItemView::DropOnly << true << QAbstractItemView::NoDragDrop;
+ QTest::newRow("DropOnly 1") << false << true << QAbstractItemView::DropOnly << true << QAbstractItemView::DragOnly;
+ QTest::newRow("DropOnly 2") << false << true << QAbstractItemView::DropOnly << true << QAbstractItemView::DropOnly;
+ QTest::newRow("DropOnly 3") << false << true << QAbstractItemView::DropOnly << true << QAbstractItemView::DragDrop;
+ QTest::newRow("DropOnly 4") << false << true << QAbstractItemView::DropOnly << true << QAbstractItemView::InternalMove;
+ QTest::newRow("DragDrop -1") << true << true << QAbstractItemView::DragDrop << false << QAbstractItemView::DragDropMode();
+ QTest::newRow("DragDrop 0") << true << true << QAbstractItemView::DragDrop << false << QAbstractItemView::DragDropMode();
+ QTest::newRow("DragDrop 1") << true << true << QAbstractItemView::DragDrop << true << QAbstractItemView::NoDragDrop;
+ QTest::newRow("DragDrop 2") << true << true << QAbstractItemView::DragDrop << true << QAbstractItemView::DragOnly;
+ QTest::newRow("DragDrop 3") << true << true << QAbstractItemView::DragDrop << true << QAbstractItemView::DropOnly;
+ QTest::newRow("DragDrop 4") << true << true << QAbstractItemView::DragDrop << true << QAbstractItemView::DragDrop;
+ QTest::newRow("DragDrop 5") << true << true << QAbstractItemView::InternalMove << true << QAbstractItemView::InternalMove;
}
void tst_QTreeView::dragDropModeFromDragEnabledAndAcceptDrops()
@@ -665,13 +623,14 @@ void tst_QTreeView::dragDropModeFromDragEnabledAndAcceptDrops()
QFETCH(bool, acceptDrops);
QFETCH(bool, dragEnabled);
QFETCH(QAbstractItemView::DragDropMode, dragDropMode);
- QFETCH(QAbstractItemView::DragDropMode, setBehavior);
+ QFETCH(bool, setBehavior);
+ QFETCH(QAbstractItemView::DragDropMode, behavior);
QTreeView view;
QCOMPARE(view.dragDropMode(), QAbstractItemView::NoDragDrop);
- if (setBehavior != QAbstractItemView::DragDropMode(-1))
- view.setDragDropMode(setBehavior);
+ if (setBehavior)
+ view.setDragDropMode(behavior);
view.setAcceptDrops(acceptDrops);
view.setDragEnabled(dragEnabled);
@@ -1743,7 +1702,7 @@ void tst_QTreeView::moveCursor()
QFETCH(bool, scrollPerPixel);
QtTestModel model(8, 6);
- PublicView view;
+ QTreeView view;
view.setUniformRowHeights(uniformRowHeights);
view.setModel(&model);
view.setRowHidden(0, QModelIndex(), true);
@@ -1762,7 +1721,7 @@ void tst_QTreeView::moveCursor()
QCOMPARE(view.currentIndex(), expected);
//then pressing down should go to the next line
- QModelIndex actual = view.doMoveCursor(PublicView::MoveDown, Qt::NoModifier);
+ QModelIndex actual = view.moveCursor(QTreeView::MoveDown, Qt::NoModifier);
expected = model.index(2, 1, QModelIndex());
QCOMPARE(actual, expected);
@@ -1771,7 +1730,7 @@ void tst_QTreeView::moveCursor()
// PageUp was broken with uniform row heights turned on
view.setCurrentIndex(model.index(1, 0));
- actual = view.doMoveCursor(PublicView::MovePageUp, Qt::NoModifier);
+ actual = view.moveCursor(QTreeView::MovePageUp, Qt::NoModifier);
expected = model.index(0, 0, QModelIndex());
QCOMPARE(actual, expected);
@@ -1870,7 +1829,7 @@ void tst_QTreeView::setSelection()
QtTestModel model(10, 5);
model.levels = 1;
model.setDecorationsEnabled(true);
- PublicView view;
+ QTreeView view;
view.resize(400, 300);
view.show();
view.setRootIsDecorated(false);
@@ -2058,7 +2017,7 @@ void tst_QTreeView::rowsAboutToBeRemoved()
}
}
- PublicView view;
+ QTreeView view;
view.setModel(&model);
view.show();
QModelIndex index = model.index(0,0, QModelIndex());
@@ -2072,7 +2031,7 @@ void tst_QTreeView::rowsAboutToBeRemoved()
QSignalSpy spy1(&model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)));
model.removeRows(1,1);
- QCOMPARE(view.state(), 0);
+ QCOMPARE(int(view.state()), 0);
// Should not be 5 (or any other number for that sake :)
QCOMPARE(spy1.count(), 1);
@@ -2175,7 +2134,7 @@ void tst_QTreeView::rowsAboutToBeRemoved_move()
view.resize(600,800);
view.show();
view.doItemsLayout();
- static_cast<PublicView *>(&view)->executeDelayedItemsLayout();
+ static_cast<QTreeView *>(&view)->executeDelayedItemsLayout();
parent = indexThatWantsToLiveButWillDieDieITellYou.parent();
QCOMPARE(view.isExpanded(indexThatWantsToLiveButWillDieDieITellYou), true);
QCOMPARE(parent.isValid(), true);
@@ -2283,7 +2242,7 @@ void tst_QTreeView::spanningItems()
{
QtTestModel model;
model.rows = model.cols = 10;
- PublicView view;
+ QTreeView view;
view.setModel(&model);
view.show();
@@ -2422,7 +2381,7 @@ void tst_QTreeView::selectionWithHiddenItems()
void tst_QTreeView::selectAll()
{
QStandardItemModel model(4,4);
- PublicView view2;
+ QTreeView view2;
view2.setModel(&model);
view2.setSelectionMode(QAbstractItemView::ExtendedSelection);
view2.selectAll(); // Should work with an empty model
@@ -2431,13 +2390,13 @@ void tst_QTreeView::selectAll()
for (int i = 0; i < model.rowCount(); ++i)
model.setData(model.index(i,0), QLatin1String("row ") + QString::number(i));
- PublicView view;
+ QTreeView view;
view.setModel(&model);
int selectedCount = view.selectedIndexes().count();
view.selectAll();
QCOMPARE(view.selectedIndexes().count(), selectedCount);
- PublicView view3;
+ QTreeView view3;
view3.setModel(&model);
view3.setSelectionMode(QAbstractItemView::NoSelection);
view3.selectAll();
@@ -2800,7 +2759,7 @@ void tst_QTreeView::evilModel()
{
QFETCH(bool, visible);
// init
- PublicView view;
+ QTreeView view;
EvilModel model;
view.setModel(&model);
view.setVisible(visible);
@@ -2858,7 +2817,7 @@ void tst_QTreeView::evilModel()
view.setSelection(rect, QItemSelectionModel::Select);
model.change();
- view.doMoveCursor(PublicView::MoveDown, Qt::NoModifier);
+ view.moveCursor(QTreeView::MoveDown, Qt::NoModifier);
model.change();
view.resizeColumnToContents(1);
@@ -2969,7 +2928,7 @@ void tst_QTreeView::evilModel()
void tst_QTreeView::indexRowSizeHint()
{
QStandardItemModel model(10, 1);
- PublicView view;
+ QTreeView view;
view.setModel(&model);
@@ -3015,7 +2974,7 @@ void tst_QTreeView::renderToPixmap_data()
void tst_QTreeView::renderToPixmap()
{
QFETCH(int, row);
- PublicView view;
+ QTreeView view;
QStandardItemModel model;
model.appendRow(new QStandardItem("Spanning"));
@@ -3031,7 +2990,7 @@ void tst_QTreeView::renderToPixmap()
// We select the index at row=1 for coverage.
QItemSelection sel(model.index(row,0), model.index(row,1));
QRect rect;
- view.aiv_priv()->renderToPixmap(sel.indexes(), &rect);
+ view.d_func()->renderToPixmap(sel.indexes(), &rect);
}
#endif
}
@@ -3093,7 +3052,7 @@ void tst_QTreeView::styleOptionViewItem()
bool allCollapsed;
};
- PublicView view;
+ QTreeView view;
QStandardItemModel model;
view.setModel(&model);
MyDelegate delegate;
@@ -3149,7 +3108,7 @@ void tst_QTreeView::styleOptionViewItem()
delegate.count = 0;
QItemSelection sel(model.index(0,0), model.index(0,modelColumns-1));
QRect rect;
- view.aiv_priv()->renderToPixmap(sel.indexes(), &rect);
+ view.d_func()->renderToPixmap(sel.indexes(), &rect);
if (delegate.count != visibleColumns) {
qDebug() << rect << view.rect() << view.isVisible();
}
@@ -3177,7 +3136,7 @@ void tst_QTreeView::styleOptionViewItem()
delegate.count = 0;
QItemSelection sel(model.index(0,0), model.index(0,modelColumns-1));
QRect rect;
- view.aiv_priv()->renderToPixmap(sel.indexes(), &rect);
+ view.d_func()->renderToPixmap(sel.indexes(), &rect);
if (delegate.count != visibleColumns) {
qDebug() << rect << view.rect() << view.isVisible();
}
@@ -4139,7 +4098,7 @@ void tst_QTreeView::taskQTBUG_13567_removeLastItemRegression()
// Note: define QT_BUILD_INTERNAL to run this test
void tst_QTreeView::taskQTBUG_25333_adjustViewOptionsForIndex()
{
- PublicView view;
+ QTreeView view;
QStandardItemModel model;
QStandardItem *item1 = new QStandardItem("Item1");
QStandardItem *item2 = new QStandardItem("Item2");
@@ -4165,9 +4124,9 @@ void tst_QTreeView::taskQTBUG_25333_adjustViewOptionsForIndex()
{
QStyleOptionViewItem option;
- view.aiv_priv()->adjustViewOptionsForIndex(&option, model.indexFromItem(item1));
+ view.d_func()->adjustViewOptionsForIndex(&option, model.indexFromItem(item1));
- view.aiv_priv()->adjustViewOptionsForIndex(&option, model.indexFromItem(item3));
+ view.d_func()->adjustViewOptionsForIndex(&option, model.indexFromItem(item3));
}
#endif
@@ -4273,7 +4232,7 @@ void tst_QTreeView::quickExpandCollapse()
//this unit tests makes sure the state after the animation is restored correctly
//after starting a 2nd animation while the first one was still on-going
//this tests that the stateBeforeAnimation is not set to AnimatingState
- PublicView tree;
+ QTreeView tree;
tree.setAnimated(true);
QStandardItemModel model;
QStandardItem *root = new QStandardItem("root");
@@ -4287,13 +4246,13 @@ void tst_QTreeView::quickExpandCollapse()
tree.show();
QTest::qWaitForWindowExposed(&tree);
- int initialState = tree.state();
+ const QAbstractItemView::State initialState = tree.state();
tree.expand(rootIndex);
- QCOMPARE(tree.state(), (int)PublicView::AnimatingState);
+ QCOMPARE(tree.state(), QTreeView::AnimatingState);
tree.collapse(rootIndex);
- QCOMPARE(tree.state(), (int)PublicView::AnimatingState);
+ QCOMPARE(tree.state(), QTreeView::AnimatingState);
QTest::qWait(500); //the animation lasts for 250ms max so 500 should be enough