Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/accessible/qaccessiblewidget.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||
2 | ** | - | ||||||||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||
5 | ** | - | ||||||||||||||||||
6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||||||||
7 | ** | - | ||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||
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 http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
15 | ** information use the contact form at http://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 2.1 or version 3 as published by the Free | - | ||||||||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||
25 | ** | - | ||||||||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||
29 | ** | - | ||||||||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
31 | ** | - | ||||||||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||||||||
33 | - | |||||||||||||||||||
34 | #include "qaccessiblewidget.h" | - | ||||||||||||||||||
35 | - | |||||||||||||||||||
36 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
37 | - | |||||||||||||||||||
38 | #include "qaction.h" | - | ||||||||||||||||||
39 | #include "qapplication.h" | - | ||||||||||||||||||
40 | #include "qgroupbox.h" | - | ||||||||||||||||||
41 | #include "qlabel.h" | - | ||||||||||||||||||
42 | #include "qtooltip.h" | - | ||||||||||||||||||
43 | #include "qwhatsthis.h" | - | ||||||||||||||||||
44 | #include "qwidget.h" | - | ||||||||||||||||||
45 | #include "qdebug.h" | - | ||||||||||||||||||
46 | #include <qmath.h> | - | ||||||||||||||||||
47 | #include <QRubberBand> | - | ||||||||||||||||||
48 | #include <QFocusFrame> | - | ||||||||||||||||||
49 | #include <QMenu> | - | ||||||||||||||||||
50 | #include <QtWidgets/private/qwidget_p.h> | - | ||||||||||||||||||
51 | - | |||||||||||||||||||
52 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
53 | - | |||||||||||||||||||
54 | static QList<QWidget*> childWidgets(const QWidget *widget) | - | ||||||||||||||||||
55 | { | - | ||||||||||||||||||
56 | QList<QObject*> list = widget->children(); | - | ||||||||||||||||||
57 | QList<QWidget*> widgets; | - | ||||||||||||||||||
58 | for (int i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||
59 | QWidget *w = qobject_cast<QWidget *>(list.at(i)); | - | ||||||||||||||||||
60 | if (w && !w->isWindow()
| 0 | ||||||||||||||||||
61 | && !qobject_cast<QFocusFrame*>(w)
| 0 | ||||||||||||||||||
62 | #if !defined(QT_NO_MENU) | - | ||||||||||||||||||
63 | && !qobject_cast<QMenu*>(w)
| 0 | ||||||||||||||||||
64 | #endif | - | ||||||||||||||||||
65 | && w->objectName() != QLatin1String("qt_rubberband")
| 0 | ||||||||||||||||||
66 | && w->objectName() != QLatin1String("qt_spinbox_lineedit"))
| 0 | ||||||||||||||||||
67 | widgets.append(w); never executed: widgets.append(w); | 0 | ||||||||||||||||||
68 | } never executed: end of block | 0 | ||||||||||||||||||
69 | return widgets; never executed: return widgets; | 0 | ||||||||||||||||||
70 | } | - | ||||||||||||||||||
71 | - | |||||||||||||||||||
72 | static QString buddyString(const QWidget *widget) | - | ||||||||||||||||||
73 | { | - | ||||||||||||||||||
74 | if (!widget)
| 0 | ||||||||||||||||||
75 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
76 | QWidget *parent = widget->parentWidget(); | - | ||||||||||||||||||
77 | if (!parent)
| 0 | ||||||||||||||||||
78 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
79 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||
80 | QObjectList ol = parent->children(); | - | ||||||||||||||||||
81 | for (int i = 0; i < ol.size(); ++i) {
| 0 | ||||||||||||||||||
82 | QLabel *label = qobject_cast<QLabel*>(ol.at(i)); | - | ||||||||||||||||||
83 | if (label && label->buddy() == widget)
| 0 | ||||||||||||||||||
84 | return label->text(); never executed: return label->text(); | 0 | ||||||||||||||||||
85 | } never executed: end of block | 0 | ||||||||||||||||||
86 | #endif | - | ||||||||||||||||||
87 | - | |||||||||||||||||||
88 | #ifndef QT_NO_GROUPBOX | - | ||||||||||||||||||
89 | QGroupBox *groupbox = qobject_cast<QGroupBox*>(parent); | - | ||||||||||||||||||
90 | if (groupbox)
| 0 | ||||||||||||||||||
91 | return groupbox->title(); never executed: return groupbox->title(); | 0 | ||||||||||||||||||
92 | #endif | - | ||||||||||||||||||
93 | - | |||||||||||||||||||
94 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
95 | } | - | ||||||||||||||||||
96 | - | |||||||||||||||||||
97 | /* This function will return the offset of the '&' in the text that would be | - | ||||||||||||||||||
98 | preceding the accelerator character. | - | ||||||||||||||||||
99 | If this text does not have an accelerator, -1 will be returned. */ | - | ||||||||||||||||||
100 | static int qt_accAmpIndex(const QString &text) | - | ||||||||||||||||||
101 | { | - | ||||||||||||||||||
102 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||
103 | if (text.isEmpty())
| 0 | ||||||||||||||||||
104 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
105 | - | |||||||||||||||||||
106 | int fa = 0; | - | ||||||||||||||||||
107 | while ((fa = text.indexOf(QLatin1Char('&'), fa)) != -1) {
| 0 | ||||||||||||||||||
108 | ++fa; | - | ||||||||||||||||||
109 | if (fa < text.length()) {
| 0 | ||||||||||||||||||
110 | // ignore "&&" | - | ||||||||||||||||||
111 | if (text.at(fa) == QLatin1Char('&')) {
| 0 | ||||||||||||||||||
112 | - | |||||||||||||||||||
113 | ++fa; | - | ||||||||||||||||||
114 | continue; never executed: continue; | 0 | ||||||||||||||||||
115 | } else { | - | ||||||||||||||||||
116 | return fa - 1; never executed: return fa - 1; | 0 | ||||||||||||||||||
117 | break; dead code: break; | - | ||||||||||||||||||
118 | } | - | ||||||||||||||||||
119 | } | - | ||||||||||||||||||
120 | } never executed: end of block | 0 | ||||||||||||||||||
121 | - | |||||||||||||||||||
122 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
123 | #else | - | ||||||||||||||||||
124 | Q_UNUSED(text); | - | ||||||||||||||||||
125 | return -1; | - | ||||||||||||||||||
126 | #endif | - | ||||||||||||||||||
127 | } | - | ||||||||||||||||||
128 | - | |||||||||||||||||||
129 | QString qt_accStripAmp(const QString &text) | - | ||||||||||||||||||
130 | { | - | ||||||||||||||||||
131 | QString newText(text); | - | ||||||||||||||||||
132 | int ampIndex = qt_accAmpIndex(newText); | - | ||||||||||||||||||
133 | if (ampIndex != -1)
| 0 | ||||||||||||||||||
134 | newText.remove(ampIndex, 1); never executed: newText.remove(ampIndex, 1); | 0 | ||||||||||||||||||
135 | - | |||||||||||||||||||
136 | return newText.replace(QLatin1String("&&"), QLatin1String("&")); never executed: return newText.replace(QLatin1String("&&"), QLatin1String("&")); | 0 | ||||||||||||||||||
137 | } | - | ||||||||||||||||||
138 | - | |||||||||||||||||||
139 | QString qt_accHotKey(const QString &text) | - | ||||||||||||||||||
140 | { | - | ||||||||||||||||||
141 | int ampIndex = qt_accAmpIndex(text); | - | ||||||||||||||||||
142 | if (ampIndex != -1)
| 0 | ||||||||||||||||||
143 | return QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + text.at(ampIndex + 1); never executed: return QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + text.at(ampIndex + 1); | 0 | ||||||||||||||||||
144 | - | |||||||||||||||||||
145 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
146 | } | - | ||||||||||||||||||
147 | - | |||||||||||||||||||
148 | // ### inherit QAccessibleObjectPrivate | - | ||||||||||||||||||
149 | class QAccessibleWidgetPrivate | - | ||||||||||||||||||
150 | { | - | ||||||||||||||||||
151 | public: | - | ||||||||||||||||||
152 | QAccessibleWidgetPrivate() | - | ||||||||||||||||||
153 | :role(QAccessible::Client) | - | ||||||||||||||||||
154 | {} never executed: end of block | 0 | ||||||||||||||||||
155 | - | |||||||||||||||||||
156 | QAccessible::Role role; | - | ||||||||||||||||||
157 | QString name; | - | ||||||||||||||||||
158 | QStringList primarySignals; | - | ||||||||||||||||||
159 | }; | - | ||||||||||||||||||
160 | - | |||||||||||||||||||
161 | /*! | - | ||||||||||||||||||
162 | \class QAccessibleWidget | - | ||||||||||||||||||
163 | \brief The QAccessibleWidget class implements the QAccessibleInterface for QWidgets. | - | ||||||||||||||||||
164 | - | |||||||||||||||||||
165 | \ingroup accessibility | - | ||||||||||||||||||
166 | \inmodule QtWidgets | - | ||||||||||||||||||
167 | - | |||||||||||||||||||
168 | This class is part of \l {Accessibility for QWidget Applications}. | - | ||||||||||||||||||
169 | - | |||||||||||||||||||
170 | This class is convenient to use as a base class for custom | - | ||||||||||||||||||
171 | implementations of QAccessibleInterfaces that provide information | - | ||||||||||||||||||
172 | about widget objects. | - | ||||||||||||||||||
173 | - | |||||||||||||||||||
174 | The class provides functions to retrieve the parentObject() (the | - | ||||||||||||||||||
175 | widget's parent widget), and the associated widget(). Controlling | - | ||||||||||||||||||
176 | signals can be added with addControllingSignal(), and setters are | - | ||||||||||||||||||
177 | provided for various aspects of the interface implementation, for | - | ||||||||||||||||||
178 | example setValue(), setDescription(), setAccelerator(), and | - | ||||||||||||||||||
179 | setHelp(). | - | ||||||||||||||||||
180 | - | |||||||||||||||||||
181 | \sa QAccessible, QAccessibleObject | - | ||||||||||||||||||
182 | */ | - | ||||||||||||||||||
183 | - | |||||||||||||||||||
184 | /*! | - | ||||||||||||||||||
185 | Creates a QAccessibleWidget object for widget \a w. | - | ||||||||||||||||||
186 | \a role and \a name are optional parameters that set the object's | - | ||||||||||||||||||
187 | role and name properties. | - | ||||||||||||||||||
188 | */ | - | ||||||||||||||||||
189 | QAccessibleWidget::QAccessibleWidget(QWidget *w, QAccessible::Role role, const QString &name) | - | ||||||||||||||||||
190 | : QAccessibleObject(w) | - | ||||||||||||||||||
191 | { | - | ||||||||||||||||||
192 | Q_ASSERT(widget()); | - | ||||||||||||||||||
193 | d = new QAccessibleWidgetPrivate(); | - | ||||||||||||||||||
194 | d->role = role; | - | ||||||||||||||||||
195 | d->name = name; | - | ||||||||||||||||||
196 | } never executed: end of block | 0 | ||||||||||||||||||
197 | - | |||||||||||||||||||
198 | /*! \reimp */ | - | ||||||||||||||||||
199 | bool QAccessibleWidget::isValid() const | - | ||||||||||||||||||
200 | { | - | ||||||||||||||||||
201 | if (!object() || static_cast<QWidget *>(object())->d_func()->data.in_destructor)
| 0 | ||||||||||||||||||
202 | return false; never executed: return false; | 0 | ||||||||||||||||||
203 | return QAccessibleObject::isValid(); never executed: return QAccessibleObject::isValid(); | 0 | ||||||||||||||||||
204 | } | - | ||||||||||||||||||
205 | - | |||||||||||||||||||
206 | /*! \reimp */ | - | ||||||||||||||||||
207 | QWindow *QAccessibleWidget::window() const | - | ||||||||||||||||||
208 | { | - | ||||||||||||||||||
209 | const QWidget *w = widget(); | - | ||||||||||||||||||
210 | Q_ASSERT(w); | - | ||||||||||||||||||
211 | QWindow *result = w->windowHandle(); | - | ||||||||||||||||||
212 | if (!result) {
| 0 | ||||||||||||||||||
213 | if (const QWidget *nativeParent = w->nativeParentWidget())
| 0 | ||||||||||||||||||
214 | result = nativeParent->windowHandle(); never executed: result = nativeParent->windowHandle(); | 0 | ||||||||||||||||||
215 | } never executed: end of block | 0 | ||||||||||||||||||
216 | return result; never executed: return result; | 0 | ||||||||||||||||||
217 | } | - | ||||||||||||||||||
218 | - | |||||||||||||||||||
219 | /*! | - | ||||||||||||||||||
220 | Destroys this object. | - | ||||||||||||||||||
221 | */ | - | ||||||||||||||||||
222 | QAccessibleWidget::~QAccessibleWidget() | - | ||||||||||||||||||
223 | { | - | ||||||||||||||||||
224 | delete d; | - | ||||||||||||||||||
225 | } never executed: end of block | 0 | ||||||||||||||||||
226 | - | |||||||||||||||||||
227 | /*! | - | ||||||||||||||||||
228 | Returns the associated widget. | - | ||||||||||||||||||
229 | */ | - | ||||||||||||||||||
230 | QWidget *QAccessibleWidget::widget() const | - | ||||||||||||||||||
231 | { | - | ||||||||||||||||||
232 | return qobject_cast<QWidget*>(object()); never executed: return qobject_cast<QWidget*>(object()); | 0 | ||||||||||||||||||
233 | } | - | ||||||||||||||||||
234 | - | |||||||||||||||||||
235 | /*! | - | ||||||||||||||||||
236 | Returns the associated widget's parent object, which is either the | - | ||||||||||||||||||
237 | parent widget, or qApp for top-level widgets. | - | ||||||||||||||||||
238 | */ | - | ||||||||||||||||||
239 | QObject *QAccessibleWidget::parentObject() const | - | ||||||||||||||||||
240 | { | - | ||||||||||||||||||
241 | QWidget *w = widget(); | - | ||||||||||||||||||
242 | if (!w || w->isWindow() || !w->parentWidget())
| 0 | ||||||||||||||||||
243 | return qApp; never executed: return (static_cast<QApplication *>(QCoreApplication::instance())); | 0 | ||||||||||||||||||
244 | return w->parent(); never executed: return w->parent(); | 0 | ||||||||||||||||||
245 | } | - | ||||||||||||||||||
246 | - | |||||||||||||||||||
247 | /*! \reimp */ | - | ||||||||||||||||||
248 | QRect QAccessibleWidget::rect() const | - | ||||||||||||||||||
249 | { | - | ||||||||||||||||||
250 | QWidget *w = widget(); | - | ||||||||||||||||||
251 | if (!w->isVisible())
| 0 | ||||||||||||||||||
252 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||
253 | QPoint wpos = w->mapToGlobal(QPoint(0, 0)); | - | ||||||||||||||||||
254 | - | |||||||||||||||||||
255 | return QRect(wpos.x(), wpos.y(), w->width(), w->height()); never executed: return QRect(wpos.x(), wpos.y(), w->width(), w->height()); | 0 | ||||||||||||||||||
256 | } | - | ||||||||||||||||||
257 | - | |||||||||||||||||||
258 | QT_BEGIN_INCLUDE_NAMESPACE | - | ||||||||||||||||||
259 | #include <private/qobject_p.h> | - | ||||||||||||||||||
260 | QT_END_INCLUDE_NAMESPACE | - | ||||||||||||||||||
261 | - | |||||||||||||||||||
262 | class QACConnectionObject : public QObject | - | ||||||||||||||||||
263 | { | - | ||||||||||||||||||
264 | Q_DECLARE_PRIVATE(QObject) never executed: return reinterpret_cast<QObjectPrivate *>(qGetPtrHelper(d_ptr)); never executed: return reinterpret_cast<const QObjectPrivate *>(qGetPtrHelper(d_ptr)); | 0 | ||||||||||||||||||
265 | public: | - | ||||||||||||||||||
266 | inline bool isSender(const QObject *receiver, const char *signal) const | - | ||||||||||||||||||
267 | { return d_func()->isSender(receiver, signal); } never executed: return d_func()->isSender(receiver, signal); | 0 | ||||||||||||||||||
268 | inline QObjectList receiverList(const char *signal) const | - | ||||||||||||||||||
269 | { return d_func()->receiverList(signal); } never executed: return d_func()->receiverList(signal); | 0 | ||||||||||||||||||
270 | inline QObjectList senderList() const | - | ||||||||||||||||||
271 | { return d_func()->senderList(); } never executed: return d_func()->senderList(); | 0 | ||||||||||||||||||
272 | }; | - | ||||||||||||||||||
273 | - | |||||||||||||||||||
274 | /*! | - | ||||||||||||||||||
275 | Registers \a signal as a controlling signal. | - | ||||||||||||||||||
276 | - | |||||||||||||||||||
277 | An object is a Controller to any other object connected to a | - | ||||||||||||||||||
278 | controlling signal. | - | ||||||||||||||||||
279 | */ | - | ||||||||||||||||||
280 | void QAccessibleWidget::addControllingSignal(const QString &signal) | - | ||||||||||||||||||
281 | { | - | ||||||||||||||||||
282 | QByteArray s = QMetaObject::normalizedSignature(signal.toLatin1()); | - | ||||||||||||||||||
283 | if (object()->metaObject()->indexOfSignal(s) < 0)
| 0 | ||||||||||||||||||
284 | qWarning("Signal %s unknown in %s", s.constData(), object()->metaObject()->className()); never executed: QMessageLogger(__FILE__, 284, __PRETTY_FUNCTION__).warning("Signal %s unknown in %s", s.constData(), object()->metaObject()->className()); | 0 | ||||||||||||||||||
285 | d->primarySignals << QLatin1String(s); | - | ||||||||||||||||||
286 | } never executed: end of block | 0 | ||||||||||||||||||
287 | - | |||||||||||||||||||
288 | static inline bool isAncestor(const QObject *obj, const QObject *child) | - | ||||||||||||||||||
289 | { | - | ||||||||||||||||||
290 | while (child) {
| 0 | ||||||||||||||||||
291 | if (child == obj)
| 0 | ||||||||||||||||||
292 | return true; never executed: return true; | 0 | ||||||||||||||||||
293 | child = child->parent(); | - | ||||||||||||||||||
294 | } never executed: end of block | 0 | ||||||||||||||||||
295 | return false; never executed: return false; | 0 | ||||||||||||||||||
296 | } | - | ||||||||||||||||||
297 | - | |||||||||||||||||||
298 | /*! \reimp */ | - | ||||||||||||||||||
299 | QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > | - | ||||||||||||||||||
300 | QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRelations*/) const | - | ||||||||||||||||||
301 | { | - | ||||||||||||||||||
302 | QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > rels; | - | ||||||||||||||||||
303 | if (match & QAccessible::Label) {
| 0 | ||||||||||||||||||
304 | const QAccessible::Relation rel = QAccessible::Label; | - | ||||||||||||||||||
305 | if (QWidget *parent = widget()->parentWidget()) {
| 0 | ||||||||||||||||||
306 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||
307 | // first check for all siblings that are labels to us | - | ||||||||||||||||||
308 | // ideally we would go through all objects and check, but that | - | ||||||||||||||||||
309 | // will be too expensive | - | ||||||||||||||||||
310 | const QList<QWidget*> kids = childWidgets(parent); | - | ||||||||||||||||||
311 | for (int i = 0; i < kids.count(); ++i) {
| 0 | ||||||||||||||||||
312 | if (QLabel *labelSibling = qobject_cast<QLabel*>(kids.at(i))) {
| 0 | ||||||||||||||||||
313 | if (labelSibling->buddy() == widget()) {
| 0 | ||||||||||||||||||
314 | QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(labelSibling); | - | ||||||||||||||||||
315 | rels.append(qMakePair(iface, rel)); | - | ||||||||||||||||||
316 | } never executed: end of block | 0 | ||||||||||||||||||
317 | } never executed: end of block | 0 | ||||||||||||||||||
318 | } never executed: end of block | 0 | ||||||||||||||||||
319 | #endif | - | ||||||||||||||||||
320 | #ifndef QT_NO_GROUPBOX | - | ||||||||||||||||||
321 | QGroupBox *groupbox = qobject_cast<QGroupBox*>(parent); | - | ||||||||||||||||||
322 | if (groupbox && !groupbox->title().isEmpty()) {
| 0 | ||||||||||||||||||
323 | QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(groupbox); | - | ||||||||||||||||||
324 | rels.append(qMakePair(iface, rel)); | - | ||||||||||||||||||
325 | } never executed: end of block | 0 | ||||||||||||||||||
326 | #endif | - | ||||||||||||||||||
327 | } never executed: end of block | 0 | ||||||||||||||||||
328 | } never executed: end of block | 0 | ||||||||||||||||||
329 | - | |||||||||||||||||||
330 | if (match & QAccessible::Controlled) {
| 0 | ||||||||||||||||||
331 | QObjectList allReceivers; | - | ||||||||||||||||||
332 | QACConnectionObject *connectionObject = (QACConnectionObject*)object(); | - | ||||||||||||||||||
333 | for (int sig = 0; sig < d->primarySignals.count(); ++sig) {
| 0 | ||||||||||||||||||
334 | const QObjectList receivers = connectionObject->receiverList(d->primarySignals.at(sig).toLatin1()); | - | ||||||||||||||||||
335 | allReceivers += receivers; | - | ||||||||||||||||||
336 | } never executed: end of block | 0 | ||||||||||||||||||
337 | - | |||||||||||||||||||
338 | allReceivers.removeAll(object()); //### The object might connect to itself internally | - | ||||||||||||||||||
339 | - | |||||||||||||||||||
340 | for (int i = 0; i < allReceivers.count(); ++i) {
| 0 | ||||||||||||||||||
341 | const QAccessible::Relation rel = QAccessible::Controlled; | - | ||||||||||||||||||
342 | QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(allReceivers.at(i)); | - | ||||||||||||||||||
343 | if (iface)
| 0 | ||||||||||||||||||
344 | rels.append(qMakePair(iface, rel)); never executed: rels.append(qMakePair(iface, rel)); | 0 | ||||||||||||||||||
345 | } never executed: end of block | 0 | ||||||||||||||||||
346 | } never executed: end of block | 0 | ||||||||||||||||||
347 | - | |||||||||||||||||||
348 | return rels; never executed: return rels; | 0 | ||||||||||||||||||
349 | } | - | ||||||||||||||||||
350 | - | |||||||||||||||||||
351 | /*! \reimp */ | - | ||||||||||||||||||
352 | QAccessibleInterface *QAccessibleWidget::parent() const | - | ||||||||||||||||||
353 | { | - | ||||||||||||||||||
354 | return QAccessible::queryAccessibleInterface(parentObject()); never executed: return QAccessible::queryAccessibleInterface(parentObject()); | 0 | ||||||||||||||||||
355 | } | - | ||||||||||||||||||
356 | - | |||||||||||||||||||
357 | /*! \reimp */ | - | ||||||||||||||||||
358 | QAccessibleInterface *QAccessibleWidget::child(int index) const | - | ||||||||||||||||||
359 | { | - | ||||||||||||||||||
360 | Q_ASSERT(widget()); | - | ||||||||||||||||||
361 | QWidgetList childList = childWidgets(widget()); | - | ||||||||||||||||||
362 | if (index >= 0 && index < childList.size())
| 0 | ||||||||||||||||||
363 | return QAccessible::queryAccessibleInterface(childList.at(index)); never executed: return QAccessible::queryAccessibleInterface(childList.at(index)); | 0 | ||||||||||||||||||
364 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
365 | } | - | ||||||||||||||||||
366 | - | |||||||||||||||||||
367 | /*! \reimp */ | - | ||||||||||||||||||
368 | QAccessibleInterface *QAccessibleWidget::focusChild() const | - | ||||||||||||||||||
369 | { | - | ||||||||||||||||||
370 | if (widget()->hasFocus())
| 0 | ||||||||||||||||||
371 | return QAccessible::queryAccessibleInterface(object()); never executed: return QAccessible::queryAccessibleInterface(object()); | 0 | ||||||||||||||||||
372 | - | |||||||||||||||||||
373 | QWidget *fw = widget()->focusWidget(); | - | ||||||||||||||||||
374 | if (!fw)
| 0 | ||||||||||||||||||
375 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
376 | - | |||||||||||||||||||
377 | if (isAncestor(widget(), fw) || fw == widget())
| 0 | ||||||||||||||||||
378 | return QAccessible::queryAccessibleInterface(fw); never executed: return QAccessible::queryAccessibleInterface(fw); | 0 | ||||||||||||||||||
379 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
380 | } | - | ||||||||||||||||||
381 | - | |||||||||||||||||||
382 | /*! \reimp */ | - | ||||||||||||||||||
383 | int QAccessibleWidget::childCount() const | - | ||||||||||||||||||
384 | { | - | ||||||||||||||||||
385 | QWidgetList cl = childWidgets(widget()); | - | ||||||||||||||||||
386 | return cl.size(); never executed: return cl.size(); | 0 | ||||||||||||||||||
387 | } | - | ||||||||||||||||||
388 | - | |||||||||||||||||||
389 | /*! \reimp */ | - | ||||||||||||||||||
390 | int QAccessibleWidget::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
391 | { | - | ||||||||||||||||||
392 | if (!child)
| 0 | ||||||||||||||||||
393 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
394 | QWidgetList cl = childWidgets(widget()); | - | ||||||||||||||||||
395 | return cl.indexOf(qobject_cast<QWidget *>(child->object())); never executed: return cl.indexOf(qobject_cast<QWidget *>(child->object())); | 0 | ||||||||||||||||||
396 | } | - | ||||||||||||||||||
397 | - | |||||||||||||||||||
398 | // from qwidget.cpp | - | ||||||||||||||||||
399 | extern QString qt_setWindowTitle_helperHelper(const QString &, const QWidget*); | - | ||||||||||||||||||
400 | - | |||||||||||||||||||
401 | /*! \reimp */ | - | ||||||||||||||||||
402 | QString QAccessibleWidget::text(QAccessible::Text t) const | - | ||||||||||||||||||
403 | { | - | ||||||||||||||||||
404 | QString str; | - | ||||||||||||||||||
405 | - | |||||||||||||||||||
406 | switch (t) { | - | ||||||||||||||||||
407 | case QAccessible::Name: never executed: case QAccessible::Name: | 0 | ||||||||||||||||||
408 | if (!d->name.isEmpty()) {
| 0 | ||||||||||||||||||
409 | str = d->name; | - | ||||||||||||||||||
410 | } else if (!widget()->accessibleName().isEmpty()) { never executed: end of block
| 0 | ||||||||||||||||||
411 | str = widget()->accessibleName(); | - | ||||||||||||||||||
412 | } else if (widget()->isWindow()) { never executed: end of block
| 0 | ||||||||||||||||||
413 | if (widget()->isMinimized())
| 0 | ||||||||||||||||||
414 | str = qt_setWindowTitle_helperHelper(widget()->windowIconText(), widget()); never executed: str = qt_setWindowTitle_helperHelper(widget()->windowIconText(), widget()); | 0 | ||||||||||||||||||
415 | else | - | ||||||||||||||||||
416 | str = qt_setWindowTitle_helperHelper(widget()->windowTitle(), widget()); never executed: str = qt_setWindowTitle_helperHelper(widget()->windowTitle(), widget()); | 0 | ||||||||||||||||||
417 | } else { | - | ||||||||||||||||||
418 | str = qt_accStripAmp(buddyString(widget())); | - | ||||||||||||||||||
419 | } never executed: end of block | 0 | ||||||||||||||||||
420 | break; never executed: break; | 0 | ||||||||||||||||||
421 | case QAccessible::Description: never executed: case QAccessible::Description: | 0 | ||||||||||||||||||
422 | str = widget()->accessibleDescription(); | - | ||||||||||||||||||
423 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||
424 | if (str.isEmpty())
| 0 | ||||||||||||||||||
425 | str = widget()->toolTip(); never executed: str = widget()->toolTip(); | 0 | ||||||||||||||||||
426 | #endif | - | ||||||||||||||||||
427 | break; never executed: break; | 0 | ||||||||||||||||||
428 | case QAccessible::Help: never executed: case QAccessible::Help: | 0 | ||||||||||||||||||
429 | #ifndef QT_NO_WHATSTHIS | - | ||||||||||||||||||
430 | str = widget()->whatsThis(); | - | ||||||||||||||||||
431 | #endif | - | ||||||||||||||||||
432 | break; never executed: break; | 0 | ||||||||||||||||||
433 | case QAccessible::Accelerator: never executed: case QAccessible::Accelerator: | 0 | ||||||||||||||||||
434 | str = qt_accHotKey(buddyString(widget())); | - | ||||||||||||||||||
435 | break; never executed: break; | 0 | ||||||||||||||||||
436 | case QAccessible::Value: never executed: case QAccessible::Value: | 0 | ||||||||||||||||||
437 | break; never executed: break; | 0 | ||||||||||||||||||
438 | default: never executed: default: | 0 | ||||||||||||||||||
439 | break; never executed: break; | 0 | ||||||||||||||||||
440 | } | - | ||||||||||||||||||
441 | return str; never executed: return str; | 0 | ||||||||||||||||||
442 | } | - | ||||||||||||||||||
443 | - | |||||||||||||||||||
444 | /*! \reimp */ | - | ||||||||||||||||||
445 | QStringList QAccessibleWidget::actionNames() const | - | ||||||||||||||||||
446 | { | - | ||||||||||||||||||
447 | QStringList names; | - | ||||||||||||||||||
448 | if (widget()->isEnabled()) {
| 0 | ||||||||||||||||||
449 | if (widget()->focusPolicy() != Qt::NoFocus)
| 0 | ||||||||||||||||||
450 | names << setFocusAction(); never executed: names << setFocusAction(); | 0 | ||||||||||||||||||
451 | } never executed: end of block | 0 | ||||||||||||||||||
452 | return names; never executed: return names; | 0 | ||||||||||||||||||
453 | } | - | ||||||||||||||||||
454 | - | |||||||||||||||||||
455 | /*! \reimp */ | - | ||||||||||||||||||
456 | void QAccessibleWidget::doAction(const QString &actionName) | - | ||||||||||||||||||
457 | { | - | ||||||||||||||||||
458 | if (!widget()->isEnabled())
| 0 | ||||||||||||||||||
459 | return; never executed: return; | 0 | ||||||||||||||||||
460 | - | |||||||||||||||||||
461 | if (actionName == setFocusAction()) {
| 0 | ||||||||||||||||||
462 | if (widget()->isWindow())
| 0 | ||||||||||||||||||
463 | widget()->activateWindow(); never executed: widget()->activateWindow(); | 0 | ||||||||||||||||||
464 | widget()->setFocus(); | - | ||||||||||||||||||
465 | } never executed: end of block | 0 | ||||||||||||||||||
466 | } never executed: end of block | 0 | ||||||||||||||||||
467 | - | |||||||||||||||||||
468 | /*! \reimp */ | - | ||||||||||||||||||
469 | QStringList QAccessibleWidget::keyBindingsForAction(const QString & /* actionName */) const | - | ||||||||||||||||||
470 | { | - | ||||||||||||||||||
471 | return QStringList(); never executed: return QStringList(); | 0 | ||||||||||||||||||
472 | } | - | ||||||||||||||||||
473 | - | |||||||||||||||||||
474 | /*! \reimp */ | - | ||||||||||||||||||
475 | QAccessible::Role QAccessibleWidget::role() const | - | ||||||||||||||||||
476 | { | - | ||||||||||||||||||
477 | return d->role; never executed: return d->role; | 0 | ||||||||||||||||||
478 | } | - | ||||||||||||||||||
479 | - | |||||||||||||||||||
480 | /*! \reimp */ | - | ||||||||||||||||||
481 | QAccessible::State QAccessibleWidget::state() const | - | ||||||||||||||||||
482 | { | - | ||||||||||||||||||
483 | QAccessible::State state; | - | ||||||||||||||||||
484 | - | |||||||||||||||||||
485 | QWidget *w = widget(); | - | ||||||||||||||||||
486 | if (w->testAttribute(Qt::WA_WState_Visible) == false)
| 0 | ||||||||||||||||||
487 | state.invisible = true; never executed: state.invisible = true; | 0 | ||||||||||||||||||
488 | if (w->focusPolicy() != Qt::NoFocus)
| 0 | ||||||||||||||||||
489 | state.focusable = true; never executed: state.focusable = true; | 0 | ||||||||||||||||||
490 | if (w->hasFocus())
| 0 | ||||||||||||||||||
491 | state.focused = true; never executed: state.focused = true; | 0 | ||||||||||||||||||
492 | if (!w->isEnabled())
| 0 | ||||||||||||||||||
493 | state.disabled = true; never executed: state.disabled = true; | 0 | ||||||||||||||||||
494 | if (w->isWindow()) {
| 0 | ||||||||||||||||||
495 | if (w->windowFlags() & Qt::WindowSystemMenuHint)
| 0 | ||||||||||||||||||
496 | state.movable = true; never executed: state.movable = true; | 0 | ||||||||||||||||||
497 | if (w->minimumSize() != w->maximumSize())
| 0 | ||||||||||||||||||
498 | state.sizeable = true; never executed: state.sizeable = true; | 0 | ||||||||||||||||||
499 | if (w->isActiveWindow())
| 0 | ||||||||||||||||||
500 | state.active = true; never executed: state.active = true; | 0 | ||||||||||||||||||
501 | } never executed: end of block | 0 | ||||||||||||||||||
502 | - | |||||||||||||||||||
503 | return state; never executed: return state; | 0 | ||||||||||||||||||
504 | } | - | ||||||||||||||||||
505 | - | |||||||||||||||||||
506 | /*! \reimp */ | - | ||||||||||||||||||
507 | QColor QAccessibleWidget::foregroundColor() const | - | ||||||||||||||||||
508 | { | - | ||||||||||||||||||
509 | return widget()->palette().color(widget()->foregroundRole()); never executed: return widget()->palette().color(widget()->foregroundRole()); | 0 | ||||||||||||||||||
510 | } | - | ||||||||||||||||||
511 | - | |||||||||||||||||||
512 | /*! \reimp */ | - | ||||||||||||||||||
513 | QColor QAccessibleWidget::backgroundColor() const | - | ||||||||||||||||||
514 | { | - | ||||||||||||||||||
515 | return widget()->palette().color(widget()->backgroundRole()); never executed: return widget()->palette().color(widget()->backgroundRole()); | 0 | ||||||||||||||||||
516 | } | - | ||||||||||||||||||
517 | - | |||||||||||||||||||
518 | /*! \reimp */ | - | ||||||||||||||||||
519 | void *QAccessibleWidget::interface_cast(QAccessible::InterfaceType t) | - | ||||||||||||||||||
520 | { | - | ||||||||||||||||||
521 | if (t == QAccessible::ActionInterface)
| 0 | ||||||||||||||||||
522 | return static_cast<QAccessibleActionInterface*>(this); never executed: return static_cast<QAccessibleActionInterface*>(this); | 0 | ||||||||||||||||||
523 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
524 | } | - | ||||||||||||||||||
525 | - | |||||||||||||||||||
526 | QT_END_NAMESPACE | - | ||||||||||||||||||
527 | - | |||||||||||||||||||
528 | #endif //QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |