| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/accessible/qaccessiblewidgets.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 "qaccessiblewidgets_p.h" | - | ||||||||||||||||||
| 41 | #include "qabstracttextdocumentlayout.h" | - | ||||||||||||||||||
| 42 | #include "qapplication.h" | - | ||||||||||||||||||
| 43 | #include "qclipboard.h" | - | ||||||||||||||||||
| 44 | #include "qtextedit.h" | - | ||||||||||||||||||
| 45 | #include "private/qtextedit_p.h" | - | ||||||||||||||||||
| 46 | #include "qtextdocument.h" | - | ||||||||||||||||||
| 47 | #include "qtextobject.h" | - | ||||||||||||||||||
| 48 | #include "qplaintextedit.h" | - | ||||||||||||||||||
| 49 | #include "qtextboundaryfinder.h" | - | ||||||||||||||||||
| 50 | #include "qscrollbar.h" | - | ||||||||||||||||||
| 51 | #include "qdebug.h" | - | ||||||||||||||||||
| 52 | #include <QApplication> | - | ||||||||||||||||||
| 53 | #include <QStackedWidget> | - | ||||||||||||||||||
| 54 | #include <QToolBox> | - | ||||||||||||||||||
| 55 | #include <QMdiArea> | - | ||||||||||||||||||
| 56 | #include <QMdiSubWindow> | - | ||||||||||||||||||
| 57 | #include <QDialogButtonBox> | - | ||||||||||||||||||
| 58 | #include <limits.h> | - | ||||||||||||||||||
| 59 | #include <QRubberBand> | - | ||||||||||||||||||
| 60 | #include <QTextBrowser> | - | ||||||||||||||||||
| 61 | #include <QCalendarWidget> | - | ||||||||||||||||||
| 62 | #include <QAbstractItemView> | - | ||||||||||||||||||
| 63 | #include <QDockWidget> | - | ||||||||||||||||||
| 64 | #include <QMainWindow> | - | ||||||||||||||||||
| 65 | #include <QAbstractButton> | - | ||||||||||||||||||
| 66 | #include <private/qdockwidget_p.h> | - | ||||||||||||||||||
| 67 | #include <QFocusFrame> | - | ||||||||||||||||||
| 68 | - | |||||||||||||||||||
| 69 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | QString qt_accStripAmp(const QString &text); | - | ||||||||||||||||||
| 74 | QString qt_accHotKey(const QString &text); | - | ||||||||||||||||||
| 75 | - | |||||||||||||||||||
| 76 | QList<QWidget*> childWidgets(const QWidget *widget) | - | ||||||||||||||||||
| 77 | { | - | ||||||||||||||||||
| 78 | if (widget == 0)
| 0 | ||||||||||||||||||
| 79 | return QList<QWidget*>(); never executed: return QList<QWidget*>(); | 0 | ||||||||||||||||||
| 80 | QList<QWidget*> widgets; | - | ||||||||||||||||||
| 81 | for (QObject *o : widget->children()) { | - | ||||||||||||||||||
| 82 | QWidget *w = qobject_cast<QWidget *>(o); | - | ||||||||||||||||||
| 83 | if (!w)
| 0 | ||||||||||||||||||
| 84 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 85 | QString objectName = w->objectName(); | - | ||||||||||||||||||
| 86 | if (!w->isWindow()
| 0 | ||||||||||||||||||
| 87 | && !qobject_cast<QFocusFrame*>(w)
| 0 | ||||||||||||||||||
| 88 | && !qobject_cast<QMenu*>(w)
| 0 | ||||||||||||||||||
| 89 | && objectName != QLatin1String("qt_rubberband")
| 0 | ||||||||||||||||||
| 90 | && objectName != QLatin1String("qt_qmainwindow_extended_splitter")) {
| 0 | ||||||||||||||||||
| 91 | widgets.append(w); | - | ||||||||||||||||||
| 92 | } never executed: end of block | 0 | ||||||||||||||||||
| 93 | } never executed: end of block | 0 | ||||||||||||||||||
| 94 | return widgets; never executed: return widgets; | 0 | ||||||||||||||||||
| 95 | } | - | ||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | #if !defined(QT_NO_TEXTEDIT) && !defined(QT_NO_CURSOR) | - | ||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | QAccessiblePlainTextEdit::QAccessiblePlainTextEdit(QWidget* o) | - | ||||||||||||||||||
| 100 | :QAccessibleTextWidget(o) | - | ||||||||||||||||||
| 101 | { | - | ||||||||||||||||||
| 102 | Q_ASSERT(widget()->inherits("QPlainTextEdit")); | - | ||||||||||||||||||
| 103 | } never executed: end of block | 0 | ||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | QPlainTextEdit* QAccessiblePlainTextEdit::plainTextEdit() const | - | ||||||||||||||||||
| 106 | { | - | ||||||||||||||||||
| 107 | return static_cast<QPlainTextEdit *>(widget()); never executed: return static_cast<QPlainTextEdit *>(widget()); | 0 | ||||||||||||||||||
| 108 | } | - | ||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | QString QAccessiblePlainTextEdit::text(QAccessible::Text t) const | - | ||||||||||||||||||
| 111 | { | - | ||||||||||||||||||
| 112 | if (t == QAccessible::Value)
| 0 | ||||||||||||||||||
| 113 | return plainTextEdit()->toPlainText(); never executed: return plainTextEdit()->toPlainText(); | 0 | ||||||||||||||||||
| 114 | - | |||||||||||||||||||
| 115 | return QAccessibleWidget::text(t); never executed: return QAccessibleWidget::text(t); | 0 | ||||||||||||||||||
| 116 | } | - | ||||||||||||||||||
| 117 | - | |||||||||||||||||||
| 118 | void QAccessiblePlainTextEdit::setText(QAccessible::Text t, const QString &text) | - | ||||||||||||||||||
| 119 | { | - | ||||||||||||||||||
| 120 | if (t != QAccessible::Value) {
| 0 | ||||||||||||||||||
| 121 | QAccessibleWidget::setText(t, text); | - | ||||||||||||||||||
| 122 | return; never executed: return; | 0 | ||||||||||||||||||
| 123 | } | - | ||||||||||||||||||
| 124 | if (plainTextEdit()->isReadOnly())
| 0 | ||||||||||||||||||
| 125 | return; never executed: return; | 0 | ||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | plainTextEdit()->setPlainText(text); | - | ||||||||||||||||||
| 128 | } never executed: end of block | 0 | ||||||||||||||||||
| 129 | - | |||||||||||||||||||
| 130 | QAccessible::State QAccessiblePlainTextEdit::state() const | - | ||||||||||||||||||
| 131 | { | - | ||||||||||||||||||
| 132 | QAccessible::State st = QAccessibleTextWidget::state(); | - | ||||||||||||||||||
| 133 | if (plainTextEdit()->isReadOnly())
| 0 | ||||||||||||||||||
| 134 | st.readOnly = true; never executed: st.readOnly = true; | 0 | ||||||||||||||||||
| 135 | else | - | ||||||||||||||||||
| 136 | st.editable = true; never executed: st.editable = true; | 0 | ||||||||||||||||||
| 137 | return st; never executed: return st; | 0 | ||||||||||||||||||
| 138 | } | - | ||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | void *QAccessiblePlainTextEdit::interface_cast(QAccessible::InterfaceType t) | - | ||||||||||||||||||
| 141 | { | - | ||||||||||||||||||
| 142 | if (t == QAccessible::TextInterface)
| 0 | ||||||||||||||||||
| 143 | return static_cast<QAccessibleTextInterface*>(this); never executed: return static_cast<QAccessibleTextInterface*>(this); | 0 | ||||||||||||||||||
| 144 | else if (t == QAccessible::EditableTextInterface)
| 0 | ||||||||||||||||||
| 145 | return static_cast<QAccessibleEditableTextInterface*>(this); never executed: return static_cast<QAccessibleEditableTextInterface*>(this); | 0 | ||||||||||||||||||
| 146 | return QAccessibleWidget::interface_cast(t); never executed: return QAccessibleWidget::interface_cast(t); | 0 | ||||||||||||||||||
| 147 | } | - | ||||||||||||||||||
| 148 | - | |||||||||||||||||||
| 149 | QPoint QAccessiblePlainTextEdit::scrollBarPosition() const | - | ||||||||||||||||||
| 150 | { | - | ||||||||||||||||||
| 151 | QPoint result; | - | ||||||||||||||||||
| 152 | result.setX(plainTextEdit()->horizontalScrollBar() ? plainTextEdit()->horizontalScrollBar()->sliderPosition() : 0); | - | ||||||||||||||||||
| 153 | result.setY(plainTextEdit()->verticalScrollBar() ? plainTextEdit()->verticalScrollBar()->sliderPosition() : 0); | - | ||||||||||||||||||
| 154 | return result; never executed: return result; | 0 | ||||||||||||||||||
| 155 | } | - | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | QTextCursor QAccessiblePlainTextEdit::textCursor() const | - | ||||||||||||||||||
| 158 | { | - | ||||||||||||||||||
| 159 | return plainTextEdit()->textCursor(); never executed: return plainTextEdit()->textCursor(); | 0 | ||||||||||||||||||
| 160 | } | - | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | void QAccessiblePlainTextEdit::setTextCursor(const QTextCursor &textCursor) | - | ||||||||||||||||||
| 163 | { | - | ||||||||||||||||||
| 164 | plainTextEdit()->setTextCursor(textCursor); | - | ||||||||||||||||||
| 165 | } never executed: end of block | 0 | ||||||||||||||||||
| 166 | - | |||||||||||||||||||
| 167 | QTextDocument* QAccessiblePlainTextEdit::textDocument() const | - | ||||||||||||||||||
| 168 | { | - | ||||||||||||||||||
| 169 | return plainTextEdit()->document(); never executed: return plainTextEdit()->document(); | 0 | ||||||||||||||||||
| 170 | } | - | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | QWidget* QAccessiblePlainTextEdit::viewport() const | - | ||||||||||||||||||
| 173 | { | - | ||||||||||||||||||
| 174 | return plainTextEdit()->viewport(); never executed: return plainTextEdit()->viewport(); | 0 | ||||||||||||||||||
| 175 | } | - | ||||||||||||||||||
| 176 | - | |||||||||||||||||||
| 177 | void QAccessiblePlainTextEdit::scrollToSubstring(int startIndex, int endIndex) | - | ||||||||||||||||||
| 178 | { | - | ||||||||||||||||||
| 179 | //TODO: Not implemented | - | ||||||||||||||||||
| 180 | Q_UNUSED(startIndex); | - | ||||||||||||||||||
| 181 | Q_UNUSED(endIndex); | - | ||||||||||||||||||
| 182 | } never executed: end of block | 0 | ||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | - | |||||||||||||||||||
| 185 | /*! | - | ||||||||||||||||||
| 186 | \class QAccessibleTextEdit | - | ||||||||||||||||||
| 187 | \brief The QAccessibleTextEdit class implements the QAccessibleInterface for richtext editors. | - | ||||||||||||||||||
| 188 | \internal | - | ||||||||||||||||||
| 189 | */ | - | ||||||||||||||||||
| 190 | - | |||||||||||||||||||
| 191 | /*! | - | ||||||||||||||||||
| 192 | \fn QAccessibleTextEdit::QAccessibleTextEdit(QWidget *widget) | - | ||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | Constructs a QAccessibleTextEdit object for a \a widget. | - | ||||||||||||||||||
| 195 | */ | - | ||||||||||||||||||
| 196 | QAccessibleTextEdit::QAccessibleTextEdit(QWidget *o) | - | ||||||||||||||||||
| 197 | : QAccessibleTextWidget(o, QAccessible::EditableText) | - | ||||||||||||||||||
| 198 | { | - | ||||||||||||||||||
| 199 | Q_ASSERT(widget()->inherits("QTextEdit")); | - | ||||||||||||||||||
| 200 | } never executed: end of block | 0 | ||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | /*! Returns the text edit. */ | - | ||||||||||||||||||
| 203 | QTextEdit *QAccessibleTextEdit::textEdit() const | - | ||||||||||||||||||
| 204 | { | - | ||||||||||||||||||
| 205 | return static_cast<QTextEdit *>(widget()); never executed: return static_cast<QTextEdit *>(widget()); | 0 | ||||||||||||||||||
| 206 | } | - | ||||||||||||||||||
| 207 | - | |||||||||||||||||||
| 208 | QTextCursor QAccessibleTextEdit::textCursor() const | - | ||||||||||||||||||
| 209 | { | - | ||||||||||||||||||
| 210 | return textEdit()->textCursor(); never executed: return textEdit()->textCursor(); | 0 | ||||||||||||||||||
| 211 | } | - | ||||||||||||||||||
| 212 | - | |||||||||||||||||||
| 213 | QTextDocument *QAccessibleTextEdit::textDocument() const | - | ||||||||||||||||||
| 214 | { | - | ||||||||||||||||||
| 215 | return textEdit()->document(); never executed: return textEdit()->document(); | 0 | ||||||||||||||||||
| 216 | } | - | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | void QAccessibleTextEdit::setTextCursor(const QTextCursor &textCursor) | - | ||||||||||||||||||
| 219 | { | - | ||||||||||||||||||
| 220 | textEdit()->setTextCursor(textCursor); | - | ||||||||||||||||||
| 221 | } never executed: end of block | 0 | ||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | QWidget *QAccessibleTextEdit::viewport() const | - | ||||||||||||||||||
| 224 | { | - | ||||||||||||||||||
| 225 | return textEdit()->viewport(); never executed: return textEdit()->viewport(); | 0 | ||||||||||||||||||
| 226 | } | - | ||||||||||||||||||
| 227 | - | |||||||||||||||||||
| 228 | QPoint QAccessibleTextEdit::scrollBarPosition() const | - | ||||||||||||||||||
| 229 | { | - | ||||||||||||||||||
| 230 | QPoint result; | - | ||||||||||||||||||
| 231 | result.setX(textEdit()->horizontalScrollBar() ? textEdit()->horizontalScrollBar()->sliderPosition() : 0); | - | ||||||||||||||||||
| 232 | result.setY(textEdit()->verticalScrollBar() ? textEdit()->verticalScrollBar()->sliderPosition() : 0); | - | ||||||||||||||||||
| 233 | return result; never executed: return result; | 0 | ||||||||||||||||||
| 234 | } | - | ||||||||||||||||||
| 235 | - | |||||||||||||||||||
| 236 | QString QAccessibleTextEdit::text(QAccessible::Text t) const | - | ||||||||||||||||||
| 237 | { | - | ||||||||||||||||||
| 238 | if (t == QAccessible::Value)
| 0 | ||||||||||||||||||
| 239 | return textEdit()->toPlainText(); never executed: return textEdit()->toPlainText(); | 0 | ||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | return QAccessibleWidget::text(t); never executed: return QAccessibleWidget::text(t); | 0 | ||||||||||||||||||
| 242 | } | - | ||||||||||||||||||
| 243 | - | |||||||||||||||||||
| 244 | void QAccessibleTextEdit::setText(QAccessible::Text t, const QString &text) | - | ||||||||||||||||||
| 245 | { | - | ||||||||||||||||||
| 246 | if (t != QAccessible::Value) {
| 0 | ||||||||||||||||||
| 247 | QAccessibleWidget::setText(t, text); | - | ||||||||||||||||||
| 248 | return; never executed: return; | 0 | ||||||||||||||||||
| 249 | } | - | ||||||||||||||||||
| 250 | if (textEdit()->isReadOnly())
| 0 | ||||||||||||||||||
| 251 | return; never executed: return; | 0 | ||||||||||||||||||
| 252 | - | |||||||||||||||||||
| 253 | textEdit()->setText(text); | - | ||||||||||||||||||
| 254 | } never executed: end of block | 0 | ||||||||||||||||||
| 255 | - | |||||||||||||||||||
| 256 | QAccessible::State QAccessibleTextEdit::state() const | - | ||||||||||||||||||
| 257 | { | - | ||||||||||||||||||
| 258 | QAccessible::State st = QAccessibleTextWidget::state(); | - | ||||||||||||||||||
| 259 | if (textEdit()->isReadOnly())
| 0 | ||||||||||||||||||
| 260 | st.readOnly = true; never executed: st.readOnly = true; | 0 | ||||||||||||||||||
| 261 | else | - | ||||||||||||||||||
| 262 | st.editable = true; never executed: st.editable = true; | 0 | ||||||||||||||||||
| 263 | return st; never executed: return st; | 0 | ||||||||||||||||||
| 264 | } | - | ||||||||||||||||||
| 265 | - | |||||||||||||||||||
| 266 | void *QAccessibleTextEdit::interface_cast(QAccessible::InterfaceType t) | - | ||||||||||||||||||
| 267 | { | - | ||||||||||||||||||
| 268 | if (t == QAccessible::TextInterface)
| 0 | ||||||||||||||||||
| 269 | return static_cast<QAccessibleTextInterface*>(this); never executed: return static_cast<QAccessibleTextInterface*>(this); | 0 | ||||||||||||||||||
| 270 | else if (t == QAccessible::EditableTextInterface)
| 0 | ||||||||||||||||||
| 271 | return static_cast<QAccessibleEditableTextInterface*>(this); never executed: return static_cast<QAccessibleEditableTextInterface*>(this); | 0 | ||||||||||||||||||
| 272 | return QAccessibleWidget::interface_cast(t); never executed: return QAccessibleWidget::interface_cast(t); | 0 | ||||||||||||||||||
| 273 | } | - | ||||||||||||||||||
| 274 | - | |||||||||||||||||||
| 275 | void QAccessibleTextEdit::scrollToSubstring(int startIndex, int endIndex) | - | ||||||||||||||||||
| 276 | { | - | ||||||||||||||||||
| 277 | QTextEdit *edit = textEdit(); | - | ||||||||||||||||||
| 278 | - | |||||||||||||||||||
| 279 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
| 280 | cursor.setPosition(startIndex); | - | ||||||||||||||||||
| 281 | QRect r = edit->cursorRect(cursor); | - | ||||||||||||||||||
| 282 | - | |||||||||||||||||||
| 283 | cursor.setPosition(endIndex); | - | ||||||||||||||||||
| 284 | r.setBottomRight(edit->cursorRect(cursor).bottomRight()); | - | ||||||||||||||||||
| 285 | - | |||||||||||||||||||
| 286 | r.moveTo(r.x() + edit->horizontalScrollBar()->value(), | - | ||||||||||||||||||
| 287 | r.y() + edit->verticalScrollBar()->value()); | - | ||||||||||||||||||
| 288 | - | |||||||||||||||||||
| 289 | // E V I L, but ensureVisible is not public | - | ||||||||||||||||||
| 290 | if (Q_UNLIKELY(!QMetaObject::invokeMethod(edit, "_q_ensureVisible", Q_ARG(QRectF, r))))
| 0 | ||||||||||||||||||
| 291 | qWarning("AccessibleTextEdit::scrollToSubstring failed!"); never executed: QMessageLogger(__FILE__, 291, __PRETTY_FUNCTION__).warning("AccessibleTextEdit::scrollToSubstring failed!"); | 0 | ||||||||||||||||||
| 292 | } never executed: end of block | 0 | ||||||||||||||||||
| 293 | - | |||||||||||||||||||
| 294 | #endif // QT_NO_TEXTEDIT && QT_NO_CURSOR | - | ||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | #ifndef QT_NO_STACKEDWIDGET | - | ||||||||||||||||||
| 297 | // ======================= QAccessibleStackedWidget ====================== | - | ||||||||||||||||||
| 298 | QAccessibleStackedWidget::QAccessibleStackedWidget(QWidget *widget) | - | ||||||||||||||||||
| 299 | : QAccessibleWidget(widget, QAccessible::LayeredPane) | - | ||||||||||||||||||
| 300 | { | - | ||||||||||||||||||
| 301 | Q_ASSERT(qobject_cast<QStackedWidget *>(widget)); | - | ||||||||||||||||||
| 302 | } never executed: end of block | 0 | ||||||||||||||||||
| 303 | - | |||||||||||||||||||
| 304 | QAccessibleInterface *QAccessibleStackedWidget::childAt(int x, int y) const | - | ||||||||||||||||||
| 305 | { | - | ||||||||||||||||||
| 306 | if (!stackedWidget()->isVisible())
| 0 | ||||||||||||||||||
| 307 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 308 | QWidget *currentWidget = stackedWidget()->currentWidget(); | - | ||||||||||||||||||
| 309 | if (!currentWidget)
| 0 | ||||||||||||||||||
| 310 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 311 | QPoint position = currentWidget->mapFromGlobal(QPoint(x, y)); | - | ||||||||||||||||||
| 312 | if (currentWidget->rect().contains(position))
| 0 | ||||||||||||||||||
| 313 | return child(stackedWidget()->currentIndex()); never executed: return child(stackedWidget()->currentIndex()); | 0 | ||||||||||||||||||
| 314 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 315 | } | - | ||||||||||||||||||
| 316 | - | |||||||||||||||||||
| 317 | int QAccessibleStackedWidget::childCount() const | - | ||||||||||||||||||
| 318 | { | - | ||||||||||||||||||
| 319 | return stackedWidget()->count(); never executed: return stackedWidget()->count(); | 0 | ||||||||||||||||||
| 320 | } | - | ||||||||||||||||||
| 321 | - | |||||||||||||||||||
| 322 | int QAccessibleStackedWidget::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
| 323 | { | - | ||||||||||||||||||
| 324 | if (!child)
| 0 | ||||||||||||||||||
| 325 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 326 | - | |||||||||||||||||||
| 327 | QWidget *widget = qobject_cast<QWidget*>(child->object()); | - | ||||||||||||||||||
| 328 | return stackedWidget()->indexOf(widget); never executed: return stackedWidget()->indexOf(widget); | 0 | ||||||||||||||||||
| 329 | } | - | ||||||||||||||||||
| 330 | - | |||||||||||||||||||
| 331 | QAccessibleInterface *QAccessibleStackedWidget::child(int index) const | - | ||||||||||||||||||
| 332 | { | - | ||||||||||||||||||
| 333 | if (index < 0 || index >= stackedWidget()->count())
| 0 | ||||||||||||||||||
| 334 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 335 | return QAccessible::queryAccessibleInterface(stackedWidget()->widget(index)); never executed: return QAccessible::queryAccessibleInterface(stackedWidget()->widget(index)); | 0 | ||||||||||||||||||
| 336 | } | - | ||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | QStackedWidget *QAccessibleStackedWidget::stackedWidget() const | - | ||||||||||||||||||
| 339 | { | - | ||||||||||||||||||
| 340 | return static_cast<QStackedWidget *>(object()); never executed: return static_cast<QStackedWidget *>(object()); | 0 | ||||||||||||||||||
| 341 | } | - | ||||||||||||||||||
| 342 | #endif // QT_NO_STACKEDWIDGET | - | ||||||||||||||||||
| 343 | - | |||||||||||||||||||
| 344 | #ifndef QT_NO_TOOLBOX | - | ||||||||||||||||||
| 345 | // ======================= QAccessibleToolBox ====================== | - | ||||||||||||||||||
| 346 | QAccessibleToolBox::QAccessibleToolBox(QWidget *widget) | - | ||||||||||||||||||
| 347 | : QAccessibleWidget(widget, QAccessible::LayeredPane) | - | ||||||||||||||||||
| 348 | { | - | ||||||||||||||||||
| 349 | Q_ASSERT(qobject_cast<QToolBox *>(widget)); | - | ||||||||||||||||||
| 350 | } never executed: end of block | 0 | ||||||||||||||||||
| 351 | - | |||||||||||||||||||
| 352 | QToolBox * QAccessibleToolBox::toolBox() const | - | ||||||||||||||||||
| 353 | { | - | ||||||||||||||||||
| 354 | return static_cast<QToolBox *>(object()); never executed: return static_cast<QToolBox *>(object()); | 0 | ||||||||||||||||||
| 355 | } | - | ||||||||||||||||||
| 356 | #endif // QT_NO_TOOLBOX | - | ||||||||||||||||||
| 357 | - | |||||||||||||||||||
| 358 | // ======================= QAccessibleMdiArea ====================== | - | ||||||||||||||||||
| 359 | #ifndef QT_NO_MDIAREA | - | ||||||||||||||||||
| 360 | QAccessibleMdiArea::QAccessibleMdiArea(QWidget *widget) | - | ||||||||||||||||||
| 361 | : QAccessibleWidget(widget, QAccessible::LayeredPane) | - | ||||||||||||||||||
| 362 | { | - | ||||||||||||||||||
| 363 | Q_ASSERT(qobject_cast<QMdiArea *>(widget)); | - | ||||||||||||||||||
| 364 | } never executed: end of block | 0 | ||||||||||||||||||
| 365 | - | |||||||||||||||||||
| 366 | int QAccessibleMdiArea::childCount() const | - | ||||||||||||||||||
| 367 | { | - | ||||||||||||||||||
| 368 | return mdiArea()->subWindowList().count(); never executed: return mdiArea()->subWindowList().count(); | 0 | ||||||||||||||||||
| 369 | } | - | ||||||||||||||||||
| 370 | - | |||||||||||||||||||
| 371 | QAccessibleInterface *QAccessibleMdiArea::child(int index) const | - | ||||||||||||||||||
| 372 | { | - | ||||||||||||||||||
| 373 | QList<QMdiSubWindow *> subWindows = mdiArea()->subWindowList(); | - | ||||||||||||||||||
| 374 | QWidget *targetObject = subWindows.value(index); | - | ||||||||||||||||||
| 375 | if (!targetObject)
| 0 | ||||||||||||||||||
| 376 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 377 | return QAccessible::queryAccessibleInterface(targetObject); never executed: return QAccessible::queryAccessibleInterface(targetObject); | 0 | ||||||||||||||||||
| 378 | } | - | ||||||||||||||||||
| 379 | - | |||||||||||||||||||
| 380 | - | |||||||||||||||||||
| 381 | int QAccessibleMdiArea::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
| 382 | { | - | ||||||||||||||||||
| 383 | if (!child || !child->object() || mdiArea()->subWindowList().isEmpty())
| 0 | ||||||||||||||||||
| 384 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 385 | if (QMdiSubWindow *window = qobject_cast<QMdiSubWindow *>(child->object())) {
| 0 | ||||||||||||||||||
| 386 | return mdiArea()->subWindowList().indexOf(window); never executed: return mdiArea()->subWindowList().indexOf(window); | 0 | ||||||||||||||||||
| 387 | } | - | ||||||||||||||||||
| 388 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 389 | } | - | ||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | QMdiArea *QAccessibleMdiArea::mdiArea() const | - | ||||||||||||||||||
| 392 | { | - | ||||||||||||||||||
| 393 | return static_cast<QMdiArea *>(object()); never executed: return static_cast<QMdiArea *>(object()); | 0 | ||||||||||||||||||
| 394 | } | - | ||||||||||||||||||
| 395 | - | |||||||||||||||||||
| 396 | // ======================= QAccessibleMdiSubWindow ====================== | - | ||||||||||||||||||
| 397 | QAccessibleMdiSubWindow::QAccessibleMdiSubWindow(QWidget *widget) | - | ||||||||||||||||||
| 398 | : QAccessibleWidget(widget, QAccessible::Window) | - | ||||||||||||||||||
| 399 | { | - | ||||||||||||||||||
| 400 | Q_ASSERT(qobject_cast<QMdiSubWindow *>(widget)); | - | ||||||||||||||||||
| 401 | } never executed: end of block | 0 | ||||||||||||||||||
| 402 | - | |||||||||||||||||||
| 403 | QString QAccessibleMdiSubWindow::text(QAccessible::Text textType) const | - | ||||||||||||||||||
| 404 | { | - | ||||||||||||||||||
| 405 | if (textType == QAccessible::Name) {
| 0 | ||||||||||||||||||
| 406 | QString title = mdiSubWindow()->windowTitle(); | - | ||||||||||||||||||
| 407 | title.replace(QLatin1String("[*]"), QLatin1String("")); | - | ||||||||||||||||||
| 408 | return title; never executed: return title; | 0 | ||||||||||||||||||
| 409 | } | - | ||||||||||||||||||
| 410 | return QAccessibleWidget::text(textType); never executed: return QAccessibleWidget::text(textType); | 0 | ||||||||||||||||||
| 411 | } | - | ||||||||||||||||||
| 412 | - | |||||||||||||||||||
| 413 | void QAccessibleMdiSubWindow::setText(QAccessible::Text textType, const QString &text) | - | ||||||||||||||||||
| 414 | { | - | ||||||||||||||||||
| 415 | if (textType == QAccessible::Name)
| 0 | ||||||||||||||||||
| 416 | mdiSubWindow()->setWindowTitle(text); never executed: mdiSubWindow()->setWindowTitle(text); | 0 | ||||||||||||||||||
| 417 | else | - | ||||||||||||||||||
| 418 | QAccessibleWidget::setText(textType, text); never executed: QAccessibleWidget::setText(textType, text); | 0 | ||||||||||||||||||
| 419 | } | - | ||||||||||||||||||
| 420 | - | |||||||||||||||||||
| 421 | QAccessible::State QAccessibleMdiSubWindow::state() const | - | ||||||||||||||||||
| 422 | { | - | ||||||||||||||||||
| 423 | QAccessible::State state; | - | ||||||||||||||||||
| 424 | state.focusable = true; | - | ||||||||||||||||||
| 425 | if (!mdiSubWindow()->isMaximized()) {
| 0 | ||||||||||||||||||
| 426 | state.movable = true; | - | ||||||||||||||||||
| 427 | state.sizeable = true; | - | ||||||||||||||||||
| 428 | } never executed: end of block | 0 | ||||||||||||||||||
| 429 | if (mdiSubWindow()->isAncestorOf(QApplication::focusWidget())
| 0 | ||||||||||||||||||
| 430 | || QApplication::focusWidget() == mdiSubWindow())
| 0 | ||||||||||||||||||
| 431 | state.focused = true; never executed: state.focused = true; | 0 | ||||||||||||||||||
| 432 | if (!mdiSubWindow()->isVisible())
| 0 | ||||||||||||||||||
| 433 | state.invisible = true; never executed: state.invisible = true; | 0 | ||||||||||||||||||
| 434 | if (const QWidget *parent = mdiSubWindow()->parentWidget())
| 0 | ||||||||||||||||||
| 435 | if (!parent->contentsRect().contains(mdiSubWindow()->geometry()))
| 0 | ||||||||||||||||||
| 436 | state.offscreen = true; never executed: state.offscreen = true; | 0 | ||||||||||||||||||
| 437 | if (!mdiSubWindow()->isEnabled())
| 0 | ||||||||||||||||||
| 438 | state.disabled = true; never executed: state.disabled = true; | 0 | ||||||||||||||||||
| 439 | return state; never executed: return state; | 0 | ||||||||||||||||||
| 440 | } | - | ||||||||||||||||||
| 441 | - | |||||||||||||||||||
| 442 | int QAccessibleMdiSubWindow::childCount() const | - | ||||||||||||||||||
| 443 | { | - | ||||||||||||||||||
| 444 | if (mdiSubWindow()->widget())
| 0 | ||||||||||||||||||
| 445 | return 1; never executed: return 1; | 0 | ||||||||||||||||||
| 446 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 447 | } | - | ||||||||||||||||||
| 448 | - | |||||||||||||||||||
| 449 | QAccessibleInterface *QAccessibleMdiSubWindow::child(int index) const | - | ||||||||||||||||||
| 450 | { | - | ||||||||||||||||||
| 451 | QMdiSubWindow *source = mdiSubWindow(); | - | ||||||||||||||||||
| 452 | if (index != 0 || !source->widget())
| 0 | ||||||||||||||||||
| 453 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 454 | - | |||||||||||||||||||
| 455 | return QAccessible::queryAccessibleInterface(source->widget()); never executed: return QAccessible::queryAccessibleInterface(source->widget()); | 0 | ||||||||||||||||||
| 456 | } | - | ||||||||||||||||||
| 457 | - | |||||||||||||||||||
| 458 | int QAccessibleMdiSubWindow::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
| 459 | { | - | ||||||||||||||||||
| 460 | if (child && child->object() && child->object() == mdiSubWindow()->widget())
| 0 | ||||||||||||||||||
| 461 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 462 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 463 | } | - | ||||||||||||||||||
| 464 | - | |||||||||||||||||||
| 465 | QRect QAccessibleMdiSubWindow::rect() const | - | ||||||||||||||||||
| 466 | { | - | ||||||||||||||||||
| 467 | if (mdiSubWindow()->isHidden())
| 0 | ||||||||||||||||||
| 468 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||
| 469 | if (!mdiSubWindow()->parent())
| 0 | ||||||||||||||||||
| 470 | return QAccessibleWidget::rect(); never executed: return QAccessibleWidget::rect(); | 0 | ||||||||||||||||||
| 471 | const QPoint pos = mdiSubWindow()->mapToGlobal(QPoint(0, 0)); | - | ||||||||||||||||||
| 472 | return QRect(pos, mdiSubWindow()->size()); never executed: return QRect(pos, mdiSubWindow()->size()); | 0 | ||||||||||||||||||
| 473 | } | - | ||||||||||||||||||
| 474 | - | |||||||||||||||||||
| 475 | QMdiSubWindow *QAccessibleMdiSubWindow::mdiSubWindow() const | - | ||||||||||||||||||
| 476 | { | - | ||||||||||||||||||
| 477 | return static_cast<QMdiSubWindow *>(object()); never executed: return static_cast<QMdiSubWindow *>(object()); | 0 | ||||||||||||||||||
| 478 | } | - | ||||||||||||||||||
| 479 | #endif // QT_NO_MDIAREA | - | ||||||||||||||||||
| 480 | - | |||||||||||||||||||
| 481 | #ifndef QT_NO_DIALOGBUTTONBOX | - | ||||||||||||||||||
| 482 | // ======================= QAccessibleDialogButtonBox ====================== | - | ||||||||||||||||||
| 483 | QAccessibleDialogButtonBox::QAccessibleDialogButtonBox(QWidget *widget) | - | ||||||||||||||||||
| 484 | : QAccessibleWidget(widget, QAccessible::Grouping) | - | ||||||||||||||||||
| 485 | { | - | ||||||||||||||||||
| 486 | Q_ASSERT(qobject_cast<QDialogButtonBox*>(widget)); | - | ||||||||||||||||||
| 487 | } never executed: end of block | 0 | ||||||||||||||||||
| 488 | - | |||||||||||||||||||
| 489 | #endif // QT_NO_DIALOGBUTTONBOX | - | ||||||||||||||||||
| 490 | - | |||||||||||||||||||
| 491 | #if !defined(QT_NO_TEXTBROWSER) && !defined(QT_NO_CURSOR) | - | ||||||||||||||||||
| 492 | QAccessibleTextBrowser::QAccessibleTextBrowser(QWidget *widget) | - | ||||||||||||||||||
| 493 | : QAccessibleTextEdit(widget) | - | ||||||||||||||||||
| 494 | { | - | ||||||||||||||||||
| 495 | Q_ASSERT(qobject_cast<QTextBrowser *>(widget)); | - | ||||||||||||||||||
| 496 | } never executed: end of block | 0 | ||||||||||||||||||
| 497 | - | |||||||||||||||||||
| 498 | QAccessible::Role QAccessibleTextBrowser::role() const | - | ||||||||||||||||||
| 499 | { | - | ||||||||||||||||||
| 500 | return QAccessible::StaticText; never executed: return QAccessible::StaticText; | 0 | ||||||||||||||||||
| 501 | } | - | ||||||||||||||||||
| 502 | #endif // QT_NO_TEXTBROWSER && QT_NO_CURSOR | - | ||||||||||||||||||
| 503 | - | |||||||||||||||||||
| 504 | #ifndef QT_NO_CALENDARWIDGET | - | ||||||||||||||||||
| 505 | // ===================== QAccessibleCalendarWidget ======================== | - | ||||||||||||||||||
| 506 | QAccessibleCalendarWidget::QAccessibleCalendarWidget(QWidget *widget) | - | ||||||||||||||||||
| 507 | : QAccessibleWidget(widget, QAccessible::Table) | - | ||||||||||||||||||
| 508 | { | - | ||||||||||||||||||
| 509 | Q_ASSERT(qobject_cast<QCalendarWidget *>(widget)); | - | ||||||||||||||||||
| 510 | } never executed: end of block | 0 | ||||||||||||||||||
| 511 | - | |||||||||||||||||||
| 512 | int QAccessibleCalendarWidget::childCount() const | - | ||||||||||||||||||
| 513 | { | - | ||||||||||||||||||
| 514 | return calendarWidget()->isNavigationBarVisible() ? 2 : 1; never executed: return calendarWidget()->isNavigationBarVisible() ? 2 : 1; | 0 | ||||||||||||||||||
| 515 | } | - | ||||||||||||||||||
| 516 | - | |||||||||||||||||||
| 517 | int QAccessibleCalendarWidget::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
| 518 | { | - | ||||||||||||||||||
| 519 | if (!child || !child->object() || childCount() <= 0)
| 0 | ||||||||||||||||||
| 520 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 521 | if (qobject_cast<QAbstractItemView *>(child->object()))
| 0 | ||||||||||||||||||
| 522 | return childCount() - 1; // FIXME never executed: return childCount() - 1; | 0 | ||||||||||||||||||
| 523 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 524 | } | - | ||||||||||||||||||
| 525 | - | |||||||||||||||||||
| 526 | QAccessibleInterface *QAccessibleCalendarWidget::child(int index) const | - | ||||||||||||||||||
| 527 | { | - | ||||||||||||||||||
| 528 | if (index < 0 || index >= childCount())
| 0 | ||||||||||||||||||
| 529 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 530 | - | |||||||||||||||||||
| 531 | if (childCount() > 1 && index == 0)
| 0 | ||||||||||||||||||
| 532 | return QAccessible::queryAccessibleInterface(navigationBar()); never executed: return QAccessible::queryAccessibleInterface(navigationBar()); | 0 | ||||||||||||||||||
| 533 | - | |||||||||||||||||||
| 534 | return QAccessible::queryAccessibleInterface(calendarView()); never executed: return QAccessible::queryAccessibleInterface(calendarView()); | 0 | ||||||||||||||||||
| 535 | } | - | ||||||||||||||||||
| 536 | - | |||||||||||||||||||
| 537 | QCalendarWidget *QAccessibleCalendarWidget::calendarWidget() const | - | ||||||||||||||||||
| 538 | { | - | ||||||||||||||||||
| 539 | return static_cast<QCalendarWidget *>(object()); never executed: return static_cast<QCalendarWidget *>(object()); | 0 | ||||||||||||||||||
| 540 | } | - | ||||||||||||||||||
| 541 | - | |||||||||||||||||||
| 542 | QAbstractItemView *QAccessibleCalendarWidget::calendarView() const | - | ||||||||||||||||||
| 543 | { | - | ||||||||||||||||||
| 544 | foreach (QObject *child, calendarWidget()->children()) { | - | ||||||||||||||||||
| 545 | if (child->objectName() == QLatin1String("qt_calendar_calendarview"))
| 0 | ||||||||||||||||||
| 546 | return static_cast<QAbstractItemView *>(child); never executed: return static_cast<QAbstractItemView *>(child); | 0 | ||||||||||||||||||
| 547 | } never executed: end of block | 0 | ||||||||||||||||||
| 548 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 549 | } | - | ||||||||||||||||||
| 550 | - | |||||||||||||||||||
| 551 | QWidget *QAccessibleCalendarWidget::navigationBar() const | - | ||||||||||||||||||
| 552 | { | - | ||||||||||||||||||
| 553 | foreach (QObject *child, calendarWidget()->children()) { | - | ||||||||||||||||||
| 554 | if (child->objectName() == QLatin1String("qt_calendar_navigationbar"))
| 0 | ||||||||||||||||||
| 555 | return static_cast<QWidget *>(child); never executed: return static_cast<QWidget *>(child); | 0 | ||||||||||||||||||
| 556 | } never executed: end of block | 0 | ||||||||||||||||||
| 557 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 558 | } | - | ||||||||||||||||||
| 559 | #endif // QT_NO_CALENDARWIDGET | - | ||||||||||||||||||
| 560 | - | |||||||||||||||||||
| 561 | #ifndef QT_NO_DOCKWIDGET | - | ||||||||||||||||||
| 562 | - | |||||||||||||||||||
| 563 | // Dock Widget - order of children: | - | ||||||||||||||||||
| 564 | // - Content widget | - | ||||||||||||||||||
| 565 | // - Float button | - | ||||||||||||||||||
| 566 | // - Close button | - | ||||||||||||||||||
| 567 | // If there is a custom title bar widget, that one becomes child 1, after the content 0 | - | ||||||||||||||||||
| 568 | // (in that case the buttons are ignored) | - | ||||||||||||||||||
| 569 | QAccessibleDockWidget::QAccessibleDockWidget(QWidget *widget) | - | ||||||||||||||||||
| 570 | : QAccessibleWidget(widget, QAccessible::Window) | - | ||||||||||||||||||
| 571 | { | - | ||||||||||||||||||
| 572 | } never executed: end of block | 0 | ||||||||||||||||||
| 573 | - | |||||||||||||||||||
| 574 | QDockWidgetLayout *QAccessibleDockWidget::dockWidgetLayout() const | - | ||||||||||||||||||
| 575 | { | - | ||||||||||||||||||
| 576 | return qobject_cast<QDockWidgetLayout*>(dockWidget()->layout()); never executed: return qobject_cast<QDockWidgetLayout*>(dockWidget()->layout()); | 0 | ||||||||||||||||||
| 577 | } | - | ||||||||||||||||||
| 578 | - | |||||||||||||||||||
| 579 | int QAccessibleDockWidget::childCount() const | - | ||||||||||||||||||
| 580 | { | - | ||||||||||||||||||
| 581 | if (dockWidget()->titleBarWidget()) {
| 0 | ||||||||||||||||||
| 582 | return dockWidget()->widget() ? 2 : 1; never executed: return dockWidget()->widget() ? 2 : 1; | 0 | ||||||||||||||||||
| 583 | } | - | ||||||||||||||||||
| 584 | return dockWidgetLayout()->count(); never executed: return dockWidgetLayout()->count(); | 0 | ||||||||||||||||||
| 585 | } | - | ||||||||||||||||||
| 586 | - | |||||||||||||||||||
| 587 | QAccessibleInterface *QAccessibleDockWidget::child(int index) const | - | ||||||||||||||||||
| 588 | { | - | ||||||||||||||||||
| 589 | if (dockWidget()->titleBarWidget()) {
| 0 | ||||||||||||||||||
| 590 | if ((!dockWidget()->widget() && index == 0) || (index == 1))
| 0 | ||||||||||||||||||
| 591 | return QAccessible::queryAccessibleInterface(dockWidget()->titleBarWidget()); never executed: return QAccessible::queryAccessibleInterface(dockWidget()->titleBarWidget()); | 0 | ||||||||||||||||||
| 592 | if (index == 0)
| 0 | ||||||||||||||||||
| 593 | return QAccessible::queryAccessibleInterface(dockWidget()->widget()); never executed: return QAccessible::queryAccessibleInterface(dockWidget()->widget()); | 0 | ||||||||||||||||||
| 594 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 595 | QLayoutItem *item = dockWidgetLayout()->itemAt(index); | - | ||||||||||||||||||
| 596 | if (item)
| 0 | ||||||||||||||||||
| 597 | return QAccessible::queryAccessibleInterface(item->widget()); never executed: return QAccessible::queryAccessibleInterface(item->widget()); | 0 | ||||||||||||||||||
| 598 | } never executed: end of block | 0 | ||||||||||||||||||
| 599 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 600 | } | - | ||||||||||||||||||
| 601 | - | |||||||||||||||||||
| 602 | int QAccessibleDockWidget::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
| 603 | { | - | ||||||||||||||||||
| 604 | if (!child || !child->object() || child->object()->parent() != object())
| 0 | ||||||||||||||||||
| 605 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 606 | - | |||||||||||||||||||
| 607 | if (dockWidget()->titleBarWidget() == child->object()) {
| 0 | ||||||||||||||||||
| 608 | return dockWidget()->widget() ? 1 : 0; never executed: return dockWidget()->widget() ? 1 : 0; | 0 | ||||||||||||||||||
| 609 | } | - | ||||||||||||||||||
| 610 | - | |||||||||||||||||||
| 611 | return dockWidgetLayout()->indexOf(qobject_cast<QWidget*>(child->object())); never executed: return dockWidgetLayout()->indexOf(qobject_cast<QWidget*>(child->object())); | 0 | ||||||||||||||||||
| 612 | } | - | ||||||||||||||||||
| 613 | - | |||||||||||||||||||
| 614 | QRect QAccessibleDockWidget::rect() const | - | ||||||||||||||||||
| 615 | { | - | ||||||||||||||||||
| 616 | QRect rect; | - | ||||||||||||||||||
| 617 | - | |||||||||||||||||||
| 618 | if (dockWidget()->isFloating()) {
| 0 | ||||||||||||||||||
| 619 | rect = dockWidget()->frameGeometry(); | - | ||||||||||||||||||
| 620 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 621 | rect = dockWidget()->rect(); | - | ||||||||||||||||||
| 622 | rect.moveTopLeft(dockWidget()->mapToGlobal(rect.topLeft())); | - | ||||||||||||||||||
| 623 | } never executed: end of block | 0 | ||||||||||||||||||
| 624 | - | |||||||||||||||||||
| 625 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
| 626 | } | - | ||||||||||||||||||
| 627 | - | |||||||||||||||||||
| 628 | QDockWidget *QAccessibleDockWidget::dockWidget() const | - | ||||||||||||||||||
| 629 | { | - | ||||||||||||||||||
| 630 | return static_cast<QDockWidget *>(object()); never executed: return static_cast<QDockWidget *>(object()); | 0 | ||||||||||||||||||
| 631 | } | - | ||||||||||||||||||
| 632 | - | |||||||||||||||||||
| 633 | QString QAccessibleDockWidget::text(QAccessible::Text t) const | - | ||||||||||||||||||
| 634 | { | - | ||||||||||||||||||
| 635 | if (t == QAccessible::Name) {
| 0 | ||||||||||||||||||
| 636 | return qt_accStripAmp(dockWidget()->windowTitle()); never executed: return qt_accStripAmp(dockWidget()->windowTitle()); | 0 | ||||||||||||||||||
| 637 | } else if (t == QAccessible::Accelerator) {
| 0 | ||||||||||||||||||
| 638 | return qt_accHotKey(dockWidget()->windowTitle()); never executed: return qt_accHotKey(dockWidget()->windowTitle()); | 0 | ||||||||||||||||||
| 639 | } | - | ||||||||||||||||||
| 640 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
| 641 | } | - | ||||||||||||||||||
| 642 | #endif // QT_NO_DOCKWIDGET | - | ||||||||||||||||||
| 643 | - | |||||||||||||||||||
| 644 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
| 645 | - | |||||||||||||||||||
| 646 | QAccessibleTextWidget::QAccessibleTextWidget(QWidget *o, QAccessible::Role r, const QString &name): | - | ||||||||||||||||||
| 647 | QAccessibleWidget(o, r, name) | - | ||||||||||||||||||
| 648 | { | - | ||||||||||||||||||
| 649 | - | |||||||||||||||||||
| 650 | } never executed: end of block | 0 | ||||||||||||||||||
| 651 | - | |||||||||||||||||||
| 652 | QAccessible::State QAccessibleTextWidget::state() const | - | ||||||||||||||||||
| 653 | { | - | ||||||||||||||||||
| 654 | QAccessible::State s = QAccessibleWidget::state(); | - | ||||||||||||||||||
| 655 | s.selectableText = true; | - | ||||||||||||||||||
| 656 | s.multiLine = true; | - | ||||||||||||||||||
| 657 | return s; never executed: return s; | 0 | ||||||||||||||||||
| 658 | } | - | ||||||||||||||||||
| 659 | - | |||||||||||||||||||
| 660 | QRect QAccessibleTextWidget::characterRect(int offset) const | - | ||||||||||||||||||
| 661 | { | - | ||||||||||||||||||
| 662 | QTextBlock block = textDocument()->findBlock(offset); | - | ||||||||||||||||||
| 663 | if (!block.isValid())
| 0 | ||||||||||||||||||
| 664 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||
| 665 | - | |||||||||||||||||||
| 666 | QTextLayout *layout = block.layout(); | - | ||||||||||||||||||
| 667 | QPointF layoutPosition = layout->position(); | - | ||||||||||||||||||
| 668 | int relativeOffset = offset - block.position(); | - | ||||||||||||||||||
| 669 | QTextLine line = layout->lineForTextPosition(relativeOffset); | - | ||||||||||||||||||
| 670 | - | |||||||||||||||||||
| 671 | QRect r; | - | ||||||||||||||||||
| 672 | - | |||||||||||||||||||
| 673 | if (line.isValid()) {
| 0 | ||||||||||||||||||
| 674 | qreal x = line.cursorToX(relativeOffset); | - | ||||||||||||||||||
| 675 | - | |||||||||||||||||||
| 676 | QTextCharFormat format; | - | ||||||||||||||||||
| 677 | QTextBlock::iterator iter = block.begin(); | - | ||||||||||||||||||
| 678 | if (iter.atEnd())
| 0 | ||||||||||||||||||
| 679 | format = block.charFormat(); never executed: format = block.charFormat(); | 0 | ||||||||||||||||||
| 680 | else { | - | ||||||||||||||||||
| 681 | while (!iter.atEnd() && !iter.fragment().contains(offset))
| 0 | ||||||||||||||||||
| 682 | ++iter; never executed: ++iter; | 0 | ||||||||||||||||||
| 683 | if (iter.atEnd()) // newline should have same format as preceding character
| 0 | ||||||||||||||||||
| 684 | --iter; never executed: --iter; | 0 | ||||||||||||||||||
| 685 | format = iter.fragment().charFormat(); | - | ||||||||||||||||||
| 686 | } never executed: end of block | 0 | ||||||||||||||||||
| 687 | - | |||||||||||||||||||
| 688 | QFontMetrics fm(format.font()); | - | ||||||||||||||||||
| 689 | const QString ch = text(offset, offset + 1); | - | ||||||||||||||||||
| 690 | if (!ch.isEmpty()) {
| 0 | ||||||||||||||||||
| 691 | int w = fm.width(ch); | - | ||||||||||||||||||
| 692 | int h = fm.height(); | - | ||||||||||||||||||
| 693 | r = QRect(layoutPosition.x() + x, layoutPosition.y() + line.y() + line.ascent() + fm.descent() - h, | - | ||||||||||||||||||
| 694 | w, h); | - | ||||||||||||||||||
| 695 | r.moveTo(viewport()->mapToGlobal(r.topLeft())); | - | ||||||||||||||||||
| 696 | } never executed: end of block | 0 | ||||||||||||||||||
| 697 | r.translate(-scrollBarPosition()); | - | ||||||||||||||||||
| 698 | } never executed: end of block | 0 | ||||||||||||||||||
| 699 | - | |||||||||||||||||||
| 700 | return r; never executed: return r; | 0 | ||||||||||||||||||
| 701 | } | - | ||||||||||||||||||
| 702 | - | |||||||||||||||||||
| 703 | int QAccessibleTextWidget::offsetAtPoint(const QPoint &point) const | - | ||||||||||||||||||
| 704 | { | - | ||||||||||||||||||
| 705 | QPoint p = viewport()->mapFromGlobal(point); | - | ||||||||||||||||||
| 706 | // convert to document coordinates | - | ||||||||||||||||||
| 707 | p += scrollBarPosition(); | - | ||||||||||||||||||
| 708 | return textDocument()->documentLayout()->hitTest(p, Qt::ExactHit); never executed: return textDocument()->documentLayout()->hitTest(p, Qt::ExactHit); | 0 | ||||||||||||||||||
| 709 | } | - | ||||||||||||||||||
| 710 | - | |||||||||||||||||||
| 711 | int QAccessibleTextWidget::selectionCount() const | - | ||||||||||||||||||
| 712 | { | - | ||||||||||||||||||
| 713 | return textCursor().hasSelection() ? 1 : 0; never executed: return textCursor().hasSelection() ? 1 : 0; | 0 | ||||||||||||||||||
| 714 | } | - | ||||||||||||||||||
| 715 | - | |||||||||||||||||||
| 716 | namespace { | - | ||||||||||||||||||
| 717 | /*! | - | ||||||||||||||||||
| 718 | \internal | - | ||||||||||||||||||
| 719 | \brief Helper class for AttributeFormatter | - | ||||||||||||||||||
| 720 | - | |||||||||||||||||||
| 721 | This class is returned from AttributeFormatter's indexing operator to act | - | ||||||||||||||||||
| 722 | as a proxy for the following assignment. | - | ||||||||||||||||||
| 723 | - | |||||||||||||||||||
| 724 | It uses perfect forwarding in its assignment operator to amend the RHS | - | ||||||||||||||||||
| 725 | with the formatting of the key, using QStringBuilder. Consequently, the | - | ||||||||||||||||||
| 726 | RHS can be anything that QStringBuilder supports. | - | ||||||||||||||||||
| 727 | */ | - | ||||||||||||||||||
| 728 | class AttributeFormatterRef { | - | ||||||||||||||||||
| 729 | QString &string; | - | ||||||||||||||||||
| 730 | const char *key; | - | ||||||||||||||||||
| 731 | friend class AttributeFormatter; | - | ||||||||||||||||||
| 732 | AttributeFormatterRef(QString &string, const char *key) : string(string), key(key) {} never executed: end of block | 0 | ||||||||||||||||||
| 733 | public: | - | ||||||||||||||||||
| 734 | template <typename RHS> | - | ||||||||||||||||||
| 735 | void operator=(RHS &&rhs) | - | ||||||||||||||||||
| 736 | { string += QLatin1String(key) + QLatin1Char(':') + std::forward<RHS>(rhs) + QLatin1Char(';'); } never executed: end of block | 0 | ||||||||||||||||||
| 737 | }; | - | ||||||||||||||||||
| 738 | - | |||||||||||||||||||
| 739 | /*! | - | ||||||||||||||||||
| 740 | \internal | - | ||||||||||||||||||
| 741 | \brief Small string-builder class that supports a map-like API to serialize key-value pairs. | - | ||||||||||||||||||
| 742 | \code | - | ||||||||||||||||||
| 743 | AttributeFormatter attrs; | - | ||||||||||||||||||
| 744 | attrs["foo"] = QLatinString("hello") + world + QLatin1Char('!'); | - | ||||||||||||||||||
| 745 | \endcode | - | ||||||||||||||||||
| 746 | The key type is always \c{const char*}, and the right-hand-side can | - | ||||||||||||||||||
| 747 | be any QStringBuilder expression. | - | ||||||||||||||||||
| 748 | - | |||||||||||||||||||
| 749 | Breaking it down, this class provides the indexing operator, stores | - | ||||||||||||||||||
| 750 | the key in an instance of, and then returns, AttributeFormatterRef, | - | ||||||||||||||||||
| 751 | which is the class that provides the assignment part of the operation. | - | ||||||||||||||||||
| 752 | */ | - | ||||||||||||||||||
| 753 | class AttributeFormatter { | - | ||||||||||||||||||
| 754 | QString string; | - | ||||||||||||||||||
| 755 | public: | - | ||||||||||||||||||
| 756 | AttributeFormatterRef operator[](const char *key) | - | ||||||||||||||||||
| 757 | { return AttributeFormatterRef(string, key); } never executed: return AttributeFormatterRef(string, key); | 0 | ||||||||||||||||||
| 758 | - | |||||||||||||||||||
| 759 | QString toFormatted() const { return string; } never executed: return string; | 0 | ||||||||||||||||||
| 760 | }; | - | ||||||||||||||||||
| 761 | } // unnamed namespace | - | ||||||||||||||||||
| 762 | - | |||||||||||||||||||
| 763 | QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *endOffset) const | - | ||||||||||||||||||
| 764 | { | - | ||||||||||||||||||
| 765 | /* The list of attributes can be found at: | - | ||||||||||||||||||
| 766 | http://linuxfoundation.org/collaborate/workgroups/accessibility/iaccessible2/textattributes | - | ||||||||||||||||||
| 767 | */ | - | ||||||||||||||||||
| 768 | - | |||||||||||||||||||
| 769 | // IAccessible2 defines -1 as length and -2 as cursor position | - | ||||||||||||||||||
| 770 | if (offset == -2)
| 0 | ||||||||||||||||||
| 771 | offset = cursorPosition(); never executed: offset = cursorPosition(); | 0 | ||||||||||||||||||
| 772 | - | |||||||||||||||||||
| 773 | const int charCount = characterCount(); | - | ||||||||||||||||||
| 774 | - | |||||||||||||||||||
| 775 | // -1 doesn't make much sense here, but it's better to return something | - | ||||||||||||||||||
| 776 | // screen readers may ask for text attributes at the cursor pos which may be equal to length | - | ||||||||||||||||||
| 777 | if (offset == -1 || offset == charCount)
| 0 | ||||||||||||||||||
| 778 | offset = charCount - 1; never executed: offset = charCount - 1; | 0 | ||||||||||||||||||
| 779 | - | |||||||||||||||||||
| 780 | if (offset < 0 || offset > charCount) {
| 0 | ||||||||||||||||||
| 781 | *startOffset = -1; | - | ||||||||||||||||||
| 782 | *endOffset = -1; | - | ||||||||||||||||||
| 783 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
| 784 | } | - | ||||||||||||||||||
| 785 | - | |||||||||||||||||||
| 786 | - | |||||||||||||||||||
| 787 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
| 788 | cursor.setPosition(offset); | - | ||||||||||||||||||
| 789 | QTextBlock block = cursor.block(); | - | ||||||||||||||||||
| 790 | - | |||||||||||||||||||
| 791 | int blockStart = block.position(); | - | ||||||||||||||||||
| 792 | int blockEnd = blockStart + block.length(); | - | ||||||||||||||||||
| 793 | - | |||||||||||||||||||
| 794 | QTextBlock::iterator iter = block.begin(); | - | ||||||||||||||||||
| 795 | int lastFragmentIndex = blockStart; | - | ||||||||||||||||||
| 796 | while (!iter.atEnd()) {
| 0 | ||||||||||||||||||
| 797 | QTextFragment f = iter.fragment(); | - | ||||||||||||||||||
| 798 | if (f.contains(offset))
| 0 | ||||||||||||||||||
| 799 | break; never executed: break; | 0 | ||||||||||||||||||
| 800 | lastFragmentIndex = f.position() + f.length(); | - | ||||||||||||||||||
| 801 | ++iter; | - | ||||||||||||||||||
| 802 | } never executed: end of block | 0 | ||||||||||||||||||
| 803 | - | |||||||||||||||||||
| 804 | QTextCharFormat charFormat; | - | ||||||||||||||||||
| 805 | if (!iter.atEnd()) {
| 0 | ||||||||||||||||||
| 806 | QTextFragment fragment = iter.fragment(); | - | ||||||||||||||||||
| 807 | charFormat = fragment.charFormat(); | - | ||||||||||||||||||
| 808 | int pos = fragment.position(); | - | ||||||||||||||||||
| 809 | // text block and fragment may overlap, use the smallest common range | - | ||||||||||||||||||
| 810 | *startOffset = qMax(pos, blockStart); | - | ||||||||||||||||||
| 811 | *endOffset = qMin(pos + fragment.length(), blockEnd); | - | ||||||||||||||||||
| 812 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 813 | charFormat = block.charFormat(); | - | ||||||||||||||||||
| 814 | *startOffset = lastFragmentIndex; | - | ||||||||||||||||||
| 815 | *endOffset = blockEnd; | - | ||||||||||||||||||
| 816 | } never executed: end of block | 0 | ||||||||||||||||||
| 817 | Q_ASSERT(*startOffset <= offset); | - | ||||||||||||||||||
| 818 | Q_ASSERT(*endOffset >= offset); | - | ||||||||||||||||||
| 819 | - | |||||||||||||||||||
| 820 | QTextBlockFormat blockFormat = cursor.blockFormat(); | - | ||||||||||||||||||
| 821 | - | |||||||||||||||||||
| 822 | const QFont charFormatFont = charFormat.font(); | - | ||||||||||||||||||
| 823 | - | |||||||||||||||||||
| 824 | AttributeFormatter attrs; | - | ||||||||||||||||||
| 825 | QString family = charFormatFont.family(); | - | ||||||||||||||||||
| 826 | if (!family.isEmpty()) {
| 0 | ||||||||||||||||||
| 827 | family = family.replace('\\', QLatin1String("\\\\")); | - | ||||||||||||||||||
| 828 | family = family.replace(':', QLatin1String("\\:")); | - | ||||||||||||||||||
| 829 | family = family.replace(',', QLatin1String("\\,")); | - | ||||||||||||||||||
| 830 | family = family.replace('=', QLatin1String("\\=")); | - | ||||||||||||||||||
| 831 | family = family.replace(';', QLatin1String("\\;")); | - | ||||||||||||||||||
| 832 | family = family.replace('\"', QLatin1String("\\\"")); | - | ||||||||||||||||||
| 833 | attrs["font-family"] = QString::fromLatin1("\"%1\"").arg(family); | - | ||||||||||||||||||
| 834 | } never executed: end of block | 0 | ||||||||||||||||||
| 835 | - | |||||||||||||||||||
| 836 | int fontSize = int(charFormatFont.pointSize()); | - | ||||||||||||||||||
| 837 | if (fontSize)
| 0 | ||||||||||||||||||
| 838 | attrs["font-size"] = QString::fromLatin1("%1pt").arg(fontSize); never executed: attrs["font-size"] = QString::fromLatin1("%1pt").arg(fontSize); | 0 | ||||||||||||||||||
| 839 | - | |||||||||||||||||||
| 840 | //Different weight values are not handled | - | ||||||||||||||||||
| 841 | attrs["font-weight"] = QString::fromLatin1(charFormatFont.weight() > QFont::Normal ? "bold" : "normal"); | - | ||||||||||||||||||
| 842 | - | |||||||||||||||||||
| 843 | QFont::Style style = charFormatFont.style(); | - | ||||||||||||||||||
| 844 | attrs["font-style"] = QString::fromLatin1((style == QFont::StyleItalic) ? "italic" : ((style == QFont::StyleOblique) ? "oblique": "normal")); | - | ||||||||||||||||||
| 845 | - | |||||||||||||||||||
| 846 | QTextCharFormat::UnderlineStyle underlineStyle = charFormat.underlineStyle(); | - | ||||||||||||||||||
| 847 | if (underlineStyle == QTextCharFormat::NoUnderline && charFormatFont.underline()) // underline could still be set in the default font
| 0 | ||||||||||||||||||
| 848 | underlineStyle = QTextCharFormat::SingleUnderline; never executed: underlineStyle = QTextCharFormat::SingleUnderline; | 0 | ||||||||||||||||||
| 849 | QString underlineStyleValue; | - | ||||||||||||||||||
| 850 | switch (underlineStyle) { | - | ||||||||||||||||||
| 851 | case QTextCharFormat::NoUnderline: never executed: case QTextCharFormat::NoUnderline: | 0 | ||||||||||||||||||
| 852 | break; never executed: break; | 0 | ||||||||||||||||||
| 853 | case QTextCharFormat::SingleUnderline: never executed: case QTextCharFormat::SingleUnderline: | 0 | ||||||||||||||||||
| 854 | underlineStyleValue = QStringLiteral("solid"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 855 | break; never executed: break; | 0 | ||||||||||||||||||
| 856 | case QTextCharFormat::DashUnderline: never executed: case QTextCharFormat::DashUnderline: | 0 | ||||||||||||||||||
| 857 | underlineStyleValue = QStringLiteral("dash"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 858 | break; never executed: break; | 0 | ||||||||||||||||||
| 859 | case QTextCharFormat::DotLine: never executed: case QTextCharFormat::DotLine: | 0 | ||||||||||||||||||
| 860 | underlineStyleValue = QStringLiteral("dash"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 861 | break; never executed: break; | 0 | ||||||||||||||||||
| 862 | case QTextCharFormat::DashDotLine: never executed: case QTextCharFormat::DashDotLine: | 0 | ||||||||||||||||||
| 863 | underlineStyleValue = QStringLiteral("dot-dash"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 864 | break; never executed: break; | 0 | ||||||||||||||||||
| 865 | case QTextCharFormat::DashDotDotLine: never executed: case QTextCharFormat::DashDotDotLine: | 0 | ||||||||||||||||||
| 866 | underlineStyleValue = QStringLiteral("dot-dot-dash"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 867 | break; never executed: break; | 0 | ||||||||||||||||||
| 868 | case QTextCharFormat::WaveUnderline: never executed: case QTextCharFormat::WaveUnderline: | 0 | ||||||||||||||||||
| 869 | underlineStyleValue = QStringLiteral("wave"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 870 | break; never executed: break; | 0 | ||||||||||||||||||
| 871 | case QTextCharFormat::SpellCheckUnderline: never executed: case QTextCharFormat::SpellCheckUnderline: | 0 | ||||||||||||||||||
| 872 | underlineStyleValue = QStringLiteral("wave"); // this is not correct, but provides good approximation at least never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 873 | break; never executed: break; | 0 | ||||||||||||||||||
| 874 | default: never executed: default: | 0 | ||||||||||||||||||
| 875 | qWarning() << "Unknown QTextCharFormat::​UnderlineStyle value " << underlineStyle << " could not be translated to IAccessible2 value"; | - | ||||||||||||||||||
| 876 | break; never executed: break; | 0 | ||||||||||||||||||
| 877 | } | - | ||||||||||||||||||
| 878 | if (!underlineStyleValue.isNull()) {
| 0 | ||||||||||||||||||
| 879 | attrs["text-underline-style"] = underlineStyleValue; | - | ||||||||||||||||||
| 880 | attrs["text-underline-type"] = QStringLiteral("single"); // if underlineStyleValue is set, there is an underline, and Qt does not support other than single ones never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 881 | } // else both are "none" which is the default - no need to set them never executed: end of block | 0 | ||||||||||||||||||
| 882 | - | |||||||||||||||||||
| 883 | if (block.textDirection() == Qt::RightToLeft)
| 0 | ||||||||||||||||||
| 884 | attrs["writing-mode"] = QStringLiteral("rl"); never executed: attrs["writing-mode"] = ([]() -> QString { enum { Size = sizeof(u"" "rl")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "rl" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 885 | - | |||||||||||||||||||
| 886 | QTextCharFormat::VerticalAlignment alignment = charFormat.verticalAlignment(); | - | ||||||||||||||||||
| 887 | attrs["text-position"] = QString::fromLatin1((alignment == QTextCharFormat::AlignSubScript) ? "sub" : ((alignment == QTextCharFormat::AlignSuperScript) ? "super" : "baseline" )); | - | ||||||||||||||||||
| 888 | - | |||||||||||||||||||
| 889 | QBrush background = charFormat.background(); | - | ||||||||||||||||||
| 890 | if (background.style() == Qt::SolidPattern) {
| 0 | ||||||||||||||||||
| 891 | attrs["background-color"] = QString::fromLatin1("rgb(%1,%2,%3)").arg(background.color().red()).arg(background.color().green()).arg(background.color().blue()); | - | ||||||||||||||||||
| 892 | } never executed: end of block | 0 | ||||||||||||||||||
| 893 | - | |||||||||||||||||||
| 894 | QBrush foreground = charFormat.foreground(); | - | ||||||||||||||||||
| 895 | if (foreground.style() == Qt::SolidPattern) {
| 0 | ||||||||||||||||||
| 896 | attrs["color"] = QString::fromLatin1("rgb(%1,%2,%3)").arg(foreground.color().red()).arg(foreground.color().green()).arg(foreground.color().blue()); | - | ||||||||||||||||||
| 897 | } never executed: end of block | 0 | ||||||||||||||||||
| 898 | - | |||||||||||||||||||
| 899 | switch (blockFormat.alignment() & (Qt::AlignLeft | Qt::AlignRight | Qt::AlignHCenter | Qt::AlignJustify)) { | - | ||||||||||||||||||
| 900 | case Qt::AlignLeft: never executed: case Qt::AlignLeft: | 0 | ||||||||||||||||||
| 901 | attrs["text-align"] = QStringLiteral("left"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 902 | break; never executed: break; | 0 | ||||||||||||||||||
| 903 | case Qt::AlignRight: never executed: case Qt::AlignRight: | 0 | ||||||||||||||||||
| 904 | attrs["text-align"] = QStringLiteral("right"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 905 | break; never executed: break; | 0 | ||||||||||||||||||
| 906 | case Qt::AlignHCenter: never executed: case Qt::AlignHCenter: | 0 | ||||||||||||||||||
| 907 | attrs["text-align"] = QStringLiteral("center"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 908 | break; never executed: break; | 0 | ||||||||||||||||||
| 909 | case Qt::AlignJustify: never executed: case Qt::AlignJustify: | 0 | ||||||||||||||||||
| 910 | attrs["text-align"] = QStringLiteral("justify"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 911 | break; never executed: break; | 0 | ||||||||||||||||||
| 912 | } | - | ||||||||||||||||||
| 913 | - | |||||||||||||||||||
| 914 | return attrs.toFormatted(); never executed: return attrs.toFormatted(); | 0 | ||||||||||||||||||
| 915 | } | - | ||||||||||||||||||
| 916 | - | |||||||||||||||||||
| 917 | int QAccessibleTextWidget::cursorPosition() const | - | ||||||||||||||||||
| 918 | { | - | ||||||||||||||||||
| 919 | return textCursor().position(); never executed: return textCursor().position(); | 0 | ||||||||||||||||||
| 920 | } | - | ||||||||||||||||||
| 921 | - | |||||||||||||||||||
| 922 | void QAccessibleTextWidget::selection(int selectionIndex, int *startOffset, int *endOffset) const | - | ||||||||||||||||||
| 923 | { | - | ||||||||||||||||||
| 924 | *startOffset = *endOffset = 0; | - | ||||||||||||||||||
| 925 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
| 926 | - | |||||||||||||||||||
| 927 | if (selectionIndex != 0 || !cursor.hasSelection())
| 0 | ||||||||||||||||||
| 928 | return; never executed: return; | 0 | ||||||||||||||||||
| 929 | - | |||||||||||||||||||
| 930 | *startOffset = cursor.selectionStart(); | - | ||||||||||||||||||
| 931 | *endOffset = cursor.selectionEnd(); | - | ||||||||||||||||||
| 932 | } never executed: end of block | 0 | ||||||||||||||||||
| 933 | - | |||||||||||||||||||
| 934 | QString QAccessibleTextWidget::text(int startOffset, int endOffset) const | - | ||||||||||||||||||
| 935 | { | - | ||||||||||||||||||
| 936 | QTextCursor cursor(textCursor()); | - | ||||||||||||||||||
| 937 | - | |||||||||||||||||||
| 938 | cursor.setPosition(startOffset, QTextCursor::MoveAnchor); | - | ||||||||||||||||||
| 939 | cursor.setPosition(endOffset, QTextCursor::KeepAnchor); | - | ||||||||||||||||||
| 940 | - | |||||||||||||||||||
| 941 | return cursor.selectedText().replace(QChar(QChar::ParagraphSeparator), QLatin1Char('\n')); never executed: return cursor.selectedText().replace(QChar(QChar::ParagraphSeparator), QLatin1Char('\n')); | 0 | ||||||||||||||||||
| 942 | } | - | ||||||||||||||||||
| 943 | - | |||||||||||||||||||
| 944 | QPoint QAccessibleTextWidget::scrollBarPosition() const | - | ||||||||||||||||||
| 945 | { | - | ||||||||||||||||||
| 946 | return QPoint(0, 0); never executed: return QPoint(0, 0); | 0 | ||||||||||||||||||
| 947 | } | - | ||||||||||||||||||
| 948 | - | |||||||||||||||||||
| 949 | - | |||||||||||||||||||
| 950 | QString QAccessibleTextWidget::textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, | - | ||||||||||||||||||
| 951 | int *startOffset, int *endOffset) const | - | ||||||||||||||||||
| 952 | { | - | ||||||||||||||||||
| 953 | Q_ASSERT(startOffset); | - | ||||||||||||||||||
| 954 | Q_ASSERT(endOffset); | - | ||||||||||||||||||
| 955 | - | |||||||||||||||||||
| 956 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
| 957 | cursor.setPosition(offset); | - | ||||||||||||||||||
| 958 | QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); | - | ||||||||||||||||||
| 959 | cursor.setPosition(boundaries.first - 1); | - | ||||||||||||||||||
| 960 | boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); | - | ||||||||||||||||||
| 961 | - | |||||||||||||||||||
| 962 | *startOffset = boundaries.first; | - | ||||||||||||||||||
| 963 | *endOffset = boundaries.second; | - | ||||||||||||||||||
| 964 | - | |||||||||||||||||||
| 965 | return text(boundaries.first, boundaries.second); never executed: return text(boundaries.first, boundaries.second); | 0 | ||||||||||||||||||
| 966 | } | - | ||||||||||||||||||
| 967 | - | |||||||||||||||||||
| 968 | - | |||||||||||||||||||
| 969 | QString QAccessibleTextWidget::textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, | - | ||||||||||||||||||
| 970 | int *startOffset, int *endOffset) const | - | ||||||||||||||||||
| 971 | { | - | ||||||||||||||||||
| 972 | Q_ASSERT(startOffset); | - | ||||||||||||||||||
| 973 | Q_ASSERT(endOffset); | - | ||||||||||||||||||
| 974 | - | |||||||||||||||||||
| 975 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
| 976 | cursor.setPosition(offset); | - | ||||||||||||||||||
| 977 | QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); | - | ||||||||||||||||||
| 978 | cursor.setPosition(boundaries.second); | - | ||||||||||||||||||
| 979 | boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); | - | ||||||||||||||||||
| 980 | - | |||||||||||||||||||
| 981 | *startOffset = boundaries.first; | - | ||||||||||||||||||
| 982 | *endOffset = boundaries.second; | - | ||||||||||||||||||
| 983 | - | |||||||||||||||||||
| 984 | return text(boundaries.first, boundaries.second); never executed: return text(boundaries.first, boundaries.second); | 0 | ||||||||||||||||||
| 985 | } | - | ||||||||||||||||||
| 986 | - | |||||||||||||||||||
| 987 | QString QAccessibleTextWidget::textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, | - | ||||||||||||||||||
| 988 | int *startOffset, int *endOffset) const | - | ||||||||||||||||||
| 989 | { | - | ||||||||||||||||||
| 990 | Q_ASSERT(startOffset); | - | ||||||||||||||||||
| 991 | Q_ASSERT(endOffset); | - | ||||||||||||||||||
| 992 | - | |||||||||||||||||||
| 993 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
| 994 | cursor.setPosition(offset); | - | ||||||||||||||||||
| 995 | QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); | - | ||||||||||||||||||
| 996 | - | |||||||||||||||||||
| 997 | *startOffset = boundaries.first; | - | ||||||||||||||||||
| 998 | *endOffset = boundaries.second; | - | ||||||||||||||||||
| 999 | - | |||||||||||||||||||
| 1000 | return text(boundaries.first, boundaries.second); never executed: return text(boundaries.first, boundaries.second); | 0 | ||||||||||||||||||
| 1001 | } | - | ||||||||||||||||||
| 1002 | - | |||||||||||||||||||
| 1003 | void QAccessibleTextWidget::setCursorPosition(int position) | - | ||||||||||||||||||
| 1004 | { | - | ||||||||||||||||||
| 1005 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
| 1006 | cursor.setPosition(position); | - | ||||||||||||||||||
| 1007 | setTextCursor(cursor); | - | ||||||||||||||||||
| 1008 | } never executed: end of block | 0 | ||||||||||||||||||
| 1009 | - | |||||||||||||||||||
| 1010 | void QAccessibleTextWidget::addSelection(int startOffset, int endOffset) | - | ||||||||||||||||||
| 1011 | { | - | ||||||||||||||||||
| 1012 | setSelection(0, startOffset, endOffset); | - | ||||||||||||||||||
| 1013 | } never executed: end of block | 0 | ||||||||||||||||||
| 1014 | - | |||||||||||||||||||
| 1015 | void QAccessibleTextWidget::removeSelection(int selectionIndex) | - | ||||||||||||||||||
| 1016 | { | - | ||||||||||||||||||
| 1017 | if (selectionIndex != 0)
| 0 | ||||||||||||||||||
| 1018 | return; never executed: return; | 0 | ||||||||||||||||||
| 1019 | - | |||||||||||||||||||
| 1020 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
| 1021 | cursor.clearSelection(); | - | ||||||||||||||||||
| 1022 | setTextCursor(cursor); | - | ||||||||||||||||||
| 1023 | } never executed: end of block | 0 | ||||||||||||||||||
| 1024 | - | |||||||||||||||||||
| 1025 | void QAccessibleTextWidget::setSelection(int selectionIndex, int startOffset, int endOffset) | - | ||||||||||||||||||
| 1026 | { | - | ||||||||||||||||||
| 1027 | if (selectionIndex != 0)
| 0 | ||||||||||||||||||
| 1028 | return; never executed: return; | 0 | ||||||||||||||||||
| 1029 | - | |||||||||||||||||||
| 1030 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
| 1031 | cursor.setPosition(startOffset, QTextCursor::MoveAnchor); | - | ||||||||||||||||||
| 1032 | cursor.setPosition(endOffset, QTextCursor::KeepAnchor); | - | ||||||||||||||||||
| 1033 | setTextCursor(cursor); | - | ||||||||||||||||||
| 1034 | } never executed: end of block | 0 | ||||||||||||||||||
| 1035 | - | |||||||||||||||||||
| 1036 | int QAccessibleTextWidget::characterCount() const | - | ||||||||||||||||||
| 1037 | { | - | ||||||||||||||||||
| 1038 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
| 1039 | cursor.movePosition(QTextCursor::End); | - | ||||||||||||||||||
| 1040 | return cursor.position(); never executed: return cursor.position(); | 0 | ||||||||||||||||||
| 1041 | } | - | ||||||||||||||||||
| 1042 | - | |||||||||||||||||||
| 1043 | QTextCursor QAccessibleTextWidget::textCursorForRange(int startOffset, int endOffset) const | - | ||||||||||||||||||
| 1044 | { | - | ||||||||||||||||||
| 1045 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
| 1046 | cursor.setPosition(startOffset, QTextCursor::MoveAnchor); | - | ||||||||||||||||||
| 1047 | cursor.setPosition(endOffset, QTextCursor::KeepAnchor); | - | ||||||||||||||||||
| 1048 | - | |||||||||||||||||||
| 1049 | return cursor; never executed: return cursor; | 0 | ||||||||||||||||||
| 1050 | } | - | ||||||||||||||||||
| 1051 | - | |||||||||||||||||||
| 1052 | void QAccessibleTextWidget::deleteText(int startOffset, int endOffset) | - | ||||||||||||||||||
| 1053 | { | - | ||||||||||||||||||
| 1054 | QTextCursor cursor = textCursorForRange(startOffset, endOffset); | - | ||||||||||||||||||
| 1055 | cursor.removeSelectedText(); | - | ||||||||||||||||||
| 1056 | } never executed: end of block | 0 | ||||||||||||||||||
| 1057 | - | |||||||||||||||||||
| 1058 | void QAccessibleTextWidget::insertText(int offset, const QString &text) | - | ||||||||||||||||||
| 1059 | { | - | ||||||||||||||||||
| 1060 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
| 1061 | cursor.setPosition(offset); | - | ||||||||||||||||||
| 1062 | cursor.insertText(text); | - | ||||||||||||||||||
| 1063 | } never executed: end of block | 0 | ||||||||||||||||||
| 1064 | - | |||||||||||||||||||
| 1065 | void QAccessibleTextWidget::replaceText(int startOffset, int endOffset, const QString &text) | - | ||||||||||||||||||
| 1066 | { | - | ||||||||||||||||||
| 1067 | QTextCursor cursor = textCursorForRange(startOffset, endOffset); | - | ||||||||||||||||||
| 1068 | cursor.removeSelectedText(); | - | ||||||||||||||||||
| 1069 | cursor.insertText(text); | - | ||||||||||||||||||
| 1070 | } never executed: end of block | 0 | ||||||||||||||||||
| 1071 | #endif // QT_NO_CURSOR | - | ||||||||||||||||||
| 1072 | - | |||||||||||||||||||
| 1073 | - | |||||||||||||||||||
| 1074 | #ifndef QT_NO_MAINWINDOW | - | ||||||||||||||||||
| 1075 | QAccessibleMainWindow::QAccessibleMainWindow(QWidget *widget) | - | ||||||||||||||||||
| 1076 | : QAccessibleWidget(widget, QAccessible::Window) { } never executed: end of block | 0 | ||||||||||||||||||
| 1077 | - | |||||||||||||||||||
| 1078 | QAccessibleInterface *QAccessibleMainWindow::child(int index) const | - | ||||||||||||||||||
| 1079 | { | - | ||||||||||||||||||
| 1080 | QList<QWidget*> kids = childWidgets(mainWindow()); | - | ||||||||||||||||||
| 1081 | if (index >= 0 && index < kids.count()) {
| 0 | ||||||||||||||||||
| 1082 | return QAccessible::queryAccessibleInterface(kids.at(index)); never executed: return QAccessible::queryAccessibleInterface(kids.at(index)); | 0 | ||||||||||||||||||
| 1083 | } | - | ||||||||||||||||||
| 1084 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 1085 | } | - | ||||||||||||||||||
| 1086 | - | |||||||||||||||||||
| 1087 | int QAccessibleMainWindow::childCount() const | - | ||||||||||||||||||
| 1088 | { | - | ||||||||||||||||||
| 1089 | QList<QWidget*> kids = childWidgets(mainWindow()); | - | ||||||||||||||||||
| 1090 | return kids.count(); never executed: return kids.count(); | 0 | ||||||||||||||||||
| 1091 | } | - | ||||||||||||||||||
| 1092 | - | |||||||||||||||||||
| 1093 | int QAccessibleMainWindow::indexOfChild(const QAccessibleInterface *iface) const | - | ||||||||||||||||||
| 1094 | { | - | ||||||||||||||||||
| 1095 | QList<QWidget*> kids = childWidgets(mainWindow()); | - | ||||||||||||||||||
| 1096 | return kids.indexOf(static_cast<QWidget*>(iface->object())); never executed: return kids.indexOf(static_cast<QWidget*>(iface->object())); | 0 | ||||||||||||||||||
| 1097 | } | - | ||||||||||||||||||
| 1098 | - | |||||||||||||||||||
| 1099 | QAccessibleInterface *QAccessibleMainWindow::childAt(int x, int y) const | - | ||||||||||||||||||
| 1100 | { | - | ||||||||||||||||||
| 1101 | QWidget *w = widget(); | - | ||||||||||||||||||
| 1102 | if (!w->isVisible())
| 0 | ||||||||||||||||||
| 1103 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 1104 | QPoint gp = w->mapToGlobal(QPoint(0, 0)); | - | ||||||||||||||||||
| 1105 | if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y))
| 0 | ||||||||||||||||||
| 1106 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 1107 | - | |||||||||||||||||||
| 1108 | const QWidgetList kids = childWidgets(mainWindow()); | - | ||||||||||||||||||
| 1109 | QPoint rp = mainWindow()->mapFromGlobal(QPoint(x, y)); | - | ||||||||||||||||||
| 1110 | for (QWidget *child : kids) { | - | ||||||||||||||||||
| 1111 | if (!child->isWindow() && !child->isHidden() && child->geometry().contains(rp)) {
| 0 | ||||||||||||||||||
| 1112 | return QAccessible::queryAccessibleInterface(child); never executed: return QAccessible::queryAccessibleInterface(child); | 0 | ||||||||||||||||||
| 1113 | } | - | ||||||||||||||||||
| 1114 | } never executed: end of block | 0 | ||||||||||||||||||
| 1115 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 1116 | } | - | ||||||||||||||||||
| 1117 | - | |||||||||||||||||||
| 1118 | QMainWindow *QAccessibleMainWindow::mainWindow() const | - | ||||||||||||||||||
| 1119 | { | - | ||||||||||||||||||
| 1120 | return qobject_cast<QMainWindow *>(object()); never executed: return qobject_cast<QMainWindow *>(object()); | 0 | ||||||||||||||||||
| 1121 | } | - | ||||||||||||||||||
| 1122 | - | |||||||||||||||||||
| 1123 | #endif //QT_NO_MAINWINDOW | - | ||||||||||||||||||
| 1124 | - | |||||||||||||||||||
| 1125 | QT_END_NAMESPACE | - | ||||||||||||||||||
| 1126 | - | |||||||||||||||||||
| 1127 | #endif // QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |