summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp')
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp64
1 files changed, 62 insertions, 2 deletions
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 4c6dd341b3..0eec2e7c75 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -165,6 +165,7 @@ private slots:
void statusTip_data();
void statusTip();
+ void fetchMoreOnScroll();
// task-specific tests:
void task174627_moveLeftToRoot();
@@ -311,6 +312,12 @@ public:
return QVariant();
}
+ void simulateMoveRows()
+ {
+ beginMoveRows(QModelIndex(), 0, 0, QModelIndex(), 2);
+ endMoveRows();
+ }
+
void removeLastRow()
{
beginRemoveRows(QModelIndex(), rows - 1, rows - 1);
@@ -1338,6 +1345,17 @@ void tst_QTreeView::columnHidden()
QCOMPARE(view.isColumnHidden(c), true);
view.update();
+ // QTBUG 54610
+ // QAbstractItemViewPrivate::_q_layoutChanged() is called on
+ // rows/columnMoved and because this function is virtual,
+ // QHeaderViewPrivate::_q_layoutChanged() was called and unhided
+ // all sections because QHeaderViewPrivate::_q_layoutAboutToBeChanged()
+ // could not fill persistentHiddenSections (and is not needed)
+ view.hideColumn(model.cols - 1);
+ QCOMPARE(view.isColumnHidden(model.cols - 1), true);
+ model.simulateMoveRows();
+ QCOMPARE(view.isColumnHidden(model.cols - 1), true);
+
// QTBUG_41124:
// QHeaderViewPrivate::_q_layoutChanged was not called because it was
// disconnected in QTreeView::setModel(). _q_layoutChanged restores
@@ -1349,7 +1367,6 @@ void tst_QTreeView::columnHidden()
// 1 is a new column and therefore must not be hidden when
// _q_layoutChanged() is called and is doing the right stuff
QCOMPARE(view.isColumnHidden(model.cols - 1), false);
-
}
void tst_QTreeView::rowHidden()
@@ -2631,7 +2648,7 @@ class TestTreeViewStyle : public QProxyStyle
{
public:
TestTreeViewStyle() : indentation(20) {}
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const override
{
if (metric == QStyle::PM_TreeViewIndentation)
return indentation;
@@ -4589,6 +4606,49 @@ void tst_QTreeView::statusTip()
QTRY_COMPARE(mw.statusBar()->currentMessage(), QLatin1String("Header 0 -- Status"));
}
+class FetchMoreModel : public QStandardItemModel
+{
+public:
+ FetchMoreModel() : QStandardItemModel(), canFetchReady(false)
+ {
+ for (int i = 0; i < 20; ++i) {
+ QStandardItem *item = new QStandardItem("Row");
+ item->appendRow(new QStandardItem("Child"));
+ appendRow(item);
+ }
+ }
+ bool canFetchMore(const QModelIndex &parent) const override
+ {
+ if (!canFetchReady || !parent.isValid())
+ return false;
+ if (!parent.parent().isValid())
+ return rowCount(parent) < 20;
+ return false;
+ }
+ void fetchMore(const QModelIndex &parent) override
+ {
+ QStandardItem *item = itemFromIndex(parent);
+ for (int i = 0; i < 19; ++i)
+ item->appendRow(new QStandardItem(QString("New Child %1").arg(i)));
+ }
+ bool canFetchReady;
+};
+
+void tst_QTreeView::fetchMoreOnScroll()
+{
+ QTreeView tw;
+ FetchMoreModel im;
+ tw.setModel(&im);
+ tw.show();
+ tw.expandAll();
+ QVERIFY(QTest::qWaitForWindowActive(&tw));
+ // Now we can allow the fetch to happen
+ im.canFetchReady = true;
+ tw.verticalScrollBar()->setValue(tw.verticalScrollBar()->maximum());
+ // The item should have now fetched the other children, thus bringing the count to 20
+ QCOMPARE(im.item(19)->rowCount(), 20);
+}
+
static void fillModeltaskQTBUG_8376(QAbstractItemModel &model)
{
model.insertRow(0);