From c59b34b8cf1c2a087e361d4235990803d89d34ec Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 29 Aug 2023 11:47:05 +0200 Subject: QAccessible: consistently respect rootIndex of item views MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/widgets/itemviews/qlistview.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/widgets/itemviews/qlistview.cpp') 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 -- cgit v1.2.3