diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-08-29 11:47:05 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-09-01 18:03:29 +0200 |
commit | c59b34b8cf1c2a087e361d4235990803d89d34ec (patch) | |
tree | 9bd0e09474bc0d0179a7ad0b3363c6997eea1608 /src/widgets/itemviews/qlistview.cpp | |
parent | b770b0f8b98a280034b70bfd7e51e29f94ca93b6 (diff) |
QAccessible: consistently respect rootIndex of item views
Accessibility implementations rely on correct information about the
model dimensions when operating on item views. An item view that has a
root index set needs to report it's size based on the root index, rather
than for the view's model directly.
Pass the rootIndex to all calls to QAbstractItemModel::column/rowCount.
Refactor the code to avoid excessive dereferencing of a QPointer, apply
const and fix/improve coding style in touched lines.
Emit a ModelReset notification when the root index changes, or (in the
case of QListView) when the model column changes.
Split long Q_ASSERTs into multiple lines to be able to better trace the
exact reason for an assertion, and replace the assert with an early
return of nil when it's plausible that a cached cell is no longer part
of the view (i.e. because the root index changed).
Add a test case that verifies that changing the root index changes the
dimension of the view as reported through the accessibility interface.
Pick-to: 6.6 6.5
Fixes: QTBUG-114423
Change-Id: I7897b79b2e1d10c789cc866b7f5c5dabdabe6770
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/widgets/itemviews/qlistview.cpp')
-rw-r--r-- | src/widgets/itemviews/qlistview.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 89fccfc2ba..a4cb4c76fb 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -1622,6 +1622,12 @@ void QListView::setModelColumn(int column) return; d->column = column; d->doDelayedItemsLayout(); +#if QT_CONFIG(accessibility) + if (QAccessible::isActive()) { + QAccessibleTableModelChangeEvent event(this, QAccessibleTableModelChangeEvent::ModelReset); + QAccessible::updateAccessibility(&event); + } +#endif } int QListView::modelColumn() const |