summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <qt-info@nokia.com>2009-09-04 09:06:08 (GMT)
committerAndy Shaw <qt-info@nokia.com>2009-09-04 09:06:08 (GMT)
commit991b6bc973238a6fd73c4c71e7c642b8cc455df3 (patch)
treea0d04d3c9513bf1d6be10df60068cbc1987bca76
parentd22b55d3159c001dc6b37422cefbec6775996494 (diff)
downloadQt-991b6bc973238a6fd73c4c71e7c642b8cc455df3.zip
Qt-991b6bc973238a6fd73c4c71e7c642b8cc455df3.tar.gz
Qt-991b6bc973238a6fd73c4c71e7c642b8cc455df3.tar.bz2
Fix a regression with QListView::setRowHidden() when a root index is set
When setRowHidden() was called after a root index was set then it would not actually hide the row, if a root index is not set then it worked fine. Task-number: 260879 Reviewed-by: Jan-Arve
-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));
}