Mac Accessibility: unify child functions
Both ways of getting the children are the same for nsview and qcocoaaccessibleelement. Factor out a function. Change-Id: I4be091c6acde0de519a358f879c24eae04ec4c8d Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>bb10
parent
47ab2edd01
commit
5e4627fb85
|
|
@ -79,6 +79,7 @@ namespace QCocoaAccessible {
|
|||
|
||||
NSString *macRole(QAccessibleInterface *interface);
|
||||
bool shouldBeIgnored(QAccessibleInterface *interface);
|
||||
NSArray *unignoredChildren(id parentObject, QAccessibleInterface *interface);
|
||||
NSString *getTranslatedAction(const QString &qtAction);
|
||||
NSMutableArray *createTranslatedActionsList(const QStringList &qtActions);
|
||||
QString translateAction(NSString *nsAction);
|
||||
|
|
|
|||
|
|
@ -223,6 +223,26 @@ bool shouldBeIgnored(QAccessibleInterface *interface)
|
|||
return false;
|
||||
}
|
||||
|
||||
NSArray *unignoredChildren(id parentObject, QAccessibleInterface *interface)
|
||||
{
|
||||
int numKids = interface->childCount();
|
||||
// qDebug() << "Children for: " << axid << iface << " are: " << numKids;
|
||||
|
||||
NSMutableArray *kids = [NSMutableArray arrayWithCapacity:numKids];
|
||||
for (int i = 0; i < numKids; ++i) {
|
||||
QAccessibleInterface *child = interface->child(i);
|
||||
Q_ASSERT(child);
|
||||
if (child->state().invalid || child->state().invisible)
|
||||
continue;
|
||||
|
||||
QAccessible::Id childId = QAccessible::uniqueId(child);
|
||||
//qDebug() << " kid: " << childId << child;
|
||||
QCocoaAccessibleElement *element = [QCocoaAccessibleElement createElementWithId:childId parent:parentObject];
|
||||
[kids addObject: element];
|
||||
[element release];
|
||||
}
|
||||
return NSAccessibilityUnignoredChildren(kids);
|
||||
}
|
||||
/*
|
||||
Translates a predefined QAccessibleActionInterface action to a Mac action constant.
|
||||
Returns 0 if the Qt Action has no mac equivalent. Ownership of the NSString is
|
||||
|
|
|
|||
|
|
@ -137,25 +137,7 @@
|
|||
} else if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) {
|
||||
return NSAccessibilityRoleDescription(role, nil);
|
||||
} else if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
|
||||
|
||||
int numKids = iface->childCount();
|
||||
// qDebug() << "Children for: " << axid << iface << " are: " << numKids;
|
||||
|
||||
NSMutableArray *kids = [NSMutableArray arrayWithCapacity:numKids];
|
||||
for (int i = 0; i < numKids; ++i) {
|
||||
QAccessibleInterface *child = iface->child(i);
|
||||
Q_ASSERT(child);
|
||||
if (child->state().invalid || child->state().invisible)
|
||||
continue;
|
||||
|
||||
QAccessible::Id childId = QAccessible::uniqueId(child);
|
||||
//qDebug() << " kid: " << childId << child;
|
||||
QCocoaAccessibleElement *element = [QCocoaAccessibleElement createElementWithId:childId parent:self];
|
||||
[kids addObject: element];
|
||||
[element release];
|
||||
}
|
||||
return NSAccessibilityUnignoredChildren(kids);
|
||||
|
||||
return QCocoaAccessible::unignoredChildren(self, iface);
|
||||
} else if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) {
|
||||
// Just check if the app thinks we're focused.
|
||||
id focusedElement = [NSApp accessibilityAttributeValue:NSAccessibilityFocusedUIElementAttribute];
|
||||
|
|
|
|||
|
|
@ -74,24 +74,7 @@
|
|||
} else if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
|
||||
if (!m_window->accessibleRoot())
|
||||
return [super accessibilityAttributeValue:attribute];
|
||||
|
||||
// Create QCocoaAccessibleElements for each child if the
|
||||
// root accessible interface.
|
||||
int numKids = m_window->accessibleRoot()->childCount();
|
||||
NSMutableArray *kids = [NSMutableArray arrayWithCapacity:numKids];
|
||||
for (int i = 0; i < numKids; ++i) {
|
||||
QAccessibleInterface *child = m_window->accessibleRoot()->child(i);
|
||||
Q_ASSERT(child);
|
||||
if (child->state().invalid || child->state().invisible)
|
||||
continue;
|
||||
|
||||
QAccessible::Id childAxid = QAccessible::uniqueId(child);
|
||||
QCocoaAccessibleElement *element = [QCocoaAccessibleElement createElementWithId:childAxid parent:self];
|
||||
[kids addObject: element];
|
||||
[element release];
|
||||
}
|
||||
|
||||
return NSAccessibilityUnignoredChildren(kids);
|
||||
return QCocoaAccessible::unignoredChildren(self, m_window->accessibleRoot());
|
||||
} else {
|
||||
return [super accessibilityAttributeValue:attribute];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue