| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/accessible/complexwidgets.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 plugins 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 "complexwidgets_p.h" | - | ||||||||||||
| 41 | - | |||||||||||||
| 42 | #include <qaccessible.h> | - | ||||||||||||
| 43 | #include <qapplication.h> | - | ||||||||||||
| 44 | #include <qabstractbutton.h> | - | ||||||||||||
| 45 | #include <qevent.h> | - | ||||||||||||
| 46 | #include <qheaderview.h> | - | ||||||||||||
| 47 | #include <qtabbar.h> | - | ||||||||||||
| 48 | #include <qcombobox.h> | - | ||||||||||||
| 49 | #include <qlistview.h> | - | ||||||||||||
| 50 | #include <qtableview.h> | - | ||||||||||||
| 51 | #include <qlineedit.h> | - | ||||||||||||
| 52 | #include <qstyle.h> | - | ||||||||||||
| 53 | #include <qstyleoption.h> | - | ||||||||||||
| 54 | #include <qtooltip.h> | - | ||||||||||||
| 55 | #include <qwhatsthis.h> | - | ||||||||||||
| 56 | #include <qtreeview.h> | - | ||||||||||||
| 57 | #include <private/qtabbar_p.h> | - | ||||||||||||
| 58 | #include <QAbstractScrollArea> | - | ||||||||||||
| 59 | #include <QScrollArea> | - | ||||||||||||
| 60 | #include <QScrollBar> | - | ||||||||||||
| 61 | #include <QDebug> | - | ||||||||||||
| 62 | - | |||||||||||||
| 63 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||
| 64 | - | |||||||||||||
| 65 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 66 | - | |||||||||||||
| 67 | QString qt_accStripAmp(const QString &text); | - | ||||||||||||
| 68 | QString qt_accHotKey(const QString &text); | - | ||||||||||||
| 69 | - | |||||||||||||
| 70 | #ifndef QT_NO_TABBAR | - | ||||||||||||
| 71 | /*! | - | ||||||||||||
| 72 | \class QAccessibleTabBar | - | ||||||||||||
| 73 | \brief The QAccessibleTabBar class implements the QAccessibleInterface for tab bars. | - | ||||||||||||
| 74 | \internal | - | ||||||||||||
| 75 | - | |||||||||||||
| 76 | \ingroup accessibility | - | ||||||||||||
| 77 | */ | - | ||||||||||||
| 78 | - | |||||||||||||
| 79 | class QAccessibleTabButton: public QAccessibleInterface, public QAccessibleActionInterface | - | ||||||||||||
| 80 | { | - | ||||||||||||
| 81 | public: | - | ||||||||||||
| 82 | QAccessibleTabButton(QTabBar *parent, int index) | - | ||||||||||||
| 83 | : m_parent(parent), m_index(index) | - | ||||||||||||
| 84 | {} never executed: end of block | 0 | ||||||||||||
| 85 | - | |||||||||||||
| 86 | void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE { | - | ||||||||||||
| 87 | if (t == QAccessible::ActionInterface) {
| 0 | ||||||||||||
| 88 | return static_cast<QAccessibleActionInterface*>(this); never executed: return static_cast<QAccessibleActionInterface*>(this); | 0 | ||||||||||||
| 89 | } | - | ||||||||||||
| 90 | return 0; never executed: return 0; | 0 | ||||||||||||
| 91 | } | - | ||||||||||||
| 92 | - | |||||||||||||
| 93 | QObject *object() const Q_DECL_OVERRIDE { return 0; } never executed: return 0; | 0 | ||||||||||||
| 94 | QAccessible::Role role() const Q_DECL_OVERRIDE { return QAccessible::PageTab; } never executed: return QAccessible::PageTab; | 0 | ||||||||||||
| 95 | QAccessible::State state() const Q_DECL_OVERRIDE { | - | ||||||||||||
| 96 | if (!isValid()) {
| 0 | ||||||||||||
| 97 | QAccessible::State s; | - | ||||||||||||
| 98 | s.invalid = true; | - | ||||||||||||
| 99 | return s; never executed: return s; | 0 | ||||||||||||
| 100 | } | - | ||||||||||||
| 101 | return parent()->state(); never executed: return parent()->state(); | 0 | ||||||||||||
| 102 | } | - | ||||||||||||
| 103 | QRect rect() const Q_DECL_OVERRIDE { | - | ||||||||||||
| 104 | if (!isValid())
| 0 | ||||||||||||
| 105 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||
| 106 | - | |||||||||||||
| 107 | QPoint tp = m_parent->mapToGlobal(QPoint(0,0)); | - | ||||||||||||
| 108 | QRect rec = m_parent->tabRect(m_index); | - | ||||||||||||
| 109 | rec = QRect(tp.x() + rec.x(), tp.y() + rec.y(), rec.width(), rec.height()); | - | ||||||||||||
| 110 | return rec; never executed: return rec; | 0 | ||||||||||||
| 111 | } | - | ||||||||||||
| 112 | - | |||||||||||||
| 113 | bool isValid() const Q_DECL_OVERRIDE { return m_parent.data() && m_parent->count() > m_index; } never executed: return m_parent.data() && m_parent->count() > m_index; | 0 | ||||||||||||
| 114 | - | |||||||||||||
| 115 | QAccessibleInterface *childAt(int, int) const Q_DECL_OVERRIDE { return 0; } never executed: return 0; | 0 | ||||||||||||
| 116 | int childCount() const Q_DECL_OVERRIDE { return 0; } never executed: return 0; | 0 | ||||||||||||
| 117 | int indexOfChild(const QAccessibleInterface *) const Q_DECL_OVERRIDE { return -1; } never executed: return -1; | 0 | ||||||||||||
| 118 | - | |||||||||||||
| 119 | QString text(QAccessible::Text t) const Q_DECL_OVERRIDE | - | ||||||||||||
| 120 | { | - | ||||||||||||
| 121 | if (!isValid())
| 0 | ||||||||||||
| 122 | return QString(); never executed: return QString(); | 0 | ||||||||||||
| 123 | switch (t) { | - | ||||||||||||
| 124 | case QAccessible::Name: never executed: case QAccessible::Name: | 0 | ||||||||||||
| 125 | return qt_accStripAmp(m_parent->tabText(m_index)); never executed: return qt_accStripAmp(m_parent->tabText(m_index)); | 0 | ||||||||||||
| 126 | case QAccessible::Accelerator: never executed: case QAccessible::Accelerator: | 0 | ||||||||||||
| 127 | return qt_accHotKey(m_parent->tabText(m_index)); never executed: return qt_accHotKey(m_parent->tabText(m_index)); | 0 | ||||||||||||
| 128 | case QAccessible::Description: never executed: case QAccessible::Description: | 0 | ||||||||||||
| 129 | return m_parent->tabToolTip(m_index); never executed: return m_parent->tabToolTip(m_index); | 0 | ||||||||||||
| 130 | case QAccessible::Help: never executed: case QAccessible::Help: | 0 | ||||||||||||
| 131 | return m_parent->tabWhatsThis(m_index); never executed: return m_parent->tabWhatsThis(m_index); | 0 | ||||||||||||
| 132 | default: never executed: default: | 0 | ||||||||||||
| 133 | break; never executed: break; | 0 | ||||||||||||
| 134 | } | - | ||||||||||||
| 135 | return QString(); never executed: return QString(); | 0 | ||||||||||||
| 136 | } | - | ||||||||||||
| 137 | - | |||||||||||||
| 138 | void setText(QAccessible::Text, const QString &) Q_DECL_OVERRIDE {} | - | ||||||||||||
| 139 | - | |||||||||||||
| 140 | QAccessibleInterface *parent() const Q_DECL_OVERRIDE { | - | ||||||||||||
| 141 | return QAccessible::queryAccessibleInterface(m_parent.data()); never executed: return QAccessible::queryAccessibleInterface(m_parent.data()); | 0 | ||||||||||||
| 142 | } | - | ||||||||||||
| 143 | QAccessibleInterface *child(int) const Q_DECL_OVERRIDE { return 0; } never executed: return 0; | 0 | ||||||||||||
| 144 | - | |||||||||||||
| 145 | // action interface | - | ||||||||||||
| 146 | QStringList actionNames() const Q_DECL_OVERRIDE | - | ||||||||||||
| 147 | { | - | ||||||||||||
| 148 | return QStringList(pressAction()); never executed: return QStringList(pressAction()); | 0 | ||||||||||||
| 149 | } | - | ||||||||||||
| 150 | - | |||||||||||||
| 151 | void doAction(const QString &actionName) Q_DECL_OVERRIDE | - | ||||||||||||
| 152 | { | - | ||||||||||||
| 153 | if (isValid() && actionName == pressAction())
| 0 | ||||||||||||
| 154 | m_parent->setCurrentIndex(m_index); never executed: m_parent->setCurrentIndex(m_index); | 0 | ||||||||||||
| 155 | } never executed: end of block | 0 | ||||||||||||
| 156 | - | |||||||||||||
| 157 | QStringList keyBindingsForAction(const QString &) const Q_DECL_OVERRIDE | - | ||||||||||||
| 158 | { | - | ||||||||||||
| 159 | return QStringList(); never executed: return QStringList(); | 0 | ||||||||||||
| 160 | } | - | ||||||||||||
| 161 | - | |||||||||||||
| 162 | int index() const { return m_index; } never executed: return m_index; | 0 | ||||||||||||
| 163 | - | |||||||||||||
| 164 | private: | - | ||||||||||||
| 165 | QPointer<QTabBar> m_parent; | - | ||||||||||||
| 166 | int m_index; | - | ||||||||||||
| 167 | - | |||||||||||||
| 168 | }; | - | ||||||||||||
| 169 | - | |||||||||||||
| 170 | /*! | - | ||||||||||||
| 171 | Constructs a QAccessibleTabBar object for \a w. | - | ||||||||||||
| 172 | */ | - | ||||||||||||
| 173 | QAccessibleTabBar::QAccessibleTabBar(QWidget *w) | - | ||||||||||||
| 174 | : QAccessibleWidget(w, QAccessible::PageTabList) | - | ||||||||||||
| 175 | { | - | ||||||||||||
| 176 | Q_ASSERT(tabBar()); | - | ||||||||||||
| 177 | } never executed: end of block | 0 | ||||||||||||
| 178 | - | |||||||||||||
| 179 | QAccessibleTabBar::~QAccessibleTabBar() | - | ||||||||||||
| 180 | { | - | ||||||||||||
| 181 | foreach (QAccessible::Id id, m_childInterfaces) | - | ||||||||||||
| 182 | QAccessible::deleteAccessibleInterface(id); never executed: QAccessible::deleteAccessibleInterface(id); | 0 | ||||||||||||
| 183 | } never executed: end of block | 0 | ||||||||||||
| 184 | - | |||||||||||||
| 185 | /*! Returns the QTabBar. */ | - | ||||||||||||
| 186 | QTabBar *QAccessibleTabBar::tabBar() const | - | ||||||||||||
| 187 | { | - | ||||||||||||
| 188 | return qobject_cast<QTabBar*>(object()); never executed: return qobject_cast<QTabBar*>(object()); | 0 | ||||||||||||
| 189 | } | - | ||||||||||||
| 190 | - | |||||||||||||
| 191 | QAccessibleInterface* QAccessibleTabBar::child(int index) const | - | ||||||||||||
| 192 | { | - | ||||||||||||
| 193 | if (QAccessible::Id id = m_childInterfaces.value(index))
| 0 | ||||||||||||
| 194 | return QAccessible::accessibleInterface(id); never executed: return QAccessible::accessibleInterface(id); | 0 | ||||||||||||
| 195 | - | |||||||||||||
| 196 | // first the tabs, then 2 buttons | - | ||||||||||||
| 197 | if (index < tabBar()->count()) {
| 0 | ||||||||||||
| 198 | QAccessibleTabButton *button = new QAccessibleTabButton(tabBar(), index); | - | ||||||||||||
| 199 | QAccessible::registerAccessibleInterface(button); | - | ||||||||||||
| 200 | m_childInterfaces.insert(index, QAccessible::uniqueId(button)); | - | ||||||||||||
| 201 | return button; never executed: return button; | 0 | ||||||||||||
| 202 | } else if (index >= tabBar()->count()) {
| 0 | ||||||||||||
| 203 | // left button | - | ||||||||||||
| 204 | if (index - tabBar()->count() == 0) {
| 0 | ||||||||||||
| 205 | return QAccessible::queryAccessibleInterface(tabBar()->d_func()->leftB); never executed: return QAccessible::queryAccessibleInterface(tabBar()->d_func()->leftB); | 0 | ||||||||||||
| 206 | } | - | ||||||||||||
| 207 | // right button | - | ||||||||||||
| 208 | if (index - tabBar()->count() == 1) {
| 0 | ||||||||||||
| 209 | return QAccessible::queryAccessibleInterface(tabBar()->d_func()->rightB); never executed: return QAccessible::queryAccessibleInterface(tabBar()->d_func()->rightB); | 0 | ||||||||||||
| 210 | } | - | ||||||||||||
| 211 | } never executed: end of block | 0 | ||||||||||||
| 212 | return 0; never executed: return 0; | 0 | ||||||||||||
| 213 | } | - | ||||||||||||
| 214 | - | |||||||||||||
| 215 | int QAccessibleTabBar::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||
| 216 | { | - | ||||||||||||
| 217 | if (child->object() && child->object() == tabBar()->d_func()->leftB)
| 0 | ||||||||||||
| 218 | return tabBar()->count(); never executed: return tabBar()->count(); | 0 | ||||||||||||
| 219 | if (child->object() && child->object() == tabBar()->d_func()->rightB)
| 0 | ||||||||||||
| 220 | return tabBar()->count() + 1; never executed: return tabBar()->count() + 1; | 0 | ||||||||||||
| 221 | if (child->role() == QAccessible::PageTab) {
| 0 | ||||||||||||
| 222 | QAccessibleInterface *parent = child->parent(); | - | ||||||||||||
| 223 | if (parent == this) {
| 0 | ||||||||||||
| 224 | const QAccessibleTabButton *tabButton = static_cast<const QAccessibleTabButton *>(child); | - | ||||||||||||
| 225 | return tabButton->index(); never executed: return tabButton->index(); | 0 | ||||||||||||
| 226 | } | - | ||||||||||||
| 227 | } never executed: end of block | 0 | ||||||||||||
| 228 | return -1; never executed: return -1; | 0 | ||||||||||||
| 229 | } | - | ||||||||||||
| 230 | - | |||||||||||||
| 231 | int QAccessibleTabBar::childCount() const | - | ||||||||||||
| 232 | { | - | ||||||||||||
| 233 | // tabs + scroll buttons | - | ||||||||||||
| 234 | return tabBar()->count() + 2; never executed: return tabBar()->count() + 2; | 0 | ||||||||||||
| 235 | } | - | ||||||||||||
| 236 | - | |||||||||||||
| 237 | QString QAccessibleTabBar::text(QAccessible::Text t) const | - | ||||||||||||
| 238 | { | - | ||||||||||||
| 239 | if (t == QAccessible::Name) {
| 0 | ||||||||||||
| 240 | return qt_accStripAmp(tabBar()->tabText(tabBar()->currentIndex())); never executed: return qt_accStripAmp(tabBar()->tabText(tabBar()->currentIndex())); | 0 | ||||||||||||
| 241 | } else if (t == QAccessible::Accelerator) {
| 0 | ||||||||||||
| 242 | return qt_accHotKey(tabBar()->tabText(tabBar()->currentIndex())); never executed: return qt_accHotKey(tabBar()->tabText(tabBar()->currentIndex())); | 0 | ||||||||||||
| 243 | } | - | ||||||||||||
| 244 | return QString(); never executed: return QString(); | 0 | ||||||||||||
| 245 | } | - | ||||||||||||
| 246 | - | |||||||||||||
| 247 | #endif // QT_NO_TABBAR | - | ||||||||||||
| 248 | - | |||||||||||||
| 249 | #ifndef QT_NO_COMBOBOX | - | ||||||||||||
| 250 | /*! | - | ||||||||||||
| 251 | \class QAccessibleComboBox | - | ||||||||||||
| 252 | \brief The QAccessibleComboBox class implements the QAccessibleInterface for editable and read-only combo boxes. | - | ||||||||||||
| 253 | \internal | - | ||||||||||||
| 254 | - | |||||||||||||
| 255 | \ingroup accessibility | - | ||||||||||||
| 256 | */ | - | ||||||||||||
| 257 | - | |||||||||||||
| 258 | /*! | - | ||||||||||||
| 259 | Constructs a QAccessibleComboBox object for \a w. | - | ||||||||||||
| 260 | */ | - | ||||||||||||
| 261 | QAccessibleComboBox::QAccessibleComboBox(QWidget *w) | - | ||||||||||||
| 262 | : QAccessibleWidget(w, QAccessible::ComboBox) | - | ||||||||||||
| 263 | { | - | ||||||||||||
| 264 | Q_ASSERT(comboBox()); | - | ||||||||||||
| 265 | } never executed: end of block | 0 | ||||||||||||
| 266 | - | |||||||||||||
| 267 | /*! | - | ||||||||||||
| 268 | Returns the combobox. | - | ||||||||||||
| 269 | */ | - | ||||||||||||
| 270 | QComboBox *QAccessibleComboBox::comboBox() const | - | ||||||||||||
| 271 | { | - | ||||||||||||
| 272 | return qobject_cast<QComboBox*>(object()); never executed: return qobject_cast<QComboBox*>(object()); | 0 | ||||||||||||
| 273 | } | - | ||||||||||||
| 274 | - | |||||||||||||
| 275 | QAccessibleInterface *QAccessibleComboBox::child(int index) const | - | ||||||||||||
| 276 | { | - | ||||||||||||
| 277 | if (index == 0) {
| 0 | ||||||||||||
| 278 | QAbstractItemView *view = comboBox()->view(); | - | ||||||||||||
| 279 | //QWidget *parent = view ? view->parentWidget() : 0; | - | ||||||||||||
| 280 | return QAccessible::queryAccessibleInterface(view); never executed: return QAccessible::queryAccessibleInterface(view); | 0 | ||||||||||||
| 281 | } else if (index == 1 && comboBox()->isEditable()) {
| 0 | ||||||||||||
| 282 | return QAccessible::queryAccessibleInterface(comboBox()->lineEdit()); never executed: return QAccessible::queryAccessibleInterface(comboBox()->lineEdit()); | 0 | ||||||||||||
| 283 | } | - | ||||||||||||
| 284 | return 0; never executed: return 0; | 0 | ||||||||||||
| 285 | } | - | ||||||||||||
| 286 | - | |||||||||||||
| 287 | int QAccessibleComboBox::childCount() const | - | ||||||||||||
| 288 | { | - | ||||||||||||
| 289 | // list and text edit | - | ||||||||||||
| 290 | return comboBox()->isEditable() ? 2 : 1; never executed: return comboBox()->isEditable() ? 2 : 1; | 0 | ||||||||||||
| 291 | } | - | ||||||||||||
| 292 | - | |||||||||||||
| 293 | QAccessibleInterface *QAccessibleComboBox::childAt(int x, int y) const | - | ||||||||||||
| 294 | { | - | ||||||||||||
| 295 | if (comboBox()->isEditable() && comboBox()->lineEdit()->rect().contains(x, y))
| 0 | ||||||||||||
| 296 | return child(1); never executed: return child(1); | 0 | ||||||||||||
| 297 | return 0; never executed: return 0; | 0 | ||||||||||||
| 298 | } | - | ||||||||||||
| 299 | - | |||||||||||||
| 300 | int QAccessibleComboBox::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||
| 301 | { | - | ||||||||||||
| 302 | if (comboBox()->view() == child->object())
| 0 | ||||||||||||
| 303 | return 0; never executed: return 0; | 0 | ||||||||||||
| 304 | if (comboBox()->isEditable() && comboBox()->lineEdit() == child->object())
| 0 | ||||||||||||
| 305 | return 1; never executed: return 1; | 0 | ||||||||||||
| 306 | return -1; never executed: return -1; | 0 | ||||||||||||
| 307 | } | - | ||||||||||||
| 308 | - | |||||||||||||
| 309 | /*! \reimp */ | - | ||||||||||||
| 310 | QString QAccessibleComboBox::text(QAccessible::Text t) const | - | ||||||||||||
| 311 | { | - | ||||||||||||
| 312 | QString str; | - | ||||||||||||
| 313 | - | |||||||||||||
| 314 | switch (t) { | - | ||||||||||||
| 315 | case QAccessible::Name: never executed: case QAccessible::Name: | 0 | ||||||||||||
| 316 | #ifndef Q_OS_UNIX // on Linux we use relations for this, name is text (fall through to Value) | - | ||||||||||||
| 317 | str = QAccessibleWidget::text(t); | - | ||||||||||||
| 318 | break; | - | ||||||||||||
| 319 | #endif | - | ||||||||||||
| 320 | case QAccessible::Value: never executed: case QAccessible::Value: | 0 | ||||||||||||
| 321 | if (comboBox()->isEditable())
| 0 | ||||||||||||
| 322 | str = comboBox()->lineEdit()->text(); never executed: str = comboBox()->lineEdit()->text(); | 0 | ||||||||||||
| 323 | else | - | ||||||||||||
| 324 | str = comboBox()->currentText(); never executed: str = comboBox()->currentText(); | 0 | ||||||||||||
| 325 | break; never executed: break; | 0 | ||||||||||||
| 326 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||
| 327 | case QAccessible::Accelerator: never executed: case QAccessible::Accelerator: | 0 | ||||||||||||
| 328 | str = QKeySequence(Qt::Key_Down).toString(QKeySequence::NativeText); | - | ||||||||||||
| 329 | break; never executed: break; | 0 | ||||||||||||
| 330 | #endif | - | ||||||||||||
| 331 | default: never executed: default: | 0 | ||||||||||||
| 332 | break; never executed: break; | 0 | ||||||||||||
| 333 | } | - | ||||||||||||
| 334 | if (str.isEmpty())
| 0 | ||||||||||||
| 335 | str = QAccessibleWidget::text(t); never executed: str = QAccessibleWidget::text(t); | 0 | ||||||||||||
| 336 | return str; never executed: return str; | 0 | ||||||||||||
| 337 | } | - | ||||||||||||
| 338 | - | |||||||||||||
| 339 | QStringList QAccessibleComboBox::actionNames() const | - | ||||||||||||
| 340 | { | - | ||||||||||||
| 341 | return QStringList() << showMenuAction() << pressAction(); never executed: return QStringList() << showMenuAction() << pressAction(); | 0 | ||||||||||||
| 342 | } | - | ||||||||||||
| 343 | - | |||||||||||||
| 344 | QString QAccessibleComboBox::localizedActionDescription(const QString &actionName) const | - | ||||||||||||
| 345 | { | - | ||||||||||||
| 346 | if (actionName == showMenuAction() || actionName == pressAction())
| 0 | ||||||||||||
| 347 | return QComboBox::tr("Open the combo box selection popup"); never executed: return QComboBox::tr("Open the combo box selection popup"); | 0 | ||||||||||||
| 348 | return QString(); never executed: return QString(); | 0 | ||||||||||||
| 349 | } | - | ||||||||||||
| 350 | - | |||||||||||||
| 351 | void QAccessibleComboBox::doAction(const QString &actionName) | - | ||||||||||||
| 352 | { | - | ||||||||||||
| 353 | if (actionName == showMenuAction() || actionName == pressAction()) {
| 0 | ||||||||||||
| 354 | if (comboBox()->view()->isVisible()) {
| 0 | ||||||||||||
| 355 | comboBox()->hidePopup(); | - | ||||||||||||
| 356 | } else { never executed: end of block | 0 | ||||||||||||
| 357 | comboBox()->showPopup(); | - | ||||||||||||
| 358 | } never executed: end of block | 0 | ||||||||||||
| 359 | } | - | ||||||||||||
| 360 | } never executed: end of block | 0 | ||||||||||||
| 361 | - | |||||||||||||
| 362 | QStringList QAccessibleComboBox::keyBindingsForAction(const QString &/*actionName*/) const | - | ||||||||||||
| 363 | { | - | ||||||||||||
| 364 | return QStringList(); never executed: return QStringList(); | 0 | ||||||||||||
| 365 | } | - | ||||||||||||
| 366 | - | |||||||||||||
| 367 | #endif // QT_NO_COMBOBOX | - | ||||||||||||
| 368 | - | |||||||||||||
| 369 | #ifndef QT_NO_SCROLLAREA | - | ||||||||||||
| 370 | // ======================= QAccessibleAbstractScrollArea ======================= | - | ||||||||||||
| 371 | QAccessibleAbstractScrollArea::QAccessibleAbstractScrollArea(QWidget *widget) | - | ||||||||||||
| 372 | : QAccessibleWidget(widget, QAccessible::Client) | - | ||||||||||||
| 373 | { | - | ||||||||||||
| 374 | Q_ASSERT(qobject_cast<QAbstractScrollArea *>(widget)); | - | ||||||||||||
| 375 | } never executed: end of block | 0 | ||||||||||||
| 376 | - | |||||||||||||
| 377 | QAccessibleInterface *QAccessibleAbstractScrollArea::child(int index) const | - | ||||||||||||
| 378 | { | - | ||||||||||||
| 379 | return QAccessible::queryAccessibleInterface(accessibleChildren().at(index)); never executed: return QAccessible::queryAccessibleInterface(accessibleChildren().at(index)); | 0 | ||||||||||||
| 380 | } | - | ||||||||||||
| 381 | - | |||||||||||||
| 382 | int QAccessibleAbstractScrollArea::childCount() const | - | ||||||||||||
| 383 | { | - | ||||||||||||
| 384 | return accessibleChildren().count(); never executed: return accessibleChildren().count(); | 0 | ||||||||||||
| 385 | } | - | ||||||||||||
| 386 | - | |||||||||||||
| 387 | int QAccessibleAbstractScrollArea::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||
| 388 | { | - | ||||||||||||
| 389 | if (!child || !child->object())
| 0 | ||||||||||||
| 390 | return -1; never executed: return -1; | 0 | ||||||||||||
| 391 | return accessibleChildren().indexOf(qobject_cast<QWidget *>(child->object())); never executed: return accessibleChildren().indexOf(qobject_cast<QWidget *>(child->object())); | 0 | ||||||||||||
| 392 | } | - | ||||||||||||
| 393 | - | |||||||||||||
| 394 | bool QAccessibleAbstractScrollArea::isValid() const | - | ||||||||||||
| 395 | { | - | ||||||||||||
| 396 | return (QAccessibleWidget::isValid() && abstractScrollArea() && abstractScrollArea()->viewport()); never executed: return (QAccessibleWidget::isValid() && abstractScrollArea() && abstractScrollArea()->viewport()); | 0 | ||||||||||||
| 397 | } | - | ||||||||||||
| 398 | - | |||||||||||||
| 399 | QAccessibleInterface *QAccessibleAbstractScrollArea::childAt(int x, int y) const | - | ||||||||||||
| 400 | { | - | ||||||||||||
| 401 | if (!abstractScrollArea()->isVisible())
| 0 | ||||||||||||
| 402 | return 0; never executed: return 0; | 0 | ||||||||||||
| 403 | - | |||||||||||||
| 404 | for (int i = 0; i < childCount(); ++i) {
| 0 | ||||||||||||
| 405 | QPoint wpos = accessibleChildren().at(i)->mapToGlobal(QPoint(0, 0)); | - | ||||||||||||
| 406 | QRect rect = QRect(wpos, accessibleChildren().at(i)->size()); | - | ||||||||||||
| 407 | if (rect.contains(x, y))
| 0 | ||||||||||||
| 408 | return child(i); never executed: return child(i); | 0 | ||||||||||||
| 409 | } never executed: end of block | 0 | ||||||||||||
| 410 | return 0; never executed: return 0; | 0 | ||||||||||||
| 411 | } | - | ||||||||||||
| 412 | - | |||||||||||||
| 413 | QAbstractScrollArea *QAccessibleAbstractScrollArea::abstractScrollArea() const | - | ||||||||||||
| 414 | { | - | ||||||||||||
| 415 | return static_cast<QAbstractScrollArea *>(object()); never executed: return static_cast<QAbstractScrollArea *>(object()); | 0 | ||||||||||||
| 416 | } | - | ||||||||||||
| 417 | - | |||||||||||||
| 418 | QWidgetList QAccessibleAbstractScrollArea::accessibleChildren() const | - | ||||||||||||
| 419 | { | - | ||||||||||||
| 420 | QWidgetList children; | - | ||||||||||||
| 421 | - | |||||||||||||
| 422 | // Viewport. | - | ||||||||||||
| 423 | QWidget * viewport = abstractScrollArea()->viewport(); | - | ||||||||||||
| 424 | if (viewport)
| 0 | ||||||||||||
| 425 | children.append(viewport); never executed: children.append(viewport); | 0 | ||||||||||||
| 426 | - | |||||||||||||
| 427 | // Horizontal scrollBar container. | - | ||||||||||||
| 428 | QScrollBar *horizontalScrollBar = abstractScrollArea()->horizontalScrollBar(); | - | ||||||||||||
| 429 | if (horizontalScrollBar && horizontalScrollBar->isVisible()) {
| 0 | ||||||||||||
| 430 | children.append(horizontalScrollBar->parentWidget()); | - | ||||||||||||
| 431 | } never executed: end of block | 0 | ||||||||||||
| 432 | - | |||||||||||||
| 433 | // Vertical scrollBar container. | - | ||||||||||||
| 434 | QScrollBar *verticalScrollBar = abstractScrollArea()->verticalScrollBar(); | - | ||||||||||||
| 435 | if (verticalScrollBar && verticalScrollBar->isVisible()) {
| 0 | ||||||||||||
| 436 | children.append(verticalScrollBar->parentWidget()); | - | ||||||||||||
| 437 | } never executed: end of block | 0 | ||||||||||||
| 438 | - | |||||||||||||
| 439 | // CornerWidget. | - | ||||||||||||
| 440 | QWidget *cornerWidget = abstractScrollArea()->cornerWidget(); | - | ||||||||||||
| 441 | if (cornerWidget && cornerWidget->isVisible())
| 0 | ||||||||||||
| 442 | children.append(cornerWidget); never executed: children.append(cornerWidget); | 0 | ||||||||||||
| 443 | - | |||||||||||||
| 444 | return children; never executed: return children; | 0 | ||||||||||||
| 445 | } | - | ||||||||||||
| 446 | - | |||||||||||||
| 447 | QAccessibleAbstractScrollArea::AbstractScrollAreaElement | - | ||||||||||||
| 448 | QAccessibleAbstractScrollArea::elementType(QWidget *widget) const | - | ||||||||||||
| 449 | { | - | ||||||||||||
| 450 | if (!widget)
| 0 | ||||||||||||
| 451 | return Undefined; never executed: return Undefined; | 0 | ||||||||||||
| 452 | - | |||||||||||||
| 453 | if (widget == abstractScrollArea())
| 0 | ||||||||||||
| 454 | return Self; never executed: return Self; | 0 | ||||||||||||
| 455 | if (widget == abstractScrollArea()->viewport())
| 0 | ||||||||||||
| 456 | return Viewport; never executed: return Viewport; | 0 | ||||||||||||
| 457 | if (widget->objectName() == QLatin1String("qt_scrollarea_hcontainer"))
| 0 | ||||||||||||
| 458 | return HorizontalContainer; never executed: return HorizontalContainer; | 0 | ||||||||||||
| 459 | if (widget->objectName() == QLatin1String("qt_scrollarea_vcontainer"))
| 0 | ||||||||||||
| 460 | return VerticalContainer; never executed: return VerticalContainer; | 0 | ||||||||||||
| 461 | if (widget == abstractScrollArea()->cornerWidget())
| 0 | ||||||||||||
| 462 | return CornerWidget; never executed: return CornerWidget; | 0 | ||||||||||||
| 463 | - | |||||||||||||
| 464 | return Undefined; never executed: return Undefined; | 0 | ||||||||||||
| 465 | } | - | ||||||||||||
| 466 | - | |||||||||||||
| 467 | bool QAccessibleAbstractScrollArea::isLeftToRight() const | - | ||||||||||||
| 468 | { | - | ||||||||||||
| 469 | return abstractScrollArea()->isLeftToRight(); never executed: return abstractScrollArea()->isLeftToRight(); | 0 | ||||||||||||
| 470 | } | - | ||||||||||||
| 471 | - | |||||||||||||
| 472 | // ======================= QAccessibleScrollArea =========================== | - | ||||||||||||
| 473 | QAccessibleScrollArea::QAccessibleScrollArea(QWidget *widget) | - | ||||||||||||
| 474 | : QAccessibleAbstractScrollArea(widget) | - | ||||||||||||
| 475 | { | - | ||||||||||||
| 476 | Q_ASSERT(qobject_cast<QScrollArea *>(widget)); | - | ||||||||||||
| 477 | } never executed: end of block | 0 | ||||||||||||
| 478 | #endif // QT_NO_SCROLLAREA | - | ||||||||||||
| 479 | - | |||||||||||||
| 480 | QT_END_NAMESPACE | - | ||||||||||||
| 481 | - | |||||||||||||
| 482 | #endif // QT_NO_ACCESSIBILITY | - | ||||||||||||
| Source code | Switch to Preprocessed file |