blob: 2e588adc5825afbef1c7a59f12150807e0b54b82 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtest.h>
#include <QListView>
#include <QStandardItemModel>
class tst_QListView : public QObject
{
Q_OBJECT
public:
tst_QListView() = default;
virtual ~tst_QListView() = default;
private slots:
void benchSetCurrentIndex();
};
void tst_QListView::benchSetCurrentIndex()
{
QStandardItemModel sm(50000, 1);
QListView lv;
lv.setModel(&sm);
const int rc = lv.model()->rowCount();
for (int i = 0; i < rc; i+= 100)
lv.setRowHidden(i, true);
lv.setCurrentIndex(lv.model()->index(0, 0, QModelIndex()));
lv.show();
QVERIFY(QTest::qWaitForWindowExposed(&lv));
QBENCHMARK_ONCE {
while (lv.currentIndex().row() < rc - 20)
lv.setCurrentIndex(lv.model()->index(lv.currentIndex().row() + 17,
lv.currentIndex().column(),
QModelIndex()));
}
}
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"
|