Qt 4.8
qaccessible_unix.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qaccessible.h"
43 #include "qaccessiblebridge.h"
44 
45 #ifndef QT_NO_ACCESSIBILITY
46 
47 #include "qcoreapplication.h"
48 #include "qmutex.h"
49 #include "qvector.h"
50 #include "private/qfactoryloader_p.h"
51 
52 #include <stdlib.h>
53 
55 
56 #ifndef QT_NO_LIBRARY
59 #endif
61 static bool isInit = false;
62 
64 {
65  if (isInit)
66  return;
67  isInit = true;
68 
69  if (qgetenv("QT_ACCESSIBILITY") != "1")
70  return;
71 #ifndef QT_NO_LIBRARY
72  const QStringList l = loader()->keys();
73  for (int i = 0; i < l.count(); ++i) {
75  qobject_cast<QAccessibleBridgeFactoryInterface*>(loader()->instance(l.at(i)))) {
76  QAccessibleBridge * bridge = factory->create(l.at(i));
77  if (bridge)
78  bridges()->append(bridge);
79  }
80  }
81 #endif
82 }
83 
85 {
86  qDeleteAll(*bridges());
87 }
88 
89 void QAccessible::updateAccessibility(QObject *o, int who, Event reason)
90 {
91  Q_ASSERT(o);
92 
93  if (updateHandler) {
94  updateHandler(o, who, reason);
95  return;
96  }
97 
98  initialize();
99  if (!bridges() || bridges()->isEmpty())
100  return;
101 
103  if (!iface)
104  return;
105 
106  // updates for List/Table/Tree should send child
107  if (who) {
108  QAccessibleInterface *child;
109  iface->navigate(QAccessible::Child, who, &child);
110  if (child) {
111  delete iface;
112  iface = child;
113  who = 0;
114  }
115  }
116 
117  for (int i = 0; i < bridges()->count(); ++i)
118  bridges()->at(i)->notifyAccessibilityUpdate(reason, iface, who);
119  delete iface;
120 }
121 
123 {
124  if (rootObjectHandler) {
126  return;
127  }
128 
129  initialize();
130  if (bridges()->isEmpty())
131  return;
132 
133  if (!o)
134  return;
135 
136  for (int i = 0; i < bridges()->count(); ++i) {
138  bridges()->at(i)->setRootObject(iface);
139  }
140 }
141 
143 
144 #endif // QT_NO_ACCESSIBILITY
145 
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static void cleanup()
static void initialize()
QStringList keys() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool isEmpty(const char *str)
virtual int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const =0
Navigates from this object to an object that has a relationship relation to this object, and returns the respective object in target.
Event
This enum type defines accessible event types.
Definition: qaccessible.h:67
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
Definition: qglobal.h:1968
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
The QAccessibleBridge class is the base class for accessibility back-ends.
static QAccessibleInterface * queryAccessibleInterface(QObject *)
If a QAccessibleInterface implementation exists for the given object, this function returns a pointer...
#define QAccessibleBridgeFactoryInterface_iid
static void setRootObject(QObject *)
Sets the root accessible object of this application to object.
The QAccessibleInterface class defines an interface that exposes information about accessible objects...
Definition: qaccessible.h:370
QFactoryLoader * l
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,(QAccessibleBridgeFactoryInterface_iid, QLatin1String("/accessiblebridge"))) static bool isInit
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319
static UpdateHandler updateHandler
Definition: qaccessible.h:337
static RootObjectHandler rootObjectHandler
Definition: qaccessible.h:338