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

source code of qtbase/src/gui/accessible/qaccessible.cpp