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