QtBase  v6.3.1
qaccessibleobject.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
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 The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #include "qaccessibleobject.h"
41 
42 #ifndef QT_NO_ACCESSIBILITY
43 
44 #include <QtGui/QGuiApplication>
45 #include <QtGui/QWindow>
46 
47 #include "qpointer.h"
48 #include "qmetaobject.h"
49 
51 
53 {
54 public:
56 };
57 
79 {
81  d->object = object;
82 }
83 
91 {
92  delete d;
93 }
94 
99 {
100  return d->object;
101 }
102 
107 {
108  return !d->object.isNull();
109 }
110 
113 {
114  return QRect();
115 }
116 
119 {
120 }
121 
124 {
125  for (int i = 0; i < childCount(); ++i) {
126  QAccessibleInterface *childIface = child(i);
127  Q_ASSERT(childIface);
128  if (childIface->isValid() && childIface->rect().contains(x,y))
129  return childIface;
130  }
131  return nullptr;
132 }
133 
148 {
149 }
150 
152 {
153  // an application can have several windows, and AFAIK we don't need
154  // to notify about changes on the application.
155  return nullptr;
156 }
157 
158 // all toplevel windows except popups and the desktop
159 static QObjectList topLevelObjects()
160 {
163  for (int i = 0; i < tlw.count(); ++i) {
164  QWindow *w = tlw.at(i);
165  if (w->type() != Qt::Popup && w->type() != Qt::Desktop) {
166  if (QAccessibleInterface *root = w->accessibleRoot()) {
167  if (root->object())
168  list.append(root->object());
169  }
170  }
171  }
172 
173  return list;
174 }
175 
178 {
179  return topLevelObjects().count();
180 }
181 
184 {
185  if (!child)
186  return -1;
187  const QObjectList tlw(topLevelObjects());
188  return tlw.indexOf(child->object());
189 }
190 
192 {
193  return nullptr;
194 }
195 
197 {
198  const QObjectList tlo(topLevelObjects());
199  if (index >= 0 && index < tlo.count())
201  return nullptr;
202 }
203 
204 
207 {
209  return window->accessibleRoot();
210  return nullptr;
211 }
212 
215 {
216  switch (t) {
217  case QAccessible::Name:
221  default:
222  break;
223  }
224  return QString();
225 }
226 
229 {
231 }
232 
235 {
236  return QAccessible::State();
237 }
238 
239 
241 
242 #endif //QT_NO_ACCESSIBILITY
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
enum State_ State
int indexOfChild(const QAccessibleInterface *) const override
QWindow * window() const override
QAccessible::Role role() const override
QAccessibleInterface * focusChild() const override
int childCount() const override
QAccessibleInterface * child(int index) const override
QString text(QAccessible::Text t) const override
QAccessibleInterface * parent() const override
QAccessible::State state() const override
static QAccessibleInterface * queryAccessibleInterface(QObject *)
The QAccessibleInterface class defines an interface that exposes information about accessible objects...
Definition: qaccessible.h:459
virtual bool isValid() const =0
virtual QObject * object() const =0
virtual int childCount() const =0
virtual QAccessibleInterface * child(int index) const =0
virtual QRect rect() const =0
The QAccessibleObject class implements parts of the QAccessibleInterface for QObjects.
QAccessibleObject(QObject *object)
QRect rect() const override
void setText(QAccessible::Text t, const QString &text) override
QObject * object() const override
bool isValid() const override
QAccessibleInterface * childAt(int x, int y) const override
QPointer< QObject > object
static QString applicationFilePath()
QString applicationName
the name of this application
static QWindowList topLevelWindows()
static QWindow * focusWindow()
const_reference at(qsizetype i) const noexcept
Definition: qlist.h:457
qsizetype count() const noexcept
Definition: qlist.h:415
The QObject class is the base class of all Qt objects.
Definition: qobject.h:125
bool isNull() const
Definition: qpointer.h:87
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:59
bool contains(const QRect &r, bool proper=false) const noexcept
Definition: qrect.cpp:887
The QString class provides a Unicode character string.
Definition: qstring.h:388
The QWindow class represents a window in the underlying windowing system.
Definition: qwindow.h:99
@ Desktop
Definition: qnamespace.h:240
@ Popup
Definition: qnamespace.h:236
#define QString()
Definition: parse-defines.h:51
#define qApp
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLuint index
[2]
GLint y
GLdouble GLdouble t
[9]
Definition: qopenglext.h:243
#define Q_ASSERT(cond)
Definition: qrandom.cpp:84
QLayoutItem * child
[0]
QStringList list
[0]
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
Definition: qlist.h:966