summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/accessible.pri2
-rw-r--r--src/gui/accessible/qaccessible.cpp28
-rw-r--r--src/gui/accessible/qaccessiblecache.cpp13
-rw-r--r--src/gui/accessible/qaccessiblecache_mac.mm67
-rw-r--r--src/gui/accessible/qaccessiblecache_p.h29
5 files changed, 120 insertions, 19 deletions
diff --git a/src/gui/accessible/accessible.pri b/src/gui/accessible/accessible.pri
index 615323dbec..86ed4c3a71 100644
--- a/src/gui/accessible/accessible.pri
+++ b/src/gui/accessible/accessible.pri
@@ -16,4 +16,6 @@ contains(QT_CONFIG, accessibility) {
HEADERS += accessible/qaccessiblebridge.h
SOURCES += accessible/qaccessiblebridge.cpp
+
+ OBJECTIVE_SOURCES += accessible/qaccessiblecache_mac.mm
}
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index dffdfa889a..776320a517 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -591,8 +591,6 @@ QAccessible::RootObjectHandler QAccessible::installRootObjectHandler(RootObjectH
return old;
}
-Q_GLOBAL_STATIC(QAccessibleCache, qAccessibleCache)
-
/*!
If a QAccessibleInterface implementation exists for the given \a object,
this function returns a pointer to the implementation; otherwise it
@@ -616,8 +614,8 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
if (!object)
return 0;
- if (Id id = qAccessibleCache->objectToId.value(object))
- return qAccessibleCache->interfaceForId(id);
+ if (Id id = QAccessibleCache::instance()->objectToId.value(object))
+ return QAccessibleCache::instance()->interfaceForId(id);
// Create a QAccessibleInterface for the object class. Start by the most
// derived class and walk up the class hierarchy.
@@ -629,8 +627,8 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
for (int i = qAccessibleFactories()->count(); i > 0; --i) {
InterfaceFactory factory = qAccessibleFactories()->at(i - 1);
if (QAccessibleInterface *iface = factory(cn, object)) {
- qAccessibleCache->insert(object, iface);
- Q_ASSERT(qAccessibleCache->objectToId.contains(object));
+ QAccessibleCache::instance()->insert(object, iface);
+ Q_ASSERT(QAccessibleCache::instance()->objectToId.contains(object));
return iface;
}
}
@@ -652,8 +650,8 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
if (factory) {
QAccessibleInterface *result = factory->create(cn, object);
if (result) { // Need this condition because of QDesktopScreenWidget
- qAccessibleCache->insert(object, result);
- Q_ASSERT(qAccessibleCache->objectToId.contains(object));
+ QAccessibleCache::instance()->insert(object, result);
+ Q_ASSERT(QAccessibleCache::instance()->objectToId.contains(object));
}
return result;
}
@@ -665,8 +663,8 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
#ifndef QT_NO_ACCESSIBILITY
if (object == qApp) {
QAccessibleInterface *appInterface = new QAccessibleApplication;
- qAccessibleCache->insert(object, appInterface);
- Q_ASSERT(qAccessibleCache->objectToId.contains(qApp));
+ QAccessibleCache::instance()->insert(object, appInterface);
+ Q_ASSERT(QAccessibleCache::instance()->objectToId.contains(qApp));
return appInterface;
}
#endif
@@ -691,7 +689,7 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
QAccessible::Id QAccessible::registerAccessibleInterface(QAccessibleInterface *iface)
{
Q_ASSERT(iface);
- return qAccessibleCache->insert(iface->object(), iface);
+ return QAccessibleCache::instance()->insert(iface->object(), iface);
}
/*!
@@ -701,7 +699,7 @@ QAccessible::Id QAccessible::registerAccessibleInterface(QAccessibleInterface *i
*/
void QAccessible::deleteAccessibleInterface(Id id)
{
- qAccessibleCache->deleteInterface(id);
+ QAccessibleCache::instance()->deleteInterface(id);
}
/*!
@@ -709,7 +707,7 @@ void QAccessible::deleteAccessibleInterface(Id id)
*/
QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface)
{
- Id id = qAccessibleCache->idToInterface.key(iface);
+ Id id = QAccessibleCache::instance()->idToInterface.key(iface);
if (!id)
id = registerAccessibleInterface(iface);
return id;
@@ -722,7 +720,7 @@ QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface)
*/
QAccessibleInterface *QAccessible::accessibleInterface(Id id)
{
- return qAccessibleCache->idToInterface.value(id);
+ return QAccessibleCache::instance()->idToInterface.value(id);
}
diff --git a/src/gui/accessible/qaccessiblecache.cpp b/src/gui/accessible/qaccessiblecache.cpp
index fe66c6e19d..09c155515e 100644
--- a/src/gui/accessible/qaccessiblecache.cpp
+++ b/src/gui/accessible/qaccessiblecache.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -49,6 +49,13 @@ QT_BEGIN_NAMESPACE
\brief Maintains a cache of accessible interfaces.
*/
+Q_GLOBAL_STATIC(QAccessibleCache, qAccessibleCache)
+
+QAccessibleCache *QAccessibleCache::instance()
+{
+ return qAccessibleCache;
+}
+
/*
The ID is always in the range [INT_MAX+1, UINT_MAX].
This makes it easy on windows to reserve the positive integer range
@@ -113,6 +120,10 @@ void QAccessibleCache::deleteInterface(QAccessible::Id id, QObject *obj)
if (obj)
objectToId.remove(obj);
delete iface;
+
+#ifdef Q_OS_MACX
+ removeCocoaElement(id);
+#endif
}
QT_END_NAMESPACE
diff --git a/src/gui/accessible/qaccessiblecache_mac.mm b/src/gui/accessible/qaccessiblecache_mac.mm
new file mode 100644
index 0000000000..861423af7d
--- /dev/null
+++ b/src/gui/accessible/qaccessiblecache_mac.mm
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qaccessiblecache_p.h"
+
+#ifdef Q_OS_OSX
+
+QT_BEGIN_NAMESPACE
+
+void QAccessibleCache::insertElement(QAccessible::Id axid, QCocoaAccessibleElement *element) const
+{
+ cocoaElements[axid] = element;
+}
+
+void QAccessibleCache::removeCocoaElement(QAccessible::Id axid)
+{
+ QCocoaAccessibleElement *element = elementForId(axid);
+ [element invalidate];
+ cocoaElements.remove(axid);
+}
+
+QCocoaAccessibleElement *QAccessibleCache::elementForId(QAccessible::Id axid) const
+{
+ return cocoaElements.value(axid);
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/gui/accessible/qaccessiblecache_p.h b/src/gui/accessible/qaccessiblecache_p.h
index 32f9c443ba..30b023cfbd 100644
--- a/src/gui/accessible/qaccessiblecache_p.h
+++ b/src/gui/accessible/qaccessiblecache_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -42,24 +42,42 @@
#ifndef QACCESSIBLECACHE_P
#define QACCESSIBLECACHE_P
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtCore/qglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qhash.h>
#include "qaccessible.h"
-QT_BEGIN_NAMESPACE
+Q_FORWARD_DECLARE_OBJC_CLASS(QCocoaAccessibleElement);
+QT_BEGIN_NAMESPACE
-class QAccessibleCache :public QObject
+class Q_GUI_EXPORT QAccessibleCache :public QObject
{
Q_OBJECT
public:
+ static QAccessibleCache *instance();
QAccessibleInterface *interfaceForId(QAccessible::Id id) const;
QAccessible::Id insert(QObject *object, QAccessibleInterface *iface) const;
void deleteInterface(QAccessible::Id id, QObject *obj = 0);
+#ifdef Q_OS_OSX
+ QCocoaAccessibleElement *elementForId(QAccessible::Id axid) const;
+ void insertElement(QAccessible::Id axid, QCocoaAccessibleElement *element) const;
+#endif
+
private Q_SLOTS:
void objectDestroyed(QObject *obj);
@@ -69,6 +87,11 @@ private:
mutable QHash<QAccessible::Id, QAccessibleInterface *> idToInterface;
mutable QHash<QObject *, QAccessible::Id> objectToId;
+#ifdef Q_OS_OSX
+ void removeCocoaElement(QAccessible::Id axid);
+ mutable QHash<QAccessible::Id, QCocoaAccessibleElement *> cocoaElements;
+#endif
+
friend class QAccessible;
friend class QAccessibleInterface;
};