| 1 | // Copyright (C) 2020 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | |
| 5 | #if 0 |
| 6 | // keep existing syncqt header working after the move of the class |
| 7 | // into qaccessible_base |
| 8 | #pragma qt_class(QAccessible) |
| 9 | #endif |
| 10 | |
| 11 | #ifndef QACCESSIBLE_H |
| 12 | #define QACCESSIBLE_H |
| 13 | #include <QtGui/qtguiglobal.h> |
| 14 | |
| 15 | #if QT_CONFIG(accessibility) |
| 16 | |
| 17 | #include <QtCore/qcoreapplication.h> |
| 18 | #include <QtCore/qdebug.h> |
| 19 | #include <QtCore/qglobal.h> |
| 20 | #include <QtCore/qlist.h> |
| 21 | #include <QtCore/qobject.h> |
| 22 | #include <QtCore/qrect.h> |
| 23 | #include <QtCore/qset.h> |
| 24 | #include <QtCore/qvariant.h> |
| 25 | #include <QtGui/qcolor.h> |
| 26 | #include <QtGui/qevent.h> |
| 27 | #include <QtGui/qaccessible_base.h> |
| 28 | |
| 29 | QT_BEGIN_NAMESPACE |
| 30 | |
| 31 | class QAccessibleInterface; |
| 32 | class QAccessibleEvent; |
| 33 | class QWindow; |
| 34 | class QTextCursor; |
| 35 | |
| 36 | class QAccessible2Interface; |
| 37 | class QAccessibleTextInterface; |
| 38 | class QAccessibleEditableTextInterface; |
| 39 | class QAccessibleValueInterface; |
| 40 | class QAccessibleActionInterface; |
| 41 | class QAccessibleImageInterface; |
| 42 | class QAccessibleTableInterface; |
| 43 | class QAccessibleTableCellInterface; |
| 44 | class QAccessibleHyperlinkInterface; |
| 45 | class QAccessibleSelectionInterface; |
| 46 | class QAccessibleAttributesInterface; |
| 47 | class QAccessibleTableModelChangeEvent; |
| 48 | |
| 49 | class Q_GUI_EXPORT QAccessibleInterface |
| 50 | { |
| 51 | protected: |
| 52 | virtual ~QAccessibleInterface(); |
| 53 | |
| 54 | public: |
| 55 | // check for valid pointers |
| 56 | virtual bool isValid() const = 0; |
| 57 | virtual QObject *object() const = 0; |
| 58 | virtual QWindow *window() const; |
| 59 | |
| 60 | // relations |
| 61 | virtual QList<QPair<QAccessibleInterface *, QAccessible::Relation>> |
| 62 | relations(QAccessible::Relation match = QAccessible::AllRelations) const; |
| 63 | virtual QAccessibleInterface *focusChild() const; |
| 64 | |
| 65 | virtual QAccessibleInterface *childAt(int x, int y) const = 0; |
| 66 | |
| 67 | // navigation, hierarchy |
| 68 | virtual QAccessibleInterface *parent() const = 0; |
| 69 | virtual QAccessibleInterface *child(int index) const = 0; |
| 70 | virtual int childCount() const = 0; |
| 71 | virtual int indexOfChild(const QAccessibleInterface *) const = 0; |
| 72 | |
| 73 | // properties and state |
| 74 | virtual QString text(QAccessible::Text t) const = 0; |
| 75 | virtual void setText(QAccessible::Text t, const QString &text) = 0; |
| 76 | virtual QRect rect() const = 0; |
| 77 | virtual QAccessible::Role role() const = 0; |
| 78 | virtual QAccessible::State state() const = 0; |
| 79 | |
| 80 | virtual QColor foregroundColor() const; |
| 81 | virtual QColor backgroundColor() const; |
| 82 | |
| 83 | inline QAccessibleTextInterface *textInterface() |
| 84 | { return reinterpret_cast<QAccessibleTextInterface *>(interface_cast(QAccessible::TextInterface)); } |
| 85 | |
| 86 | inline QAccessibleEditableTextInterface *editableTextInterface() |
| 87 | { return reinterpret_cast<QAccessibleEditableTextInterface *>(interface_cast(QAccessible::EditableTextInterface)); } |
| 88 | |
| 89 | inline QAccessibleValueInterface *valueInterface() |
| 90 | { return reinterpret_cast<QAccessibleValueInterface *>(interface_cast(QAccessible::ValueInterface)); } |
| 91 | |
| 92 | inline QAccessibleActionInterface *actionInterface() |
| 93 | { return reinterpret_cast<QAccessibleActionInterface *>(interface_cast(QAccessible::ActionInterface)); } |
| 94 | |
| 95 | inline QAccessibleImageInterface *imageInterface() |
| 96 | { return reinterpret_cast<QAccessibleImageInterface *>(interface_cast(QAccessible::ImageInterface)); } |
| 97 | |
| 98 | inline QAccessibleTableInterface *tableInterface() |
| 99 | { return reinterpret_cast<QAccessibleTableInterface *>(interface_cast(QAccessible::TableInterface)); } |
| 100 | |
| 101 | inline QAccessibleTableCellInterface *tableCellInterface() |
| 102 | { return reinterpret_cast<QAccessibleTableCellInterface *>(interface_cast(QAccessible::TableCellInterface)); } |
| 103 | |
| 104 | inline QAccessibleHyperlinkInterface *hyperlinkInterface() |
| 105 | { return reinterpret_cast<QAccessibleHyperlinkInterface *>(interface_cast(QAccessible::HyperlinkInterface)); } |
| 106 | |
| 107 | inline QAccessibleSelectionInterface *selectionInterface() |
| 108 | { return reinterpret_cast<QAccessibleSelectionInterface *>(interface_cast(QAccessible::SelectionInterface)); } |
| 109 | |
| 110 | inline QAccessibleAttributesInterface *attributesInterface() |
| 111 | { return reinterpret_cast<QAccessibleAttributesInterface *>(interface_cast(QAccessible::AttributesInterface)); } |
| 112 | |
| 113 | virtual void virtual_hook(int id, void *data); |
| 114 | |
| 115 | virtual void *interface_cast(QAccessible::InterfaceType) |
| 116 | { return nullptr; } |
| 117 | |
| 118 | protected: |
| 119 | friend class QAccessibleCache; |
| 120 | }; |
| 121 | |
| 122 | class Q_GUI_EXPORT QAccessibleTextInterface |
| 123 | { |
| 124 | public: |
| 125 | virtual ~QAccessibleTextInterface(); |
| 126 | // selection |
| 127 | virtual void selection(int selectionIndex, int *startOffset, int *endOffset) const = 0; |
| 128 | virtual int selectionCount() const = 0; |
| 129 | virtual void addSelection(int startOffset, int endOffset) = 0; |
| 130 | virtual void removeSelection(int selectionIndex) = 0; |
| 131 | virtual void setSelection(int selectionIndex, int startOffset, int endOffset) = 0; |
| 132 | |
| 133 | // cursor |
| 134 | virtual int cursorPosition() const = 0; |
| 135 | virtual void setCursorPosition(int position) = 0; |
| 136 | |
| 137 | // text |
| 138 | virtual QString text(int startOffset, int endOffset) const = 0; |
| 139 | virtual QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, |
| 140 | int *startOffset, int *endOffset) const; |
| 141 | virtual QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, |
| 142 | int *startOffset, int *endOffset) const; |
| 143 | virtual QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, |
| 144 | int *startOffset, int *endOffset) const; |
| 145 | virtual int characterCount() const = 0; |
| 146 | |
| 147 | // character <-> geometry |
| 148 | virtual QRect characterRect(int offset) const = 0; |
| 149 | virtual int offsetAtPoint(const QPoint &point) const = 0; |
| 150 | |
| 151 | virtual void scrollToSubstring(int startIndex, int endIndex) = 0; |
| 152 | virtual QString attributes(int offset, int *startOffset, int *endOffset) const = 0; |
| 153 | }; |
| 154 | |
| 155 | class Q_GUI_EXPORT QAccessibleEditableTextInterface |
| 156 | { |
| 157 | public: |
| 158 | virtual ~QAccessibleEditableTextInterface(); |
| 159 | |
| 160 | virtual void deleteText(int startOffset, int endOffset) = 0; |
| 161 | virtual void insertText(int offset, const QString &text) = 0; |
| 162 | virtual void replaceText(int startOffset, int endOffset, const QString &text) = 0; |
| 163 | }; |
| 164 | |
| 165 | class Q_GUI_EXPORT QAccessibleValueInterface |
| 166 | { |
| 167 | public: |
| 168 | virtual ~QAccessibleValueInterface(); |
| 169 | |
| 170 | virtual QVariant currentValue() const = 0; |
| 171 | virtual void setCurrentValue(const QVariant &value) = 0; |
| 172 | virtual QVariant maximumValue() const = 0; |
| 173 | virtual QVariant minimumValue() const = 0; |
| 174 | virtual QVariant minimumStepSize() const = 0; |
| 175 | }; |
| 176 | |
| 177 | class Q_GUI_EXPORT QAccessibleTableCellInterface |
| 178 | { |
| 179 | public: |
| 180 | virtual ~QAccessibleTableCellInterface(); |
| 181 | |
| 182 | virtual bool isSelected() const = 0; |
| 183 | |
| 184 | virtual QList<QAccessibleInterface*> columnHeaderCells() const = 0; |
| 185 | virtual QList<QAccessibleInterface*> () const = 0; |
| 186 | virtual int columnIndex() const = 0; |
| 187 | virtual int rowIndex() const = 0; |
| 188 | virtual int columnExtent() const = 0; |
| 189 | virtual int rowExtent() const = 0; |
| 190 | |
| 191 | virtual QAccessibleInterface* table() const = 0; |
| 192 | }; |
| 193 | |
| 194 | class Q_GUI_EXPORT QAccessibleTableInterface |
| 195 | { |
| 196 | public: |
| 197 | virtual ~QAccessibleTableInterface(); |
| 198 | |
| 199 | virtual QAccessibleInterface *caption() const = 0; |
| 200 | virtual QAccessibleInterface *summary() const = 0; |
| 201 | |
| 202 | virtual QAccessibleInterface *cellAt (int row, int column) const = 0; |
| 203 | virtual int selectedCellCount() const = 0; |
| 204 | virtual QList<QAccessibleInterface*> selectedCells() const = 0; |
| 205 | |
| 206 | virtual QString columnDescription(int column) const = 0; |
| 207 | virtual QString rowDescription(int row) const = 0; |
| 208 | virtual int selectedColumnCount() const = 0; |
| 209 | virtual int selectedRowCount() const = 0; |
| 210 | virtual int columnCount() const = 0; |
| 211 | virtual int rowCount() const = 0; |
| 212 | virtual QList<int> selectedColumns() const = 0; |
| 213 | virtual QList<int> selectedRows() const = 0; |
| 214 | virtual bool isColumnSelected(int column) const = 0; |
| 215 | virtual bool isRowSelected(int row) const = 0; |
| 216 | virtual bool selectRow(int row) = 0; |
| 217 | virtual bool selectColumn(int column) = 0; |
| 218 | virtual bool unselectRow(int row) = 0; |
| 219 | virtual bool unselectColumn(int column) = 0; |
| 220 | |
| 221 | virtual void modelChange(QAccessibleTableModelChangeEvent *event) = 0; |
| 222 | |
| 223 | protected: |
| 224 | friend class QAbstractItemView; |
| 225 | friend class QAbstractItemViewPrivate; |
| 226 | }; |
| 227 | |
| 228 | class Q_GUI_EXPORT QAccessibleActionInterface |
| 229 | { |
| 230 | Q_DECLARE_TR_FUNCTIONS(QAccessibleActionInterface) |
| 231 | public: |
| 232 | virtual ~QAccessibleActionInterface(); |
| 233 | |
| 234 | virtual QStringList actionNames() const = 0; |
| 235 | virtual QString localizedActionName(const QString &name) const; |
| 236 | virtual QString localizedActionDescription(const QString &name) const; |
| 237 | virtual void doAction(const QString &actionName) = 0; |
| 238 | virtual QStringList keyBindingsForAction(const QString &actionName) const = 0; |
| 239 | |
| 240 | static const QString &pressAction(); |
| 241 | static const QString &increaseAction(); |
| 242 | static const QString &decreaseAction(); |
| 243 | static const QString &(); |
| 244 | static const QString &setFocusAction(); |
| 245 | static const QString &toggleAction(); |
| 246 | static QString scrollLeftAction(); |
| 247 | static QString scrollRightAction(); |
| 248 | static QString scrollUpAction(); |
| 249 | static QString scrollDownAction(); |
| 250 | static QString nextPageAction(); |
| 251 | static QString previousPageAction(); |
| 252 | }; |
| 253 | |
| 254 | class Q_GUI_EXPORT QAccessibleImageInterface |
| 255 | { |
| 256 | public: |
| 257 | virtual ~QAccessibleImageInterface(); |
| 258 | |
| 259 | virtual QString imageDescription() const = 0; |
| 260 | virtual QSize imageSize() const = 0; |
| 261 | virtual QPoint imagePosition() const = 0; |
| 262 | }; |
| 263 | |
| 264 | class Q_GUI_EXPORT QAccessibleHyperlinkInterface |
| 265 | { |
| 266 | public: |
| 267 | virtual ~QAccessibleHyperlinkInterface(); |
| 268 | |
| 269 | virtual QString anchor() const = 0; |
| 270 | virtual QString anchorTarget() const = 0; |
| 271 | virtual int startIndex() const = 0; |
| 272 | virtual int endIndex() const = 0; |
| 273 | virtual bool isValid() const = 0; |
| 274 | }; |
| 275 | |
| 276 | class Q_GUI_EXPORT QAccessibleSelectionInterface |
| 277 | { |
| 278 | public: |
| 279 | virtual ~QAccessibleSelectionInterface(); |
| 280 | |
| 281 | virtual int selectedItemCount() const = 0; |
| 282 | virtual QList<QAccessibleInterface*> selectedItems() const = 0; |
| 283 | virtual QAccessibleInterface* selectedItem(int selectionIndex) const; |
| 284 | virtual bool isSelected(QAccessibleInterface *childItem) const; |
| 285 | virtual bool select(QAccessibleInterface *childItem) = 0; |
| 286 | virtual bool unselect(QAccessibleInterface *childItem) = 0; |
| 287 | virtual bool selectAll() = 0; |
| 288 | virtual bool clear() = 0; |
| 289 | }; |
| 290 | |
| 291 | class Q_GUI_EXPORT QAccessibleAttributesInterface |
| 292 | { |
| 293 | public: |
| 294 | virtual ~QAccessibleAttributesInterface(); |
| 295 | virtual QList<QAccessible::Attribute> attributeKeys() const = 0; |
| 296 | virtual QVariant attributeValue(QAccessible::Attribute key) const = 0; |
| 297 | }; |
| 298 | |
| 299 | |
| 300 | class Q_GUI_EXPORT QAccessibleEvent |
| 301 | { |
| 302 | Q_DISABLE_COPY(QAccessibleEvent) |
| 303 | public: |
| 304 | |
| 305 | inline QAccessibleEvent(QObject *obj, QAccessible::Event typ) |
| 306 | : m_type(typ), m_object(obj), m_child(-1) |
| 307 | { |
| 308 | Q_ASSERT(obj); |
| 309 | // All events below have a subclass of QAccessibleEvent. |
| 310 | // Use the subclass, since it's expected that it's possible to cast to that. |
| 311 | Q_ASSERT(m_type != QAccessible::ValueChanged); |
| 312 | Q_ASSERT(m_type != QAccessible::StateChanged); |
| 313 | Q_ASSERT(m_type != QAccessible::TextCaretMoved); |
| 314 | Q_ASSERT(m_type != QAccessible::TextSelectionChanged); |
| 315 | Q_ASSERT(m_type != QAccessible::TextInserted); |
| 316 | Q_ASSERT(m_type != QAccessible::TextRemoved); |
| 317 | Q_ASSERT(m_type != QAccessible::TextUpdated); |
| 318 | Q_ASSERT(m_type != QAccessible::TableModelChanged); |
| 319 | Q_ASSERT(m_type != QAccessible::Announcement); |
| 320 | } |
| 321 | |
| 322 | inline QAccessibleEvent(QAccessibleInterface *iface, QAccessible::Event typ) |
| 323 | : m_type(typ) |
| 324 | { |
| 325 | Q_ASSERT(iface); |
| 326 | Q_ASSERT(m_type != QAccessible::ValueChanged); |
| 327 | Q_ASSERT(m_type != QAccessible::StateChanged); |
| 328 | Q_ASSERT(m_type != QAccessible::TextCaretMoved); |
| 329 | Q_ASSERT(m_type != QAccessible::TextSelectionChanged); |
| 330 | Q_ASSERT(m_type != QAccessible::TextInserted); |
| 331 | Q_ASSERT(m_type != QAccessible::TextRemoved); |
| 332 | Q_ASSERT(m_type != QAccessible::TextUpdated); |
| 333 | Q_ASSERT(m_type != QAccessible::TableModelChanged); |
| 334 | Q_ASSERT(m_type != QAccessible::Announcement); |
| 335 | m_uniqueId = QAccessible::uniqueId(iface); |
| 336 | m_object = iface->object(); |
| 337 | } |
| 338 | |
| 339 | virtual ~QAccessibleEvent(); |
| 340 | |
| 341 | QAccessible::Event type() const { return m_type; } |
| 342 | QObject *object() const { return m_object; } |
| 343 | QAccessible::Id uniqueId() const; |
| 344 | |
| 345 | void setChild(int chld) { m_child = chld; } |
| 346 | int child() const { return m_child; } |
| 347 | |
| 348 | virtual QAccessibleInterface *accessibleInterface() const; |
| 349 | |
| 350 | protected: |
| 351 | QAccessible::Event m_type; |
| 352 | QObject *m_object; |
| 353 | union { |
| 354 | int m_child; |
| 355 | QAccessible::Id m_uniqueId; |
| 356 | }; |
| 357 | |
| 358 | friend class QTestAccessibility; |
| 359 | }; |
| 360 | |
| 361 | class Q_GUI_EXPORT QAccessibleStateChangeEvent :public QAccessibleEvent |
| 362 | { |
| 363 | public: |
| 364 | inline QAccessibleStateChangeEvent(QObject *obj, QAccessible::State state) |
| 365 | : QAccessibleEvent(obj, QAccessible::InvalidEvent), m_changedStates(state) |
| 366 | { |
| 367 | m_type = QAccessible::StateChanged; |
| 368 | } |
| 369 | inline QAccessibleStateChangeEvent(QAccessibleInterface *iface, QAccessible::State state) |
| 370 | : QAccessibleEvent(iface, QAccessible::InvalidEvent), m_changedStates(state) |
| 371 | { |
| 372 | m_type = QAccessible::StateChanged; |
| 373 | } |
| 374 | ~QAccessibleStateChangeEvent(); |
| 375 | |
| 376 | QAccessible::State changedStates() const { |
| 377 | return m_changedStates; |
| 378 | } |
| 379 | |
| 380 | protected: |
| 381 | QAccessible::State m_changedStates; |
| 382 | }; |
| 383 | |
| 384 | // Update the cursor and optionally the selection. |
| 385 | class Q_GUI_EXPORT QAccessibleTextCursorEvent : public QAccessibleEvent |
| 386 | { |
| 387 | public: |
| 388 | inline QAccessibleTextCursorEvent(QObject *obj, int cursorPos) |
| 389 | : QAccessibleEvent(obj, QAccessible::InvalidEvent) |
| 390 | , m_cursorPosition(cursorPos) |
| 391 | { |
| 392 | m_type = QAccessible::TextCaretMoved; |
| 393 | } |
| 394 | inline QAccessibleTextCursorEvent(QAccessibleInterface *iface, int cursorPos) |
| 395 | : QAccessibleEvent(iface, QAccessible::InvalidEvent) |
| 396 | , m_cursorPosition(cursorPos) |
| 397 | { |
| 398 | m_type = QAccessible::TextCaretMoved; |
| 399 | } |
| 400 | |
| 401 | ~QAccessibleTextCursorEvent(); |
| 402 | |
| 403 | void setCursorPosition(int position) { m_cursorPosition = position; } |
| 404 | int cursorPosition() const { return m_cursorPosition; } |
| 405 | |
| 406 | protected: |
| 407 | int m_cursorPosition; |
| 408 | }; |
| 409 | |
| 410 | // Updates the cursor position simultaneously. By default the cursor is set to the end of the selection. |
| 411 | class Q_GUI_EXPORT QAccessibleTextSelectionEvent : public QAccessibleTextCursorEvent |
| 412 | { |
| 413 | public: |
| 414 | inline QAccessibleTextSelectionEvent(QObject *obj, int start, int end) |
| 415 | : QAccessibleTextCursorEvent(obj, (start == -1) ? 0 : end) |
| 416 | , m_selectionStart(start), m_selectionEnd(end) |
| 417 | { |
| 418 | m_type = QAccessible::TextSelectionChanged; |
| 419 | } |
| 420 | inline QAccessibleTextSelectionEvent(QAccessibleInterface *iface, int start, int end) |
| 421 | : QAccessibleTextCursorEvent(iface, (start == -1) ? 0 : end) |
| 422 | , m_selectionStart(start), m_selectionEnd(end) |
| 423 | { |
| 424 | m_type = QAccessible::TextSelectionChanged; |
| 425 | } |
| 426 | |
| 427 | ~QAccessibleTextSelectionEvent(); |
| 428 | |
| 429 | void setSelection(int start, int end) { |
| 430 | m_selectionStart = start; |
| 431 | m_selectionEnd = end; |
| 432 | } |
| 433 | |
| 434 | int selectionStart() const { return m_selectionStart; } |
| 435 | int selectionEnd() const { return m_selectionEnd; } |
| 436 | |
| 437 | protected: |
| 438 | int m_selectionStart; |
| 439 | int m_selectionEnd; |
| 440 | }; |
| 441 | |
| 442 | class Q_GUI_EXPORT QAccessibleTextInsertEvent : public QAccessibleTextCursorEvent |
| 443 | { |
| 444 | public: |
| 445 | inline QAccessibleTextInsertEvent(QObject *obj, int position, const QString &text) |
| 446 | : QAccessibleTextCursorEvent(obj, position + int(text.size())) |
| 447 | , m_position(position), m_text(text) |
| 448 | { |
| 449 | m_type = QAccessible::TextInserted; |
| 450 | } |
| 451 | inline QAccessibleTextInsertEvent(QAccessibleInterface *iface, int position, const QString &text) |
| 452 | : QAccessibleTextCursorEvent(iface, position + int(text.size())) |
| 453 | , m_position(position), m_text(text) |
| 454 | { |
| 455 | m_type = QAccessible::TextInserted; |
| 456 | } |
| 457 | |
| 458 | ~QAccessibleTextInsertEvent(); |
| 459 | |
| 460 | QString textInserted() const { |
| 461 | return m_text; |
| 462 | } |
| 463 | int changePosition() const { |
| 464 | return m_position; |
| 465 | } |
| 466 | |
| 467 | protected: |
| 468 | int m_position; |
| 469 | QString m_text; |
| 470 | }; |
| 471 | |
| 472 | class Q_GUI_EXPORT QAccessibleTextRemoveEvent : public QAccessibleTextCursorEvent |
| 473 | { |
| 474 | public: |
| 475 | inline QAccessibleTextRemoveEvent(QObject *obj, int position, const QString &text) |
| 476 | : QAccessibleTextCursorEvent(obj, position) |
| 477 | , m_position(position), m_text(text) |
| 478 | { |
| 479 | m_type = QAccessible::TextRemoved; |
| 480 | } |
| 481 | inline QAccessibleTextRemoveEvent(QAccessibleInterface *iface, int position, const QString &text) |
| 482 | : QAccessibleTextCursorEvent(iface, position) |
| 483 | , m_position(position), m_text(text) |
| 484 | { |
| 485 | m_type = QAccessible::TextRemoved; |
| 486 | } |
| 487 | |
| 488 | ~QAccessibleTextRemoveEvent(); |
| 489 | |
| 490 | QString textRemoved() const { |
| 491 | return m_text; |
| 492 | } |
| 493 | int changePosition() const { |
| 494 | return m_position; |
| 495 | } |
| 496 | |
| 497 | protected: |
| 498 | int m_position; |
| 499 | QString m_text; |
| 500 | }; |
| 501 | |
| 502 | class Q_GUI_EXPORT QAccessibleTextUpdateEvent : public QAccessibleTextCursorEvent |
| 503 | { |
| 504 | public: |
| 505 | inline QAccessibleTextUpdateEvent(QObject *obj, int position, const QString &oldText, const QString &text) |
| 506 | : QAccessibleTextCursorEvent(obj, position + int(text.size())) |
| 507 | , m_position(position), m_oldText(oldText), m_text(text) |
| 508 | { |
| 509 | m_type = QAccessible::TextUpdated; |
| 510 | } |
| 511 | inline QAccessibleTextUpdateEvent(QAccessibleInterface *iface, int position, const QString &oldText, const QString &text) |
| 512 | : QAccessibleTextCursorEvent(iface, position + int(text.size())) |
| 513 | , m_position(position), m_oldText(oldText), m_text(text) |
| 514 | { |
| 515 | m_type = QAccessible::TextUpdated; |
| 516 | } |
| 517 | |
| 518 | ~QAccessibleTextUpdateEvent(); |
| 519 | |
| 520 | QString textRemoved() const { |
| 521 | return m_oldText; |
| 522 | } |
| 523 | QString textInserted() const { |
| 524 | return m_text; |
| 525 | } |
| 526 | int changePosition() const { |
| 527 | return m_position; |
| 528 | } |
| 529 | |
| 530 | protected: |
| 531 | int m_position; |
| 532 | QString m_oldText; |
| 533 | QString m_text; |
| 534 | }; |
| 535 | |
| 536 | class Q_GUI_EXPORT QAccessibleValueChangeEvent : public QAccessibleEvent |
| 537 | { |
| 538 | public: |
| 539 | inline QAccessibleValueChangeEvent(QObject *obj, const QVariant &val) |
| 540 | : QAccessibleEvent(obj, QAccessible::InvalidEvent) |
| 541 | , m_value(val) |
| 542 | { |
| 543 | m_type = QAccessible::ValueChanged; |
| 544 | } |
| 545 | inline QAccessibleValueChangeEvent(QAccessibleInterface *iface, const QVariant &val) |
| 546 | : QAccessibleEvent(iface, QAccessible::InvalidEvent) |
| 547 | , m_value(val) |
| 548 | { |
| 549 | m_type = QAccessible::ValueChanged; |
| 550 | } |
| 551 | |
| 552 | ~QAccessibleValueChangeEvent(); |
| 553 | |
| 554 | void setValue(const QVariant & val) { m_value= val; } |
| 555 | QVariant value() const { return m_value; } |
| 556 | |
| 557 | protected: |
| 558 | QVariant m_value; |
| 559 | }; |
| 560 | |
| 561 | class Q_GUI_EXPORT QAccessibleTableModelChangeEvent : public QAccessibleEvent |
| 562 | { |
| 563 | public: |
| 564 | enum ModelChangeType { |
| 565 | ModelReset, |
| 566 | DataChanged, |
| 567 | RowsInserted, |
| 568 | ColumnsInserted, |
| 569 | RowsRemoved, |
| 570 | ColumnsRemoved |
| 571 | }; |
| 572 | |
| 573 | inline QAccessibleTableModelChangeEvent(QObject *obj, ModelChangeType changeType) |
| 574 | : QAccessibleEvent(obj, QAccessible::InvalidEvent) |
| 575 | , m_modelChangeType(changeType) |
| 576 | , m_firstRow(-1), m_firstColumn(-1), m_lastRow(-1), m_lastColumn(-1) |
| 577 | { |
| 578 | m_type = QAccessible::TableModelChanged; |
| 579 | } |
| 580 | inline QAccessibleTableModelChangeEvent(QAccessibleInterface *iface, ModelChangeType changeType) |
| 581 | : QAccessibleEvent(iface, QAccessible::InvalidEvent) |
| 582 | , m_modelChangeType(changeType) |
| 583 | , m_firstRow(-1), m_firstColumn(-1), m_lastRow(-1), m_lastColumn(-1) |
| 584 | { |
| 585 | m_type = QAccessible::TableModelChanged; |
| 586 | } |
| 587 | |
| 588 | ~QAccessibleTableModelChangeEvent(); |
| 589 | |
| 590 | void setModelChangeType(ModelChangeType changeType) { m_modelChangeType = changeType; } |
| 591 | ModelChangeType modelChangeType() const { return m_modelChangeType; } |
| 592 | |
| 593 | void setFirstRow(int row) { m_firstRow = row; } |
| 594 | void setFirstColumn(int col) { m_firstColumn = col; } |
| 595 | void setLastRow(int row) { m_lastRow = row; } |
| 596 | void setLastColumn(int col) { m_lastColumn = col; } |
| 597 | int firstRow() const { return m_firstRow; } |
| 598 | int firstColumn() const { return m_firstColumn; } |
| 599 | int lastRow() const { return m_lastRow; } |
| 600 | int lastColumn() const { return m_lastColumn; } |
| 601 | |
| 602 | protected: |
| 603 | ModelChangeType m_modelChangeType; |
| 604 | int m_firstRow; |
| 605 | int m_firstColumn; |
| 606 | int m_lastRow; |
| 607 | int m_lastColumn; |
| 608 | }; |
| 609 | |
| 610 | class Q_GUI_EXPORT QAccessibleAnnouncementEvent : public QAccessibleEvent |
| 611 | { |
| 612 | public: |
| 613 | explicit QAccessibleAnnouncementEvent(QObject *object, const QString &message) |
| 614 | : QAccessibleEvent(object, QAccessible::InvalidEvent) |
| 615 | , m_message(message) |
| 616 | , m_politeness(QAccessible::AnnouncementPoliteness::Polite) |
| 617 | { |
| 618 | m_type = QAccessible::Announcement; |
| 619 | } |
| 620 | |
| 621 | explicit QAccessibleAnnouncementEvent(QAccessibleInterface *iface, const QString &message) |
| 622 | : QAccessibleEvent(iface, QAccessible::InvalidEvent) |
| 623 | , m_message(message) |
| 624 | , m_politeness(QAccessible::AnnouncementPoliteness::Polite) |
| 625 | { |
| 626 | m_type = QAccessible::Announcement; |
| 627 | } |
| 628 | |
| 629 | ~QAccessibleAnnouncementEvent() override; |
| 630 | |
| 631 | QString message() const { return m_message; } |
| 632 | QAccessible::AnnouncementPoliteness politeness() const { return m_politeness; } |
| 633 | void setPoliteness(QAccessible::AnnouncementPoliteness politeness) |
| 634 | { m_politeness = politeness; } |
| 635 | |
| 636 | protected: |
| 637 | QString m_message; |
| 638 | QAccessible::AnnouncementPoliteness m_politeness; |
| 639 | }; |
| 640 | |
| 641 | #ifndef Q_QDOC |
| 642 | #define QAccessibleInterface_iid "org.qt-project.Qt.QAccessibleInterface" |
| 643 | Q_DECLARE_INTERFACE(QAccessibleInterface, QAccessibleInterface_iid) |
| 644 | #endif |
| 645 | |
| 646 | Q_GUI_EXPORT const char *qAccessibleRoleString(QAccessible::Role role); |
| 647 | Q_GUI_EXPORT const char *qAccessibleEventString(QAccessible::Event event); |
| 648 | Q_GUI_EXPORT QString qAccessibleLocalizedActionDescription(const QString &actionName); |
| 649 | |
| 650 | #ifndef QT_NO_DEBUG_STREAM |
| 651 | Q_GUI_EXPORT QDebug operator<<(QDebug d, const QAccessibleInterface *iface); |
| 652 | Q_GUI_EXPORT QDebug operator<<(QDebug d, const QAccessibleEvent &ev); |
| 653 | #endif |
| 654 | |
| 655 | QT_END_NAMESPACE |
| 656 | |
| 657 | #endif // QT_CONFIG(accessibility) |
| 658 | #endif // QACCESSIBLE_H |
| 659 | |