QListView: fix skipping indexes in selectedIndexes().
Remove spurious increment of i. Task-number: QTBUG-51086 Change-Id: I4307a6728de1e7f25c8afa31fe2066f92373f3fc Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
parent
5b727576b1
commit
a3b8e355fc
@ -1437,7 +1437,7 @@ QModelIndexList QListView::selectedIndexes() const
|
||||
return QModelIndexList();
|
||||
|
||||
QModelIndexList viewSelected = d->selectionModel->selectedIndexes();
|
||||
for (int i = 0; i < viewSelected.count(); ++i) {
|
||||
for (int i = 0; i < viewSelected.count();) {
|
||||
const QModelIndex &index = viewSelected.at(i);
|
||||
if (!isIndexHidden(index) && index.parent() == d->root && index.column() == d->column)
|
||||
++i;
|
||||
|
@ -152,6 +152,7 @@ private slots:
|
||||
void taskQTBUG_39902_mutualScrollBars_data();
|
||||
void taskQTBUG_39902_mutualScrollBars();
|
||||
void horizontalScrollingByVerticalWheelEvents();
|
||||
void taskQTBUG_51086_skippingIndexesInSelectedIndexes();
|
||||
};
|
||||
|
||||
// Testing get/set functions
|
||||
@ -2493,5 +2494,32 @@ void tst_QListView::horizontalScrollingByVerticalWheelEvents()
|
||||
QVERIFY(lv.verticalScrollBar()->value() > vValue);
|
||||
}
|
||||
|
||||
void tst_QListView::taskQTBUG_51086_skippingIndexesInSelectedIndexes()
|
||||
{
|
||||
// simple way to get access to selectedIndexes()
|
||||
class QListViewWithPublicSelectedIndexes : public QListView
|
||||
{
|
||||
public:
|
||||
using QListView::selectedIndexes;
|
||||
};
|
||||
|
||||
QStandardItemModel data(10, 1);
|
||||
QItemSelectionModel selections(&data);
|
||||
QListViewWithPublicSelectedIndexes list;
|
||||
list.setModel(&data);
|
||||
list.setSelectionModel(&selections);
|
||||
|
||||
list.setRowHidden(7, true);
|
||||
list.setRowHidden(8, true);
|
||||
|
||||
for (int i = 0, count = data.rowCount(); i < count; ++i)
|
||||
selections.select(data.index(i, 0), QItemSelectionModel::Select);
|
||||
|
||||
const QModelIndexList indexes = list.selectedIndexes();
|
||||
|
||||
QVERIFY(!indexes.contains(data.index(7, 0)));
|
||||
QVERIFY(!indexes.contains(data.index(8, 0)));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QListView)
|
||||
#include "tst_qlistview.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user