Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qaccessible.cpp
Go to the documentation of this file.
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// Qt-Security score:critical reason:data-parser
4
5#include "qaccessible.h"
6
11#include <QtCore/qtextboundaryfinder.h>
12#include <QtGui/qclipboard.h>
13#include <QtGui/qguiapplication.h>
14#include <QtGui/qtextcursor.h>
15#include <private/qguiapplication_p.h>
16#include <qpa/qplatformaccessibility.h>
17#include <qpa/qplatformintegration.h>
18
19#include <QtCore/qdebug.h>
20#include <QtCore/qloggingcategory.h>
21#include <QtCore/qmetaobject.h>
22#include <QtCore/private/qmetaobject_p.h>
23#include <QtCore/qhash.h>
24#include <private/qfactoryloader_p.h>
25
26QT_BEGIN_NAMESPACE
27
28using namespace Qt::StringLiterals;
29
30Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core");
31
32/*!
33 \class QAccessible
34 \brief The QAccessible class provides enums and static functions
35 related to accessibility.
36
37 \ingroup accessibility
38 \inmodule QtGui
39
40 This class is part of \l {Accessibility for QWidget Applications}.
41
42 Accessible applications can be used by people who are not able to
43 use applications by conventional means.
44
45 The functions in this class are used for communication between
46 accessible applications (also called AT Servers) and
47 accessibility tools (AT Clients), such as screen readers and
48 braille displays. Clients and servers communicate in the following way:
49
50 \list
51 \li \e{AT Servers} notify the clients about events through calls to the
52 updateAccessibility() function.
53
54 \li \e{AT Clients} request information about the objects in the server.
55 The QAccessibleInterface class is the core interface, and encapsulates
56 this information in a pure virtual API. Implementations of the interface
57 are provided by Qt through the queryAccessibleInterface() API.
58 \endlist
59
60 The communication between servers and clients is initialized by
61 the setRootObject() function. Function pointers can be installed
62 to replace or extend the default behavior of the static functions
63 in QAccessible.
64
65 Qt supports Microsoft Active Accessibility (MSAA), \macos
66 Accessibility, and the Unix/X11 AT-SPI standard. Other backends
67 can be supported using QAccessibleBridge.
68
69 In the Unix/X11 AT-SPI implementation, applications become accessible
70 when two conditions are met:
71 \list
72 \li org.a11y.Status.IsEnabled DBus property is true
73 \li org.a11y.Status.ScreenReaderEnabled DBus property is true
74 \endlist
75 An alternative to setting the DBus AT-SPI properties is to set
76 the QT_LINUX_ACCESSIBILITY_ALWAYS_ON environment variable.
77
78 In addition to QAccessible's static functions, Qt offers one
79 generic interface, QAccessibleInterface, that can be used to wrap
80 all widgets and objects (e.g., QPushButton). This single
81 interface provides all the metadata necessary for the assistive
82 technologies. Qt provides implementations of this interface for
83 its built-in widgets as plugins.
84
85 When you develop custom widgets, you can create custom subclasses
86 of QAccessibleInterface and distribute them as plugins (using
87 QAccessiblePlugin) or compile them into the application.
88 Likewise, Qt's predefined accessibility support can be built as
89 plugin (the default) or directly into the Qt library. The main
90 advantage of using plugins is that the accessibility classes are
91 only loaded into memory if they are actually used; they don't
92 slow down the common case where no assistive technology is being
93 used.
94
95 Qt also includes two convenience classes, QAccessibleObject and
96 QAccessibleWidget, that inherit from QAccessibleInterface and
97 provide the lowest common denominator of metadata (e.g., widget
98 geometry, window title, basic help text). You can use them as
99 base classes when wrapping your custom QObject or QWidget
100 subclasses.
101
102 \sa QAccessibleInterface
103*/
104
105
106/*!
107 \class QAccessible::State
108
109 \inmodule QtGui
110
111 This structure defines bit flags that indicate
112 the state of an accessible object. The values are:
113
114 \value active The object is the active window or the active sub-element in a container (that would get focus when focusing the container).
115 \value adjustable The object represents an adjustable value, e.g. sliders.
116 \value animated The object's appearance changes frequently.
117 \value busy The object cannot accept input at the moment.
118 \value checkable The object is checkable.
119 \value checked The object's check box is checked.
120 \value checkStateMixed The third state of checkboxes (half checked in tri-state check boxes).
121 \value collapsed The object is collapsed, e.g. a closed listview item, or an iconified window.
122 \value defaultButton The object represents the default button in a dialog.
123 \value defunct The object no longer exists.
124 \value editable The object has a text carret (and often implements the text interface).
125 \value expandable The object is expandable, mostly used for cells in a tree view.
126 \value expanded The object is expanded, currently its children are visible.
127 \value extSelectable The object supports extended selection.
128 \value focusable The object can receive focus. Only objects in the active window can receive focus.
129 \value focused The object has keyboard focus.
130 \value hasPopup The object opens a popup.
131 \value hotTracked The object's appearance is sensitive to the mouse cursor position.
132 \value invalid The object is no longer valid (because it has been deleted).
133 \value invisible The object is not visible to the user.
134 \value linked The object is linked to another object, e.g. a hyperlink.
135 \value marqueed The object displays scrolling contents, e.g. a log view.
136 \value modal The object blocks input from other objects.
137 \value movable The object can be moved.
138 \value multiLine The object has multiple lines of text (word wrap), as opposed to a single line.
139 \value multiSelectable The object supports multiple selected items.
140 \value offscreen The object is clipped by the visible area. Objects that are off screen are also invisible.
141 \value passwordEdit The object is a password field, e.g. a line edit for entering a Password.
142 \value playsSound The object produces sound when interacted with.
143 \value pressed The object is pressed.
144 \value readOnly The object can usually be edited, but is explicitly set to read-only.
145 \value searchEdit The object is a line edit that is the input for search queries.
146 \value selectable The object is selectable.
147 \value selectableText The object has text which can be selected. This is different from selectable which refers to the object's children.
148 \value selected The object is selected, this is independent of text selection.
149 \value selfVoicing The object describes itself through speech or sound.
150 \value sizeable The object can be resized, e.g. top-level windows.
151 \value summaryElement The object summarizes the state of the window and should be treated with priority.
152 \value supportsAutoCompletion The object has auto-completion, for example in line edits or combo boxes.
153 \value traversed The object is linked and has been visited.
154 \value updatesFrequently The object changes frequently and needs to be refreshed when accessing it.
155 \value disabled The object is unavailable to the user, e.g. a disabled widget.
156
157 Implementations of QAccessibleInterface::state() return a combination
158 of these flags.
159*/
160
161/*!
162 \fn QAccessible::State::State()
163
164 Constructs a new QAccessible::State with all states set to false.
165*/
166
167/*!
168 \enum QAccessible::Event
169
170 This enum type defines accessible event types.
171
172 \omitvalue InvalidEvent \omit Internal: Used when creating subclasses of QAccessibleEvent. \endomit
173 \value AcceleratorChanged The keyboard accelerator for an action has been changed.
174 \value ActionChanged An action has been changed.
175 \value ActiveDescendantChanged
176 \value Alert A system alert (e.g., a message from a QMessageBox)
177 \value [since 6.8] Announcement The announcement of a message is requested.
178 \value AttributeChanged
179 \value ContextHelpEnd Context help (QWhatsThis) for an object is finished.
180 \value ContextHelpStart Context help (QWhatsThis) for an object is initiated.
181 \value DefaultActionChanged The default QAccessible::Action for the accessible
182 object has changed.
183 \value DescriptionChanged The object's QAccessible::Description changed.
184 \value DialogEnd A dialog (QDialog) has been hidden
185 \value DialogStart A dialog (QDialog) has been set visible.
186 \value DocumentContentChanged The contents of a text document have changed.
187 \value DocumentLoadComplete A document has been loaded.
188 \value DocumentLoadStopped A document load has been stopped.
189 \value DocumentReload A document reload has been initiated.
190 \value DragDropEnd A drag and drop operation is about to finished.
191 \value DragDropStart A drag and drop operation is about to be initiated.
192 \value Focus An object has gained keyboard focus.
193 \value ForegroundChanged A window has been activated (i.e., a new window has
194 gained focus on the desktop).
195 \value HelpChanged The QAccessible::Help text property of an object has
196 changed.
197 \value HyperlinkEndIndexChanged The end position of the display text for a hypertext
198 link has changed.
199 \value HyperlinkNumberOfAnchorsChanged The number of anchors in a hypertext link has changed,
200 perhaps because the display text has been split to
201 provide more than one link.
202 \value HyperlinkSelectedLinkChanged The link for the selected hypertext link has changed.
203 \value HyperlinkStartIndexChanged The start position of the display text for a hypertext
204 link has changed.
205 \value HypertextChanged The display text for a hypertext link has changed.
206 \value HypertextLinkActivated A hypertext link has been activated, perhaps by being
207 clicked or via a key press.
208 \value HypertextLinkSelected A hypertext link has been selected.
209 \value HypertextNLinksChanged
210 \value [since 6.8] IdentifierChanged The identifier of an object has changed.
211 \value LocationChanged An object's location on the screen has changed.
212 \value MenuCommand A menu item is triggered.
213 \value MenuEnd A menu has been closed (Qt uses PopupMenuEnd for all
214 menus).
215 \value MenuStart A menu has been opened on the menubar (Qt uses
216 PopupMenuStart for all menus).
217 \value NameChanged The QAccessible::Name property of an object has changed.
218 \value ObjectAttributeChanged
219 \value ObjectCreated A new object is created.
220 \value ObjectDestroyed An object is deleted.
221 \value ObjectHide An object is hidden; for example, with QWidget::hide().
222 Any children the object that is hidden has do not send
223 this event. It is not sent when an object is hidden as
224 it is being obscured by others.
225 \value ObjectReorder A layout or item view has added, removed, or moved an
226 object (Qt does not use this event).
227 \value ObjectShow An object is displayed; for example, with
228 QWidget::show().
229 \value PageChanged
230 \value ParentChanged An object's parent object changed.
231 \value PopupMenuEnd A pop-up menu has closed.
232 \value PopupMenuStart A pop-up menu has opened.
233 \value [since 6.11] RoleChanged The role of an object has changed.
234 \value ScrollingEnd A scrollbar scroll operation has ended (the mouse has
235 released the slider handle).
236 \value ScrollingStart A scrollbar scroll operation is about to start; this may
237 be caused by a mouse press on the slider handle, for
238 example.
239 \value ScrollingPositionChanged The position changed during a scroll operation.
240 \value SectionChanged
241 \value SelectionAdd An item has been added to the selection in an item view.
242 \value SelectionRemove An item has been removed from an item view selection.
243 \value Selection The selection has changed in a menu or item view.
244 \value SelectionWithin Several changes to a selection has occurred in an item
245 view.
246 \value SoundPlayed A sound has been played by an object
247 \omitvalue StateChanged \omit The QAccessible::State of an object has changed.
248 This value is used internally for the QAccessibleStateChangeEvent. \endomit
249 \value TableCaptionChanged A table caption has been changed.
250 \value TableColumnDescriptionChanged The description of a table column, typically found in
251 the column's header, has been changed.
252 \value TableColumnHeaderChanged A table column header has been changed.
253 \omitvalue TableModelChanged \omit The model providing data for a table has been changed. \endomit
254 \value TableRowDescriptionChanged The description of a table row, typically found in the
255 row's header, has been changed.
256 \value TableRowHeaderChanged A table row header has been changed.
257 \value TableSummaryChanged The summary of a table has been changed.
258 \omitvalue TextAttributeChanged
259 \omitvalue TextCaretMoved \omit The caret has moved in an editable widget.
260 The caret represents the cursor position in an editable
261 widget with the input focus. \endomit
262 \value TextColumnChanged A text column has been changed.
263 \omitvalue TextInserted \omit Text has been inserted into an editable widget. \endomit
264 \omitvalue TextRemoved \omit Text has been removed from an editable widget. \endomit
265 \omitvalue TextSelectionChanged \omit The selected text has changed in an editable widget. \endomit
266 \omitvalue TextUpdated \omit The text has been update in an editable widget. \endomit
267 \omitvalue ValueChanged \omit The QAccessible::Value of an object has changed. \endomit
268 \value VisibleDataChanged
269
270 The values for this enum are defined to be the same as those defined in the
271 \l{AccessibleEventID.idl File Reference}{IAccessible2} and
272 \l{Microsoft Active Accessibility Event Constants}{MSAA} specifications.
273*/
274
275/*!
276 \enum QAccessible::Role
277
278 This enum defines the role of an accessible object. The roles are:
279
280 \value AlertMessage An object that is used to alert the user.
281 \value Animation An object that displays an animation.
282 \value Application The application's main window.
283 \value Assistant An object that provides interactive help.
284 \value [since 6.9] BlockQuote A section of content that is quoted from another source.
285 \value Border An object that represents a border.
286 \value ButtonDropDown A button that drops down a list of items.
287 \value ButtonDropGrid A button that drops down a grid.
288 \value ButtonMenu A button that drops down a menu.
289 \value Canvas An object that displays graphics that the user can interact with.
290 \value Caret An object that represents the system caret (text cursor).
291 \value Cell A cell in a table.
292 \value Chart An object that displays a graphical representation of data.
293 \value CheckBox An object that represents an option that can be checked or unchecked. Some options provide a "mixed" state, e.g. neither checked nor unchecked.
294 \value Client The client area in a window.
295 \value Clock A clock displaying time.
296 \value ColorChooser A dialog that lets the user choose a color.
297 \value Column A column of cells, usually within a table.
298 \value ColumnHeader A header for a column of data.
299 \value ComboBox A list of choices that the user can select from.
300 \value ComplementaryContent A part of the document or web page that is complementary to the main content, usually a landmark (see WAI-ARIA).
301 \value Cursor An object that represents the mouse cursor.
302 \value Desktop The object represents the desktop or workspace.
303 \value Dial An object that represents a dial or knob.
304 \value Dialog A dialog box.
305 \value Document A document, for example in an office application.
306 \value EditableText Editable text such as a line or text edit.
307 \value Equation An object that represents a mathematical equation.
308 \value Footer A footer in a page (usually in documents).
309 \value Form A web form containing controls.
310 \value Graphic A graphic or picture, e.g. an icon.
311 \value Grip A grip that the user can drag to change the size of widgets.
312 \value Grouping An object that represents a logical grouping of other objects.
313 \value Heading A heading in a document.
314 \value HelpBalloon An object that displays help in a separate, short lived window.
315 \value HotkeyField A hotkey field that allows the user to enter a key sequence.
316 \value Indicator An indicator that represents a current value or item.
317 \value LayeredPane An object that can contain layered children, e.g. in a stack.
318 \value Link A link to something else.
319 \value List A list of items, from which the user can select one or more items.
320 \value ListItem An item in a list of items.
321 \value MenuBar A menu bar from which menus are opened by the user.
322 \value MenuItem An item in a menu or menu bar.
323 \value NoRole The object has no role. This usually indicates an invalid object.
324 \value Note A section whose content is parenthetic or ancillary to the main content of the resource.
325 \value Notification An object that represents a notification (e.g. in the system tray). This role only has an effect on Linux.
326 \value PageTab A page tab that the user can select to switch to a different page in a dialog.
327 \value PageTabList A list of page tabs.
328 \value Paragraph A paragraph of text (usually found in documents).
329 \value Pane A generic container.
330 \value PopupMenu A menu which lists options that the user can select to perform an action.
331 \value ProgressBar The object displays the progress of an operation in progress.
332 \value PropertyPage A property page where the user can change options and settings.
333 \value Button A button.
334 \value RadioButton An object that represents an option that is mutually exclusive with other options.
335 \value Row A row of cells, usually within a table.
336 \value RowHeader A header for a row of data.
337 \value ScrollBar A scroll bar, which allows the user to scroll the visible area.
338 \value Section A section (in a document).
339 \value Separator A separator that divides space into logical areas.
340 \value Slider A slider that allows the user to select a value within a given range.
341 \value Sound An object that represents a sound.
342 \value SpinBox A spin box widget that allows the user to enter a value within a given range.
343 \value Splitter A splitter distributing available space between its child widgets.
344 \value StaticText Static text, such as labels for other widgets.
345 \value StatusBar A status bar.
346 \value [since 6.11] Switch A switch that can be toggled on or off.
347 \value Table A table representing data in a grid of rows and columns.
348 \value Terminal A terminal or command line interface.
349 \value TitleBar The title bar caption of a window.
350 \value ToolBar A tool bar, which groups widgets that the user accesses frequently.
351 \value ToolTip A tool tip which provides information about other objects.
352 \value Tree A list of items in a tree structure.
353 \value TreeItem An item in a tree structure.
354 \value UserRole The first value to be used for user defined roles.
355 \value WebDocument HTML document, usually in a browser.
356 \value Whitespace Blank space between other objects.
357 \value Window A top level window.
358*/
359
360/*!
361 \enum QAccessible::RelationFlag
362
363 This enum type defines bit flags that can be combined to indicate
364 the relationship between two accessible objects. It is used by
365 the relations() function, which returns a list of all the related
366 interfaces of the calling object, together with the relations
367 for each object.
368
369 Each entry in the list is a std::pair where the \c second member stores
370 the relation type(s) between the \c returned object represented by the
371 \c first member and the \c origin (the caller) interface/object.
372
373 In the table below, the \c returned object refers to the object in
374 the returned list, and the \c origin object is the one represented
375 by the calling interface.
376
377 \value Label The \c returned object is the label for the \c origin object.
378 \value Labelled The \c returned object is labelled by the \c origin object.
379 \value Controller The \c returned object controls the \c origin object.
380 \value Controlled The \c returned object is controlled by the \c origin object.
381 \value [since 6.6] DescriptionFor The \c returned object provides a description for the \c origin object.
382 \value [since 6.6] Described The \c returned object is described by the \c origin object.
383 \value [since 6.6] FlowsFrom Content logically flows from the \c returned object to the \c origin object.
384 \value [since 6.6] FlowsTo Content logically flows to the \c returned object from the \c origin object.
385 \value AllRelations Used as a mask to specify that we are interesting in information
386 about all relations
387
388 Implementations of relations() return a combination of these flags.
389 Some values are mutually exclusive.
390*/
391
392/*!
393 \enum QAccessible::Text
394
395 This enum specifies string information that an accessible object
396 returns.
397
398 \value Name The name of the object. This can be used both
399 as an identifier or a short description by
400 accessible clients.
401 \value Description A short text describing the object.
402 \value Value The value of the object.
403 \value Help A longer text giving information about how to use the object.
404 \value Accelerator The keyboard shortcut that executes the object's default action.
405 \value UserText The first value to be used for user defined text.
406 \value [since 6.8] Identifier An identifier for the object for e.g. UI tests.
407 \omitvalue DebugDescription
408*/
409
410/*! \enum QAccessible::TextBoundaryType
411 This enum describes different types of text boundaries. It follows the IAccessible2 API and is used in the \l QAccessibleTextInterface.
412
413 \value CharBoundary Use individual characters as boundary.
414 \value WordBoundary Use words as boundaries.
415 \value SentenceBoundary Use sentences as boundary.
416 \value ParagraphBoundary Use paragraphs as boundary.
417 \value LineBoundary Use newlines as boundary.
418 \value NoBoundary No boundary (use the whole text).
419
420 \sa QAccessibleTextInterface
421*/
422
423/*! \enum QAccessible::Attribute
424 This enum describes different types of attributes used by the
425 \l QAccessibleAttributesInterface.
426 \since 6.8
427
428 These attributes are comparable to the concept of properties/(object)
429 attributes found in ARIA, AT-SPI2, IAccessible, UIA and NSAccessibility
430 and are mapped to their platform counterpart where applicable.
431
432 Each attribute is handled as a key-value pair, with the values of this
433 enumeration being used as keys.
434
435 Attribute values are represented in a \l QVariant. The type of the value
436 stored in the \l QVariant is fixed and specified below for each of the
437 attribute types.
438
439 \value Custom value type: \a QHash<QString, QString>
440 The \a Custom attribute is special in that
441 it can effectively represent multiple attributes at
442 once, since it itself is a \l QHash used to represent
443 key-value pairs.
444 For platforms supporting custom key-value pairs for
445 attributes, those set in the \a Custom attribute
446 are bridged to the platform layer without applying any
447 translation to platform-specific attributes. In general,
448 the other, more strongly typed attributes should be used.
449 This attribute can e.g. be used for prototyping
450 before officially adding an official new enumeration value
451 for a specific feature.
452 \value Level value type: \a int
453 Defines the hierarchical level of an element within a structure,
454 e.g. the heading level of a heading. This attribute conceptually
455 matches the "aria-level" property in ARIA.
456 \value [since 6.10] Locale value type: \a QLocale
457 Locale of the element.
458 This can be used to specify that an element has a locale that
459 differs from the application's default locale, e.g. for documents
460 or paragraphs within a document that use a language that differs
461 from the application's user interface language.
462 \value [since 6.11] Orientation value type: \a Qt::Orientation
463 Orientation of the element. This attribute conceptually matches
464 the "aria-orientation" property in ARIA.
465
466 \sa QAccessibleAttributesInterface
467*/
468
469/*! \enum QAccessible::AnnouncementPoliteness
470 This enum describes the priority for announcements used by the
471 \l QAccessibleAnnouncementEvent.
472 \since 6.8
473
474 With \a QAccessible::AnouncementPoliteness::Polite, assistive technologies
475 should announce the message at the next graceful opportunity such as at the
476 end of speaking the current sentence or when the user pauses typing. A
477 polite announcement might still interrupt an ongoing polite announcement.
478
479 When specifying \a QAccessible::AnouncementPoliteness::Assertive, assistive
480 technologies should notify the user immediately.
481
482 Because an interruption might disorient users or cause them to not complete
483 their current task, \a QAccessible::AnouncementPoliteness::Assertive should
484 not be used unless the interruption is imperative.
485
486 \value Polite The announcement has normal priority.
487 \value Assertive The announcement has high priority and should notify
488 the user immediately, even if that means interrupting the user's
489 current task.
490
491 \sa QAccessibleAnnouncementEvent
492*/
493
494
495/*!
496 \enum QAccessible::InterfaceType
497
498 \l QAccessibleInterface supports several sub interfaces.
499 In order to provide more information about some objects, their accessible
500 representation should implement one or more of these interfaces.
501
502 \note When subclassing one of these interfaces, \l QAccessibleInterface::interface_cast() needs to be implemented.
503
504 \value TextInterface For text that supports selections or is more than one line. Simple labels do not need to implement this interface.
505 \omitvalue EditableTextInterface \omit For text that can be edited by the user. \endomit
506 \value ValueInterface For objects that are used to manipulate a value, for example slider or scroll bar.
507 \value ActionInterface For interactive objects that allow the user to trigger an action. Basically everything that allows for example mouse interaction.
508 \omitvalue ImageInterface \omit For objects that represent an image. This interface is generally less important. \endomit
509 \value TableInterface For lists, tables and trees.
510 \value TableCellInterface For cells in a TableInterface object.
511 \value HyperlinkInterface For hyperlink nodes (usually embedded as children of text nodes)
512 \value [since 6.5] SelectionInterface For non-text objects that support selection of child objects.
513 \value [since 6.8] AttributesInterface For objects that support object-specific attributes.
514 \value [since 6.12] ViewportInterface For objects that allow 2-dimensional or indexed scrolling.
515
516 \sa QAccessibleInterface::interface_cast(), QAccessibleTextInterface, QAccessibleValueInterface, QAccessibleActionInterface, QAccessibleTableInterface, QAccessibleTableCellInterface, QAccessibleSelectionInterface, QAccessibleAttributesInterface, QAccessibleViewportInterface
517*/
518
519#if QT_CONFIG(accessibility)
520
521/*!
522 Destroys the QAccessibleInterface.
523*/
524QAccessibleInterface::~QAccessibleInterface()
525{
526}
527
528/*!
529 \typedef QAccessible::Id
530
531 Synonym for unsigned, used by the QAccessibleInterface cache.
532*/
533
534
535/* accessible widgets plugin discovery stuff */
536Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, acLoader,
537 (QAccessibleFactoryInterface_iid, "/accessible"_L1))
538typedef QHash<QString, QAccessiblePlugin*> QAccessiblePluginsHash;
539Q_GLOBAL_STATIC(QAccessiblePluginsHash, qAccessiblePlugins)
540
541// FIXME turn this into one global static struct
542Q_GLOBAL_STATIC(QList<QAccessible::InterfaceFactory>, qAccessibleFactories)
543Q_GLOBAL_STATIC(QList<QAccessible::ActivationObserver *>, qAccessibleActivationObservers)
544
545QAccessible::UpdateHandler QAccessible::updateHandler = nullptr;
546QAccessible::RootObjectHandler QAccessible::rootObjectHandler = nullptr;
547
548static bool cleanupAdded = false;
549
550static QPlatformAccessibility *platformAccessibility()
551{
552 QPlatformIntegration *pfIntegration = QGuiApplicationPrivate::platformIntegration();
553 return pfIntegration ? pfIntegration->accessibility() : nullptr;
554}
555
556/*!
557 \fn QAccessible::QAccessible()
558 \internal
559
560 This class is purely a collection of enums and static functions,
561 it is not supposed to be instantiated.
562*/
563
564
565/*!
566 \internal
567*/
568void QAccessible::cleanup()
569{
570 if (QPlatformAccessibility *pfAccessibility = platformAccessibility())
571 pfAccessibility->cleanup();
572}
573
574static void qAccessibleCleanup()
575{
576 qAccessibleActivationObservers()->clear();
577 qAccessibleFactories()->clear();
578}
579
580/*!
581 \typedef QAccessible::InterfaceFactory
582
583 This is a typedef for a pointer to a function with the following
584 signature:
585
586 \snippet code/src_gui_accessible_qaccessible.cpp 1
587
588 The function receives a QString and a QObject pointer, where the
589 QString is the key identifying the interface. The QObject is used
590 to pass on to the QAccessibleInterface so that it can hold a reference
591 to it.
592
593 If the key and the QObject does not have a corresponding
594 QAccessibleInterface, \nullptr will be returned.
595
596 Installed factories are called by queryAccessibilityInterface() until
597 one provides an interface.
598*/
599
600/*!
601 \typedef QAccessible::UpdateHandler
602
603 \internal
604
605 A function pointer type. Use a function with this prototype to install
606 your own update function.
607
608 The function is called by updateAccessibility().
609*/
610
611/*!
612 \typedef QAccessible::RootObjectHandler
613
614 \internal
615
616 A function pointer type. Use a function with this prototype to install
617 your own root object handler.
618
619 The function is called by setRootObject().
620*/
621
622
623/*!
624 Installs the InterfaceFactory \a factory. The last factory added
625 is the first one used by queryAccessibleInterface().
626*/
627void QAccessible::installFactory(InterfaceFactory factory)
628{
629 if (!factory)
630 return;
631
632 if (!cleanupAdded) {
633 qAddPostRoutine(qAccessibleCleanup);
634 cleanupAdded = true;
635 }
636 if (qAccessibleFactories()->contains(factory))
637 return;
638 qAccessibleFactories()->append(factory);
639}
640
641/*!
642 Removes \a factory from the list of installed InterfaceFactories.
643*/
644void QAccessible::removeFactory(InterfaceFactory factory)
645{
646 qAccessibleFactories()->removeAll(factory);
647}
648
649/*!
650 \internal
651
652 Installs the given \a handler as the function to be used by
653 updateAccessibility(), and returns the previously installed
654 handler.
655*/
656QAccessible::UpdateHandler QAccessible::installUpdateHandler(UpdateHandler handler)
657{
658 UpdateHandler old = updateHandler;
659 updateHandler = handler;
660 return old;
661}
662
663/*!
664 \internal
665
666 Installs the given \a handler as the function to be used by setRootObject(),
667 and returns the previously installed handler.
668*/
669QAccessible::RootObjectHandler QAccessible::installRootObjectHandler(RootObjectHandler handler)
670{
671 RootObjectHandler old = rootObjectHandler;
672 rootObjectHandler = handler;
673 return old;
674}
675
676/*!
677 \class QAccessible::ActivationObserver
678 \internal
679
680 Interface to listen to activation or deactivation of the accessibility framework.
681 \sa installActivationObserver()
682*/
683
684QAccessible::ActivationObserver::~ActivationObserver()
685{
686}
687
688/*!
689 \internal
690
691 Install \a observer to get notified of activation or deactivation (global accessibility has been enabled or disabled).
692*/
693void QAccessible::installActivationObserver(QAccessible::ActivationObserver *observer)
694{
695 if (!observer)
696 return;
697
698 if (!cleanupAdded) {
699 qAddPostRoutine(qAccessibleCleanup);
700 cleanupAdded = true;
701 }
702 if (qAccessibleActivationObservers()->contains(observer))
703 return;
704 qAccessibleActivationObservers()->append(observer);
705
706 // Make sure the newly added observer gets a callback on the next
707 // QPlatformAccessibility::setActive() callback
708 if (QPlatformAccessibility *pfAccessibility = platformAccessibility())
709 pfAccessibility->clearActiveNotificationState();
710}
711
712/*!
713 \internal
714
715 Remove an \a observer to no longer get notified of state changes.
716 \sa installActivationObserver()
717*/
718void QAccessible::removeActivationObserver(ActivationObserver *observer)
719{
720 qAccessibleActivationObservers()->removeAll(observer);
721}
722
723/*!
724 \internal
725
726 Sends accessibility activation notifications to all registered observers.
727*/
728void qAccessibleNotifyActivationObservers(bool active)
729{
730 for (int i = 0; i < qAccessibleActivationObservers()->size(); ++i)
731 qAccessibleActivationObservers()->at(i)->accessibilityActiveChanged(active);
732}
733
734/*!
735 If a QAccessibleInterface implementation exists for the given \a object,
736 this function returns a pointer to the implementation; otherwise it
737 returns \nullptr.
738
739 The function calls all installed factory functions (from most
740 recently installed to least recently installed) until one is found
741 that provides an interface for the class of \a object. If no
742 factory can provide an accessibility implementation for the class
743 the function loads installed accessibility plugins, and tests if
744 any of the plugins can provide the implementation.
745
746 If no implementation for the object's class is available, the
747 function tries to find an implementation for the object's parent
748 class, using the above strategy.
749
750 All interfaces are managed by an internal cache and should not be deleted.
751*/
752QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
753{
754 if (!object)
755 return nullptr;
756
757 if (Id id = QAccessibleCache::instance()->idForObject(object))
758 return QAccessibleCache::instance()->interfaceForId(id);
759
760 // Create a QAccessibleInterface for the object class. Start by the most
761 // derived class and walk up the class hierarchy.
762 const QMetaObject *mo = object->metaObject();
763 const auto *objectPriv = QObjectPrivate::get(object);
764 /*
765 We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
766 Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
767 accessible interface in any case. Instead, we start the whole checking
768 with the first non-dynamic meta-object. To avoid potential regressions
769 in other areas of Qt that also use dynamic metaobjects, we only do this
770 for objects that are QML-related (approximated by checking whether they
771 have ddata set).
772 */
773 const bool qmlRelated = !objectPriv->isDeletingChildren &&
774 objectPriv->declarativeData;
775 while (qmlRelated && mo) {
776 auto mop = QMetaObjectPrivate::get(mo);
777 if (!mop || !(mop->flags & DynamicMetaObject))
778 break;
779
780 mo = mo->superClass();
781 };
782 while (mo) {
783 const QString cn = QLatin1StringView(mo->className());
784
785 // Check if the class has a InterfaceFactory installed.
786 for (int i = qAccessibleFactories()->size(); i > 0; --i) {
787 InterfaceFactory factory = qAccessibleFactories()->at(i - 1);
788 if (QAccessibleInterface *iface = factory(cn, object)) {
789 QAccessibleCache::instance()->insert(object, iface);
790 Q_ASSERT(QAccessibleCache::instance()->containsObject(object));
791 return iface;
792 }
793 }
794 // Find a QAccessiblePlugin (factory) for the class name. If there's
795 // no entry in the cache try to create it using the plugin loader.
796 if (!qAccessiblePlugins()->contains(cn)) {
797 QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
798 const int index = acLoader()->indexOf(cn);
799 if (index != -1)
800 factory = qobject_cast<QAccessiblePlugin *>(acLoader()->instance(index));
801 qAccessiblePlugins()->insert(cn, factory);
802 }
803
804 // At this point the cache should contain a valid factory pointer or 0:
805 Q_ASSERT(qAccessiblePlugins()->contains(cn));
806 QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
807 if (factory) {
808 QAccessibleInterface *result = factory->create(cn, object);
809 if (result) {
810 QAccessibleCache::instance()->insert(object, result);
811 Q_ASSERT(QAccessibleCache::instance()->containsObject(object));
812 }
813 return result;
814 }
815 mo = mo->superClass();
816 }
817
818 if (object == qApp) {
819 QAccessibleInterface *appInterface = new QAccessibleApplication;
820 QAccessibleCache::instance()->insert(object, appInterface);
821 Q_ASSERT(QAccessibleCache::instance()->containsObject(qApp));
822 return appInterface;
823 }
824
825 return nullptr;
826}
827
828/*!
829 \brief Call this function to ensure that manually created interfaces
830 are properly memory managed.
831
832 Must only be called exactly once per interface \a iface.
833 This is implicitly called when calling queryAccessibleInterface,
834 calling this function is only required when QAccessibleInterfaces
835 are instantiated with the "new" operator. This is not recommended,
836 whenever possible use the default functions and let \l queryAccessibleInterface()
837 take care of this.
838
839 When it is necessary to reimplement the QAccessibleInterface::child() function
840 and returning the child after constructing it, this function needs to be called.
841 */
842QAccessible::Id QAccessible::registerAccessibleInterface(QAccessibleInterface *iface)
843{
844 Q_ASSERT(iface);
845 return QAccessibleCache::instance()->insert(iface->object(), iface);
846}
847
848/*!
849 Removes the interface belonging to this \a id from the cache and
850 deletes it. The id becomes invalid an may be re-used by the
851 cache.
852*/
853void QAccessible::deleteAccessibleInterface(Id id)
854{
855 QAccessibleCache::instance()->deleteInterface(id);
856}
857
858/*!
859 Returns the unique ID for the QAccessibleInterface \a iface.
860*/
861QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface)
862{
863 Id id = QAccessibleCache::instance()->idForInterface(iface);
864 if (!id)
865 id = registerAccessibleInterface(iface);
866 return id;
867}
868
869/*!
870 Returns the QAccessibleInterface belonging to the \a id.
871
872 Returns \nullptr if the id is invalid.
873*/
874QAccessibleInterface *QAccessible::accessibleInterface(Id id)
875{
876 return QAccessibleCache::instance()->interfaceForId(id);
877}
878
879
880/*!
881 Returns \c true if the platform requested accessibility information.
882
883 This function will return false until a tool such as a screen reader
884 accessed the accessibility framework. It is still possible to use
885 \l QAccessible::queryAccessibleInterface() even if accessibility is not
886 active. But there will be no notifications sent to the platform.
887
888 It is recommended to use this function to prevent expensive notifications
889 via updateAccessibility() when they are not needed.
890*/
891bool QAccessible::isActive()
892{
893 if (QPlatformAccessibility *pfAccessibility = platformAccessibility())
894 return pfAccessibility->isActive();
895 return false;
896}
897
898/*!
899 \internal
900*/
901void QAccessible::setActive(bool active)
902{
903 if (QPlatformAccessibility *pfAccessibility = platformAccessibility())
904 pfAccessibility->setActive(active);
905}
906
907/*!
908 Sets the root object of the accessible objects of this application
909 to \a object. All other accessible objects are reachable using object
910 navigation from the root object.
911
912 Normally, it isn't necessary to call this function, because Qt sets
913 the QApplication object as the root object immediately before the
914 event loop is entered in QApplication::exec().
915
916 Use QAccessible::installRootObjectHandler() to redirect the function
917 call to a customized handler function.
918
919 \sa queryAccessibleInterface()
920*/
921void QAccessible::setRootObject(QObject *object)
922{
923 if (rootObjectHandler) {
924 rootObjectHandler(object);
925 return;
926 }
927
928 if (QPlatformAccessibility *pfAccessibility = platformAccessibility())
929 pfAccessibility->setRootObject(object);
930}
931
932/*!
933 Notifies about a change that might be relevant for accessibility clients.
934
935 \a event provides details about the change. These include the source
936 of the change and the nature of the change. The \a event should
937 contain enough information give meaningful notifications.
938
939 For example, the type \c ValueChange indicates that the position of
940 a slider has been changed.
941
942 Call this function whenever the state of your accessible object or
943 one of its sub-elements has been changed either programmatically
944 (e.g. by calling QLabel::setText()) or by user interaction.
945
946 If there are no accessibility tools listening to this event, the
947 performance penalty for calling this function is small, but if
948 determining the parameters of the call is expensive you can test
949 QAccessible::isActive() to avoid unnecessary computation.
950*/
951void QAccessible::updateAccessibility(QAccessibleEvent *event)
952{
953 // NOTE: Querying for the accessibleInterface below will result in
954 // resolving and caching the interface, which in some cases will
955 // cache the wrong information as updateAccessibility is called
956 // during construction of widgets. If you see cases where the
957 // cache seems wrong, this call is "to blame", but the code that
958 // caches dynamic data should be updated to handle change events.
959 if (isActive()) {
960 QAccessibleInterface *iface = event->accessibleInterface();
961 if (iface) {
962 if (event->type() == QAccessible::TableModelChanged) {
963 if (iface->tableInterface())
964 iface->tableInterface()->modelChange(static_cast<QAccessibleTableModelChangeEvent*>(event));
965 }
966 }
967 }
968 if (updateHandler) {
969 updateHandler(event);
970 return;
971 }
972
973 if (QPlatformAccessibility *pfAccessibility = platformAccessibility())
974 pfAccessibility->notifyAccessibilityUpdate(event);
975}
976
977static std::pair<int, int> qAccessibleTextBoundaryHelperHelper(QTextCursor &cursor,
978 QTextCursor::MoveOperation start,
979 QTextCursor::MoveOperation end)
980{
981 std::pair<int, int> result;
982 cursor.movePosition(start, QTextCursor::MoveAnchor);
983 result.first = cursor.position();
984 cursor.movePosition(end, QTextCursor::KeepAnchor);
985 result.second = cursor.position();
986 return result;
987}
988
989/*!
990 \internal
991 \brief qAccessibleTextBoundaryHelper is a helper function to find the accessible text boundaries for QTextCursor based documents.
992 \param documentCursor a valid cursor bound to the document (not null). It needs to ba at the position to look for the boundary
993 \param boundaryType the type of boundary to find
994 \return the boundaries as pair
995*/
996std::pair< int, int > QAccessible::qAccessibleTextBoundaryHelper(const QTextCursor &offsetCursor, TextBoundaryType boundaryType)
997{
998 Q_ASSERT(!offsetCursor.isNull());
999
1000 QTextCursor cursor = offsetCursor;
1001 switch (boundaryType) {
1002 case CharBoundary:
1003 return qAccessibleTextBoundaryHelperHelper(cursor, QTextCursor::NoMove,
1004 QTextCursor::NextCharacter);
1005 case WordBoundary:
1006 return qAccessibleTextBoundaryHelperHelper(cursor, QTextCursor::StartOfWord,
1007 QTextCursor::EndOfWord);
1008 case SentenceBoundary: {
1009 // QCursor does not provide functionality to move to next sentence.
1010 // We therefore find the current block, then go through the block using
1011 // QTextBoundaryFinder and find the sentence the \offset represents
1012 std::pair<int, int> result = qAccessibleTextBoundaryHelperHelper(
1013 cursor, QTextCursor::StartOfBlock, QTextCursor::EndOfBlock);
1014 QString blockText = cursor.selectedText();
1015 const int offsetWithinBlockText = offsetCursor.position() - result.first;
1016 QTextBoundaryFinder sentenceFinder(QTextBoundaryFinder::Sentence, blockText);
1017 sentenceFinder.setPosition(offsetWithinBlockText);
1018 int prevBoundary = offsetWithinBlockText;
1019 int nextBoundary = offsetWithinBlockText;
1020 if (!(sentenceFinder.boundaryReasons() & QTextBoundaryFinder::StartOfItem))
1021 prevBoundary = sentenceFinder.toPreviousBoundary();
1022 nextBoundary = sentenceFinder.toNextBoundary();
1023 if (nextBoundary != -1)
1024 result.second = result.first + nextBoundary;
1025 if (prevBoundary != -1)
1026 result.first += prevBoundary;
1027 return result;
1028 }
1029 case LineBoundary:
1030 return qAccessibleTextBoundaryHelperHelper(cursor, QTextCursor::StartOfLine,
1031 QTextCursor::EndOfLine);
1032 case ParagraphBoundary:
1033 return qAccessibleTextBoundaryHelperHelper(cursor, QTextCursor::StartOfBlock,
1034 QTextCursor::EndOfBlock);
1035 case NoBoundary:
1036 return qAccessibleTextBoundaryHelperHelper(cursor, QTextCursor::Start, QTextCursor::End);
1037 }
1038
1039 Q_UNREACHABLE_RETURN({});
1040}
1041
1042/*!
1043 \class QAccessibleInterface
1044 \brief The QAccessibleInterface class defines an interface that exposes information
1045 about accessible objects.
1046
1047 \ingroup accessibility
1048 \inmodule QtGui
1049
1050 This class is part of \l {Accessibility for QWidget Applications}.
1051
1052 Accessibility tools (also called AT Clients), such as screen readers
1053 or braille displays, require high-level information about
1054 accessible objects in an application. Accessible objects provide
1055 specialized input and output methods, making it possible for users
1056 to use accessibility tools with enabled applications (AT Servers).
1057
1058 Every element that the user needs to interact with or react to is
1059 an accessible object, and should provide this information. These
1060 are mainly visual objects, such as widgets and widget elements, but
1061 can also be content, such as sounds.
1062
1063 The AT client uses three basic concepts to acquire information
1064 about any accessible object in an application:
1065 \list
1066 \li \e Properties The client can read information about
1067 accessible objects. In some cases the client can also modify these
1068 properties; such as text in a line edit.
1069 \li \e Actions The client can invoke actions like pressing a button
1070 or .
1071 \li \e{Relationships and Navigation} The client can traverse from one
1072 accessible object to another, using the relationships between objects.
1073 \endlist
1074
1075 The QAccessibleInterface defines the API for these three concepts.
1076
1077 \section1 Relationships and Navigation
1078
1079 The functions childCount() and indexOfChild() return the number of
1080 children of an accessible object and the index a child object has
1081 in its parent. The childAt() function returns a child QAccessibleInterface
1082 that is found at a position. The child does not have to be a direct
1083 child. This allows bypassing intermediate layers when the parent already knows the
1084 top-most child. childAt() is used for hit testing (finding the object
1085 under the mouse).
1086
1087 The relations() function provides information about the relations an
1088 object has to other objects, and parent() and child() allows
1089 traversing from one object to another object.
1090
1091 \section1 Properties
1092
1093 The central property of an accessible objects is what role() it
1094 has. Different objects can have the same role, e.g. both the "Add
1095 line" element in a scroll bar and the \c OK button in a dialog have
1096 the same role, "button". The role implies what kind of
1097 interaction the user can perform with the user interface element.
1098
1099 An object's state() property is a combination of different state
1100 flags and can describe both how the object's state differs from a
1101 "normal" state, e.g. it might be unavailable, and also how it
1102 behaves, e.g. it might be selectable.
1103
1104 The text() property provides textual information about the object.
1105 An object usually has a name, but can provide extended information
1106 such as a description, help text, or information about any
1107 keyboard accelerators it provides. Some objects allow changing the
1108 text() property through the setText() function, but this
1109 information is in most cases read-only.
1110
1111 The rect() property provides information about the geometry of an
1112 accessible object. This information is usually only available for
1113 visual objects.
1114
1115 \section1 Interfaces
1116
1117 To enable the user to interact with an accessible object the
1118 object must implement QAccessibleActionInterface in addition to
1119 QAccessibleInterface.
1120 Objects that support selections can define actions to change the selection.
1121
1122 There are several other interfaces that should be implemented as required.
1123 QAccessibleTextInterface should be used for bigger texts edits such as document views.
1124 This interface should not be implemented for labels/single line edits.
1125
1126 For sliders, scrollbars and other numerical value selectors QAccessibleValueInterface
1127 should be implemented.
1128
1129 Lists, tables and trees should implement QAccessibleTableInterface.
1130
1131 Scrollable views should implement QAccessibleViewportInterface.
1132
1133 \sa QAccessible, QAccessibleActionInterface, QAccessibleTextInterface, QAccessibleValueInterface, QAccessibleTableInterface, QAccessibleViewportInterface
1134*/
1135
1136/*!
1137 \fn bool QAccessibleInterface::isValid() const
1138
1139 Returns \c true if all the data necessary to use this interface
1140 implementation is valid (e.g. all pointers are non-null);
1141 otherwise returns \c false.
1142
1143 \sa object()
1144*/
1145
1146/*!
1147 \fn QObject *QAccessibleInterface::object() const
1148
1149 Returns a pointer to the QObject this interface implementation provides
1150 information for.
1151
1152 \sa isValid()
1153*/
1154
1155/*!
1156 \fn int QAccessibleInterface::childCount() const
1157
1158 Returns the number of children that belong to this object. A child
1159 can provide accessibility information on its own (e.g. a child
1160 widget), or be a sub-element of this accessible object.
1161
1162 All objects provide this information.
1163
1164 \sa indexOfChild()
1165*/
1166
1167/*!
1168 \fn int QAccessibleInterface::indexOfChild(const QAccessibleInterface *child) const
1169
1170 Returns the 0-based index of the object \a child in this object's
1171 children list, or -1 if \a child is not a child of this object.
1172
1173 All objects provide this information about their children.
1174
1175 \sa childCount()
1176*/
1177
1178/*!
1179 Returns the meaningful relations to other widgets. Usually this will not return parent/child
1180 relations, unless they are handled in a specific way such as in tree views.
1181 It will typically return the labelled-by and label relations.
1182
1183 It is possible to filter the relations by using the optional parameter \a match.
1184 It should never return itself.
1185
1186 \sa parent(), child()
1187*/
1188QList<std::pair<QAccessibleInterface*, QAccessible::Relation>>
1189QAccessibleInterface::relations(QAccessible::Relation match) const
1190{
1191 Q_UNUSED(match);
1192 return { };
1193}
1194
1195/*!
1196 Returns the object that has the keyboard focus.
1197
1198 The object returned can be any descendant, including itself.
1199*/
1200QAccessibleInterface *QAccessibleInterface::focusChild() const
1201{
1202 return nullptr;
1203}
1204
1205/*!
1206 \fn QAccessibleInterface *QAccessibleInterface::childAt(int x, int y) const
1207
1208 Returns the QAccessibleInterface of a child that contains the screen coordinates (\a x, \a y).
1209 If there are no children at this position this function returns \nullptr.
1210 The returned accessible must be a child, but not necessarily a direct child.
1211
1212 This function is only reliable for visible objects (invisible
1213 object might not be laid out correctly).
1214
1215 All visual objects provide this information.
1216
1217 A default implementation is provided for objects inheriting QAccessibleObject. This will iterate
1218 over all children. If the widget manages its children (e.g. a table) it will be more efficient
1219 to write a specialized implementation.
1220
1221 \sa rect()
1222*/
1223
1224/*!
1225 \fn QAccessibleInterface* QAccessibleInterface::parent() const
1226
1227 Returns the QAccessibleInterface of the parent in the accessible object hierarchy.
1228
1229 Returns \nullptr if no parent exists (e.g. for the top level application object).
1230
1231 \sa child()
1232*/
1233
1234/*!
1235 \fn QAccessibleInterface* QAccessibleInterface::child(int index) const
1236
1237 Returns the accessible child with index \a index.
1238 0-based index. The number of children of an object can be checked with childCount.
1239
1240 Returns \nullptr when asking for an invalid child (e.g. when the child became invalid in the meantime).
1241
1242 \sa childCount(), parent()
1243*/
1244
1245/*!
1246 \fn QString QAccessibleInterface::text(QAccessible::Text t) const
1247
1248 Returns the value of the text property \a t of the object.
1249
1250 The \l QAccessible::Name is a string used by clients to identify, find, or
1251 announce an accessible object for the user. All objects must have
1252 a name that is unique within their container. The name can be
1253 used differently by clients, so the name should both give a
1254 short description of the object and be unique.
1255
1256 An accessible object's \l QAccessible::Description provides textual information
1257 about an object's visual appearance. The description is primarily
1258 used to provide greater context for vision-impaired users, but is
1259 also used for context searching or other applications. Not all
1260 objects have a description. An "OK" button would not need a
1261 description, but a tool button that shows a picture of a smiley
1262 would.
1263
1264 The \l QAccessible::Value of an accessible object represents visual information
1265 contained by the object, e.g. the text in a line edit. Usually,
1266 the value can be modified by the user. Not all objects have a
1267 value, e.g. static text labels don't, and some objects have a
1268 state that already is the value, e.g. toggle buttons.
1269
1270 The \l QAccessible::Help text provides information about the function and
1271 usage of an accessible object. Not all objects provide this
1272 information.
1273
1274 The \l QAccessible::Accelerator is a keyboard shortcut that activates the
1275 object's default action. A keyboard shortcut is the underlined
1276 character in the text of a menu, menu item or widget, and is
1277 either the character itself, or a combination of this character
1278 and a modifier key like Alt, Ctrl or Shift. Command controls like
1279 tool buttons also have shortcut keys and usually display them in
1280 their tooltip.
1281
1282 The \l QAccessible::Identifier can be explicitly set to provide an
1283 ID to assistive technologies. This can be especially useful for UI tests.
1284 If no identifier has been explicitly set, the identifier is set by the
1285 respective interface to an ID based on \l QObject::objectName or its
1286 class name and \l QObject::objectName or class name of the parents
1287 in its parents chain.
1288
1289 All objects provide a string for \l QAccessible::Name.
1290
1291 \sa role(), state()
1292*/
1293
1294/*!
1295 \fn void QAccessibleInterface::setText(QAccessible::Text t, const QString &text)
1296
1297 Sets the text property \a t of the object to \a text.
1298
1299 Note that the text properties of most objects are read-only
1300 so calling this function might have no effect.
1301
1302 \sa text()
1303*/
1304
1305/*!
1306 \fn QRect QAccessibleInterface::rect() const
1307
1308 Returns the geometry of the object. The geometry is in screen coordinates.
1309
1310 This function is only reliable for visible objects (invisible
1311 objects might not be laid out correctly).
1312
1313 All visual objects provide this information.
1314
1315 \sa childAt()
1316*/
1317
1318/*!
1319 \fn QAccessible::Role QAccessibleInterface::role() const
1320
1321 Returns the role of the object.
1322 The role of an object is usually static.
1323
1324 All accessible objects have a role.
1325
1326 \sa text(), state()
1327*/
1328
1329/*!
1330 \fn QAccessible::State QAccessibleInterface::state() const
1331
1332 Returns the current state of the object.
1333 The returned value is a combination of the flags in
1334 the QAccessible::StateFlag enumeration.
1335
1336 All accessible objects have a state.
1337
1338 \sa text(), role()
1339*/
1340
1341/*!
1342 Returns the accessible's foreground color if applicable or an invalid QColor.
1343
1344 \sa backgroundColor()
1345*/
1346QColor QAccessibleInterface::foregroundColor() const
1347{
1348 return QColor();
1349}
1350
1351/*!
1352 Returns the accessible's background color if applicable or an invalid QColor.
1353
1354 \sa foregroundColor()
1355*/
1356QColor QAccessibleInterface::backgroundColor() const
1357{
1358 return QColor();
1359}
1360
1361/*!
1362 \fn QAccessibleTextInterface *QAccessibleInterface::textInterface()
1363*/
1364
1365/*!
1366 \fn QAccessibleTextInterface *QAccessibleInterface::editableTextInterface()
1367 \internal
1368*/
1369
1370/*!
1371 \fn QAccessibleValueInterface *QAccessibleInterface::valueInterface()
1372*/
1373
1374/*!
1375 \fn QAccessibleTableInterface *QAccessibleInterface::tableInterface()
1376*/
1377
1378/*!
1379 \fn QAccessibleTableCellInterface *QAccessibleInterface::tableCellInterface()
1380*/
1381
1382/*!
1383 \fn QAccessibleActionInterface *QAccessibleInterface::actionInterface()
1384*/
1385
1386/*!
1387 \fn QAccessibleImageInterface *QAccessibleInterface::imageInterface()
1388 \internal
1389*/
1390
1391/*!
1392 \fn QAccessibleSelectionInterface *QAccessibleInterface::selectionInterface()
1393 \since 6.5
1394*/
1395
1396/*!
1397 \fn QAccessibleViewportInterface *QAccessibleInterface::viewportInterface()
1398 \since 6.12
1399*/
1400
1401/*!
1402 \class QAccessibleEvent
1403 \ingroup accessibility
1404 \inmodule QtGui
1405
1406 \brief The QAccessibleEvent class is the base class for accessibility notifications.
1407
1408 This class is used with \l QAccessible::updateAccessibility().
1409
1410 The event type is one of the values of \l QAccessible::Event.
1411 There are a number of subclasses that should be used to provide more details about the
1412 event.
1413
1414 For example to notify about a focus change when re-implementing QWidget::setFocus,
1415 the event could be used as follows:
1416 \snippet code/src_gui_accessible_qaccessible.cpp 2
1417
1418 To enable in process screen readers, all events must be sent after the change has happened.
1419*/
1420
1421/*! \fn QAccessibleEvent::QAccessibleEvent(QObject *object, QAccessible::Event type)
1422
1423 Constructs a QAccessibleEvent to notify that \a object has changed.
1424 The event \a type describes what changed.
1425*/
1426
1427/*! \fn QAccessibleEvent::QAccessibleEvent(QAccessibleInterface *interface, QAccessible::Event type)
1428
1429 Constructs a QAccessibleEvent to notify that \a interface has changed.
1430 The event \a type describes what changed.
1431 Use this function if you already have a QAccessibleInterface or no QObject, otherwise consider
1432 the overload taking a \l QObject parameter as it might be cheaper.
1433*/
1434
1435/*!
1436 Destroys the event.
1437*/
1438QAccessibleEvent::~QAccessibleEvent()
1439{
1440}
1441
1442/*! \fn QAccessible::Event QAccessibleEvent::type() const
1443 Returns the event type.
1444*/
1445
1446/*! \fn QObject* QAccessibleEvent::object() const
1447 Returns the event object.
1448*/
1449
1450/*! \fn void QAccessibleEvent::setChild(int child)
1451 Sets the child index to \a child.
1452*/
1453
1454/*! \fn int QAccessibleEvent::child() const
1455 Returns the child index.
1456*/
1457
1458/*!
1459 \internal
1460 Returns the uniqueId of the QAccessibleInterface represented by this event.
1461
1462 In case the object() function returns \nullptr, this is the only way to access the
1463 interface.
1464*/
1465QAccessible::Id QAccessibleEvent::uniqueId() const
1466{
1467 if (!m_object)
1468 return m_uniqueId;
1469 QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(m_object);
1470 if (!iface)
1471 return 0;
1472 if (m_child != -1) {
1473 iface = iface->child(m_child);
1474 if (Q_UNLIKELY(!iface)) {
1475 qCWarning(lcAccessibilityCore) << "Invalid child in QAccessibleEvent:" << m_object << "child:" << m_child;
1476 return 0;
1477 }
1478 }
1479 return QAccessible::uniqueId(iface);
1480}
1481
1482void QAccessibleEvent::setChild(int chld)
1483{
1484 if (m_type == QAccessible::ObjectDestroyed)
1485 qCWarning(lcAccessibilityCore) << "Calling QAccessibleEvent::setChild on ObjectDestroyed event " <<
1486 "is not supported";
1487 m_child = chld;
1488}
1489
1490/*!
1491 \class QAccessibleValueChangeEvent
1492 \ingroup accessibility
1493 \inmodule QtGui
1494
1495 \brief The QAccessibleValueChangeEvent describes a change in value for an accessible object.
1496
1497 It contains the new value.
1498
1499 This class is used with \l QAccessible::updateAccessibility().
1500*/
1501
1502/*! \fn QAccessibleValueChangeEvent::QAccessibleValueChangeEvent(QObject *object, const QVariant &value)
1503
1504 Constructs a new QAccessibleValueChangeEvent for \a object.
1505 The event contains the new \a value.
1506*/
1507/*! \fn QAccessibleValueChangeEvent::QAccessibleValueChangeEvent(QAccessibleInterface *iface, const QVariant &val)
1508
1509 Constructs a new QAccessibleValueChangeEvent for \a iface.
1510 The event contains the new value \a val.
1511*/
1512
1513/*! \fn void QAccessibleValueChangeEvent::setValue(const QVariant & value)
1514
1515 Sets the new \a value for this event.
1516*/
1517/*!
1518 \fn QVariant QAccessibleValueChangeEvent::value() const
1519
1520 Returns the new value of the accessible object of this event.
1521*/
1522
1523/*!
1524 \internal
1525*/
1526QAccessibleValueChangeEvent::~QAccessibleValueChangeEvent()
1527{
1528}
1529
1530/*!
1531 \class QAccessibleStateChangeEvent
1532 \ingroup accessibility
1533 \inmodule QtGui
1534
1535 \brief The QAccessibleStateChangeEvent notfies the accessibility framework
1536 that the state of an object has changed.
1537
1538 This class is used with \l QAccessible::updateAccessibility().
1539
1540 \sa QAccessibleInterface::state()
1541*/
1542/*! \fn QAccessibleStateChangeEvent::QAccessibleStateChangeEvent(QObject *object, QAccessible::State state)
1543
1544 Constructs a new QAccessibleStateChangeEvent for \a object.
1545 The difference to the object's previous state is in \a state.
1546*/
1547/*!
1548 \fn QAccessibleStateChangeEvent::QAccessibleStateChangeEvent(QAccessibleInterface *iface, QAccessible::State state)
1549
1550 Constructs a new QAccessibleStateChangeEvent.
1551 \a iface is the interface associated with the event
1552 \a state is the state of the accessible object.
1553*/
1554/*!
1555 \fn QAccessible::State QAccessibleStateChangeEvent::changedStates() const
1556 \brief Returns the states that have been changed.
1557
1558 Keep in mind that the returned states are the ones that have changed.
1559 To find out about the state of an object, use QAccessibleInterface::state().
1560
1561 For example, if an object used to have the focus but loses it,
1562 the object's state will have focused set to \c false. This event on the
1563 other hand tells about the change and has focused set to \c true since
1564 the focus state is changed from \c true to \c false.
1565*/
1566/*!
1567 \internal
1568*/
1569QAccessibleStateChangeEvent::~QAccessibleStateChangeEvent()
1570{
1571}
1572
1573/*!
1574 \class QAccessibleTableModelChangeEvent
1575 \ingroup accessibility
1576 \inmodule QtGui
1577
1578 \brief The QAccessibleTableModelChangeEvent signifies a change in a table, list, or tree where cells
1579 are added or removed.
1580 If the change affected a number of rows, firstColumn and lastColumn will return -1.
1581 Likewise for columns, the row functions may return -1.
1582
1583 This class is used with \l QAccessible::updateAccessibility().
1584*/
1585
1586/*! \enum QAccessibleTableModelChangeEvent::ModelChangeType
1587 This enum describes the different types of changes in the table model.
1588 \value ModelReset The model has been reset, all previous knowledge about the model is now invalid.
1589 \value DataChanged No cells have been added or removed, but the data of the specified cell range is invalid.
1590 \value RowsInserted New rows have been inserted.
1591 \value ColumnsInserted New columns have been inserted.
1592 \value RowsRemoved Rows have been removed.
1593 \value ColumnsRemoved Columns have been removed.
1594*/
1595/*! \fn QAccessibleTableModelChangeEvent::QAccessibleTableModelChangeEvent(QObject *object, ModelChangeType changeType)
1596
1597 Constructs a new QAccessibleTableModelChangeEvent for \a object of with \a changeType.
1598*/
1599/*! \fn int QAccessibleTableModelChangeEvent::firstColumn() const
1600
1601 Returns the first changed column.
1602*/
1603/*! \fn int QAccessibleTableModelChangeEvent::firstRow() const
1604
1605 Returns the first changed row.
1606*/
1607/*! \fn int QAccessibleTableModelChangeEvent::lastColumn() const
1608
1609 Returns the last changed column.
1610*/
1611/*! \fn int QAccessibleTableModelChangeEvent::lastRow() const
1612
1613 Returns the last changed row.
1614*/
1615/*! \fn QAccessibleTableModelChangeEvent::ModelChangeType QAccessibleTableModelChangeEvent::modelChangeType() const
1616
1617 Returns the type of change.
1618*/
1619/*! \fn void QAccessibleTableModelChangeEvent::setFirstColumn(int column)
1620
1621 Sets the first changed \a column.
1622*/
1623/*! \fn void QAccessibleTableModelChangeEvent::setFirstRow(int row)
1624
1625 Sets the first changed \a row.
1626*/
1627/*! \fn void QAccessibleTableModelChangeEvent::setLastColumn(int column)
1628
1629 Sets the last changed \a column.
1630*/
1631/*! \fn void QAccessibleTableModelChangeEvent::setLastRow(int row)
1632
1633 Sets the last changed \a row.
1634*/
1635/*! \fn void QAccessibleTableModelChangeEvent::setModelChangeType(ModelChangeType changeType)
1636
1637 Sets the type of change to \a changeType.
1638*/
1639/*!
1640 \fn QAccessibleTableModelChangeEvent::QAccessibleTableModelChangeEvent(QAccessibleInterface *iface, ModelChangeType changeType)
1641
1642 Constructs a new QAccessibleTableModelChangeEvent for interface \a iface with a model
1643 change type \a changeType.
1644*/
1645/*!
1646 \internal
1647*/
1648QAccessibleTableModelChangeEvent::~QAccessibleTableModelChangeEvent()
1649{
1650}
1651/*!
1652 \class QAccessibleTextCursorEvent
1653 \ingroup accessibility
1654 \inmodule QtGui
1655
1656 \brief The QAccessibleTextCursorEvent class notifies of cursor movements.
1657
1658 This class is used with \l QAccessible::updateAccessibility().
1659*/
1660/*! \fn QAccessibleTextCursorEvent::QAccessibleTextCursorEvent(QObject *object, int cursorPos)
1661
1662 Create a new QAccessibleTextCursorEvent for \a object.
1663 The \a cursorPos is the new cursor position.
1664*/
1665/*! \fn int QAccessibleTextCursorEvent::cursorPosition() const
1666
1667 Returns the cursor position.
1668*/
1669/*! \fn void QAccessibleTextCursorEvent::setCursorPosition(int position)
1670
1671 Sets the cursor \a position for this event.
1672*/
1673/*!
1674 \internal
1675*/
1676QAccessibleTextCursorEvent::~QAccessibleTextCursorEvent()
1677{
1678}
1679
1680
1681/*!
1682 \fn QAccessibleTextCursorEvent::QAccessibleTextCursorEvent(QAccessibleInterface *iface, int cursorPos)
1683
1684 Create a new QAccessibleTextCursorEvent for \a iface,
1685 The \a cursorPos is the new cursor position.
1686*/
1687
1688/*!
1689 \class QAccessibleTextInsertEvent
1690 \ingroup accessibility
1691 \inmodule QtGui
1692
1693 \brief The QAccessibleTextInsertEvent class notifies of text being inserted.
1694
1695 This class is used with \l QAccessible::updateAccessibility().
1696*/
1697/*! \fn QAccessibleTextInsertEvent::QAccessibleTextInsertEvent(QObject *object, int position, const QString &text)
1698
1699 Constructs a new QAccessibleTextInsertEvent event for \a object.
1700 The \a text has been inserted at \a position.
1701 By default, it is assumed that the cursor has moved to the end
1702 of the selection. If that is not the case, one needs to manually
1703 set it with \l QAccessibleTextCursorEvent::setCursorPosition() for this event.
1704*/
1705/*! \fn int QAccessibleTextInsertEvent::changePosition() const
1706
1707 Returns the position where the text was inserted.
1708*/
1709/*! \fn QString QAccessibleTextInsertEvent::textInserted() const
1710
1711 Returns the text that has been inserted.
1712*/
1713/*!
1714 \internal
1715*/
1716QAccessibleTextInsertEvent::~QAccessibleTextInsertEvent()
1717{
1718}
1719
1720
1721/*!
1722 \class QAccessibleTextRemoveEvent
1723 \ingroup accessibility
1724 \inmodule QtGui
1725
1726 \brief The QAccessibleTextRemoveEvent class notifies of text being deleted.
1727
1728 This class is used with \l QAccessible::updateAccessibility().
1729*/
1730/*! \fn QAccessibleTextRemoveEvent::QAccessibleTextRemoveEvent(QObject *object, int position, const QString &text)
1731
1732 Constructs a new QAccessibleTextRemoveEvent event for \a object.
1733 The \a text has been removed at \a position.
1734 By default it is assumed that the cursor has moved to \a position.
1735 If that is not the case, one needs to manually
1736 set it with \l QAccessibleTextCursorEvent::setCursorPosition() for this event.
1737*/
1738/*! \fn QAccessibleTextRemoveEvent::QAccessibleTextRemoveEvent(QAccessibleInterface *iface, int position, const QString &text)
1739
1740 Constructs a new QAccessibleTextRemoveEvent event for \a iface.
1741 The \a text has been removed at \a position.
1742 By default it is assumed that the cursor has moved to \a position.
1743 If that is not the case, one needs to manually
1744 set it with \l QAccessibleTextCursorEvent::setCursorPosition() for this event.
1745*/
1746
1747/*! \fn int QAccessibleTextRemoveEvent::changePosition() const
1748
1749 Returns the position where the text was removed.
1750*/
1751/*! \fn QString QAccessibleTextRemoveEvent::textRemoved() const
1752
1753 Returns the text that has been removed.
1754*/
1755/*!
1756 \internal
1757*/
1758QAccessibleTextRemoveEvent::~QAccessibleTextRemoveEvent()
1759{
1760}
1761
1762/*!
1763 \fn QAccessibleTextSelectionEvent::QAccessibleTextSelectionEvent(QAccessibleInterface *iface, int start, int end)
1764
1765 Constructs a new QAccessibleTextSelectionEvent for \a iface. The new selection this
1766 event notifies about is from position \a start to \a end.
1767*/
1768
1769/*!
1770 \fn QAccessibleTextInsertEvent::QAccessibleTextInsertEvent(QAccessibleInterface *iface, int position, const QString &text)
1771
1772 Constructs a new QAccessibleTextInsertEvent event for \a iface. The \a text has been inserted
1773 at \a position.
1774*/
1775
1776/*!
1777 \fn inline QAccessibleTextUpdateEvent::QAccessibleTextUpdateEvent(QAccessibleInterface *iface, int position, const QString &oldText,
1778 const QString &text)
1779
1780 Constructs a new QAccessibleTextUpdateEvent for \a iface. The text change takes place at
1781 \a position where the \a oldText was removed and \a text inserted instead.
1782
1783*/
1784
1785
1786
1787/*!
1788 \class QAccessibleTextUpdateEvent
1789 \ingroup accessibility
1790 \inmodule QtGui
1791
1792 \brief The QAccessibleTextUpdateEvent class notifies about text changes.
1793 This is for accessibles that support editable text such as line edits.
1794 This event occurs for example when a portion of selected text
1795 gets replaced by pasting a new text or in override mode of editors.
1796
1797 This class is used with \l QAccessible::updateAccessibility().
1798*/
1799/*! \fn QAccessibleTextUpdateEvent::QAccessibleTextUpdateEvent(QObject *object, int position, const QString &oldText, const QString &text)
1800
1801 Constructs a new QAccessibleTextUpdateEvent for \a object.
1802 The text change takes place at \a position where the \a oldText was removed and \a text inserted instead.
1803*/
1804/*! \fn int QAccessibleTextUpdateEvent::changePosition() const
1805
1806 Returns where the change took place.
1807*/
1808/*! \fn QString QAccessibleTextUpdateEvent::textInserted() const
1809
1810 Returns the inserted text.
1811*/
1812/*! \fn QString QAccessibleTextUpdateEvent::textRemoved() const
1813
1814 Returns the removed text.
1815*/
1816/*!
1817 \internal
1818*/
1819QAccessibleTextUpdateEvent::~QAccessibleTextUpdateEvent()
1820{
1821}
1822
1823
1824/*!
1825 \class QAccessibleTextSelectionEvent
1826 \ingroup accessibility
1827 \inmodule QtGui
1828
1829 \brief QAccessibleTextSelectionEvent signals a change in the text selection of an object.
1830
1831 This class is used with \l QAccessible::updateAccessibility().
1832*/
1833/*! \fn QAccessibleTextSelectionEvent::QAccessibleTextSelectionEvent(QObject *object, int start, int end)
1834
1835 Constructs a new QAccessibleTextSelectionEvent for \a object.
1836 The new selection this event notifies about is from position \a start to \a end.
1837*/
1838/*! \fn int QAccessibleTextSelectionEvent::selectionEnd() const
1839
1840 Returns the position of the last selected character.
1841*/
1842/*! \fn int QAccessibleTextSelectionEvent::selectionStart() const
1843
1844 Returns the position of the first selected character.
1845*/
1846/*! \fn void QAccessibleTextSelectionEvent::setSelection(int start, int end)
1847
1848 Sets the selection for this event from position \a start to \a end.
1849*/
1850/*!
1851 \internal
1852*/
1853QAccessibleTextSelectionEvent::~QAccessibleTextSelectionEvent()
1854{
1855}
1856
1857/*!
1858 \since 6.8
1859 \class QAccessibleAnnouncementEvent
1860 \ingroup accessibility
1861 \inmodule QtGui
1862
1863 \brief The QAccessibleAnnouncementEvent is used to request the announcement
1864 of a given message by assistive technologies.
1865
1866 This class is used with \l QAccessible::updateAccessibility().
1867*/
1868
1869/*! \fn QAccessibleAnnouncementEvent::QAccessibleAnnouncementEvent(QObject *object, const QString &message)
1870
1871 Constructs a new QAccessibleAnnouncementEvent event for \a object
1872 to request the announcement of \a message with politeness
1873 \l QAccessible::AnnouncementPoliteness::Polite.
1874
1875 \l QAccessibleAnnouncementEvent::setPoliteness can be used to adjust the politeness.
1876*/
1877
1878/*! \fn QAccessibleAnnouncementEvent::QAccessibleAnnouncementEvent(QAccessibleInterface *iface, const QString &message)
1879
1880 Constructs a new QAccessibleAnnouncementEvent event for \a iface
1881 to request the announcement of \a message with politeness
1882 \l QAccessible::AnnouncementPoliteness::Polite.
1883
1884 \l QAccessibleAnnouncementEvent::setPoliteness can be used to adjust the politeness.
1885*/
1886
1887/*! \fn QString QAccessibleAnnouncementEvent::message() const
1888
1889 Returns the message.
1890*/
1891
1892/*! \fn QAccessible::AnnouncementPoliteness QAccessibleAnnouncementEvent::politeness() const
1893
1894 Returns the politeness.
1895*/
1896
1897/*! \fn void QAccessibleAnnouncementEvent::setPoliteness(QAccessible::AnnouncementPoliteness politeness)
1898
1899 Sets the politeness with which the announcement will be requested to \a politeness.
1900*/
1901
1902
1903/*!
1904 \internal
1905*/
1906QAccessibleAnnouncementEvent::~QAccessibleAnnouncementEvent()
1907{
1908}
1909
1910/*!
1911 Returns the QAccessibleInterface associated with the event.
1912*/
1913QAccessibleInterface *QAccessibleEvent::accessibleInterface() const
1914{
1915 if (m_object == nullptr)
1916 return QAccessible::accessibleInterface(m_uniqueId);
1917
1918 QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(m_object);
1919 if (!iface || !iface->isValid())
1920 return nullptr;
1921
1922 if (m_child >= 0) {
1923 QAccessibleInterface *child = iface->child(m_child);
1924 if (child) {
1925 iface = child;
1926 } else {
1927 qCWarning(lcAccessibilityCore) << "Cannot create accessible child interface for object: " << m_object << " index: " << m_child << "type: " << m_type;
1928 }
1929 }
1930 return iface;
1931}
1932
1933/*!
1934 Returns the window associated with the underlying object.
1935 For instance, QAccessibleWidget reimplements this and returns
1936 the windowHandle() of the QWidget.
1937
1938 It is used on some platforms to be able to notify the AT client about
1939 state changes.
1940 The backend will traverse up all ancestors until it finds a window.
1941 (This means that at least one interface among the ancestors should
1942 return a valid QWindow pointer).
1943
1944 The default implementation returns \nullptr.
1945 */
1946QWindow *QAccessibleInterface::window() const
1947{
1948 return nullptr;
1949}
1950
1951/*!
1952 \internal
1953 Method to allow extending this class without breaking binary compatibility.
1954 The actual behavior and format of \a data depends on \a id argument
1955 which must be defined if the class is to be extended with another virtual
1956 function.
1957 Currently, this is unused.
1958*/
1959void QAccessibleInterface::virtual_hook(int /*id*/, void * /*data*/)
1960{
1961}
1962
1963/*!
1964 \fn void *QAccessibleInterface::interface_cast(QAccessible::InterfaceType type)
1965
1966 Returns a specialized accessibility interface \a type from the
1967 generic QAccessibleInterface.
1968
1969 This function must be reimplemented when providing more
1970 information about a widget or object through the specialized
1971 interfaces. For example a line edit should implement the
1972 QAccessibleTextInterface.
1973
1974 \sa QAccessible::InterfaceType, QAccessibleTextInterface,
1975 QAccessibleValueInterface, QAccessibleActionInterface,
1976 QAccessibleTableInterface, QAccessibleTableCellInterface,
1977 QAccessibleViewportInterface
1978*/
1979
1980/*! \internal */
1981const char *qAccessibleRoleString(QAccessible::Role role)
1982{
1983 if (role >= QAccessible::UserRole)
1984 role = QAccessible::UserRole;
1985 static int roleEnum = QAccessible::staticMetaObject.indexOfEnumerator("Role");
1986 return QAccessible::staticMetaObject.enumerator(roleEnum).valueToKey(role);
1987}
1988
1989/*! \internal */
1990const char *qAccessibleEventString(QAccessible::Event event)
1991{
1992 static int eventEnum = QAccessible::staticMetaObject.indexOfEnumerator("Event");
1993 return QAccessible::staticMetaObject.enumerator(eventEnum).valueToKey(event);
1994}
1995
1996#ifndef QT_NO_DEBUG_STREAM
1997/*! \internal */
1998Q_GUI_EXPORT QDebug operator<<(QDebug d, const QAccessibleInterface *iface)
1999{
2000 QDebugStateSaver saver(d);
2001 if (!iface)
2002 return d << "QAccessibleInterface(0x0)";
2003
2004 d.nospace();
2005 d << "QAccessibleInterface(" << Qt::hex << (const void *) iface << Qt::dec;
2006 if (iface->isValid()) {
2007 d << " name=" << iface->text(QAccessible::Name) << ' ';
2008 d << "role=" << qAccessibleRoleString(iface->role()) << ' ';
2009 if (iface->childCount())
2010 d << "childc=" << iface->childCount() << ' ';
2011 if (iface->object()) {
2012 d << "obj=" << iface->object();
2013 }
2014 QStringList stateStrings;
2015 QAccessible::State st = iface->state();
2016 if (st.focusable)
2017 stateStrings << u"focusable"_s;
2018 if (st.focused)
2019 stateStrings << u"focused"_s;
2020 if (st.selected)
2021 stateStrings << u"selected"_s;
2022 if (st.invisible)
2023 stateStrings << u"invisible"_s;
2024
2025 if (!stateStrings.isEmpty())
2026 d << stateStrings.join(u'|');
2027
2028 if (!st.invisible)
2029 d << "rect=" << iface->rect();
2030
2031 } else {
2032 d << " invalid";
2033 }
2034 d << ')';
2035 return d;
2036}
2037
2038/*! \internal */
2039QDebug operator<<(QDebug d, const QAccessibleEvent &ev)
2040{
2041 QDebugStateSaver saver(d);
2042 d.nospace() << "QAccessibleEvent(";
2043 if (ev.object()) {
2044 d.nospace() << "object=" << Qt::hex << ev.object() << Qt::dec;
2045 d.nospace() << "child=" << ev.child();
2046 } else {
2047 d.nospace() << "no object, uniqueId=" << ev.uniqueId();
2048 }
2049 d << " event=" << qAccessibleEventString(ev.type());
2050 if (ev.type() == QAccessible::StateChanged) {
2051 QAccessible::State changed = static_cast<const QAccessibleStateChangeEvent*>(&ev)->changedStates();
2052 d << "State changed:";
2053 if (changed.disabled) d << "disabled";
2054 if (changed.selected) d << "selected";
2055 if (changed.focusable) d << "focusable";
2056 if (changed.focused) d << "focused";
2057 if (changed.pressed) d << "pressed";
2058 if (changed.checkable) d << "checkable";
2059 if (changed.checked) d << "checked";
2060 if (changed.checkStateMixed) d << "checkStateMixed";
2061 if (changed.readOnly) d << "readOnly";
2062 if (changed.hotTracked) d << "hotTracked";
2063 if (changed.defaultButton) d << "defaultButton";
2064 if (changed.expanded) d << "expanded";
2065 if (changed.collapsed) d << "collapsed";
2066 if (changed.busy) d << "busy";
2067 if (changed.expandable) d << "expandable";
2068 if (changed.marqueed) d << "marqueed";
2069 if (changed.animated) d << "animated";
2070 if (changed.invisible) d << "invisible";
2071 if (changed.offscreen) d << "offscreen";
2072 if (changed.sizeable) d << "sizeable";
2073 if (changed.movable) d << "movable";
2074 if (changed.selfVoicing) d << "selfVoicing";
2075 if (changed.selectable) d << "selectable";
2076 if (changed.linked) d << "linked";
2077 if (changed.traversed) d << "traversed";
2078 if (changed.multiSelectable) d << "multiSelectable";
2079 if (changed.extSelectable) d << "extSelectable";
2080 if (changed.passwordEdit) d << "passwordEdit"; // used to be Protected
2081 if (changed.hasPopup) d << "hasPopup";
2082 if (changed.modal) d << "modal";
2083
2084 // IA2 - we chose to not add some IA2 states for now
2085 // Below the ones that seem helpful
2086 if (changed.active) d << "active";
2087 if (changed.invalid) d << "invalid"; // = defunct
2088 if (changed.editable) d << "editable";
2089 if (changed.multiLine) d << "multiLine";
2090 if (changed.selectableText) d << "selectableText";
2091 if (changed.supportsAutoCompletion) d << "supportsAutoCompletion";
2092
2093 }
2094 d << ')';
2095 return d;
2096}
2097#endif // QT_NO_DEBUGSTREAM
2098
2099/*!
2100 \class QAccessibleTextInterface
2101 \inmodule QtGui
2102
2103 \ingroup accessibility
2104
2105 \brief The QAccessibleTextInterface class implements support for text handling.
2106
2107 This interface corresponds to the IAccessibleText interface.
2108 It should be implemented for widgets that display more text than a plain label.
2109 Labels should be represented by only \l QAccessibleInterface
2110 and return their text as name (\l QAccessibleInterface::text() with \l QAccessible::Name as type).
2111 The QAccessibleTextInterface is typically for text that a screen reader
2112 might want to read line by line, and for widgets that support text selection and input.
2113 This interface is, for example, implemented for QLineEdit.
2114
2115 \l{IAccessible2 Specification}
2116*/
2117
2118/*!
2119
2120 Destroys the QAccessibleTextInterface.
2121*/
2122QAccessibleTextInterface::~QAccessibleTextInterface()
2123{
2124}
2125
2126/*!
2127 \fn void QAccessibleTextInterface::addSelection(int startOffset, int endOffset)
2128
2129 Select the text from \a startOffset to \a endOffset.
2130 The \a startOffset is the first character that will be selected.
2131 The \a endOffset is the first character that will not be selected.
2132
2133 When the object supports multiple selections (e.g. in a word processor),
2134 this adds a new selection, otherwise it replaces the previous selection.
2135
2136 The selection will be \a endOffset - \a startOffset characters long.
2137*/
2138
2139/*!
2140 \fn QString QAccessibleTextInterface::attributes(int offset, int *startOffset, int *endOffset) const
2141
2142 Returns the text attributes at the position \a offset.
2143 In addition the range of the attributes is returned in \a startOffset and \a endOffset.
2144*/
2145
2146/*!
2147 \fn int QAccessibleTextInterface::cursorPosition() const
2148
2149 Returns the current cursor position.
2150*/
2151
2152/*!
2153 \fn QRect QAccessibleTextInterface::characterRect(int offset) const
2154
2155 Returns the position and size of the character at position \a offset in screen coordinates.
2156*/
2157
2158/*!
2159 \fn int QAccessibleTextInterface::selectionCount() const
2160
2161 Returns the number of selections in this text.
2162*/
2163
2164/*!
2165 \fn int QAccessibleTextInterface::offsetAtPoint(const QPoint &point) const
2166
2167 Returns the offset of the character at the \a point in screen coordinates.
2168*/
2169
2170/*!
2171 \fn void QAccessibleTextInterface::selection(int selectionIndex, int *startOffset, int *endOffset) const
2172
2173 Returns a selection. The size of the selection is returned in \a startOffset and \a endOffset.
2174 If there is no selection both \a startOffset and \a endOffset are \nullptr.
2175
2176 The accessibility APIs support multiple selections. For most widgets though, only one selection
2177 is supported with \a selectionIndex equal to 0.
2178*/
2179
2180/*!
2181 \fn QString QAccessibleTextInterface::text(int startOffset, int endOffset) const
2182
2183 Returns the text from \a startOffset to \a endOffset.
2184 The \a startOffset is the first character that will be returned.
2185 The \a endOffset is the first character that will not be returned.
2186*/
2187
2188/*!
2189 \internal
2190 Helper for finding line breaks in textBeforeOffset/textAtOffset/textAfterOffset.
2191 \a beforeAtAfter is the line we look for. -1 for before, 0 for at and 1 for after.
2192*/
2193static QString textLineBoundary(int beforeAtAfter, const QString &text, int offset, int *startOffset, int *endOffset)
2194{
2195 Q_ASSERT(beforeAtAfter >= -1 && beforeAtAfter <= 1);
2196 Q_ASSERT(*startOffset == -1 && *endOffset == -1);
2197 int length = text.size();
2198 Q_ASSERT(offset >= 0 && offset <= length);
2199
2200 // move offset into the right range (if asking for line before or after
2201 if (beforeAtAfter == 1) {
2202 offset = text.indexOf(QChar::LineFeed, qMin(offset, length - 1));
2203 if (offset < 0)
2204 return QString(); // after the last line comes nothing
2205 ++offset; // move after the newline
2206 } else if (beforeAtAfter == -1) {
2207 offset = text.lastIndexOf(QChar::LineFeed, qMax(offset - 1, 0));
2208 if (offset < 0)
2209 return QString(); // before first line comes nothing
2210 }
2211
2212 if (offset > 0)
2213 *startOffset = text.lastIndexOf(QChar::LineFeed, offset - 1);
2214 ++*startOffset; // move to the char after the newline (0 if lastIndexOf returned -1)
2215
2216 *endOffset = text.indexOf(QChar::LineFeed, qMin(offset, length - 1)) + 1; // include newline char
2217 if (*endOffset <= 0 || *endOffset > length)
2218 *endOffset = length; // if the text doesn't end with a newline it ends at length
2219
2220 return text.mid(*startOffset, *endOffset - *startOffset);
2221}
2222
2223/*!
2224 Returns the text item of type \a boundaryType that is close to offset \a offset
2225 and sets \a startOffset and \a endOffset values to the start and end positions
2226 of that item; returns an empty string if there is no such an item.
2227 Sets \a startOffset and \a endOffset values to -1 on error.
2228
2229 This default implementation is provided for small text edits. A word processor or
2230 text editor should provide their own efficient implementations. This function makes no
2231 distinction between paragraphs and lines.
2232
2233 \note this function can not take the cursor position into account. By convention
2234 an \a offset of -2 means that this function should use the cursor position as offset.
2235 Thus an offset of -2 must be converted to the cursor position before calling this
2236 function.
2237 An offset of -1 is used for the text length and custom implementations of this function
2238 have to return the result as if the length was passed in as offset.
2239*/
2240QString QAccessibleTextInterface::textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType,
2241 int *startOffset, int *endOffset) const
2242{
2243 const QString txt = text(0, characterCount());
2244
2245 if (offset == -1)
2246 offset = txt.size();
2247
2248 *startOffset = *endOffset = -1;
2249 if (txt.isEmpty() || offset <= 0 || offset > txt.size())
2250 return QString();
2251
2252 // type initialized just to silence a compiler warning [-Werror=maybe-uninitialized]
2253 QTextBoundaryFinder::BoundaryType type = QTextBoundaryFinder::Grapheme;
2254 switch (boundaryType) {
2255 case QAccessible::CharBoundary:
2256 type = QTextBoundaryFinder::Grapheme;
2257 break;
2258 case QAccessible::WordBoundary:
2259 type = QTextBoundaryFinder::Word;
2260 break;
2261 case QAccessible::SentenceBoundary:
2262 type = QTextBoundaryFinder::Sentence;
2263 break;
2264 case QAccessible::LineBoundary:
2265 case QAccessible::ParagraphBoundary:
2266 // Lines can not use QTextBoundaryFinder since Line there means any potential line-break.
2267 return textLineBoundary(-1, txt, offset, startOffset, endOffset);
2268 case QAccessible::NoBoundary:
2269 // return empty, this function currently only supports single lines, so there can be no line before
2270 return QString();
2271 default:
2272 Q_UNREACHABLE();
2273 }
2274
2275 // keep behavior in sync with QTextCursor::movePosition()!
2276
2277 QTextBoundaryFinder boundary(type, txt);
2278 boundary.setPosition(offset);
2279
2280 do {
2281 if ((boundary.boundaryReasons() & (QTextBoundaryFinder::StartOfItem | QTextBoundaryFinder::EndOfItem)))
2282 break;
2283 } while (boundary.toPreviousBoundary() > 0);
2284 Q_ASSERT(boundary.position() >= 0);
2285 const int endPos = boundary.position();
2286
2287 while (boundary.toPreviousBoundary() > 0) {
2288 if ((boundary.boundaryReasons() & (QTextBoundaryFinder::StartOfItem | QTextBoundaryFinder::EndOfItem)))
2289 break;
2290 }
2291 if (boundary.position() < 0)
2292 return QString();
2293
2294 *endOffset = endPos;
2295 *startOffset = boundary.position();
2296
2297 return txt.mid(*startOffset, *endOffset - *startOffset);
2298}
2299
2300/*!
2301 Returns the text item of type \a boundaryType that is right after offset \a offset
2302 and sets \a startOffset and \a endOffset values to the start and end positions
2303 of that item; returns an empty string if there is no such an item.
2304 Sets \a startOffset and \a endOffset values to -1 on error.
2305
2306 This default implementation is provided for small text edits. A word processor or
2307 text editor should provide their own efficient implementations. This function makes no
2308 distinction between paragraphs and lines.
2309
2310 \note this function can not take the cursor position into account. By convention
2311 an \a offset of -2 means that this function should use the cursor position as offset.
2312 Thus an offset of -2 must be converted to the cursor position before calling this
2313 function.
2314 An offset of -1 is used for the text length and custom implementations of this function
2315 have to return the result as if the length was passed in as offset.
2316*/
2317QString QAccessibleTextInterface::textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType,
2318 int *startOffset, int *endOffset) const
2319{
2320 const QString txt = text(0, characterCount());
2321
2322 if (offset == -1)
2323 offset = txt.size();
2324
2325 *startOffset = *endOffset = -1;
2326 if (txt.isEmpty() || offset < 0 || offset >= txt.size())
2327 return QString();
2328
2329 // type initialized just to silence a compiler warning [-Werror=maybe-uninitialized]
2330 QTextBoundaryFinder::BoundaryType type = QTextBoundaryFinder::Grapheme;
2331 switch (boundaryType) {
2332 case QAccessible::CharBoundary:
2333 type = QTextBoundaryFinder::Grapheme;
2334 break;
2335 case QAccessible::WordBoundary:
2336 type = QTextBoundaryFinder::Word;
2337 break;
2338 case QAccessible::SentenceBoundary:
2339 type = QTextBoundaryFinder::Sentence;
2340 break;
2341 case QAccessible::LineBoundary:
2342 case QAccessible::ParagraphBoundary:
2343 // Lines can not use QTextBoundaryFinder since Line there means any potential line-break.
2344 return textLineBoundary(1, txt, offset, startOffset, endOffset);
2345 case QAccessible::NoBoundary:
2346 // return empty, this function currently only supports single lines, so there can be no line after
2347 return QString();
2348 default:
2349 Q_UNREACHABLE();
2350 }
2351
2352 // keep behavior in sync with QTextCursor::movePosition()!
2353
2354 QTextBoundaryFinder boundary(type, txt);
2355 boundary.setPosition(offset);
2356
2357 while (true) {
2358 int toNext = boundary.toNextBoundary();
2359 if ((boundary.boundaryReasons() & (QTextBoundaryFinder::StartOfItem | QTextBoundaryFinder::EndOfItem)))
2360 break;
2361 if (toNext < 0 || toNext >= txt.size())
2362 break; // not found, the boundary might not exist
2363 }
2364 Q_ASSERT(boundary.position() <= txt.size());
2365 *startOffset = boundary.position();
2366
2367 while (true) {
2368 int toNext = boundary.toNextBoundary();
2369 if ((boundary.boundaryReasons() & (QTextBoundaryFinder::StartOfItem | QTextBoundaryFinder::EndOfItem)))
2370 break;
2371 if (toNext < 0 || toNext >= txt.size())
2372 break; // not found, the boundary might not exist
2373 }
2374 Q_ASSERT(boundary.position() <= txt.size());
2375 *endOffset = boundary.position();
2376
2377 if ((*startOffset == -1) || (*endOffset == -1) || (*startOffset == *endOffset)) {
2378 *endOffset = -1;
2379 *startOffset = -1;
2380 }
2381
2382 return txt.mid(*startOffset, *endOffset - *startOffset);
2383}
2384
2385/*!
2386 Returns the text item of type \a boundaryType at offset \a offset
2387 and sets \a startOffset and \a endOffset values to the start and end positions
2388 of that item; returns an empty string if there is no such an item.
2389 Sets \a startOffset and \a endOffset values to -1 on error.
2390
2391 This default implementation is provided for small text edits. A word processor or
2392 text editor should provide their own efficient implementations. This function makes no
2393 distinction between paragraphs and lines.
2394
2395 \note this function can not take the cursor position into account. By convention
2396 an \a offset of -2 means that this function should use the cursor position as offset.
2397 Thus an offset of -2 must be converted to the cursor position before calling this
2398 function.
2399 An offset of -1 is used for the text length and custom implementations of this function
2400 have to return the result as if the length was passed in as offset.
2401*/
2402QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType,
2403 int *startOffset, int *endOffset) const
2404{
2405 const QString txt = text(0, characterCount());
2406
2407 if (offset == -1)
2408 offset = txt.size();
2409
2410 *startOffset = *endOffset = -1;
2411 if (txt.isEmpty() || offset < 0 || offset > txt.size())
2412 return QString();
2413
2414 if (offset == txt.size() && boundaryType == QAccessible::CharBoundary)
2415 return QString();
2416
2417 // type initialized just to silence a compiler warning [-Werror=maybe-uninitialized]
2418 QTextBoundaryFinder::BoundaryType type = QTextBoundaryFinder::Grapheme;
2419 switch (boundaryType) {
2420 case QAccessible::CharBoundary:
2421 type = QTextBoundaryFinder::Grapheme;
2422 break;
2423 case QAccessible::WordBoundary:
2424 type = QTextBoundaryFinder::Word;
2425 break;
2426 case QAccessible::SentenceBoundary:
2427 type = QTextBoundaryFinder::Sentence;
2428 break;
2429 case QAccessible::LineBoundary:
2430 case QAccessible::ParagraphBoundary:
2431 // Lines can not use QTextBoundaryFinder since Line there means any potential line-break.
2432 return textLineBoundary(0, txt, offset, startOffset, endOffset);
2433 case QAccessible::NoBoundary:
2434 *startOffset = 0;
2435 *endOffset = txt.size();
2436 return txt;
2437 default:
2438 Q_UNREACHABLE();
2439 }
2440
2441 // keep behavior in sync with QTextCursor::movePosition()!
2442
2443 QTextBoundaryFinder boundary(type, txt);
2444 boundary.setPosition(offset);
2445
2446 do {
2447 if ((boundary.boundaryReasons() & (QTextBoundaryFinder::StartOfItem | QTextBoundaryFinder::EndOfItem)))
2448 break;
2449 } while (boundary.toPreviousBoundary() > 0);
2450 Q_ASSERT(boundary.position() >= 0);
2451 const int startPos = boundary.position();
2452
2453 while (boundary.toNextBoundary() < txt.size()) {
2454 if ((boundary.boundaryReasons() & (QTextBoundaryFinder::StartOfItem | QTextBoundaryFinder::EndOfItem)))
2455 break;
2456 if (boundary.position() == -1)
2457 return QString();
2458 }
2459
2460 Q_ASSERT(boundary.position() <= txt.size());
2461 *startOffset = startPos;
2462 *endOffset = boundary.position();
2463
2464 return txt.mid(*startOffset, *endOffset - *startOffset);
2465}
2466
2467/*!
2468 \fn void QAccessibleTextInterface::removeSelection(int selectionIndex)
2469
2470 Clears the selection with index \a selectionIndex.
2471*/
2472
2473/*!
2474 \fn void QAccessibleTextInterface::setCursorPosition(int position)
2475
2476 Moves the cursor to \a position.
2477*/
2478
2479/*!
2480 \fn void QAccessibleTextInterface::setSelection(int selectionIndex, int startOffset, int endOffset)
2481
2482 Set the selection \a selectionIndex to the range from \a startOffset to \a endOffset.
2483
2484 \sa addSelection(), removeSelection()
2485*/
2486
2487/*!
2488 \fn int QAccessibleTextInterface::characterCount() const
2489
2490 Returns the length of the text (total size including spaces).
2491*/
2492
2493/*!
2494 \fn void QAccessibleTextInterface::scrollToSubstring(int startIndex, int endIndex)
2495
2496 Ensures that the text between \a startIndex and \a endIndex is visible.
2497*/
2498
2499/*!
2500 \class QAccessibleEditableTextInterface
2501 \ingroup accessibility
2502 \inmodule QtGui
2503
2504 \brief The QAccessibleEditableTextInterface class implements support for objects with editable text.
2505
2506 When implementing this interface you will almost certainly also want to implement \l QAccessibleTextInterface.
2507
2508 \sa QAccessibleInterface
2509
2510 \l{IAccessible2 Specification}
2511*/
2512
2513/*!
2514
2515 Destroys the QAccessibleEditableTextInterface.
2516*/
2517QAccessibleEditableTextInterface::~QAccessibleEditableTextInterface()
2518{
2519}
2520
2521/*!
2522 \fn void QAccessibleEditableTextInterface::deleteText(int startOffset, int endOffset)
2523
2524 Deletes the text from \a startOffset to \a endOffset.
2525*/
2526
2527/*!
2528 \fn void QAccessibleEditableTextInterface::insertText(int offset, const QString &text)
2529
2530 Inserts \a text at position \a offset.
2531*/
2532
2533/*!
2534 \fn void QAccessibleEditableTextInterface::replaceText(int startOffset, int endOffset, const QString &text)
2535
2536 Removes the text from \a startOffset to \a endOffset and instead inserts \a text.
2537*/
2538
2539/*!
2540 \class QAccessibleValueInterface
2541 \inmodule QtGui
2542 \ingroup accessibility
2543
2544 \brief The QAccessibleValueInterface class implements support for objects that manipulate a value.
2545
2546 This interface should be implemented by accessible objects that represent a value.
2547 Examples are spinner, slider, dial and scroll bar.
2548
2549 Instead of forcing the user to deal with the individual parts of the widgets, this interface
2550 gives an easier approach to the kind of widget it represents.
2551
2552 Usually this interface is implemented by classes that also implement \l QAccessibleInterface.
2553
2554 \l{IAccessible2 Specification}
2555*/
2556
2557/*!
2558 Destroys the QAccessibleValueInterface.
2559
2560*/
2561QAccessibleValueInterface::~QAccessibleValueInterface()
2562{
2563}
2564
2565/*!
2566 \fn QVariant QAccessibleValueInterface::currentValue() const
2567
2568 Returns the current value of the widget. This is usually a double or int.
2569 \sa setCurrentValue()
2570*/
2571
2572/*!
2573 \fn void QAccessibleValueInterface::setCurrentValue(const QVariant &value)
2574
2575 Sets the \a value. If the desired \a value is out of the range of permissible values,
2576 this call will be ignored.
2577
2578 \sa currentValue(), minimumValue(), maximumValue()
2579*/
2580
2581/*!
2582 \fn QVariant QAccessibleValueInterface::maximumValue() const
2583
2584 Returns the maximum value this object accepts.
2585 \sa minimumValue(), currentValue()
2586*/
2587
2588/*!
2589 \fn QVariant QAccessibleValueInterface::minimumValue() const
2590
2591 Returns the minimum value this object accepts.
2592 \sa maximumValue(), currentValue()
2593*/
2594
2595/*!
2596 \fn QVariant QAccessibleValueInterface::minimumStepSize() const
2597
2598 Returns the minimum step size for the accessible.
2599 This is the smallest increment that makes sense when changing the value.
2600 When programmatically changing the value it should always be a multiple
2601 of the minimum step size.
2602
2603 Some tools use this value even when the setCurrentValue does not
2604 perform any action. Progress bars for example are read-only but
2605 should return their range divided by 100.
2606*/
2607
2608/*!
2609 \class QAccessibleImageInterface
2610 \inmodule QtGui
2611 \ingroup accessibility
2612 \internal
2613 \preliminary
2614
2615 \brief The QAccessibleImageInterface class implements support for
2616 the IAccessibleImage interface.
2617
2618 \l{IAccessible2 Specification}
2619*/
2620
2621/*!
2622 Destroys the QAccessibleImageInterface.
2623*/
2624QAccessibleImageInterface::~QAccessibleImageInterface()
2625{
2626}
2627
2628/*!
2629 \class QAccessibleTableCellInterface
2630 \inmodule QtGui
2631 \ingroup accessibility
2632
2633 \brief The QAccessibleTableCellInterface class implements support for
2634 the IAccessibleTable2 Cell interface.
2635
2636 \l{IAccessible2 Specification}
2637*/
2638
2639/*!
2640
2641 Destroys the QAccessibleTableCellInterface.
2642*/
2643QAccessibleTableCellInterface::~QAccessibleTableCellInterface()
2644{
2645}
2646
2647/*!
2648 \fn virtual int QAccessibleTableCellInterface::columnExtent() const
2649
2650 Returns the number of columns occupied by this cell accessible.
2651*/
2652
2653/*!
2654 \fn virtual QList<QAccessibleInterface*> QAccessibleTableCellInterface::columnHeaderCells() const
2655
2656 Returns the column headers as an array of cell accessibles.
2657*/
2658
2659/*!
2660 \fn virtual int QAccessibleTableCellInterface::columnIndex() const
2661
2662 Translates this cell accessible into the corresponding column index.
2663*/
2664
2665/*!
2666 \fn virtual int QAccessibleTableCellInterface::rowExtent() const
2667
2668 Returns the number of rows occupied by this cell accessible.
2669*/
2670
2671/*!
2672 \fn virtual QList<QAccessibleInterface*> QAccessibleTableCellInterface::rowHeaderCells() const
2673
2674 Returns the row headers as an array of cell accessibles.
2675*/
2676
2677/*!
2678 \fn virtual int QAccessibleTableCellInterface::rowIndex() const
2679
2680 Translates this cell accessible into the corresponding row index.
2681*/
2682
2683/*!
2684 \fn virtual bool QAccessibleTableCellInterface::isSelected() const
2685
2686 Returns a boolean value indicating whether this cell is selected.
2687*/
2688
2689/*!
2690 \fn virtual QAccessibleInterface *QAccessibleTableCellInterface::table() const
2691
2692 Returns the QAccessibleInterface of the table containing this cell.
2693*/
2694
2695
2696/*!
2697 \class QAccessibleTableInterface
2698 \inmodule QtGui
2699 \ingroup accessibility
2700
2701 \brief The QAccessibleTableInterface class implements support for
2702 the IAccessibleTable2 interface.
2703
2704 \l{IAccessible2 Specification}
2705*/
2706
2707/*!
2708
2709 Destroys the QAccessibleTableInterface.
2710*/
2711QAccessibleTableInterface::~QAccessibleTableInterface()
2712{
2713}
2714
2715/*!
2716 \fn virtual QAccessibleInterface *QAccessibleTableInterface::cellAt(int row, int column) const
2717
2718 Returns the cell at the specified \a row and \a column in the table.
2719*/
2720
2721/*!
2722 \fn virtual QAccessibleInterface *QAccessibleTableInterface::caption() const
2723
2724 Returns the caption for the table.
2725*/
2726
2727/*!
2728 \fn virtual QString QAccessibleTableInterface::columnDescription(int column) const
2729
2730 Returns the description text of the specified \a column in the table.
2731*/
2732
2733/*!
2734 \fn virtual int QAccessibleTableInterface::columnCount() const
2735
2736 Returns the total number of columns in table.
2737*/
2738
2739/*!
2740 \fn virtual int QAccessibleTableInterface::rowCount() const
2741
2742 Returns the total number of rows in table.
2743*/
2744
2745/*!
2746 \fn virtual int QAccessibleTableInterface::selectedCellCount() const
2747
2748 Returns the total number of selected cells.
2749*/
2750
2751/*!
2752 \fn virtual int QAccessibleTableInterface::selectedColumnCount() const
2753
2754 Returns the total number of selected columns.
2755*/
2756
2757/*!
2758 \fn virtual int QAccessibleTableInterface::selectedRowCount() const
2759
2760 Returns the total number of selected rows.
2761*/
2762
2763/*!
2764 \fn virtual QString QAccessibleTableInterface::rowDescription(int row) const
2765
2766 Returns the description text of the specified \a row in the table.
2767*/
2768
2769/*!
2770 \fn virtual QList<int> QAccessibleTableInterface::selectedCells() const
2771
2772 Returns the list of selected cell (by their index as \l QAccessibleInterface::child() accepts).
2773*/
2774
2775/*!
2776 \fn virtual QList<int> QAccessibleTableInterface::selectedColumns() const
2777
2778 Returns the list of currently selected columns.
2779*/
2780
2781/*!
2782 \fn virtual QList<int> QAccessibleTableInterface::selectedRows() const
2783
2784 Returns the list of currently selected rows.
2785*/
2786
2787/*!
2788 \fn virtual QAccessibleInterface *QAccessibleTableInterface::summary() const
2789
2790 Returns a QAccessibleInterface that represents a summary of the table.
2791 This function may return 0 if no such interface exists.
2792*/
2793
2794/*!
2795 \fn virtual bool QAccessibleTableInterface::isColumnSelected(int column) const
2796
2797 Returns a boolean value indicating whether the specified \a column is completely selected.
2798*/
2799
2800/*!
2801 \fn virtual bool QAccessibleTableInterface::isRowSelected(int row) const
2802
2803 Returns a boolean value indicating whether the specified \a row is completely selected.
2804*/
2805
2806/*!
2807 \fn virtual bool QAccessibleTableInterface::selectRow(int row)
2808
2809 Selects \a row. This function might unselect all previously selected rows.
2810 Returns \c true if the selection was successful.
2811*/
2812
2813/*!
2814 \fn virtual bool QAccessibleTableInterface::selectColumn(int column)
2815
2816 Selects \a column. This function might unselect all previously selected columns.
2817 Returns \c true if the selection was successful.
2818*/
2819
2820/*!
2821 \fn virtual bool QAccessibleTableInterface::unselectRow(int row)
2822
2823 Unselects \a row, leaving other selected rows selected (if any).
2824 Returns \c true if the selection was successful.
2825*/
2826
2827/*!
2828 \fn virtual bool QAccessibleTableInterface::unselectColumn(int column)
2829
2830 Unselects \a column, leaving other selected columns selected (if any).
2831 Returns \c true if the selection was successful.
2832*/
2833
2834/*!
2835 \fn virtual void QAccessibleTableInterface::modelChange(QAccessibleTableModelChangeEvent *event)
2836
2837 Informs about a change in the model's layout.
2838 The \a event contains the details.
2839 \sa QAccessibleTableModelChangeEvent
2840*/
2841
2842
2843/*!
2844 \class QAccessibleActionInterface
2845 \inmodule QtGui
2846 \ingroup accessibility
2847
2848 \brief The QAccessibleActionInterface class implements support for
2849 invocable actions in the interface.
2850
2851 Accessible objects should implement the action interface if they support user interaction.
2852 Usually this interface is implemented by classes that also implement \l QAccessibleInterface.
2853
2854 The supported actions should use the predefined actions offered in this class unless they do not
2855 fit a predefined action. In that case a custom action can be added.
2856
2857 When subclassing QAccessibleActionInterface you need to provide a list of actionNames which
2858 is the primary means to discover the available actions. Action names are never localized.
2859 In order to present actions to the user there are two functions that need to return localized versions
2860 of the name and give a description of the action. For the predefined action names use
2861 \l QAccessibleActionInterface::localizedActionName() and \l QAccessibleActionInterface::localizedActionDescription()
2862 to return their localized counterparts.
2863
2864 In general you should use one of the predefined action names, unless describing an action that does not fit these:
2865 \table
2866 \header \li Action name \li Description
2867 \row \li \l toggleAction() \li toggles the item (checkbox, radio button, switch, ...)
2868 \row \li \l decreaseAction() \li decrease the value of the accessible (e.g. spinbox)
2869 \row \li \l increaseAction() \li increase the value of the accessible (e.g. spinbox)
2870 \row \li \l pressAction() \li press or click or activate the accessible (should correspond to clicking the object with the mouse)
2871 \row \li \l setFocusAction() \li set the focus to this accessible
2872 \row \li \l showOnScreenAction() \li move this accessible into the viewport
2873 \row \li \l showMenuAction() \li show a context menu, corresponds to right-clicks
2874 \endtable
2875
2876 In order to invoke the action, \l doAction() is called with an action name.
2877
2878 Most widgets will simply implement \l pressAction(). This is what happens when the widget is activated by
2879 being clicked, space pressed or similar.
2880
2881 \l{IAccessible2 Specification}
2882*/
2883
2884/*!
2885
2886 Destroys the QAccessibleActionInterface.
2887*/
2888QAccessibleActionInterface::~QAccessibleActionInterface()
2889{
2890}
2891
2892/*!
2893 \fn QStringList QAccessibleActionInterface::actionNames() const
2894
2895 Returns the list of actions supported by this accessible object.
2896 The actions returned should be in preferred order,
2897 i.e. the action that the user most likely wants to trigger should be returned first,
2898 while the least likely action should be returned last.
2899
2900 The list does only contain actions that can be invoked.
2901 It won't return disabled actions, or actions associated with disabled UI controls.
2902
2903 The list can be empty.
2904
2905 Note that this list is not localized. For a localized representation re-implement \l localizedActionName()
2906 and \l localizedActionDescription()
2907
2908 \sa doAction(), localizedActionName(), localizedActionDescription()
2909*/
2910
2911/*!
2912 \fn QString QAccessibleActionInterface::localizedActionName(const QString &actionName) const
2913
2914 Returns a localized action name of \a actionName.
2915
2916 For custom actions this function has to be re-implemented.
2917 When using one of the default names, you can call this function in QAccessibleActionInterface
2918 to get the localized string.
2919
2920 \sa actionNames(), localizedActionDescription()
2921*/
2922
2923/*!
2924 \fn QString QAccessibleActionInterface::localizedActionDescription(const QString &actionName) const
2925
2926 Returns a localized action description of the action \a actionName.
2927
2928 When using one of the default names, you can call this function in QAccessibleActionInterface
2929 to get the localized string.
2930
2931 \sa actionNames(), localizedActionName()
2932*/
2933
2934/*!
2935 \fn void QAccessibleActionInterface::doAction(const QString &actionName)
2936
2937 Invokes the action specified by \a actionName.
2938 Note that \a actionName is the non-localized name as returned by \l actionNames()
2939 This function is usually implemented by calling the same functions
2940 that other user interaction, such as clicking the object, would trigger.
2941
2942 \sa actionNames()
2943*/
2944
2945/*!
2946 \fn QStringList QAccessibleActionInterface::keyBindingsForAction(const QString &actionName) const
2947
2948 Returns a list of the keyboard shortcuts available for invoking the action named \a actionName.
2949
2950 This is important to let users learn alternative ways of using the application by emphasizing the keyboard.
2951
2952 \sa actionNames()
2953*/
2954
2955
2956struct QAccessibleActionStrings
2957{
2958 QAccessibleActionStrings() :
2959 pressAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Press"))),
2960 increaseAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Increase"))),
2961 decreaseAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Decrease"))),
2962 showMenuAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Show Menu"))),
2963 setFocusAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Set Focus"))),
2964 showOnScreenAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Show on Screen"))),
2965 toggleAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Toggle"))),
2966 scrollLeftAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Scroll Left"))),
2967 scrollRightAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Scroll Right"))),
2968 scrollUpAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Scroll Up"))),
2969 scrollDownAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Scroll Down"))),
2970 previousPageAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Previous Page"))),
2971 nextPageAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Next Page")))
2972 {}
2973
2974 const QString pressAction;
2975 const QString increaseAction;
2976 const QString decreaseAction;
2977 const QString showMenuAction;
2978 const QString setFocusAction;
2979 const QString showOnScreenAction;
2980 const QString toggleAction;
2981 const QString scrollLeftAction;
2982 const QString scrollRightAction;
2983 const QString scrollUpAction;
2984 const QString scrollDownAction;
2985 const QString previousPageAction;
2986 const QString nextPageAction;
2987
2988 QString localizedDescription(const QString &actionName)
2989 {
2990 if (actionName == pressAction)
2991 return QAccessibleActionInterface::tr("Triggers the action");
2992 else if (actionName == increaseAction)
2993 return QAccessibleActionInterface::tr("Increase the value");
2994 else if (actionName == decreaseAction)
2995 return QAccessibleActionInterface::tr("Decrease the value");
2996 else if (actionName == showMenuAction)
2997 return QAccessibleActionInterface::tr("Shows the menu");
2998 else if (actionName == setFocusAction)
2999 return QAccessibleActionInterface::tr("Sets the focus");
3000 else if (actionName == showOnScreenAction)
3001 return QAccessibleActionInterface::tr("Moves the element into the visible area");
3002 else if (actionName == toggleAction)
3003 return QAccessibleActionInterface::tr("Toggles the state");
3004 else if (actionName == scrollLeftAction)
3005 return QAccessibleActionInterface::tr("Scrolls to the left");
3006 else if (actionName == scrollRightAction)
3007 return QAccessibleActionInterface::tr("Scrolls to the right");
3008 else if (actionName == scrollUpAction)
3009 return QAccessibleActionInterface::tr("Scrolls up");
3010 else if (actionName == scrollDownAction)
3011 return QAccessibleActionInterface::tr("Scrolls down");
3012 else if (actionName == previousPageAction)
3013 return QAccessibleActionInterface::tr("Goes back a page");
3014 else if (actionName == nextPageAction)
3015 return QAccessibleActionInterface::tr("Goes to the next page");
3016
3017
3018 return QString();
3019 }
3020};
3021
3022Q_GLOBAL_STATIC(QAccessibleActionStrings, accessibleActionStrings)
3023
3024QString QAccessibleActionInterface::localizedActionName(const QString &actionName) const
3025{
3026 return QAccessibleActionInterface::tr(qPrintable(actionName));
3027}
3028
3029QString QAccessibleActionInterface::localizedActionDescription(const QString &actionName) const
3030{
3031 return accessibleActionStrings()->localizedDescription(actionName);
3032}
3033
3034/*!
3035 Returns the name of the press default action.
3036 \sa actionNames(), localizedActionName()
3037 */
3038const QString &QAccessibleActionInterface::pressAction()
3039{
3040 return accessibleActionStrings()->pressAction;
3041}
3042
3043/*!
3044 Returns the name of the increase default action.
3045 \sa actionNames(), localizedActionName()
3046 */
3047const QString &QAccessibleActionInterface::increaseAction()
3048{
3049 return accessibleActionStrings()->increaseAction;
3050}
3051
3052/*!
3053 Returns the name of the decrease default action.
3054 \sa actionNames(), localizedActionName()
3055 */
3056const QString &QAccessibleActionInterface::decreaseAction()
3057{
3058 return accessibleActionStrings()->decreaseAction;
3059}
3060
3061/*!
3062 Returns the name of the show menu default action.
3063 \sa actionNames(), localizedActionName()
3064 */
3065const QString &QAccessibleActionInterface::showMenuAction()
3066{
3067 return accessibleActionStrings()->showMenuAction;
3068}
3069
3070/*!
3071 Returns the name of the set focus default action.
3072 \sa actionNames(), localizedActionName()
3073 */
3074const QString &QAccessibleActionInterface::setFocusAction()
3075{
3076 return accessibleActionStrings()->setFocusAction;
3077}
3078
3079/*!
3080 Returns the name of the show on screen default action.
3081 \sa actionNames(), localizedActionName()
3082 */
3083const QString &QAccessibleActionInterface::showOnScreenAction()
3084{
3085 return accessibleActionStrings()->showOnScreenAction;
3086}
3087
3088/*!
3089 Returns the name of the toggle default action.
3090 \sa actionNames(), localizedActionName()
3091 */
3092const QString &QAccessibleActionInterface::toggleAction()
3093{
3094 return accessibleActionStrings()->toggleAction;
3095}
3096
3097/*!
3098 Returns the name of the scroll left default action.
3099 \sa actionNames(), localizedActionName()
3100 */
3101QString QAccessibleActionInterface::scrollLeftAction()
3102{
3103 return accessibleActionStrings()->scrollLeftAction;
3104}
3105
3106/*!
3107 Returns the name of the scroll right default action.
3108 \sa actionNames(), localizedActionName()
3109 */
3110QString QAccessibleActionInterface::scrollRightAction()
3111{
3112 return accessibleActionStrings()->scrollRightAction;
3113}
3114
3115/*!
3116 Returns the name of the scroll up default action.
3117 \sa actionNames(), localizedActionName()
3118 */
3119QString QAccessibleActionInterface::scrollUpAction()
3120{
3121 return accessibleActionStrings()->scrollUpAction;
3122}
3123
3124/*!
3125 Returns the name of the scroll down default action.
3126 \sa actionNames(), localizedActionName()
3127 */
3128QString QAccessibleActionInterface::scrollDownAction()
3129{
3130 return accessibleActionStrings()->scrollDownAction;
3131}
3132
3133/*!
3134 Returns the name of the previous page default action.
3135 \sa actionNames(), localizedActionName()
3136 */
3137QString QAccessibleActionInterface::previousPageAction()
3138{
3139 return accessibleActionStrings()->previousPageAction;
3140}
3141
3142/*!
3143 Returns the name of the next page default action.
3144 \sa actionNames(), localizedActionName()
3145 */
3146QString QAccessibleActionInterface::nextPageAction()
3147{
3148 return accessibleActionStrings()->nextPageAction;
3149}
3150
3151
3152/*!
3153 \since 6.5
3154 \class QAccessibleSelectionInterface
3155 \inmodule QtGui
3156 \ingroup accessibility
3157
3158 \brief The QAccessibleSelectionInterface class implements support for
3159 selection handling.
3160
3161 It provides methods for both, retrieving the current selection
3162 as well as modifying the selection.
3163
3164 Only selections of direct children are supported.
3165*/
3166
3167/*!
3168
3169 Destroys the QAccessibleSelectionInterface.
3170*/
3171QAccessibleSelectionInterface::~QAccessibleSelectionInterface()
3172{
3173}
3174
3175/*!
3176 \fn virtual int QAccessibleSelectionInterface::selectedItemCount() const
3177
3178 Returns the total number of selected accessible items.
3179*/
3180
3181/*!
3182 \fn virtual QList<QAccessibleInterface *> QAccessibleSelectionInterface::selectedItems() const
3183
3184 Returns the list of selected accessible items.
3185*/
3186
3187/*!
3188 Returns the selected accessible item at index \a selectionIndex in the selection.
3189
3190 Note that the index refers to the n-th selected accessible item (i.e. the index in the current selection),
3191 which generally differs from the index that would be passed to \l QAccessibleInterface::child()
3192 in order to retrieve the same item.
3193
3194 The default implementation uses \a selectionIndex to retrieve the item from the list
3195 of selected items retrieved by \l QAccessibleSelectionInterface::selectedItems().
3196
3197 In particular for implementations dealing with many selected items, reimplementing
3198 this method in a more efficient way may be desirable for performance reasons.
3199*/
3200QAccessibleInterface* QAccessibleSelectionInterface::selectedItem(int selectionIndex) const
3201{
3202 QList<QAccessibleInterface*> items = selectedItems();
3203 if (selectionIndex < 0 || selectionIndex > items.length() -1) {
3204 qCWarning(lcAccessibilityCore) << "Selection index" << selectionIndex << "out of range.";
3205 return nullptr;
3206 }
3207
3208 return items.at(selectionIndex);
3209}
3210
3211/*!
3212 Returns whether \a childItem is part of the current selection.
3213
3214 The default implementation checks whether \a childItem is contained
3215 in the list of items retrieved by \l QAccessibleSelectionInterface::selectedItems.
3216*/
3217bool QAccessibleSelectionInterface::isSelected(QAccessibleInterface *childItem) const
3218{
3219 return selectedItems().contains(childItem);
3220}
3221
3222/*!
3223 \fn virtual bool QAccessibleSelectionInterface::select(QAccessibleInterface *childItem)
3224
3225 Adds \a childItem to the selection.
3226 Returns whether \a childItem has actually been added to the selection.
3227
3228 For implementations that only allow single selections,
3229 this may replace the current selection.
3230*/
3231
3232/*!
3233 \fn virtual bool QAccessibleSelectionInterface::unselect(QAccessibleInterface *childItem)
3234
3235 Removes \a childItem from the selection.
3236
3237 Returns whether the accessible item has actually been removed from the selection.
3238*/
3239
3240/*!
3241 \fn virtual bool QAccessibleSelectionInterface::selectAll()
3242
3243 Selects all accessible child items.
3244
3245 Returns whether all accessible child items have actually been added to the selection.
3246*/
3247
3248/*!
3249 \fn virtual bool QAccessibleSelectionInterface::clear()
3250
3251 Unselects all accessible child items.
3252
3253 Returns whether all accessible child items have actually been removed from the selection,
3254 i.e. whether the selection is empty after this method has been called.
3255*/
3256
3257
3258/*!
3259 \since 6.8
3260 \class QAccessibleAttributesInterface
3261 \inmodule QtGui
3262 \ingroup accessibility
3263
3264 \brief The QAccessibleAttributesInterface class implements support for
3265 reporting attributes for an accessible object.
3266
3267 Attributes are key-value pairs. Values are stored in \l QVariant.
3268
3269 The \l QAccessible::Attribute enumeration describes the available keys and
3270 documents which type to use for the value of each key.
3271
3272 While the text-specific attributes handled by \l QAccessibleTextInterface::attributes
3273 are specific to objects implementing text and are specific to a specific text
3274 position/offset, the attributes handled by the \l QAccessibleAttributesInterface
3275 can be used for objects of any role and apply for the whole object.
3276
3277 Classes already implementing \l QAccessibleTextInterface for text-specific attrtibutes
3278 may want to implement \l QAccessibleAttributesInterface in addition for object-specific
3279 attributes.
3280*/
3281
3282/*!
3283
3284 Destroys the QAccessibleAttributesInterface.
3285*/
3286QAccessibleAttributesInterface::~QAccessibleAttributesInterface()
3287{
3288}
3289
3290/*!
3291 \fn QList<QAccessible::Attribute> QAccessibleAttributesInterface::attributeKeys() const
3292
3293 Returns the keys of all attributes the object supports. The \l QAccessible::Attribute
3294 enumeration describes available keys.
3295*/
3296
3297/*!
3298 \fn QVariant QAccessibleAttributesInterface::attributeValue(QAccessible::Attribute key) const
3299
3300 Returns the value of the attribute \a key of this object.
3301
3302 If the attribute is set for this object, a value of the type documented for the
3303 given key in the documentation of the \l QAccessible::Attribute enumeration is
3304 returned in the \l QVariant.
3305
3306 Otherwise, an invalid \l QVariant is returned.
3307*/
3308
3309/*! \internal */
3310QString qAccessibleLocalizedActionDescription(const QString &actionName)
3311{
3312 return accessibleActionStrings()->localizedDescription(actionName);
3313}
3314
3315/*!
3316 \internal
3317 \fn QString QAccessibleHyperlinkInterface::anchor() const
3318
3319 The logical/human readable name of the hyperlink
3320*/
3321
3322/*!
3323 \internal
3324 \fn QString QAccessibleHyperlinkInterface::anchorTarget() const
3325
3326 The target url of the hyperlink
3327*/
3328
3329/*!
3330 \internal
3331 \fn int QAccessibleHyperlinkInterface::startIndex() const
3332
3333 Returns the start index that will refer to the first character in the text where the hyperlink
3334 begins. The index corresponds to the index that the QAccessibleTextInterface needs in order
3335 to find the start of the hyperlink.
3336
3337*/
3338
3339/*!
3340 \internal
3341 \fn int QAccessibleHyperlinkInterface::endIndex() const
3342
3343 Returns the end index that will refer to the first character in the text where the hyperlink
3344 begins. The index corresponds to the index that the QAccessibleTextInterface needs in order
3345 to find the end of the hyperlink.
3346*/
3347
3348QAccessibleHyperlinkInterface::~QAccessibleHyperlinkInterface()
3349{
3350
3351}
3352
3353/*!
3354 \since 6.12
3355 \class QAccessibleViewportInterface
3356 \inmodule QtGui
3357 \ingroup accessibility
3358 \preliminary
3359
3360 \brief The QAccessibleViewportInterface class implements support for viewports.
3361
3362 This interface should be implemented by accessible objects that allow an 2-dimensional
3363 or indexed viewports (e.g. by scrolling). For example lists or flickable views.
3364*/
3365
3366/*!
3367 Destroys the QAccessibleViewportInterface.
3368
3369*/
3370QAccessibleViewportInterface::~QAccessibleViewportInterface()
3371{
3372}
3373
3374/*!
3375 \fn QSizeF QAccessibleViewportInterface::contentSize() const
3376
3377 Returns the total size of the content in absolute values. For non-indexed viewports this will return
3378 the absolute size of the underlying content, for indexed viewports the count of rows and columns is
3379 returned.
3380*/
3381
3382/*!
3383 \fn QPointF QAccessibleViewportInterface::position() const
3384
3385 Returns the current position within the viewport in normalized values.
3386*/
3387
3388/*!
3389 \fn QSizeF QAccessibleViewportInterface::viewportSize() const
3390
3391 Returns the currently visible portion of the content in normalized values.
3392*/
3393
3394/*!
3395 \fn bool QAccessibleViewportInterface::isIndexed() const
3396
3397 Returns true if the underlying content is indexed (e.g. a list of items).
3398*/
3399
3400/*!
3401 \fn void QAccessibleViewportInterface::setPosition(const QPointF &position)
3402
3403 Sets the viewport's position to the given \a position defined in normalized values.
3404*/
3405
3406#endif // QT_CONFIG(accessibility)
3407
3408QT_END_NAMESPACE
3409
3410#include "moc_qaccessible_base.cpp"
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)