Skip to content

Commit

Permalink
Compile with changes to the accessibility API.
Browse files Browse the repository at this point in the history
Change-Id: I72e7636a02ad2fba984f4a96cbb33d441a7f8be7
Reviewed-by: Jan Arve Sæther <[email protected]>
  • Loading branch information
Morten Johan Sørvig authored and The Qt Project committed Apr 18, 2013
1 parent a7fd869 commit b945073
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 32 deletions.
6 changes: 3 additions & 3 deletions util/accessibilityinspector/accessibilityinspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ void MouseInterceptingGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEv
AccessibilitySceneManager *sceneManager = 0;
QAccessible::UpdateHandler previousUpdateHandler = 0;
bool updateHandlerRecursion = false;
void accessibilityUpdateHandler(QObject *object, int who, QAccessible::Event reason)
void accessibilityUpdateHandler(QAccessibleEvent *event)
{
if (updateHandlerRecursion)
return;

updateHandlerRecursion = true;

if (sceneManager) {
sceneManager->handleUpdate(object, reason);
sceneManager->handleUpdate(event);

//qDebug() << "update";
}

if (previousUpdateHandler) // call prev just to be sure.
previousUpdateHandler(object, who, reason);
previousUpdateHandler(event);

updateHandlerRecursion = false;
}
Expand Down
38 changes: 12 additions & 26 deletions util/accessibilityinspector/accessibilityscenemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ void AccessibilitySceneManager::updateAccessibilitySceneItemFlags()
if (!interface)
continue;
updateItemFlags(m_graphicsItems.value(object), interface);
delete interface;
}
}

Expand All @@ -89,15 +88,18 @@ void AccessibilitySceneManager::populateAccessibilityTreeScene()
populateAccessibilityTreeScene(rootInterface);
}

void AccessibilitySceneManager::handleUpdate(QObject *object, QAccessible::Event reason)
void AccessibilitySceneManager::handleUpdate(QAccessibleEvent *event)
{
QObject *object = event->object();
QAccessible::Event type = event->type();

QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(object);
if (!interface)
return;

QString name = interface->text(QAccessible::Name);

if (reason == QAccessible::ObjectCreated) {
if (type == QAccessible::ObjectCreated) {
// qDebug() << "ObjectCreated" << object << name;
populateAccessibilityScene(interface, m_scene);
}
Expand All @@ -109,7 +111,7 @@ void AccessibilitySceneManager::handleUpdate(QObject *object, QAccessible::Event
return;
}

if (reason == QAccessible::LocationChanged) {
if (type == QAccessible::LocationChanged) {

//if (name.startsWith("List"))
qDebug() << "locationChange" << object << name << interface->rect();
Expand All @@ -119,41 +121,36 @@ void AccessibilitySceneManager::handleUpdate(QObject *object, QAccessible::Event
QAccessibleInterface *child = interface->child(i);
if (child) {
updateItem(m_graphicsItems.value(child->object()), child);
delete child;
}
}

delete interface;
} else if (reason == QAccessible::ObjectDestroyed) {
} else if (type == QAccessible::ObjectDestroyed) {
// qDebug() << "ObjectDestroyed" << object << name;
delete m_graphicsItems.value(object);
m_graphicsItems.remove(object);
m_animatedObjects.remove(object);
if (object == m_selectedObject) {
m_selectedObject = 0;
}
} else if (reason == QAccessible::ObjectHide) {
} else if (type == QAccessible::ObjectHide) {
// qDebug() << "ObjectCreated Hide" << object;
updateItemFlags(item, interface);
} else if (reason == QAccessible::ObjectShow) {
} else if (type == QAccessible::ObjectShow) {
// qDebug() << "ObjectCreated Show" << object;
updateItemFlags(item, interface);
} else if (reason == QAccessible::ScrollingStart) {
} else if (type == QAccessible::ScrollingStart) {
qDebug() << "ObjectCreated ScrollingStart" << object;
QAccessibleInterface *child = 0;
for (int i = 0; i < interface->childCount(); ++i) {
QAccessibleInterface *child = interface->child(i);
if (child) {
m_animatedObjects.insert(child->object());
delete child;
}
}
} else if (reason == QAccessible::ScrollingEnd) {
} else if (type == QAccessible::ScrollingEnd) {
// qDebug() << "ObjectCreated ScrollingEnd" << object;
foreach (QObject *object, m_animatedObjects) {
updateItem(m_graphicsItems.value(object), interface);
}
delete interface;
m_animatedObjects.clear();

} else {
Expand Down Expand Up @@ -197,10 +194,7 @@ void AccessibilitySceneManager::updateItems(QObject *root)
for (int i = 0; i < interface->childCount(); ++i) {
QAccessibleInterface *child = interface->child(i);
updateItems(child->object());
delete child;
}

delete interface;
}

void AccessibilitySceneManager::updateItem(QObject *object)
Expand All @@ -213,8 +207,6 @@ void AccessibilitySceneManager::updateItem(QObject *object)
return;

updateItem(m_graphicsItems.value(object), interface);

delete interface;
}

void AccessibilitySceneManager::updateItem(QGraphicsRectItem *item, QAccessibleInterface *interface)
Expand Down Expand Up @@ -332,7 +324,6 @@ void AccessibilitySceneManager::populateAccessibilityScene(QAccessibleInterface
QAccessibleInterface *child = interface->child(i);
updateItems(child->object());
populateAccessibilityScene(child, scene);
delete child;
}
}

Expand All @@ -351,7 +342,6 @@ AccessibilitySceneManager::TreeItem AccessibilitySceneManager::computeLevels(QAc
TreeItem childLevel = computeLevels(child, level + 1);
currentLevel.children.append(childLevel);
currentLevel.width += childLevel.width + m_treeItemHorizontalPadding;
delete child;
}
}

Expand Down Expand Up @@ -485,11 +475,7 @@ bool AccessibilitySceneManager::isHidden(QAccessibleInterface *interface)
return true;
}

QAccessibleInterface *parent = current->parent();

if (current != interface)
delete current;
current = parent;
current = current->parent();
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion util/accessibilityinspector/accessibilityscenemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public slots:
void populateAccessibilityScene();
void updateAccessibilitySceneItemFlags();
void populateAccessibilityTreeScene();
void handleUpdate(QObject *object, QAccessible::Event reason);
void handleUpdate(QAccessibleEvent *event);
void setSelected(QObject *object);

void changeScale(int scale);
Expand Down
3 changes: 1 addition & 2 deletions util/accessibilityinspector/screenreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "screenreader.h"
#include "optionswidget.h"
#include "accessibilityscenemanager.h"
#include <private/qaccessible2_p.h>
#include <QtGui>

ScreenReader::ScreenReader(QObject *parent) :
Expand All @@ -54,8 +55,6 @@ ScreenReader::ScreenReader(QObject *parent) :

ScreenReader::~ScreenReader()
{
delete m_selectedInterface;
delete m_rootInterface;
}

void ScreenReader::setRootObject(QObject *rootObject)
Expand Down

0 comments on commit b945073

Please sign in to comment.