/src/qtbase/src/gui/accessible/qaccessible.h
Line | Count | Source |
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/qglobal.h> |
19 | | #include <QtCore/qlist.h> |
20 | | #include <QtCore/qobject.h> |
21 | | #include <QtCore/qrect.h> |
22 | | #include <QtCore/qset.h> |
23 | | #include <QtCore/qvariant.h> |
24 | | #include <QtGui/qcolor.h> |
25 | | #include <QtGui/qevent.h> |
26 | | #include <QtGui/qaccessible_base.h> |
27 | | |
28 | | QT_BEGIN_NAMESPACE |
29 | | |
30 | | class QDebug; |
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<std::pair<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 | 0 | { return reinterpret_cast<QAccessibleTextInterface *>(interface_cast(QAccessible::TextInterface)); } |
85 | | |
86 | | inline QAccessibleEditableTextInterface *editableTextInterface() |
87 | 0 | { return reinterpret_cast<QAccessibleEditableTextInterface *>(interface_cast(QAccessible::EditableTextInterface)); } |
88 | | |
89 | | inline QAccessibleValueInterface *valueInterface() |
90 | 0 | { return reinterpret_cast<QAccessibleValueInterface *>(interface_cast(QAccessible::ValueInterface)); } |
91 | | |
92 | | inline QAccessibleActionInterface *actionInterface() |
93 | 0 | { return reinterpret_cast<QAccessibleActionInterface *>(interface_cast(QAccessible::ActionInterface)); } |
94 | | |
95 | | inline QAccessibleImageInterface *imageInterface() |
96 | 0 | { return reinterpret_cast<QAccessibleImageInterface *>(interface_cast(QAccessible::ImageInterface)); } |
97 | | |
98 | | inline QAccessibleTableInterface *tableInterface() |
99 | 0 | { return reinterpret_cast<QAccessibleTableInterface *>(interface_cast(QAccessible::TableInterface)); } |
100 | | |
101 | | inline QAccessibleTableCellInterface *tableCellInterface() |
102 | 0 | { return reinterpret_cast<QAccessibleTableCellInterface *>(interface_cast(QAccessible::TableCellInterface)); } |
103 | | |
104 | | inline QAccessibleHyperlinkInterface *hyperlinkInterface() |
105 | 0 | { return reinterpret_cast<QAccessibleHyperlinkInterface *>(interface_cast(QAccessible::HyperlinkInterface)); } |
106 | | |
107 | | inline QAccessibleSelectionInterface *selectionInterface() |
108 | 0 | { return reinterpret_cast<QAccessibleSelectionInterface *>(interface_cast(QAccessible::SelectionInterface)); } |
109 | | |
110 | | inline QAccessibleAttributesInterface *attributesInterface() |
111 | 0 | { 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 | 0 | { 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*> rowHeaderCells() 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 | 0 | Q_DECLARE_TR_FUNCTIONS(QAccessibleActionInterface) |
231 | 0 | public: |
232 | 0 | virtual ~QAccessibleActionInterface(); |
233 | 0 |
|
234 | 0 | virtual QStringList actionNames() const = 0; |
235 | 0 | virtual QString localizedActionName(const QString &name) const; |
236 | 0 | virtual QString localizedActionDescription(const QString &name) const; |
237 | 0 | virtual void doAction(const QString &actionName) = 0; |
238 | 0 | virtual QStringList keyBindingsForAction(const QString &actionName) const = 0; |
239 | 0 |
|
240 | 0 | static const QString &pressAction(); |
241 | 0 | static const QString &increaseAction(); |
242 | 0 | static const QString &decreaseAction(); |
243 | 0 | static const QString &showMenuAction(); |
244 | 0 | static const QString &setFocusAction(); |
245 | 0 | static const QString &toggleAction(); |
246 | 0 | static QString scrollLeftAction(); |
247 | 0 | static QString scrollRightAction(); |
248 | 0 | static QString scrollUpAction(); |
249 | 0 | static QString scrollDownAction(); |
250 | 0 | static QString nextPageAction(); |
251 | 0 | static QString previousPageAction(); |
252 | 0 | }; |
253 | 0 |
|
254 | 0 | class Q_GUI_EXPORT QAccessibleImageInterface |
255 | 0 | { |
256 | 0 | public: |
257 | 0 | virtual ~QAccessibleImageInterface(); |
258 | 0 |
|
259 | 0 | virtual QString imageDescription() const = 0; |
260 | 0 | virtual QSize imageSize() const = 0; |
261 | 0 | virtual QPoint imagePosition() const = 0; |
262 | 0 | }; |
263 | 0 |
|
264 | 0 | class Q_GUI_EXPORT QAccessibleHyperlinkInterface |
265 | 0 | { |
266 | 0 | public: |
267 | 0 | virtual ~QAccessibleHyperlinkInterface(); |
268 | 0 |
|
269 | 0 | virtual QString anchor() const = 0; |
270 | 0 | virtual QString anchorTarget() const = 0; |
271 | 0 | virtual int startIndex() const = 0; |
272 | 0 | virtual int endIndex() const = 0; |
273 | 0 | virtual bool isValid() const = 0; |
274 | 0 | }; |
275 | 0 |
|
276 | 0 | class Q_GUI_EXPORT QAccessibleSelectionInterface |
277 | 0 | { |
278 | 0 | public: |
279 | 0 | virtual ~QAccessibleSelectionInterface(); |
280 | 0 |
|
281 | 0 | virtual int selectedItemCount() const = 0; |
282 | 0 | virtual QList<QAccessibleInterface*> selectedItems() const = 0; |
283 | 0 | virtual QAccessibleInterface* selectedItem(int selectionIndex) const; |
284 | 0 | virtual bool isSelected(QAccessibleInterface *childItem) const; |
285 | 0 | virtual bool select(QAccessibleInterface *childItem) = 0; |
286 | 0 | virtual bool unselect(QAccessibleInterface *childItem) = 0; |
287 | 0 | virtual bool selectAll() = 0; |
288 | 0 | virtual bool clear() = 0; |
289 | 0 | }; |
290 | 0 |
|
291 | 0 | class Q_GUI_EXPORT QAccessibleAttributesInterface |
292 | 0 | { |
293 | 0 | public: |
294 | 0 | virtual ~QAccessibleAttributesInterface(); |
295 | 0 | virtual QList<QAccessible::Attribute> attributeKeys() const = 0; |
296 | 0 | virtual QVariant attributeValue(QAccessible::Attribute key) const = 0; |
297 | 0 | }; |
298 | 0 |
|
299 | 0 |
|
300 | 0 | class Q_GUI_EXPORT QAccessibleEvent |
301 | 0 | { |
302 | 0 | Q_DISABLE_COPY(QAccessibleEvent) |
303 | 0 | public: |
304 | 0 |
|
305 | 0 | inline QAccessibleEvent(QObject *obj, QAccessible::Event typ) |
306 | 0 | : m_type(typ), m_object(obj), m_child(-1) |
307 | 0 | { |
308 | 0 | if (m_type != QAccessible::ObjectDestroyed) |
309 | 0 | Q_ASSERT(obj); |
310 | | // All events below have a subclass of QAccessibleEvent. |
311 | | // Use the subclass, since it's expected that it's possible to cast to that. |
312 | 0 | Q_ASSERT(m_type != QAccessible::ValueChanged); |
313 | 0 | Q_ASSERT(m_type != QAccessible::StateChanged); |
314 | 0 | Q_ASSERT(m_type != QAccessible::TextCaretMoved); |
315 | 0 | Q_ASSERT(m_type != QAccessible::TextSelectionChanged); |
316 | 0 | Q_ASSERT(m_type != QAccessible::TextInserted); |
317 | 0 | Q_ASSERT(m_type != QAccessible::TextRemoved); |
318 | 0 | Q_ASSERT(m_type != QAccessible::TextUpdated); |
319 | 0 | Q_ASSERT(m_type != QAccessible::TableModelChanged); |
320 | 0 | Q_ASSERT(m_type != QAccessible::Announcement); |
321 | 0 | } |
322 | | |
323 | | inline QAccessibleEvent(QAccessibleInterface *iface, QAccessible::Event typ) |
324 | | : m_type(typ) |
325 | 0 | { |
326 | 0 | Q_ASSERT(iface); |
327 | 0 | Q_ASSERT(m_type != QAccessible::ValueChanged); |
328 | 0 | Q_ASSERT(m_type != QAccessible::StateChanged); |
329 | 0 | Q_ASSERT(m_type != QAccessible::TextCaretMoved); |
330 | 0 | Q_ASSERT(m_type != QAccessible::TextSelectionChanged); |
331 | 0 | Q_ASSERT(m_type != QAccessible::TextInserted); |
332 | 0 | Q_ASSERT(m_type != QAccessible::TextRemoved); |
333 | 0 | Q_ASSERT(m_type != QAccessible::TextUpdated); |
334 | 0 | Q_ASSERT(m_type != QAccessible::TableModelChanged); |
335 | 0 | Q_ASSERT(m_type != QAccessible::Announcement); |
336 | 0 | m_uniqueId = QAccessible::uniqueId(iface); |
337 | 0 | m_object = iface->object(); |
338 | 0 | } |
339 | | |
340 | | virtual ~QAccessibleEvent(); |
341 | | |
342 | 0 | QAccessible::Event type() const { return m_type; } |
343 | 0 | QObject *object() const { return m_object; } |
344 | | QAccessible::Id uniqueId() const; |
345 | | |
346 | | void setChild(int chld); |
347 | 0 | int child() const { return m_child; } |
348 | | |
349 | | virtual QAccessibleInterface *accessibleInterface() const; |
350 | | |
351 | | protected: |
352 | | QAccessible::Event m_type; |
353 | | QObject *m_object; |
354 | | union { |
355 | | int m_child; |
356 | | QAccessible::Id m_uniqueId; |
357 | | }; |
358 | | |
359 | | friend class QTestAccessibility; |
360 | | }; |
361 | | |
362 | | class Q_GUI_EXPORT QAccessibleStateChangeEvent :public QAccessibleEvent |
363 | | { |
364 | | public: |
365 | | inline QAccessibleStateChangeEvent(QObject *obj, QAccessible::State state) |
366 | 0 | : QAccessibleEvent(obj, QAccessible::InvalidEvent), m_changedStates(state) |
367 | 0 | { |
368 | 0 | m_type = QAccessible::StateChanged; |
369 | 0 | } |
370 | | inline QAccessibleStateChangeEvent(QAccessibleInterface *iface, QAccessible::State state) |
371 | | : QAccessibleEvent(iface, QAccessible::InvalidEvent), m_changedStates(state) |
372 | 0 | { |
373 | 0 | m_type = QAccessible::StateChanged; |
374 | 0 | } |
375 | | ~QAccessibleStateChangeEvent(); |
376 | | |
377 | 0 | QAccessible::State changedStates() const { |
378 | 0 | return m_changedStates; |
379 | 0 | } |
380 | | |
381 | | protected: |
382 | | QAccessible::State m_changedStates; |
383 | | }; |
384 | | |
385 | | // Update the cursor and optionally the selection. |
386 | | class Q_GUI_EXPORT QAccessibleTextCursorEvent : public QAccessibleEvent |
387 | | { |
388 | | public: |
389 | | inline QAccessibleTextCursorEvent(QObject *obj, int cursorPos) |
390 | | : QAccessibleEvent(obj, QAccessible::InvalidEvent) |
391 | | , m_cursorPosition(cursorPos) |
392 | 0 | { |
393 | 0 | m_type = QAccessible::TextCaretMoved; |
394 | 0 | } |
395 | | inline QAccessibleTextCursorEvent(QAccessibleInterface *iface, int cursorPos) |
396 | | : QAccessibleEvent(iface, QAccessible::InvalidEvent) |
397 | | , m_cursorPosition(cursorPos) |
398 | 0 | { |
399 | 0 | m_type = QAccessible::TextCaretMoved; |
400 | 0 | } |
401 | | |
402 | | ~QAccessibleTextCursorEvent(); |
403 | | |
404 | 0 | void setCursorPosition(int position) { m_cursorPosition = position; } |
405 | 0 | int cursorPosition() const { return m_cursorPosition; } |
406 | | |
407 | | protected: |
408 | | int m_cursorPosition; |
409 | | }; |
410 | | |
411 | | // Updates the cursor position simultaneously. By default the cursor is set to the end of the selection. |
412 | | class Q_GUI_EXPORT QAccessibleTextSelectionEvent : public QAccessibleTextCursorEvent |
413 | | { |
414 | | public: |
415 | | inline QAccessibleTextSelectionEvent(QObject *obj, int start, int end) |
416 | | : QAccessibleTextCursorEvent(obj, (start == -1) ? 0 : end) |
417 | | , m_selectionStart(start), m_selectionEnd(end) |
418 | 0 | { |
419 | 0 | m_type = QAccessible::TextSelectionChanged; |
420 | 0 | } |
421 | | inline QAccessibleTextSelectionEvent(QAccessibleInterface *iface, int start, int end) |
422 | | : QAccessibleTextCursorEvent(iface, (start == -1) ? 0 : end) |
423 | | , m_selectionStart(start), m_selectionEnd(end) |
424 | 0 | { |
425 | 0 | m_type = QAccessible::TextSelectionChanged; |
426 | 0 | } |
427 | | |
428 | | ~QAccessibleTextSelectionEvent(); |
429 | | |
430 | 0 | void setSelection(int start, int end) { |
431 | 0 | m_selectionStart = start; |
432 | 0 | m_selectionEnd = end; |
433 | 0 | } |
434 | | |
435 | 0 | int selectionStart() const { return m_selectionStart; } |
436 | 0 | int selectionEnd() const { return m_selectionEnd; } |
437 | | |
438 | | protected: |
439 | | int m_selectionStart; |
440 | | int m_selectionEnd; |
441 | | }; |
442 | | |
443 | | class Q_GUI_EXPORT QAccessibleTextInsertEvent : public QAccessibleTextCursorEvent |
444 | | { |
445 | | public: |
446 | | inline QAccessibleTextInsertEvent(QObject *obj, int position, const QString &text) |
447 | | : QAccessibleTextCursorEvent(obj, position + int(text.size())) |
448 | | , m_position(position), m_text(text) |
449 | 0 | { |
450 | 0 | m_type = QAccessible::TextInserted; |
451 | 0 | } |
452 | | inline QAccessibleTextInsertEvent(QAccessibleInterface *iface, int position, const QString &text) |
453 | | : QAccessibleTextCursorEvent(iface, position + int(text.size())) |
454 | | , m_position(position), m_text(text) |
455 | 0 | { |
456 | 0 | m_type = QAccessible::TextInserted; |
457 | 0 | } |
458 | | |
459 | | ~QAccessibleTextInsertEvent(); |
460 | | |
461 | 0 | QString textInserted() const { |
462 | 0 | return m_text; |
463 | 0 | } |
464 | 0 | int changePosition() const { |
465 | 0 | return m_position; |
466 | 0 | } |
467 | | |
468 | | protected: |
469 | | int m_position; |
470 | | QString m_text; |
471 | | }; |
472 | | |
473 | | class Q_GUI_EXPORT QAccessibleTextRemoveEvent : public QAccessibleTextCursorEvent |
474 | | { |
475 | | public: |
476 | | inline QAccessibleTextRemoveEvent(QObject *obj, int position, const QString &text) |
477 | | : QAccessibleTextCursorEvent(obj, position) |
478 | | , m_position(position), m_text(text) |
479 | 0 | { |
480 | 0 | m_type = QAccessible::TextRemoved; |
481 | 0 | } |
482 | | inline QAccessibleTextRemoveEvent(QAccessibleInterface *iface, int position, const QString &text) |
483 | | : QAccessibleTextCursorEvent(iface, position) |
484 | | , m_position(position), m_text(text) |
485 | 0 | { |
486 | 0 | m_type = QAccessible::TextRemoved; |
487 | 0 | } |
488 | | |
489 | | ~QAccessibleTextRemoveEvent(); |
490 | | |
491 | 0 | QString textRemoved() const { |
492 | 0 | return m_text; |
493 | 0 | } |
494 | 0 | int changePosition() const { |
495 | 0 | return m_position; |
496 | 0 | } |
497 | | |
498 | | protected: |
499 | | int m_position; |
500 | | QString m_text; |
501 | | }; |
502 | | |
503 | | class Q_GUI_EXPORT QAccessibleTextUpdateEvent : public QAccessibleTextCursorEvent |
504 | | { |
505 | | public: |
506 | | inline QAccessibleTextUpdateEvent(QObject *obj, int position, const QString &oldText, const QString &text) |
507 | | : QAccessibleTextCursorEvent(obj, position + int(text.size())) |
508 | | , m_position(position), m_oldText(oldText), m_text(text) |
509 | 0 | { |
510 | 0 | m_type = QAccessible::TextUpdated; |
511 | 0 | } |
512 | | inline QAccessibleTextUpdateEvent(QAccessibleInterface *iface, int position, const QString &oldText, const QString &text) |
513 | | : QAccessibleTextCursorEvent(iface, position + int(text.size())) |
514 | | , m_position(position), m_oldText(oldText), m_text(text) |
515 | 0 | { |
516 | 0 | m_type = QAccessible::TextUpdated; |
517 | 0 | } |
518 | | |
519 | | ~QAccessibleTextUpdateEvent(); |
520 | | |
521 | 0 | QString textRemoved() const { |
522 | 0 | return m_oldText; |
523 | 0 | } |
524 | 0 | QString textInserted() const { |
525 | 0 | return m_text; |
526 | 0 | } |
527 | 0 | int changePosition() const { |
528 | 0 | return m_position; |
529 | 0 | } |
530 | | |
531 | | protected: |
532 | | int m_position; |
533 | | QString m_oldText; |
534 | | QString m_text; |
535 | | }; |
536 | | |
537 | | class Q_GUI_EXPORT QAccessibleValueChangeEvent : public QAccessibleEvent |
538 | | { |
539 | | public: |
540 | | inline QAccessibleValueChangeEvent(QObject *obj, const QVariant &val) |
541 | | : QAccessibleEvent(obj, QAccessible::InvalidEvent) |
542 | | , m_value(val) |
543 | 0 | { |
544 | 0 | m_type = QAccessible::ValueChanged; |
545 | 0 | } |
546 | | inline QAccessibleValueChangeEvent(QAccessibleInterface *iface, const QVariant &val) |
547 | | : QAccessibleEvent(iface, QAccessible::InvalidEvent) |
548 | | , m_value(val) |
549 | 0 | { |
550 | 0 | m_type = QAccessible::ValueChanged; |
551 | 0 | } |
552 | | |
553 | | ~QAccessibleValueChangeEvent(); |
554 | | |
555 | 0 | void setValue(const QVariant & val) { m_value= val; } |
556 | 0 | QVariant value() const { return m_value; } |
557 | | |
558 | | protected: |
559 | | QVariant m_value; |
560 | | }; |
561 | | |
562 | | class Q_GUI_EXPORT QAccessibleTableModelChangeEvent : public QAccessibleEvent |
563 | | { |
564 | | public: |
565 | | enum ModelChangeType { |
566 | | ModelReset, |
567 | | DataChanged, |
568 | | RowsInserted, |
569 | | ColumnsInserted, |
570 | | RowsRemoved, |
571 | | ColumnsRemoved |
572 | | }; |
573 | | |
574 | | inline QAccessibleTableModelChangeEvent(QObject *obj, ModelChangeType changeType) |
575 | | : QAccessibleEvent(obj, QAccessible::InvalidEvent) |
576 | | , m_modelChangeType(changeType) |
577 | | , m_firstRow(-1), m_firstColumn(-1), m_lastRow(-1), m_lastColumn(-1) |
578 | 0 | { |
579 | 0 | m_type = QAccessible::TableModelChanged; |
580 | 0 | } |
581 | | inline QAccessibleTableModelChangeEvent(QAccessibleInterface *iface, ModelChangeType changeType) |
582 | | : QAccessibleEvent(iface, QAccessible::InvalidEvent) |
583 | | , m_modelChangeType(changeType) |
584 | | , m_firstRow(-1), m_firstColumn(-1), m_lastRow(-1), m_lastColumn(-1) |
585 | 0 | { |
586 | 0 | m_type = QAccessible::TableModelChanged; |
587 | 0 | } |
588 | | |
589 | | ~QAccessibleTableModelChangeEvent(); |
590 | | |
591 | 0 | void setModelChangeType(ModelChangeType changeType) { m_modelChangeType = changeType; } |
592 | 0 | ModelChangeType modelChangeType() const { return m_modelChangeType; } |
593 | | |
594 | 0 | void setFirstRow(int row) { m_firstRow = row; } |
595 | 0 | void setFirstColumn(int col) { m_firstColumn = col; } |
596 | 0 | void setLastRow(int row) { m_lastRow = row; } |
597 | 0 | void setLastColumn(int col) { m_lastColumn = col; } |
598 | 0 | int firstRow() const { return m_firstRow; } |
599 | 0 | int firstColumn() const { return m_firstColumn; } |
600 | 0 | int lastRow() const { return m_lastRow; } |
601 | 0 | int lastColumn() const { return m_lastColumn; } |
602 | | |
603 | | protected: |
604 | | ModelChangeType m_modelChangeType; |
605 | | int m_firstRow; |
606 | | int m_firstColumn; |
607 | | int m_lastRow; |
608 | | int m_lastColumn; |
609 | | }; |
610 | | |
611 | | class Q_GUI_EXPORT QAccessibleAnnouncementEvent : public QAccessibleEvent |
612 | | { |
613 | | public: |
614 | | explicit QAccessibleAnnouncementEvent(QObject *object, const QString &message) |
615 | | : QAccessibleEvent(object, QAccessible::InvalidEvent) |
616 | | , m_message(message) |
617 | | , m_politeness(QAccessible::AnnouncementPoliteness::Polite) |
618 | 0 | { |
619 | 0 | m_type = QAccessible::Announcement; |
620 | 0 | } |
621 | | |
622 | | explicit QAccessibleAnnouncementEvent(QAccessibleInterface *iface, const QString &message) |
623 | | : QAccessibleEvent(iface, QAccessible::InvalidEvent) |
624 | | , m_message(message) |
625 | | , m_politeness(QAccessible::AnnouncementPoliteness::Polite) |
626 | 0 | { |
627 | 0 | m_type = QAccessible::Announcement; |
628 | 0 | } |
629 | | |
630 | | ~QAccessibleAnnouncementEvent() override; |
631 | | |
632 | 0 | QString message() const { return m_message; } |
633 | 0 | QAccessible::AnnouncementPoliteness politeness() const { return m_politeness; } |
634 | | void setPoliteness(QAccessible::AnnouncementPoliteness politeness) |
635 | 0 | { m_politeness = politeness; } |
636 | | |
637 | | protected: |
638 | | QString m_message; |
639 | | QAccessible::AnnouncementPoliteness m_politeness; |
640 | | }; |
641 | | |
642 | | #ifndef Q_QDOC |
643 | | #define QAccessibleInterface_iid "org.qt-project.Qt.QAccessibleInterface" |
644 | | Q_DECLARE_INTERFACE(QAccessibleInterface, QAccessibleInterface_iid) Unexecuted instantiation: char const* qobject_interface_iid<QAccessibleInterface*>() Unexecuted instantiation: QAccessibleInterface* qobject_cast<QAccessibleInterface*>(QObject*) Unexecuted instantiation: QAccessibleInterface const* qobject_cast<QAccessibleInterface const*>(QObject const*) |
645 | | #endif |
646 | | |
647 | | Q_GUI_EXPORT const char *qAccessibleRoleString(QAccessible::Role role); |
648 | | Q_GUI_EXPORT const char *qAccessibleEventString(QAccessible::Event event); |
649 | | Q_GUI_EXPORT QString qAccessibleLocalizedActionDescription(const QString &actionName); |
650 | | |
651 | | #ifndef QT_NO_DEBUG_STREAM |
652 | | Q_GUI_EXPORT QDebug operator<<(QDebug d, const QAccessibleInterface *iface); |
653 | | Q_GUI_EXPORT QDebug operator<<(QDebug d, const QAccessibleEvent &ev); |
654 | | #endif |
655 | | |
656 | | QT_END_NAMESPACE |
657 | | |
658 | | #endif // QT_CONFIG(accessibility) |
659 | | #endif // QACCESSIBLE_H |