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