a11y: Remember QTreeView's a11y child interfaces
In the same way that QAccessibleTable::child already
does, also make use of the childToId hash in
QAccessibleTree::child to remember and reuse previously
created child interfaces instead of creating new ones
for the same index every time the method gets called.
When items in the tree view change,
QTreeViewPrivate::updateAccessibility already sends a
QAccessibleTableModelChangeEvent event of type
QAccessibleTableModelChangeEvent::ModelReset,
which ensures that the then outdated cache is cleared
in the base class's QAccessibleTable::modelChange
method.
This addresses an old FIXME comment added in 2013
commit b2ec0da956 and
fixes the issue reported in QTBUG-128558.
Fixes: QTBUG-128558
Pick-to: 6.7
Change-Id: Ia2a518ac26f3c9b9ba8ab1870bb656c8e9014a77
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 3cfabf92b09290f71b7fafa79723dc374b807206)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
bb10
parent
e9f1dd072d
commit
77b8cd0a45
|
|
@ -860,6 +860,10 @@ QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const
|
|||
if (logicalIndex < 0 || !theModel || !theModel->columnCount(rootIndex))
|
||||
return nullptr;
|
||||
|
||||
auto id = childToId.constFind(logicalIndex);
|
||||
if (id != childToId.constEnd())
|
||||
return QAccessible::accessibleInterface(id.value());
|
||||
|
||||
QAccessibleInterface *iface = nullptr;
|
||||
int index = logicalIndex;
|
||||
|
||||
|
|
@ -879,7 +883,7 @@ QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const
|
|||
iface = new QAccessibleTableCell(view(), modelIndex, cellRole());
|
||||
}
|
||||
QAccessible::registerAccessibleInterface(iface);
|
||||
// ### FIXME: get interfaces from the cache instead of re-creating them
|
||||
childToId.insert(logicalIndex, QAccessible::uniqueId(iface));
|
||||
return iface;
|
||||
}
|
||||
|
||||
|
|
@ -931,7 +935,7 @@ QAccessibleInterface *QAccessibleTree::cellAt(int row, int column) const
|
|||
Q_ASSERT(treeView);
|
||||
int logicalIndex = treeView->d_func()->accessibleTable2Index(index);
|
||||
|
||||
return child(logicalIndex); // FIXME ### new QAccessibleTableCell(view(), index, cellRole());
|
||||
return child(logicalIndex);
|
||||
}
|
||||
|
||||
QString QAccessibleTree::rowDescription(int) const
|
||||
|
|
|
|||
Loading…
Reference in New Issue