summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/itemviews/qlistview.cpp8
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp12
2 files changed, 16 insertions, 4 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index 35b44b4..1212194 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -549,16 +549,16 @@ void QListView::setRowHidden(int row, bool hide)
const bool hidden = d->isHidden(row);
if (d->viewMode == ListMode) {
if (hide && !hidden)
- d->hiddenRows.append(d->model->index(row, 0));
+ d->hiddenRows.append(d->model->index(row, 0, rootIndex()));
else if (!hide && hidden)
- d->hiddenRows.remove(d->hiddenRows.indexOf(d->model->index(row, 0)));
+ d->hiddenRows.remove(d->hiddenRows.indexOf(d->model->index(row, 0, rootIndex())));
d->doDelayedItemsLayout();
} else {
if (hide && !hidden) {
d->dynamicListView->removeItem(row);
- d->hiddenRows.append(d->model->index(row, 0));
+ d->hiddenRows.append(d->model->index(row, 0, rootIndex()));
} else if (!hide && hidden) {
- d->hiddenRows.remove(d->hiddenRows.indexOf(d->model->index(row, 0)));
+ d->hiddenRows.remove(d->hiddenRows.indexOf(d->model->index(row, 0, rootIndex())));
d->dynamicListView->insertItem(row);
}
if (d->resizeMode == Adjust)
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index b52bef0..27c6a05 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -417,6 +417,18 @@ void tst_QListView::hideRows()
view.setRowHidden(0, false);
QVERIFY(!view.isRowHidden(0));
+ QStandardItemModel sim(0);
+ QStandardItem *root = new QStandardItem("Root row");
+ for (int i=0;i<5;i++)
+ root->appendRow(new QStandardItem(QString("Row %1").arg(i)));
+ sim.appendRow(root);
+ view.setModel(&sim);
+ view.setRootIndex(root->index());
+ QVERIFY(!view.isRowHidden(0));
+ view.setRowHidden(0, true);
+ QVERIFY(view.isRowHidden(0));
+ view.setRowHidden(0, false);
+ QVERIFY(!view.isRowHidden(0));
}