diff --git a/CMakeLists.txt b/CMakeLists.txt index 119813b91..643db2c68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,9 +155,6 @@ option(WITH_EXECINFO "Build ExecInfo support" OFF) add_feature_info(execinfo WITH_EXECINFO "build ExecInfo support") # optional features -option(WITH_ACCESSIBILITY "Build accessibility support" ON) -add_feature_info(accessibility WITH_ACCESSIBILITY "build accessibility support") - option(KATIE_TESTS "Build automatic tests" OFF) add_feature_info(tests KATIE_TESTS "build automatic tests") @@ -468,10 +465,6 @@ if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") katie_config(QT_NO_DEBUG) endif() -if(NOT WITH_ACCESSIBILITY) - katie_config(QT_NO_ACCESSIBILITY) -endif() - add_library(pic_test ${KATIE_TYPE} EXCLUDE_FROM_ALL "${CMAKE_SOURCE_DIR}/cmake/pic.cpp") get_target_property(HAVE_pic pic_test POSITION_INDEPENDENT_CODE) if(NOT HAVE_pic) @@ -547,25 +540,6 @@ katie_generate_obsolete(QAbstractGraphicsShapeItem QtGui qgraphicsitem.h) katie_generate_obsolete(QAbstractListModel QtCore qabstractitemmodel.h) katie_generate_obsolete(QAbstractTableModel QtCore qabstractitemmodel.h) katie_generate_obsolete(QAbstractUndoItem QtGui qtextdocument.h) -katie_generate_obsolete(QAccessible2Interface QtGui qaccessible2.h) -katie_generate_obsolete(QAccessibleActionInterface QtGui qaccessible2.h) -katie_generate_obsolete(QAccessibleApplication QtGui qaccessibleobject.h) -katie_generate_obsolete(QAccessibleBridgeFactoryInterface QtGui qaccessiblebridge.h) -katie_generate_obsolete(QAccessibleBridgePlugin QtGui qaccessiblebridge.h) -katie_generate_obsolete(QAccessibleEditableTextInterface QtGui qaccessible2.h) -katie_generate_obsolete(QAccessibleEvent QtGui qaccessible.h) -katie_generate_obsolete(QAccessibleFactoryInterface QtGui qaccessibleplugin.h) -katie_generate_obsolete(QAccessibleImageInterface QtGui qaccessible2.h) -katie_generate_obsolete(QAccessibleInterfaceEx QtGui qaccessible.h) -katie_generate_obsolete(QAccessibleInterface QtGui qaccessible.h) -katie_generate_obsolete(QAccessibleObjectEx QtGui qaccessibleobject.h) -katie_generate_obsolete(QAccessibleSimpleEditableTextInterface QtGui qaccessible2.h) -katie_generate_obsolete(QAccessibleTable2CellInterface QtGui qaccessible2.h) -katie_generate_obsolete(QAccessibleTable2Interface QtGui qaccessible2.h) -katie_generate_obsolete(QAccessibleTableInterface QtGui qaccessible2.h) -katie_generate_obsolete(QAccessibleTextInterface QtGui qaccessible2.h) -katie_generate_obsolete(QAccessibleValueInterface QtGui qaccessible2.h) -katie_generate_obsolete(QAccessibleWidgetEx QtGui qaccessiblewidget.h) katie_generate_obsolete(QActionEvent QtGui qevent.h) katie_generate_obsolete(QAnimationDriver QtGui qabstractanimation.h) katie_generate_obsolete(QArgument QtCore qobjectdefs.h) @@ -851,8 +825,6 @@ katie_generate_obsolete(QtConfig QtCore qconfig.h) katie_generate_obsolete(QtContainerFwd QtCore qcontainerfwd.h) katie_generate_obsolete(QtDebug QtCore qdebug.h) katie_generate_obsolete(QtEndian QtCore qendian.h) -katie_generate_obsolete(QTestAccessibilityEvent QtTest qtestaccessible.h) -katie_generate_obsolete(QTestAccessibility QtTest qtestaccessible.h) katie_generate_obsolete(QTestDelayEvent QtTest qtestevent.h) katie_generate_obsolete(QTestEventList QtTest qtestevent.h) katie_generate_obsolete(QTestKeyClicksEvent QtTest qtestevent.h) diff --git a/README b/README index cc14f8d92..1528d7ec4 100644 --- a/README +++ b/README @@ -47,6 +47,7 @@ There are several things you should be aware before considering Katie: - dropped network interfaces management support - dropped no-op touch devices support - dropped bitmap fonts support + - dropped accessibility support - some additions have been made: - JSON document handler diff --git a/package/freebsd/pkg-plist b/package/freebsd/pkg-plist index 5c8797252..c2ed18573 100644 --- a/package/freebsd/pkg-plist +++ b/package/freebsd/pkg-plist @@ -577,30 +577,6 @@ include/katie/QtGui/QAbstractSlider include/katie/QtGui/QAbstractSpinBox include/katie/QtGui/QAbstractTextDocumentLayout include/katie/QtGui/QAbstractUndoItem -include/katie/QtGui/QAccessible -include/katie/QtGui/QAccessible2Interface -include/katie/QtGui/QAccessibleActionInterface -include/katie/QtGui/QAccessibleApplication -include/katie/QtGui/QAccessibleBridge -include/katie/QtGui/QAccessibleBridgeFactoryInterface -include/katie/QtGui/QAccessibleBridgePlugin -include/katie/QtGui/QAccessibleEditableTextInterface -include/katie/QtGui/QAccessibleEvent -include/katie/QtGui/QAccessibleFactoryInterface -include/katie/QtGui/QAccessibleImageInterface -include/katie/QtGui/QAccessibleInterface -include/katie/QtGui/QAccessibleInterfaceEx -include/katie/QtGui/QAccessibleObject -include/katie/QtGui/QAccessibleObjectEx -include/katie/QtGui/QAccessiblePlugin -include/katie/QtGui/QAccessibleSimpleEditableTextInterface -include/katie/QtGui/QAccessibleTable2CellInterface -include/katie/QtGui/QAccessibleTable2Interface -include/katie/QtGui/QAccessibleTableInterface -include/katie/QtGui/QAccessibleTextInterface -include/katie/QtGui/QAccessibleValueInterface -include/katie/QtGui/QAccessibleWidget -include/katie/QtGui/QAccessibleWidgetEx include/katie/QtGui/QAction include/katie/QtGui/QActionEvent include/katie/QtGui/QActionGroup @@ -965,12 +941,6 @@ include/katie/QtGui/qabstractscrollarea.h include/katie/QtGui/qabstractslider.h include/katie/QtGui/qabstractspinbox.h include/katie/QtGui/qabstracttextdocumentlayout.h -include/katie/QtGui/qaccessible.h -include/katie/QtGui/qaccessible2.h -include/katie/QtGui/qaccessiblebridge.h -include/katie/QtGui/qaccessibleobject.h -include/katie/QtGui/qaccessibleplugin.h -include/katie/QtGui/qaccessiblewidget.h include/katie/QtGui/qaction.h include/katie/QtGui/qactiongroup.h include/katie/QtGui/qanimationgroup.h @@ -1277,8 +1247,6 @@ include/katie/QtTest/QEventSizeOfChecker include/katie/QtTest/QSignalSpy include/katie/QtTest/QSpontaneKeyEvent include/katie/QtTest/QTest -include/katie/QtTest/QTestAccessibility -include/katie/QtTest/QTestAccessibilityEvent include/katie/QtTest/QTestBasicStreamer include/katie/QtTest/QTestCoreElement include/katie/QtTest/QTestCoreList @@ -1304,7 +1272,6 @@ include/katie/QtTest/qsignalspy.h include/katie/QtTest/qtest.h include/katie/QtTest/qtest_global.h include/katie/QtTest/qtest_gui.h -include/katie/QtTest/qtestaccessible.h include/katie/QtTest/qtestassert.h include/katie/QtTest/qtestbasicstreamer.h include/katie/QtTest/qtestcase.h @@ -1384,7 +1351,6 @@ lib/katie/imports/Qt/labs/folderlistmodel/libqmlfolderlistmodelplugin.so lib/katie/imports/Qt/labs/folderlistmodel/qmldir lib/katie/imports/Qt/labs/particles/libqmlparticlesplugin.so lib/katie/imports/Qt/labs/particles/qmldir -lib/katie/plugins/accessible/libqtaccessiblewidgets.so lib/katie/plugins/designer/libqdeclarativeview.so lib/katie/plugins/iconengines/libqsvgicon.so lib/katie/plugins/imageformats/libqsvg.so diff --git a/package/netbsd/PLIST b/package/netbsd/PLIST index 2e26defa1..3a4ed3ed7 100644 --- a/package/netbsd/PLIST +++ b/package/netbsd/PLIST @@ -580,30 +580,6 @@ include/katie/QtGui/QAbstractSlider include/katie/QtGui/QAbstractSpinBox include/katie/QtGui/QAbstractTextDocumentLayout include/katie/QtGui/QAbstractUndoItem -include/katie/QtGui/QAccessible -include/katie/QtGui/QAccessible2Interface -include/katie/QtGui/QAccessibleActionInterface -include/katie/QtGui/QAccessibleApplication -include/katie/QtGui/QAccessibleBridge -include/katie/QtGui/QAccessibleBridgeFactoryInterface -include/katie/QtGui/QAccessibleBridgePlugin -include/katie/QtGui/QAccessibleEditableTextInterface -include/katie/QtGui/QAccessibleEvent -include/katie/QtGui/QAccessibleFactoryInterface -include/katie/QtGui/QAccessibleImageInterface -include/katie/QtGui/QAccessibleInterface -include/katie/QtGui/QAccessibleInterfaceEx -include/katie/QtGui/QAccessibleObject -include/katie/QtGui/QAccessibleObjectEx -include/katie/QtGui/QAccessiblePlugin -include/katie/QtGui/QAccessibleSimpleEditableTextInterface -include/katie/QtGui/QAccessibleTable2CellInterface -include/katie/QtGui/QAccessibleTable2Interface -include/katie/QtGui/QAccessibleTableInterface -include/katie/QtGui/QAccessibleTextInterface -include/katie/QtGui/QAccessibleValueInterface -include/katie/QtGui/QAccessibleWidget -include/katie/QtGui/QAccessibleWidgetEx include/katie/QtGui/QAction include/katie/QtGui/QActionEvent include/katie/QtGui/QActionGroup @@ -968,12 +944,6 @@ include/katie/QtGui/qabstractscrollarea.h include/katie/QtGui/qabstractslider.h include/katie/QtGui/qabstractspinbox.h include/katie/QtGui/qabstracttextdocumentlayout.h -include/katie/QtGui/qaccessible.h -include/katie/QtGui/qaccessible2.h -include/katie/QtGui/qaccessiblebridge.h -include/katie/QtGui/qaccessibleobject.h -include/katie/QtGui/qaccessibleplugin.h -include/katie/QtGui/qaccessiblewidget.h include/katie/QtGui/qaction.h include/katie/QtGui/qactiongroup.h include/katie/QtGui/qanimationgroup.h @@ -1280,8 +1250,6 @@ include/katie/QtTest/QEventSizeOfChecker include/katie/QtTest/QSignalSpy include/katie/QtTest/QSpontaneKeyEvent include/katie/QtTest/QTest -include/katie/QtTest/QTestAccessibility -include/katie/QtTest/QTestAccessibilityEvent include/katie/QtTest/QTestBasicStreamer include/katie/QtTest/QTestCoreElement include/katie/QtTest/QTestCoreList @@ -1307,7 +1275,6 @@ include/katie/QtTest/qsignalspy.h include/katie/QtTest/qtest.h include/katie/QtTest/qtest_global.h include/katie/QtTest/qtest_gui.h -include/katie/QtTest/qtestaccessible.h include/katie/QtTest/qtestassert.h include/katie/QtTest/qtestbasicstreamer.h include/katie/QtTest/qtestcase.h @@ -1387,7 +1354,6 @@ lib/katie/imports/Qt/labs/folderlistmodel/libqmlfolderlistmodelplugin.so lib/katie/imports/Qt/labs/folderlistmodel/qmldir lib/katie/imports/Qt/labs/particles/libqmlparticlesplugin.so lib/katie/imports/Qt/labs/particles/qmldir -lib/katie/plugins/accessible/libqtaccessiblewidgets.so lib/katie/plugins/designer/libqdeclarativeview.so lib/katie/plugins/iconengines/libqsvgicon.so lib/katie/plugins/imageformats/libqsvg.so diff --git a/package/openbsd/pkg/PLIST b/package/openbsd/pkg/PLIST index 5e79271a8..b2e99bb70 100644 --- a/package/openbsd/pkg/PLIST +++ b/package/openbsd/pkg/PLIST @@ -585,30 +585,6 @@ include/katie/QtGui/QAbstractSlider include/katie/QtGui/QAbstractSpinBox include/katie/QtGui/QAbstractTextDocumentLayout include/katie/QtGui/QAbstractUndoItem -include/katie/QtGui/QAccessible -include/katie/QtGui/QAccessible2Interface -include/katie/QtGui/QAccessibleActionInterface -include/katie/QtGui/QAccessibleApplication -include/katie/QtGui/QAccessibleBridge -include/katie/QtGui/QAccessibleBridgeFactoryInterface -include/katie/QtGui/QAccessibleBridgePlugin -include/katie/QtGui/QAccessibleEditableTextInterface -include/katie/QtGui/QAccessibleEvent -include/katie/QtGui/QAccessibleFactoryInterface -include/katie/QtGui/QAccessibleImageInterface -include/katie/QtGui/QAccessibleInterface -include/katie/QtGui/QAccessibleInterfaceEx -include/katie/QtGui/QAccessibleObject -include/katie/QtGui/QAccessibleObjectEx -include/katie/QtGui/QAccessiblePlugin -include/katie/QtGui/QAccessibleSimpleEditableTextInterface -include/katie/QtGui/QAccessibleTable2CellInterface -include/katie/QtGui/QAccessibleTable2Interface -include/katie/QtGui/QAccessibleTableInterface -include/katie/QtGui/QAccessibleTextInterface -include/katie/QtGui/QAccessibleValueInterface -include/katie/QtGui/QAccessibleWidget -include/katie/QtGui/QAccessibleWidgetEx include/katie/QtGui/QAction include/katie/QtGui/QActionEvent include/katie/QtGui/QActionGroup @@ -973,12 +949,6 @@ include/katie/QtGui/qabstractscrollarea.h include/katie/QtGui/qabstractslider.h include/katie/QtGui/qabstractspinbox.h include/katie/QtGui/qabstracttextdocumentlayout.h -include/katie/QtGui/qaccessible.h -include/katie/QtGui/qaccessible2.h -include/katie/QtGui/qaccessiblebridge.h -include/katie/QtGui/qaccessibleobject.h -include/katie/QtGui/qaccessibleplugin.h -include/katie/QtGui/qaccessiblewidget.h include/katie/QtGui/qaction.h include/katie/QtGui/qactiongroup.h include/katie/QtGui/qanimationgroup.h @@ -1290,8 +1260,6 @@ include/katie/QtTest/QEventSizeOfChecker include/katie/QtTest/QSignalSpy include/katie/QtTest/QSpontaneKeyEvent include/katie/QtTest/QTest -include/katie/QtTest/QTestAccessibility -include/katie/QtTest/QTestAccessibilityEvent include/katie/QtTest/QTestBasicStreamer include/katie/QtTest/QTestCoreElement include/katie/QtTest/QTestCoreList @@ -1317,7 +1285,6 @@ include/katie/QtTest/qsignalspy.h include/katie/QtTest/qtest.h include/katie/QtTest/qtest_global.h include/katie/QtTest/qtest_gui.h -include/katie/QtTest/qtestaccessible.h include/katie/QtTest/qtestassert.h include/katie/QtTest/qtestbasicstreamer.h include/katie/QtTest/qtestcase.h @@ -1407,8 +1374,6 @@ lib/katie/imports/Qt/labs/particles/ @so lib/katie/imports/Qt/labs/particles/libqmlparticlesplugin.so lib/katie/imports/Qt/labs/particles/qmldir lib/katie/plugins/ -lib/katie/plugins/accessible/ -@so lib/katie/plugins/accessible/libqtaccessiblewidgets.so lib/katie/plugins/designer/ @so lib/katie/plugins/designer/libqdeclarativeview.so lib/katie/plugins/iconengines/ diff --git a/scripts/incfsck.py b/scripts/incfsck.py index 3c5666a17..dc56dda56 100755 --- a/scripts/incfsck.py +++ b/scripts/incfsck.py @@ -167,25 +167,6 @@ incmap = { 'QtGui': { 'QAbstractGraphicsShapeItem': 'qgraphicsitem.h', 'QAbstractUndoItem': 'qtextdocument.h', - 'QAccessible2Interface': 'qaccessible2.h', - 'QAccessibleActionInterface': 'qaccessible2.h', - 'QAccessibleApplication': 'qaccessibleobject.h', - 'QAccessibleBridgeFactoryInterface': 'qaccessiblebridge.h', - 'QAccessibleBridgePlugin': 'qaccessiblebridge.h', - 'QAccessibleEditableTextInterface': 'qaccessible2.h', - 'QAccessibleEvent': 'qaccessible.h', - 'QAccessibleFactoryInterface': 'qaccessibleplugin.h', - 'QAccessibleImageInterface': 'qaccessible2.h', - 'QAccessibleInterface': 'qaccessible.h', - 'QAccessibleInterfaceEx': 'qaccessible.h', - 'QAccessibleObjectEx': 'qaccessibleobject.h', - 'QAccessibleSimpleEditableTextInterface': 'qaccessible2.h', - 'QAccessibleTable2CellInterface': 'qaccessible2.h', - 'QAccessibleTable2Interface': 'qaccessible2.h', - 'QAccessibleTableInterface': 'qaccessible2.h', - 'QAccessibleTextInterface': 'qaccessible2.h', - 'QAccessibleValueInterface': 'qaccessible2.h', - 'QAccessibleWidgetEx': 'qaccessiblewidget.h', 'QActionEvent': 'qevent.h', 'QAnimationDriver': 'qabstractanimation.h', 'QBrushData': 'qbrush.h', @@ -371,8 +352,6 @@ incmap = { 'QtTest': { 'QEventSizeOfChecker': 'qtestspontaneevent.h', 'QSpontaneKeyEvent': 'qtestspontaneevent.h', - 'QTestAccessibility': 'qtestaccessible.h', - 'QTestAccessibilityEvent': 'qtestaccessible.h', 'QTestDelayEvent': 'qtestevent.h', 'QTestEventList': 'qtestevent.h', 'QTestKeyClicksEvent': 'qtestevent.h', diff --git a/scripts/namefsck.py b/scripts/namefsck.py index 1a4df2f48..924f31ccc 100755 --- a/scripts/namefsck.py +++ b/scripts/namefsck.py @@ -30,30 +30,6 @@ classlist = [ "QAbstractTableModel", "QAbstractTextDocumentLayout", "QAbstractUndoItem", - "QAccessible", - "QAccessible2Interface", - "QAccessibleActionInterface", - "QAccessibleApplication", - "QAccessibleBridge", - "QAccessibleBridgeFactoryInterface", - "QAccessibleBridgePlugin", - "QAccessibleEditableTextInterface", - "QAccessibleEvent", - "QAccessibleFactoryInterface", - "QAccessibleImageInterface", - "QAccessibleInterface", - "QAccessibleInterfaceEx", - "QAccessibleObject", - "QAccessibleObjectEx", - "QAccessiblePlugin", - "QAccessibleSimpleEditableTextInterface", - "QAccessibleTable2CellInterface", - "QAccessibleTable2Interface", - "QAccessibleTableInterface", - "QAccessibleTextInterface", - "QAccessibleValueInterface", - "QAccessibleWidget", - "QAccessibleWidgetEx", "QAction", "QActionEvent", "QActionGroup", @@ -654,8 +630,6 @@ classlist = [ "QTemporaryFile", "QtEndian", "QTest", - "QTestAccessibility", - "QTestAccessibilityEvent", "QTestBasicStreamer", "QTestCoreElement", "QTestCoreList", diff --git a/src/core/global/qconfig.h.cmake b/src/core/global/qconfig.h.cmake index 28e5cb571..3b0486570 100644 --- a/src/core/global/qconfig.h.cmake +++ b/src/core/global/qconfig.h.cmake @@ -111,6 +111,7 @@ #define QT_NO_GESTURES #define QT_NO_STYLE_MOTIF #define QT_NO_STYLE_PLASTIQUE +#define QT_NO_ACCESSIBILITY // Not supported, used to bootstrap #cmakedefine QT_NO_QOBJECT @@ -155,7 +156,6 @@ // Misc #cmakedefine QT_NO_USING_NAMESPACE -#cmakedefine QT_NO_ACCESSIBILITY #cmakedefine QT_NO_ACTION #cmakedefine QT_NO_ANIMATION #cmakedefine QT_NO_BACKINGSTORE @@ -592,11 +592,6 @@ # define QT_NO_TREEVIEW #endif -// Accessibility -#if !defined(QT_NO_ACCESSIBILITY) && (defined(QT_NO_PROPERTIES) || defined(QT_NO_MENUBAR)) -# define QT_NO_ACCESSIBILITY -#endif - // QColumnView #if !defined(QT_NO_COLUMNVIEW) && defined(QT_NO_LISTVIEW) # define QT_NO_COLUMNVIEW diff --git a/src/core/global/qnamespace.h b/src/core/global/qnamespace.h index 45d110da9..754d90d78 100644 --- a/src/core/global/qnamespace.h +++ b/src/core/global/qnamespace.h @@ -1187,18 +1187,15 @@ public: BackgroundRole = 8, ForegroundRole = 9, CheckStateRole = 10, - // Accessibility - AccessibleTextRole = 11, - AccessibleDescriptionRole = 12, // More general purpose - SizeHintRole = 13, - InitialSortOrderRole = 14, + SizeHintRole = 11, + InitialSortOrderRole = 12, // Internal UiLib roles - DisplayPropertyRole = 15, - DecorationPropertyRole = 16, - ToolTipPropertyRole = 17, - StatusTipPropertyRole = 18, - WhatsThisPropertyRole = 19, + DisplayPropertyRole = 13, + DecorationPropertyRole = 14, + ToolTipPropertyRole = 15, + StatusTipPropertyRole = 16, + WhatsThisPropertyRole = 17, // Reserved UserRole = 32 }; diff --git a/src/core/global/qnamespace.qdoc b/src/core/global/qnamespace.qdoc index ea4ccb73a..94771c8af 100644 --- a/src/core/global/qnamespace.qdoc +++ b/src/core/global/qnamespace.qdoc @@ -2103,14 +2103,6 @@ of a header view section. (Qt::SortOrder). This role was introduced in Qt 4.8. - Accessibility roles (with associated types): - - \value AccessibleTextRole The text to be used by accessibility - extensions and plugins, such as screen - readers. (QString) - \value AccessibleDescriptionRole A description of the item for accessibility - purposes. (QString) - User roles: \value UserRole The first role that can be used for application-specific purposes. diff --git a/src/core/kernel/qcoreevent.cpp b/src/core/kernel/qcoreevent.cpp index bf916e36d..f08853808 100644 --- a/src/core/kernel/qcoreevent.cpp +++ b/src/core/kernel/qcoreevent.cpp @@ -73,9 +73,6 @@ QT_BEGIN_NAMESPACE types and the specialized classes for each type are as follows: \value None Not an event. - \value AccessibilityDescription Used to query accessibility description texts (QAccessibleEvent). - \value AccessibilityHelp Used to query accessibility help texts (QAccessibleEvent). - \value AccessibilityPrepare Accessibility information is requested. \value ActionAdded A new action has been added (QActionEvent). \value ActionChanged An action has been changed (QActionEvent). \value ActionRemoved An action has been removed (QActionEvent). diff --git a/src/core/kernel/qcoreevent.h b/src/core/kernel/qcoreevent.h index 34e373911..687d292aa 100644 --- a/src/core/kernel/qcoreevent.h +++ b/src/core/kernel/qcoreevent.h @@ -96,101 +96,97 @@ public: UpdateLater = 52, // request update() later ContextMenu = 53, // context popup menu - AccessibilityPrepare = 54, // accessibility information is requested - LocaleChange = 55, // the system locale changed - LanguageChange = 56, // the application language changed - LayoutDirectionChange = 57, // the layout direction changed - Style = 58, // internal style event + LocaleChange = 54, // the system locale changed + LanguageChange = 55, // the application language changed + LayoutDirectionChange = 56, // the layout direction changed + Style = 57, // internal style event - FontChange = 59, // font has changed - EnabledChange = 60, // enabled state has changed - ActivationChange = 61, // window activation has changed - StyleChange = 62, // style has changed - IconTextChange = 63, // icon text has changed - ModifiedChange = 64, // modified state has changed - MouseTrackingChange = 65, // mouse tracking state has changed + FontChange = 58, // font has changed + EnabledChange = 59, // enabled state has changed + ActivationChange = 60, // window activation has changed + StyleChange = 61, // style has changed + IconTextChange = 62, // icon text has changed + ModifiedChange = 63, // modified state has changed + MouseTrackingChange = 64, // mouse tracking state has changed - WindowBlocked = 66, // window is about to be blocked modally - WindowUnblocked = 67, // windows modal blocking has ended - WindowStateChange = 68, + WindowBlocked = 65, // window is about to be blocked modally + WindowUnblocked = 66, // windows modal blocking has ended + WindowStateChange = 67, - ToolTip = 69, - WhatsThis = 70, - StatusTip = 71, + ToolTip = 68, + WhatsThis = 69, + StatusTip = 70, - ActionChanged = 72, - ActionAdded = 73, - ActionRemoved = 74, + ActionChanged = 71, + ActionAdded = 72, + ActionRemoved = 73, - Shortcut = 75, // shortcut triggered - ShortcutOverride = 76, // shortcut override request + Shortcut = 74, // shortcut triggered + ShortcutOverride = 75, // shortcut override request - WhatsThisClicked = 77, + WhatsThisClicked = 76, - ApplicationActivate = 78, // application has been changed to active - ApplicationDeactivate = 79, // application has been changed to inactive + ApplicationActivate = 77, // application has been changed to active + ApplicationDeactivate = 78, // application has been changed to inactive - QueryWhatsThis = 80, // query what's this widget help - EnterWhatsThisMode = 81, - LeaveWhatsThisMode = 82, + QueryWhatsThis = 79, // query what's this widget help + EnterWhatsThisMode = 80, + LeaveWhatsThisMode = 81, - ZOrderChange = 83, // child widget has had its z-order changed + ZOrderChange = 82, // child widget has had its z-order changed - HoverEnter = 84, // mouse cursor enters a hover widget - HoverLeave = 85, // mouse cursor leaves a hover widget - HoverMove = 86, // mouse cursor move inside a hover widget + HoverEnter = 83, // mouse cursor enters a hover widget + HoverLeave = 84, // mouse cursor leaves a hover widget + HoverMove = 85, // mouse cursor move inside a hover widget - AccessibilityHelp = 87, // accessibility help text request - AccessibilityDescription = 88, // accessibility description text request + AcceptDropsChange = 86, - AcceptDropsChange = 89, + GraphicsSceneMouseMove = 87, // GraphicsView + GraphicsSceneMousePress = 88, + GraphicsSceneMouseRelease = 89, + GraphicsSceneMouseDoubleClick = 90, + GraphicsSceneContextMenu = 91, + GraphicsSceneHoverEnter = 92, + GraphicsSceneHoverMove = 93, + GraphicsSceneHoverLeave = 94, + GraphicsSceneLeave = 95, // internal + GraphicsSceneHelp = 96, + GraphicsSceneDragEnter = 97, + GraphicsSceneDragMove = 98, + GraphicsSceneDragLeave = 99, + GraphicsSceneDrop = 100, + GraphicsSceneWheel = 101, - GraphicsSceneMouseMove = 90, // GraphicsView - GraphicsSceneMousePress = 91, - GraphicsSceneMouseRelease = 92, - GraphicsSceneMouseDoubleClick = 93, - GraphicsSceneContextMenu = 94, - GraphicsSceneHoverEnter = 95, - GraphicsSceneHoverMove = 96, - GraphicsSceneHoverLeave = 97, - GraphicsSceneLeave = 98, // internal - GraphicsSceneHelp = 99, - GraphicsSceneDragEnter = 100, - GraphicsSceneDragMove = 101, - GraphicsSceneDragLeave = 102, - GraphicsSceneDrop = 103, - GraphicsSceneWheel = 104, + KeyboardLayoutChange = 102, // keyboard layout changed - KeyboardLayoutChange = 105, // keyboard layout changed + DynamicPropertyChange = 103, // A dynamic property was changed through setProperty/property - DynamicPropertyChange = 106, // A dynamic property was changed through setProperty/property + NonClientAreaMouseMove = 104, + NonClientAreaMouseButtonPress = 105, + NonClientAreaMouseButtonRelease = 106, + NonClientAreaMouseButtonDblClick = 107, - NonClientAreaMouseMove = 107, - NonClientAreaMouseButtonPress = 108, - NonClientAreaMouseButtonRelease = 109, - NonClientAreaMouseButtonDblClick = 110, + ContentsRectChange = 108, // sent by QWidget::setContentsMargins (internal) - ContentsRectChange = 111, // sent by QWidget::setContentsMargins (internal) + FutureCallOut = 109, - FutureCallOut = 112, + GraphicsSceneResize = 110, + GraphicsSceneMove = 111, - GraphicsSceneResize = 113, - GraphicsSceneMove = 114, + CursorChange = 112, + ToolTipChange = 113, - CursorChange = 115, - ToolTipChange = 116, + NetworkReplyUpdated = 114, // Internal for QNetworkReply - NetworkReplyUpdated = 117, // Internal for QNetworkReply + GrabMouse = 115, + UngrabMouse = 116, + GrabKeyboard = 117, + UngrabKeyboard = 118, - GrabMouse = 118, - UngrabMouse = 119, - GrabKeyboard = 120, - UngrabKeyboard = 121, + RequestSoftwareInputPanel = 119, + CloseSoftwareInputPanel = 120, - RequestSoftwareInputPanel = 122, - CloseSoftwareInputPanel = 123, - - WinIdChange = 124, + WinIdChange = 121, User = 1000, // first user event id MaxUser = 65535 // last user event id diff --git a/src/core/kernel/qobject.cpp b/src/core/kernel/qobject.cpp index 8a6976526..1dabf9a6d 100644 --- a/src/core/kernel/qobject.cpp +++ b/src/core/kernel/qobject.cpp @@ -207,62 +207,6 @@ public: } }; -// Used by QAccessibleWidget -bool QObjectPrivate::isSender(const QObject *receiver, const char *signal) const -{ - Q_Q(const QObject); - int signal_index = signalIndex(signal); - if (signal_index < 0) - return false; - QMutexLocker locker(signalSlotLock(q)); - if (connectionLists) { - if (signal_index < connectionLists->count()) { - const QObjectPrivate::Connection *c = - connectionLists->at(signal_index).first; - - while (c) { - if (c->receiver == receiver) - return true; - c = c->nextConnectionList; - } - } - } - return false; -} - -// Used by QAccessibleWidget -QObjectList QObjectPrivate::receiverList(const char *signal) const -{ - Q_Q(const QObject); - QObjectList returnValue; - int signal_index = signalIndex(signal); - if (signal_index < 0) - return returnValue; - QMutexLocker locker(signalSlotLock(q)); - if (connectionLists) { - if (signal_index < connectionLists->count()) { - const QObjectPrivate::Connection *c = connectionLists->at(signal_index).first; - - while (c) { - if (c->receiver) - returnValue << c->receiver; - c = c->nextConnectionList; - } - } - } - return returnValue; -} - -// Used by QAccessibleWidget -QObjectList QObjectPrivate::senderList() const -{ - QObjectList returnValue; - QMutexLocker locker(signalSlotLock(q_func())); - for (Connection *c = senders; c; c = c->next) - returnValue << c->sender; - return returnValue; -} - void QObjectPrivate::addConnection(int signal, Connection *c) { if (!connectionLists) diff --git a/src/core/kernel/qobject_p.h b/src/core/kernel/qobject_p.h index a18270f00..35ea570de 100644 --- a/src/core/kernel/qobject_p.h +++ b/src/core/kernel/qobject_p.h @@ -120,10 +120,6 @@ public: void setThreadData_helper(QThreadData *currentData, QThreadData *targetData); void _q_reregisterTimers(void *pointer); - bool isSender(const QObject *receiver, const char *signal) const; - QObjectList receiverList(const char *signal) const; - QObjectList senderList() const; - void addConnection(int signal, Connection *c); void cleanConnectionLists(); diff --git a/src/designer/components/formeditor/formwindowmanager.cpp b/src/designer/components/formeditor/formwindowmanager.cpp index 3be952da9..04a830792 100644 --- a/src/designer/components/formeditor/formwindowmanager.cpp +++ b/src/designer/components/formeditor/formwindowmanager.cpp @@ -142,9 +142,6 @@ bool FormWindowManager::eventFilter(QObject *o, QEvent *e) switch (eventType) { // Uninteresting events case QEvent::Create: case QEvent::Destroy: - case QEvent::AccessibilityDescription: - case QEvent::AccessibilityHelp: - case QEvent::AccessibilityPrepare: case QEvent::ActionAdded: case QEvent::ActionChanged: case QEvent::ActionRemoved: diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 2cc483a3f..eb587d83e 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -24,11 +24,6 @@ set(GUI_PUBLIC_HEADERS QAbstractSlider QAbstractSpinBox QAbstractTextDocumentLayout - QAccessible - QAccessibleBridge - QAccessibleObject - QAccessiblePlugin - QAccessibleWidget QAction QActionGroup QApplication @@ -923,29 +918,6 @@ if(WITH_FONTCONFIG AND FONTCONFIG_FOUND) add_definitions(${FONTCONFIG_DEFINITIONS}) endif() -if(WITH_ACCESSIBILITY) - set(GUI_HEADERS - ${GUI_HEADERS} - ${CMAKE_CURRENT_SOURCE_DIR}/accessible/qaccessible.h - ${CMAKE_CURRENT_SOURCE_DIR}/accessible/qaccessible2.h - ${CMAKE_CURRENT_SOURCE_DIR}/accessible/qaccessibleobject.h - ${CMAKE_CURRENT_SOURCE_DIR}/accessible/qaccessiblewidget.h - ${CMAKE_CURRENT_SOURCE_DIR}/accessible/qaccessibleplugin.h - ${CMAKE_CURRENT_SOURCE_DIR}/accessible/qaccessiblebridge.h - ) - - set(GUI_SOURCES - ${GUI_SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/accessible/qaccessible.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/accessible/qaccessible2.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/accessible/qaccessibleobject.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/accessible/qaccessiblewidget.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/accessible/qaccessibleplugin.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/accessible/qaccessible_unix.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/accessible/qaccessiblebridge.cpp - ) -endif() - # anything that includes qt_x11_p.h is known to break unity build katie_unity_exclude( ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/qdialog.cpp diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp deleted file mode 100644 index c5a46babd..000000000 --- a/src/gui/accessible/qaccessible.cpp +++ /dev/null @@ -1,1133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaccessible.h" - -#ifndef QT_NO_ACCESSIBILITY - -#include "qaccessibleplugin.h" -#include "qaccessiblewidget.h" -#include "qapplication.h" -#include "qhash.h" -#include "qmetaobject.h" -#include "qfactoryloader_p.h" - -#include "qwidget.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QAccessible - \brief The QAccessible class provides enums and static functions - relating to accessibility. - - \ingroup accessibility - - - Accessible applications can be used by people who are not able to - use applications by conventional means. - - The functions in this class are used for communication between - accessible applications (also called AT Servers) and - accessibility tools (AT Clients), such as screen readers and - braille displays. Clients and servers communicate in the following way: - - \list - \o \e{AT Servers} notify the clients about events through calls to the - updateAccessibility() function. - - \o \e{AT Clients} request information about the objects in the server. - The QAccessibleInterface class is the core interface, and encapsulates - this information in a pure virtual API. Implementations of the interface - are provided by Qt through the queryAccessibleInterface() API. - \endlist - - The communication between servers and clients is initialized by - the setRootObject() function. Function pointers can be installed - to replace or extend the default behavior of the static functions - in QAccessible. - - Qt supports Microsoft Active Accessibility (MSAA), Mac OS X - Accessibility, and the Unix/X11 AT-SPI standard. Other backends - can be supported using QAccessibleBridge. - - In addition to QAccessible's static functions, Qt offers one - generic interface, QAccessibleInterface, that can be used to wrap - all widgets and objects (e.g., QPushButton). This single - interface provides all the metadata necessary for the assistive - technologies. Qt provides implementations of this interface for - its built-in widgets as plugins. - - When you develop custom widgets, you can create custom subclasses - of QAccessibleInterface and distribute them as plugins (using - QAccessiblePlugin) or compile them into the application. - Likewise, Qt's predefined accessibility support can be built as - plugin (the default) or directly into the Qt library. The main - advantage of using plugins is that the accessibility classes are - only loaded into memory if they are actually used; they don't - slow down the common case where no assistive technology is being - used. - - Qt also includes two convenience classes, QAccessibleObject and - QAccessibleWidget, that inherit from QAccessibleInterface and - provide the lowest common denominator of metadata (e.g., widget - geometry, window title, basic help text). You can use them as - base classes when wrapping your custom QObject or QWidget - subclasses. - - \sa QAccessibleInterface -*/ - -/*! - \enum QAccessible::Action - - This enum describes the possible types of action that can occur. - - \value DefaultAction - \value Press - \value SetFocus - \value Increase - \value Decrease - \value Accept - \value Cancel - \value Select - \value ClearSelection - \value RemoveSelection - \value ExtendSelection - \value AddToSelection - - \value FirstStandardAction - \value LastStandardAction -*/ - -/*! - \enum QAccessible::Method - - This enum describes the possible types of methods that can be - invoked on an accessible object. - - \value ListSupportedMethods - \value SetCursorPosition - \value GetCursorPosition - - \omitvalue ForegroundColor - \omitvalue BackgroundColor - - \sa QAccessibleInterface::invokeMethod() -*/ - -/*! - \fn QSet QAccessibleInterface::supportedMethods() - \since 4.3 - - Returns a QSet of \l{QAccessible::}{Method}s that are supported by this - accessible interface. - - \sa QAccessible::Method invokeMethod() -*/ - -/*! - \enum QAccessible::StateFlag - - This enum type defines bit flags that can be combined to indicate - the state of an accessible object. The values are: - - \value Animated The object's appearance changes frequently. - \value Busy The object cannot accept input at the moment. - \value Checked The object's check box is checked. - \value Collapsed The object is collapsed, e.g. a closed listview item, or an iconified window. - \value DefaultButton The object represents the default button in a dialog. - \value Expanded The object is expandable, and currently the children are visible. - \value ExtSelectable The object supports extended selection. - \value Focusable The object can receive focus. Only objects in the active window can receive focus. - \value Focused The object has keyboard focus. - \value HasPopup The object opens a popup. - \value HotTracked The object's appearance is sensitive to the mouse cursor position. - \value Invisible The object is not visible to the user. - \value Linked The object is linked to another object, e.g. a hyperlink. - \value Marqueed The object displays scrolling contents, e.g. a log view. - \value Mixed The state of the object is not determined, e.g. a tri-state check box that is neither checked nor unchecked. - \value Modal The object blocks input from other objects. - \value Movable The object can be moved. - \value MultiSelectable The object supports multiple selected items. - \value Normal The normal state. - \value Offscreen The object is clipped by the visible area. Objects that are off screen are also invisible. - \value Pressed The object is pressed. - \value Protected The object is password protected, e.g. a line edit for entering a Password. - \value ReadOnly The object can usually be edited, but is explicitly set to read-only. - \value Selectable The object is selectable. - \value Selected The object is selected. - \value SelfVoicing The object describes itself through speech or sound. - \value Sizeable The object can be resized, e.g. top-level windows. - \value Traversed The object is linked and has been visited. - \value Unavailable The object is unavailable to the user, e.g. a disabled widget. - \omitvalue Moveable - \omitvalue HasInvokeExtension - - Implementations of QAccessibleInterface::state() return a combination - of these flags. -*/ - -/*! - \enum QAccessible::Event - - This enum type defines accessible event types. - - \value AcceleratorChanged The keyboard accelerator for an action has been changed. - \value ActionChanged An action has been changed. - \value ActiveDescendantChanged - \value Alert A system alert (e.g., a message from a QMessageBox) - \value AttributeChanged - \value ContextHelpEnd Context help (QWhatsThis) for an object is finished. - \value ContextHelpStart Context help (QWhatsThis) for an object is initiated. - \value DefaultActionChanged The default QAccessible::Action for the accessible - object has changed. - \value DescriptionChanged The object's QAccessible::Description changed. - \value DialogEnd A dialog (QDialog) has been hidden - \value DialogStart A dialog (QDialog) has been set visible. - \value DocumentContentChanged The contents of a text document have changed. - \value DocumentLoadComplete A document has been loaded. - \value DocumentLoadStopped A document load has been stopped. - \value DocumentReload A document reload has been initiated. - \value DragDropEnd A drag and drop operation is about to finished. - \value DragDropStart A drag and drop operation is about to be initiated. - \value Focus An object has gained keyboard focus. - \value ForegroundChanged A window has been activated (i.e., a new window has - gained focus on the desktop). - \value HelpChanged The QAccessible::Help text property of an object has - changed. - \value HyperlinkEndIndexChanged The end position of the display text for a hypertext - link has changed. - \value HyperlinkNumberOfAnchorsChanged The number of anchors in a hypertext link has changed, - perhaps because the display text has been split to - provide more than one link. - \value HyperlinkSelectedLinkChanged The link for the selected hypertext link has changed. - \value HyperlinkStartIndexChanged The start position of the display text for a hypertext - link has changed. - \value HypertextChanged The display text for a hypertext link has changed. - \value HypertextLinkActivated A hypertext link has been activated, perhaps by being - clicked or via a key press. - \value HypertextLinkSelected A hypertext link has been selected. - \value HypertextNLinksChanged - \value LocationChanged An object's location on the screen has changed. - \value MenuCommand A menu item is triggered. - \value MenuEnd A menu has been closed (Qt uses PopupMenuEnd for all - menus). - \value MenuStart A menu has been opened on the menubar (Qt uses - PopupMenuStart for all menus). - \value NameChanged The QAccessible::Name property of an object has changed. - \value ObjectAttributeChanged - \value ObjectCreated A new object is created. - \value ObjectDestroyed An object is deleted. - \value ObjectHide An object is hidden; for example, with QWidget::hide(). - Any children the object that is hidden has do not send - this event. It is not sent when an object is hidden as - it is being obcured by others. - \value ObjectReorder A layout or item view has added, removed, or moved an - object (Qt does not use this event). - \value ObjectShow An object is displayed; for example, with - QWidget::show(). - \value PageChanged - \value ParentChanged An object's parent object changed. - \value PopupMenuEnd A pop-up menu has closed. - \value PopupMenuStart A pop-up menu has opened. - \value ScrollingEnd A scrollbar scroll operation has ended (the mouse has - released the slider handle). - \value ScrollingStart A scrollbar scroll operation is about to start; this may - be caused by a mouse press on the slider handle, for - example. - \value SectionChanged - \value SelectionAdd An item has been added to the selection in an item view. - \value SelectionRemove An item has been removed from an item view selection. - \value Selection The selection has changed in a menu or item view. - \value SelectionWithin Several changes to a selection has occurred in an item - view. - \value SoundPlayed A sound has been played by an object - \value StateChanged The QAccessible::State of an object has changed. - \value TableCaptionChanged A table caption has been changed. - \value TableColumnDescriptionChanged The description of a table column, typically found in - the column's header, has been changed. - \value TableColumnHeaderChanged A table column header has been changed. - \value TableModelChanged The model providing data for a table has been changed. - \value TableRowDescriptionChanged The description of a table row, typically found in the - row's header, has been changed. - \value TableRowHeaderChanged A table row header has been changed. - \value TableSummaryChanged The summary of a table has been changed. - \value TextAttributeChanged - \value TextCaretMoved The caret has moved in an editable widget. - The caret represents the cursor position in an editable - widget with the input focus. - \value TextColumnChanged A text column has been changed. - \value TextInserted Text has been inserted into an editable widget. - \value TextRemoved Text has been removed from an editable widget. - \value TextSelectionChanged The selected text has changed in an editable widget. - \value TextUpdated The text has been update in an editable widget. - \value ValueChanged The QAccessible::Value of an object has changed. - \value VisibleDataChanged - - The values for this enum are defined to be the same as those defined in the - \l{AccessibleEventID.idl File Reference}{IAccessible2} and - \l{Microsoft Active Accessibility Event Constants}{MSAA} specifications. -*/ - -/*! - \enum QAccessible::Role - - This enum defines the role of an accessible object. The roles are: - - \value AlertMessage An object that is used to alert the user. - \value Animation An object that displays an animation. - \value Application The application's main window. - \value Assistant An object that provids interactive help. - \value Border An object that represents a border. - \value ButtonDropDown A button that drops down a list of items. - \value ButtonDropGrid A button that drops down a grid. - \value ButtonMenu A button that drops down a menu. - \value Canvas An object that displays graphics that the user can interact with. - \value Caret An object that represents the system caret (text cursor). - \value Cell A cell in a table. - \value Chart An object that displays a graphical representation of data. - \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. - \value Client The client area in a window. - \value Clock A clock displaying time. - \value Column A column of cells, usually within a table. - \value ColumnHeader A header for a column of data. - \value ComboBox A list of choices that the user can select from. - \value Cursor An object that represents the mouse cursor. - \value Desktop The object represents the desktop or workspace. - \value Dial An object that represents a dial or knob. - \value Dialog A dialog box. - \value Document A document window, usually in an MDI environment. - \value EditableText Editable text - \value Equation An object that represents a mathematical equation. - \value Graphic A graphic or picture, e.g. an icon. - \value Grip A grip that the user can drag to change the size of widgets. - \value Grouping An object that represents a logical grouping of other objects. - \value HelpBalloon An object that displays help in a separate, short lived window. - \value HotkeyField A hotkey field that allows the user to enter a key sequence. - \value Indicator An indicator that represents a current value or item. - \value LayeredPane An object that can contain layered children, e.g. in a stack. - \value Link A link to something else. - \value List A list of items, from which the user can select one or more items. - \value ListItem An item in a list of items. - \value MenuBar A menu bar from which menus are opened by the user. - \value MenuItem An item in a menu or menu bar. - \value NoRole The object has no role. This usually indicates an invalid object. - \value PageTab A page tab that the user can select to switch to a different page in a dialog. - \value PageTabList A list of page tabs. - \value Pane A generic container. - \value PopupMenu A menu which lists options that the user can select to perform an action. - \value ProgressBar The object displays the progress of an operation in progress. - \value PropertyPage A property page where the user can change options and settings. - \value PushButton A button. - \value RadioButton An object that represents an option that is mutually exclusive with other options. - \value Row A row of cells, usually within a table. - \value RowHeader A header for a row of data. - \value ScrollBar A scroll bar, which allows the user to scroll the visible area. - \value Separator A separator that divides space into logical areas. - \value Slider A slider that allows the user to select a value within a given range. - \value Sound An object that represents a sound. - \value SpinBox A spin box widget that allows the user to enter a value within a given range. - \value Splitter A splitter distributing available space between its child widgets. - \value StaticText Static text, such as labels for other widgets. - \value StatusBar A status bar. - \value Table A table representing data in a grid of rows and columns. - \value Terminal A terminal or command line interface. - \value TitleBar The title bar caption of a window. - \value ToolBar A tool bar, which groups widgets that the user accesses frequently. - \value ToolTip A tool tip which provides information about other objects. - \value Tree A list of items in a tree structure. - \value TreeItem An item in a tree structure. - \value UserRole The first value to be used for user defined roles. - \value Whitespace Blank space between other objects. - \value Window A top level window. -*/ - -/*! - \enum QAccessible::RelationFlag - - This enum type defines bit flags that can be combined to indicate - the relationship between two accessible objects. - - \value Unrelated The objects are unrelated. - \value Self The objects are the same. - \value Ancestor The first object is a parent of the second object. - \value Child The first object is a direct child of the second object. - \value Descendent The first object is an indirect child of the second object. - \value Sibling The objects are siblings. - - \value Up The first object is above the second object. - \value Down The first object is below the second object. - \value Left The first object is left of the second object. - \value Right The first object is right of the second object. - \value Covers The first object covers the second object. - \value Covered The first object is covered by the second object. - - \value FocusChild The first object is the second object's focus child. - \value Label The first object is the label of the second object. - \value Labelled The first object is labelled by the second object. - \value Controller The first object controls the second object. - \value Controlled The first object is controlled by the second object. - - \omitvalue HierarchyMask - \omitvalue GeometryMask - \omitvalue LogicalMask - - Implementations of relationTo() return a combination of these flags. - Some values are mutually exclusive. - - Implementations of navigate() can accept only one distinct value. -*/ - -/*! - \enum QAccessible::Text - - This enum specifies string information that an accessible object - returns. - - \value Name The name of the object. This can be used both - as an identifier or a short description by - accessible clients. - \value Description A short text describing the object. - \value Value The value of the object. - \value Help A longer text giving information about how to use the object. - \value Accelerator The keyboard shortcut that executes the object's default action. - \value UserText The first value to be used for user defined text. -*/ - -/*! - \fn QAccessibleInterface::~QAccessibleInterface() - - Destroys the object. -*/ - -/*! - \fn void QAccessible::initialize() - \internal -*/ - -/*! - \fn void QAccessible::cleanup() - \internal -*/ - -#ifndef QT_NO_LIBRARY -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, accessibleloader, - (QAccessibleFactoryInterface_iid, QLatin1String("/accessible"))) -#endif - -Q_GLOBAL_STATIC(QList, qAccessibleFactories) - -QAccessible::UpdateHandler QAccessible::updateHandler = 0; -QAccessible::RootObjectHandler QAccessible::rootObjectHandler = 0; - -static bool accessibility_active = false; -static bool cleanupAdded = false; -static void qAccessibleCleanup() -{ - qAccessibleFactories()->clear(); -} - -/*! - \typedef QAccessible::InterfaceFactory - - This is a typedef for a pointer to a function with the following - signature: - - \snippet doc/src/snippets/code/src_gui_accessible_qaccessible.cpp 1 - - The function receives a QString and a QObject pointer, where the - QString is the key identifying the interface. The QObject is used - to pass on to the QAccessibleInterface so that it can hold a reference - to it. - - If the key and the QObject does not have a corresponding - QAccessibleInterface, a null-pointer will be returned. - - Installed factories are called by queryAccessibilityInterface() until - one provides an interface. -*/ - -/*! - \typedef QAccessible::UpdateHandler - - \internal - - A function pointer type. Use a function with this prototype to install - your own update function. - - The function is called by updateAccessibility(). -*/ - -/*! - \typedef QAccessible::RootObjectHandler - - \internal - - A function pointer type. Use a function with this prototype to install - your own root object handler. - - The function is called by setRootObject(). -*/ - -/*! - Installs the InterfaceFactory \a factory. The last factory added - is the first one used by queryAccessibleInterface(). -*/ -void QAccessible::installFactory(InterfaceFactory factory) -{ - if (!factory) - return; - - if (!cleanupAdded) { - qAddPostRoutine(qAccessibleCleanup); - cleanupAdded = true; - } - if (qAccessibleFactories()->contains(factory)) - return; - qAccessibleFactories()->append(factory); -} - -/*! - Removes \a factory from the list of installed InterfaceFactories. -*/ -void QAccessible::removeFactory(InterfaceFactory factory) -{ - qAccessibleFactories()->removeAll(factory); -} - -/*! - \internal - - Installs the given \a handler as the function to be used by - updateAccessibility(), and returns the previously installed - handler. -*/ -QAccessible::UpdateHandler QAccessible::installUpdateHandler(UpdateHandler handler) -{ - UpdateHandler old = updateHandler; - updateHandler = handler; - return old; -} - -/*! - Installs the given \a handler as the function to be used by setRootObject(), - and returns the previously installed handler. -*/ -QAccessible::RootObjectHandler QAccessible::installRootObjectHandler(RootObjectHandler handler) -{ - RootObjectHandler old = rootObjectHandler; - rootObjectHandler = handler; - return old; -} - -/*! - If a QAccessibleInterface implementation exists for the given \a object, - this function returns a pointer to the implementation; otherwise it - returns 0. - - The function calls all installed factory functions (from most - recently installed to least recently installed) until one is found - that provides an interface for the class of \a object. If no - factory can provide an accessibility implementation for the class - the function loads installed accessibility plugins, and tests if - any of the plugins can provide the implementation. - - If no implementation for the object's class is available, the - function tries to find an implementation for the object's parent - class, using the above strategy. - - \warning The caller is responsible for deleting the returned - interface after use. -*/ -QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object) -{ - accessibility_active = true; - QAccessibleInterface *iface = 0; - if (!object) - return 0; - - const QMetaObject *mo = object->metaObject(); - while (mo) { - const QString cn = QString::fromLatin1(mo->className()); - for (int i = qAccessibleFactories()->count(); i > 0; --i) { - InterfaceFactory factory = qAccessibleFactories()->at(i - 1); - iface = factory(cn, object); - if (iface) - return iface; - } -#ifndef QT_NO_LIBRARY - QAccessibleFactoryInterface *factory = qobject_cast(accessibleloader()->instance(cn)); - if (factory) { - iface = factory->create(cn, object); - if (iface) - return iface; - } -#endif - mo = mo->superClass(); - } - - QWidget *widget = qobject_cast(object); - if (widget) - return new QAccessibleWidget(widget); - else if (object == qApp) - return new QAccessibleApplication(); - - return 0; -} - -/*! - Returns true if an accessibility implementation has been requested - during the runtime of the application; otherwise returns false. - - Use this function to prevent potentially expensive notifications via - updateAccessibility(). -*/ -bool QAccessible::isActive() -{ - return accessibility_active; -} - -/*! - \fn void QAccessible::setRootObject(QObject *object) - - Sets the root accessible object of this application to \a object. - All other accessible objects in the application can be reached by the - client using object navigation. - - You should never need to call this function. Qt sets the QApplication - object as the root object immediately before the event loop is entered - in QApplication::exec(). - - Use QAccessible::installRootObjectHandler() to redirect the function - call to a customized handler function. - - \sa queryAccessibleInterface() -*/ - -/*! - \fn void QAccessible::updateAccessibility(QObject *object, int child, Event reason) - - Notifies accessibility clients about a change in \a object's - accessibility information. - - \a reason specifies the cause of the change, for example, - \c ValueChange when the position of a slider has been changed. \a - child is the (1-based) index of the child element that has changed. - When \a child is 0, the object itself has changed. - - Call this function whenever the state of your accessible object or - one of its sub-elements has been changed either programmatically - (e.g. by calling QLabel::setText()) or by user interaction. - - If there are no accessibility tools listening to this event, the - performance penalty for calling this function is small, but if determining - the parameters of the call is expensive you can test isActive() to - avoid unnecessary computations. -*/ - - -/*! - \class QAccessibleInterface - \brief The QAccessibleInterface class defines an interface that exposes information - about accessible objects. - - \ingroup accessibility - - Accessibility tools (also called AT Clients), such as screen readers - or braille displays, require high-level information about - accessible objects in an application. Accessible objects provide - specialized input and output methods, making it possible for users - to use accessibility tools with enabled applications (AT Servers). - - Every element that the user needs to interact with or react to is - an accessible object, and should provide this information. These - are mainly visual objects, such as widgets and widget elements, but - can also be content, such as sounds. - - The AT client uses three basic concepts to acquire information - about any accessible object in an application: - \list - \i \e Properties The client can read information about - accessible objects. In some cases the client can also modify these - properties; such as text in a line edit. - \i \e Actions The client can invoke actions like pressing a button - or . - \i \e{Relationships and Navigation} The client can traverse from one - accessible object to another, using the relationships between objects. - \endlist - - The QAccessibleInterface defines the API for these three concepts. - - \section1 Relationships and Navigation - - The functions childCount() and indexOfChild() return the number of - children of an accessible object and the index a child object has - in its parent. The childAt() function returns the index of a child - at a given position. - - The relationTo() function provides information about how two - different objects relate to each other, and navigate() allows - traversing from one object to another object with a given - relationship. - - \section1 Properties - - The central property of an accessible objects is what role() it - has. Different objects can have the same role, e.g. both the "Add - line" element in a scroll bar and the \c OK button in a dialog have - the same role, "button". The role implies what kind of - interaction the user can perform with the user interface element. - - An object's state() property is a combination of different state - flags and can describe both how the object's state differs from a - "normal" state, e.g. it might be unavailable, and also how it - behaves, e.g. it might be selectable. - - The text() property provides textual information about the object. - An object usually has a name, but can provide extended information - such as a description, help text, or information about any - keyboard accelerators it provides. Some objects allow changing the - text() property through the setText() function, but this - information is in most cases read-only. - - The rect() property provides information about the geometry of an - accessible object. This information is usually only available for - visual objects. - - \section1 Actions and Selection - - To enable the user to interact with an accessible object the - object must expose information about the actions that it can - perform. userActionCount() returns the number of actions supported by - an accessible object, and actionText() returns textual information - about those actions. doAction() invokes an action. - - Objects that support selections can define actions to change the selection. - - \section2 Objects and children - - A QAccessibleInterface provides information about the accessible - object, and can also provide information for the children of that - object if those children don't provide a QAccessibleInterface - implementation themselves. This is practical if the object has - many similar children (e.g. items in a list view), or if the - children are an integral part of the object itself, for example, the - different sections in a scroll bar. - - If an accessible object provides information about its children - through one QAccessibleInterface, the children are referenced - using indexes. The index is 1-based for the children, i.e. 0 - refers to the object itself, 1 to the first child, 2 to the second - child, and so on. - - All functions in QAccessibleInterface that take a child index - relate to the object itself if the index is 0, or to the child - specified. If a child provides its own interface implementation - (which can be retrieved through navigation) asking the parent for - information about that child will usually not succeed. - - \sa QAccessible -*/ - -/*! - \fn bool QAccessibleInterface::isValid() const - - Returns true if all the data necessary to use this interface - implementation is valid (e.g. all pointers are non-null); - otherwise returns false. - - \sa object() -*/ - -/*! - \fn QObject *QAccessibleInterface::object() const - - Returns a pointer to the QObject this interface implementation provides - information for. - - \sa isValid() -*/ - -/*! - \fn int QAccessibleInterface::childCount() const - - Returns the number of children that belong to this object. A child - can provide accessibility information on its own (e.g. a child - widget), or be a sub-element of this accessible object. - - All objects provide this information. - - \sa indexOfChild() -*/ - -/*! - \fn int QAccessibleInterface::indexOfChild(const QAccessibleInterface *child) const - - Returns the 1-based index of the object \a child in this object's - children list, or -1 if \a child is not a child of this object. 0 - is not a possible return value. - - All objects provide this information about their children. - - \sa childCount() -*/ - -/*! - \fn QAccessible::Relation QAccessibleInterface::relationTo(int child, -const QAccessibleInterface *other, int otherChild) const - - Returns the relationship between this object's \a child and the \a - other object's \a otherChild. If \a child is 0 the object's own relation - is returned. - - The returned value indicates the relation of the called object to - the \a other object, e.g. if this object is a child of \a other - the return value will be \c Child. - - The return value is a combination of the bit flags in the - QAccessible::Relation enumeration. - - All objects provide this information. - - \sa indexOfChild(), navigate() -*/ - -/*! - \fn int QAccessibleInterface::childAt(int x, int y) const - - Returns the 1-based index of the child that contains the screen - coordinates (\a x, \a y). This function returns 0 if the point is - positioned on the object itself. If the tested point is outside - the boundaries of the object this function returns -1. - - This function is only relyable for visible objects (invisible - object might not be laid out correctly). - - All visual objects provide this information. - - \sa rect() -*/ - -/*! - \fn int QAccessibleInterface::navigate(RelationFlag relation, int entry, QAccessibleInterface -**target) const - - Navigates from this object to an object that has a relationship - \a relation to this object, and returns the respective object in - \a target. It is the caller's responsibility to delete *\a target - after use. - - If an object is found, \a target is set to point to the object, and - the index of the child of \a target is returned. The return value - is 0 if \a target itself is the requested object. \a target is set - to null if this object is the target object (i.e. the requested - object is a handled by this object). - - If no object is found \a target is set to null, and the return - value is -1. - - The \a entry parameter has two different meanings: - \list - \i \e{Hierarchical and Logical relationships} -- if multiple objects with - the requested relationship exist \a entry specifies which one to - return. \a entry is 1-based, e.g. use 1 to get the first (and - possibly only) object with the requested relationship. - - The following code demonstrates how to use this function to - navigate to the first child of an object: - - \snippet doc/src/snippets/code/src_gui_accessible_qaccessible.cpp 0 - - \i \e{Geometric relationships} -- the index of the child from - which to start navigating in the specified direction. \a entry - can be 0 to navigate to a sibling of this object, or non-null to - navigate within contained children that don't provide their own - accessible information. - \endlist - - Note that the \c Descendent value for \a relation is not supported. - - All objects support navigation. - - \sa relationTo(), childCount() -*/ - -/*! - \fn QString QAccessibleInterface::text(Text t, int child) const - - Returns the value of the text property \a t of the object, or of - the object's child if \a child is not 0. - - The \l Name is a string used by clients to identify, find, or - announce an accessible object for the user. All objects must have - a name that is unique within their container. The name can be - used differently by clients, so the name should both give a - short description of the object and be unique. - - An accessible object's \l Description provides textual information - about an object's visual appearance. The description is primarily - used to provide greater context for vision-impaired users, but is - also used for context searching or other applications. Not all - objects have a description. An "OK" button would not need a - description, but a tool button that shows a picture of a smiley - would. - - The \l Value of an accessible object represents visual information - contained by the object, e.g. the text in a line edit. Usually, - the value can be modified by the user. Not all objects have a - value, e.g. static text labels don't, and some objects have a - state that already is the value, e.g. toggle buttons. - - The \l Help text provides information about the function and - usage of an accessible object. Not all objects provide this - information. - - The \l Accelerator is a keyboard shortcut that activates the - object's default action. A keyboard shortcut is the underlined - character in the text of a menu, menu item or widget, and is - either the character itself, or a combination of this character - and a modifier key like Alt, Ctrl or Shift. Command controls like - tool buttons also have shortcut keys and usually display them in - their tooltip. - - All objects provide a string for \l Name. - - \sa role(), state() -*/ - -/*! - \fn void QAccessibleInterface::setText(Text t, int child, const QString &text) - - Sets the text property \a t of the object, or of the object's - child if \a child is not 0, to \a text. - - Note that the text properties of most objects are read-only. - - \sa text() -*/ - -/*! - \fn QRect QAccessibleInterface::rect(int child) const - - Returns the geometry of the object, or of the object's child if \a child - is not 0. The geometry is in screen coordinates. - - This function is only reliable for visible objects (invisible - objects might not be laid out correctly). - - All visual objects provide this information. - - \sa childAt() -*/ - -/*! - \fn QAccessible::Role QAccessibleInterface::role(int child) const - - Returns the role of the object, or of the object's child if \a child - is not 0. The role of an object is usually static. - - All accessible objects have a role. - - \sa text(), state() -*/ - -/*! - \fn QAccessible::State QAccessibleInterface::state(int child) const - - Returns the current state of the object, or of the object's child if - \a child is not 0. The returned value is a combination of the flags in - the QAccessible::StateFlag enumeration. - - All accessible objects have a state. - - \sa text(), role() -*/ - -/*! - \fn int QAccessibleInterface::userActionCount(int child) const - - Returns the number of custom actions of the object, or of the - object's child if \a child is not 0. - - The \c Action type enumerates predefined actions: these - are not included in the returned value. - - \sa actionText(), doAction() -*/ - -/*! - \fn QString QAccessibleInterface::actionText(int action, Text t, int child) const - - Returns the text property \a t of the action \a action supported by - the object, or of the object's child if \a child is not 0. - - \sa text(), userActionCount() -*/ - -/*! - \fn bool QAccessibleInterface::doAction(int action, int child, const QVariantList ¶ms) - - Asks the object, or the object's \a child if \a child is not 0, to - execute \a action using the parameters, \a params. Returns true if - the action could be executed; otherwise returns false. - - \a action can be a predefined or a custom action. - - \sa userActionCount(), actionText() -*/ - -/*! - \fn QColor QAccessibleInterface::backgroundColor() - \internal -*/ - -/*! - \fn QAccessibleEditableTextInterface *QAccessibleInterface::editableTextInterface() - \internal -*/ - -/*! - \fn QColor QAccessibleInterface::foregroundColor() - \internal -*/ - -/*! - \fn QAccessibleTextInterface *QAccessibleInterface::textInterface() - \internal -*/ - -/*! - \fn QAccessibleValueInterface *QAccessibleInterface::valueInterface() - \internal -*/ - -/*! - \fn QAccessibleTableInterface *QAccessibleInterface::tableInterface() - \internal -*/ - -/*! - \fn QAccessibleTable2Interface *QAccessibleInterface::table2Interface() - \internal -*/ - -/*! - \fn QAccessibleActionInterface *QAccessibleInterface::actionInterface() - \internal -*/ - -/*! - \fn QAccessibleImageInterface *QAccessibleInterface::imageInterface() - \internal -*/ - -/*! - \class QAccessibleEvent - \brief The QAccessibleEvent class is used to query addition - accessibility information about complex widgets. - - The event can be of type QEvent::AccessibilityDescription or - QEvent::AccessibilityHelp. - - Some QAccessibleInterface implementations send QAccessibleEvents - to the widget they wrap to obtain the description or help text of - a widget or of its children. The widget can answer by calling - setValue() with the requested information. - - The default QWidget::event() implementation simply sets the text - to be the widget's \l{QWidget::toolTip}{tooltip} (for \l - AccessibilityDescription event) or its - \l{QWidget::whatsThis}{"What's This?" text} (for \l - AccessibilityHelp event). - - \ingroup accessibility - \ingroup events -*/ - -/*! - \fn QAccessibleEvent::QAccessibleEvent(Type type, int child) - - Constructs an accessibility event of the given \a type, which - must be QEvent::AccessibilityDescription or - QEvent::AccessibilityHelp. - - \a child is the (1-based) index of the child to which the request - applies. If \a child is 0, the request is for the widget itself. - - \sa child() -*/ - -/*! - \fn int QAccessibleEvent::child() const - - Returns the (1-based) index of the child to which the request - applies. If the child is 0, the request is for the widget itself. -*/ - -/*! - \fn QString QAccessibleEvent::value() const - - Returns the text set using setValue(). - - \sa setValue() -*/ - -/*! - \fn void QAccessibleEvent::setValue(const QString &text) - - Set the description or help text for the given child() to \a - text, thereby answering the request. - - \sa value() -*/ - -/*! - \since 4.2 - - Invokes a \a method on \a child with the given parameters \a params - and returns the result of the operation as QVariant. - - Note that the type of the returned QVariant depends on the action. - - Returns an invalid QVariant if the object doesn't support the action. -*/ -QVariant QAccessibleInterface::invokeMethod(Method method, int child, const QVariantList ¶ms) -{ - Q_UNUSED(method) - Q_UNUSED(child) - Q_UNUSED(params) - return QVariant(); -} - -/*! \internal */ -QAccessible2Interface *QAccessibleInterface::cast_helper(QAccessible2::InterfaceType t) -{ - return interface_cast(t); -} - -QT_END_NAMESPACE - -#endif - - - - diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h deleted file mode 100644 index 53dc19c9a..000000000 --- a/src/gui/accessible/qaccessible.h +++ /dev/null @@ -1,438 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QACCESSIBLE_H -#define QACCESSIBLE_H - -#include -#include -#include -#include -#include -#include -#include - -#ifndef QT_NO_ACCESSIBILITY - - -QT_BEGIN_NAMESPACE - -class QAccessibleInterface; - -class Q_GUI_EXPORT QAccessible -{ -public: - enum Event { - SoundPlayed = 0x0001, - Alert = 0x0002, - ForegroundChanged = 0x0003, - MenuStart = 0x0004, - MenuEnd = 0x0005, - PopupMenuStart = 0x0006, - PopupMenuEnd = 0x0007, - ContextHelpStart = 0x000C, - ContextHelpEnd = 0x000D, - DragDropStart = 0x000E, - DragDropEnd = 0x000F, - DialogStart = 0x0010, - DialogEnd = 0x0011, - ScrollingStart = 0x0012, - ScrollingEnd = 0x0013, - - MenuCommand = 0x0018, - - // Values from IAccessible2 - ActionChanged = 0x0101, - ActiveDescendantChanged = 0x0102, - AttributeChanged = 0x0103, - DocumentContentChanged = 0x0104, - DocumentLoadComplete = 0x0105, - DocumentLoadStopped = 0x0106, - DocumentReload = 0x0107, - HyperlinkEndIndexChanged = 0x0108, - HyperlinkNumberOfAnchorsChanged = 0x0109, - HyperlinkSelectedLinkChanged = 0x010A, - HypertextLinkActivated = 0x010B, - HypertextLinkSelected = 0x010C, - HyperlinkStartIndexChanged = 0x010D, - HypertextChanged = 0x010E, - HypertextNLinksChanged = 0x010F, - ObjectAttributeChanged = 0x0110, - PageChanged = 0x0111, - SectionChanged = 0x0112, - TableCaptionChanged = 0x0113, - TableColumnDescriptionChanged = 0x0114, - TableColumnHeaderChanged = 0x0115, - TableModelChanged = 0x0116, - TableRowDescriptionChanged = 0x0117, - TableRowHeaderChanged = 0x0118, - TableSummaryChanged = 0x0119, - TextAttributeChanged = 0x011A, - TextCaretMoved = 0x011B, - // TextChanged = 0x011C, is deprecated in IA2, use TextUpdated - TextColumnChanged = 0x011D, - TextInserted = 0x011E, - TextRemoved = 0x011F, - TextUpdated = 0x0120, - TextSelectionChanged = 0x0121, - VisibleDataChanged = 0x0122, - - ObjectCreated = 0x8000, - ObjectDestroyed = 0x8001, - ObjectShow = 0x8002, - ObjectHide = 0x8003, - ObjectReorder = 0x8004, - Focus = 0x8005, - Selection = 0x8006, - SelectionAdd = 0x8007, - SelectionRemove = 0x8008, - SelectionWithin = 0x8009, - StateChanged = 0x800A, - LocationChanged = 0x800B, - NameChanged = 0x800C, - DescriptionChanged = 0x800D, - ValueChanged = 0x800E, - ParentChanged = 0x800F, - HelpChanged = 0x80A0, - DefaultActionChanged = 0x80B0, - AcceleratorChanged = 0x80C0 - }; - - enum StateFlag { - Normal = 0x00000000, - Unavailable = 0x00000001, - Selected = 0x00000002, - Focused = 0x00000004, - Pressed = 0x00000008, - Checked = 0x00000010, - Mixed = 0x00000020, - ReadOnly = 0x00000040, - HotTracked = 0x00000080, - DefaultButton = 0x00000100, - // #### Qt5 Expandable - Expanded = 0x00000200, - Collapsed = 0x00000400, - Busy = 0x00000800, - // Floating = 0x00001000, - Marqueed = 0x00002000, - Animated = 0x00004000, - Invisible = 0x00008000, - Offscreen = 0x00010000, - Sizeable = 0x00020000, - Movable = 0x00040000, - SelfVoicing = 0x00080000, - Focusable = 0x00100000, - Selectable = 0x00200000, - Linked = 0x00400000, - Traversed = 0x00800000, - MultiSelectable = 0x01000000, - ExtSelectable = 0x02000000, - //AlertLow = 0x04000000, - //AlertMedium = 0x08000000, - //AlertHigh = 0x10000000, /* reused for HasInvokeExtension */ - Protected = 0x20000000, - HasPopup = 0x40000000, - Modal = 0x80000000 - - }; - Q_DECLARE_FLAGS(State, StateFlag) - - enum Role { - NoRole = 0x00000000, - TitleBar = 0x00000001, - MenuBar = 0x00000002, - ScrollBar = 0x00000003, - Grip = 0x00000004, - Sound = 0x00000005, - Cursor = 0x00000006, - Caret = 0x00000007, - AlertMessage = 0x00000008, - Window = 0x00000009, - Client = 0x0000000A, - PopupMenu = 0x0000000B, - MenuItem = 0x0000000C, - ToolTip = 0x0000000D, - Application = 0x0000000E, - Document = 0x0000000F, - Pane = 0x00000010, - Chart = 0x00000011, - Dialog = 0x00000012, - Border = 0x00000013, - Grouping = 0x00000014, - Separator = 0x00000015, - ToolBar = 0x00000016, - StatusBar = 0x00000017, - Table = 0x00000018, - ColumnHeader = 0x00000019, - RowHeader = 0x0000001A, - Column = 0x0000001B, - Row = 0x0000001C, - Cell = 0x0000001D, - Link = 0x0000001E, - HelpBalloon = 0x0000001F, - Assistant = 0x00000020, - List = 0x00000021, - ListItem = 0x00000022, - Tree = 0x00000023, - TreeItem = 0x00000024, - PageTab = 0x00000025, - PropertyPage = 0x00000026, - Indicator = 0x00000027, - Graphic = 0x00000028, - StaticText = 0x00000029, - EditableText = 0x0000002A, // Editable, selectable, etc. - PushButton = 0x0000002B, - CheckBox = 0x0000002C, - RadioButton = 0x0000002D, - ComboBox = 0x0000002E, - // DropList = 0x0000002F, - ProgressBar = 0x00000030, - Dial = 0x00000031, - HotkeyField = 0x00000032, - Slider = 0x00000033, - SpinBox = 0x00000034, - Canvas = 0x00000035, - Animation = 0x00000036, - Equation = 0x00000037, - ButtonDropDown = 0x00000038, - ButtonMenu = 0x00000039, - ButtonDropGrid = 0x0000003A, - Whitespace = 0x0000003B, - PageTabList = 0x0000003C, - Clock = 0x0000003D, - Splitter = 0x0000003E, - // Additional Qt roles where enum value does not map directly to MSAA: - LayeredPane = 0x0000003F, - Terminal = 0x00000040, - Desktop = 0x00000041, - UserRole = 0x0000ffff - }; - - enum Text { - Name = 0, - Description, - Value, - Help, - Accelerator, - UserText = 0x0000ffff - }; - - enum RelationFlag { - Unrelated = 0x00000000, - Self = 0x00000001, - Ancestor = 0x00000002, - Child = 0x00000004, - Descendent = 0x00000008, - Sibling = 0x00000010, - HierarchyMask = 0x000000ff, - - Up = 0x00000100, - Down = 0x00000200, - Left = 0x00000400, - Right = 0x00000800, - Covers = 0x00001000, - Covered = 0x00002000, - GeometryMask = 0x0000ff00, - - FocusChild = 0x00010000, - Label = 0x00020000, - Labelled = 0x00040000, - Controller = 0x00080000, - Controlled = 0x00100000, - LogicalMask = 0x00ff0000 - }; - Q_DECLARE_FLAGS(Relation, RelationFlag) - - enum Action { - DefaultAction = 0, - Press = -1, - FirstStandardAction = Press, - SetFocus = -2, - Increase = -3, - Decrease = -4, - Accept = -5, - Cancel = -6, - Select = -7, - ClearSelection = -8, - RemoveSelection = -9, - ExtendSelection = -10, - AddToSelection = -11, - LastStandardAction = AddToSelection - }; - - enum Method { - ListSupportedMethods = 0, - SetCursorPosition = 1, - GetCursorPosition = 2, - ForegroundColor = 3, - BackgroundColor = 4 - }; - - typedef QAccessibleInterface*(*InterfaceFactory)(const QString &key, QObject*); - typedef void(*UpdateHandler)(QObject*, int who, Event reason); - typedef void(*RootObjectHandler)(QObject*); - - static void installFactory(InterfaceFactory); - static void removeFactory(InterfaceFactory); - static UpdateHandler installUpdateHandler(UpdateHandler); - static RootObjectHandler installRootObjectHandler(RootObjectHandler); - - static QAccessibleInterface *queryAccessibleInterface(QObject *); - static void updateAccessibility(QObject *, int who, Event reason); - static bool isActive(); - static void setRootObject(QObject*); - - static void initialize(); - static void cleanup(); - -private: - static UpdateHandler updateHandler; - static RootObjectHandler rootObjectHandler; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::State) -Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::Relation) -QT_END_NAMESPACE -Q_DECLARE_METATYPE(QSet) -QT_BEGIN_NAMESPACE - -namespace QAccessible2 -{ - enum InterfaceType - { - TextInterface, - EditableTextInterface, - ValueInterface, - TableInterface, - ActionInterface, - ImageInterface, - Table2Interface - }; -} - -class QAccessible2Interface; -class QAccessibleTextInterface; -class QAccessibleEditableTextInterface; -class QAccessibleValueInterface; -class QAccessibleTableInterface; -class QAccessibleActionInterface; -class QAccessibleImageInterface; -class QAccessibleTable2Interface; - -class Q_GUI_EXPORT QAccessibleInterface : public QAccessible -{ -public: - virtual ~QAccessibleInterface() {} - // check for valid pointers - virtual bool isValid() const = 0; - virtual QObject *object() const = 0; - - // hierarchy - virtual int childCount() const = 0; - virtual int indexOfChild(const QAccessibleInterface *) const = 0; - - // relations - virtual Relation relationTo(int child, const QAccessibleInterface *other, - int otherChild) const = 0; - virtual int childAt(int x, int y) const = 0; - - // navigation - virtual int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const = 0; - - // properties and state - virtual QString text(Text t, int child) const = 0; - virtual void setText(Text t, int child, const QString &text) = 0; - virtual QRect rect(int child) const = 0; - virtual Role role(int child) const = 0; - virtual State state(int child) const = 0; - - // action - virtual int userActionCount(int child) const = 0; - virtual QString actionText(int action, Text t, int child) const = 0; - virtual bool doAction(int action, int child, const QVariantList ¶ms = QVariantList()) = 0; - - virtual QVariant invokeMethod(Method method, int child = 0, - const QVariantList ¶ms = QVariantList()); - - inline QSet supportedMethods() - { return qvariant_cast >(invokeMethod(ListSupportedMethods)); } - - inline QColor foregroundColor() - { return qvariant_cast(invokeMethod(ForegroundColor)); } - - inline QColor backgroundColor() - { return qvariant_cast(invokeMethod(BackgroundColor)); } - - inline QAccessibleTextInterface *textInterface() - { return reinterpret_cast(cast_helper(QAccessible2::TextInterface)); } - - inline QAccessibleEditableTextInterface *editableTextInterface() - { return reinterpret_cast(cast_helper(QAccessible2::EditableTextInterface)); } - - inline QAccessibleValueInterface *valueInterface() - { return reinterpret_cast(cast_helper(QAccessible2::ValueInterface)); } - - inline QAccessibleTableInterface *tableInterface() - { return reinterpret_cast(cast_helper(QAccessible2::TableInterface)); } - - inline QAccessibleActionInterface *actionInterface() - { return reinterpret_cast(cast_helper(QAccessible2::ActionInterface)); } - - inline QAccessibleImageInterface *imageInterface() - { return reinterpret_cast(cast_helper(QAccessible2::ImageInterface)); } - - inline QAccessibleTable2Interface *table2Interface() - { return reinterpret_cast(cast_helper(QAccessible2::Table2Interface)); } - - // FIXME - virtual QAccessible2Interface *interface_cast(QAccessible2::InterfaceType) - { return 0; } - -private: - QAccessible2Interface *cast_helper(QAccessible2::InterfaceType); -}; -typedef QAccessibleInterface QAccessibleInterfaceEx; - -class Q_GUI_EXPORT QAccessibleEvent : public QEvent -{ -public: - inline QAccessibleEvent(Type type, int child); - inline int child() const { return c; } - inline QString value() const { return val; } - inline void setValue(const QString &aText) { val = aText; } - -private: - int c; - QString val; -}; - -inline QAccessibleEvent::QAccessibleEvent(Type atype, int achild) - : QEvent(atype), c(achild) {} - -QT_END_NAMESPACE - -#define QAccessibleInterface_iid "Katie.QAccessibleInterface" -Q_DECLARE_INTERFACE(QAccessibleInterface, QAccessibleInterface_iid) - - -#endif // QT_NO_ACCESSIBILITY - -#endif // QACCESSIBLE_H diff --git a/src/gui/accessible/qaccessible2.cpp b/src/gui/accessible/qaccessible2.cpp deleted file mode 100644 index 96241fc71..000000000 --- a/src/gui/accessible/qaccessible2.cpp +++ /dev/null @@ -1,301 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaccessible2.h" -#include "qapplication.h" -#include "qclipboard.h" -#include "qtextboundaryfinder.h" - -#ifndef QT_NO_ACCESSIBILITY - -QT_BEGIN_NAMESPACE - -/*! - \namespace QAccessible2 - \ingroup accessibility - \internal - \preliminary - - \brief The QAccessible2 namespace defines constants relating to - IAccessible2-based interfaces - - \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink -*/ - -/*! - \class QAccessibleTextInterface - - \ingroup accessibility - \internal - \preliminary - - \brief The QAccessibleTextInterface class implements support for - the IAccessibleText interface. - - \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink -*/ - -/*! - \class QAccessibleEditableTextInterface - \ingroup accessibility - \internal - \preliminary - - \brief The QAccessibleEditableTextInterface class implements support for - the IAccessibleEditableText interface. - - \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink -*/ - -/*! - \class QAccessibleSimpleEditableTextInterface - \ingroup accessibility - \internal - \preliminary - - \brief The QAccessibleSimpleEditableTextInterface class is a convenience class for - text-based widgets. - - \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink -*/ - -/*! - \class QAccessibleValueInterface - \ingroup accessibility - \internal - \preliminary - - \brief The QAccessibleValueInterface class implements support for - the IAccessibleValue interface. - - \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink -*/ - -/*! - \class QAccessibleActionInterface - \ingroup accessibility - \internal - \preliminary - - \brief The QAccessibleActionInterface class implements support for - the IAccessibleAction interface. - - \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink -*/ - -/*! - \class QAccessibleImageInterface - \ingroup accessibility - \internal - \preliminary - - \brief The QAccessibleImageInterface class implements support for - the IAccessibleImage interface. - - \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink -*/ - - -/*! - \internal -*/ -QString Q_GUI_EXPORT qTextBeforeOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset, const QString& text) -{ - QTextBoundaryFinder::BoundaryType type; - switch (boundaryType) { - case QAccessible2::CharBoundary: - type = QTextBoundaryFinder::Grapheme; - break; - case QAccessible2::WordBoundary: - type = QTextBoundaryFinder::Word; - break; - case QAccessible2::SentenceBoundary: - type = QTextBoundaryFinder::Sentence; - break; - default: - // in any other case return the whole line - *startOffset = 0; - *endOffset = text.length(); - return text; - } - - QTextBoundaryFinder boundary(type, text); - boundary.setPosition(offset); - - if (!boundary.isAtBoundary()) { - boundary.toPreviousBoundary(); - } - boundary.toPreviousBoundary(); - *startOffset = boundary.position(); - boundary.toNextBoundary(); - *endOffset = boundary.position(); - - return text.mid(*startOffset, *endOffset - *startOffset); -} - -/*! - \internal -*/ -QString Q_GUI_EXPORT qTextAfterOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset, const QString& text) -{ - QTextBoundaryFinder::BoundaryType type; - switch (boundaryType) { - case QAccessible2::CharBoundary: - type = QTextBoundaryFinder::Grapheme; - break; - case QAccessible2::WordBoundary: - type = QTextBoundaryFinder::Word; - break; - case QAccessible2::SentenceBoundary: - type = QTextBoundaryFinder::Sentence; - break; - default: - // in any other case return the whole line - *startOffset = 0; - *endOffset = text.length(); - return text; - } - - QTextBoundaryFinder boundary(type, text); - boundary.setPosition(offset); - - boundary.toNextBoundary(); - *startOffset = boundary.position(); - boundary.toNextBoundary(); - *endOffset = boundary.position(); - - return text.mid(*startOffset, *endOffset - *startOffset); -} - -/*! - \internal -*/ -QString Q_GUI_EXPORT qTextAtOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset, const QString& text) -{ - QTextBoundaryFinder::BoundaryType type; - switch (boundaryType) { - case QAccessible2::CharBoundary: - type = QTextBoundaryFinder::Grapheme; - break; - case QAccessible2::WordBoundary: - type = QTextBoundaryFinder::Word; - break; - case QAccessible2::SentenceBoundary: - type = QTextBoundaryFinder::Sentence; - break; - default: - // in any other case return the whole line - *startOffset = 0; - *endOffset = text.length(); - return text; - } - - QTextBoundaryFinder boundary(type, text); - boundary.setPosition(offset); - - if (!boundary.isAtBoundary()) { - boundary.toPreviousBoundary(); - } - *startOffset = boundary.position(); - boundary.toNextBoundary(); - *endOffset = boundary.position(); - - return text.mid(*startOffset, *endOffset - *startOffset); -} - -QAccessibleSimpleEditableTextInterface::QAccessibleSimpleEditableTextInterface( - QAccessibleInterface *accessibleInterface) - : iface(accessibleInterface) -{ - Q_ASSERT(iface); -} - -#ifndef QT_NO_CLIPBOARD -static QString textForRange(QAccessibleInterface *iface, int startOffset, int endOffset) -{ - return iface->text(QAccessible::Value, 0).mid(startOffset, endOffset - startOffset); -} -#endif - -void QAccessibleSimpleEditableTextInterface::copyText(int startOffset, int endOffset) -{ -#ifdef QT_NO_CLIPBOARD - Q_UNUSED(startOffset); - Q_UNUSED(endOffset); -#else - QApplication::clipboard()->setText(textForRange(iface, startOffset, endOffset)); -#endif -} - -void QAccessibleSimpleEditableTextInterface::deleteText(int startOffset, int endOffset) -{ - QString txt = iface->text(QAccessible::Value, 0); - txt.remove(startOffset, endOffset - startOffset); - iface->setText(QAccessible::Value, 0, txt); -} - -void QAccessibleSimpleEditableTextInterface::insertText(int offset, const QString &text) -{ - QString txt = iface->text(QAccessible::Value, 0); - txt.insert(offset, text); - iface->setText(QAccessible::Value, 0, txt); -} - -void QAccessibleSimpleEditableTextInterface::cutText(int startOffset, int endOffset) -{ -#ifdef QT_NO_CLIPBOARD - Q_UNUSED(startOffset); - Q_UNUSED(endOffset); -#else - QString sub = textForRange(iface, startOffset, endOffset); - deleteText(startOffset, endOffset); - QApplication::clipboard()->setText(sub); -#endif -} - -void QAccessibleSimpleEditableTextInterface::pasteText(int offset) -{ -#ifdef QT_NO_CLIPBOARD - Q_UNUSED(offset); -#else - QString txt = iface->text(QAccessible::Value, 0); - txt.insert(offset, QApplication::clipboard()->text()); - iface->setText(QAccessible::Value, 0, txt); -#endif -} - -void QAccessibleSimpleEditableTextInterface::replaceText(int startOffset, int endOffset, const QString &text) -{ - QString txt = iface->text(QAccessible::Value, 0); - txt.replace(startOffset, endOffset - startOffset, text); - iface->setText(QAccessible::Value, 0, txt); -} - -QT_END_NAMESPACE - -#endif // QT_NO_ACCESSIBILITY - - - - diff --git a/src/gui/accessible/qaccessible2.h b/src/gui/accessible/qaccessible2.h deleted file mode 100644 index 954d0ecba..000000000 --- a/src/gui/accessible/qaccessible2.h +++ /dev/null @@ -1,335 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QACCESSIBLE2_H -#define QACCESSIBLE2_H - -#include - - -QT_BEGIN_NAMESPACE - - -#ifndef QT_NO_ACCESSIBILITY - -class QModelIndex; - -namespace QAccessible2 -{ - enum CoordinateType - { - RelativeToScreen = 0, - RelativeToParent = 1 - }; - - enum BoundaryType { - CharBoundary, - WordBoundary, - SentenceBoundary, - ParagraphBoundary, - LineBoundary, - NoBoundary - }; - - enum TableModelChangeType { - TableModelChangeInsert, - TableModelChangeDelete, - TableModelChangeUpdate - }; - - struct TableModelChange { - int firstColumn; - int firstRow; - int lastColumn; - int lastRow; - TableModelChangeType type; - - TableModelChange() - : firstColumn(0), firstRow(0), lastColumn(0), lastRow(0), type(TableModelChangeUpdate) - {} - }; -} - -class Q_GUI_EXPORT QAccessible2Interface -{ -public: - virtual ~QAccessible2Interface() {} -}; - -// catch-all functions. If an accessible class doesn't implement interface T, return 0 -inline QAccessible2Interface *qAccessibleValueCastHelper() { return 0; } -inline QAccessible2Interface *qAccessibleTextCastHelper() { return 0; } -inline QAccessible2Interface *qAccessibleEditableTextCastHelper() { return 0; } -inline QAccessible2Interface *qAccessibleTableCastHelper() { return 0; } -inline QAccessible2Interface *qAccessibleActionCastHelper() { return 0; } -inline QAccessible2Interface *qAccessibleImageCastHelper() { return 0; } -inline QAccessible2Interface *qAccessibleTable2CastHelper() { return 0; } - -#define Q_ACCESSIBLE_OBJECT \ - public: \ - QAccessible2Interface *interface_cast(QAccessible2::InterfaceType t) \ - { \ - switch (t) { \ - case QAccessible2::TextInterface: \ - return qAccessibleTextCastHelper(); \ - case QAccessible2::EditableTextInterface: \ - return qAccessibleEditableTextCastHelper(); \ - case QAccessible2::ValueInterface: \ - return qAccessibleValueCastHelper(); \ - case QAccessible2::TableInterface: \ - return qAccessibleTableCastHelper(); \ - case QAccessible2::ActionInterface: \ - return qAccessibleActionCastHelper(); \ - case QAccessible2::ImageInterface: \ - return qAccessibleImageCastHelper(); \ - case QAccessible2::Table2Interface: \ - return qAccessibleTable2CastHelper(); \ - } \ - return 0; \ - } \ - private: - -class Q_GUI_EXPORT QAccessibleTextInterface: public QAccessible2Interface -{ -public: - inline QAccessible2Interface *qAccessibleTextCastHelper() { return this; } - - virtual ~QAccessibleTextInterface() {} - - virtual void addSelection(int startOffset, int endOffset) = 0; - virtual QString attributes(int offset, int *startOffset, int *endOffset) = 0; - virtual int cursorPosition() = 0; - virtual QRect characterRect(int offset, QAccessible2::CoordinateType coordType) = 0; - virtual int selectionCount() = 0; - virtual int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType) = 0; - virtual void selection(int selectionIndex, int *startOffset, int *endOffset) = 0; - virtual QString text(int startOffset, int endOffset) = 0; - virtual QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset) = 0; - virtual QString textAfterOffset(int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset) = 0; - virtual QString textAtOffset(int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset) = 0; - virtual void removeSelection(int selectionIndex) = 0; - virtual void setCursorPosition(int position) = 0; - virtual void setSelection(int selectionIndex, int startOffset, int endOffset) = 0; - virtual int characterCount() = 0; - virtual void scrollToSubstring(int startIndex, int endIndex) = 0; -}; - -class Q_GUI_EXPORT QAccessibleEditableTextInterface: public QAccessible2Interface -{ -public: - inline QAccessible2Interface *qAccessibleEditableTextCastHelper() { return this; } - - virtual ~QAccessibleEditableTextInterface() {} - - virtual void copyText(int startOffset, int endOffset) = 0; - virtual void deleteText(int startOffset, int endOffset) = 0; - virtual void insertText(int offset, const QString &text) = 0; - virtual void cutText(int startOffset, int endOffset) = 0; - virtual void pasteText(int offset) = 0; - virtual void replaceText(int startOffset, int endOffset, const QString &text) = 0; - virtual void setAttributes(int startOffset, int endOffset, const QString &attributes) = 0; -}; - -class Q_GUI_EXPORT QAccessibleSimpleEditableTextInterface: public QAccessibleEditableTextInterface -{ -public: - QAccessibleSimpleEditableTextInterface(QAccessibleInterface *accessibleInterface); - - void copyText(int startOffset, int endOffset); - void deleteText(int startOffset, int endOffset); - void insertText(int offset, const QString &text); - void cutText(int startOffset, int endOffset); - void pasteText(int offset); - void replaceText(int startOffset, int endOffset, const QString &text); - inline void setAttributes(int, int, const QString &) {} - -private: - QAccessibleInterface *iface; -}; - -class Q_GUI_EXPORT QAccessibleValueInterface: public QAccessible2Interface -{ -public: - inline QAccessible2Interface *qAccessibleValueCastHelper() { return this; } - - virtual ~QAccessibleValueInterface() {} - - virtual QVariant currentValue() = 0; - virtual void setCurrentValue(const QVariant &value) = 0; - virtual QVariant maximumValue() = 0; - virtual QVariant minimumValue() = 0; -}; - -class Q_GUI_EXPORT QAccessibleTableInterface: public QAccessible2Interface -{ -public: - inline QAccessible2Interface *qAccessibleTableCastHelper() { return this; } - - virtual QAccessibleInterface *accessibleAt(int row, int column) = 0; - virtual QAccessibleInterface *caption() = 0; - virtual int childIndex(int rowIndex, int columnIndex) = 0; - virtual QString columnDescription(int column) = 0; - virtual int columnSpan(int row, int column) = 0; - virtual QAccessibleInterface *columnHeader() = 0; - virtual int columnIndex(int childIndex) = 0; - virtual int columnCount() = 0; - virtual int rowCount() = 0; - virtual int selectedColumnCount() = 0; - virtual int selectedRowCount() = 0; - virtual QString rowDescription(int row) = 0; - virtual int rowSpan(int row, int column) = 0; - virtual QAccessibleInterface *rowHeader() = 0; - virtual int rowIndex(int childIndex) = 0; - virtual int selectedRows(int maxRows, QList *rows) = 0; - virtual int selectedColumns(int maxColumns, QList *columns) = 0; - virtual QAccessibleInterface *summary() = 0; - virtual bool isColumnSelected(int column) = 0; - virtual bool isRowSelected(int row) = 0; - virtual bool isSelected(int row, int column) = 0; - virtual void selectRow(int row) = 0; - virtual void selectColumn(int column) = 0; - virtual void unselectRow(int row) = 0; - virtual void unselectColumn(int column) = 0; - virtual void cellAtIndex(int index, int *row, int *column, int *rowSpan, - int *columnSpan, bool *isSelected) = 0; -}; - -class Q_GUI_EXPORT QAccessibleTable2CellInterface: public QAccessibleInterface -{ -public: - // Returns the number of columns occupied by this cell accessible. - virtual int columnExtent() const = 0; - - // Returns the column headers as an array of cell accessibles. - virtual QList columnHeaderCells() const = 0; - - // Translates this cell accessible into the corresponding column index. - virtual int columnIndex() const = 0; - // Returns the number of rows occupied by this cell accessible. - virtual int rowExtent() const = 0; - // Returns the row headers as an array of cell accessibles. - virtual QList rowHeaderCells() const = 0; - // Translates this cell accessible into the corresponding row index. - virtual int rowIndex() const = 0; - // Returns a boolean value indicating whether this cell is selected. - virtual bool isSelected() const = 0; - - // Gets the row and column indexes and extents of this cell accessible and whether or not it is selected. - virtual void rowColumnExtents(int *row, int *column, int *rowExtents, int *columnExtents, bool *selected) const = 0; - // Returns a reference to the accessbile of the containing table. - virtual QAccessibleTable2Interface* table() const = 0; - - // #### Qt5 this should not be here but part of the state - virtual bool isExpandable() const = 0; -}; - -class Q_GUI_EXPORT QAccessibleTable2Interface: public QAccessible2Interface -{ -public: - inline QAccessible2Interface *qAccessibleTable2CastHelper() { return this; } - - // Returns the cell at the specified row and column in the table. - virtual QAccessibleTable2CellInterface *cellAt (int row, int column) const = 0; - // Returns the caption for the table. - virtual QAccessibleInterface *caption() const = 0; - // Returns the description text of the specified column in the table. - virtual QString columnDescription(int column) const = 0; - // Returns the total number of columns in table. - virtual int columnCount() const = 0; - // Returns the total number of rows in table. - virtual int rowCount() const = 0; - // Returns the total number of selected cells. - virtual int selectedCellCount() const = 0; - // Returns the total number of selected columns. - virtual int selectedColumnCount() const = 0; - // Returns the total number of selected rows. - virtual int selectedRowCount() const = 0; - // Returns the description text of the specified row in the table. - virtual QString rowDescription(int row) const = 0; - // Returns a list of accessibles currently selected. - virtual QList selectedCells() const = 0; - // Returns a list of column indexes currently selected (0 based). - virtual QList selectedColumns() const = 0; - // Returns a list of row indexes currently selected (0 based). - virtual QList selectedRows() const = 0; - // Returns the summary description of the table. - virtual QAccessibleInterface *summary() const = 0; - // Returns a boolean value indicating whether the specified column is completely selected. - virtual bool isColumnSelected(int column) const = 0; - // Returns a boolean value indicating whether the specified row is completely selected. - virtual bool isRowSelected(int row) const = 0; - // Selects a row and unselects all previously selected rows. - virtual bool selectRow(int row) = 0; - // Selects a column and unselects all previously selected columns. - virtual bool selectColumn(int column) = 0; - // Unselects one row, leaving other selected rows selected (if any). - virtual bool unselectRow(int row) = 0; - // Unselects one column, leaving other selected columns selected (if any). - virtual bool unselectColumn(int column) = 0; - // Returns the type and extents describing how a table changed. - virtual QAccessible2::TableModelChange modelChange() const = 0; - -protected: - // These functions are called when the model changes. - virtual void modelReset() = 0; - virtual void rowsInserted(const QModelIndex &parent, int first, int last) = 0; - virtual void rowsRemoved(const QModelIndex &parent, int first, int last) = 0; - virtual void columnsInserted(const QModelIndex &parent, int first, int last) = 0; - virtual void columnsRemoved(const QModelIndex &parent, int first, int last) = 0; - virtual void rowsMoved( const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row) = 0; - virtual void columnsMoved( const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column) = 0; - -friend class QAbstractItemView; -friend class QAbstractItemViewPrivate; -}; - -class Q_GUI_EXPORT QAccessibleActionInterface : public QAccessible2Interface -{ -public: - inline QAccessible2Interface *qAccessibleActionCastHelper() { return this; } - - virtual int actionCount() = 0; - virtual void doAction(int actionIndex) = 0; - virtual QString description(int actionIndex) = 0; - virtual QString name(int actionIndex) = 0; - virtual QString localizedName(int actionIndex) = 0; - virtual QStringList keyBindings(int actionIndex) = 0; -}; - -class Q_GUI_EXPORT QAccessibleImageInterface : public QAccessible2Interface -{ -public: - inline QAccessible2Interface *qAccessibleImageCastHelper() { return this; } - - virtual QString imageDescription() = 0; - virtual QSize imageSize() = 0; - virtual QRect imagePosition(QAccessible2::CoordinateType coordType) = 0; -}; - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - - -#endif diff --git a/src/gui/accessible/qaccessible_unix.cpp b/src/gui/accessible/qaccessible_unix.cpp deleted file mode 100644 index 359742c13..000000000 --- a/src/gui/accessible/qaccessible_unix.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaccessible.h" -#include "qaccessiblebridge.h" - -#ifndef QT_NO_ACCESSIBILITY - -#include "qcoreapplication.h" -#include "qvector.h" -#include "qfactoryloader_p.h" - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_LIBRARY -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, bridgeloader, - (QAccessibleBridgeFactoryInterface_iid, QLatin1String("/accessiblebridge"))) -#endif -Q_GLOBAL_STATIC(QVector, bridges) - -void QAccessible::initialize() -{ - static const int shouldinit = qgetenv("QT_ACCESSIBILITY").toInt(); - if (!shouldinit) - return; - -#ifndef QT_NO_LIBRARY - const QStringList l = bridgeloader()->keys(); - for (int i = 0; i < l.count(); ++i) { - if (QAccessibleBridgeFactoryInterface *factory = - qobject_cast(bridgeloader()->instance(l.at(i)))) { - QAccessibleBridge * bridge = factory->create(l.at(i)); - if (bridge) - bridges()->append(bridge); - } - } -#endif -} - -void QAccessible::cleanup() -{ - qDeleteAll(*bridges()); -} - -void QAccessible::updateAccessibility(QObject *o, int who, Event reason) -{ - Q_ASSERT(o); - - if (updateHandler) { - updateHandler(o, who, reason); - return; - } - - initialize(); - if (!bridges() || bridges()->isEmpty()) - return; - - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(o); - if (!iface) - return; - - // updates for List/Table/Tree should send child - if (who) { - QAccessibleInterface *child; - iface->navigate(QAccessible::Child, who, &child); - if (child) { - delete iface; - iface = child; - who = 0; - } - } - - for (int i = 0; i < bridges()->count(); ++i) - bridges()->at(i)->notifyAccessibilityUpdate(reason, iface, who); - delete iface; -} - -void QAccessible::setRootObject(QObject *o) -{ - if (rootObjectHandler) { - rootObjectHandler(o); - return; - } - - initialize(); - if (bridges()->isEmpty() || !o) - return; - - for (int i = 0; i < bridges()->count(); ++i) { - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(o); - bridges()->at(i)->setRootObject(iface); - } -} - -QT_END_NAMESPACE - -#endif // QT_NO_ACCESSIBILITY - - - diff --git a/src/gui/accessible/qaccessiblebridge.cpp b/src/gui/accessible/qaccessiblebridge.cpp deleted file mode 100644 index f0b6f8c92..000000000 --- a/src/gui/accessible/qaccessiblebridge.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaccessiblebridge.h" - -#ifndef QT_NO_ACCESSIBILITY - -QT_BEGIN_NAMESPACE - -/*! - \class QAccessibleBridge - \brief The QAccessibleBridge class is the base class for - accessibility back-ends. - - \ingroup accessibility - - Qt supports Microsoft Active Accessibility (MSAA), Mac OS X - Accessibility, and the Unix/X11 AT-SPI standard. By subclassing - QAccessibleBridge, you can support other backends than the - predefined ones. - - Currently, custom bridges are only supported on Unix. We might - add support for them on other platforms as well if there is - enough demand. - - \sa QAccessible, QAccessibleBridgePlugin -*/ - -/*! - \fn QAccessibleBridge::~QAccessibleBridge() - - Destroys the accessibility bridge object. -*/ - -/*! - \fn void QAccessibleBridge::setRootObject(QAccessibleInterface *object) - - This function is called by Qt at application startup to set the - root accessible object of the application to \a object. All other - accessible objects in the application can be reached by the - client using object navigation. -*/ - -/*! - \fn void QAccessibleBridge::notifyAccessibilityUpdate(int reason, QAccessibleInterface *interface, int child) - - This function is called by Qt to notify the bridge about a change - in the accessibility information for object wrapped by the given - \a interface. - - \a reason specifies the cause of the change. It can take values - of type QAccessible::Event. - - \a child is the (1-based) index of the child element that has - changed. When \a child is 0, the object itself has changed. - - \sa QAccessible::updateAccessibility() -*/ - -/*! - \class QAccessibleBridgePlugin - \brief The QAccessibleBridgePlugin class provides an abstract - base for accessibility bridge plugins. - - \ingroup plugins - \ingroup accessibility - - Writing an accessibility bridge plugin is achieved by subclassing - this base class, reimplementing the pure virtual functions keys() - and create(), and exporting the class with the - Q_EXPORT_PLUGIN2() macro. - - \sa QAccessibleBridge, QAccessiblePlugin, {How to Create Qt Plugins} -*/ - -/*! - Constructs an accessibility bridge plugin with the given \a - parent. This is invoked automatically by the Q_EXPORT_PLUGIN2() - macro. -*/ -QAccessibleBridgePlugin::QAccessibleBridgePlugin(QObject *parent) - : QObject(parent) -{ - -} - -/*! - Destroys the accessibility bridge plugin. - - You never have to call this explicitly. Qt destroys a plugin - automatically when it is no longer used. -*/ -QAccessibleBridgePlugin::~QAccessibleBridgePlugin() -{ - -} - -/*! - \fn QStringList QAccessibleBridgePlugin::keys() const - - Returns the list of keys this plugins supports. - - These keys must be the names of the bridges that this - plugin provides. - - \sa create() -*/ - -/*! - \fn QAccessibleBridge *QAccessibleBridgePlugin::create(const QString &key) - - Creates and returns the QAccessibleBridge object corresponding to - the given \a key. Keys are case sensitive. - - \sa keys() -*/ - -QT_END_NAMESPACE - - -#include "moc_qaccessiblebridge.h" - -#endif // QT_NO_ACCESSIBILITY diff --git a/src/gui/accessible/qaccessiblebridge.h b/src/gui/accessible/qaccessiblebridge.h deleted file mode 100644 index 73b5d7d7f..000000000 --- a/src/gui/accessible/qaccessiblebridge.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QACCESSIBLEBRIDGE_H -#define QACCESSIBLEBRIDGE_H - -#include -#include - - -QT_BEGIN_NAMESPACE - - -#ifndef QT_NO_ACCESSIBILITY - -class QAccessibleInterface; - -class QAccessibleBridge -{ -public: - virtual ~QAccessibleBridge() {} - virtual void setRootObject(QAccessibleInterface *) = 0; - virtual void notifyAccessibilityUpdate(int, QAccessibleInterface*, int) = 0; -}; - -struct Q_GUI_EXPORT QAccessibleBridgeFactoryInterface : public QFactoryInterface -{ - virtual QAccessibleBridge *create(const QString& name) = 0; -}; - -QT_END_NAMESPACE - -#define QAccessibleBridgeFactoryInterface_iid "Katie.QAccessibleBridgeFactoryInterface" -Q_DECLARE_INTERFACE(QAccessibleBridgeFactoryInterface, QAccessibleBridgeFactoryInterface_iid) - -QT_BEGIN_NAMESPACE - -class Q_GUI_EXPORT QAccessibleBridgePlugin : public QObject, public QAccessibleBridgeFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QAccessibleBridgeFactoryInterface:QFactoryInterface) -public: - explicit QAccessibleBridgePlugin(QObject *parent = nullptr); - ~QAccessibleBridgePlugin(); - - virtual QStringList keys() const = 0; - virtual QAccessibleBridge *create(const QString &key) = 0; -}; - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - - -#endif // QACCESSIBLEBRIDGE_H diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp deleted file mode 100644 index ffda80a00..000000000 --- a/src/gui/accessible/qaccessibleobject.cpp +++ /dev/null @@ -1,337 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaccessibleobject.h" - -#ifndef QT_NO_ACCESSIBILITY - -#include "qapplication.h" -#include "qwidget.h" -#include "qpointer.h" -#include "qmetaobject.h" - -QT_BEGIN_NAMESPACE - -class QAccessibleObjectPrivate -{ -public: - QPointer object; -}; - -/*! - \class QAccessibleObject - \brief The QAccessibleObject class implements parts of the - QAccessibleInterface for QObjects. - - \ingroup accessibility - - This class is mainly provided for convenience. All subclasses of - the QAccessibleInterface that provide implementations of non-widget objects - should use this class as their base class. - - \sa QAccessible, QAccessibleWidget -*/ - -/*! - Creates a QAccessibleObject for \a object. -*/ -QAccessibleObject::QAccessibleObject(QObject *object) -{ - d = new QAccessibleObjectPrivate; - d->object = object; -} - -/*! - Destroys the QAccessibleObject. - - This only happens when a call to release() decrements the internal - reference counter to zero. -*/ -QAccessibleObject::~QAccessibleObject() -{ - delete d; -} - -/*! - \reimp -*/ -QObject *QAccessibleObject::object() const -{ -#ifndef QT_NO_DEBUG - if (!d->object) - qWarning("QAccessibleInterface is invalid. Crash pending..."); -#endif - return d->object; -} - -/*! - \reimp -*/ -bool QAccessibleObject::isValid() const -{ - return !d->object.isNull(); -} - -/*! \reimp */ -QRect QAccessibleObject::rect(int) const -{ - return QRect(); -} - -/*! \reimp */ -void QAccessibleObject::setText(Text, int, const QString &) -{ -} - -/*! \reimp */ -int QAccessibleObject::userActionCount(int) const -{ - return 0; -} - -/*! \reimp */ -bool QAccessibleObject::doAction(int, int, const QVariantList &) -{ - return false; -} - -static const char * const action_text[][5] = -{ - // Name, Description, Value, Help, Accelerator - { "Press", "", "", "", "Space" }, - { "SetFocus", "Passes focus to this widget", "", "", "" }, - { "Increase", "", "", "", "" }, - { "Decrease", "", "", "", "" }, - { "Accept", "", "", "", "" }, - { "Cancel", "", "", "", "" }, - { "Select", "", "", "", "" }, - { "ClearSelection", "", "", "", "" }, - { "RemoveSelection", "", "", "", "" }, - { "ExtendSelection", "", "", "", "" }, - { "AddToSelection", "", "", "", "" } -}; - -/*! \reimp */ -QString QAccessibleObject::actionText(int action, Text t, int child) const -{ - if (child || action > FirstStandardAction || action < LastStandardAction || t > Accelerator) - return QString(); - - return QString::fromLatin1(action_text[-(action - FirstStandardAction)][t]); -} - - -/*! - \class QAccessibleApplication - \brief The QAccessibleApplication class implements the QAccessibleInterface for QApplication. - - \internal - - \ingroup accessibility -*/ - -/*! - Creates a QAccessibleApplication for the QApplication object referenced by qApp. -*/ -QAccessibleApplication::QAccessibleApplication() -: QAccessibleObject(qApp) -{ -} - -// all toplevel widgets except popups and the desktop -static QWidgetList topLevelWidgets() -{ - QWidgetList list; - const QWidgetList tlw(QApplication::topLevelWidgets()); - for (int i = 0; i < tlw.count(); ++i) { - QWidget *w = tlw.at(i); - if (!(w->windowType() == Qt::Popup) && !(w->windowType() == Qt::Desktop)) - list.append(w); - } - - return list; -} - -/*! \reimp */ -int QAccessibleApplication::childCount() const -{ - return topLevelWidgets().count(); -} - -/*! \reimp */ -int QAccessibleApplication::indexOfChild(const QAccessibleInterface *child) const -{ - if (!child->object()->isWidgetType()) - return -1; - - const QWidgetList tlw(topLevelWidgets()); - int index = tlw.indexOf(static_cast(child->object())); - if (index != -1) - ++index; - return index; -} - -/*! \reimp */ -int QAccessibleApplication::childAt(int x, int y) const -{ - const QWidgetList tlw(topLevelWidgets()); - for (int i = 0; i < tlw.count(); ++i) { - QWidget *w = tlw.at(i); - if (w->frameGeometry().contains(x,y)) - return i+1; - } - return -1; -} - -/*! \reimp */ -QAccessible::Relation QAccessibleApplication::relationTo(int child, const - QAccessibleInterface *other, int otherChild) const -{ - QObject *o = other ? other->object() : 0; - if (!o) - return Unrelated; - - if(o == object()) { - if (child && !otherChild) - return Child; - if (!child && otherChild) - return Ancestor; - if (!child && !otherChild) - return Self; - } - - QWidgetList tlw(topLevelWidgets()); - if (tlw.contains(qobject_cast(o))) - return Ancestor; - - for (int i = 0; i < tlw.count(); ++i) { - QWidget *w = tlw.at(i); - QObjectList cl = w->findChildren(QString()); - if (cl.contains(o)) - return Ancestor; - } - - return Unrelated; -} - -/*! \reimp */ -int QAccessibleApplication::navigate(RelationFlag relation, int entry, - QAccessibleInterface **target) const -{ - if (!target) - return -1; - - *target = 0; - QObject *targetObject = 0; - - switch (relation) { - case Self: - targetObject = object(); - break; - case Child: - if (entry > 0 && entry <= childCount()) { - const QWidgetList tlw(topLevelWidgets()); - if (tlw.count() >= entry) - targetObject = tlw.at(entry-1); - } else { - return -1; - } - break; - case FocusChild: - targetObject = QApplication::activeWindow(); - break; - default: - break; - } - *target = QAccessible::queryAccessibleInterface(targetObject); - return *target ? 0 : -1; -} - -/*! \reimp */ -QString QAccessibleApplication::text(Text t, int) const -{ - switch (t) { - case Name: - return QApplication::applicationName(); - case Description: - return QApplication::applicationFilePath(); - default: - break; - } - return QString(); -} - -/*! \reimp */ -QAccessible::Role QAccessibleApplication::role(int) const -{ - return Application; -} - -/*! \reimp */ -QAccessible::State QAccessibleApplication::state(int) const -{ - return QApplication::activeWindow() ? Focused : Normal; -} - -/*! \reimp */ -int QAccessibleApplication::userActionCount(int) const -{ - return 1; -} - -/*! \reimp */ -bool QAccessibleApplication::doAction(int action, int child, const QVariantList ¶m) -{ - if (action == 0 || action == 1) { - QWidget *w = 0; - w = QApplication::activeWindow(); - if (!w) - w = topLevelWidgets().at(0); - if (!w) - return false; - w->activateWindow(); - return true; - } - return QAccessibleObject::doAction(action, child, param); -} - -/*! \reimp */ -QString QAccessibleApplication::actionText(int action, Text text, int child) const -{ - QString str; - if ((action == 0 || action == 1) && !child) switch (text) { - case Name: - return QApplication::tr("Activate"); - case Description: - return QApplication::tr("Activates the program's main window"); - default: - break; - } - return QAccessibleObject::actionText(action, text, child); -} - -QT_END_NAMESPACE - -#endif //QT_NO_ACCESSIBILITY - - - - diff --git a/src/gui/accessible/qaccessibleobject.h b/src/gui/accessible/qaccessibleobject.h deleted file mode 100644 index a7c37236e..000000000 --- a/src/gui/accessible/qaccessibleobject.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QACCESSIBLEOBJECT_H -#define QACCESSIBLEOBJECT_H - -#include - - -QT_BEGIN_NAMESPACE - - -#ifndef QT_NO_ACCESSIBILITY - -class QAccessibleObjectPrivate; -class QObject; - -class Q_GUI_EXPORT QAccessibleObject : public QAccessibleInterface -{ -public: - explicit QAccessibleObject(QObject *object); - - bool isValid() const; - QObject *object() const; - - // properties - QRect rect(int child) const; - void setText(Text t, int child, const QString &text); - - // actions - int userActionCount(int child) const; - bool doAction(int action, int child, const QVariantList ¶ms); - QString actionText(int action, Text t, int child) const; - -protected: - virtual ~QAccessibleObject(); - -private: - QAccessibleObjectPrivate *d; - Q_DISABLE_COPY(QAccessibleObject) -}; -typedef QAccessibleObject QAccessibleObjectEx; - -class Q_GUI_EXPORT QAccessibleApplication : public QAccessibleObject -{ -public: - QAccessibleApplication(); - - // relations - int childCount() const; - int indexOfChild(const QAccessibleInterface*) const; - Relation relationTo(int, const QAccessibleInterface *, int) const; - - // navigation - int childAt(int x, int y) const; - int navigate(RelationFlag, int, QAccessibleInterface **) const; - - // properties and state - QString text(Text t, int child) const; - Role role(int child) const; - State state(int child) const; - - // actions - int userActionCount(int child) const; - bool doAction(int action, int child, const QVariantList ¶ms); - QString actionText(int action, Text t, int child) const; -}; - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - - -#endif // QACCESSIBLEOBJECT_H diff --git a/src/gui/accessible/qaccessibleplugin.cpp b/src/gui/accessible/qaccessibleplugin.cpp deleted file mode 100644 index d6a5d449c..000000000 --- a/src/gui/accessible/qaccessibleplugin.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaccessibleplugin.h" - -#ifndef QT_NO_ACCESSIBILITY - -#include "qaccessible.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QAccessiblePlugin - \brief The QAccessiblePlugin class provides an abstract base for - accessibility plugins. - - \ingroup plugins - \ingroup accessibility - - Writing an accessibility plugin is achieved by subclassing this - base class, reimplementing the pure virtual functions keys() and - create(), and exporting the class with the Q_EXPORT_PLUGIN2() - macro. - - \sa QAccessibleBridgePlugin, {How to Create Qt Plugins} -*/ - -/*! - Constructs an accessibility plugin with the given \a parent. This - is invoked automatically by the Q_EXPORT_PLUGIN2() macro. -*/ -QAccessiblePlugin::QAccessiblePlugin(QObject *parent) - : QObject(parent) -{ -} - -/*! - Destroys the accessibility plugin. - - You never have to call this explicitly. Qt destroys a plugin - automatically when it is no longer used. -*/ -QAccessiblePlugin::~QAccessiblePlugin() -{ -} - -/*! - \fn QStringList QAccessiblePlugin::keys() const - - Returns the list of keys this plugin supports. - - These keys must be the class names that this plugin provides - an accessibility implementation for. - - \sa create() -*/ - -/*! - \fn QAccessibleInterface *QAccessiblePlugin::create(const QString &key, QObject *object) - - Creates and returns a QAccessibleInterface implementation for the - class \a key and the object \a object. Keys are case sensitive. - - \sa keys() -*/ - -QT_END_NAMESPACE - - -#include "moc_qaccessibleplugin.h" - -#endif // QT_NO_ACCESSIBILITY diff --git a/src/gui/accessible/qaccessibleplugin.h b/src/gui/accessible/qaccessibleplugin.h deleted file mode 100644 index 5111f0708..000000000 --- a/src/gui/accessible/qaccessibleplugin.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QACCESSIBLEPLUGIN_H -#define QACCESSIBLEPLUGIN_H - -#include -#include - - -QT_BEGIN_NAMESPACE - - -#ifndef QT_NO_ACCESSIBILITY - -class QStringList; -class QAccessibleInterface; - -struct Q_GUI_EXPORT QAccessibleFactoryInterface : public QAccessible, public QFactoryInterface -{ - virtual QAccessibleInterface* create(const QString &key, QObject *object) = 0; -}; - -QT_END_NAMESPACE - -#define QAccessibleFactoryInterface_iid "Katie.QAccessibleFactoryInterface" -Q_DECLARE_INTERFACE(QAccessibleFactoryInterface, QAccessibleFactoryInterface_iid) - -QT_BEGIN_NAMESPACE - -class QAccessiblePluginPrivate; - -class Q_GUI_EXPORT QAccessiblePlugin : public QObject, public QAccessibleFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QAccessibleFactoryInterface:QFactoryInterface) -public: - explicit QAccessiblePlugin(QObject *parent = nullptr); - ~QAccessiblePlugin(); - - virtual QStringList keys() const = 0; - virtual QAccessibleInterface *create(const QString &key, QObject *object) = 0; -}; - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - - -#endif // QACCESSIBLEPLUGIN_H diff --git a/src/gui/accessible/qaccessiblewidget.cpp b/src/gui/accessible/qaccessiblewidget.cpp deleted file mode 100644 index d848c115f..000000000 --- a/src/gui/accessible/qaccessiblewidget.cpp +++ /dev/null @@ -1,971 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaccessiblewidget.h" - -#ifndef QT_NO_ACCESSIBILITY - -#include "qaction.h" -#include "qapplication.h" -#include "qgroupbox.h" -#include "qlabel.h" -#include "qtooltip.h" -#include "qwhatsthis.h" -#include "qwidget.h" -#include "qdebug.h" -#include "qmath.h" -#include -#include -#include -#include "qobject_p.h" - -QT_BEGIN_NAMESPACE - -static QList childWidgets(const QWidget *widget) -{ - QList list = widget->children(); - QList widgets; - for (int i = 0; i < list.size(); ++i) { - QWidget *w = qobject_cast(list.at(i)); - if (w && !w->isWindow() - && !qobject_cast(w) -#if !defined(QT_NO_MENU) - && !qobject_cast(w) -#endif - && w->objectName() != QLatin1String("qt_rubberband")) - widgets.append(w); - } - return widgets; -} - -static QString buddyString(const QWidget *widget) -{ - if (!widget) - return QString(); - QWidget *parent = widget->parentWidget(); - if (!parent) - return QString(); -#ifndef QT_NO_SHORTCUT - QObjectList ol = parent->children(); - for (int i = 0; i < ol.size(); ++i) { - QLabel *label = qobject_cast(ol.at(i)); - if (label && label->buddy() == widget) - return label->text(); - } -#endif - -#ifndef QT_NO_GROUPBOX - QGroupBox *groupbox = qobject_cast(parent); - if (groupbox) - return groupbox->title(); -#endif - - return QString(); -} - -/* This function will return the offset of the '&' in the text that would be - preceding the accelerator character. - If this text does not have an accelerator, -1 will be returned. */ -static int qt_accAmpIndex(const QString &text) -{ -#ifndef QT_NO_SHORTCUT - if (text.isEmpty()) - return -1; - - int fa = 0; - while ((fa = text.indexOf(QLatin1Char('&'), fa)) != -1) { - ++fa; - if (fa < text.length()) { - // ignore "&&" - if (text.at(fa) == QLatin1Char('&')) { - ++fa; - continue; - } - return fa - 1; - } - } - - return -1; -#else - Q_UNUSED(text); - return -1; -#endif -} - -QString Q_GUI_EXPORT qt_accStripAmp(const QString &text) -{ - QString newText(text); - int ampIndex = qt_accAmpIndex(newText); - if (ampIndex != -1) - newText.remove(ampIndex, 1); - - return newText.replace(QLatin1String("&&"), QLatin1String("&")); -} - -QString Q_GUI_EXPORT qt_accHotKey(const QString &text) -{ - int ampIndex = qt_accAmpIndex(text); - if (ampIndex != -1) - return QKeySequence(Qt::ALT).toString() + text.at(ampIndex + 1); - - return QString(); -} - -class QAccessibleWidgetPrivate : public QAccessible -{ -public: - QAccessibleWidgetPrivate() - :role(Client) - {} - - Role role; - QString name; - QString description; - QString value; - QString help; - QString accelerator; - QStringList primarySignals; - const QAccessibleInterface *asking; -}; - -/*! - \class QAccessibleWidget - \brief The QAccessibleWidget class implements the QAccessibleInterface for QWidgets. - - \ingroup accessibility - - This class is convenient to use as a base class for custom - implementations of QAccessibleInterfaces that provide information - about widget objects. - - The class provides functions to retrieve the parentObject() (the - widget's parent widget), and the associated widget(). Controlling - signals can be added with addControllingSignal(), and setters are - provided for various aspects of the interface implementation, for - example setValue(), setDescription(), setAccelerator(), and - setHelp(). - - \sa QAccessible, QAccessibleObject -*/ - -/*! - Creates a QAccessibleWidget object for widget \a w. - \a role and \a name are optional parameters that set the object's - role and name properties. -*/ -QAccessibleWidget::QAccessibleWidget(QWidget *w, Role role, const QString &name) -: QAccessibleObject(w) -{ - Q_ASSERT(widget()); - d = new QAccessibleWidgetPrivate(); - d->role = role; - d->name = name; - d->asking = 0; -} - -/*! - Destroys this object. -*/ -QAccessibleWidget::~QAccessibleWidget() -{ - delete d; -} - -/*! - Returns the associated widget. -*/ -QWidget *QAccessibleWidget::widget() const -{ - return qobject_cast(object()); -} - -/*! - Returns the associated widget's parent object, which is either the - parent widget, or qApp for top-level widgets. -*/ -QObject *QAccessibleWidget::parentObject() const -{ - QObject *parent = object()->parent(); - if (!parent) - parent = qApp; - return parent; -} - -/*! \reimp */ -int QAccessibleWidget::childAt(int x, int y) const -{ - QWidget *w = widget(); - if (!w->isVisible()) - return -1; - QPoint gp = w->mapToGlobal(QPoint(0, 0)); - if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y)) - return -1; - - QWidgetList list = childWidgets(w); - int ccount = childCount(); - - // a complex child - if (list.size() < ccount) { - for (int i = 1; i <= ccount; ++i) { - if (rect(i).contains(x, y)) - return i; - } - return 0; - } - - QPoint rp = w->mapFromGlobal(QPoint(x, y)); - for (int i = 0; iisWindow() && !child->isHidden() && child->geometry().contains(rp)) { - return i + 1; - } - } - return 0; -} - -/*! \reimp */ -QRect QAccessibleWidget::rect(int child) const -{ - if (child) { - qWarning("QAccessibleWidget::rect: This implementation does not support subelements! " - "(ID %d unknown for %s)", child, widget()->metaObject()->className()); - } - - QWidget *w = widget(); - if (!w->isVisible()) - return QRect(); - QPoint wpos = w->mapToGlobal(QPoint(0, 0)); - - return QRect(wpos.x(), wpos.y(), w->width(), w->height()); -} - -class QACConnectionObject : public QObject -{ - Q_DECLARE_PRIVATE(QObject) -public: - inline bool isSender(const QObject *receiver, const char *signal) const - { return d_func()->isSender(receiver, signal); } - inline QObjectList receiverList(const char *signal) const - { return d_func()->receiverList(signal); } - inline QObjectList senderList() const - { return d_func()->senderList(); } -}; - -/*! - Registers \a signal as a controlling signal. - - An object is a Controller to any other object connected to a - controlling signal. -*/ -void QAccessibleWidget::addControllingSignal(const QString &signal) -{ - QByteArray s = QMetaObject::normalizedSignature(signal.toAscii()); - if (object()->metaObject()->indexOfSignal(s) < 0) - qWarning("Signal %s unknown in %s", s.constData(), object()->metaObject()->className()); - d->primarySignals << QLatin1String(s); -} - -/*! - Sets the value of this interface implementation to \a value. - - The default implementation of text() returns the set value for - the Value text. - - Note that the object wrapped by this interface is not modified. -*/ -void QAccessibleWidget::setValue(const QString &value) -{ - d->value = value; -} - -/*! - Sets the description of this interface implementation to \a desc. - - The default implementation of text() returns the set value for - the Description text. - - Note that the object wrapped by this interface is not modified. -*/ -void QAccessibleWidget::setDescription(const QString &desc) -{ - d->description = desc; -} - -/*! - Sets the help of this interface implementation to \a help. - - The default implementation of text() returns the set value for - the Help text. - - Note that the object wrapped by this interface is not modified. -*/ -void QAccessibleWidget::setHelp(const QString &help) -{ - d->help = help; -} - -/*! - Sets the accelerator of this interface implementation to \a accel. - - The default implementation of text() returns the set value for - the Accelerator text. - - Note that the object wrapped by this interface is not modified. -*/ -void QAccessibleWidget::setAccelerator(const QString &accel) -{ - d->accelerator = accel; -} - -static inline bool isAncestor(const QObject *obj, const QObject *child) -{ - while (child) { - if (child == obj) - return true; - child = child->parent(); - } - return false; -} - - -/*! \reimp */ -QAccessible::Relation QAccessibleWidget::relationTo(int child, - const QAccessibleInterface *other, int otherChild) const -{ - Relation relation = Unrelated; - if (d->asking == this) // recursive call - return relation; - - QObject *o = other ? other->object() : 0; - if (!o) - return relation; - - QWidget *focus = widget()->focusWidget(); - if (object() == focus && isAncestor(o, focus)) - relation |= FocusChild; - - QACConnectionObject *connectionObject = (QACConnectionObject*)object(); - for (int sig = 0; sig < d->primarySignals.count(); ++sig) { - if (connectionObject->isSender(o, d->primarySignals.at(sig).toAscii())) { - relation |= Controller; - break; - } - } - // test for passive relationships. - // d->asking protects from endless recursion. - d->asking = this; - int inverse = other->relationTo(otherChild, this, child); - d->asking = 0; - - if (inverse & Controller) - relation |= Controlled; - if (inverse & Label) - relation |= Labelled; - - if(o == object()) { - if (child && !otherChild) - return relation | Child; - if (!child && otherChild) - return relation | Ancestor; - if (!child && !otherChild) - return relation | Self; - } - - QObject *parent = object()->parent(); - if (o == parent) - return relation | Child; - - if (o->parent() == parent) { - relation |= Sibling; - QAccessibleInterface *sibIface = QAccessible::queryAccessibleInterface(o); - Q_ASSERT(sibIface); - QRect wg = rect(0); - QRect sg = sibIface->rect(0); - if (wg.intersects(sg)) { - QAccessibleInterface *pIface = 0; - sibIface->navigate(Ancestor, 1, &pIface); - if (pIface && !((sibIface->state(0) | state(0)) & Invisible)) { - int wi = pIface->indexOfChild(this); - int si = pIface->indexOfChild(sibIface); - - if (wi > si) - relation |= QAccessible::Covers; - else - relation |= QAccessible::Covered; - } - delete pIface; - } else { - QPoint wc = wg.center(); - QPoint sc = sg.center(); - if (wc.x() < sc.x()) - relation |= QAccessible::Left; - else if(wc.x() > sc.x()) - relation |= QAccessible::Right; - if (wc.y() < sc.y()) - relation |= QAccessible::Up; - else if (wc.y() > sc.y()) - relation |= QAccessible::Down; - } - delete sibIface; - - return relation; - } - - if (isAncestor(o, object())) - return relation | Descendent; - if (isAncestor(object(), o)) - return relation | Ancestor; - - return relation; -} - -/*! \reimp */ -int QAccessibleWidget::navigate(RelationFlag relation, int entry, - QAccessibleInterface **target) const -{ - if (!target) - return -1; - - *target = 0; - QObject *targetObject = 0; - - QWidgetList childList = childWidgets(widget()); - bool complexWidget = childList.size() < childCount(); - - switch (relation) { - // Hierarchical - case Self: - targetObject = object(); - break; - case Child: - if (complexWidget) { - if (entry > 0 && entry <= childCount()) - return entry; - return -1; - }else { - if (entry > 0 && childList.size() >= entry) - targetObject = childList.at(entry - 1); - } - break; - case Ancestor: - { - if (entry <= 0) - return -1; - targetObject = widget()->parentWidget(); - int i; - for (i = entry; i > 1 && targetObject; --i) - targetObject = targetObject->parent(); - if (!targetObject && i == 1) - targetObject = qApp; - } - break; - case Sibling: - { - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(parentObject()); - if (!iface) - return -1; - - iface->navigate(Child, entry, target); - delete iface; - if (*target) - return 0; - } - break; - - // Geometrical - case QAccessible::Left: - if (complexWidget && entry) { - if (entry < 2 || widget()->height() > widget()->width() + 20) // looks vertical - return -1; - return entry - 1; - } - // fall through - case QAccessible::Right: - if (complexWidget && entry) { - if (entry >= childCount() || widget()->height() > widget()->width() + 20) // looks vertical - return -1; - return entry + 1; - } - // fall through - case QAccessible::Up: - if (complexWidget && entry) { - if (entry < 2 || widget()->width() > widget()->height() + 20) // looks horizontal - return - 1; - return entry - 1; - } - // fall through - case QAccessible::Down: - if (complexWidget && entry) { - if (entry >= childCount() || widget()->width() > widget()->height() + 20) // looks horizontal - return - 1; - return entry + 1; - } else { - QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject()); - if (!pIface) - return -1; - - QRect startg = rect(0); - QPoint startc = startg.center(); - QAccessibleInterface *candidate = 0; - int mindist = 100000; - int sibCount = pIface->childCount(); - for (int i = 0; i < sibCount; ++i) { - QAccessibleInterface *sibling = 0; - pIface->navigate(Child, i+1, &sibling); - Q_ASSERT(sibling); - if ((relationTo(0, sibling, 0) & Self) || (sibling->state(0) & QAccessible::Invisible)) { - //ignore ourself and invisible siblings - delete sibling; - continue; - } - - QRect sibg = sibling->rect(0); - QPoint sibc = sibg.center(); - QPoint sibp; - QPoint startp; - QPoint distp; - switch (relation) { - case QAccessible::Left: - startp = QPoint(startg.left(), startg.top() + startg.height() / 2); - sibp = QPoint(sibg.right(), sibg.top() + sibg.height() / 2); - if (QPoint(sibc - startc).x() >= 0) { - delete sibling; - continue; - } - distp = sibp - startp; - break; - case QAccessible::Right: - startp = QPoint(startg.right(), startg.top() + startg.height() / 2); - sibp = QPoint(sibg.left(), sibg.top() + sibg.height() / 2); - if (QPoint(sibc - startc).x() <= 0) { - delete sibling; - continue; - } - distp = sibp - startp; - break; - case QAccessible::Up: - startp = QPoint(startg.left() + startg.width() / 2, startg.top()); - sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.bottom()); - if (QPoint(sibc - startc).y() >= 0) { - delete sibling; - continue; - } - distp = sibp - startp; - break; - case QAccessible::Down: - startp = QPoint(startg.left() + startg.width() / 2, startg.bottom()); - sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.top()); - if (QPoint(sibc - startc).y() <= 0) { - delete sibling; - continue; - } - distp = sibp - startp; - break; - default: - break; - } - - int dist = (int)qSqrt((qreal)distp.x() * distp.x() + distp.y() * distp.y()); - if (dist < mindist) { - delete candidate; - candidate = sibling; - mindist = dist; - } else { - delete sibling; - } - } - delete pIface; - *target = candidate; - if (*target) - return 0; - } - break; - case Covers: - if (entry > 0) { - QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject()); - if (!pIface) - return -1; - - QRect r = rect(0); - int sibCount = pIface->childCount(); - QAccessibleInterface *sibling = 0; - for (int i = pIface->indexOfChild(this) + 1; i <= sibCount && entry; ++i) { - pIface->navigate(Child, i, &sibling); - if (!sibling || (sibling->state(0) & Invisible)) { - delete sibling; - sibling = 0; - continue; - } - if (sibling->rect(0).intersects(r)) - --entry; - if (!entry) - break; - delete sibling; - sibling = 0; - } - delete pIface; - *target = sibling; - if (*target) - return 0; - } - break; - case Covered: - if (entry > 0) { - QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject()); - if (!pIface) - return -1; - - QRect r = rect(0); - int index = pIface->indexOfChild(this); - QAccessibleInterface *sibling = 0; - for (int i = 1; i < index && entry; ++i) { - pIface->navigate(Child, i, &sibling); - Q_ASSERT(sibling); - if (!sibling || (sibling->state(0) & Invisible)) { - delete sibling; - sibling = 0; - continue; - } - if (sibling->rect(0).intersects(r)) - --entry; - if (!entry) - break; - delete sibling; - sibling = 0; - } - delete pIface; - *target = sibling; - if (*target) - return 0; - } - break; - - // Logical - case FocusChild: - { - if (widget()->hasFocus()) { - targetObject = object(); - break; - } - - QWidget *fw = widget()->focusWidget(); - if (!fw) - return -1; - - if (isAncestor(widget(), fw) || fw == widget()) - targetObject = fw; - /* ### - QWidget *parent = fw; - while (parent && !targetObject) { - parent = parent->parentWidget(); - if (parent == widget()) - targetObject = fw; - } - */ - } - break; - case Label: - if (entry > 0) { - QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject()); - if (!pIface) - return -1; - - // first check for all siblings that are labels to us - // ideally we would go through all objects and check, but that - // will be too expensive - int sibCount = pIface->childCount(); - QAccessibleInterface *candidate = 0; - for (int i = 0; i < sibCount && entry; ++i) { - const int childId = pIface->navigate(Child, i+1, &candidate); - Q_ASSERT(childId >= 0); - if (childId > 0) - candidate = pIface; - if (candidate->relationTo(childId, this, 0) & Label) - --entry; - if (!entry) - break; - if (candidate != pIface) - delete candidate; - candidate = 0; - } - if (!candidate) { - if (pIface->relationTo(0, this, 0) & Label) - --entry; - if (!entry) - candidate = pIface; - } - if (pIface != candidate) - delete pIface; - - *target = candidate; - if (*target) - return 0; - } - break; - case Labelled: // only implemented in subclasses - break; - case Controller: - if (entry > 0) { - // check all senders we are connected to, - // and figure out which one are controllers to us - QACConnectionObject *connectionObject = (QACConnectionObject*)object(); - QObjectList allSenders = connectionObject->senderList(); - QObjectList senders; - for (int s = 0; s < allSenders.size(); ++s) { - QObject *sender = allSenders.at(s); - QAccessibleInterface *candidate = QAccessible::queryAccessibleInterface(sender); - if (!candidate) - continue; - if (candidate->relationTo(0, this, 0)&Controller) - senders << sender; - delete candidate; - } - if (entry <= senders.size()) - targetObject = senders.at(entry-1); - } - break; - case Controlled: - if (entry > 0) { - QObjectList allReceivers; - QACConnectionObject *connectionObject = (QACConnectionObject*)object(); - for (int sig = 0; sig < d->primarySignals.count(); ++sig) { - QObjectList receivers = connectionObject->receiverList(d->primarySignals.at(sig).toAscii()); - allReceivers += receivers; - } - if (entry <= allReceivers.size()) - targetObject = allReceivers.at(entry-1); - } - break; - default: - break; - } - - *target = QAccessible::queryAccessibleInterface(targetObject); - return *target ? 0 : -1; -} - -/*! \reimp */ -int QAccessibleWidget::childCount() const -{ - QWidgetList cl = childWidgets(widget()); - return cl.size(); -} - -/*! \reimp */ -int QAccessibleWidget::indexOfChild(const QAccessibleInterface *child) const -{ - QWidgetList cl = childWidgets(widget()); - int index = cl.indexOf(qobject_cast(child->object())); - if (index != -1) - ++index; - return index; -} - -// from qwidget.cpp -extern QString qt_setWindowTitle_helperHelper(const QString &, const QWidget*); - -/*! \reimp */ -QString QAccessibleWidget::text(Text t, int child) const -{ - QString str; - - switch (t) { - case Name: - if (!d->name.isEmpty()) { - str = d->name; - } else if (!widget()->accessibleName().isEmpty()) { - str = widget()->accessibleName(); - } else if (!child && widget()->isWindow()) { - if (widget()->isMinimized()) - str = qt_setWindowTitle_helperHelper(widget()->windowIconText(), widget()); - else - str = qt_setWindowTitle_helperHelper(widget()->windowTitle(), widget()); - } else { - str = qt_accStripAmp(buddyString(widget())); - } - break; - case Description: - if (!d->description.isEmpty()) - str = d->description; - else if (!widget()->accessibleDescription().isEmpty()) - str = widget()->accessibleDescription(); -#ifndef QT_NO_TOOLTIP - else - str = widget()->toolTip(); -#endif - break; - case Help: - if (!d->help.isEmpty()) - str = d->help; -#ifndef QT_NO_WHATSTHIS - else - str = widget()->whatsThis(); -#endif - break; - case Accelerator: - if (!d->accelerator.isEmpty()) - str = d->accelerator; - else - str = qt_accHotKey(buddyString(widget())); - break; - case Value: - str = d->value; - break; - default: - break; - } - return str; -} - -#ifndef QT_NO_ACTION - -/*! \reimp */ -int QAccessibleWidget::userActionCount(int child) const -{ - if (child) - return 0; - return widget()->actions().count(); -} - -/*! \reimp */ -QString QAccessibleWidget::actionText(int action, Text t, int child) const -{ - if (action == DefaultAction) - action = SetFocus; - - if (action > 0 && !child) { - QAction *act = widget()->actions().value(action - 1); - if (act) { - switch (t) { - case Name: - return act->text(); - case Description: - return act->toolTip(); -#ifndef QT_NO_SHORTCUT - case Accelerator: - return act->shortcut().toString(); -#endif - default: - break; - } - } - } - - return QAccessibleObject::actionText(action, t, child); -} - -/*! \reimp */ -bool QAccessibleWidget::doAction(int action, int child, const QVariantList ¶ms) -{ - if (action == SetFocus || action == DefaultAction) { - if (child || !widget()->isEnabled()) - return false; - - if ((widget()->focusPolicy() == Qt::NoFocus) && (!widget()->isWindow())) - return false; - - if (!widget()->isWindow()) - widget()->setFocus(); - - widget()->activateWindow(); - - return true; - } else if (action > 0) { - if (QAction *act = widget()->actions().value(action - 1)) { - act->trigger(); - return true; - } - } - return QAccessibleObject::doAction(action, child, params); -} - -#endif // QT_NO_ACTION - -/*! \reimp */ -QAccessible::Role QAccessibleWidget::role(int child) const -{ - if (!child) - return d->role; - - QWidgetList childList = childWidgets(widget()); - if (childList.count() > 0 && child <= childList.count()) { - QWidget *targetWidget = childList.at(child - 1); - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(targetWidget); - if (iface) { - QAccessible::Role role = iface->role(0); - delete iface; - return role; - } - } - - return NoRole; -} - -/*! \reimp */ -QAccessible::State QAccessibleWidget::state(int child) const -{ - if (child) - return Normal; - - QAccessible::State state = Normal; - - QWidget *w = widget(); - if (w->testAttribute(Qt::WA_WState_Visible) == false) - state |= Invisible; - if (w->focusPolicy() != Qt::NoFocus) - state |= Focusable; - if (w->hasFocus()) - state |= Focused; - if (!w->isEnabled()) - state |= Unavailable; - if (w->isWindow()) { - if (w->windowFlags() & Qt::WindowSystemMenuHint) - state |= Movable; - if (w->minimumSize() != w->maximumSize()) - state |= Sizeable; - } - - return state; -} - -QVariant QAccessibleWidget::invokeMethod(Method method, int child, const QVariantList & /*params*/) -{ - if (child) - return QVariant(); - - switch (method) { - case ListSupportedMethods: { - QSet set; - set << ListSupportedMethods << ForegroundColor << BackgroundColor; - return QVariant::fromValue(set); - } - case ForegroundColor: - return widget()->palette().color(widget()->foregroundRole()); - case BackgroundColor: - return widget()->palette().color(widget()->backgroundRole()); - default: - return QVariant(); - } -} - -QT_END_NAMESPACE - -#endif //QT_NO_ACCESSIBILITY diff --git a/src/gui/accessible/qaccessiblewidget.h b/src/gui/accessible/qaccessiblewidget.h deleted file mode 100644 index 96921734b..000000000 --- a/src/gui/accessible/qaccessiblewidget.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QACCESSIBLEWIDGET_H -#define QACCESSIBLEWIDGET_H - -#include - - -QT_BEGIN_NAMESPACE - - -#ifndef QT_NO_ACCESSIBILITY - -class QAccessibleWidgetPrivate; - -class Q_GUI_EXPORT QAccessibleWidget : public QAccessibleObject -{ -public: - explicit QAccessibleWidget(QWidget *o, Role r = Client, const QString& name = QString()); - - int childCount() const; - int indexOfChild(const QAccessibleInterface *child) const; - Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const; - - int childAt(int x, int y) const; - QRect rect(int child) const; - int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const; - - QString text(Text t, int child) const; - Role role(int child) const; - State state(int child) const; - -#ifndef QT_NO_ACTION - int userActionCount(int child) const; - QString actionText(int action, Text t, int child) const; - bool doAction(int action, int child, const QVariantList ¶ms); -#endif - - QVariant invokeMethod(Method method, int child, const QVariantList ¶ms); - -protected: - ~QAccessibleWidget(); - QWidget *widget() const; - QObject *parentObject() const; - - void addControllingSignal(const QString &signal); - void setValue(const QString &value); - void setDescription(const QString &desc); - void setHelp(const QString &help); - void setAccelerator(const QString &accel); - -private: - QAccessibleWidgetPrivate *d; - Q_DISABLE_COPY(QAccessibleWidget) -}; -typedef QAccessibleWidget QAccessibleWidgetEx; - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - - -#endif // QACCESSIBLEWIDGET_H diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp index e79ae9356..d853e1f30 100644 --- a/src/gui/dialogs/qdialog.cpp +++ b/src/gui/dialogs/qdialog.cpp @@ -31,10 +31,6 @@ #include "qcursor.h" #include "qdialog_p.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif - #if defined(Q_WS_X11) # include "qt_x11_p.h" #endif @@ -608,19 +604,10 @@ void QDialog::setVisible(bool visible) QApplication::sendEvent(fw, &e); } -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::DialogStart); -#endif - } else { if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden)) return; -#ifndef QT_NO_ACCESSIBILITY - if (isVisible()) - QAccessible::updateAccessibility(this, 0, QAccessible::DialogEnd); -#endif - // Reimplemented to exit a modal event loop when the dialog is hidden. QWidget::setVisible(visible); if (d->eventLoop) diff --git a/src/gui/dialogs/qfiledialog.ui b/src/gui/dialogs/qfiledialog.ui index 2ba5f3e8a..8e8ef5cd0 100644 --- a/src/gui/dialogs/qfiledialog.ui +++ b/src/gui/dialogs/qfiledialog.ui @@ -63,12 +63,6 @@ Back - - Back - - - Go back - @@ -76,12 +70,6 @@ Forward - - Forward - - - Go forward - @@ -89,12 +77,6 @@ Parent Directory - - Parent Directory - - - Go to the parent directory - @@ -102,12 +84,6 @@ Create New Folder - - Create New Folder - - - Create a New Folder - @@ -115,12 +91,6 @@ List View - - List View - - - Change to list view mode - @@ -128,12 +98,6 @@ Detail View - - Detail View - - - Change to detail view mode - diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp index 82db4e6e4..1edd79005 100644 --- a/src/gui/dialogs/qmessagebox.cpp +++ b/src/gui/dialogs/qmessagebox.cpp @@ -33,9 +33,6 @@ #include #include #include -#ifndef QT_NO_ACCESSIBILITY -# include -#endif #include #include #include @@ -1238,9 +1235,6 @@ void QMessageBox::showEvent(QShowEvent *e) d->detectEscapeButton(); d->updateSize(); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::Alert); -#endif QDialog::showEvent(e); } diff --git a/src/gui/dialogs/qpagesetupwidget.ui b/src/gui/dialogs/qpagesetupwidget.ui index 73902a847..38870c4c8 100644 --- a/src/gui/dialogs/qpagesetupwidget.ui +++ b/src/gui/dialogs/qpagesetupwidget.ui @@ -191,9 +191,6 @@ top margin - - top margin - Qt::AlignRight|Qt::AlignVCenter @@ -222,9 +219,6 @@ left margin - - left margin - Qt::AlignRight|Qt::AlignVCenter @@ -254,9 +248,6 @@ right margin - - right margin - Qt::AlignRight|Qt::AlignVCenter @@ -285,9 +276,6 @@ bottom margin - - bottom margin - Qt::AlignRight|Qt::AlignVCenter diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 424a15b79..1b92baf4d 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -716,10 +716,6 @@ #include "qwidget_p.h" #include "qapplication_p.h" -#ifndef QT_NO_ACCESSIBILITY -# include "qaccessible.h" -#endif - #ifdef Q_WS_X11 # include "qt_x11_p.h" # include "qpixmap_x11_p.h" diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 4f55add02..77fbf4061 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -223,9 +223,6 @@ #include #include #include -#ifndef QT_NO_ACCESSIBILITY -# include -#endif #include "qapplication_p.h" #include "qobject_p.h" @@ -768,13 +765,6 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item, if (item) focusItem = item; -#ifndef QT_NO_ACCESSIBILITY - if (focusItem) { - if (QGraphicsObject *focusObj = focusItem->toGraphicsObject()) { - QAccessible::updateAccessibility(focusObj, 0, QAccessible::Focus); - } - } -#endif if (item) { QFocusEvent event(QEvent::FocusIn, focusReason); sendEvent(item, &event); diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 5dfd61c8c..f97a4cc7b 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -38,10 +38,6 @@ #include "qstyleditemdelegate.h" #include "qabstractitemview_p.h" #include "qabstractitemmodel_p.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#include "qaccessible2.h" -#endif QT_BEGIN_NAMESPACE @@ -1018,14 +1014,6 @@ void QAbstractItemView::reset() setRootIndex(QModelIndex()); if (d->selectionModel) d->selectionModel->reset(); -#ifndef QT_NO_ACCESSIBILITY -#ifdef Q_WS_X11 - if (QAccessible::isActive()) { - QAccessible::queryAccessibleInterface(this)->table2Interface()->modelReset(); - QAccessible::updateAccessibility(this, 0, QAccessible::TableModelChanged); - } -#endif -#endif } /*! @@ -3096,14 +3084,6 @@ void QAbstractItemViewPrivate::_q_rowsRemoved(const QModelIndex &index, int star if (q->isVisible()) q->updateEditorGeometries(); q->setState(QAbstractItemView::NoState); -#ifndef QT_NO_ACCESSIBILITY -#ifdef Q_WS_X11 - if (QAccessible::isActive()) { - QAccessible::queryAccessibleInterface(q)->table2Interface()->rowsRemoved(index, start, end); - QAccessible::updateAccessibility(q, 0, QAccessible::TableModelChanged); - } -#endif -#endif } /*! @@ -3176,14 +3156,6 @@ void QAbstractItemViewPrivate::_q_columnsRemoved(const QModelIndex &index, int s if (q->isVisible()) q->updateEditorGeometries(); q->setState(QAbstractItemView::NoState); -#ifndef QT_NO_ACCESSIBILITY -#ifdef Q_WS_X11 - if (QAccessible::isActive()) { - QAccessible::queryAccessibleInterface(q)->table2Interface()->columnsRemoved(index, start, end); - QAccessible::updateAccessibility(q, 0, QAccessible::TableModelChanged); - } -#endif -#endif } @@ -3197,16 +3169,6 @@ void QAbstractItemViewPrivate::_q_rowsInserted(const QModelIndex &index, int sta Q_UNUSED(index) Q_UNUSED(start) Q_UNUSED(end) - -#ifndef QT_NO_ACCESSIBILITY -#ifdef Q_WS_X11 - Q_Q(QAbstractItemView); - if (QAccessible::isActive()) { - QAccessible::queryAccessibleInterface(q)->table2Interface()->rowsInserted(index, start, end); - QAccessible::updateAccessibility(q, 0, QAccessible::TableModelChanged); - } -#endif -#endif } /*! @@ -3223,14 +3185,6 @@ void QAbstractItemViewPrivate::_q_columnsInserted(const QModelIndex &index, int Q_Q(QAbstractItemView); if (q->isVisible()) q->updateEditorGeometries(); -#ifndef QT_NO_ACCESSIBILITY -#ifdef Q_WS_X11 - if (QAccessible::isActive()) { - QAccessible::queryAccessibleInterface(q)->table2Interface()->columnsInserted(index, start, end); - QAccessible::updateAccessibility(q, 0, QAccessible::TableModelChanged); - } -#endif -#endif } /*! @@ -3250,15 +3204,6 @@ void QAbstractItemViewPrivate::_q_modelDestroyed() void QAbstractItemViewPrivate::_q_layoutChanged() { doDelayedItemsLayout(); -#ifndef QT_NO_ACCESSIBILITY -#ifdef Q_WS_X11 - Q_Q(QAbstractItemView); - if (QAccessible::isActive()) { - QAccessible::queryAccessibleInterface(q)->table2Interface()->modelReset(); - QAccessible::updateAccessibility(q, 0, QAccessible::TableModelChanged); - } -#endif -#endif } /*! diff --git a/src/gui/itemviews/qabstractitemview.h b/src/gui/itemviews/qabstractitemview.h index 3d8680356..7271d4c90 100644 --- a/src/gui/itemviews/qabstractitemview.h +++ b/src/gui/itemviews/qabstractitemview.h @@ -335,7 +335,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_headerDataChanged()) friend class QTreeViewPrivate; // needed to compile with MSVC - friend class QAccessibleItemRow; friend class QListModeViewBase; friend class QListViewPrivate; }; diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp index 707b47308..be1f8b9d4 100644 --- a/src/gui/itemviews/qitemdelegate.cpp +++ b/src/gui/itemviews/qitemdelegate.cpp @@ -218,10 +218,6 @@ QSizeF QItemDelegatePrivate::doTextLayout(int lineWidth) const \table \header \o Role \o Accepted Types - \omit - \row \o \l Qt::AccessibleDescriptionRole \o QString - \row \o \l Qt::AccessibleTextRole \o QString - \endomit \row \o \l Qt::BackgroundRole \o QBrush \row \o \l Qt::CheckStateRole \o Qt::CheckState \row \o \l Qt::DecorationRole \o QIcon, QPixmap and QColor diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index d4969ece1..5f1cdb94d 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -33,9 +33,6 @@ #include "qrubberband.h" #include "qlistview_p.h" #include "qdebug.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif QT_BEGIN_NAMESPACE @@ -3151,58 +3148,6 @@ void QIconModeViewBase::updateContentsSize() contentsSize = bounding.size(); } -/*! - \reimp -*/ -void QListView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) -{ -#ifndef QT_NO_ACCESSIBILITY - if (QAccessible::isActive()) { - if (current.isValid()) { - int entry = visualIndex(current) + 1; -#ifdef Q_WS_X11 - QAccessible::updateAccessibility(this, entry, QAccessible::Focus); -#else - QAccessible::updateAccessibility(viewport(), entry, QAccessible::Focus); -#endif - } - } -#endif - QAbstractItemView::currentChanged(current, previous); -} - -/*! - \reimp -*/ -void QListView::selectionChanged(const QItemSelection &selected, - const QItemSelection &deselected) -{ -#ifndef QT_NO_ACCESSIBILITY - if (QAccessible::isActive()) { - // ### does not work properly for selection ranges. - QModelIndex sel = selected.indexes().value(0); - if (sel.isValid()) { - int entry = visualIndex(sel) + 1; -#ifdef Q_WS_X11 - QAccessible::updateAccessibility(this, entry, QAccessible::Selection); -#else - QAccessible::updateAccessibility(viewport(), entry, QAccessible::Selection); -#endif - } - QModelIndex desel = deselected.indexes().value(0); - if (desel.isValid()) { - int entry = visualIndex(desel) + 1; -#ifdef Q_WS_X11 - QAccessible::updateAccessibility(this, entry, QAccessible::SelectionRemove); -#else - QAccessible::updateAccessibility(viewport(), entry, QAccessible::SelectionRemove); -#endif - } - } -#endif - QAbstractItemView::selectionChanged(selected, deselected); -} - int QListView::visualIndex(const QModelIndex &index) const { Q_D(const QListView); diff --git a/src/gui/itemviews/qlistview.h b/src/gui/itemviews/qlistview.h index 6bcafa34f..c2d43ee1b 100644 --- a/src/gui/itemviews/qlistview.h +++ b/src/gui/itemviews/qlistview.h @@ -159,11 +159,7 @@ protected: bool isIndexHidden(const QModelIndex &index) const; - void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); - void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); - private: - friend class QAccessibleItemView; int visualIndex(const QModelIndex &index) const; Q_DECLARE_PRIVATE(QListView) diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp index 00ab400a6..e14c45b2d 100644 --- a/src/gui/itemviews/qstandarditemmodel.cpp +++ b/src/gui/itemviews/qstandarditemmodel.cpp @@ -1058,51 +1058,6 @@ Qt::ItemFlags QStandardItem::flags() const \sa checkState(), setCheckable() */ -/*! - \fn QString QStandardItem::accessibleText() const - - Returns the item's accessible text. - - The accessible text is used by assistive technologies (i.e. for users who - cannot use conventional means of interaction). - - \sa setAccessibleText(), accessibleDescription() -*/ - -/*! - \fn void QStandardItem::setAccessibleText(const QString &accessibleText) - - Sets the item's accessible text to the string specified by \a accessibleText. - - The accessible text is used by assistive technologies (i.e. for users who - cannot use conventional means of interaction). - - \sa accessibleText(), setAccessibleDescription() -*/ - -/*! - \fn QString QStandardItem::accessibleDescription() const - - Returns the item's accessible description. - - The accessible description is used by assistive technologies (i.e. for - users who cannot use conventional means of interaction). - - \sa setAccessibleDescription(), accessibleText() -*/ - -/*! - \fn void QStandardItem::setAccessibleDescription(const QString &accessibleDescription) - - Sets the item's accessible description to the string specified by \a - accessibleDescription. - - The accessible description is used by assistive technologies (i.e. for - users who cannot use conventional means of interaction). - - \sa accessibleDescription(), setAccessibleText() -*/ - /*! Sets whether the item is enabled. If \a enabled is true, the item is enabled, meaning that the user can interact with the item; if \a enabled is false, the diff --git a/src/gui/itemviews/qstandarditemmodel.h b/src/gui/itemviews/qstandarditemmodel.h index 1f18f4755..55b96f34b 100644 --- a/src/gui/itemviews/qstandarditemmodel.h +++ b/src/gui/itemviews/qstandarditemmodel.h @@ -114,16 +114,6 @@ public: } inline void setCheckState(Qt::CheckState checkState); - inline QString accessibleText() const { - return qvariant_cast(data(Qt::AccessibleTextRole)); - } - inline void setAccessibleText(const QString &accessibleText); - - inline QString accessibleDescription() const { - return qvariant_cast(data(Qt::AccessibleDescriptionRole)); - } - inline void setAccessibleDescription(const QString &accessibleDescription); - Qt::ItemFlags flags() const; void setFlags(Qt::ItemFlags flags); @@ -267,12 +257,6 @@ inline void QStandardItem::setForeground(const QBrush &abrush) inline void QStandardItem::setCheckState(Qt::CheckState acheckState) { setData(acheckState, Qt::CheckStateRole); } -inline void QStandardItem::setAccessibleText(const QString &aaccessibleText) -{ setData(aaccessibleText, Qt::AccessibleTextRole); } - -inline void QStandardItem::setAccessibleDescription(const QString &aaccessibleDescription) -{ setData(aaccessibleDescription, Qt::AccessibleDescriptionRole); } - inline void QStandardItem::setChild(int arow, QStandardItem *aitem) { setChild(arow, 0, aitem); } diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp index a5b057d6c..5af3eb783 100644 --- a/src/gui/itemviews/qstyleditemdelegate.cpp +++ b/src/gui/itemviews/qstyleditemdelegate.cpp @@ -113,10 +113,6 @@ public: \table \header \o Role \o Accepted Types - \omit - \row \o \l Qt::AccessibleDescriptionRole \o QString - \row \o \l Qt::AccessibleTextRole \o QString - \endomit \row \o \l Qt::BackgroundRole \o QBrush \row \o \l Qt::CheckStateRole \o Qt::CheckState \row \o \l Qt::DecorationRole \o QIcon, QPixmap, QImage and QColor diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index 7d8ce1803..3b82805f1 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -33,9 +33,6 @@ #include "qscrollbar.h" #include "qabstractbutton.h" #include "qtableview_p.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif QT_BEGIN_NAMESPACE @@ -3075,70 +3072,6 @@ void QTableViewPrivate::selectColumn(int column, bool anchor) } } -/*! - \reimp - */ -void QTableView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) -{ -#ifndef QT_NO_ACCESSIBILITY - if (QAccessible::isActive()) { - if (current.isValid()) { -#ifdef Q_WS_X11 - Q_D(QTableView); - int entry = d->accessibleTable2Index(current); - QAccessible::updateAccessibility(this, entry, QAccessible::Focus); -#else - int entry = visualIndex(current) + 1; - if (horizontalHeader()) - ++entry; - QAccessible::updateAccessibility(viewport(), entry, QAccessible::Focus); -#endif - } - } -#endif - QAbstractItemView::currentChanged(current, previous); -} - -/*! - \reimp - */ -void QTableView::selectionChanged(const QItemSelection &selected, - const QItemSelection &deselected) -{ -#ifndef QT_NO_ACCESSIBILITY - Q_D(QTableView); - Q_UNUSED(d) - if (QAccessible::isActive()) { - // ### does not work properly for selection ranges. - QModelIndex sel = selected.indexes().value(0); - if (sel.isValid()) { -#ifdef Q_WS_X11 - int entry = d->accessibleTable2Index(sel); - QAccessible::updateAccessibility(this, entry, QAccessible::Selection); -#else - int entry = visualIndex(sel); - if (horizontalHeader()) - ++entry; - QAccessible::updateAccessibility(viewport(), entry, QAccessible::Selection); -#endif - } - QModelIndex desel = deselected.indexes().value(0); - if (desel.isValid()) { -#ifdef Q_WS_X11 - int entry = d->accessibleTable2Index(desel); - QAccessible::updateAccessibility(this, entry, QAccessible::SelectionRemove); -#else - int entry = visualIndex(sel); - if (horizontalHeader()) - ++entry; - QAccessible::updateAccessibility(viewport(), entry, QAccessible::SelectionRemove); -#endif - } - } -#endif - QAbstractItemView::selectionChanged(selected, deselected); -} - int QTableView::visualIndex(const QModelIndex &index) const { return index.row(); diff --git a/src/gui/itemviews/qtableview.h b/src/gui/itemviews/qtableview.h index 56c36049d..69f08457c 100644 --- a/src/gui/itemviews/qtableview.h +++ b/src/gui/itemviews/qtableview.h @@ -145,13 +145,7 @@ protected: bool isIndexHidden(const QModelIndex &index) const; - void selectionChanged(const QItemSelection &selected, - const QItemSelection &deselected); - void currentChanged(const QModelIndex ¤t, - const QModelIndex &previous); - private: - friend class QAccessibleItemView; int visualIndex(const QModelIndex &index) const; Q_DECLARE_PRIVATE(QTableView) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index a034ed942..28f1be6df 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -32,11 +32,6 @@ #include "qevent.h" #include "qpen.h" #include "qdebug.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#include "qaccessible2.h" -#endif - #include "qtreeview_p.h" QT_BEGIN_NAMESPACE @@ -2835,14 +2830,6 @@ void QTreeViewPrivate::insertViewItems(int pos, int count, const QTreeViewItem & for (int i = pos + count; i < viewItems.count(); i++) if (items[i].parentItem >= pos) items[i].parentItem += count; -#ifndef QT_NO_ACCESSIBILITY -#ifdef Q_WS_X11 - Q_Q(QTreeView); - if (QAccessible::isActive()) { - QAccessible::updateAccessibility(q, 0, QAccessible::TableModelChanged); - } -#endif -#endif } void QTreeViewPrivate::removeViewItems(int pos, int count) @@ -2852,14 +2839,6 @@ void QTreeViewPrivate::removeViewItems(int pos, int count) for (int i = pos; i < viewItems.count(); i++) if (items[i].parentItem >= pos) items[i].parentItem -= count; -#ifndef QT_NO_ACCESSIBILITY -#ifdef Q_WS_X11 - Q_Q(QTreeView); - if (QAccessible::isActive()) { - QAccessible::updateAccessibility(q, 0, QAccessible::TableModelChanged); - } -#endif -#endif } #if 0 @@ -3668,59 +3647,6 @@ void QTreeView::currentChanged(const QModelIndex ¤t, const QModelIndex &pr viewport()->update(currentRect); } } -#ifndef QT_NO_ACCESSIBILITY - if (QAccessible::isActive() && current.isValid()) { -#ifdef Q_WS_X11 - int entry = (visualIndex(current) + (header()?1:0))*current.model()->columnCount()+current.column() + 1; - QAccessible::updateAccessibility(this, entry, QAccessible::Focus); -#else - int entry = visualIndex(current) + 1; - if (header()) - ++entry; - QAccessible::updateAccessibility(viewport(), entry, QAccessible::Focus); -#endif - } -#endif -} - -/*! - \reimp - */ -void QTreeView::selectionChanged(const QItemSelection &selected, - const QItemSelection &deselected) -{ - QAbstractItemView::selectionChanged(selected, deselected); -#ifndef QT_NO_ACCESSIBILITY - if (QAccessible::isActive()) { - // ### does not work properly for selection ranges. - QModelIndex sel = selected.indexes().value(0); - if (sel.isValid()) { -#ifdef Q_WS_X11 - int entry = (visualIndex(sel) + (header()?1:0))*sel.model()->columnCount()+sel.column() + 1; - Q_ASSERT(entry > 0); - QAccessible::updateAccessibility(this, entry, QAccessible::Selection); -#else - int entry = visualIndex(sel) + 1; - if (header()) - ++entry; - QAccessible::updateAccessibility(viewport(), entry, QAccessible::Selection); -#endif - } - QModelIndex desel = deselected.indexes().value(0); - if (desel.isValid()) { -#ifdef Q_WS_X11 - int entry = (visualIndex(desel) + (header()?1:0))*desel.model()->columnCount()+desel.column() + 1; - Q_ASSERT(entry > 0); - QAccessible::updateAccessibility(this, entry, QAccessible::SelectionRemove); -#else - int entry = visualIndex(desel) + 1; - if (header()) - ++entry; - QAccessible::updateAccessibility(viewport(), entry, QAccessible::SelectionRemove); -#endif - } - } -#endif } int QTreeView::visualIndex(const QModelIndex &index) const diff --git a/src/gui/itemviews/qtreeview.h b/src/gui/itemviews/qtreeview.h index 39591aff5..72eeef70f 100644 --- a/src/gui/itemviews/qtreeview.h +++ b/src/gui/itemviews/qtreeview.h @@ -189,15 +189,9 @@ protected: int rowHeight(const QModelIndex &index) const; bool isIndexHidden(const QModelIndex &index) const; - void selectionChanged(const QItemSelection &selected, - const QItemSelection &deselected); void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); private: - friend class QAccessibleItemView; - friend class QAccessibleTable2; - friend class QAccessibleTree; - friend class QAccessibleTable2Cell; int visualIndex(const QModelIndex &index) const; Q_DECLARE_PRIVATE(QTreeView) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index dbd658aa3..85e476772 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -21,7 +21,6 @@ #include "qplatformdefs.h" #include "qabstracteventdispatcher.h" -#include "qaccessible.h" #include "qapplication.h" #include "qclipboard.h" #include "qcursor.h" @@ -2930,9 +2929,6 @@ void QApplication::changeOverrideCursor(const QCursor &cursor) */ int QApplication::exec() { -#ifndef QT_NO_ACCESSIBILITY - QAccessible::setRootObject(qApp); -#endif return QCoreApplication::exec(); } diff --git a/src/gui/kernel/qwhatsthis.cpp b/src/gui/kernel/qwhatsthis.cpp index 723f4c9e4..7795c69bc 100644 --- a/src/gui/kernel/qwhatsthis.cpp +++ b/src/gui/kernel/qwhatsthis.cpp @@ -36,9 +36,7 @@ #include "../text/qtextdocumentlayout_p.h" #include "qtoolbutton.h" #include "qdebug.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif + #if defined(Q_WS_X11) #include "qx11info_x11.h" #include "qwidget.h" @@ -374,9 +372,6 @@ QWhatsThisPrivate::QWhatsThisPrivate() QApplication::setOverrideCursor(Qt::WhatsThisCursor); #endif } -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::ContextHelpStart); -#endif } QWhatsThisPrivate::~QWhatsThisPrivate() @@ -385,9 +380,6 @@ QWhatsThisPrivate::~QWhatsThisPrivate() action->setChecked(false); #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); -#endif -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::ContextHelpEnd); #endif instance = 0; } diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 92e11a7b5..03d658e5e 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -58,10 +58,6 @@ #include "qabstractscrollarea_p.h" #include "qevent_p.h" -#ifndef QT_NO_ACCESSIBILITY -# include "qaccessible.h" -#endif - #if defined(Q_WS_X11) # include "qpaintengine_x11_p.h" # include "qx11info_x11.h" @@ -1165,10 +1161,6 @@ QWidget::~QWidget() if (!d->children.isEmpty()) d->deleteChildren(); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::ObjectDestroyed); -#endif - QApplication::removePostedEvents(this); destroy(); // platform-dependent cleanup @@ -5359,11 +5351,6 @@ void QWidget::setFocus(Qt::FocusReason reason) if (f->isActiveWindow()) { QApplicationPrivate::setFocusWidget(f, reason); -#ifndef QT_NO_ACCESSIBILITY - // menus update the focus manually and this would create bogus events - if (!(f->inherits("QMenuBar") || f->inherits("QMenu"))) - QAccessible::updateAccessibility(f, 0, QAccessible::Focus); -#endif #ifndef QT_NO_GRAPHICSVIEW if (QWExtra *topData = window()->d_func()->extra) { if (topData->proxyWidget) { @@ -5429,9 +5416,6 @@ void QWidget::clearFocus() if (hasFocus()) { // Update proxy state QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::Focus); -#endif } } @@ -6367,11 +6351,6 @@ void QWidgetPrivate::show_helper() if (!isEmbedded && q->windowType() == Qt::Popup) qApp->d_func()->openPopup(q); -#ifndef QT_NO_ACCESSIBILITY - if (q->windowType() != Qt::ToolTip) // Tooltips are read aloud twice in MS narrator. - QAccessible::updateAccessibility(q, 0, QAccessible::ObjectShow); -#endif - if (QApplicationPrivate::hidden_focus_widget == q) { QApplicationPrivate::hidden_focus_widget = 0; q->setFocus(Qt::OtherFocusReason); @@ -6454,11 +6433,6 @@ void QWidgetPrivate::hide_helper() if (QWidgetBackingStore *bs = maybeBackingStore()) bs->removeDirtyWidget(q); - -#ifndef QT_NO_ACCESSIBILITY - if (wasVisible) - QAccessible::updateAccessibility(q, 0, QAccessible::ObjectHide); -#endif } /*! @@ -6665,10 +6639,6 @@ void QWidgetPrivate::hideChildren(bool spontaneous) } #if defined(Q_WS_X11) qApp->d_func()->sendSyntheticEnterLeave(widget); -#endif -#ifndef QT_NO_ACCESSIBILITY - if (!spontaneous) - QAccessible::updateAccessibility(widget, 0, QAccessible::ObjectHide); #endif } } @@ -7350,29 +7320,6 @@ bool QWidget::event(QEvent *event) event->ignore(); break; #endif -#ifndef QT_NO_ACCESSIBILITY - case QEvent::AccessibilityDescription: - case QEvent::AccessibilityHelp: { - QAccessibleEvent *ev = static_cast(event); - if (ev->child()) - return false; - switch (ev->type()) { -#ifndef QT_NO_TOOLTIP - case QEvent::AccessibilityDescription: - ev->setValue(d->toolTip); - break; -#endif -#ifndef QT_NO_WHATSTHIS - case QEvent::AccessibilityHelp: - ev->setValue(d->whatsThis); - break; -#endif - default: - return false; - } - break; - } -#endif #ifndef QT_NO_ACTION case QEvent::ActionAdded: case QEvent::ActionRemoved: @@ -7435,12 +7382,10 @@ bool QWidget::event(QEvent *event) void QWidget::changeEvent(QEvent * event) { switch(event->type()) { - case QEvent::EnabledChange: + case QEvent::EnabledChange: { update(); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::StateChanged); -#endif break; + } case QEvent::FontChange: case QEvent::StyleChange: { @@ -7452,9 +7397,10 @@ void QWidget::changeEvent(QEvent * event) break; } - case QEvent::PaletteChange: + case QEvent::PaletteChange: { update(); break; + } default: break; @@ -9228,55 +9174,6 @@ QString QWidget::whatsThis() const } #endif // QT_NO_WHATSTHIS -#ifndef QT_NO_ACCESSIBILITY -/*! - \property QWidget::accessibleName - - \brief the widget's name as seen by assistive technologies - - This property is used by accessible clients to identify, find, or announce - the widget for accessible clients. - - By default, this property contains an empty string. - - \sa QAccessibleInterface::text() -*/ -void QWidget::setAccessibleName(const QString &name) -{ - Q_D(QWidget); - d->accessibleName = name; - QAccessible::updateAccessibility(this, 0, QAccessible::NameChanged); -} - -QString QWidget::accessibleName() const -{ - Q_D(const QWidget); - return d->accessibleName; -} - -/*! - \property QWidget::accessibleDescription - - \brief the widget's description as seen by assistive technologies - - By default, this property contains an empty string. - - \sa QAccessibleInterface::text() -*/ -void QWidget::setAccessibleDescription(const QString &description) -{ - Q_D(QWidget); - d->accessibleDescription = description; - QAccessible::updateAccessibility(this, 0, QAccessible::DescriptionChanged); -} - -QString QWidget::accessibleDescription() const -{ - Q_D(const QWidget); - return d->accessibleDescription; -} -#endif // QT_NO_ACCESSIBILITY - #ifndef QT_NO_SHORTCUT /*! Adds a shortcut to Qt's shortcut system that watches for the given diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 3cb57da5c..2de4a020a 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -149,10 +149,6 @@ class Q_GUI_EXPORT QWidget : public QObject, public QPaintDevice #endif #ifndef QT_NO_WHATSTHIS Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis) -#endif -#ifndef QT_NO_ACCESSIBILITY - Q_PROPERTY(QString accessibleName READ accessibleName WRITE setAccessibleName) - Q_PROPERTY(QString accessibleDescription READ accessibleDescription WRITE setAccessibleDescription) #endif Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection) Q_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags) @@ -331,12 +327,6 @@ public: void setWhatsThis(const QString &); QString whatsThis() const; #endif -#ifndef QT_NO_ACCESSIBILITY - QString accessibleName() const; - void setAccessibleName(const QString &name); - QString accessibleDescription() const; - void setAccessibleDescription(const QString &description); -#endif void setLayoutDirection(Qt::LayoutDirection direction); Qt::LayoutDirection layoutDirection() const; diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index ceab4a98a..c72918176 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -538,10 +538,6 @@ public: #ifndef QT_NO_WHATSTHIS QString whatsThis; #endif -#ifndef QT_NO_ACCESSIBILITY - QString accessibleName; - QString accessibleDescription; -#endif // Other variables. uint inheritedFontResolveMask; diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index aa0959711..bf4f238f6 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -57,7 +57,6 @@ #include "qtooltip.h" #include "qstyleoption.h" #include "qlineedit.h" -#include "qaccessible.h" #ifndef QT_NO_SHORTCUT #include "qapplication_p.h" @@ -541,10 +540,6 @@ void QTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged /*=fal Q_Q(QTextControl); if (forceEmitSelectionChanged) { emit q->selectionChanged(); -#ifndef QT_NO_ACCESSIBILITY - if (q->parent()) - QAccessible::updateAccessibility(q->parent(), 0, QAccessible::TextSelectionChanged); -#endif } bool current = cursor.hasSelection(); @@ -555,10 +550,6 @@ void QTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged /*=fal emit q->copyAvailable(current); if (!forceEmitSelectionChanged) { emit q->selectionChanged(); -#ifndef QT_NO_ACCESSIBILITY - if (q->parent()) - QAccessible::updateAccessibility(q->parent(), 0, QAccessible::TextSelectionChanged); -#endif } } diff --git a/src/gui/widgets/qabstractbutton.cpp b/src/gui/widgets/qabstractbutton.cpp index 982129f41..7beec6f40 100644 --- a/src/gui/widgets/qabstractbutton.cpp +++ b/src/gui/widgets/qabstractbutton.cpp @@ -28,9 +28,6 @@ #include "qapplication.h" #include "qstyle.h" #include "qaction.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif QT_BEGIN_NAMESPACE @@ -470,9 +467,6 @@ void QAbstractButtonPrivate::refresh() if (blockRefresh) return; q->update(); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(q, 0, QAccessible::StateChanged); -#endif } void QAbstractButtonPrivate::click() @@ -612,9 +606,6 @@ void QAbstractButton::setText(const QString &text) d->sizeHint = QSize(); update(); updateGeometry(); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::NameChanged); -#endif } QString QAbstractButton::text() const diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp index f6e8fd834..c2760a59c 100644 --- a/src/gui/widgets/qabstractslider.cpp +++ b/src/gui/widgets/qabstractslider.cpp @@ -24,9 +24,7 @@ #include "qevent.h" #include "qabstractslider_p.h" #include "qdebug.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif + #include QT_BEGIN_NAMESPACE @@ -509,9 +507,6 @@ void QAbstractSlider::setValue(int value) if (d->pressed) emit sliderMoved((d->position = value)); } -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::ValueChanged); -#endif sliderChange(SliderValueChange); emit valueChanged(value); } diff --git a/src/gui/widgets/qabstractspinbox.cpp b/src/gui/widgets/qabstractspinbox.cpp index 5534df001..59dc7fe7a 100644 --- a/src/gui/widgets/qabstractspinbox.cpp +++ b/src/gui/widgets/qabstractspinbox.cpp @@ -36,13 +36,8 @@ #include "qpalette.h" #include "qstylepainter.h" #include "qdebug.h" -#ifndef QT_NO_ACCESSIBILITY -# include "qaccessible.h" -#endif -#if defined(Q_WS_X11) #include -#endif //#define QABSTRACTSPINBOX_QSBDEBUG @@ -916,9 +911,6 @@ void QAbstractSpinBox::keyPressEvent(QKeyEvent *event) d->updateState(up, true); } } -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::ValueChanged); -#endif return; } case Qt::Key_Enter: @@ -1503,9 +1495,6 @@ void QAbstractSpinBoxPrivate::updateState(bool up, bool fromKeyboard /* = false spinClickThresholdTimerId = q->startTimer(spinClickThresholdTimerInterval); buttonState = (up ? Up : Down) | (fromKeyboard ? Keyboard : Mouse); q->stepBy(up ? 1 : -1); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(q, 0, QAccessible::ValueChanged); -#endif } } diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index a7cddf5a8..ca8a411e1 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -47,10 +47,6 @@ # include "qeffects_p.h" #endif -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif - QT_BEGIN_NAMESPACE QComboBoxPrivate::QComboBoxPrivate() @@ -897,9 +893,6 @@ void QComboBoxPrivate::_q_dataChanged(const QModelIndex &topLeft, const QModelIn } q->update(); } -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(q, 0, QAccessible::NameChanged); -#endif } void QComboBoxPrivate::_q_rowsInserted(const QModelIndex &parent, int start, int end) @@ -1151,9 +1144,6 @@ void QComboBoxPrivate::_q_emitCurrentIndexChanged(const QModelIndex &index) Q_Q(QComboBox); emit q->currentIndexChanged(index.row()); emit q->currentIndexChanged(itemText(index)); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(q, 0, QAccessible::NameChanged); -#endif } QString QComboBoxPrivate::itemText(const QModelIndex &index) const @@ -2429,9 +2419,6 @@ void QComboBox::clear() { Q_D(QComboBox); d->model->removeRows(0, d->model->rowCount(d->root), d->root); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::NameChanged); -#endif } /*! @@ -2448,9 +2435,6 @@ void QComboBox::clearEditText() Q_D(QComboBox); if (d->lineEdit) d->lineEdit->clear(); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::NameChanged); -#endif } /*! @@ -2461,9 +2445,6 @@ void QComboBox::setEditText(const QString &text) Q_D(QComboBox); if (d->lineEdit) d->lineEdit->setText(text); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::NameChanged); -#endif } /*! diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h index f260e739c..8997c71f3 100644 --- a/src/gui/widgets/qcombobox_p.h +++ b/src/gui/widgets/qcombobox_p.h @@ -221,16 +221,18 @@ private: QComboBox *mCombo; }; +static const int comboseparatorrole = (Qt::UserRole - 1); + class QComboBoxDelegate : public QStyledItemDelegate { Q_OBJECT public: QComboBoxDelegate(QObject *parent, QComboBox *cmb) : QStyledItemDelegate(parent), mCombo(cmb) {} static bool isSeparator(const QModelIndex &index) { - return index.data(Qt::AccessibleDescriptionRole).toString() == QLatin1String("separator"); + return index.data(comboseparatorrole).toInt() == 1; } static void setSeparator(QAbstractItemModel *model, const QModelIndex &index) { - model->setData(index, QString::fromLatin1("separator"), Qt::AccessibleDescriptionRole); + model->setData(index, 1, comboseparatorrole); if (QStandardItemModel *m = qobject_cast(model)) if (QStandardItem *item = m->itemFromIndex(index)) item->setFlags(item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled)); diff --git a/src/gui/widgets/qdial.cpp b/src/gui/widgets/qdial.cpp index 4316bbe66..699db6891 100644 --- a/src/gui/widgets/qdial.cpp +++ b/src/gui/widgets/qdial.cpp @@ -37,10 +37,6 @@ #include "qabstractslider_p.h" #include "qmath.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif - QT_BEGIN_NAMESPACE class QDialPrivate : public QAbstractSliderPrivate diff --git a/src/gui/widgets/qgroupbox.cpp b/src/gui/widgets/qgroupbox.cpp index 5b7f1566d..734d2be0b 100644 --- a/src/gui/widgets/qgroupbox.cpp +++ b/src/gui/widgets/qgroupbox.cpp @@ -29,11 +29,7 @@ #include "qstyle.h" #include "qstyleoption.h" #include "qstylepainter.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif #include "qwidget_p.h" - #include "qdebug.h" QT_BEGIN_NAMESPACE @@ -226,9 +222,6 @@ void QGroupBox::setTitle(const QString &title) update(); updateGeometry(); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::NameChanged); -#endif } /*! @@ -613,9 +606,6 @@ void QGroupBox::setChecked(bool b) update(); d->checked = b; d->_q_setChildrenEnabled(b); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::StateChanged); -#endif emit toggled(b); } } diff --git a/src/gui/widgets/qlabel.cpp b/src/gui/widgets/qlabel.cpp index 879be85f8..443221553 100644 --- a/src/gui/widgets/qlabel.cpp +++ b/src/gui/widgets/qlabel.cpp @@ -34,11 +34,6 @@ #include "qstylesheetstyle_p.h" #include "qmath.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif - - QT_BEGIN_NAMESPACE /*! @@ -275,11 +270,6 @@ void QLabel::setText(const QString &text) #endif d->updateLabel(); - -#ifndef QT_NO_ACCESSIBILITY - if (accessibleName().isEmpty()) - QAccessible::updateAccessibility(this, 0, QAccessible::NameChanged); -#endif } QString QLabel::text() const diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 22bb7c6cb..6bdabc606 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -25,9 +25,6 @@ #include "qabstractitemview.h" #include "qclipboard.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif #include "qapplication.h" #ifndef QT_NO_GRAPHICSVIEW #include "qgraphicssceneevent.h" @@ -562,14 +559,7 @@ void QLineControl::internalSetText(const QString &txt, int pos, bool edited) m_modifiedState = m_undoState = 0; m_cursor = (pos < 0 || pos > m_text.length()) ? m_text.length() : pos; m_textDirty = (oldText != m_text); - bool changed = finishChange(-1, true, edited); - -#ifndef QT_NO_ACCESSIBILITY - if (changed) - QAccessible::updateAccessibility(parent(), 0, QAccessible::TextUpdated); -#else - Q_UNUSED(changed); -#endif + finishChange(-1, true, edited); } @@ -1173,9 +1163,6 @@ void QLineControl::emitCursorPositionChanged() const int oldLast = m_lastCursorPos; m_lastCursorPos = m_cursor; cursorPositionChanged(oldLast, m_cursor); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(parent(), 0, QAccessible::TextCaretMoved); -#endif } } diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index a14710122..9ea0db730 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -44,8 +44,6 @@ #include "QtGui/qclipboard.h" #include "QtCore/qpoint.h" #include "QtGui/qcompleter.h" -#include "qaccessible.h" - #include "qplatformdefs.h" diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index c3edf49a6..cf107aace 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -44,9 +44,6 @@ #include "qdebug.h" #include "qtextedit.h" #include "qtextedit_p.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif #include "qabstractitemview.h" #include "qstylesheetstyle_p.h" diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h index 499a5a96f..e91c87e4f 100644 --- a/src/gui/widgets/qlineedit.h +++ b/src/gui/widgets/qlineedit.h @@ -198,7 +198,6 @@ public: private: friend class QAbstractSpinBox; - friend class QAccessibleLineEdit; Q_DISABLE_COPY(QLineEdit) Q_DECLARE_PRIVATE(QLineEdit) Q_PRIVATE_SLOT(d_func(), void _q_handleWindowActivate()) diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp index 0136b9105..adfae374c 100644 --- a/src/gui/widgets/qlineedit_p.cpp +++ b/src/gui/widgets/qlineedit_p.cpp @@ -26,9 +26,6 @@ #include "qabstractitemview.h" #include "qclipboard.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif QT_BEGIN_NAMESPACE @@ -108,9 +105,6 @@ void QLineEditPrivate::_q_selectionChanged() setCursorVisible(showCursor); emit q->selectionChanged(); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(q, 0, QAccessible::TextSelectionChanged); -#endif } void QLineEditPrivate::_q_updateNeeded(const QRect &rect) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index d05107066..ae38a6b6b 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -39,10 +39,6 @@ #include "qpushbutton_p.h" #include "qaction_p.h" -#ifndef QT_NO_ACCESSIBILITY -# include "qaccessible.h" -#endif - #ifndef QT_NO_EFFECTS # include "qeffects_p.h" #endif @@ -1017,13 +1013,6 @@ void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e if (action_e == QAction::Hover) { -#ifndef QT_NO_ACCESSIBILITY - if (QAccessible::isActive()) { - int actionIndex = indexOf(action) + 1; - QAccessible::updateAccessibility(q, actionIndex, QAccessible::Focus); - QAccessible::updateAccessibility(q, actionIndex, QAccessible::Selection); - } -#endif action->showStatusText(topCausedWidget()); } else { actionAboutToTrigger = 0; @@ -1886,10 +1875,6 @@ void QMenu::popup(const QPoint &p, QAction *atAction) { show(); } - -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::PopupMenuStart); -#endif } /*! @@ -2008,9 +1993,6 @@ void QMenu::hideEvent(QHideEvent *) if (d->eventLoop) d->eventLoop->exit(); d->setCurrentAction(0); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::PopupMenuEnd); -#endif #ifndef QT_NO_MENUBAR if (QMenuBar *mb = qobject_cast(d->causedPopup.widget)) mb->d_func()->setCurrentAction(0); diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index 60c92ec83..f16b38fe8 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -25,9 +25,6 @@ #include "qlayout.h" #include "qapplication.h" #include "qdesktopwidget.h" -#ifndef QT_NO_ACCESSIBILITY -# include "qaccessible.h" -#endif #include "qpainter.h" #include "qstylepainter.h" #include "qevent.h" @@ -495,14 +492,6 @@ void QMenuBarPrivate::_q_actionHovered() Q_Q(QMenuBar); if (QAction *action = qobject_cast(q->sender())) { emit q->hovered(action); -#ifndef QT_NO_ACCESSIBILITY - if (QAccessible::isActive()) { - int actionIndex = actions.indexOf(action); - ++actionIndex; - QAccessible::updateAccessibility(q, actionIndex, QAccessible::Focus); - QAccessible::updateAccessibility(q, actionIndex, QAccessible::Selection); - } -#endif //QT_NO_ACCESSIBILITY } } diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 759924f5a..3d278be95 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -36,7 +36,6 @@ #include "qtextdocument_p.h" #include "qtextlist.h" #include "qtextcontrol_p.h" -#include "qaccessible.h" #include "qtextformat.h" #include "qdatetime.h" #include "qapplication.h" @@ -410,10 +409,6 @@ QPlainTextEditControl::QPlainTextEditControl(QPlainTextEdit *parent) void QPlainTextEditPrivate::_q_cursorPositionChanged() { pageUpDownLastCursorYIsValid = false; -#ifndef QT_NO_ACCESSIBILITY - Q_Q(QPlainTextEdit); - QAccessible::updateAccessibility(q, 0, QAccessible::TextCaretMoved); -#endif } void QPlainTextEditPrivate::_q_verticalScrollbarActionTriggered(int action) { diff --git a/src/gui/widgets/qprogressbar.cpp b/src/gui/widgets/qprogressbar.cpp index 4a01bc5a1..6bb5855ad 100644 --- a/src/gui/widgets/qprogressbar.cpp +++ b/src/gui/widgets/qprogressbar.cpp @@ -26,9 +26,6 @@ #include "qstylepainter.h" #include "qstyleoption.h" #include "qwidget_p.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif #include @@ -291,10 +288,6 @@ void QProgressBar::setValue(int value) return; d->value = value; emit valueChanged(value); -#ifndef QT_NO_ACCESSIBILITY - if (isVisible()) - QAccessible::updateAccessibility(this, 0, QAccessible::ValueChanged); -#endif if (d->repaintRequired()) repaint(); } diff --git a/src/gui/widgets/qpushbutton.cpp b/src/gui/widgets/qpushbutton.cpp index 61a794b4b..851b16c2a 100644 --- a/src/gui/widgets/qpushbutton.cpp +++ b/src/gui/widgets/qpushbutton.cpp @@ -37,11 +37,6 @@ #include "qdebug.h" #include "qlayoutitem.h" #include "qdialogbuttonbox.h" - -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif - #include "qmenu_p.h" #include "qpushbutton_p.h" @@ -350,9 +345,6 @@ void QPushButton::setDefault(bool enable) dlg->d_func()->setMainDefault(this); } update(); -#ifndef QT_NO_ACCESSIBILITY - QAccessible::updateAccessibility(this, 0, QAccessible::StateChanged); -#endif } bool QPushButton::isDefault() const diff --git a/src/gui/widgets/qscrollbar.cpp b/src/gui/widgets/qscrollbar.cpp index 4156de8ac..3d49020a4 100644 --- a/src/gui/widgets/qscrollbar.cpp +++ b/src/gui/widgets/qscrollbar.cpp @@ -31,12 +31,10 @@ #ifndef QT_NO_SCROLLBAR -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif -#include #include "qabstractslider_p.h" +#include + QT_BEGIN_NAMESPACE /*! diff --git a/src/gui/widgets/qslider.cpp b/src/gui/widgets/qslider.cpp index 186c37dff..bf5aaa895 100644 --- a/src/gui/widgets/qslider.cpp +++ b/src/gui/widgets/qslider.cpp @@ -21,9 +21,6 @@ #include "qslider.h" #ifndef QT_NO_SLIDER -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif #include "qapplication.h" #include "qevent.h" #include "qpainter.h" diff --git a/src/gui/widgets/qstatusbar.cpp b/src/gui/widgets/qstatusbar.cpp index eba785906..fcd2ed453 100644 --- a/src/gui/widgets/qstatusbar.cpp +++ b/src/gui/widgets/qstatusbar.cpp @@ -32,11 +32,6 @@ #include "qstyleoption.h" #include "qsizegrip.h" #include "qmainwindow.h" - -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif - #include "qlayoutengine_p.h" #include "qwidget_p.h" @@ -622,11 +617,6 @@ void QStatusBar::hideOrShow() emit messageChanged(d->tempItem); -#ifndef QT_NO_ACCESSIBILITY - if (QAccessible::isActive()) - QAccessible::updateAccessibility(this, 0, QAccessible::NameChanged); -#endif - repaint(d->messageRect()); } diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index 3fd5906e2..00855ebdf 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -36,10 +36,6 @@ #include "qtabbar_p.h" #include "qguicommon_p.h" -#ifndef QT_NO_ACCESSIBILITY -#include "qaccessible.h" -#endif - #ifndef QT_NO_TABBAR QT_BEGIN_NAMESPACE @@ -1100,14 +1096,6 @@ void QTabBar::setCurrentIndex(int index) if (oldIndex >= 0 && oldIndex < count()) d->layoutTab(oldIndex); d->layoutTab(index); -#ifndef QT_NO_ACCESSIBILITY - if (QAccessible::isActive()) { - QAccessible::updateAccessibility(this, oldIndex + 1, QAccessible::Selection); - - QAccessible::updateAccessibility(this, index + 1, QAccessible::Focus); - QAccessible::updateAccessibility(this, index + 1, QAccessible::Selection); - } -#endif emit currentChanged(index); } } diff --git a/src/gui/widgets/qtabbar.h b/src/gui/widgets/qtabbar.h index d776addde..0cbf44fbc 100644 --- a/src/gui/widgets/qtabbar.h +++ b/src/gui/widgets/qtabbar.h @@ -183,8 +183,6 @@ protected: void changeEvent(QEvent *); void initStyleOption(QStyleOptionTab *option, int tabIndex) const; - - friend class QAccessibleTabBar; private: Q_DISABLE_COPY(QTabBar) Q_DECLARE_PRIVATE(QTabBar) diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index c037806fa..6034a89c2 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -13,13 +13,6 @@ include_directories( # place the plugins in a sub-directory the leading of which can be used as plugin path, # this makes testing without installation possible and is relied upon in the exec script -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/accessible") -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/accessible") -if(WITH_ACCESSIBILITY) - add_subdirectory(accessible/widgets) -endif() - - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/iconengines") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/iconengines") add_subdirectory(iconengines/svgiconengine) diff --git a/src/plugins/accessible/widgets/CMakeLists.txt b/src/plugins/accessible/widgets/CMakeLists.txt deleted file mode 100644 index 4453d2f87..000000000 --- a/src/plugins/accessible/widgets/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -set(ACCESSIBLEWIDGETSPLUGIN_HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/qaccessiblewidgets.h - ${CMAKE_CURRENT_SOURCE_DIR}/simplewidgets.h - ${CMAKE_CURRENT_SOURCE_DIR}/rangecontrols.h - ${CMAKE_CURRENT_SOURCE_DIR}/complexwidgets.h - ${CMAKE_CURRENT_SOURCE_DIR}/qaccessiblemenu.h - ${CMAKE_CURRENT_SOURCE_DIR}/itemviews.h -) - -set(ACCESSIBLEWIDGETSPLUGIN_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/simplewidgets.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rangecontrols.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/complexwidgets.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/qaccessiblewidgets.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/qaccessiblemenu.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/itemviews.cpp -) - -katie_setup_target(qtaccessiblewidgetsplugin ${ACCESSIBLEWIDGETSPLUGIN_SOURCES} ${ACCESSIBLEWIDGETSPLUGIN_HEADERS}) - -add_library(qtaccessiblewidgetsplugin MODULE ${qtaccessiblewidgetsplugin_SOURCES}) -target_link_libraries(qtaccessiblewidgetsplugin KtCore KtGui) -set_target_properties(qtaccessiblewidgetsplugin PROPERTIES OUTPUT_NAME qtaccessiblewidgets) - -katie_setup_plugin(qtaccessiblewidgetsplugin) - -install( - TARGETS qtaccessiblewidgetsplugin - DESTINATION ${KATIE_PLUGINS_PATH}/accessible - COMPONENT Runtime -) diff --git a/src/plugins/accessible/widgets/complexwidgets.cpp b/src/plugins/accessible/widgets/complexwidgets.cpp deleted file mode 100644 index c2975b111..000000000 --- a/src/plugins/accessible/widgets/complexwidgets.cpp +++ /dev/null @@ -1,2210 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the plugins of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "complexwidgets.h" - -#include "qapplication.h" -#include "qabstractbutton.h" -#include "qevent.h" -#include "qheaderview.h" -#include "qtabbar.h" -#include "qcombobox.h" -#include "qlistview.h" -#include "qtableview.h" -#include "qlineedit.h" -#include "qstyle.h" -#include "qstyleoption.h" -#include "qtooltip.h" -#include "qwhatsthis.h" -#include "qtreeview.h" -#include "qtabbar_p.h" -#include -#include -#include -#include - -#ifndef QT_NO_ACCESSIBILITY - -QT_BEGIN_NAMESPACE - -QString Q_GUI_EXPORT qt_accStripAmp(const QString &text); - -#ifndef QT_NO_ITEMVIEWS -/* -The MSDN article "Exposing Data Tables through Microsoft Active Accessibility" explains -how data tables should be exposed. Url: http://msdn2.microsoft.com/en-us/library/ms971325.aspx -Basically, the model is like this: - -ROLE_SYSTEM_TABLE - |- ROLE_SYSTEM_ROW - | |- ROLE_SYSTEM_ROWHEADER - | |- ROLE_SYSTEM_COLUMNHEADER - | |- ROLE_SYSTEM_COLUMNHEADER - | |- ROLE_SYSTEM_COLUMNHEADER - | '- .. - |- ROLE_SYSTEM_ROW - | |- ROLE_SYSTEM_ROWHEADER - | |- ROLE_SYSTEM_CELL - | |- ROLE_SYSTEM_CELL - | |- ROLE_SYSTEM_CELL - | '- .. - |- ROLE_SYSTEM_ROW - | |- ROLE_SYSTEM_ROWHEADER - | |- ROLE_SYSTEM_CELL - | |- ROLE_SYSTEM_CELL - | |- ROLE_SYSTEM_CELL - | '- .. - '- .. - -The headers of QTreeView is also represented like this. -*/ -QAccessibleItemRow::QAccessibleItemRow(QAbstractItemView *aView, const QModelIndex &index, bool isHeader) - : row(index), view(aView), m_header(isHeader) -{ -} - -QHeaderView *QAccessibleItemRow::horizontalHeader() const -{ - QHeaderView *header = 0; - if (m_header) { - if (false) { -#ifndef QT_NO_TABLEVIEW - } else if (const QTableView *tv = qobject_cast(view)) { - header = tv->horizontalHeader(); -#endif -#ifndef QT_NO_TREEVIEW - } else if (const QTreeView *tv = qobject_cast(view)) { - header = tv->header(); -#endif - } - } - return header; -} - -QHeaderView *QAccessibleItemRow::verticalHeader() const -{ - QHeaderView *header = 0; -#ifndef QT_NO_TABLEVIEW - if (const QTableView *tv = qobject_cast(view)) - header = tv->verticalHeader(); -#endif - return header; -} - -int QAccessibleItemRow::logicalFromChild(QHeaderView *header, int child) const -{ - int logical = -1; - if (header->sectionsHidden()) { - int kid = 0; - for (int i = 0; i < header->count(); ++i) { - if (!header->isSectionHidden(i)) - ++kid; - if (kid == child) { - logical = i; - break; - } - } - } else { - logical = child - 1; - } - return logical; -} - -QRect QAccessibleItemRow::rect(int child) const -{ - QRect r; - if (view && view->isVisible()) { - if (QHeaderView *header = horizontalHeader()) { - if (!child) { - r = header->rect(); - } else { - if (QHeaderView *vheader = verticalHeader()) { - if (child == 1) { - int w = vheader->width(); - int h = header->height(); - r.setRect(0, 0, w, h); - } - --child; - } - if (child) { - int logical = logicalFromChild(header, child); - int w = header->sectionSize(logical); - r.setRect(header->sectionViewportPosition(logical), 0, w, header->height()); - r.translate(header->mapTo(view, QPoint(0, 0))); - } - } - } else if (row.isValid()) { - if (!child) { - QModelIndex parent = row.parent(); - const int colCount = row.model()->columnCount(parent); - for (int i = 0; i < colCount; ++i) - r |= view->visualRect(row.model()->index(row.row(), i, parent)); - r.translate(view->viewport()->mapTo(view, QPoint(0,0))); - - if (const QHeaderView *vheader = verticalHeader()) { // include the section of the vertical header - QRect re; - int logicalRow = row.row(); - int h = vheader->sectionSize(logicalRow); - re.setRect(0, vheader->sectionViewportPosition(logicalRow), vheader->width(), h); - re.translate(vheader->mapTo(view, QPoint(0, 0))); - r |= re; - } - } else { - if (QHeaderView *vheader = verticalHeader()) { - if (child == 1) { - int logicalRow = row.row(); - int h = vheader->sectionSize(logicalRow); - r.setRect(0, vheader->sectionViewportPosition(logicalRow), vheader->width(), h); - r.translate(vheader->mapTo(view, QPoint(0, 0))); - } - --child; - } - if (child) { - r = view->visualRect(childIndex(child)); - r.translate(view->viewport()->mapTo(view, QPoint(0,0))); - } - } - } - } - if (!r.isNull()) - r.translate(view->mapToGlobal(QPoint(0, 0))); - - return r; -} - -int QAccessibleItemRow::treeLevel() const -{ - int level = 0; - QModelIndex idx = row; - while (idx.isValid()) { - idx = idx.parent(); - ++level; - } - return level; -} - -QString QAccessibleItemRow::text_helper(int child) const -{ - QString value; - if (m_header) { - if (!child) - return QString(); - if (verticalHeader()) { - if (child == 1) - return QString(); - --child; - } - QHeaderView *header = horizontalHeader(); - int logical = logicalFromChild(header, child); - value = view->model()->headerData(logical, Qt::Horizontal, Qt::AccessibleTextRole).toString(); - if (value.isEmpty()) - value = view->model()->headerData(logical, Qt::Horizontal).toString(); - return value; - } else { - if (!child) { // for one-column views (i.e. QListView) - if (children().count() >= 1) - child = 1; - else - return QString(); - } - if (verticalHeader()) { - if (child == 1) { - int logical = row.row(); - value = view->model()->headerData(logical, Qt::Vertical, Qt::AccessibleTextRole).toString(); - if (value.isEmpty()) - value = view->model()->headerData(logical, Qt::Vertical).toString(); - return value; - } else { - --child; - } - } - } - if (value.isEmpty()) { - QModelIndex idx = childIndex(child); - if (idx.isValid()) { - value = idx.model()->data(idx, Qt::AccessibleTextRole).toString(); - if (value.isEmpty()) - value = idx.model()->data(idx, Qt::DisplayRole).toString(); - } - } - return value; -} - -QString QAccessibleItemRow::text(Text t, int child) const -{ - QString value; - if (t == Name) { - value = text_helper(child); - } else if (t == Value) { -#ifndef QT_NO_TREEVIEW - if (qobject_cast(view)) { - if (child == 0) - value = QString::number(treeLevel()); - } else -#endif - { - value = text_helper(child); - } - } else if (t == Description) { -#ifndef QT_NO_TREEVIEW - if (child == 0 && qobject_cast(view)) { - // We store the tree coordinates of the current item in the description. - // This enables some screen readers to report where the focus is - // in a tree view. (works in JAWS). Also, Firefox does the same thing. - // For instance the description "L2, 4 of 25 with 24" means - // "L2": Tree Level 2 - // "4 of 25": We are item 4 out of in total 25 other siblings - // "with 24": We have 24 children. (JAWS does not read this number) - - // level - int level = treeLevel(); - - QAbstractItemModel *m = view->model(); - // totalSiblings and itemIndex - QModelIndex parent = row.parent(); - int rowCount = m->rowCount(parent); - int itemIndex = -1; - int totalSiblings = 0; - for (int i = 0 ; i < rowCount; ++i) { - QModelIndex sibling = row.sibling(i, 0); - if (!view->isIndexHidden(sibling)) - ++totalSiblings; - if (row == sibling) - itemIndex = totalSiblings; - } - int totalChildren = m->rowCount(row); // JAWS does not report child count, so we do - // this simple and efficient. - // (don't check if they are all visible). - value = QString::fromAscii("L%1, %2 of %3 with %4").arg(level).arg(itemIndex).arg(totalSiblings).arg(totalChildren); - } else -#endif // QT_NO_TREEVIEW - { - if (!m_header) { - if (child == 0 && children().count() >= 1) - child = 1; - if (verticalHeader()) { - if (child == 1) { - value = view->model()->headerData(row.row(), Qt::Vertical).toString(); - } - --child; - } - if (child) { - QModelIndex idx = childIndex(child); - value = idx.model()->data(idx, Qt::AccessibleDescriptionRole).toString(); - } - - } - } - } - return value; -} - -void QAccessibleItemRow::setText(Text t, int child, const QString &text) -{ - if (m_header) { - if (child) - view->model()->setHeaderData(child - 1, Qt::Horizontal, text); - // child == 0 means the cell to the left of the horizontal header, which is empty!? - } else { - if (!child) { - if (children().count() == 1) - child = 1; - else - return; - } - - if (verticalHeader()) { - if (child == 1) { - view->model()->setHeaderData(row.row(), Qt::Vertical, text); - return; - } - --child; - } - QModelIndex idx = childIndex(child); - if (!idx.isValid()) - return; - - switch (t) { - case Description: - const_cast(idx.model())->setData(idx, text, - Qt::AccessibleDescriptionRole); - break; - case Value: - const_cast(idx.model())->setData(idx, text, Qt::EditRole); - break; - default: - break; - } - } -} - -QModelIndex QAccessibleItemRow::childIndex(int child) const -{ - QList kids = children(); - Q_ASSERT(child >= 1 && child <= kids.count()); - return kids.at(child - 1); -} - -QList QAccessibleItemRow::children() const -{ - QList kids; - for (int i = 0; i < row.model()->columnCount(row.parent()); ++i) { - QModelIndex idx = row.model()->index(row.row(), i, row.parent()); - if (!view->isIndexHidden(idx)) { - kids << idx; - } - } - return kids; -} - -bool QAccessibleItemRow::isValid() const -{ - return m_header ? true : row.isValid(); -} - -QObject *QAccessibleItemRow::object() const -{ - return 0; -} - -int QAccessibleItemRow::childCount() const -{ - int count = 0; - if (QHeaderView *header = horizontalHeader()) { - count = header->count() - header->hiddenSectionCount(); - } else { - count = children().count(); - } -#ifndef QT_NO_TABLEVIEW - if (qobject_cast(view)) { - if (verticalHeader()) - ++count; - } -#endif - return count; -} - -int QAccessibleItemRow::indexOfChild(const QAccessibleInterface *iface) const -{ - if (!iface || iface->role(0) != Row) - return -1; - - //### meaningless code? - QList kids = children(); - QModelIndex idx = static_cast(iface)->row; - if (!idx.isValid()) - return -1; - return kids.indexOf(idx) + 1; -} - -QAccessible::Relation QAccessibleItemRow::relationTo(int child, const QAccessibleInterface *other, - int otherChild) const -{ - if (!child && !otherChild && other->object() == view) - return Child; - if (!child && !otherChild && other == this) - return Self; - if (!child && otherChild && other == this) - return Ancestor; - if (child && otherChild && other == this) - return Sibling; - return Unrelated; -} - -int QAccessibleItemRow::childAt(int x, int y) const -{ - if (!view || !view->isVisible()) - return -1; - - for (int i = childCount(); i >= 0; --i) { - if (rect(i).contains(x, y)) - return i; - } - return -1; -} - -QAbstractItemView::CursorAction QAccessibleItemRow::toCursorAction( - QAccessible::Relation rel) -{ - switch (rel) { - case QAccessible::Up: - return QAbstractItemView::MoveUp; - case QAccessible::Down: - return QAbstractItemView::MoveDown; - case QAccessible::Left: - return QAbstractItemView::MoveLeft; - case QAccessible::Right: - return QAbstractItemView::MoveRight; - default: - Q_ASSERT(false); - } - // should never be reached. - return QAbstractItemView::MoveRight; -} - -int QAccessibleItemRow::navigate(RelationFlag relation, int index, - QAccessibleInterface **iface) const -{ - *iface = 0; - if (!view) - return -1; - - switch (relation) { - case Ancestor: { - if (!index) - return -1; - QAccessibleItemView *ancestor = new QAccessibleItemView(view->viewport()); - if (index == 1) { - *iface = ancestor; - return 0; - } else if (index > 1) { - int ret = ancestor->navigate(Ancestor, index - 1, iface); - delete ancestor; - return ret; - } - } - case Child: { - if (!index) - return -1; - if (index < 1 && index > childCount()) - return -1; - - return index;} - case Sibling: - if (index) { - QAccessibleInterface *ifaceParent = 0; - navigate(Ancestor, 1, &ifaceParent); - if (ifaceParent) { - int entry = ifaceParent->navigate(Child, index, iface); - delete ifaceParent; - return entry; - } - } - return -1; - case Up: - case Down: - case Left: - case Right: { - // This is in the "not so nice" category. In order to find out which item - // is geometrically around, we have to set the current index, navigate - // and restore the index as well as the old selection - view->setUpdatesEnabled(false); - const QModelIndex oldIdx = view->currentIndex(); - QList kids = children(); - const QModelIndex currentIndex = index ? kids.at(index - 1) : QModelIndex(row); - const QItemSelection oldSelection = view->selectionModel()->selection(); - view->setCurrentIndex(currentIndex); - const QModelIndex idx = view->moveCursor(toCursorAction(relation), Qt::NoModifier); - view->setCurrentIndex(oldIdx); - view->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect); - view->setUpdatesEnabled(true); - if (!idx.isValid()) - return -1; - - if (idx.parent() != row.parent() || idx.row() != row.row()) - *iface = new QAccessibleItemRow(view, idx); - return index ? kids.indexOf(idx) + 1 : 0; } - default: - break; - } - - return -1; -} - -QAccessible::Role QAccessibleItemRow::role(int child) const -{ - if (false) { -#ifndef QT_NO_TREEVIEW - } else if (qobject_cast(view)) { - if (horizontalHeader()) { - if (!child) - return Row; - return ColumnHeader; - } - return TreeItem; -#endif -#ifndef QT_NO_LISTVIEW - } else if (qobject_cast(view)) { - return ListItem; -#endif -#ifndef QT_NO_TABLEVIEW - } else if (qobject_cast(view)) { - if (!child) - return Row; - if (child == 1) { - if (verticalHeader()) - return RowHeader; - } - if (m_header) - return ColumnHeader; -#endif - } - return Cell; -} - -QAccessible::State QAccessibleItemRow::state(int child) const -{ - State st = Normal; - - if (!view) - return st; - - QAccessibleInterface *parent = 0; - QRect globalRect; - if (navigate(Ancestor, 1, &parent) == 0) { - globalRect = parent->rect(0); - delete parent; - } - if (!globalRect.intersects(rect(child))) - st |= Invisible; - - if (!horizontalHeader()) { - if (!(st & Invisible)) { - if (child) { - if (QHeaderView *vheader = verticalHeader() ) { - if (child == 1) { - if (!vheader->isVisible()) - st |= Invisible; - } - --child; - } - if (child) { - QModelIndex idx = childIndex(child); - if (!idx.isValid()) - return st; - - if (view->selectionModel()->isSelected(idx)) - st |= Selected; - if (view->selectionModel()->currentIndex() == idx) - st |= Focused; - if (idx.model()->data(idx, Qt::CheckStateRole).toInt() == Qt::Checked) - st |= Checked; - - Qt::ItemFlags flags = idx.flags(); - if (flags & Qt::ItemIsSelectable) { - st |= Selectable; - if (view->selectionMode() == QAbstractItemView::MultiSelection) - st |= MultiSelectable; - if (view->selectionMode() == QAbstractItemView::ExtendedSelection) - st |= ExtSelectable; - } - } - } else { - Qt::ItemFlags flags = row.flags(); - if (flags & Qt::ItemIsSelectable) { - st |= Selectable; - st |= Focusable; - } - if (view->selectionModel()->isRowSelected(row.row(), row.parent())) - st |= Selected; - if (view->selectionModel()->currentIndex().row() == row.row()) - st |= Focused; - } - } - } - - return st; -} - -int QAccessibleItemRow::userActionCount(int) const -{ - return 0; -} - -QString QAccessibleItemRow::actionText(int, Text, int) const -{ - return QString(); -} - -static QItemSelection rowAt(const QModelIndex &idx) -{ - return QItemSelection(idx.sibling(idx.row(), 0), - idx.sibling(idx.row(), idx.model()->columnCount(idx.parent()))); -} - -bool QAccessibleItemRow::doAction(int action, int child, const QVariantList & /*params*/) -{ - if (!view) - return false; - - if (verticalHeader()) - --child; - - QModelIndex idx = child ? childIndex(child) : QModelIndex(row); - if (!idx.isValid()) - return false; - - QItemSelectionModel::SelectionFlags command = QItemSelectionModel::NoUpdate; - - switch (action) { - case SetFocus: - view->setCurrentIndex(idx); - return true; - case ExtendSelection: - if (!child) - return false; - view->selectionModel()->select(QItemSelection(view->currentIndex(), idx), - QItemSelectionModel::SelectCurrent); - return true; - case Select: - command = QItemSelectionModel::ClearAndSelect; - break; - case ClearSelection: - command = QItemSelectionModel::Clear; - break; - case RemoveSelection: - command = QItemSelectionModel::Deselect; - break; - case AddToSelection: - command = QItemSelectionModel::SelectCurrent; - break; - } - if (command == QItemSelectionModel::NoUpdate) - return false; - - if (child) - view->selectionModel()->select(idx, command); - else - view->selectionModel()->select(rowAt(row), command); - return true; -} - -class ModelIndexIterator -{ -public: - ModelIndexIterator(QAbstractItemView *view, const QModelIndex &start = QModelIndex()) : m_view(view) - { -#ifndef QT_NO_LISTVIEW - list = qobject_cast(m_view); -#endif -#ifndef QT_NO_TREEVIEW - tree = qobject_cast(m_view); -#endif -#ifndef QT_NO_TABLEVIEW - table = qobject_cast(m_view); -#endif - if (start.isValid()) { - m_current = start; - } else if (m_view && m_view->model()) { - m_current = view->rootIndex().isValid() ? - view->rootIndex().child(0,0) : view->model()->index(0, 0); - } - } - - bool next(int count = 1) { - for (int i = 0; i < count; ++i) { - do { - if (m_current.isValid()) { - const QAbstractItemModel *m = m_current.model(); -#ifndef QT_NO_TREEVIEW - if (tree && m_current.model()->hasChildren(m_current) && tree->isExpanded(m_current)) { - m_current = m_current.child(0, 0); - } else -#endif - { - int row = m_current.row(); - QModelIndex par = m_current.parent(); - - // Go up to the parent if we reach the end of the rows - // If m_curent becomses invalid, stop going up. - while (row + 1 >= m->rowCount(par)) { - m_current = par; - if (m_current.isValid()) { - row = m_current.row(); - par = m_current.parent(); - } else { - row = 0; - par = QModelIndex(); - break; - } - } - - if (m_current.isValid()) - m_current = m_current.sibling(row + 1, 0); - } - } - } while (isHidden()); - } - return m_current.isValid(); - } - - bool isHidden() const { - if (false) { -#ifndef QT_NO_LISTVIEW - } else if (list) { - return list->isRowHidden(m_current.row()); -#endif -#ifndef QT_NO_TREEVIEW - } else if (tree) { - return tree->isRowHidden(m_current.row(), m_current.parent()); -#endif -#ifndef QT_NO_TABLEVIEW - } else if (table) { - return table->isRowHidden(m_current.row()); -#endif - } - return false; - } - - QModelIndex current() const { - return m_current; - } - -private: - QModelIndex m_current; - QAbstractItemView *m_view; - -#ifndef QT_NO_TREEVIEW - QTreeView *tree; -#endif -#ifndef QT_NO_LISTVIEW - QListView *list; -#endif -#ifndef QT_NO_TABLEVIEW - QTableView *table; -#endif -}; - -QAccessibleItemView::QAccessibleItemView(QWidget *w) - : QAccessibleAbstractScrollArea(w->objectName() == QLatin1String("qt_scrollarea_viewport") ? w->parentWidget() : w) -{ - atVP = w->objectName() == QLatin1String("qt_scrollarea_viewport"); - -} - - -QHeaderView *QAccessibleItemView::horizontalHeader() const -{ - QHeaderView *header = 0; - if (false) { -#ifndef QT_NO_TABLEVIEW - } else if (const QTableView *tv = qobject_cast(itemView())) { - header = tv->horizontalHeader(); -#endif -#ifndef QT_NO_TREEVIEW - } else if (const QTreeView *tv = qobject_cast(itemView())) { - header = tv->header(); -#endif - } - return header; -} - -QHeaderView *QAccessibleItemView::verticalHeader() const -{ - QHeaderView *header = 0; - if (false) { -#ifndef QT_NO_TABLEVIEW - } else if (const QTableView *tv = qobject_cast(itemView())) { - header = tv->verticalHeader(); -#endif - } - return header; -} - - -bool QAccessibleItemView::isValidChildRole(QAccessible::Role role) const -{ - if (atViewport()) { - if (false) { -#ifndef QT_NO_TREEVIEW - } else if (qobject_cast(itemView())) { - return (role == TreeItem || role == Row); -#endif -#ifndef QT_NO_LISTVIEW - } else if (qobject_cast(itemView())) { - return (role == ListItem); -#endif - } - // TableView - return role == Row; - } else { - if (false) { -#ifndef QT_NO_TREEVIEW - } else if (qobject_cast(itemView())) { - return (role == Tree); -#endif -#ifndef QT_NO_LISTVIEW - } else if (qobject_cast(itemView())) { - return (role == List); -#endif - } - // TableView - return (role == Table); - } -} - -QObject *QAccessibleItemView::object() const -{ - QObject *view = QAccessibleAbstractScrollArea::object(); - Q_ASSERT(qobject_cast(view)); - if (atViewport()) - view = qobject_cast(view)->viewport(); - return view; -} - -QAbstractItemView *QAccessibleItemView::itemView() const -{ - return qobject_cast(QAccessibleAbstractScrollArea::object()); -} - -int QAccessibleItemView::indexOfChild(const QAccessibleInterface *iface) const -{ - if (atViewport()) { - if (!iface || !isValidChildRole(iface->role(0))) - return -1; - - int entry = -1; - // ### This will fail if a row is hidden. - const QAccessibleItemRow *ifRow = static_cast(iface); - if (ifRow->horizontalHeader()) - return 1; - - QModelIndex idx = ifRow->row; - if (!idx.isValid()) - return -1; - - entry = entryFromIndex(idx); - if (horizontalHeader()) - ++entry; - - return entry; - - } else { - return QAccessibleAbstractScrollArea::indexOfChild(iface); - } -} - -QModelIndex QAccessibleItemView::childIndex(int child) const -{ - if (!atViewport()) - return QModelIndex(); - ModelIndexIterator it(itemView()); - it.next(child - 1); - return it.current(); -} - -int QAccessibleItemView::entryFromIndex(const QModelIndex &index) const -{ - int entry = -1; - if (false) { -#ifndef QT_NO_TREEVIEW - } else if (QTreeView *tree = qobject_cast(itemView())) { - entry = tree->visualIndex(index) + 1; -#endif -#ifndef QT_NO_LISTVIEW - } else if (QListView *list = qobject_cast(itemView())) { - entry = list->visualIndex(index) + 1; -#endif -#ifndef QT_NO_TABLEVIEW - } else if (QTableView *table = qobject_cast(itemView())) { - entry = table->visualIndex(index) + 1; -#endif - } - return entry; -} - -int QAccessibleItemView::childCount() const -{ - if (atViewport()) { - if (itemView()->model() == 0) - return 0; - QAbstractItemModel *m = itemView()->model(); - QModelIndex idx = m->index(0,0); - if (!idx.isValid()) - return 0; - ModelIndexIterator it(itemView()); - int count = 1; - while (it.next()) { - ++count; - } - if (horizontalHeader()) - ++count; - - return count; - } else { - return QAccessibleAbstractScrollArea::childCount(); - } -} - -QString QAccessibleItemView::text(Text t, int child) const -{ - if (atViewport()) { - if (!child) - return QAccessibleAbstractScrollArea::text(t, child); - - QAccessibleItemRow item(itemView(), childIndex(child)); - if (item.isValid()) { - return item.text(t, 1); - } else { - return QString(); - } - } else { - return QAccessibleAbstractScrollArea::text(t, child); - } -} - -void QAccessibleItemView::setText(Text t, int child, const QString &text) -{ - if (atViewport()) { - if (!child) { - QAccessibleAbstractScrollArea::setText(t, child, text); - return; - } - - QAccessibleItemRow item(itemView(), childIndex(child)); - item.setText(t, 1, text); - } else { - QAccessibleAbstractScrollArea::setText(t, child, text); - } -} - -QRect QAccessibleItemView::rect(int child) const -{ - if (atViewport()) { - QRect r; - if (!child) { - // Make sure that the rect *include* the vertical and horizontal headers, while - // not including the potential vertical and horizontal scrollbars. - QAbstractItemView *w = itemView(); - - int vscrollWidth = 0; - const QScrollBar *sb = w->verticalScrollBar(); - if (sb && sb->isVisible()) - vscrollWidth = sb->width(); - - int hscrollHeight = 0; - sb = w->horizontalScrollBar(); - if (sb && sb->isVisible()) - hscrollHeight = sb->height(); - - QPoint globalPos = w->mapToGlobal(QPoint(0,0)); - r = w->rect().translated(globalPos); - if (w->isRightToLeft()) { - r.adjust(vscrollWidth, 0, 0, -hscrollHeight); - } else { - r.adjust(0, 0, -vscrollWidth, -hscrollHeight); - } - } else { - QAccessibleInterface *iface = 0; - if (navigate(Child, child, &iface) == 0) { - r = iface->rect(0); - delete iface; - } - } - return r; - } else { - QRect r = QAccessibleAbstractScrollArea::rect(child); - if (child == 1) { - // include the potential vertical and horizontal headers - - const QHeaderView *header = verticalHeader(); - int headerWidth = (header && header->isVisible()) ? header->width() : 0; - header = horizontalHeader(); - int headerHeight= (header && header->isVisible()) ? header->height() : 0; - if (itemView()->isRightToLeft()) { - r.adjust(0, -headerHeight, headerWidth, 0); - } else { - r.adjust(-headerWidth, -headerHeight, 0, 0); - } - } - return r; - } -} - -int QAccessibleItemView::childAt(int x, int y) const -{ - if (atViewport()) { - QPoint p(x, y); - for (int i = childCount(); i >= 0; --i) { - if (rect(i).contains(p)) - return i; - } - return -1; - } else { - return QAccessibleAbstractScrollArea::childAt(x, y); - } -} - -QAccessible::Role QAccessibleItemView::role(int child) const -{ - if ((!atViewport() && child) || (atViewport() && child == 0)) { - QAbstractItemView *view = itemView(); -#ifndef QT_NO_TABLEVIEW - if (qobject_cast(view)) - return Table; -#endif -#ifndef QT_NO_LISTVIEW - if (qobject_cast(view)) - return List; -#endif - return Tree; - } - if (atViewport()) { - if (child) - return Row; - } - - return QAccessibleAbstractScrollArea::role(child); -} - -QAccessible::State QAccessibleItemView::state(int child) const -{ - State st = Normal; - - if (itemView() == 0) - return State(Unavailable); - - bool queryViewPort = (atViewport() && child == 0) || (!atViewport() && child == 1); - if (queryViewPort) { - if (itemView()->selectionMode() != QAbstractItemView::NoSelection) { - st |= Selectable; - st |= Focusable; - } - } else if (atViewport()) { // children of viewport - if (horizontalHeader()) - --child; - if (child) { - QAccessibleItemRow item(itemView(), childIndex(child)); - st |= item.state(0); - } - } else if (!atViewport() && child != 1) { - st = QAccessibleAbstractScrollArea::state(child); - } - return st; -} - -bool QAccessibleItemView::isValid() const -{ - if (atViewport()) - return QAccessibleWidget::isValid(); - else - return QAccessibleAbstractScrollArea::isValid(); -} - -int QAccessibleItemView::navigate(RelationFlag relation, int index, - QAccessibleInterface **iface) const -{ - if (atViewport()) { - if (relation == Ancestor && index == 1) { - *iface = new QAccessibleItemView(itemView()); - return 0; - } else if (relation == Child && index >= 1) { - if (horizontalHeader()) { - if (index == 1) { - *iface = new QAccessibleItemRow(itemView(), QModelIndex(), true); - return 0; - } - --index; - } - - //###JAS hidden rows.. - QModelIndex idx = childIndex(index); - if (idx.isValid()) { - *iface = new QAccessibleItemRow(itemView(), idx); - return 0; - } - } else if (relation == Sibling && index >= 1) { - QAccessibleInterface *parent = new QAccessibleItemView(itemView()); - return parent->navigate(Child, index, iface); - } - *iface = 0; - return -1; - } else { - return QAccessibleAbstractScrollArea::navigate(relation, index, iface); - } -} - -/* returns the model index for a given row and column */ -QModelIndex QAccessibleItemView::index(int row, int column) const -{ - return itemView()->model()->index(row, column); -} - -QAccessibleInterface *QAccessibleItemView::accessibleAt(int row, int column) -{ - QWidget *indexWidget = itemView()->indexWidget(index(row, column)); - return QAccessible::queryAccessibleInterface(indexWidget); -} - -/* We don't have a concept of a "caption" in Qt's standard widgets */ -QAccessibleInterface *QAccessibleItemView::caption() -{ - return 0; -} - -/* childIndex is row * columnCount + columnIndex */ -int QAccessibleItemView::childIndex(int rowIndex, int columnIndex) -{ - return rowIndex * itemView()->model()->columnCount() + columnIndex; -} - -/* Return the header data as column description */ -QString QAccessibleItemView::columnDescription(int column) -{ - return itemView()->model()->headerData(column, Qt::Horizontal).toString(); -} - -/* We don't support column spanning atm */ -int QAccessibleItemView::columnSpan(int /* row */, int /* column */) -{ - return 1; -} - -/* Return the horizontal header view */ -QAccessibleInterface *QAccessibleItemView::columnHeader() -{ -#ifndef QT_NO_TREEVIEW - if (QTreeView *tree = qobject_cast(itemView())) - return QAccessible::queryAccessibleInterface(tree->header()); -#endif -#ifndef QT_NO_TABLEVIEW - if (QTableView *table = qobject_cast(itemView())) - return QAccessible::queryAccessibleInterface(table->horizontalHeader()); -#endif - return 0; -} - -int QAccessibleItemView::columnIndex(int childIndex) -{ - int columnCount = itemView()->model()->columnCount(); - if (!columnCount) - return 0; - - return childIndex % columnCount; -} - -int QAccessibleItemView::columnCount() -{ - return itemView()->model()->columnCount(); -} - -int QAccessibleItemView::rowCount() -{ - return itemView()->model()->rowCount(); -} - -int QAccessibleItemView::selectedColumnCount() -{ - return itemView()->selectionModel()->selectedColumns().count(); -} - -int QAccessibleItemView::selectedRowCount() -{ - return itemView()->selectionModel()->selectedRows().count(); -} - -QString QAccessibleItemView::rowDescription(int row) -{ - return itemView()->model()->headerData(row, Qt::Vertical).toString(); -} - -/* We don't support row spanning */ -int QAccessibleItemView::rowSpan(int /*row*/, int /*column*/) -{ - return 1; -} - -QAccessibleInterface *QAccessibleItemView::rowHeader() -{ -#ifndef QT_NO_TABLEVIEW - if (QTableView *table = qobject_cast(itemView())) - return QAccessible::queryAccessibleInterface(table->verticalHeader()); -#endif - return 0; -} - -int QAccessibleItemView::rowIndex(int childIndex) -{ - int columnCount = itemView()->model()->columnCount(); - if (!columnCount) - return 0; - - return int(childIndex / columnCount); -} - -int QAccessibleItemView::selectedRows(int maxRows, QList *rows) -{ - Q_ASSERT(rows); - - const QModelIndexList selRows = itemView()->selectionModel()->selectedRows(); - int maxCount = qMin(selRows.count(), maxRows); - - for (int i = 0; i < maxCount; ++i) - rows->append(selRows.at(i).row()); - - return maxCount; -} - -int QAccessibleItemView::selectedColumns(int maxColumns, QList *columns) -{ - Q_ASSERT(columns); - - const QModelIndexList selColumns = itemView()->selectionModel()->selectedColumns(); - int maxCount = qMin(selColumns.count(), maxColumns); - - for (int i = 0; i < maxCount; ++i) - columns->append(selColumns.at(i).row()); - - return maxCount; -} - -/* Qt widgets don't have a concept of a summary */ -QAccessibleInterface *QAccessibleItemView::summary() -{ - return 0; -} - -bool QAccessibleItemView::isColumnSelected(int column) -{ - return itemView()->selectionModel()->isColumnSelected(column, QModelIndex()); -} - -bool QAccessibleItemView::isRowSelected(int row) -{ - return itemView()->selectionModel()->isRowSelected(row, QModelIndex()); -} - -bool QAccessibleItemView::isSelected(int row, int column) -{ - return itemView()->selectionModel()->isSelected(index(row, column)); -} - -void QAccessibleItemView::selectRow(int row) -{ - QItemSelectionModel *s = itemView()->selectionModel(); - s->select(index(row, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows); -} - -void QAccessibleItemView::selectColumn(int column) -{ - QItemSelectionModel *s = itemView()->selectionModel(); - s->select(index(0, column), QItemSelectionModel::Select | QItemSelectionModel::Columns); -} - -void QAccessibleItemView::unselectRow(int row) -{ - QItemSelectionModel *s = itemView()->selectionModel(); - s->select(index(row, 0), QItemSelectionModel::Deselect | QItemSelectionModel::Rows); -} - -void QAccessibleItemView::unselectColumn(int column) -{ - QItemSelectionModel *s = itemView()->selectionModel(); - s->select(index(0, column), QItemSelectionModel::Deselect | QItemSelectionModel::Columns); -} - -void QAccessibleItemView::cellAtIndex(int index, int *row, int *column, int *rSpan, - int *cSpan, bool *isSelect) -{ - *row = rowIndex(index); - *column = columnIndex(index); - *rSpan = rowSpan(*row, *column); - *cSpan = columnSpan(*row, *column); - *isSelect = isSelected(*row, *column); -} - -/*! - \class QAccessibleHeader - \brief The QAccessibleHeader class implements the QAccessibleInterface for header widgets. - \internal - - \ingroup accessibility -*/ - -/*! - Constructs a QAccessibleHeader object for \a w. -*/ -QAccessibleHeader::QAccessibleHeader(QWidget *w) -: QAccessibleWidget(w) -{ - Q_ASSERT(header()); - addControllingSignal(QLatin1String("sectionClicked(int)")); -} - -/*! Returns the QHeaderView. */ -QHeaderView *QAccessibleHeader::header() const -{ - return qobject_cast(object()); -} - -/*! \reimp */ -QRect QAccessibleHeader::rect(int child) const -{ - if (!child) - return QAccessibleWidget::rect(0); - - QHeaderView *h = header(); - QPoint zero = h->mapToGlobal(QPoint(0, 0)); - int sectionSize = h->sectionSize(child - 1); - int sectionPos = h->sectionPosition(child - 1); - return h->orientation() == Qt::Horizontal - ? QRect(zero.x() + sectionPos, zero.y(), sectionSize, h->height()) - : QRect(zero.x(), zero.y() + sectionPos, h->width(), sectionSize); -} - -/*! \reimp */ -int QAccessibleHeader::childCount() const -{ - return header()->count(); -} - -/*! \reimp */ -QString QAccessibleHeader::text(Text t, int child) const -{ - QString str; - - if (child > 0 && child <= childCount()) { - switch (t) { - case Name: - str = header()->model()->headerData(child - 1, header()->orientation()).toString(); - break; - case Description: { - QAccessibleEvent event(QEvent::AccessibilityDescription, child); - if (QApplication::sendEvent(widget(), &event)) - str = event.value(); - break; } - case Help: { - QAccessibleEvent event(QEvent::AccessibilityHelp, child); - if (QApplication::sendEvent(widget(), &event)) - str = event.value(); - break; } - default: - break; - } - } - if (str.isEmpty()) - str = QAccessibleWidget::text(t, child); - return str; -} - -/*! \reimp */ -QAccessible::Role QAccessibleHeader::role(int) const -{ - return (header()->orientation() == Qt::Horizontal) ? ColumnHeader : RowHeader; -} - -/*! \reimp */ -QAccessible::State QAccessibleHeader::state(int child) const -{ - State state = QAccessibleWidget::state(child); - - if (child) { - int section = child - 1; - if (header()->isSectionHidden(section)) - state |= Invisible; - if (header()->resizeMode(section) != QHeaderView::Custom) - state |= Sizeable; - } else { - if (header()->isMovable()) - state |= Movable; - } - if (!header()->isClickable()) - state |= Unavailable; - return state; -} -#endif // QT_NO_ITEMVIEWS - -#ifndef QT_NO_TABBAR -/*! - \class QAccessibleTabBar - \brief The QAccessibleTabBar class implements the QAccessibleInterface for tab bars. - \internal - - \ingroup accessibility -*/ - -/*! - Constructs a QAccessibleTabBar object for \a w. -*/ -QAccessibleTabBar::QAccessibleTabBar(QWidget *w) -: QAccessibleWidget(w) -{ - Q_ASSERT(tabBar()); -} - -/*! Returns the QTabBar. */ -QTabBar *QAccessibleTabBar::tabBar() const -{ - return qobject_cast(object()); -} - -QAbstractButton *QAccessibleTabBar::button(int child) const -{ - if (child <= tabBar()->count()) - return 0; - QTabBarPrivate * const tabBarPrivate = tabBar()->d_func(); - if (child - tabBar()->count() == 1) - return tabBarPrivate->leftB; - if (child - tabBar()->count() == 2) - return tabBarPrivate->rightB; - Q_ASSERT(false); - return 0; -} - -/*! \reimp */ -QRect QAccessibleTabBar::rect(int child) const -{ - if (!child || !tabBar()->isVisible()) - return QAccessibleWidget::rect(0); - - QPoint tp = tabBar()->mapToGlobal(QPoint(0,0)); - QRect rec; - if (child <= tabBar()->count()) { - rec = tabBar()->tabRect(child - 1); - } else { - QWidget *widget = button(child); - rec = widget ? widget->geometry() : QRect(); - } - return QRect(tp.x() + rec.x(), tp.y() + rec.y(), rec.width(), rec.height()); -} - -/*! \reimp */ -int QAccessibleTabBar::childCount() const -{ - // tabs + scroll buttons - return tabBar()->count() + 2; -} - -/*! \reimp */ -QString QAccessibleTabBar::text(Text t, int child) const -{ - QString str; - - if (child > tabBar()->count()) { - bool left = child - tabBar()->count() == 1; - switch (t) { - case Name: - return left ? QTabBar::tr("Scroll Left") : QTabBar::tr("Scroll Right"); - default: - break; - } - } else { - switch (t) { - case Name: - if (child > 0) - return qt_accStripAmp(tabBar()->tabText(child - 1)); - else if (tabBar()->currentIndex() != -1) - return qt_accStripAmp(tabBar()->tabText(tabBar()->currentIndex())); - break; - default: - break; - } - } - - if (str.isEmpty()) - str = QAccessibleWidget::text(t, child);; - return str; -} - -/*! \reimp */ -QAccessible::Role QAccessibleTabBar::role(int child) const -{ - if (!child) - return PageTabList; - if (child > tabBar()->count()) - return PushButton; - return PageTab; -} - -/*! \reimp */ -int QAccessibleTabBar::navigate(RelationFlag relation, int entry, QAccessibleInterface** target) const -{ - //QAccessibleWidget::navigate might think that this is not a complex widget - //if close buttons are enabled, so this functions handles those cases in which - //the value to return is different if it's a complex widget and if it's not. - if (!target) - return -1; - - *target = 0; - - switch (relation) { - case Child: - if ((entry >= 0) && (entry <= childCount())) - return entry; - return -1; - default: - return QAccessibleWidget::navigate(relation, entry, target); - } -} - - -/*! \reimp */ -QAccessible::State QAccessibleTabBar::state(int child) const -{ - State st = QAccessibleWidget::state(0); - - if (!child) - return st; - - QTabBar *tb = tabBar(); - - if (child > tb->count()) { - QWidget *bt = button(child); - if (!bt) - return st; - if (bt->isEnabled() == false) - st |= Unavailable; - if (bt->isVisible() == false) - st |= Invisible; - if (bt->focusPolicy() != Qt::NoFocus && bt->isActiveWindow()) - st |= Focusable; - if (bt->hasFocus()) - st |= Focused; - return st; - } - - if (!tb->isTabEnabled(child - 1)) - st |= Unavailable; - else - st |= Selectable; - - if (tb->currentIndex() == child - 1) - st |= Selected; - - return st; -} - -/*! \reimp */ -QString QAccessibleTabBar::actionText(int action, Text t, int child) const -{ - if (!child) - return QString(); - - switch (t) { - case QAccessible::Name: - if ((action == 1) && (child <= tabBar()->count())) { - return tabBar()->tabsClosable() ? QTabBar::tr("Close") : QString(); - } else if (action == 0) { - if (child <= tabBar()->count()) - return QTabBar::tr("Activate"); - else //it's an scroll button - return QTabBar::tr("Press"); - } - break; - case QAccessible::Description: - if ((action == 1) && (child <= tabBar()->count())) { - return tabBar()->tabsClosable() ? QTabBar::tr("Close the tab") : QString(); - } else if (action == 0) { - if (child <= tabBar()->count()) - return QTabBar::tr("Activate the tab"); - } - break; - default: - break; - } - return QString(); -} - -/*! \reimp */ -int QAccessibleTabBar::userActionCount(int child) const -{ - if (!child || (child > tabBar()->count())) - return 0; - return tabBar()->tabsClosable() ? 1 : 0; -} - -/*! \reimp */ -bool QAccessibleTabBar::doAction(int action, int child, const QVariantList &) -{ - if (!child) - return false; - - if ((action == 1) && (child <= tabBar()->count()) && tabBar()->tabsClosable()) { - emit tabBar()->tabCloseRequested(child - 1); - } - - if (action != QAccessible::DefaultAction && action != QAccessible::Press) - return false; - - if (child > tabBar()->count()) { - QAbstractButton *bt = button(child); - if (!bt->isEnabled()) - return false; - bt->animateClick(); - return true; - } - if (!tabBar()->isTabEnabled(child - 1)) - return false; - tabBar()->setCurrentIndex(child - 1); - return true; -} - -/*! - Selects the item with index \a child if \a on is true; otherwise - unselects it. If \a extend is true and the selection mode is not - \c Single and there is an existing selection, the selection is - extended to include all the items from the existing selection up - to and including the item with index \a child. Returns true if a - selection was made or extended; otherwise returns false. - - \sa selection() clearSelection() -*/ -bool QAccessibleTabBar::setSelected(int child, bool on, bool extend) -{ - if (!child || !on || extend || child > tabBar()->count()) - return false; - - if (!tabBar()->isTabEnabled(child - 1)) - return false; - tabBar()->setCurrentIndex(child - 1); - return true; -} - -/*! - Returns a (possibly empty) list of indexes of the items selected - in the list box. - - \sa setSelected() clearSelection() -*/ -QVector QAccessibleTabBar::selection() const -{ - QVector array; - if (tabBar()->currentIndex() != -1) - array +=tabBar()->currentIndex() + 1; - return array; -} - -#endif // QT_NO_TABBAR - -#ifndef QT_NO_COMBOBOX -/*! - \class QAccessibleComboBox - \brief The QAccessibleComboBox class implements the QAccessibleInterface for editable and read-only combo boxes. - \internal - - \ingroup accessibility -*/ - -/*! - \enum QAccessibleComboBox::ComboBoxElements - - \internal - - \value ComboBoxSelf - \value CurrentText - \value OpenList - \value PopupList -*/ - -/*! - Constructs a QAccessibleComboBox object for \a w. -*/ -QAccessibleComboBox::QAccessibleComboBox(QWidget *w) -: QAccessibleWidget(w, ComboBox) -{ - Q_ASSERT(comboBox()); -} - -/*! - Returns the combobox. -*/ -QComboBox *QAccessibleComboBox::comboBox() const -{ - return qobject_cast(object()); -} - -/*! \reimp */ -QRect QAccessibleComboBox::rect(int child) const -{ - QPoint tp; - QStyle::SubControl sc; - QRect r; - switch (child) { - case CurrentText: - if (comboBox()->isEditable()) { - tp = comboBox()->lineEdit()->mapToGlobal(QPoint(0,0)); - r = comboBox()->lineEdit()->rect(); - sc = QStyle::SC_None; - } else { - tp = comboBox()->mapToGlobal(QPoint(0,0)); - sc = QStyle::SC_ComboBoxEditField; - } - break; - case OpenList: - tp = comboBox()->mapToGlobal(QPoint(0,0)); - sc = QStyle::SC_ComboBoxArrow; - break; - default: - return QAccessibleWidget::rect(child); - } - - if (sc != QStyle::SC_None) { - QStyleOptionComboBox option; - option.initFrom(comboBox()); - r = comboBox()->style()->subControlRect(QStyle::CC_ComboBox, &option, sc, comboBox()); - } - return QRect(tp.x() + r.x(), tp.y() + r.y(), r.width(), r.height()); -} - -/*! \reimp */ -int QAccessibleComboBox::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const -{ - *target = 0; - if (entry > ComboBoxSelf) switch (rel) { - case Child: - if (entry == CurrentText && comboBox()->isEditable()) { - *target = QAccessible::queryAccessibleInterface(comboBox()->lineEdit()); - return *target ? 0 : -1; - } else if (entry < PopupList) { - return entry; - } else if (entry == PopupList) { - QAbstractItemView *view = comboBox()->view(); - QWidget *parent = view ? view->parentWidget() : 0; - *target = QAccessible::queryAccessibleInterface(parent); - return *target ? 0 : -1; - } - case QAccessible::Left: - return entry == OpenList ? CurrentText : -1; - case QAccessible::Right: - return entry == CurrentText ? OpenList : -1; - case QAccessible::Up: - return -1; - case QAccessible::Down: - return -1; - default: - break; - } - return QAccessibleWidget::navigate(rel, entry, target); -} - -/*! \reimp */ -int QAccessibleComboBox::childCount() const -{ - return comboBox()->view() ? PopupList : OpenList; -} - -/*! \reimp */ -int QAccessibleComboBox::childAt(int x, int y) const -{ - if (!comboBox()->isVisible()) - return -1; - QPoint gp = widget()->mapToGlobal(QPoint(0, 0)); - if (!QRect(gp.x(), gp.y(), widget()->width(), widget()->height()).contains(x, y)) - return -1; - - // a complex control - for (int i = 1; i < PopupList; ++i) { - if (rect(i).contains(x, y)) - return i; - } - return 0; -} - -/*! \reimp */ -int QAccessibleComboBox::indexOfChild(const QAccessibleInterface *child) const -{ - QObject *viewParent = comboBox()->view() ? comboBox()->view()->parentWidget() : 0; - if (child->object() == viewParent) - return PopupList; - return -1; -} - -/*! \reimp */ -QString QAccessibleComboBox::text(Text t, int child) const -{ - QString str; - - switch (t) { - case Name: -#ifndef Q_WS_X11 // on Linux we use relations for this, name is text (fall through to Value) - if (child == OpenList) - str = QComboBox::tr("Open"); - else - str = QAccessibleWidget::text(t, 0); - break; -#endif - case Value: - if (comboBox()->isEditable()) - str = comboBox()->lineEdit()->text(); - else - str = comboBox()->currentText(); - break; -#ifndef QT_NO_SHORTCUT - case Accelerator: - if (child == OpenList) - str = QKeySequence(Qt::Key_Down).toString(); - break; -#endif - default: - break; - } - if (str.isEmpty()) - str = QAccessibleWidget::text(t, 0); - return str; -} - -/*! \reimp */ -QAccessible::Role QAccessibleComboBox::role(int child) const -{ - switch (child) { - case CurrentText: - if (comboBox()->isEditable()) - return EditableText; - return StaticText; - case OpenList: - return PushButton; - case PopupList: - return List; - default: - return ComboBox; - } -} - -/*! \reimp */ -QAccessible::State QAccessibleComboBox::state(int /*child*/) const -{ - return QAccessibleWidget::state(0); -} - -/*! \reimp */ -bool QAccessibleComboBox::doAction(int action, int child, const QVariantList &) -{ - if (child == 2 && (action == DefaultAction || action == Press)) { - if (comboBox()->view()->isVisible()) { - comboBox()->hidePopup(); - } else { - comboBox()->showPopup(); - } - return true; - } - return false; -} - -QString QAccessibleComboBox::actionText(int action, Text t, int child) const -{ - QString text; - if (child == 2 && t == Name && (action == DefaultAction || action == Press)) - text = comboBox()->view()->isVisible() ? QComboBox::tr("Close") : QComboBox::tr("Open"); - return text; -} -#endif // QT_NO_COMBOBOX - -#ifndef QT_NO_SCROLLAREA -// ======================= QAccessibleAbstractScrollArea ======================= -QAccessibleAbstractScrollArea::QAccessibleAbstractScrollArea(QWidget *widget) - : QAccessibleWidget(widget, Client) -{ - Q_ASSERT(qobject_cast(widget)); -} - -QString QAccessibleAbstractScrollArea::text(Text textType, int child) const -{ - if (child == Self) - return QAccessibleWidget::text(textType, 0); - QWidgetList children = accessibleChildren(); - if (child < 1 || child > children.count()) - return QString(); - QAccessibleInterface *childInterface = queryAccessibleInterface(children.at(child - 1)); - if (!childInterface) - return QString(); - QString string = childInterface->text(textType, 0); - delete childInterface; - return string; -} - -void QAccessibleAbstractScrollArea::setText(Text textType, int child, const QString &text) -{ - if (text.isEmpty()) - return; - if (child == 0) { - QAccessibleWidget::setText(textType, 0, text); - return; - } - QWidgetList children = accessibleChildren(); - if (child < 1 || child > children.count()) - return; - QAccessibleInterface *childInterface = queryAccessibleInterface(children.at(child - 1)); - if (!childInterface) - return; - childInterface->setText(textType, 0, text); - delete childInterface; -} - -QAccessible::State QAccessibleAbstractScrollArea::state(int child) const -{ - if (child == Self) - return QAccessibleWidget::state(child); - QWidgetList children = accessibleChildren(); - if (child < 1 || child > children.count()) - return QAccessibleWidget::state(Self); - QAccessibleInterface *childInterface = queryAccessibleInterface(children.at(child - 1)); - if (!childInterface) - return QAccessibleWidget::state(Self); - QAccessible::State returnState = childInterface->state(0); - delete childInterface; - return returnState; -} - -QVariant QAccessibleAbstractScrollArea::invokeMethod(QAccessible::Method, int, const QVariantList &) -{ - return QVariant(); -} - -int QAccessibleAbstractScrollArea::childCount() const -{ - return accessibleChildren().count(); -} - -int QAccessibleAbstractScrollArea::indexOfChild(const QAccessibleInterface *child) const -{ - if (!child || !child->object()) - return -1; - int index = accessibleChildren().indexOf(qobject_cast(child->object())); - if (index >= 0) - return ++index; - return -1; -} - -bool QAccessibleAbstractScrollArea::isValid() const -{ - return (QAccessibleWidget::isValid() && abstractScrollArea() && abstractScrollArea()->viewport()); -} - -int QAccessibleAbstractScrollArea::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - if (!target) - return -1; - - *target = 0; - - QWidget *targetWidget = 0; - QWidget *entryWidget = 0; - - if (relation == Child || - relation == Left || relation == Up || relation == Right || relation == Down) { - QWidgetList children = accessibleChildren(); - if (entry < 0 || entry > children.count()) - return -1; - - if (entry == Self) - entryWidget = abstractScrollArea(); - else - entryWidget = children.at(entry - 1); - AbstractScrollAreaElement entryElement = elementType(entryWidget); - - // Not one of the most beautiful switches I've ever seen, but I believe it has - // to be like this since each case need special handling. - // It might be possible to make it more general, but I'll leave that as an exercise - // to the reader. :-) - switch (relation) { - case Child: - if (entry > 0) - targetWidget = children.at(entry - 1); - break; - case Left: - if (entry < 1) - break; - switch (entryElement) { - case Viewport: - if (!isLeftToRight()) - targetWidget = abstractScrollArea()->verticalScrollBar(); - break; - case HorizontalContainer: - if (!isLeftToRight()) - targetWidget = abstractScrollArea()->cornerWidget(); - break; - case VerticalContainer: - if (isLeftToRight()) - targetWidget = abstractScrollArea()->viewport(); - break; - case CornerWidget: - if (isLeftToRight()) - targetWidget = abstractScrollArea()->horizontalScrollBar(); - break; - default: - break; - } - break; - case Right: - if (entry < 1) - break; - switch (entryElement) { - case Viewport: - if (isLeftToRight()) - targetWidget = abstractScrollArea()->verticalScrollBar(); - break; - case HorizontalContainer: - targetWidget = abstractScrollArea()->cornerWidget(); - break; - case VerticalContainer: - if (!isLeftToRight()) - targetWidget = abstractScrollArea()->viewport(); - break; - case CornerWidget: - if (!isLeftToRight()) - targetWidget = abstractScrollArea()->horizontalScrollBar(); - break; - default: - break; - } - break; - case Up: - if (entry < 1) - break; - switch (entryElement) { - case HorizontalContainer: - targetWidget = abstractScrollArea()->viewport(); - break; - case CornerWidget: - targetWidget = abstractScrollArea()->verticalScrollBar(); - break; - default: - break; - } - break; - case Down: - if (entry < 1) - break; - switch (entryElement) { - case Viewport: - targetWidget = abstractScrollArea()->horizontalScrollBar(); - break; - case VerticalContainer: - targetWidget = abstractScrollArea()->cornerWidget(); - break; - default: - break; - } - break; - default: - break; - } - } else { - return QAccessibleWidget::navigate(relation, entry, target); - } - - if (qobject_cast(targetWidget)) - targetWidget = targetWidget->parentWidget(); - *target = QAccessible::queryAccessibleInterface(targetWidget); - return *target ? 0: -1; -} - -QRect QAccessibleAbstractScrollArea::rect(int child) const -{ - if (!abstractScrollArea()->isVisible()) - return QRect(); - if (child == Self) - return QAccessibleWidget::rect(child); - QWidgetList children = accessibleChildren(); - if (child < 1 || child > children.count()) - return QRect(); - const QWidget *childWidget = children.at(child - 1); - if (!childWidget->isVisible()) - return QRect(); - return QRect(childWidget->mapToGlobal(QPoint(0, 0)), childWidget->size()); -} - -int QAccessibleAbstractScrollArea::childAt(int x, int y) const -{ - if (!abstractScrollArea()->isVisible()) - return -1; -#if 0 - const QRect globalSelfGeometry = rect(Self); - if (!globalSelfGeometry.isValid() || !globalSelfGeometry.contains(QPoint(x, y))) - return -1; - const QWidgetList children = accessibleChildren(); - for (int i = 0; i < children.count(); ++i) { - const QWidget *child = children.at(i); - const QRect globalChildGeometry = QRect(child->mapToGlobal(QPoint(0, 0)), child->size()); - if (globalChildGeometry.contains(QPoint(x, y))) { - return ++i; - } - } - return 0; -#else - for (int i = childCount(); i >= 0; --i) { - if (rect(i).contains(x, y)) - return i; - } - return -1; -#endif -} - -QAbstractScrollArea *QAccessibleAbstractScrollArea::abstractScrollArea() const -{ - return static_cast(object()); -} - -QWidgetList QAccessibleAbstractScrollArea::accessibleChildren() const -{ - QWidgetList children; - - // Viewport. - QWidget * viewport = abstractScrollArea()->viewport(); - if (viewport) - children.append(viewport); - - // Horizontal scrollBar container. - QScrollBar *horizontalScrollBar = abstractScrollArea()->horizontalScrollBar(); - if (horizontalScrollBar && horizontalScrollBar->isVisible()) { - children.append(horizontalScrollBar->parentWidget()); - } - - // Vertical scrollBar container. - QScrollBar *verticalScrollBar = abstractScrollArea()->verticalScrollBar(); - if (verticalScrollBar && verticalScrollBar->isVisible()) { - children.append(verticalScrollBar->parentWidget()); - } - - // CornerWidget. - QWidget *cornerWidget = abstractScrollArea()->cornerWidget(); - if (cornerWidget && cornerWidget->isVisible()) - children.append(cornerWidget); - - return children; -} - -QAccessibleAbstractScrollArea::AbstractScrollAreaElement -QAccessibleAbstractScrollArea::elementType(QWidget *widget) const -{ - if (!widget) - return Undefined; - - if (widget == abstractScrollArea()) - return Self; - if (widget == abstractScrollArea()->viewport()) - return Viewport; - if (widget->objectName() == QLatin1String("qt_scrollarea_hcontainer")) - return HorizontalContainer; - if (widget->objectName() == QLatin1String("qt_scrollarea_vcontainer")) - return VerticalContainer; - if (widget == abstractScrollArea()->cornerWidget()) - return CornerWidget; - - return Undefined; -} - -bool QAccessibleAbstractScrollArea::isLeftToRight() const -{ - return abstractScrollArea()->isLeftToRight(); -} - -// ======================= QAccessibleScrollArea =========================== -QAccessibleScrollArea::QAccessibleScrollArea(QWidget *widget) - : QAccessibleAbstractScrollArea(widget) -{ - Q_ASSERT(qobject_cast(widget)); -} -#endif // QT_NO_SCROLLAREA - -QT_END_NAMESPACE - -#endif // QT_NO_ACCESSIBILITY diff --git a/src/plugins/accessible/widgets/complexwidgets.h b/src/plugins/accessible/widgets/complexwidgets.h deleted file mode 100644 index c95f6e006..000000000 --- a/src/plugins/accessible/widgets/complexwidgets.h +++ /dev/null @@ -1,277 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the plugins of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef COMPLEXWIDGETS_H -#define COMPLEXWIDGETS_H - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACCESSIBILITY - -class QAbstractButton; -class QHeaderView; -class QTabBar; -class QComboBox; -class QTitleBar; -class QAbstractScrollArea; -class QScrollArea; - -#ifndef QT_NO_SCROLLAREA -class QAccessibleAbstractScrollArea : public QAccessibleWidget -{ -public: - explicit QAccessibleAbstractScrollArea(QWidget *widget); - - enum AbstractScrollAreaElement { - Self = 0, - Viewport, - HorizontalContainer, - VerticalContainer, - CornerWidget, - Undefined - }; - - QString text(Text textType, int child) const; - void setText(Text textType, int child, const QString &text); - State state(int child) const; - QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms); - int childCount() const; - int indexOfChild(const QAccessibleInterface *child) const; - bool isValid() const; - int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const; - QRect rect(int child) const; - int childAt(int x, int y) const; - -//protected: - QAbstractScrollArea *abstractScrollArea() const; - -private: - QWidgetList accessibleChildren() const; - AbstractScrollAreaElement elementType(QWidget *widget) const; - bool isLeftToRight() const; -}; - -class QAccessibleScrollArea : public QAccessibleAbstractScrollArea -{ -public: - explicit QAccessibleScrollArea(QWidget *widget); -}; - -#endif // QT_NO_SCROLLAREA - -#ifndef QT_NO_ITEMVIEWS -class QAccessibleHeader : public QAccessibleWidget -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleHeader(QWidget *w); - - int childCount() const; - - QRect rect(int child) const; - QString text(Text t, int child) const; - Role role(int child) const; - State state(int child) const; - -protected: - QHeaderView *header() const; -}; - -class QAccessibleItemRow: public QAccessibleInterface -{ - friend class QAccessibleItemView; -public: - QAccessibleItemRow(QAbstractItemView *view, const QModelIndex &index = QModelIndex(), bool isHeader = false); - QRect rect(int child) const; - QString text(Text t, int child) const; - void setText(Text t, int child, const QString &text); - bool isValid() const; - QObject *object() const; - Role role(int child) const; - State state(int child) const; - - int childCount() const; - int indexOfChild(const QAccessibleInterface *) const; - QList children() const; - - Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const; - int childAt(int x, int y) const; - int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const; - - int userActionCount(int child) const; - QString actionText(int action, Text t, int child) const; - bool doAction(int action, int child, const QVariantList ¶ms = QVariantList()); - - QModelIndex childIndex(int child) const; - - QHeaderView *horizontalHeader() const; //used by QAccessibleItemView -private: - static QAbstractItemView::CursorAction toCursorAction(Relation rel); - int logicalFromChild(QHeaderView *header, int child) const; - int treeLevel() const; - QHeaderView *verticalHeader() const; - QString text_helper(int child) const; - - QPersistentModelIndex row; - QPointer view; - bool m_header; -}; - -class QAccessibleItemView: public QAccessibleAbstractScrollArea, public QAccessibleTableInterface -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleItemView(QWidget *w); - - QObject *object() const; - Role role(int child) const; - State state(int child) const; - QRect rect(int child) const; - int childAt(int x, int y) const; - int childCount() const; - QString text(Text t, int child) const; - void setText(Text t, int child, const QString &text); - int indexOfChild(const QAccessibleInterface *iface) const; - - QModelIndex childIndex(int child) const; - int entryFromIndex(const QModelIndex &index) const; - bool isValid() const; - int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const; - - QAccessibleInterface *accessibleAt(int row, int column); - QAccessibleInterface *caption(); - int childIndex(int rowIndex, int columnIndex); - QString columnDescription(int column); - int columnSpan(int row, int column); - QAccessibleInterface *columnHeader(); - int columnIndex(int childIndex); - int columnCount(); - int rowCount(); - int selectedColumnCount(); - int selectedRowCount(); - QString rowDescription(int row); - int rowSpan(int row, int column); - QAccessibleInterface *rowHeader(); - int rowIndex(int childIndex); - int selectedRows(int maxRows, QList *rows); - int selectedColumns(int maxColumns, QList *columns); - QAccessibleInterface *summary(); - bool isColumnSelected(int column); - bool isRowSelected(int row); - bool isSelected(int row, int column); - void selectRow(int row); - void selectColumn(int column); - void unselectRow(int row); - void unselectColumn(int column); - void cellAtIndex(int index, int *row, int *column, int *rowSpan, - int *columnSpan, bool *isSelected); - - QHeaderView *horizontalHeader() const; - QHeaderView *verticalHeader() const; - bool isValidChildRole(QAccessible::Role role) const; - -protected: - QAbstractItemView *itemView() const; - QModelIndex index(int row, int column) const; - -private: - inline bool atViewport() const { - return atVP; - }; - QAccessible::Role expectedRoleOfChildren() const; - - bool atVP; -}; - -#endif - -#ifndef QT_NO_TABBAR -class QAccessibleTabBar : public QAccessibleWidget -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleTabBar(QWidget *w); - - int childCount() const; - - QRect rect(int child) const; - QString text(Text t, int child) const; - Role role(int child) const; - State state(int child) const; - int navigate(RelationFlag relation, int entry, - QAccessibleInterface **target) const; - - bool doAction(int action, int child, const QVariantList ¶ms); - QString actionText(int action, Text t, int child) const; - int userActionCount(int child) const; - bool setSelected(int child, bool on, bool extend); - QVector selection() const; - -protected: - QTabBar *tabBar() const; - -private: - QAbstractButton *button(int child) const; -}; -#endif // QT_NO_TABBAR - -#ifndef QT_NO_COMBOBOX -class QAccessibleComboBox : public QAccessibleWidget -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleComboBox(QWidget *w); - - enum ComboBoxElements { - ComboBoxSelf = 0, - CurrentText, - OpenList, - PopupList - }; - - int childCount() const; - int childAt(int x, int y) const; - int indexOfChild(const QAccessibleInterface *child) const; - int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const; - - QString text(Text t, int child) const; - QRect rect(int child) const; - Role role(int child) const; - State state(int child) const; - - bool doAction(int action, int child, const QVariantList ¶ms); - QString actionText(int action, Text t, int child) const; - -protected: - QComboBox *comboBox() const; -}; -#endif // QT_NO_COMBOBOX - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - -#endif // COMPLEXWIDGETS_H diff --git a/src/plugins/accessible/widgets/itemviews.cpp b/src/plugins/accessible/widgets/itemviews.cpp deleted file mode 100644 index 5d8d27a49..000000000 --- a/src/plugins/accessible/widgets/itemviews.cpp +++ /dev/null @@ -1,1080 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the plugins of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "itemviews.h" - -#include "qheaderview.h" -#include "qtableview.h" -#include "qlistview.h" -#include "qtreeview.h" -#include "qtreewidget_p.h" -#include "qaccessible2.h" -#include - -#ifndef QT_NO_ACCESSIBILITY - -QT_BEGIN_NAMESPACE - -QString Q_GUI_EXPORT qt_accStripAmp(const QString &text); - -#ifndef QT_NO_ITEMVIEWS -/* -Implementation of the IAccessible2 table2 interface. Much simpler than -the other table interfaces since there is only the main table and cells: - -TABLE/LIST/TREE - |- HEADER CELL - |- CELL - |- CELL - ... -*/ - -QAbstractItemView *QAccessibleTable2::view() const -{ - return qobject_cast(object()); -} - -int QAccessibleTable2::logicalIndex(const QModelIndex &index) const -{ - if (!view()->model() || !index.isValid()) - return -1; - int vHeader = verticalHeader() ? 1 : 0; - int hHeader = horizontalHeader() ? 1 : 0; - // row * number columns + column + 1 for one based counting - return (index.row() + hHeader)*(index.model()->columnCount() + vHeader) + (index.column() + vHeader) + 1; -} - -QAccessibleInterface *QAccessibleTable2::childFromLogical(int logicalIndex) const -{ - if (!view()->model()) - return 0; - - logicalIndex--; // one based counting ftw - int vHeader = verticalHeader() ? 1 : 0; - int hHeader = horizontalHeader() ? 1 : 0; - - int columns = view()->model()->columnCount() + vHeader; - - int row = logicalIndex / columns; - int column = logicalIndex % columns; - - if (vHeader) { - if (column == 0) { - if (row == 0) { - return new QAccessibleTable2CornerButton(view()); - } - return new QAccessibleTable2HeaderCell(view(), row-1, Qt::Vertical); - } - --column; - } - if (hHeader) { - if (row == 0) { - return new QAccessibleTable2HeaderCell(view(), column, Qt::Horizontal); - } - --row; - } - - QModelIndex index = view()->model()->index(row, column, view()->rootIndex()); - if (!index.isValid()) { - qWarning() << "QAccessibleTable2::childFromLogical: Invalid index at: " << row << column; - return 0; - } - return new QAccessibleTable2Cell(view(), index, cellRole()); -} - -QAccessibleTable2::QAccessibleTable2(QWidget *w) - : QAccessibleObject(w) -{ - Q_ASSERT(view()); - - if (qobject_cast(view())) { - m_role = QAccessible::Table; - } else if (qobject_cast(view())) { - m_role = QAccessible::Tree; - } else if (qobject_cast(view())) { - m_role = QAccessible::List; - } else { - // is this our best guess? - m_role = QAccessible::Table; - } -} - -QAccessibleTable2::~QAccessibleTable2() -{ -} - -QHeaderView *QAccessibleTable2::horizontalHeader() const -{ - QHeaderView *header = 0; - if (false) { -#ifndef QT_NO_TABLEVIEW - } else if (const QTableView *tv = qobject_cast(view())) { - header = tv->horizontalHeader(); -#endif -#ifndef QT_NO_TREEVIEW - } else if (const QTreeView *tv = qobject_cast(view())) { - header = tv->header(); -#endif - } - return header; -} - -QHeaderView *QAccessibleTable2::verticalHeader() const -{ - QHeaderView *header = 0; - if (false) { -#ifndef QT_NO_TABLEVIEW - } else if (const QTableView *tv = qobject_cast(view())) { - header = tv->verticalHeader(); -#endif - } - return header; -} - -void QAccessibleTable2::modelReset() -{} - -void QAccessibleTable2::rowsInserted(const QModelIndex &, int first, int last) -{ - lastChange.firstRow = first; - lastChange.lastRow = last; - lastChange.firstColumn = 0; - lastChange.lastColumn = 0; - lastChange.type = QAccessible2::TableModelChangeInsert; -} - -void QAccessibleTable2::rowsRemoved(const QModelIndex &, int first, int last) -{ - lastChange.firstRow = first; - lastChange.lastRow = last; - lastChange.firstColumn = 0; - lastChange.lastColumn = 0; - lastChange.type = QAccessible2::TableModelChangeDelete; -} - -void QAccessibleTable2::columnsInserted(const QModelIndex &, int first, int last) -{ - lastChange.firstRow = 0; - lastChange.lastRow = 0; - lastChange.firstColumn = first; - lastChange.lastColumn = last; - lastChange.type = QAccessible2::TableModelChangeInsert; -} - -void QAccessibleTable2::columnsRemoved(const QModelIndex &, int first, int last) -{ - lastChange.firstRow = 0; - lastChange.lastRow = 0; - lastChange.firstColumn = first; - lastChange.lastColumn = last; - lastChange.type = QAccessible2::TableModelChangeDelete; -} - -void QAccessibleTable2::rowsMoved( const QModelIndex &, int, int, const QModelIndex &, int) -{ - lastChange.firstRow = 0; - lastChange.lastRow = 0; - lastChange.firstColumn = 0; - lastChange.lastColumn = 0; - lastChange.type = QAccessible2::TableModelChangeUpdate; -} - -void QAccessibleTable2::columnsMoved( const QModelIndex &, int, int, const QModelIndex &, int) -{ - lastChange.firstRow = 0; - lastChange.lastRow = 0; - lastChange.firstColumn = 0; - lastChange.lastColumn = 0; - lastChange.type = QAccessible2::TableModelChangeUpdate; -} - -QAccessibleTable2Cell *QAccessibleTable2::cell(const QModelIndex &index) const -{ - if (index.isValid()) - return new QAccessibleTable2Cell(view(), index, cellRole()); - return 0; -} - -QAccessibleTable2CellInterface *QAccessibleTable2::cellAt(int row, int column) const -{ - if (!view()->model()) - return 0; - Q_ASSERT(role(0) != QAccessible::Tree); - QModelIndex index = view()->model()->index(row, column, view()->rootIndex()); - //Q_ASSERT(index.isValid()); - if (!index.isValid()) { - qWarning() << "QAccessibleTable2::cellAt: invalid index: " << index << " for " << view(); - return 0; - } - return cell(index); -} - -QAccessibleInterface *QAccessibleTable2::caption() const -{ - return 0; -} - -QString QAccessibleTable2::columnDescription(int column) const -{ - if (!view()->model()) - return QString(); - return view()->model()->headerData(column, Qt::Horizontal).toString(); -} - -int QAccessibleTable2::columnCount() const -{ - if (!view()->model()) - return 0; - return view()->model()->columnCount(); -} - -int QAccessibleTable2::rowCount() const -{ - if (!view()->model()) - return 0; - return view()->model()->rowCount(); -} - -int QAccessibleTable2::selectedCellCount() const -{ - if (!view()->selectionModel()) - return 0; - return view()->selectionModel()->selectedIndexes().count(); -} - -int QAccessibleTable2::selectedColumnCount() const -{ - if (!view()->selectionModel()) - return 0; - return view()->selectionModel()->selectedColumns().count(); -} - -int QAccessibleTable2::selectedRowCount() const -{ - if (!view()->selectionModel()) - return 0; - return view()->selectionModel()->selectedRows().count(); -} - -QString QAccessibleTable2::rowDescription(int row) const -{ - if (!view()->model()) - return QString(); - return view()->model()->headerData(row, Qt::Vertical).toString(); -} - -QList QAccessibleTable2::selectedCells() const -{ - QList cells; - if (!view()->selectionModel()) - return cells; - Q_FOREACH (const QModelIndex &index, view()->selectionModel()->selectedIndexes()) { - cells.append(cell(index)); - } - return cells; -} - -QList QAccessibleTable2::selectedColumns() const -{ - QList columns; - if (!view()->selectionModel()) - return columns; - Q_FOREACH (const QModelIndex &index, view()->selectionModel()->selectedColumns()) { - columns.append(index.column()); - } - return columns; -} - -QList QAccessibleTable2::selectedRows() const -{ - if (!view()->selectionModel()) - return QList(); - QList rows; - Q_FOREACH (const QModelIndex &index, view()->selectionModel()->selectedRows()) { - rows.append(index.row()); - } - return rows; -} - -QAccessibleInterface *QAccessibleTable2::summary() const -{ - return 0; -} - -bool QAccessibleTable2::isColumnSelected(int column) const -{ - if (!view()->selectionModel()) - return false; - return view()->selectionModel()->isColumnSelected(column, QModelIndex()); -} - -bool QAccessibleTable2::isRowSelected(int row) const -{ - if (!view()->selectionModel()) - return false; - return view()->selectionModel()->isRowSelected(row, QModelIndex()); -} - -bool QAccessibleTable2::selectRow(int row) -{ - if (!view()->model() || !view()->selectionModel()) - return false; - QModelIndex index = view()->model()->index(row, 0, view()->rootIndex()); - if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection) - return false; - view()->selectionModel()->select(index, QItemSelectionModel::Select); - return true; -} - -bool QAccessibleTable2::selectColumn(int column) -{ - if (!view()->model() || !view()->selectionModel()) - return false; - QModelIndex index = view()->model()->index(0, column, view()->rootIndex()); - if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection) - return false; - view()->selectionModel()->select(index, QItemSelectionModel::Select); - return true; -} - -bool QAccessibleTable2::unselectRow(int row) -{ - if (!view()->model() || !view()->selectionModel()) - return false; - QModelIndex index = view()->model()->index(row, 0, view()->rootIndex()); - if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection) - return false; - view()->selectionModel()->select(index, QItemSelectionModel::Deselect); - return true; -} - -bool QAccessibleTable2::unselectColumn(int column) -{ - if (!view()->model() || !view()->selectionModel()) - return false; - QModelIndex index = view()->model()->index(0, column, view()->rootIndex()); - if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection) - return false; - view()->selectionModel()->select(index, QItemSelectionModel::Columns | QItemSelectionModel::Deselect); - return true; -} - -QAccessible2::TableModelChange QAccessibleTable2::modelChange() const -{ - QAccessible2::TableModelChange change; - // FIXME - return change; -} - -QAccessible::Role QAccessibleTable2::role(int child) const -{ - Q_ASSERT(child >= 0); - if (child > 0) - return QAccessible::Cell; - return m_role; -} - -QAccessible::State QAccessibleTable2::state(int child) const -{ - Q_ASSERT(child == 0); - return QAccessible::Normal; -} - -int QAccessibleTable2::childAt(int x, int y) const -{ - QPoint viewportOffset = view()->viewport()->mapTo(view(), QPoint(0,0)); - QPoint indexPosition = view()->mapFromGlobal(QPoint(x, y) - viewportOffset); - // FIXME: if indexPosition < 0 in one coordinate, return header - - QModelIndex index = view()->indexAt(indexPosition); - if (index.isValid()) { - return logicalIndex(index); - } - return -1; -} - -int QAccessibleTable2::childCount() const -{ - if (!view()->model()) - return 0; - int vHeader = verticalHeader() ? 1 : 0; - int hHeader = horizontalHeader() ? 1 : 0; - return (view()->model()->rowCount()+hHeader) * (view()->model()->columnCount()+vHeader); -} - -int QAccessibleTable2::indexOfChild(const QAccessibleInterface *iface) const -{ - if (!view()->model()) - return -1; - Q_ASSERT(iface->role(0) != QAccessible::TreeItem); // should be handled by tree class - if (iface->role(0) == QAccessible::Cell || iface->role(0) == QAccessible::ListItem) { - const QAccessibleTable2Cell* cell = static_cast(iface); - return logicalIndex(cell->m_index); - } else if (iface->role(0) == QAccessible::ColumnHeader){ - const QAccessibleTable2HeaderCell* cell = static_cast(iface); - return cell->index + (verticalHeader() ? 1 : 0) + 1; - } else if (iface->role(0) == QAccessible::RowHeader){ - const QAccessibleTable2HeaderCell* cell = static_cast(iface); - return (cell->index+1) * (view()->model()->columnCount()+1) + 1; - } else if (iface->role(0) == QAccessible::Pane) { - return 1; // corner button - } else { - qWarning() << "WARNING QAccessibleTable2::indexOfChild Fix my children..." - << iface->role(0) << iface->text(QAccessible::Name, 0); - } - // FIXME: we are in denial of our children. this should stop. - return -1; -} - -QString QAccessibleTable2::text(Text t, int child) const -{ - Q_ASSERT(child == 0); - if (t == QAccessible::Description) - return view()->accessibleDescription(); - return view()->accessibleName(); -} - -QRect QAccessibleTable2::rect(int child) const -{ - Q_ASSERT(!child); - if (!view()->isVisible()) - return QRect(); - QPoint pos = view()->mapToGlobal(QPoint(0, 0)); - return QRect(pos.x(), pos.y(), view()->width(), view()->height()); -} - -int QAccessibleTable2::navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const -{ - *iface = 0; - if ((index < 0) || (!view()->model())) - return -1; - - switch (relation) { - case Ancestor: { - if (index == 1 && view()->parent()) { - *iface = QAccessible::queryAccessibleInterface(view()->parent()); - if (*iface) - return 0; - } - break; - } - case QAccessible::Child: { - Q_ASSERT(index > 0); - *iface = childFromLogical(index); - if (*iface) { - return 0; - } - break; - } - default: - break; - } - return -1; -} - -QAccessible::Relation QAccessibleTable2::relationTo(int, const QAccessibleInterface *, int) const -{ - return QAccessible::Unrelated; -} - -#ifndef QT_NO_ACTION -int QAccessibleTable2::userActionCount(int) const -{ - return 0; -} -QString QAccessibleTable2::actionText(int, Text, int) const -{ - return QString(); -} -bool QAccessibleTable2::doAction(int, int, const QVariantList &) -{ - return false; -} -#endif - - -// TREE VIEW - -QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const -{ - if (!isValid() || !view()->model()) - return QModelIndex(); - - const QTreeView *treeView = qobject_cast(view()); - if (treeView->d_func()->viewItems.count() <= row) { - qWarning() << "QAccessibleTree::indexFromLogical: invalid index: " << row << column << " for " << treeView; - return QModelIndex(); - } - QModelIndex modelIndex = treeView->d_func()->viewItems.at(row).index; - - if (modelIndex.isValid() && column > 0) { - modelIndex = view()->model()->index(modelIndex.row(), column, modelIndex.parent()); - } - return modelIndex; -} - -int QAccessibleTree::childAt(int x, int y) const -{ - QPoint viewportOffset = view()->viewport()->mapTo(view(), QPoint(0,0)); - QPoint indexPosition = view()->mapFromGlobal(QPoint(x, y) - viewportOffset); - - QModelIndex index = view()->indexAt(indexPosition); - if (!index.isValid()) - return -1; - - const QTreeView *treeView = qobject_cast(view()); - int row = treeView->d_func()->viewIndex(index) + (horizontalHeader() ? 1 : 0); - int column = index.column(); - - int i = row * view()->model()->columnCount() + column + 1; - Q_ASSERT(i > view()->model()->columnCount()); - return i; -} - -int QAccessibleTree::childCount() const -{ - const QTreeView *treeView = qobject_cast(view()); - Q_ASSERT(treeView); - if (!view()->model()) - return 0; - - int hHeader = horizontalHeader() ? 1 : 0; - return (treeView->d_func()->viewItems.count() + hHeader)* view()->model()->columnCount(); -} - -int QAccessibleTree::rowCount() const -{ - const QTreeView *treeView = qobject_cast(view()); - Q_ASSERT(treeView); - return treeView->d_func()->viewItems.count(); -} - -int QAccessibleTree::indexOfChild(const QAccessibleInterface *iface) const -{ - if (!view()->model()) - return -1; - if (iface->role(0) == QAccessible::TreeItem) { - const QAccessibleTable2Cell* cell = static_cast(iface); - const QTreeView *treeView = qobject_cast(view()); - Q_ASSERT(treeView); - int row = treeView->d_func()->viewIndex(cell->m_index) + (horizontalHeader() ? 1 : 0); - int column = cell->m_index.column(); - - int index = row * view()->model()->columnCount() + column + 1; - //qDebug() << "QAccessibleTree::indexOfChild r " << row << " c " << column << "index " << index; - Q_ASSERT(index > treeView->model()->columnCount()); - return index; - } else if (iface->role(0) == QAccessible::ColumnHeader){ - const QAccessibleTable2HeaderCell* cell = static_cast(iface); - //qDebug() << "QAccessibleTree::indexOfChild header " << cell->index << "is: " << cell->index + 1; - return cell->index + 1; - } else { - qWarning() << "WARNING QAccessibleTable2::indexOfChild invalid child" - << iface->role(0) << iface->text(QAccessible::Name, 0); - } - // FIXME: add scrollbars and don't just ignore them - return -1; -} - -int QAccessibleTree::navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const -{ - *iface = 0; - if ((index < 0) || (!view()->model())) - return -1; - - switch (relation) { - case QAccessible::Child: { - Q_ASSERT(index > 0); - --index; - int hHeader = horizontalHeader() ? 1 : 0; - - if (hHeader) { - if (index < view()->model()->columnCount()) { - *iface = new QAccessibleTable2HeaderCell(view(), index, Qt::Horizontal); - return 0; - } else { - index -= view()->model()->columnCount(); - } - } - - int row = index / view()->model()->columnCount(); - int column = index % view()->model()->columnCount(); - QModelIndex modelIndex = indexFromLogical(row, column); - if (modelIndex.isValid()) { - *iface = cell(modelIndex); - return 0; - } - return -1; - } - default: - break; - } - // handle everything except child - return QAccessibleTable2::navigate(relation, index, iface); -} - -QAccessible::Relation QAccessibleTree::relationTo(int, const QAccessibleInterface *, int) const -{ - return QAccessible::Unrelated; -} - -QAccessibleTable2CellInterface *QAccessibleTree::cellAt(int row, int column) const -{ - QModelIndex index = indexFromLogical(row, column); - if (!index.isValid()) { - qWarning() << "Requested invalid tree cell: " << row << column; - return 0; - } - return new QAccessibleTable2Cell(view(), index, cellRole()); -} - -QString QAccessibleTree::rowDescription(int) const -{ - return QString(); // no headers for rows in trees -} - -bool QAccessibleTree::isRowSelected(int row) const -{ - if (!view()->selectionModel()) - return false; - QModelIndex index = indexFromLogical(row); - return view()->selectionModel()->isRowSelected(index.row(), index.parent()); -} - -bool QAccessibleTree::selectRow(int row) -{ - if (!view()->selectionModel()) - return false; - QModelIndex index = indexFromLogical(row); - if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection) - return false; - view()->selectionModel()->select(index, QItemSelectionModel::Select); - return true; -} - -// TABLE CELL - -QAccessibleTable2Cell::QAccessibleTable2Cell(QAbstractItemView *view_, const QModelIndex &index_, QAccessible::Role role_) - : /* QAccessibleSimpleEditableTextInterface(this), */ view(view_), m_index(index_), m_role(role_) -{ - Q_ASSERT(index_.isValid()); -} - -int QAccessibleTable2Cell::columnExtent() const { return 1; } -int QAccessibleTable2Cell::rowExtent() const { return 1; } - -QList QAccessibleTable2Cell::rowHeaderCells() const -{ - QList headerCell; - if (verticalHeader()) { - headerCell.append(new QAccessibleTable2HeaderCell(view, m_index.row(), Qt::Vertical)); - } - return headerCell; -} - -QList QAccessibleTable2Cell::columnHeaderCells() const -{ - QList headerCell; - if (horizontalHeader()) { - headerCell.append(new QAccessibleTable2HeaderCell(view, m_index.column(), Qt::Horizontal)); - } - return headerCell; -} - -QHeaderView *QAccessibleTable2Cell::horizontalHeader() const -{ - QHeaderView *header = 0; - - if (false) { -#ifndef QT_NO_TABLEVIEW - } else if (const QTableView *tv = qobject_cast(view)) { - header = tv->horizontalHeader(); -#endif -#ifndef QT_NO_TREEVIEW - } else if (const QTreeView *tv = qobject_cast(view)) { - header = tv->header(); -#endif - } - - return header; -} - -QHeaderView *QAccessibleTable2Cell::verticalHeader() const -{ - QHeaderView *header = 0; -#ifndef QT_NO_TABLEVIEW - if (const QTableView *tv = qobject_cast(view)) - header = tv->verticalHeader(); -#endif - return header; -} - -int QAccessibleTable2Cell::columnIndex() const -{ - return m_index.column(); -} - -int QAccessibleTable2Cell::rowIndex() const -{ - if (role(0) == QAccessible::TreeItem) { - const QTreeView *treeView = qobject_cast(view); - Q_ASSERT(treeView); - int row = treeView->d_func()->viewIndex(m_index); - return row; - } - return m_index.row(); -} - -bool QAccessibleTable2Cell::isSelected() const -{ - return view->selectionModel()->isSelected(m_index); -} - -void QAccessibleTable2Cell::rowColumnExtents(int *row, int *column, int *rowExtents, int *columnExtents, bool *selected) const -{ - *row = m_index.row(); - *column = m_index.column(); - *rowExtents = 1; - *columnExtents = 1; - *selected = isSelected(); -} - -QAccessibleTable2Interface* QAccessibleTable2Cell::table() const -{ - return QAccessible::queryAccessibleInterface(view)->table2Interface(); -} - -QAccessible::Role QAccessibleTable2Cell::role(int child) const -{ - Q_ASSERT(child == 0); - return m_role; -} - -QAccessible::State QAccessibleTable2Cell::state(int child) const -{ - Q_ASSERT(child == 0); - State st = Normal; - - QRect globalRect = view->rect(); - globalRect.translate(view->mapToGlobal(QPoint(0,0))); - if (!globalRect.intersects(rect(0))) - st |= Invisible; - - if (view->selectionModel()->isSelected(m_index)) - st |= Selected; - if (view->selectionModel()->currentIndex() == m_index) - st |= Focused; - if (m_index.model()->data(m_index, Qt::CheckStateRole).toInt() == Qt::Checked) - st |= Checked; - - Qt::ItemFlags flags = m_index.flags(); - if (flags & Qt::ItemIsSelectable) { - st |= Selectable; - st |= Focusable; - if (view->selectionMode() == QAbstractItemView::MultiSelection) - st |= MultiSelectable; - if (view->selectionMode() == QAbstractItemView::ExtendedSelection) - st |= ExtSelectable; - } - if (m_role == QAccessible::TreeItem) { - const QTreeView *treeView = qobject_cast(view); - if (treeView->isExpanded(m_index)) - st |= Expanded; - } - return st; -} - -bool QAccessibleTable2Cell::isExpandable() const -{ - return view->model()->hasChildren(m_index); -} - -QRect QAccessibleTable2Cell::rect(int child) const -{ - Q_ASSERT(child == 0); - - QRect r = view->visualRect(m_index); - - if (!r.isNull()) { - r.translate(view->viewport()->mapTo(view, QPoint(0,0))); - r.translate(view->mapToGlobal(QPoint(0, 0))); - } - return r; -} - -QString QAccessibleTable2Cell::text(Text t, int child) const -{ - Q_ASSERT(child == 0); - QAbstractItemModel *model = view->model(); - QString value; - switch (t) { - case QAccessible::Value: - case QAccessible::Name: - value = model->data(m_index, Qt::AccessibleTextRole).toString(); - if (value.isEmpty()) - value = model->data(m_index, Qt::DisplayRole).toString(); - break; - case QAccessible::Description: - value = model->data(m_index, Qt::AccessibleDescriptionRole).toString(); - break; - default: - break; - } - return value; -} - -void QAccessibleTable2Cell::setText(Text /*t*/, int child, const QString &text) -{ - Q_ASSERT(child == 0); - if (!(m_index.flags() & Qt::ItemIsEditable)) - return; - view->model()->setData(m_index, text); -} - -bool QAccessibleTable2Cell::isValid() const -{ - return view && view->model() && m_index.isValid(); -} - -int QAccessibleTable2Cell::navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const -{ - if (relation == Ancestor && index == 1) { - if (m_role == QAccessible::TreeItem) { - *iface = new QAccessibleTree(view); - } else { - *iface = new QAccessibleTable2(view); - } - return 0; - } - - *iface = 0; - if (!view) - return -1; - - switch (relation) { - - case Child: { - return -1; - } - case Sibling: - if (index > 0) { - QAccessibleInterface *parent = queryAccessibleInterface(view); - int ret = parent->navigate(QAccessible::Child, index, iface); - delete parent; - if (*iface) - return ret; - } - return -1; - -// From table1 implementation: -// case Up: -// case Down: -// case Left: -// case Right: { -// // This is in the "not so nice" category. In order to find out which item -// // is geometrically around, we have to set the current index, navigate -// // and restore the index as well as the old selection -// view()->setUpdatesEnabled(false); -// const QModelIndex oldIdx = view()->currentIndex(); -// QList kids = children(); -// const QModelIndex currentIndex = index ? kids.at(index - 1) : QModelIndex(row); -// const QItemSelection oldSelection = view()->selectionModel()->selection(); -// view()->setCurrentIndex(currentIndex); -// const QModelIndex idx = view()->moveCursor(toCursorAction(relation), Qt::NoModifier); -// view()->setCurrentIndex(oldIdx); -// view()->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect); -// view()->setUpdatesEnabled(true); -// if (!idx.isValid()) -// return -1; - -// if (idx.parent() != row.parent() || idx.row() != row.row()) -// *iface = cell(idx); -// return index ? kids.indexOf(idx) + 1 : 0; } - default: - break; - } - - return -1; -} - -QAccessible::Relation QAccessibleTable2Cell::relationTo(int child, const QAccessibleInterface *other, int otherChild) const -{ - Q_ASSERT(child == 0); - Q_ASSERT(otherChild == 0); - // we only check for parent-child relationships in trees - if (m_role == QAccessible::TreeItem && other->role(0) == QAccessible::TreeItem) { - QModelIndex otherIndex = static_cast(other)->m_index; - // is the other our parent? - if (otherIndex.parent() == m_index) - return QAccessible::Ancestor; - // are we the other's child? - if (m_index.parent() == otherIndex) - return QAccessible::Child; - } - return QAccessible::Unrelated; -} - -#ifndef QT_NO_ACTION -int QAccessibleTable2Cell::userActionCount(int) const -{ - return 0; -} - -QString QAccessibleTable2Cell::actionText(int, Text, int) const -{ - return QString(); -} - -bool QAccessibleTable2Cell::doAction(int, int, const QVariantList &) -{ - return false; -} - -QAccessibleTable2HeaderCell::QAccessibleTable2HeaderCell(QAbstractItemView *view_, int index_, Qt::Orientation orientation_) - : view(view_), index(index_), orientation(orientation_) -{ - Q_ASSERT(index_ >= 0); -} - -QAccessible::Role QAccessibleTable2HeaderCell::role(int child) const -{ - Q_ASSERT(child == 0); - if (orientation == Qt::Horizontal) - return QAccessible::ColumnHeader; - return QAccessible::RowHeader; -} - -QAccessible::State QAccessibleTable2HeaderCell::state(int child) const -{ - Q_ASSERT(child == 0); - return QAccessible::Normal; -} - -QRect QAccessibleTable2HeaderCell::rect(int child) const -{ - Q_ASSERT(child == 0); - - QHeaderView *header = 0; - if (false) { -#ifndef QT_NO_TABLEVIEW - } else if (const QTableView *tv = qobject_cast(view)) { - if (orientation == Qt::Horizontal) { - header = tv->horizontalHeader(); - } else { - header = tv->verticalHeader(); - } -#endif -#ifndef QT_NO_TREEVIEW - } else if (const QTreeView *tv = qobject_cast(view)) { - header = tv->header(); -#endif - } - if (!header) - return QRect(); - QPoint zero = header->mapToGlobal(QPoint(0, 0)); - int sectionSize = header->sectionSize(index); - int sectionPos = header->sectionPosition(index); - return orientation == Qt::Horizontal - ? QRect(zero.x() + sectionPos, zero.y(), sectionSize, header->height()) - : QRect(zero.x(), zero.y() + sectionPos, header->width(), sectionSize); -} - -QString QAccessibleTable2HeaderCell::text(Text t, int child) const -{ - Q_ASSERT(child == 0); - QAbstractItemModel *model = view->model(); - QString value; - switch (t) { - case QAccessible::Value: - case QAccessible::Name: - value = model->headerData(index, orientation, Qt::AccessibleTextRole).toString(); - if (value.isEmpty()) - value = model->headerData(index, orientation, Qt::DisplayRole).toString(); - break; - case QAccessible::Description: - value = model->headerData(index, orientation, Qt::AccessibleDescriptionRole).toString(); - break; - default: - break; - } - return value; -} - -void QAccessibleTable2HeaderCell::setText(Text, int, const QString &) -{ - return; -} - -bool QAccessibleTable2HeaderCell::isValid() const -{ - return view && view->model() && (index >= 0) - && ((orientation == Qt::Horizontal) ? (index < view->model()->columnCount()) : (index < view->model()->rowCount())); -} - -int QAccessibleTable2HeaderCell::navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const -{ - if (relation == QAccessible::Ancestor && index == 1) { - if (false) { -#ifndef QT_NO_TREEVIEW - } else if (qobject_cast(view)) { - *iface = new QAccessibleTree(view); - return 0; -#endif - } else { - *iface = new QAccessibleTable2(view); - return 0; - } - } - *iface = 0; - return -1; -} - -QAccessible::Relation QAccessibleTable2HeaderCell::relationTo(int, const QAccessibleInterface *, int) const -{ - return QAccessible::Unrelated; -} - -#ifndef QT_NO_ACTION -int QAccessibleTable2HeaderCell::userActionCount(int) const -{ - return 0; -} - -QString QAccessibleTable2HeaderCell::actionText(int, Text, int) const -{ - return QString(); -} - -bool QAccessibleTable2HeaderCell::doAction(int, int, const QVariantList &) -{ - return false; -} -#endif - - - -#endif - -#endif // QT_NO_ITEMVIEWS - -QT_END_NAMESPACE - -#endif // QT_NO_ACCESSIBILITY diff --git a/src/plugins/accessible/widgets/itemviews.h b/src/plugins/accessible/widgets/itemviews.h deleted file mode 100644 index 6ad3bf6ef..000000000 --- a/src/plugins/accessible/widgets/itemviews.h +++ /dev/null @@ -1,301 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the plugins of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ACCESSIBLE_ITEMVIEWS_H -#define ACCESSIBLE_ITEMVIEWS_H - -#include "QtCore/qpointer.h" - -#include -#include -#include -#include -#include - - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACCESSIBILITY - -#ifndef QT_NO_ITEMVIEWS - -class QAccessibleTable2Cell; -class QAccessibleTable2HeaderCell; - -class QAccessibleTable2 :public QAccessibleTable2Interface, public QAccessibleObject -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleTable2(QWidget *w); - - virtual ~QAccessibleTable2(); - - Role role(int child) const; - State state(int child) const; - QString text(Text t, int child) const; - QRect rect(int child) const; - - int childAt(int x, int y) const; - int childCount() const; - int indexOfChild(const QAccessibleInterface *) const; - - int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const; - Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const; - -#ifndef QT_NO_ACTION - int userActionCount(int child) const; - QString actionText(int action, Text t, int child) const; - bool doAction(int action, int child, const QVariantList ¶ms); -#endif - QVariant invokeMethodEx(Method, int, const QVariantList &) { return QVariant(); } - - // table2 interface - virtual QAccessibleTable2CellInterface *cellAt(int row, int column) const; - virtual QAccessibleInterface *caption() const; - virtual QAccessibleInterface *summary() const; - virtual QString columnDescription(int column) const; - virtual QString rowDescription(int row) const; - virtual int columnCount() const; - virtual int rowCount() const; - virtual QAccessible2::TableModelChange modelChange() const; - - // selection - virtual int selectedCellCount() const; - virtual int selectedColumnCount() const; - virtual int selectedRowCount() const; - virtual QList selectedCells() const; - virtual QList selectedColumns() const; - virtual QList selectedRows() const; - virtual bool isColumnSelected(int column) const; - virtual bool isRowSelected(int row) const; - virtual bool selectRow(int row); - virtual bool selectColumn(int column); - virtual bool unselectRow(int row); - virtual bool unselectColumn(int column); - - QAbstractItemView *view() const; - -protected: - virtual void modelReset(); - virtual void rowsInserted(const QModelIndex &parent, int first, int last); - virtual void rowsRemoved(const QModelIndex &parent, int first, int last); - virtual void columnsInserted(const QModelIndex &parent, int first, int last); - virtual void columnsRemoved(const QModelIndex &parent, int first, int last); - virtual void rowsMoved( const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row); - virtual void columnsMoved( const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column); - -protected: - QAccessible2::TableModelChange lastChange; - inline QAccessibleTable2Cell *cell(const QModelIndex &index) const; - inline QAccessible::Role cellRole() const { - switch (m_role) { - case QAccessible::List: - return QAccessible::ListItem; - case QAccessible::Table: - return QAccessible::Cell; - case QAccessible::Tree: - return QAccessible::TreeItem; - default: - Q_ASSERT(false); - } - return QAccessible::NoRole; - } - - QHeaderView *horizontalHeader() const; - QHeaderView *verticalHeader() const; -private: - // the child index for a model index - inline int logicalIndex(const QModelIndex &index) const; - // the model index from the child index - QAccessibleInterface *childFromLogical(int logicalIndex) const; - QAccessible::Role m_role; -}; - -class QAccessibleTree :public QAccessibleTable2 -{ -public: - explicit QAccessibleTree(QWidget *w) - : QAccessibleTable2(w) - {} - - virtual ~QAccessibleTree() {} - - int childAt(int x, int y) const; - int childCount() const; - int indexOfChild(const QAccessibleInterface *) const; - - int rowCount() const; - - int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const; - Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const; - - // table2 interface - QAccessibleTable2CellInterface *cellAt(int row, int column) const; - QString rowDescription(int row) const; - bool isRowSelected(int row) const; - bool selectRow(int row); - -private: - QModelIndex indexFromLogical(int row, int column = 0) const; -}; - -class QAccessibleTable2Cell: public QAccessibleTable2CellInterface /*), public QAccessibleTextInterface, public QAccessibleSimpleEditableTextInterface*/ -{ -public: - QAccessibleTable2Cell(QAbstractItemView *view, const QModelIndex &m_index, QAccessible::Role role); - - QObject *object() const { return 0; } - Role role(int child) const; - State state(int child) const; - QRect rect(int child) const; - bool isValid() const; - - int childAt(int, int) const { return 0; } - int childCount() const { return 0; } - int indexOfChild(const QAccessibleInterface *) const { return -1; } - - QString text(Text t, int child) const; - void setText(Text t, int child, const QString &text); - - int navigate(RelationFlag relation, int m_index, QAccessibleInterface **iface) const; - Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const; - - bool isExpandable() const; - -#ifndef QT_NO_ACTION - int userActionCount(int child) const; - QString actionText(int action, Text t, int child) const; - bool doAction(int action, int child, const QVariantList ¶ms); -#endif - - // cell interface - virtual int columnExtent() const; - virtual QList columnHeaderCells() const; - virtual int columnIndex() const; - virtual int rowExtent() const; - virtual QList rowHeaderCells() const; - virtual int rowIndex() const; - virtual bool isSelected() const; - virtual void rowColumnExtents(int *row, int *column, int *rowExtents, int *columnExtents, bool *selected) const; - virtual QAccessibleTable2Interface* table() const; - -private: - QHeaderView *verticalHeader() const; - QHeaderView *horizontalHeader() const; - QPointer view; - QModelIndex m_index; - QAccessible::Role m_role; - -friend class QAccessibleTable2; -friend class QAccessibleTree; -}; - - -class QAccessibleTable2HeaderCell: public QAccessibleInterface /*), public QAccessibleTextInterface, public QAccessibleSimpleEditableTextInterface*/ -{ -public: - // For header cells, pass the header view in addition - QAccessibleTable2HeaderCell(QAbstractItemView *view, int index, Qt::Orientation orientation); - - QObject *object() const { return 0; } - Role role(int child) const; - State state(int child) const; - QRect rect(int child) const; - bool isValid() const; - - int childAt(int, int) const { return 0; } - int childCount() const { return 0; } - int indexOfChild(const QAccessibleInterface *) const { return -1; } - - QString text(Text t, int child) const; - void setText(Text t, int child, const QString &text); - - int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const; - Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const; - -#ifndef QT_NO_ACTION - int userActionCount(int child) const; - QString actionText(int action, Text t, int child) const; - bool doAction(int action, int child, const QVariantList ¶ms); -#endif - -private: - QAbstractItemView *view; - int index; - Qt::Orientation orientation; - -friend class QAccessibleTable2; -friend class QAccessibleTree; -}; - -// This is the corner button on the top left of a table. -// It can be used to select all cells or it is not active at all. -// For now it is ignored. -class QAccessibleTable2CornerButton: public QAccessibleInterface -{ -public: - QAccessibleTable2CornerButton(QAbstractItemView *view_) - :view(view_) - {} - - QObject *object() const { return 0; } - Role role(int child) const { Q_ASSERT(child == 0); return QAccessible::Pane; } - State state(int child) const { Q_ASSERT(child == 0); return QAccessible::Normal; } - QRect rect(int child) const { Q_ASSERT(child == 0); return QRect(); } - bool isValid() const { return true; } - - int childAt(int, int) const { return 0; } - int childCount() const { return 0; } - int indexOfChild(const QAccessibleInterface *) const { return -1; } - - QString text(Text, int) const { return QString(); } - void setText(Text, int, const QString &) {} - - int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const - { - if (relation == QAccessible::Ancestor && index == 1) { - *iface = QAccessible::queryAccessibleInterface(view); - return 0; - } - return -1; - } - Relation relationTo(int, const QAccessibleInterface *, int) const - { - return QAccessible::Unrelated; - } - -#ifndef QT_NO_ACTION - int userActionCount(int) const { return 0; } - QString actionText(int, Text, int) const { return QString(); } - bool doAction(int, int, const QVariantList &) { return false; } -#endif -private: - QAbstractItemView *view; -}; - - -#endif - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - -#endif // ACCESSIBLE_ITEMVIEWS_H diff --git a/src/plugins/accessible/widgets/main.cpp b/src/plugins/accessible/widgets/main.cpp deleted file mode 100644 index 3944fbd73..000000000 --- a/src/plugins/accessible/widgets/main.cpp +++ /dev/null @@ -1,342 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the plugins of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaccessiblewidgets.h" -#include "qaccessiblemenu.h" -#include "simplewidgets.h" -#include "rangecontrols.h" -#include "complexwidgets.h" -#include "itemviews.h" - -#include "qaccessibleplugin.h" -#include "qplugin.h" -#include "qpushbutton.h" -#include "qtoolbutton.h" -#include "qtreeview.h" -#include "qvariant.h" -#include "qaccessible.h" - -#ifndef QT_NO_ACCESSIBILITY - -QT_BEGIN_NAMESPACE - - -class AccessibleFactory : public QAccessiblePlugin -{ -public: - AccessibleFactory(); - - QStringList keys() const; - QAccessibleInterface *create(const QString &classname, QObject *object); -}; - -AccessibleFactory::AccessibleFactory() -{ -} - -QStringList AccessibleFactory::keys() const -{ - static const QStringList list = QStringList() -#ifndef QT_NO_LINEEDIT - << QLatin1String("QLineEdit") -#endif -#ifndef QT_NO_COMBOBOX - << QLatin1String("QComboBox") -#endif -#ifndef QT_NO_SPINBOX - << QLatin1String("QAbstractSpinBox") - << QLatin1String("QSpinBox") - << QLatin1String("QDoubleSpinBox") -#endif -#ifndef QT_NO_SCROLLBAR - << QLatin1String("QScrollBar") -#endif -#ifndef QT_NO_SLIDER - << QLatin1String("QSlider") -#endif - << QLatin1String("QAbstractSlider") -#ifndef QT_NO_TOOLBUTTON - << QLatin1String("QToolButton") -#endif -#ifndef QT_NO_SPLITTER - << QLatin1String("QSplitter") - << QLatin1String("QSplitterHandle") -#endif -#ifndef QT_NO_TEXTEDIT - << QLatin1String("QTextEdit") -#endif -#ifndef QT_NO_DIAL - << QLatin1String("QDial") -#endif -#ifndef QT_NO_RUBBERBAND - << QLatin1String("QRubberBand") -#endif -#ifndef QT_NO_TEXTBROWSER - << QLatin1String("QTextBrowser") -#endif -#ifndef QT_NO_SCROLLAREA - << QLatin1String("QAbstractScrollArea") - << QLatin1String("QScrollArea") -#endif -#ifndef QT_NO_CALENDARWIDGET - << QLatin1String("QCalendarWidget") -#endif - -#ifndef QT_NO_DOCKWIDGET - << QLatin1String("QDockWidget") -#endif - << QLatin1String("QPlainTextEdit") - << QLatin1String("QTipLabel") - << QLatin1String("QFrame") - << QLatin1String("QStackedWidget") - << QLatin1String("QToolBox") - << QLatin1String("QMdiArea") - << QLatin1String("QMdiSubWindow") - << QLatin1String("QWorkspace") - << QLatin1String("QDialogButtonBox") - << QLatin1String("QCheckBox") - << QLatin1String("QRadioButton") - << QLatin1String("QPushButton") - << QLatin1String("QAbstractButton") - << QLatin1String("QDialog") - << QLatin1String("QMessageBox") - << QLatin1String("QMainWindow") - << QLatin1String("QLabel") - << QLatin1String("QLCDNumber") - << QLatin1String("QGroupBox") - << QLatin1String("QStatusBar") - << QLatin1String("QProgressBar") - << QLatin1String("QMenuBar") - << QLatin1String("QMenu") - << QLatin1String("QHeaderView") - << QLatin1String("QTabBar") - << QLatin1String("QToolBar") - << QLatin1String("QWorkspaceChild") - << QLatin1String("QSizeGrip") - << QLatin1String("QAbstractItemView") - << QLatin1String("QWidget"); - return list; -} - -QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObject *object) -{ - QAccessibleInterface *iface = 0; - if (!object || !object->isWidgetType()) - return iface; - QWidget *widget = static_cast(object); - - if (false) { -#ifndef QT_NO_LINEEDIT - } else if (classname == QLatin1String("QLineEdit")) { - iface = new QAccessibleLineEdit(widget); -#endif -#ifndef QT_NO_COMBOBOX - } else if (classname == QLatin1String("QComboBox")) { - iface = new QAccessibleComboBox(widget); -#endif -#ifndef QT_NO_SPINBOX - } else if (classname == QLatin1String("QAbstractSpinBox")) { - iface = new QAccessibleAbstractSpinBox(widget); - } else if (classname == QLatin1String("QSpinBox")) { - iface = new QAccessibleSpinBox(widget); - } else if (classname == QLatin1String("QDoubleSpinBox")) { - iface = new QAccessibleDoubleSpinBox(widget); -#endif -#ifndef QT_NO_SCROLLBAR - } else if (classname == QLatin1String("QScrollBar")) { - iface = new QAccessibleScrollBar(widget); -#endif - } else if (classname == QLatin1String("QAbstractSlider")) { - iface = new QAccessibleAbstractSlider(widget); -#ifndef QT_NO_SLIDER - } else if (classname == QLatin1String("QSlider")) { - iface = new QAccessibleSlider(widget); -#endif -#ifndef QT_NO_TOOLBUTTON - } else if (classname == QLatin1String("QToolButton")) { - Role role = NoRole; -#ifndef QT_NO_MENU - QToolButton *tb = qobject_cast(widget); - if (!tb->menu()) - role = tb->isCheckable() ? CheckBox : PushButton; - else if (tb->popupMode() != QToolButton::DelayedPopup) - role = ButtonDropDown; - else -#endif - role = ButtonMenu; - iface = new QAccessibleToolButton(widget, role); -#endif // QT_NO_TOOLBUTTON - } else if (classname == QLatin1String("QCheckBox")) { - iface = new QAccessibleButton(widget, CheckBox); - } else if (classname == QLatin1String("QRadioButton")) { - iface = new QAccessibleButton(widget, RadioButton); - } else if (classname == QLatin1String("QPushButton")) { - Role role = NoRole; - QPushButton *pb = qobject_cast(widget); -#ifndef QT_NO_MENU - if (pb->menu()) - role = ButtonMenu; - else -#endif - if (pb->isCheckable()) - role = CheckBox; - else - role = PushButton; - iface = new QAccessibleButton(widget, role); - } else if (classname == QLatin1String("QAbstractButton")) { - iface = new QAccessibleButton(widget, PushButton); - } else if (classname == QLatin1String("QDialog")) { - iface = new QAccessibleWidget(widget, Dialog); - } else if (classname == QLatin1String("QMessageBox")) { - iface = new QAccessibleWidget(widget, AlertMessage); -#ifndef QT_NO_MAINWINDOW - } else if (classname == QLatin1String("QMainWindow")) { - iface = new QAccessibleMainWindow(widget); -#endif - } else if (classname == QLatin1String("QLabel") || classname == QLatin1String("QLCDNumber")) { - iface = new QAccessibleDisplay(widget); -#ifndef QT_NO_GROUPBOX - } else if (classname == QLatin1String("QGroupBox")) { - iface = new QAccessibleGroupBox(widget); -#endif - } else if (classname == QLatin1String("QStatusBar")) { - iface = new QAccessibleDisplay(widget); -#ifndef QT_NO_PROGRESSBAR - } else if (classname == QLatin1String("QProgressBar")) { - iface = new QAccessibleProgressBar(widget); -#endif - } else if (classname == QLatin1String("QToolBar")) { - iface = new QAccessibleWidget(widget, ToolBar, widget->windowTitle()); -#ifndef QT_NO_MENUBAR - } else if (classname == QLatin1String("QMenuBar")) { - iface = new QAccessibleMenuBar(widget); -#endif -#ifndef QT_NO_MENU - } else if (classname == QLatin1String("QMenu")) { - iface = new QAccessibleMenu(widget); -#endif -#ifndef QT_NO_ITEMVIEWS -#ifdef Q_WS_X11 - } else if (classname == QLatin1String("QAbstractItemView")) { - if (qobject_cast(widget)) { - iface = new QAccessibleTree(widget); - } else { - iface = new QAccessibleTable2(widget); - } - } else if (classname == QLatin1String("QWidget") - && widget->objectName() == QLatin1String("qt_scrollarea_viewport") - && qobject_cast(widget->parentWidget())) { - if (qobject_cast(widget->parentWidget())) { - iface = new QAccessibleTree(widget->parentWidget()); - } else { - iface = new QAccessibleTable2(widget->parentWidget()); - } -#else - } else if (classname == QLatin1String("QHeaderView")) { - iface = new QAccessibleHeader(widget); - } else if (classname == QLatin1String("QAbstractItemView")) { - iface = new QAccessibleItemView(widget); - } else if (classname == QLatin1String("QWidget") - && widget->objectName() == QLatin1String("qt_scrollarea_viewport") - && qobject_cast(widget->parentWidget())) { - iface = new QAccessibleItemView(widget); -#endif // Q_WS_X11 -#endif // QT_NO_ITEMVIEWS -#ifndef QT_NO_TABBAR - } else if (classname == QLatin1String("QTabBar")) { - iface = new QAccessibleTabBar(widget); -#endif - } else if (classname == QLatin1String("QWorkspaceChild")) { - iface = new QAccessibleWidget(widget, Window); - } else if (classname == QLatin1String("QSizeGrip")) { - iface = new QAccessibleWidget(widget, Grip); -#ifndef QT_NO_SPLITTER - } else if (classname == QLatin1String("QSplitter")) { - iface = new QAccessibleWidget(widget, Splitter); - } else if (classname == QLatin1String("QSplitterHandle")) { - iface = new QAccessibleWidget(widget, Grip); -#endif -#ifndef QT_NO_TEXTEDIT - } else if (classname == QLatin1String("QTextEdit")) { - iface = new QAccessibleTextEdit(widget); -#endif - } else if (classname == QLatin1String("QPlainTextEdit")) { - iface = new QAccessiblePlainTextEdit(widget); - } else if (classname == QLatin1String("QTipLabel")) { - iface = new QAccessibleDisplay(widget, ToolTip); - } else if (classname == QLatin1String("QFrame")) { - iface = new QAccessibleWidget(widget, Border); -#ifndef QT_NO_STACKEDWIDGET - } else if (classname == QLatin1String("QStackedWidget")) { - iface = new QAccessibleStackedWidget(widget); -#endif -#ifndef QT_NO_TOOLBOX - } else if (classname == QLatin1String("QToolBox")) { - iface = new QAccessibleToolBox(widget); -#endif -#ifndef QT_NO_MDIAREA - } else if (classname == QLatin1String("QMdiArea")) { - iface = new QAccessibleMdiArea(widget); - } else if (classname == QLatin1String("QMdiSubWindow")) { - iface = new QAccessibleMdiSubWindow(widget); -#endif -#ifndef QT_NO_WORKSPACE - } else if (classname == QLatin1String("QWorkspace")) { - iface = new QAccessibleWorkspace(widget); -#endif - } else if (classname == QLatin1String("QDialogButtonBox")) { - iface = new QAccessibleDialogButtonBox(widget); -#ifndef QT_NO_DIAL - } else if (classname == QLatin1String("QDial")) { - iface = new QAccessibleDial(widget); -#endif -#ifndef QT_NO_RUBBERBAND - } else if (classname == QLatin1String("QRubberBand")) { - iface = new QAccessibleWidget(widget, QAccessible::Border); -#endif -#ifndef QT_NO_TEXTBROWSER - } else if (classname == QLatin1String("QTextBrowser")) { - iface = new QAccessibleTextBrowser(widget); -#endif -#ifndef QT_NO_SCROLLAREA - } else if (classname == QLatin1String("QAbstractScrollArea")) { - iface = new QAccessibleAbstractScrollArea(widget); - } else if (classname == QLatin1String("QScrollArea")) { - iface = new QAccessibleScrollArea(widget); -#endif -#ifndef QT_NO_CALENDARWIDGET - } else if (classname == QLatin1String("QCalendarWidget")) { - iface = new QAccessibleCalendarWidget(widget); -#endif -#ifndef QT_NO_DOCKWIDGET - } else if (classname == QLatin1String("QDockWidget")) { - iface = new QAccessibleDockWidget(widget); -#endif - } - - return iface; -} - -Q_EXPORT_PLUGIN2(qtaccessiblewidgets, AccessibleFactory) - -QT_END_NAMESPACE - -#endif // QT_NO_ACCESSIBILITY diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.cpp b/src/plugins/accessible/widgets/qaccessiblemenu.cpp deleted file mode 100644 index 66c166e98..000000000 --- a/src/plugins/accessible/widgets/qaccessiblemenu.cpp +++ /dev/null @@ -1,723 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the plugins of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaccessiblemenu.h" - -#include "qmenu.h" -#include "qmenubar.h" -#include "qaction.h" -#include "qstyle.h" - -#ifndef QT_NO_ACCESSIBILITY - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_MENU - -QString Q_GUI_EXPORT qt_accStripAmp(const QString &text); -QString Q_GUI_EXPORT qt_accHotKey(const QString &text); - -QAccessibleMenu::QAccessibleMenu(QWidget *w) -: QAccessibleWidget(w) -{ - Q_ASSERT(menu()); -} - -QMenu *QAccessibleMenu::menu() const -{ - return qobject_cast(object()); -} - -int QAccessibleMenu::childCount() const -{ - return menu()->actions().count(); -} - -QRect QAccessibleMenu::rect(int child) const -{ - if (!child || child > childCount()) - return QAccessibleWidget::rect(child); - - QRect r = menu()->actionGeometry(menu()->actions()[child - 1]); - QPoint tlp = menu()->mapToGlobal(QPoint(0,0)); - - return QRect(tlp.x() + r.x(), tlp.y() + r.y(), r.width(), r.height()); -} - -int QAccessibleMenu::childAt(int x, int y) const -{ - QAction *act = menu()->actionAt(menu()->mapFromGlobal(QPoint(x,y))); - if(act && act->isSeparator()) - act = 0; - return menu()->actions().indexOf(act) + 1; -} - -QString QAccessibleMenu::text(Text t, int child) const -{ - QString tx = QAccessibleWidget::text(t, child); - if (!child && tx.size()) - return tx; - - switch (t) { - case Name: - if (!child) - return menu()->windowTitle(); - return qt_accStripAmp(menu()->actions().at(child-1)->text()); - case Help: - return child ? menu()->actions().at(child-1)->whatsThis() : tx; -#ifndef QT_NO_SHORTCUT - case Accelerator: - return child ? menu()->actions().at(child-1)->shortcut().toString() : tx; -#endif - default: - break; - } - return tx; -} - -QAccessible::Role QAccessibleMenu::role(int child) const -{ - if (!child) - return PopupMenu; - - QAction *action = menu()->actions()[child-1]; - if (action && action->isSeparator()) - return Separator; - return MenuItem; -} - -QAccessible::State QAccessibleMenu::state(int child) const -{ - State s = QAccessibleWidget::state(child); - if (!child) - return s; - - QAction *action = menu()->actions()[child-1]; - if (!action) - return s; - - if (menu()->style()->styleHint(QStyle::SH_Menu_MouseTracking)) - s |= HotTracked; - if (action->isSeparator() || !action->isEnabled()) - s |= Unavailable; - if (action->isChecked()) - s |= Checked; - if (menu()->activeAction() == action) - s |= Focused; - - return s; -} - -QString QAccessibleMenu::actionText(int action, QAccessible::Text text, int child) const -{ - if (action == QAccessible::DefaultAction && child && text == QAccessible::Name) { - QAction *a = menu()->actions().value(child-1, 0); - if (!a || a->isSeparator()) - return QString(); - if (a->menu()) { - if (a->menu()->isVisible()) - return QMenu::tr("Close"); - return QMenu::tr("Open"); - } - return QMenu::tr("Execute"); - } - - return QAccessibleWidget::actionText(action, text, child); -} - -bool QAccessibleMenu::doAction(int act, int child, const QVariantList &) -{ - if (!child || act != QAccessible::DefaultAction) - return false; - - QAction *action = menu()->actions().value(child-1, 0); - if (!action || !action->isEnabled()) - return false; - - if (action->menu() && action->menu()->isVisible()) - action->menu()->hide(); - else - menu()->setActiveAction(action); - return true; -} - -int QAccessibleMenu::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - int ret = -1; - if (entry < 0) { - *target = 0; - return ret; - } - - if (relation == Self || entry == 0) { - *target = new QAccessibleMenu(menu()); - return 0; - } - - switch (relation) { - case Child: - if (entry <= childCount()) { - *target = new QAccessibleMenuItem(menu(), menu()->actions().at( entry - 1 )); - ret = 0; - } - break; - case Ancestor: { - QAccessibleInterface *iface; - QWidget *parent = menu()->parentWidget(); - if (qobject_cast(parent) || qobject_cast(parent)) { - iface = new QAccessibleMenuItem(parent, menu()->menuAction()); - if (entry == 1) { - *target = iface; - ret = 0; - } else { - ret = iface->navigate(Ancestor, entry - 1, target); - delete iface; - } - } else { - return QAccessibleWidget::navigate(relation, entry, target); - } - break;} - default: - return QAccessibleWidget::navigate(relation, entry, target); - } - - - if (ret == -1) - *target = 0; - - return ret; - -} - -int QAccessibleMenu::indexOfChild( const QAccessibleInterface *child ) const -{ - int index = -1; - Role r = child->role(0); - if ((r == MenuItem || r == Separator) && menu()) { - index = menu()->actions().indexOf(qobject_cast(child->object())); - if (index != -1) - ++index; - } - return index; -} - -#ifndef QT_NO_MENUBAR -QAccessibleMenuBar::QAccessibleMenuBar(QWidget *w) -: QAccessibleWidget(w) -{ - Q_ASSERT(menuBar()); -} - -QMenuBar *QAccessibleMenuBar::menuBar() const -{ - return qobject_cast(object()); -} - -int QAccessibleMenuBar::childCount() const -{ - return menuBar()->actions().count(); -} - -QRect QAccessibleMenuBar::rect(int child) const -{ - if (!child) - return QAccessibleWidget::rect(child); - - QRect r = menuBar()->actionGeometry(menuBar()->actions()[child - 1]); - QPoint tlp = menuBar()->mapToGlobal(QPoint(0,0)); - return QRect(tlp.x() + r.x(), tlp.y() + r.y(), r.width(), r.height()); -} - -int QAccessibleMenuBar::childAt(int x, int y) const -{ - for (int i = childCount(); i >= 0; --i) { - if (rect(i).contains(x,y)) - return i; - } - return -1; -} - -int QAccessibleMenuBar::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - int ret = -1; - if (entry < 0) { - *target = 0; - return ret; - } - - if (relation == Self || entry == 0) { - *target = new QAccessibleMenuBar(menuBar()); - return 0; - } - - switch (relation) { - case Child: - if (entry <= childCount()) { - *target = new QAccessibleMenuItem(menuBar(), menuBar()->actions().at( entry - 1 )); - ret = 0; - } - break; - default: - return QAccessibleWidget::navigate(relation, entry, target); - } - - - if (ret == -1) - *target = 0; - - return ret; -} - -int QAccessibleMenuBar::indexOfChild( const QAccessibleInterface *child ) const -{ - int index = -1; - Role r = child->role(0); - if ((r == MenuItem || r == Separator) && menuBar()) { - index = menuBar()->actions().indexOf(qobject_cast(child->object())); - if (index != -1) - ++index; - } - return index; -} - -QString QAccessibleMenuBar::text(Text t, int child) const -{ - QString str; - - if (child) { - if (QAction *action = menuBar()->actions().value(child - 1, 0)) { - switch (t) { - case Name: - return qt_accStripAmp(action->text()); - case Accelerator: - str = qt_accHotKey(action->text()); - break; - default: - break; - } - } - } - if (str.isEmpty()) - str = QAccessibleWidget::text(t, child); - return str; -} - -QAccessible::Role QAccessibleMenuBar::role(int child) const -{ - if (!child) - return MenuBar; - - QAction *action = menuBar()->actions()[child-1]; - if (action && action->isSeparator()) - return Separator; - return MenuItem; -} - -QAccessible::State QAccessibleMenuBar::state(int child) const -{ - State s = QAccessibleWidget::state(child); - if (!child) - return s; - - QAction *action = menuBar()->actions().value(child-1, 0); - if (!action) - return s; - - if (menuBar()->style()->styleHint(QStyle::SH_Menu_MouseTracking)) - s |= HotTracked; - if (action->isSeparator() || !action->isEnabled()) - s |= Unavailable; - if (menuBar()->activeAction() == action) - s |= Focused; - - return s; -} - -QString QAccessibleMenuBar::actionText(int action, QAccessible::Text text, int child) const -{ - if (action == QAccessible::DefaultAction && child && text == QAccessible::Name) { - QAction *a = menuBar()->actions().value(child-1, 0); - if (!a || a->isSeparator()) - return QString(); - if (a->menu()) { - if (a->menu()->isVisible()) - return QMenu::tr("Close"); - return QMenu::tr("Open"); - } - return QMenu::tr("Execute"); - } - - return QAccessibleWidget::actionText(action, text, child); -} - -bool QAccessibleMenuBar::doAction(int act, int child, const QVariantList &) -{ - if (act != !child) - return false; - - QAction *action = menuBar()->actions().value(child-1, 0); - if (!action || !action->isEnabled()) - return false; - if (action->menu() && action->menu()->isVisible()) - action->menu()->hide(); - else - menuBar()->setActiveAction(action); - return true; -} - -#endif // QT_NO_MENUBAR - -QAccessibleMenuItem::QAccessibleMenuItem(QWidget *owner, QAction *action) : m_action(action), m_owner(owner) -{ -} - - -QAccessibleMenuItem::~QAccessibleMenuItem() -{} - -int QAccessibleMenuItem::childAt(int x, int y ) const -{ - for (int i = childCount(); i >= 0; --i) { - if (rect(i).contains(x,y)) - return i; - } - return -1; -} - -int QAccessibleMenuItem::childCount() const -{ - return m_action->menu() ? 1 : 0; -} - -QString QAccessibleMenuItem::actionText(int action, Text text, int child ) const -{ - if (text == Name && child == 0) { - switch (action) { - case Press: - case DefaultAction: - if (m_action->menu()) - return QMenu::tr("Open"); - return QMenu::tr("Execute"); - break; - default: - break; - } - } - return QString(); -} - -bool QAccessibleMenuItem::doAction(int action, int child, const QVariantList & /*params = QVariantList()*/ ) -{ - if ((child) || ((action != DefaultAction) && (action != Press))) - return false; - - // if the action has a menu, expand/hide it - if (m_action->menu()) { - if (m_action->menu()->isVisible()) { - m_action->menu()->hide(); - return true; - } else { - if (QMenuBar *bar = qobject_cast(owner())) { - bar->setActiveAction(m_action); - return true; - } else if (QMenu *menu = qobject_cast(owner())){ - menu->setActiveAction(m_action); - return true; - } - } - } - // no menu - m_action->trigger(); - return true; -} - -// action interface -int QAccessibleMenuItem::actionCount() -{ - return 1; -} - -void QAccessibleMenuItem::doAction(int actionIndex) -{ - if (actionIndex) - return; - - doAction(DefaultAction, 0); -} - -int QAccessibleMenuItem::indexOfChild( const QAccessibleInterface * child ) const -{ - if (child->role(0) == PopupMenu && child->object() == m_action->menu()) - return 1; - - return -1; -} - -bool QAccessibleMenuItem::isValid() const -{ - return (m_action != nullptr); -} - -int QAccessibleMenuItem::navigate(RelationFlag relation, int entry, QAccessibleInterface ** target ) const -{ - int ret = -1; - if (entry < 0) { - *target = 0; - return ret; - } - - if (relation == Self || entry == 0) { - *target = new QAccessibleMenuItem(owner(), action()); - return 0; - } - - switch (relation) { - case Child: - if (entry <= childCount()) { - *target = new QAccessibleMenu(action()->menu()); - ret = 0; - } - break; - - case Ancestor:{ - QWidget *parent = owner(); - QAccessibleInterface *ancestor = parent ? QAccessible::queryAccessibleInterface(parent) : 0; - if (ancestor) { - if (entry == 1) { - *target = ancestor; - ret = 0; - } else { - ret = ancestor->navigate(Ancestor, entry - 1, target); - delete ancestor; - } - } - break;} - case Up: - case Down:{ - QAccessibleInterface *parent = 0; - int ent = navigate(Ancestor, 1, &parent); - if (ent == 0) { - int index = parent->indexOfChild(this); - if (index != -1) { - index += (relation == Down ? +1 : -1); - ret = parent->navigate(Child, index, target); - } - } - delete parent; - break;} - case Sibling: { - QAccessibleInterface *parent = 0; - int ent = navigate(Ancestor, 1, &parent); - if (ent == 0) { - ret = parent->navigate(Child, entry, target); - } - delete parent; - break;} - default: - break; - - } - if (ret == -1) - *target = 0; - return ret; -} - -QObject *QAccessibleMenuItem::object() const -{ - return m_action; -} - -QRect QAccessibleMenuItem::rect (int child ) const -{ - QRect rect; - if (child == 0) { - QWidget *own = owner(); -#ifndef QT_NO_MENUBAR - if (QMenuBar *menuBar = qobject_cast(own)) { - rect = menuBar->actionGeometry(m_action); - QPoint globalPos = menuBar->mapToGlobal(QPoint(0,0)); - rect = rect.translated(globalPos); - } else -#endif // QT_NO_MENUBAR - if (QMenu *menu = qobject_cast(own)) { - rect = menu->actionGeometry(m_action); - QPoint globalPos = menu->mapToGlobal(QPoint(0,0)); - rect = rect.translated(globalPos); - } - } else if (child == 1) { - QMenu *menu = m_action->menu(); - if (menu) { - rect = menu->rect(); - QPoint globalPos = menu->mapToGlobal(QPoint(0,0)); - rect = rect.translated(globalPos); - } - } - return rect; -} - -QAccessible::Relation QAccessibleMenuItem::relationTo ( int child, const QAccessibleInterface * other, int otherChild ) const -{ - if (other->object() == owner()) { - return Child; - } - Q_UNUSED(child) - Q_UNUSED(other) - Q_UNUSED(otherChild) - // ### - return Unrelated; -} - -QAccessible::Role QAccessibleMenuItem::role(int /*child*/ ) const -{ - return m_action->isSeparator() ? Separator :MenuItem; -} - -void QAccessibleMenuItem::setText ( Text /*t*/, int /*child*/, const QString & /*text */) -{ - -} - -QAccessible::State QAccessibleMenuItem::state(int child ) const -{ - QAccessible::State s = Unavailable; - - if (child == 0) { - s = Normal; - QWidget *own = owner(); - - if (own && (own->testAttribute(Qt::WA_WState_Visible) == false || m_action->isVisible() == false)) { - s |= Invisible; - } - - if (QMenu *menu = qobject_cast(own)) { - if (menu->activeAction() == m_action) - s |= Focused; -#ifndef QT_NO_MENUBAR - } else if (QMenuBar *menuBar = qobject_cast(own)) { - if (menuBar->activeAction() == m_action) - s |= Focused; -#endif - } - if (own && own->style()->styleHint(QStyle::SH_Menu_MouseTracking)) - s |= HotTracked; - if (m_action->isSeparator() || !m_action->isEnabled()) - s |= Unavailable; - if (m_action->isChecked()) - s |= Checked; - } else if (child == 1) { - QMenu *menu = m_action->menu(); - if (menu) { - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(menu); - s = iface->state(0); - delete iface; - } - } - return s; -} - -QString QAccessibleMenuItem::text ( Text t, int child ) const -{ - QString str; - switch (t) { - case Name: - if (child == 0) { - str = m_action->text(); - } else if (child == 1) { - QMenu *m = m_action->menu(); - if (m) - str = m->title(); - } - str = qt_accStripAmp(str); - break; - case Accelerator: - if (child == 0) { -#ifndef QT_NO_SHORTCUT - QKeySequence key = m_action->shortcut(); - if (!key.isEmpty()) { - str = key.toString(); - } else -#endif - { - str = qt_accHotKey(m_action->text()); - } - } - break; - default: - break; - } - return str; -} - -// action interface -int QAccessibleMenuItem::userActionCount ( int /*child*/ ) const -{ - return 0; -} - -QAction *QAccessibleMenuItem::action() const -{ - return m_action; -} - -QString QAccessibleMenuItem::description(int) -{ - return text(QAccessible::Description, 0); -} - -QString QAccessibleMenuItem::name(int) -{ - return actionText(DefaultAction, QAccessible::Name, 0); -} - -QString QAccessibleMenuItem::localizedName(int) -{ - return text(QAccessible::Name, 0); -} - -QStringList QAccessibleMenuItem::keyBindings(int) -{ - QStringList keys; -#ifndef QT_NO_SHORTCUT - QKeySequence key = m_action->shortcut(); - if (!key.isEmpty()) { - keys.append(key.toString()); - } -#endif - return keys; -} - - -QVariant QAccessibleMenuItem::invokeMethodEx(Method, int, const QVariantList &) -{ - return QVariant(); -} - -QWidget *QAccessibleMenuItem::owner() const -{ - return m_owner; -} - -#endif // QT_NO_MENU - -QT_END_NAMESPACE - -#endif // QT_NO_ACCESSIBILITY - diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.h b/src/plugins/accessible/widgets/qaccessiblemenu.h deleted file mode 100644 index 65d253775..000000000 --- a/src/plugins/accessible/widgets/qaccessiblemenu.h +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the plugins of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QACCESSIBLEMENU_H -#define QACCESSIBLEMENU_H - -#include -#include - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACCESSIBILITY - -#ifndef QT_NO_MENU -class QMenu; -class QMenuBar; -class QAction; - -class QAccessibleMenu : public QAccessibleWidget -{ -public: - explicit QAccessibleMenu(QWidget *w); - - int childCount() const; - int childAt(int x, int y) const; - - QRect rect(int child) const; - QString text(Text t, int child) const; - Role role(int child) const; - State state(int child) const; - int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const; - int indexOfChild( const QAccessibleInterface *child ) const; - - QString actionText(int action, QAccessible::Text text, int child) const; - bool doAction(int action, int child, const QVariantList ¶ms); - -protected: - QMenu *menu() const; -}; - -#ifndef QT_NO_MENUBAR -class QAccessibleMenuBar : public QAccessibleWidget -{ -public: - explicit QAccessibleMenuBar(QWidget *w); - - int childCount() const; - int childAt(int x, int y) const; - - QRect rect(int child) const; - QString text(Text t, int child) const; - Role role(int child) const; - State state(int child) const; - int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const; - int indexOfChild( const QAccessibleInterface *child ) const; - - QString actionText(int action, QAccessible::Text text, int child) const; - bool doAction(int action, int child, const QVariantList ¶ms); - -protected: - QMenuBar *menuBar() const; -}; -#endif // QT_NO_MENUBAR - - - -class QAccessibleMenuItem : public QAccessibleActionInterface, public QAccessibleInterface -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleMenuItem(QWidget *owner, QAction *w); - - virtual ~QAccessibleMenuItem(); - virtual QString actionText ( int action, Text t, int child ) const; - virtual int childAt ( int x, int y ) const; - virtual int childCount () const; - virtual bool doAction ( int action, int child, const QVariantList & params = QVariantList() ); - virtual int indexOfChild ( const QAccessibleInterface * child ) const; - virtual bool isValid () const; - virtual int navigate ( RelationFlag relation, int entry, QAccessibleInterface ** target ) const; - virtual QObject * object () const; - virtual QRect rect ( int child ) const; - virtual Relation relationTo ( int child, const QAccessibleInterface * other, int otherChild ) const; - virtual Role role ( int child ) const; - virtual void setText ( Text t, int child, const QString & text ); - virtual State state ( int child ) const; - virtual QString text ( Text t, int child ) const; - virtual int userActionCount ( int child ) const; - - // action interface - virtual int actionCount(); - virtual void doAction(int actionIndex); - virtual QString description(int); - virtual QString name(int); - virtual QString localizedName(int); - virtual QStringList keyBindings(int); - - virtual QVariant invokeMethodEx(Method, int, const QVariantList &); - - QWidget *owner() const; -protected: - QAction *action() const; -private: - QAction *m_action; - QWidget *m_owner; // can hold either QMenu or the QMenuBar that contains the action -}; - -#endif // QT_NO_MENU - -QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY -#endif // QACCESSIBLEMENU_H diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp deleted file mode 100644 index 43cf039f7..000000000 --- a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp +++ /dev/null @@ -1,1920 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the plugins of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaccessiblewidgets.h" -#include "qabstracttextdocumentlayout.h" -#include "qapplication.h" -#include "qclipboard.h" -#include "qtextedit.h" -#include "qtextedit_p.h" -#include "qtextdocument.h" -#include "qtextobject.h" -#include "qplaintextedit.h" -#include "qscrollbar.h" -#include "qdebug.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "qdockwidget_p.h" -#include - -#ifndef QT_NO_ACCESSIBILITY - -QT_BEGIN_NAMESPACE - -using namespace QAccessible2; - -QString Q_GUI_EXPORT qt_accStripAmp(const QString &text); -QString Q_GUI_EXPORT qt_accHotKey(const QString &text); - -QList childWidgets(const QWidget *widget, bool includeTopLevel) -{ - if (widget == 0) - return QList(); - QList list = widget->children(); - QList widgets; - for (int i = 0; i < list.size(); ++i) { - QWidget *w = qobject_cast(list.at(i)); - if (!w) - continue; - QString objectName = w->objectName(); - if ((includeTopLevel || !w->isWindow()) - && !qobject_cast(w) - && !qobject_cast(w) - && objectName != QLatin1String("qt_rubberband") - && objectName != QLatin1String("qt_qmainwindow_extended_splitter")) { - widgets.append(w); - } - } - return widgets; -} - -static inline int distance(QWidget *source, QWidget *target, - QAccessible::RelationFlag relation) -{ - if (!source || !target) - return -1; - - int returnValue = -1; - switch (relation) { - case QAccessible::Up: - if (target->y() <= source->y()) - returnValue = source->y() - target->y(); - break; - case QAccessible::Down: - if (target->y() >= source->y() + source->height()) - returnValue = target->y() - (source->y() + source->height()); - break; - case QAccessible::Right: - if (target->x() >= source->x() + source->width()) - returnValue = target->x() - (source->x() + source->width()); - break; - case QAccessible::Left: - if (target->x() <= source->x()) - returnValue = source->x() - target->x(); - break; - default: - break; - } - return returnValue; -} - -static inline QWidget *mdiAreaNavigate(QWidget *area, - QAccessible::RelationFlag relation, int entry) -{ -#if defined(QT_NO_MDIAREA) && defined(QT_NO_WORKSPACE) - Q_UNUSED(area); -#endif -#ifndef QT_NO_MDIAREA - const QMdiArea *mdiArea = qobject_cast(area); -#endif -#ifndef QT_NO_WORKSPACE - const QWorkspace *workspace = qobject_cast(area); -#endif - if (true -#ifndef QT_NO_MDIAREA - && !mdiArea -#endif -#ifndef QT_NO_WORKSPACE - && !workspace -#endif - ) - return 0; - - QWidgetList windows; -#ifndef QT_NO_MDIAREA - if (mdiArea) { - foreach (QMdiSubWindow *window, mdiArea->subWindowList()) - windows.append(window); - } else -#endif - { -#ifndef QT_NO_WORKSPACE - foreach (QWidget *window, workspace->windowList()) - windows.append(window->parentWidget()); -#endif - } - - if (windows.isEmpty() || entry < 1 || entry > windows.count()) - return 0; - - QWidget *source = windows.at(entry - 1); - QMap candidates; - foreach (QWidget *window, windows) { - if (source == window) - continue; - int candidateDistance = distance(source, window, relation); - if (candidateDistance >= 0) - candidates.insert(candidateDistance, window); - } - - int minimumDistance = INT_MAX; - QWidget *target = 0; - foreach (QWidget *candidate, candidates) { - switch (relation) { - case QAccessible::Up: - case QAccessible::Down: - if (qAbs(candidate->x() - source->x()) < minimumDistance) { - target = candidate; - minimumDistance = qAbs(candidate->x() - source->x()); - } - break; - case QAccessible::Left: - case QAccessible::Right: - if (qAbs(candidate->y() - source->y()) < minimumDistance) { - target = candidate; - minimumDistance = qAbs(candidate->y() - source->y()); - } - break; - default: - break; - } - if (minimumDistance == 0) - break; - } - -#ifndef QT_NO_WORKSPACE - if (workspace) { - foreach (QWidget *widget, workspace->windowList()) { - if (widget->parentWidget() == target) - target = widget; - } - } -#endif - return target; -} - -#ifndef QT_NO_TEXTEDIT - -/*! - \class QAccessibleTextEdit - \brief The QAccessibleTextEdit class implements the QAccessibleInterface for richtext editors. - \internal -*/ - -static QTextBlock qTextBlockAt(const QTextDocument *doc, int pos) -{ - Q_ASSERT(pos >= 0); - - QTextBlock block = doc->begin(); - int i = 0; - while (block.isValid() && i < pos) { - block = block.next(); - ++i; - } - return block; -} - -static int qTextBlockPosition(QTextBlock block) -{ - int child = 0; - while (block.isValid()) { - block = block.previous(); - ++child; - } - - return child; -} - -QAccessiblePlainTextEdit::QAccessiblePlainTextEdit(QWidget* o) - :QAccessibleTextWidget(o) -{ -} - -QPlainTextEdit* QAccessiblePlainTextEdit::plainTextEdit() const -{ - return static_cast(widget()); -} - -QPoint QAccessiblePlainTextEdit::scrollBarPosition() const -{ - QPoint result; - result.setX(plainTextEdit()->horizontalScrollBar() ? plainTextEdit()->horizontalScrollBar()->sliderPosition() : 0); - result.setY(plainTextEdit()->verticalScrollBar() ? plainTextEdit()->verticalScrollBar()->sliderPosition() : 0); - return result; -} - -QTextCursor QAccessiblePlainTextEdit::textCursor() const -{ - return plainTextEdit()->textCursor(); -} - -void QAccessiblePlainTextEdit::setTextCursor(const QTextCursor &textCursor) -{ - plainTextEdit()->setTextCursor(textCursor); -} - -int QAccessiblePlainTextEdit::childCount() const -{ - return 0; -} - -QTextDocument* QAccessiblePlainTextEdit::textDocument() const -{ - return plainTextEdit()->document(); -} - -QWidget* QAccessiblePlainTextEdit::viewport() const -{ - return plainTextEdit()->viewport(); -} - -void QAccessiblePlainTextEdit::scrollToSubstring(int startIndex, int endIndex) -{ - //TODO: Not implemented - Q_UNUSED(startIndex); - Q_UNUSED(endIndex); -} - - -/*! - \fn QAccessibleTextEdit::QAccessibleTextEdit(QWidget* widget) - - Constructs a QAccessibleTextEdit object for a \a widget. -*/ -QAccessibleTextEdit::QAccessibleTextEdit(QWidget *o) -: QAccessibleTextWidget(o, EditableText) -{ - Q_ASSERT(widget()->inherits("QTextEdit")); - childOffset = QAccessibleWidget::childCount(); -} - -/*! Returns the text edit. */ -QTextEdit *QAccessibleTextEdit::textEdit() const -{ - return static_cast(widget()); -} - -QTextCursor QAccessibleTextEdit::textCursor() const -{ - return textEdit()->textCursor(); -} - -QTextDocument* QAccessibleTextEdit::textDocument() const -{ - return textEdit()->document(); -} - -void QAccessibleTextEdit::setTextCursor(const QTextCursor& textCursor) -{ - textEdit()->setTextCursor(textCursor); -} - -QWidget* QAccessibleTextEdit::viewport() const -{ - return textEdit()->viewport(); -} - -QPoint QAccessibleTextEdit::scrollBarPosition() const -{ - QPoint result; - result.setX(textEdit()->horizontalScrollBar() ? textEdit()->horizontalScrollBar()->sliderPosition() : 0); - result.setY(textEdit()->verticalScrollBar() ? textEdit()->verticalScrollBar()->sliderPosition() : 0); - return result; -} - -QRect QAccessibleTextEdit::rect(int child) const -{ - if (child <= childOffset) - return QAccessibleWidget::rect(child); - - QTextEdit *edit = textEdit(); - QTextBlock block = qTextBlockAt(edit->document(), child - childOffset - 1); - if (!block.isValid()) - return QRect(); - - QRect rect = edit->document()->documentLayout()->blockBoundingRect(block).toRect(); - rect.translate(-edit->horizontalScrollBar()->value(), -edit->verticalScrollBar()->value()); - - rect = edit->viewport()->rect().intersected(rect); - if (rect.isEmpty()) - return QRect(); - - return rect.translated(edit->viewport()->mapToGlobal(QPoint(0, 0))); -} - -int QAccessibleTextEdit::childAt(int x, int y) const -{ - QTextEdit *edit = textEdit(); - if (!edit->isVisible()) - return -1; - - QPoint point = edit->viewport()->mapFromGlobal(QPoint(x, y)); - QTextBlock block = edit->cursorForPosition(point).block(); - if (block.isValid()) - return qTextBlockPosition(block) + childOffset; - - return QAccessibleWidget::childAt(x, y); -} - -/*! \reimp */ -QString QAccessibleTextEdit::text(Text t, int child) const -{ - if (t == Value) { - if (child > childOffset) - return qTextBlockAt(textEdit()->document(), child - childOffset - 1).text(); - if (!child) - return textEdit()->toPlainText(); - } - - return QAccessibleWidget::text(t, child); -} - -/*! \reimp */ -void QAccessibleTextEdit::setText(Text t, int child, const QString &text) -{ - if (t != Value || (child > 0 && child <= childOffset)) { - QAccessibleWidget::setText(t, child, text); - return; - } - if (textEdit()->isReadOnly()) - return; - - if (!child) { - textEdit()->setText(text); - return; - } - QTextBlock block = qTextBlockAt(textEdit()->document(), child - childOffset - 1); - if (!block.isValid()) - return; - - QTextCursor cursor(block); - cursor.select(QTextCursor::BlockUnderCursor); - cursor.insertText(text); -} - -/*! \reimp */ -QAccessible::Role QAccessibleTextEdit::role(int child) const -{ - if (child > childOffset) - return EditableText; - return QAccessibleWidget::role(child); -} - -QVariant QAccessibleTextEdit::invokeMethod(QAccessible::Method method, int child, - const QVariantList ¶ms) -{ - if (child) - return QVariant(); - - switch (method) { - case ListSupportedMethods: { - QSet set; - set << ListSupportedMethods << SetCursorPosition << GetCursorPosition; - return QVariant::fromValue(set | qvariant_cast >( - QAccessibleWidget::invokeMethod(method, child, params))); - } - case SetCursorPosition: - setCursorPosition(params.value(0).toInt()); - return true; - case GetCursorPosition: - return textEdit()->textCursor().position(); - default: - return QAccessibleWidget::invokeMethod(method, child, params); - } -} - -int QAccessibleTextEdit::childCount() const -{ - return childOffset + textEdit()->document()->blockCount(); -} -#endif // QT_NO_TEXTEDIT - -#ifndef QT_NO_STACKEDWIDGET -// ======================= QAccessibleStackedWidget ====================== -QAccessibleStackedWidget::QAccessibleStackedWidget(QWidget *widget) - : QAccessibleWidget(widget, LayeredPane) -{ - Q_ASSERT(qobject_cast(widget)); -} - -QVariant QAccessibleStackedWidget::invokeMethod(QAccessible::Method, int, const QVariantList &) -{ - return QVariant(); -} - - -int QAccessibleStackedWidget::childAt(int x, int y) const -{ - if (!stackedWidget()->isVisible()) - return -1; - QWidget *currentWidget = stackedWidget()->currentWidget(); - if (!currentWidget) - return -1; - QPoint position = currentWidget->mapFromGlobal(QPoint(x, y)); - if (currentWidget->rect().contains(position)) - return 1; - return -1; -} - -int QAccessibleStackedWidget::childCount() const -{ - return stackedWidget()->count(); -} - -int QAccessibleStackedWidget::indexOfChild(const QAccessibleInterface *child) const -{ - if (!child) - return -1; - - QWidget* widget = qobject_cast(child->object()); - int index = stackedWidget()->indexOf(widget); - if (index >= 0) // one based counting of children - return index + 1; - return -1; -} - -int QAccessibleStackedWidget::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - *target = 0; - - QObject *targetObject = 0; - switch (relation) { - case Child: - if (entry < 1 || entry > stackedWidget()->count()) - return -1; - targetObject = stackedWidget()->widget(entry-1); - break; - default: - return QAccessibleWidget::navigate(relation, entry, target); - } - *target = QAccessible::queryAccessibleInterface(targetObject); - return *target ? 0 : -1; -} - -QStackedWidget *QAccessibleStackedWidget::stackedWidget() const -{ - return static_cast(object()); -} -#endif // QT_NO_STACKEDWIDGET - -#ifndef QT_NO_TOOLBOX -// ======================= QAccessibleToolBox ====================== -QAccessibleToolBox::QAccessibleToolBox(QWidget *widget) - : QAccessibleWidget(widget, LayeredPane) -{ - Q_ASSERT(qobject_cast(widget)); -} - -QString QAccessibleToolBox::text(Text textType, int child) const -{ - if (textType != Value || child <= 0 || child > toolBox()->count()) - return QAccessibleWidget::text(textType, child); - return toolBox()->itemText(child - 1); -} - -void QAccessibleToolBox::setText(Text textType, int child, const QString &text) -{ - if (textType != Value || child <= 0 || child > toolBox()->count()) { - QAccessibleWidget::setText(textType, child, text); - return; - } - toolBox()->setItemText(child - 1, text); -} - -QAccessible::State QAccessibleToolBox::state(int child) const -{ - QWidget *childWidget = toolBox()->widget(child - 1); - if (!childWidget) - return QAccessibleWidget::state(child); - QAccessible::State childState = QAccessible::Normal; - if (toolBox()->currentWidget() == childWidget) - childState |= QAccessible::Expanded; - else - childState |= QAccessible::Collapsed; - return childState; -} - -QVariant QAccessibleToolBox::invokeMethod(QAccessible::Method, int, const QVariantList &) -{ - return QVariant(); -} - -int QAccessibleToolBox::childCount() const -{ - return toolBox()->count(); -} - -int QAccessibleToolBox::indexOfChild(const QAccessibleInterface *child) const -{ - if (!child) - return -1; - QWidget *childWidget = qobject_cast(child->object()); - if (!childWidget) - return -1; - int index = toolBox()->indexOf(childWidget); - if (index != -1) - ++index; - return index; -} - -int QAccessibleToolBox::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - *target = 0; - if (entry <= 0 || entry > toolBox()->count()) - return QAccessibleWidget::navigate(relation, entry, target); - int index = -1; - if (relation == QAccessible::Up) - index = entry - 2; - else if (relation == QAccessible::Down) - index = entry; - *target = QAccessible::queryAccessibleInterface(toolBox()->widget(index)); - return *target ? 0: -1; -} - -QToolBox * QAccessibleToolBox::toolBox() const -{ - return static_cast(object()); -} -#endif // QT_NO_TOOLBOX - -// ======================= QAccessibleMdiArea ====================== -#ifndef QT_NO_MDIAREA -QAccessibleMdiArea::QAccessibleMdiArea(QWidget *widget) - : QAccessibleWidget(widget, LayeredPane) -{ - Q_ASSERT(qobject_cast(widget)); -} - -QAccessible::State QAccessibleMdiArea::state(int child) const -{ - if (child < 0) - return QAccessibleWidget::state(child); - if (child == 0) - return QAccessible::Normal; - QList subWindows = mdiArea()->subWindowList(); - if (subWindows.isEmpty() || child > subWindows.count()) - return QAccessibleWidget::state(child); - if (subWindows.at(child - 1) == mdiArea()->activeSubWindow()) - return QAccessible::Focused; - return QAccessible::Normal; -} - -QVariant QAccessibleMdiArea::invokeMethod(QAccessible::Method, int, const QVariantList &) -{ - return QVariant(); -} - -int QAccessibleMdiArea::childCount() const -{ - return mdiArea()->subWindowList().count(); -} - -int QAccessibleMdiArea::indexOfChild(const QAccessibleInterface *child) const -{ - if (!child || !child->object() || mdiArea()->subWindowList().isEmpty()) - return -1; - if (QMdiSubWindow *window = qobject_cast(child->object())) { - int index = mdiArea()->subWindowList().indexOf(window); - if (index != -1) - return ++index; - } - return -1; -} - -int QAccessibleMdiArea::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - *target = 0; - QWidget *targetObject = 0; - QList subWindows = mdiArea()->subWindowList(); - switch (relation) { - case Child: - if (entry < 1 || subWindows.isEmpty() || entry > subWindows.count()) - return -1; - targetObject = subWindows.at(entry - 1); - break; - case Up: - case Down: - case Left: - case Right: - targetObject = mdiAreaNavigate(mdiArea(), relation, entry); - break; - default: - return QAccessibleWidget::navigate(relation, entry, target); - } - *target = QAccessible::queryAccessibleInterface(targetObject); - return *target ? 0: -1; -} - -QMdiArea *QAccessibleMdiArea::mdiArea() const -{ - return static_cast(object()); -} - -// ======================= QAccessibleMdiSubWindow ====================== -QAccessibleMdiSubWindow::QAccessibleMdiSubWindow(QWidget *widget) - : QAccessibleWidget(widget, QAccessible::Window) -{ - Q_ASSERT(qobject_cast(widget)); -} - -QString QAccessibleMdiSubWindow::text(Text textType, int child) const -{ - if (textType == QAccessible::Name && (child == 0 || child == 1)) { - QString title = mdiSubWindow()->windowTitle(); - title.replace(QLatin1String("[*]"), QLatin1String("")); - return title; - } - return QAccessibleWidget::text(textType, child); -} - -void QAccessibleMdiSubWindow::setText(Text textType, int child, const QString &text) -{ - if (textType == QAccessible::Name && (child == 0 || child == 1)) - mdiSubWindow()->setWindowTitle(text); - else - QAccessibleWidget::setText(textType, child, text); -} - -QAccessible::State QAccessibleMdiSubWindow::state(int child) const -{ - if (child != 0 || !mdiSubWindow()->parent()) - return QAccessibleWidget::state(child); - QAccessible::State state = QAccessible::Normal | QAccessible::Focusable; - if (!mdiSubWindow()->isMaximized()) - state |= (QAccessible::Movable | QAccessible::Sizeable); - if (mdiSubWindow()->isAncestorOf(QApplication::focusWidget()) - || QApplication::focusWidget() == mdiSubWindow()) - state |= QAccessible::Focused; - if (!mdiSubWindow()->isVisible()) - state |= QAccessible::Invisible; - if (!mdiSubWindow()->parentWidget()->contentsRect().contains(mdiSubWindow()->geometry())) - state |= QAccessible::Offscreen; - if (!mdiSubWindow()->isEnabled()) - state |= QAccessible::Unavailable; - return state; -} - -QVariant QAccessibleMdiSubWindow::invokeMethod(QAccessible::Method, int, const QVariantList &) -{ - return QVariant(); -} - -int QAccessibleMdiSubWindow::childCount() const -{ - if (mdiSubWindow()->widget()) - return 1; - return 0; -} - -int QAccessibleMdiSubWindow::indexOfChild(const QAccessibleInterface *child) const -{ - if (child && child->object() && child->object() == mdiSubWindow()->widget()) - return 1; - return -1; -} - -int QAccessibleMdiSubWindow::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - *target = 0; - - if (!mdiSubWindow()->parent()) - return QAccessibleWidget::navigate(relation, entry, target); - - QWidget *targetObject = 0; - QMdiSubWindow *source = mdiSubWindow(); - switch (relation) { - case Child: - if (entry != 1 || !source->widget()) - return -1; - targetObject = source->widget(); - break; - case Up: - case Down: - case Left: - case Right: { - if (entry != 0) - break; - QWidget *parent = source->parentWidget(); - while (parent && !parent->inherits("QMdiArea")) - parent = parent->parentWidget(); - QMdiArea *mdiArea = qobject_cast(parent); - if (!mdiArea) - break; - int index = mdiArea->subWindowList().indexOf(source); - if (index == -1) - break; - if (QWidget *dest = mdiAreaNavigate(mdiArea, relation, index + 1)) { - *target = QAccessible::queryAccessibleInterface(dest); - return *target ? 0 : -1; - } - break; - } - default: - return QAccessibleWidget::navigate(relation, entry, target); - } - *target = QAccessible::queryAccessibleInterface(targetObject); - return *target ? 0: -1; -} - -QRect QAccessibleMdiSubWindow::rect(int child) const -{ - if (mdiSubWindow()->isHidden()) - return QRect(); - if (!mdiSubWindow()->parent()) - return QAccessibleWidget::rect(child); - const QPoint pos = mdiSubWindow()->mapToGlobal(QPoint(0, 0)); - if (child == 0) - return QRect(pos, mdiSubWindow()->size()); - if (child == 1 && mdiSubWindow()->widget()) { - if (mdiSubWindow()->widget()->isHidden()) - return QRect(); - const QRect contentsRect = mdiSubWindow()->contentsRect(); - return QRect(pos.x() + contentsRect.x(), pos.y() + contentsRect.y(), - contentsRect.width(), contentsRect.height()); - } - return QRect(); -} - -int QAccessibleMdiSubWindow::childAt(int x, int y) const -{ - if (!mdiSubWindow()->isVisible()) - return -1; - if (!mdiSubWindow()->parent()) - return QAccessibleWidget::childAt(x, y); - const QRect globalGeometry = rect(0); - if (!globalGeometry.isValid()) - return -1; - const QRect globalChildGeometry = rect(1); - if (globalChildGeometry.isValid() && globalChildGeometry.contains(QPoint(x, y))) - return 1; - if (globalGeometry.contains(QPoint(x, y))) - return 0; - return -1; -} - -QMdiSubWindow *QAccessibleMdiSubWindow::mdiSubWindow() const -{ - return static_cast(object()); -} -#endif // QT_NO_MDIAREA - -// ======================= QAccessibleWorkspace ====================== -#ifndef QT_NO_WORKSPACE -QAccessibleWorkspace::QAccessibleWorkspace(QWidget *widget) - : QAccessibleWidget(widget, LayeredPane) -{ - Q_ASSERT(qobject_cast(widget)); -} - -QAccessible::State QAccessibleWorkspace::state(int child) const -{ - if (child < 0) - return QAccessibleWidget::state(child); - if (child == 0) - return QAccessible::Normal; - QWidgetList subWindows = workspace()->windowList(); - if (subWindows.isEmpty() || child > subWindows.count()) - return QAccessibleWidget::state(child); - if (subWindows.at(child - 1) == workspace()->activeWindow()) - return QAccessible::Focused; - return QAccessible::Normal; -} - -QVariant QAccessibleWorkspace::invokeMethod(QAccessible::Method, int, const QVariantList &) -{ - return QVariant(); -} - -int QAccessibleWorkspace::childCount() const -{ - return workspace()->windowList().count(); -} - -int QAccessibleWorkspace::indexOfChild(const QAccessibleInterface *child) const -{ - if (!child || !child->object() || workspace()->windowList().isEmpty()) - return -1; - if (QWidget *window = qobject_cast(child->object())) { - int index = workspace()->windowList().indexOf(window); - if (index != -1) - return ++index; - } - return -1; -} - -int QAccessibleWorkspace::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - *target = 0; - QWidget *targetObject = 0; - QWidgetList subWindows = workspace()->windowList(); - switch (relation) { - case Child: - if (entry < 1 || subWindows.isEmpty() || entry > subWindows.count()) - return -1; - targetObject = subWindows.at(entry - 1); - break; - case Up: - case Down: - case Left: - case Right: - targetObject = mdiAreaNavigate(workspace(), relation, entry); - break; - default: - return QAccessibleWidget::navigate(relation, entry, target); - } - *target = QAccessible::queryAccessibleInterface(targetObject); - return *target ? 0: -1; -} - -QWorkspace *QAccessibleWorkspace::workspace() const -{ - return static_cast(object()); -} -#endif - -#ifndef QT_NO_DIALOGBUTTONBOX -// ======================= QAccessibleDialogButtonBox ====================== -QAccessibleDialogButtonBox::QAccessibleDialogButtonBox(QWidget *widget) - : QAccessibleWidget(widget, Grouping) -{ - Q_ASSERT(qobject_cast(widget)); -} - -QVariant QAccessibleDialogButtonBox::invokeMethod(QAccessible::Method, int, const QVariantList &) -{ - return QVariant(); -} -#endif // QT_NO_DIALOGBUTTONBOX - -#ifndef QT_NO_TEXTBROWSER -QAccessibleTextBrowser::QAccessibleTextBrowser(QWidget *widget) - : QAccessibleTextEdit(widget) -{ - Q_ASSERT(qobject_cast(widget)); -} - -QAccessible::Role QAccessibleTextBrowser::role(int child) const -{ - if (child != 0) - return QAccessibleTextEdit::role(child); - return QAccessible::StaticText; -} -#endif // QT_NO_TEXTBROWSER - -#ifndef QT_NO_CALENDARWIDGET -// ===================== QAccessibleCalendarWidget ======================== -QAccessibleCalendarWidget::QAccessibleCalendarWidget(QWidget *widget) - : QAccessibleWidget(widget, Table) -{ - Q_ASSERT(qobject_cast(widget)); -} - -QVariant QAccessibleCalendarWidget::invokeMethod(QAccessible::Method, int, const QVariantList &) -{ - return QVariant(); -} - -int QAccessibleCalendarWidget::childCount() const -{ - return calendarWidget()->isNavigationBarVisible() ? 2 : 1; -} - -int QAccessibleCalendarWidget::indexOfChild(const QAccessibleInterface *child) const -{ - if (!child || !child->object() || childCount() <= 0) - return -1; - if (qobject_cast(child->object())) - return childCount(); - return 1; -} - -int QAccessibleCalendarWidget::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - *target = 0; - if (entry <= 0 || entry > childCount()) - return QAccessibleWidget::navigate(relation, entry, target); - QWidget *targetWidget = 0; - switch (relation) { - case Child: - if (childCount() == 1) { - targetWidget = calendarView(); - } else { - if (entry == 1) - targetWidget = navigationBar(); - else - targetWidget = calendarView(); - } - break; - case Up: - if (entry == 2) - targetWidget = navigationBar(); - break; - case Down: - if (entry == 1 && childCount() == 2) - targetWidget = calendarView(); - break; - default: - return QAccessibleWidget::navigate(relation, entry, target); - } - *target = queryAccessibleInterface(targetWidget); - return *target ? 0: -1; -} - -QRect QAccessibleCalendarWidget::rect(int child) const -{ - if (!calendarWidget()->isVisible() || child > childCount()) - return QRect(); - if (child == 0) - return QAccessibleWidget::rect(child); - QWidget *childWidget = 0; - if (childCount() == 2) - childWidget = child == 1 ? navigationBar() : calendarView(); - else - childWidget = calendarView(); - return QRect(childWidget->mapToGlobal(QPoint(0, 0)), childWidget->size()); -} - -int QAccessibleCalendarWidget::childAt(int x, int y) const -{ - const QPoint globalTargetPos = QPoint(x, y); - if (!rect(0).contains(globalTargetPos)) - return -1; - if (rect(1).contains(globalTargetPos)) - return 1; - if (rect(2).contains(globalTargetPos)) - return 2; - return 0; -} - -QCalendarWidget *QAccessibleCalendarWidget::calendarWidget() const -{ - return static_cast(object()); -} - -QAbstractItemView *QAccessibleCalendarWidget::calendarView() const -{ - foreach (QObject *child, calendarWidget()->children()) { - if (child->objectName() == QLatin1String("qt_calendar_calendarview")) - return static_cast(child); - } - return 0; -} - -QWidget *QAccessibleCalendarWidget::navigationBar() const -{ - foreach (QObject *child, calendarWidget()->children()) { - if (child->objectName() == QLatin1String("qt_calendar_navigationbar")) - return static_cast(child); - } - return 0; -} -#endif // QT_NO_CALENDARWIDGET - -#ifndef QT_NO_DOCKWIDGET -QAccessibleDockWidget::QAccessibleDockWidget(QWidget *widget) - : QAccessibleWidget(widget, Window) -{ - -} - -int QAccessibleDockWidget::navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const -{ - if (relation == Child) { - if (entry == 1) { - *iface = new QAccessibleTitleBar(dockWidget()); - return 0; - } else if (entry == 2) { - if (dockWidget()->widget()) - *iface = QAccessible::queryAccessibleInterface(dockWidget()->widget()); - return 0; - } - *iface = 0; - return -1; - } - return QAccessibleWidget::navigate(relation, entry, iface); -} - -int QAccessibleDockWidget::childAt(int x, int y) const -{ - for (int i = childCount(); i >= 0; --i) { - if (rect(i).contains(x,y)) - return i; - } - return -1; -} - -int QAccessibleDockWidget::childCount() const -{ - return dockWidget()->widget() ? 2 : 1; -} - -int QAccessibleDockWidget::indexOfChild(const QAccessibleInterface *child) const -{ - if (child) { - if (child->role(0) == TitleBar) { - return 1; - } else { - return 2; //### - } - } - return -1; -} - -QAccessible::Role QAccessibleDockWidget::role(int child) const -{ - switch (child) { - case 0: - return Window; - case 1: - return TitleBar; - case 2: - //### - break; - default: - break; - } - return NoRole; -} - -QAccessible::State QAccessibleDockWidget::state(int child) const -{ - //### mark tabified widgets as invisible - return QAccessibleWidget::state(child); -} - -QRect QAccessibleDockWidget::rect (int child ) const -{ - QRect rect; - bool mapToGlobal = true; - if (child == 0) { - if (dockWidget()->isFloating()) { - rect = dockWidget()->frameGeometry(); - mapToGlobal = false; - } else { - rect = dockWidget()->rect(); - } - }else if (child == 1) { - QDockWidgetLayout *layout = qobject_cast(dockWidget()->layout()); - rect = layout->titleArea(); - }else if (child == 2) { - if (dockWidget()->widget()) - rect = dockWidget()->widget()->geometry(); - } - if (rect.isNull()) - return rect; - - if (mapToGlobal) - rect.moveTopLeft(dockWidget()->mapToGlobal(rect.topLeft())); - - return rect; -} - -QVariant QAccessibleDockWidget::invokeMethod(QAccessible::Method, int, const QVariantList &) -{ - return QVariant(); -} - -QDockWidget *QAccessibleDockWidget::dockWidget() const -{ - return static_cast(object()); -} - -//// -// QAccessibleTitleBar -//// -QAccessibleTitleBar::QAccessibleTitleBar(QDockWidget *widget) - : m_dockWidget(widget) -{ - -} - -int QAccessibleTitleBar::navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const -{ - if (entry == 0 || relation == Self) { - *iface = new QAccessibleTitleBar(dockWidget()); - return 0; - } - switch (relation) { - case Child: - case FocusChild: - if (entry >= 1) { - QDockWidgetLayout *layout = dockWidgetLayout(); - int index = 1; - int role; - for (role = QDockWidgetLayout::CloseButton; role <= QDockWidgetLayout::FloatButton; ++role) { - QWidget *w = layout->widgetForRole((QDockWidgetLayout::Role)role); - if (!w->isVisible()) - continue; - if (index == entry) - break; - ++index; - } - *iface = 0; - return role > QDockWidgetLayout::FloatButton ? -1 : index; - } - break; - case Ancestor: - { - QAccessibleDockWidget *target = new QAccessibleDockWidget(dockWidget()); - int index; - if (entry == 1) { - *iface = target; - return 0; - } - index = target->navigate(Ancestor, entry - 1, iface); - delete target; - return index; - - break;} - case Sibling: - return navigate(Child, entry, iface); - break; - default: - break; - } - *iface = 0; - return -1; -} - -QAccessible::Relation QAccessibleTitleBar::relationTo(int /*child*/, const QAccessibleInterface * /*other*/, int /*otherChild*/) const -{ - return Unrelated; //### -} - -int QAccessibleTitleBar::indexOfChild(const QAccessibleInterface * /*child*/) const -{ - return -1; -} - -int QAccessibleTitleBar::childCount() const -{ - QDockWidgetLayout *layout = dockWidgetLayout(); - int count = 0; - for (int role = QDockWidgetLayout::CloseButton; role <= QDockWidgetLayout::FloatButton; ++role) { - QWidget *w = layout->widgetForRole((QDockWidgetLayout::Role)role); - if (w && w->isVisible()) - ++count; - } - return count; -} - -QString QAccessibleTitleBar::text(Text t, int child) const -{ - if (!child) { - if (t == Name || t == Value) { - return qt_accStripAmp(dockWidget()->windowTitle()); - } - } - return QString(); -} - -QAccessible::State QAccessibleTitleBar::state(int child) const -{ - QAccessible::State state = Normal; - if (child) { - QDockWidgetLayout *layout = dockWidgetLayout(); - QAbstractButton *b = static_cast(layout->widgetForRole((QDockWidgetLayout::Role)child)); - if (b) { - if (b->isDown()) - state |= Pressed; - } - } else { - QDockWidget *w = dockWidget(); - if (w->testAttribute(Qt::WA_WState_Visible) == false) - state |= Invisible; - if (w->focusPolicy() != Qt::NoFocus && w->isActiveWindow()) - state |= Focusable; - if (w->hasFocus()) - state |= Focused; - if (!w->isEnabled()) - state |= Unavailable; - } - - return state; -} - -QRect QAccessibleTitleBar::rect(int child) const -{ - bool mapToGlobal = true; - QRect rect; - if (child == 0) { - if (dockWidget()->isFloating()) { - rect = dockWidget()->frameGeometry(); - if (dockWidget()->widget()) { - QPoint globalPos = dockWidget()->mapToGlobal(dockWidget()->widget()->rect().topLeft()); - globalPos.ry()--; - rect.setBottom(globalPos.y()); - mapToGlobal = false; - } - } else { - QDockWidgetLayout *layout = qobject_cast(dockWidget()->layout()); - rect = layout->titleArea(); - } - }else if (child >= 1 && child <= childCount()) { - QDockWidgetLayout *layout = dockWidgetLayout(); - int index = 1; - for (int role = QDockWidgetLayout::CloseButton; role <= QDockWidgetLayout::FloatButton; ++role) { - QWidget *w = layout->widgetForRole((QDockWidgetLayout::Role)role); - if (!w || !w->isVisible()) - continue; - if (index == child) { - rect = w->geometry(); - break; - } - ++index; - } - } - if (rect.isNull()) - return rect; - - if (mapToGlobal) - rect.moveTopLeft(dockWidget()->mapToGlobal(rect.topLeft())); - return rect; -} - -int QAccessibleTitleBar::childAt(int x, int y) const -{ - for (int i = childCount(); i >= 0; --i) { - if (rect(i).contains(x,y)) - return i; - } - return -1; -} - -QObject *QAccessibleTitleBar::object() const -{ - return 0; -} - -QDockWidgetLayout *QAccessibleTitleBar::dockWidgetLayout() const -{ - return qobject_cast(dockWidget()->layout()); -} - -QDockWidget *QAccessibleTitleBar::dockWidget() const -{ - return m_dockWidget; -} - -QString QAccessibleTitleBar::actionText(int action, Text t, int child) const -{ - QString str; - if (child >= 1 && child <= childCount()) { - if (t == Name) { - switch (action) { - case Press: - case DefaultAction: - if (child == QDockWidgetLayout::CloseButton) { - str = QDockWidget::tr("Close"); - } else if (child == QDockWidgetLayout::FloatButton) { - str = dockWidget()->isFloating() ? QDockWidget::tr("Dock") - : QDockWidget::tr("Float"); - } - break; - default: - break; - } - } - } - return str; -} - -bool QAccessibleTitleBar::doAction(int action, int child, const QVariantList& /*params*/) -{ - if (!child || !dockWidget()->isEnabled()) - return false; - - switch (action) { - case DefaultAction: - case Press: { - QDockWidgetLayout *layout = dockWidgetLayout(); - QAbstractButton *btn = static_cast(layout->widgetForRole((QDockWidgetLayout::Role)child)); - if (btn) - btn->animateClick(); - return true; - break;} - default: - break; - } - - return false; -} - -int QAccessibleTitleBar::userActionCount (int /*child*/) const -{ - return 0; -} - -QAccessible::Role QAccessibleTitleBar::role(int child) const -{ - switch (child) { - case 0: - return TitleBar; - break; - default: - if (child >= 1 && child <= childCount()) - return PushButton; - break; - } - - return NoRole; -} - -void QAccessibleTitleBar::setText(Text /*t*/, int /*child*/, const QString &/*text*/) -{ - -} - -bool QAccessibleTitleBar::isValid() const -{ - return dockWidget(); -} - -#endif // QT_NO_DOCKWIDGET - -QAccessibleTextWidget::QAccessibleTextWidget(QWidget* o, QAccessible::Role r, const QString& name): - QAccessibleWidget(o, r, name) -{ -} - -void QAccessibleTextWidget::setAttributes(int startOffset, int endOffset, const QString& attributes) -{ - //TODO: not implemented - Q_UNUSED(startOffset); - Q_UNUSED(endOffset); - Q_UNUSED(attributes); -} - -QRect QAccessibleTextWidget::characterRect(int offset, CoordinateType coordType) -{ - QTextBlock block = textDocument()->findBlock(offset); - if (!block.isValid()) - return QRect(); - - QTextLayout *layout = block.layout(); - QPointF layoutPosition = layout->position(); - int relativeOffset = offset - block.position(); - QTextLine line = layout->lineForTextPosition(relativeOffset); - - QRect r; - - if (line.isValid()) { - qreal x = line.cursorToX(relativeOffset); - qreal w = 0; - - if ((relativeOffset - line.textStart())< line.textLength()) { - w = line.cursorToX(relativeOffset + 1) - x; - } else { - // If the width of a character is not known, IAccessible2 tells to return the width of a default character - int averageCharWidth = QFontMetrics(textCursor().charFormat().font()).averageCharWidth(); - if (block.blockFormat().layoutDirection() == Qt::RightToLeft) - averageCharWidth *= -1; - - r.setWidth(averageCharWidth); - } - int height = line.height(); - - // make sure that height does not include leading. (only ascent + descent + 1) - if (line.leadingIncluded()) - height -= qRound(line.leading()); - r = QRect(layoutPosition.x() + x, layoutPosition.y() + line.y(), - w, height); - - if (coordType == RelativeToScreen) { - r.moveTo(viewport()->mapToGlobal(r.topLeft())); - } - - r.translate(-scrollBarPosition()); - } - - return r; -} - -int QAccessibleTextWidget::offsetAtPoint(const QPoint &point, CoordinateType coordType) -{ - QPoint p = point; - if (coordType == RelativeToScreen) - p = viewport()->mapFromGlobal(p); - - p += scrollBarPosition(); - - return textDocument()->documentLayout()->hitTest(p, Qt::ExactHit); -} - -int QAccessibleTextWidget::selectionCount() -{ - return textCursor().hasSelection() ? 1 : 0; -} - -QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *endOffset) -{ - /* The list of attributes can be found at: - http://linuxfoundation.org/collaborate/workgroups/accessibility/iaccessible2/textattributes - */ - - if (offset >= characterCount()) { - *startOffset = -1; - *endOffset = -1; - return QString(); - } - - QMap attrs; - - QTextCursor cursor = textCursor(); - - //cursor.charFormat returns the format of the previous character - cursor.setPosition(offset + 1); - QTextCharFormat charFormat = cursor.charFormat(); - - cursor.setPosition(offset); - QTextBlockFormat blockFormat = cursor.blockFormat(); - - QTextCharFormat charFormatComp; - QTextBlockFormat blockFormatComp; - - *startOffset = offset; - cursor.setPosition(*startOffset); - while (*startOffset > 0) { - charFormatComp = cursor.charFormat(); - cursor.setPosition(*startOffset - 1); - blockFormatComp = cursor.blockFormat(); - if ((charFormat == charFormatComp) && (blockFormat == blockFormatComp)) - (*startOffset)--; - else - break; - } - - int limit = characterCount() + 1; - *endOffset = offset + 1; - cursor.setPosition(*endOffset); - while (*endOffset < limit) { - blockFormatComp = cursor.blockFormat(); - cursor.setPosition(*endOffset + 1); - charFormatComp = cursor.charFormat(); - if ((charFormat == charFormatComp) && (cursor.blockFormat() == blockFormatComp)) - (*endOffset)++; - else - break; - } - - QString family = charFormat.fontFamily(); - if (!family.isEmpty()) { - family = family.replace(QLatin1Char('\\'), QLatin1String("\\\\")); - family = family.replace(QLatin1Char(':'), QLatin1String("\\:")); - family = family.replace(QLatin1Char(','), QLatin1String("\\,")); - family = family.replace(QLatin1Char('='), QLatin1String("\\=")); - family = family.replace(QLatin1Char(';'), QLatin1String("\\;")); - family = family.replace(QLatin1Char('\"'), QLatin1String("\\\"")); - attrs[QLatin1String("font-family")] = QLatin1Char('"') + family + QLatin1Char('"'); - } - - int fontSize = int(charFormat.fontPointSize()); - if (fontSize) - attrs[QLatin1String("font-size")] = QString::number(fontSize).append(QLatin1String("pt")); - - //Different weight values are not handled - attrs[QLatin1String("font-weight")] = (charFormat.fontWeight() > QFont::Normal) ? QLatin1String("bold") : QLatin1String("normal"); - - QFont::Style style = charFormat.font().style(); - attrs[QLatin1String("font-style")] = (style == QFont::StyleItalic) ? QLatin1String("italic") : ((style == QFont::StyleOblique) ? QLatin1String("oblique"): QLatin1String("normal")); - - attrs[QLatin1String("text-underline-style")] = charFormat.font().underline() ? QLatin1String("solid") : QLatin1String("none"); - - QTextCharFormat::VerticalAlignment alignment = charFormat.verticalAlignment(); - attrs[QLatin1String("text-position")] = (alignment == QTextCharFormat::AlignSubScript) ? QLatin1String("sub") : ((alignment == QTextCharFormat::AlignSuperScript) ? QLatin1String("super") : QLatin1String("baseline") ); - - QBrush background = charFormat.background(); - QString rgbString = QString::fromLatin1("rgb(%1,%2,%3)").arg(background.color().red()).arg(background.color().green()).arg(background.color().blue()); - if (background.style() == Qt::SolidPattern) { - attrs[QLatin1String("background-color")] = rgbString; - } - - QBrush foreground = charFormat.foreground(); - if (foreground.style() == Qt::SolidPattern) { - attrs[QLatin1String("color")] = rgbString; - } - - switch (blockFormat.alignment() & (Qt::AlignLeft | Qt::AlignRight | Qt::AlignHCenter | Qt::AlignJustify)) { - case Qt::AlignLeft: - attrs[QLatin1String("text-align")] = QLatin1String("left"); - break; - case Qt::AlignRight: - attrs[QLatin1String("text-align")] = QLatin1String("right"); - break; - case Qt::AlignHCenter: - attrs[QLatin1String("text-align")] = QLatin1String("center"); - break; - case Qt::AlignJustify: - attrs[QLatin1String("text-align")] = QLatin1String("left"); - break; - } - - QString result; - foreach (const QString &attributeName, attrs.keys()) { - result.append(attributeName).append(QLatin1Char(':')).append(attrs[attributeName]).append(QLatin1Char(';')); - } - - return result; -} - -int QAccessibleTextWidget::cursorPosition() -{ - return textCursor().position(); -} - -void QAccessibleTextWidget::selection(int selectionIndex, int *startOffset, int *endOffset) -{ - *startOffset = *endOffset = 0; - QTextCursor cursor = textCursor(); - - if (selectionIndex != 0 || !cursor.hasSelection()) - return; - - *startOffset = cursor.selectionStart(); - *endOffset = cursor.selectionEnd(); -} - -QString QAccessibleTextWidget::text(int startOffset, int endOffset) -{ - QTextCursor cursor = textCursor(); - - cursor.setPosition(startOffset, QTextCursor::MoveAnchor); - cursor.setPosition(endOffset, QTextCursor::KeepAnchor); - - return cursor.selectedText(); -} - -QPoint QAccessibleTextWidget::scrollBarPosition() const -{ - return QPoint(0, 0); -} - -QPair< int, int > QAccessibleTextWidget::getBoundaries(int offset, BoundaryType boundaryType) -{ - if (offset >= characterCount()) - return QPair(characterCount(), characterCount()); - if (offset < 0) - return QPair(0, 0); - - QTextCursor cursor = textCursor(); - - QPair result; - - cursor.setPosition(offset); - switch (boundaryType) { - case CharBoundary: - result.first = cursor.position(); - cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); - result.second = cursor.position(); - break; - case WordBoundary: - cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor); - result.first = cursor.position(); - cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); - result.second = cursor.position(); - break; - case SentenceBoundary: - // TODO - what's a sentence? - case LineBoundary: - cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor); - result.first = cursor.position(); - cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor); - result.second = cursor.position(); - break; - case ParagraphBoundary: - cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::MoveAnchor); - result.first = cursor.position(); - cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); - result.second = cursor.position(); - break; - case NoBoundary: - result.first = 0; - result.second = characterCount(); - break; - default: - qDebug("QAccessibleTextWidget::getBoundaries: Unknown boundary type %d", boundaryType); - result.first = -1; - result.second = -1; - } - return result; -} - -QString QAccessibleTextWidget::textBeforeOffset (int offset, BoundaryType boundaryType, - int *startOffset, int *endOffset) -{ - Q_ASSERT(startOffset); - Q_ASSERT(endOffset); - - QPair boundaries = getBoundaries(offset, boundaryType); - boundaries = getBoundaries(boundaries.first - 1, boundaryType); - - *startOffset = boundaries.first; - *endOffset = boundaries.second; - - return text(boundaries.first, boundaries.second); -} - -QString QAccessibleTextWidget::textAfterOffset (int offset, BoundaryType boundaryType, - int *startOffset, int *endOffset) -{ - Q_ASSERT(startOffset); - Q_ASSERT(endOffset); - - QPair boundaries = getBoundaries(offset, boundaryType); - boundaries = getBoundaries(boundaries.second, boundaryType); - - *startOffset = boundaries.first; - *endOffset = boundaries.second; - - return text(boundaries.first, boundaries.second); -} - -QString QAccessibleTextWidget::textAtOffset(int offset, BoundaryType boundaryType, - int *startOffset, int *endOffset) -{ - Q_ASSERT(startOffset); - Q_ASSERT(endOffset); - - QPair boundaries = getBoundaries(offset, boundaryType); - - *startOffset = boundaries.first; - *endOffset = boundaries.second; - - return text(boundaries.first, boundaries.second); -} - -void QAccessibleTextWidget::setCursorPosition(int position) -{ - QTextCursor cursor = textCursor(); - cursor.setPosition(position); - setTextCursor(cursor); -} - -void QAccessibleTextWidget::addSelection(int startOffset, int endOffset) -{ - setSelection(0, startOffset, endOffset); -} - -void QAccessibleTextWidget::removeSelection(int selectionIndex) -{ - if (selectionIndex != 0) - return; - - QTextCursor cursor = textCursor(); - cursor.clearSelection(); - setTextCursor(cursor); -} - -void QAccessibleTextWidget::setSelection(int selectionIndex, int startOffset, int endOffset) -{ - if (selectionIndex != 0) - return; - - QTextCursor cursor = textCursor(); - cursor.setPosition(startOffset, QTextCursor::MoveAnchor); - cursor.setPosition(endOffset, QTextCursor::KeepAnchor); - setTextCursor(cursor); -} - -int QAccessibleTextWidget::characterCount() -{ - QTextCursor cursor = textCursor(); - cursor.movePosition(QTextCursor::End); - return cursor.position(); -} - -QTextCursor QAccessibleTextWidget::textCursorForRange(int startOffset, int endOffset) const -{ - QTextCursor cursor = textCursor(); - cursor.setPosition(startOffset, QTextCursor::MoveAnchor); - cursor.setPosition(endOffset, QTextCursor::KeepAnchor); - - return cursor; -} - -void QAccessibleTextWidget::deleteText(int startOffset, int endOffset) -{ - QTextCursor cursor = textCursorForRange(startOffset, endOffset); - - cursor.removeSelectedText(); -} - -void QAccessibleTextWidget::insertText(int offset, const QString &text) -{ - QTextCursor cursor = textCursor(); - cursor.setPosition(offset); - - cursor.insertText(text); -} - -void QAccessibleTextWidget::replaceText(int startOffset, int endOffset, const QString &text) -{ - QTextCursor cursor = textCursorForRange(startOffset, endOffset); - - cursor.removeSelectedText(); - cursor.insertText(text); -} - -void QAccessibleTextWidget::copyText(int startOffset, int endOffset) -{ -#ifndef QT_NO_CLIPBOARD - QString text = this->text(startOffset, endOffset); - QApplication::clipboard()->setText(text); -#endif -} - -void QAccessibleTextWidget::cutText(int startOffset, int endOffset) -{ -#ifndef QT_NO_CLIPBOARD - QString text = this->text(startOffset, endOffset); - QApplication::clipboard()->setText(text); - deleteText(startOffset, endOffset); -#endif -} - -void QAccessibleTextWidget::pasteText(int offset) -{ -#ifndef QT_NO_CLIPBOARD - QString text = QApplication::clipboard()->text(); - insertText(offset, text); -#endif -} - -#ifndef QT_NO_TEXTEDIT -void QAccessibleTextEdit::scrollToSubstring(int startIndex, int endIndex) -{ - QTextEdit *edit = textEdit(); - - QTextCursor cursor(edit->document()); - cursor.setPosition(startIndex); - QRect r = edit->cursorRect(cursor); - - cursor.setPosition(endIndex); - r.setBottomRight(edit->cursorRect(cursor).bottomRight()); - - r.moveTo(r.x() + edit->horizontalScrollBar()->value(), - r.y() + edit->verticalScrollBar()->value()); - - // E V I L, but ensureVisible is not public - if (!QMetaObject::invokeMethod(edit, "_q_ensureVisible", Q_ARG(QRectF, r))) - qWarning("AccessibleTextEdit::scrollToSubstring failed!"); -} - -void QAccessibleTextEdit::copyText(int startOffset, int endOffset) -{ -#ifndef QT_NO_CLIPBOARD - QTextCursor previousCursor = textEdit()->textCursor(); - QTextCursor cursor = textCursorForRange(startOffset, endOffset); - - if (!cursor.hasSelection()) - return; - - textEdit()->setTextCursor(cursor); - textEdit()->copy(); - textEdit()->setTextCursor(previousCursor); -#endif -} - -void QAccessibleTextEdit::cutText(int startOffset, int endOffset) -{ -#ifndef QT_NO_CLIPBOARD - QTextCursor cursor = textCursorForRange(startOffset, endOffset); - - if (!cursor.hasSelection()) - return; - - textEdit()->setTextCursor(cursor); - textEdit()->cut(); -#endif -} - -void QAccessibleTextEdit::pasteText(int offset) -{ - QTextEdit *edit = textEdit(); - - QTextCursor oldCursor = edit->textCursor(); - QTextCursor newCursor = oldCursor; - newCursor.setPosition(offset); - - edit->setTextCursor(newCursor); -#ifndef QT_NO_CLIPBOARD - edit->paste(); -#endif - edit->setTextCursor(oldCursor); -} - -void QAccessibleTextEdit::setAttributes(int startOffset, int endOffset, const QString &attributes) -{ - // TODO - Q_UNUSED(startOffset); - Q_UNUSED(endOffset); - Q_UNUSED(attributes); -} - -#endif // QT_NO_TEXTEDIT - -#ifndef QT_NO_MAINWINDOW -QAccessibleMainWindow::QAccessibleMainWindow(QWidget *widget) - : QAccessibleWidget(widget, Window) { } - -QVariant QAccessibleMainWindow::invokeMethod(QAccessible::Method /*method*/, int /*child*/, const QVariantList & /*params*/) -{ - return QVariant(); -} - -int QAccessibleMainWindow::childCount() const -{ - QList kids = childWidgets(mainWindow(), true); - return kids.count(); -} - -int QAccessibleMainWindow::indexOfChild(const QAccessibleInterface *iface) const -{ - QList kids = childWidgets(mainWindow(), true); - int childIndex = kids.indexOf(static_cast(iface->object())); - return childIndex == -1 ? -1 : ++childIndex; -} - -int QAccessibleMainWindow::navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const -{ - if (relation == Child && entry >= 1) { - QList kids = childWidgets(mainWindow(), true); - if (entry <= kids.count()) { - *iface = QAccessible::queryAccessibleInterface(kids.at(entry - 1)); - return *iface ? 0 : -1; - } - } - return QAccessibleWidget::navigate(relation, entry, iface); -} - -int QAccessibleMainWindow::childAt(int x, int y) const -{ - QWidget *w = widget(); - if (!w->isVisible()) - return -1; - QPoint gp = w->mapToGlobal(QPoint(0, 0)); - if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y)) - return -1; - - QWidgetList kids = childWidgets(mainWindow(), true); - QPoint rp = mainWindow()->mapFromGlobal(QPoint(x, y)); - for (int i = 0; i < kids.size(); ++i) { - QWidget *child = kids.at(i); - if (!child->isWindow() && !child->isHidden() && child->geometry().contains(rp)) { - return i + 1; - } - } - return 0; -} - -QMainWindow *QAccessibleMainWindow::mainWindow() const -{ - return qobject_cast(object()); -} - -#endif //QT_NO_MAINWINDOW - -QT_END_NAMESPACE - -#endif // QT_NO_ACCESSIBILITY diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.h b/src/plugins/accessible/widgets/qaccessiblewidgets.h deleted file mode 100644 index 3afdcec2c..000000000 --- a/src/plugins/accessible/widgets/qaccessiblewidgets.h +++ /dev/null @@ -1,355 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the plugins of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QACCESSIBLEWIDGETS_H -#define QACCESSIBLEWIDGETS_H - -#include -#include - -#ifndef QT_NO_ACCESSIBILITY - -#include -#include - -QT_BEGIN_NAMESPACE - -class QTextEdit; -class QStackedWidget; -class QToolBox; -class QMdiArea; -class QMdiSubWindow; -class QWorkspace; -class QRubberBand; -class QTextBrowser; -class QCalendarWidget; -class QAbstractItemView; -class QDockWidget; -class QDockWidgetLayout; -class QMainWindow; -class QPlainTextEdit; -class QTextCursor; -class QTextDocument; - -class QAccessibleTextWidget : public QAccessibleWidget, - public QAccessibleTextInterface, - public QAccessibleEditableTextInterface -{ -public: - QAccessibleTextWidget(QWidget *o, Role r = EditableText, const QString& name = QString()); - void addSelection(int startOffset, int endOffset); - void setSelection(int selectionIndex, int startOffset, int endOffset); - void removeSelection(int selectionIndex); - void selection(int selectionIndex, int *startOffset, int *endOffset); - int selectionCount(); - - int characterCount(); - - void setCursorPosition(int position); - int cursorPosition(); - - QString text(int startOffset, int endOffset); - - QString textAtOffset(int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset); - QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset); - QString textAfterOffset(int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset); - - QString attributes(int offset, int *startOffset, int *endOffset); - - void deleteText(int startOffset, int endOffset); - void insertText(int offset, const QString &text); - - void copyText(int startOffset, int endOffset); - void cutText(int startOffset, int endOffset); - void pasteText(int offset); - void setAttributes(int startOffset, int endOffset, const QString &attributes); - - void replaceText(int startOffset, int endOffset, const QString &text); - - QRect characterRect(int offset, QAccessible2::CoordinateType coordType); - int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType); -protected: - QTextCursor textCursorForRange(int startOffset, int endOffset) const; - QPair getBoundaries(int offset, QAccessible2::BoundaryType boundaryType); - virtual QPoint scrollBarPosition() const; - virtual QTextCursor textCursor() const = 0; - virtual void setTextCursor(const QTextCursor &) = 0; - virtual QTextDocument *textDocument() const = 0; - virtual QWidget *viewport() const = 0; -}; - -class QAccessiblePlainTextEdit : public QAccessibleTextWidget -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessiblePlainTextEdit(QWidget *o); - - int childCount() const; - - // QAccessibleTextInterface - void scrollToSubstring(int startIndex, int endIndex); -protected: - QPlainTextEdit *plainTextEdit() const; - - QPoint scrollBarPosition() const; - QTextCursor textCursor() const; - void setTextCursor(const QTextCursor &textCursor); - QTextDocument *textDocument() const; - QWidget *viewport() const; -}; - -#ifndef QT_NO_TEXTEDIT -class QAccessibleTextEdit : public QAccessibleTextWidget -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleTextEdit(QWidget *o); - - QString text(Text t, int child) const; - void setText(Text t, int control, const QString &text); - Role role(int child) const; - - QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms); - - QRect rect(int child) const; - int childAt(int x, int y) const; - - int childCount() const; - - // QAccessibleTextInterface - void scrollToSubstring(int startIndex, int endIndex); - - // QAccessibleEditableTextInterface - void copyText(int startOffset, int endOffset); - void cutText(int startOffset, int endOffset); - void pasteText(int offset); - void setAttributes(int startOffset, int endOffset, const QString &attributes); - -protected: - QTextEdit *textEdit() const; - - QPoint scrollBarPosition() const; - QTextCursor textCursor() const; - void setTextCursor(const QTextCursor &textCursor); - QTextDocument *textDocument() const; - QWidget *viewport() const; -private: - int childOffset; -}; -#endif // QT_NO_TEXTEDIT - -class QAccessibleStackedWidget : public QAccessibleWidget -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleStackedWidget(QWidget *widget); - - QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms); - int childAt(int x, int y) const; - int childCount() const; - int indexOfChild(const QAccessibleInterface *child) const; - int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const; - -protected: - QStackedWidget *stackedWidget() const; -}; - -class QAccessibleToolBox : public QAccessibleWidget -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleToolBox(QWidget *widget); - - QString text(Text textType, int child) const; - void setText(Text textType, int child, const QString &text); - State state(int child) const; - QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms); - int childCount() const; - int indexOfChild(const QAccessibleInterface *child) const; - int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const; - -protected: - QToolBox *toolBox() const; -}; - -#ifndef QT_NO_MDIAREA -class QAccessibleMdiArea : public QAccessibleWidget -{ -public: - explicit QAccessibleMdiArea(QWidget *widget); - - State state(int child) const; - QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms); - int childCount() const; - int indexOfChild(const QAccessibleInterface *child) const; - int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const; - -protected: - QMdiArea *mdiArea() const; -}; - -class QAccessibleMdiSubWindow : public QAccessibleWidget -{ -public: - explicit QAccessibleMdiSubWindow(QWidget *widget); - - QString text(Text textType, int child) const; - void setText(Text textType, int child, const QString &text); - State state(int child) const; - QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms); - int childCount() const; - int indexOfChild(const QAccessibleInterface *child) const; - int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const; - QRect rect(int child) const; - int childAt(int x, int y) const; - -protected: - QMdiSubWindow *mdiSubWindow() const; -}; -#endif // QT_NO_MDIAREA - -#ifndef QT_NO_WORKSPACE -class QAccessibleWorkspace : public QAccessibleWidget -{ -public: - explicit QAccessibleWorkspace(QWidget *widget); - - State state(int child) const; - QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms); - int childCount() const; - int indexOfChild(const QAccessibleInterface *child) const; - int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const; - -protected: - QWorkspace *workspace() const; -}; -#endif - -class QAccessibleDialogButtonBox : public QAccessibleWidget -{ -public: - explicit QAccessibleDialogButtonBox(QWidget *widget); - - QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms); -}; - -#ifndef QT_NO_TEXTBROWSER -class QAccessibleTextBrowser : public QAccessibleTextEdit -{ -public: - explicit QAccessibleTextBrowser(QWidget *widget); - - Role role(int child) const; -}; -#endif // QT_NO_TEXTBROWSER - -#ifndef QT_NO_CALENDARWIDGET -class QAccessibleCalendarWidget : public QAccessibleWidget -{ -public: - explicit QAccessibleCalendarWidget(QWidget *widget); - - QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms); - int childCount() const; - int indexOfChild(const QAccessibleInterface *child) const; - int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const; - QRect rect(int child) const; - int childAt(int x, int y) const; - -protected: - QCalendarWidget *calendarWidget() const; - -private: - QAbstractItemView *calendarView() const; - QWidget *navigationBar() const; -}; -#endif // QT_NO_CALENDARWIDGET - -#ifndef QT_NO_DOCKWIDGET -class QAccessibleDockWidget: public QAccessibleWidget -{ -public: - explicit QAccessibleDockWidget(QWidget *widget); - int navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const; - int indexOfChild(const QAccessibleInterface *child) const; - int childCount() const; - QRect rect (int child ) const; - Role role(int child) const; - State state(int child) const; - int childAt(int x, int y) const; - - QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms); - QDockWidget *dockWidget() const; -}; - -class QAccessibleTitleBar : public QAccessibleInterface -{ -public: - explicit QAccessibleTitleBar(QDockWidget *widget); - QString actionText(int action, Text t, int child) const; - bool doAction(int action, int child, const QVariantList& params = QVariantList()); - int userActionCount ( int child) const; - int navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const; - int indexOfChild(const QAccessibleInterface *child) const; - int childCount() const; - Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const; - void setText(Text t, int child, const QString &text); - QString text(Text t, int child) const; - Role role(int child) const; - QRect rect (int child) const; - State state(int child) const; - int childAt(int x, int y) const; - QObject *object() const; - bool isValid() const; - - - QPointer m_dockWidget; - - QDockWidget *dockWidget() const; - QDockWidgetLayout *dockWidgetLayout() const; -}; - -#endif // QT_NO_DOCKWIDGET - -#ifndef QT_NO_MAINWINDOW -class QAccessibleMainWindow : public QAccessibleWidget -{ -public: - explicit QAccessibleMainWindow(QWidget *widget); - - QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms); - int childCount() const; - int navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const; - int indexOfChild(const QAccessibleInterface *iface) const; - int childAt(int x, int y) const; - QMainWindow *mainWindow() const; - -}; -#endif //QT_NO_MAINWINDOW - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - -#endif // QACESSIBLEWIDGETS_H diff --git a/src/plugins/accessible/widgets/rangecontrols.cpp b/src/plugins/accessible/widgets/rangecontrols.cpp deleted file mode 100644 index 5ef8cabb4..000000000 --- a/src/plugins/accessible/widgets/rangecontrols.cpp +++ /dev/null @@ -1,952 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the plugins of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "rangecontrols.h" - -#include "qslider.h" -#include "qdial.h" -#include "qspinbox.h" -#include "qscrollbar.h" -#include "qstyle.h" -#include "qstyleoption.h" -#include "qdebug.h" -#include "qglobal.h" -#include -#include -#include "qmath.h" - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACCESSIBILITY -extern QString Q_GUI_EXPORT qt_accStripAmp(const QString &text); -#ifndef QT_NO_SCROLLBAR -extern QStyleOptionSlider Q_GUI_EXPORT qt_qscrollbarStyleOption(QScrollBar *scrollBar); -#endif -#ifndef QT_NO_SLIDER -extern QStyleOptionSlider Q_GUI_EXPORT qt_qsliderStyleOption(QSlider *slider); -#endif - -#ifndef QT_NO_SPINBOX -QAccessibleAbstractSpinBox::QAccessibleAbstractSpinBox(QWidget *w) -: QAccessibleWidget(w, SpinBox) -{ - Q_ASSERT(abstractSpinBox()); -} - -/*! - Returns the underlying QAbstractSpinBox. -*/ -QAbstractSpinBox *QAccessibleAbstractSpinBox::abstractSpinBox() const -{ - return qobject_cast(object()); -} - -/*! \reimp */ -int QAccessibleAbstractSpinBox::childCount() const -{ - return ValueDown; -} - -/*! \reimp */ -QRect QAccessibleAbstractSpinBox::rect(int child) const -{ - QRect rect; - if (!abstractSpinBox()->isVisible()) - return rect; - QStyleOptionSpinBox so; - so.rect = widget()->rect(); - switch(child) { - case Editor: - rect = widget()->style()->subControlRect(QStyle::CC_SpinBox, &so, - QStyle::SC_SpinBoxEditField, widget()); - break; - case ValueUp: - rect = widget()->style()->subControlRect(QStyle::CC_SpinBox, &so, - QStyle::SC_SpinBoxUp, widget()); - break; - case ValueDown: - rect = widget()->style()->subControlRect(QStyle::CC_SpinBox, &so, - QStyle::SC_SpinBoxDown, widget()); - break; - default: - rect = so.rect; - break; - } - QPoint tl = widget()->mapToGlobal(QPoint(0, 0)); - return QRect(tl.x() + rect.x(), tl.y() + rect.y(), rect.width(), rect.height()); -} - -/*! \reimp */ -int QAccessibleAbstractSpinBox::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const -{ - *target = 0; - - if (entry) switch (rel) { - case Child: - return entry <= childCount() ? entry : -1; - case QAccessible::Left: - return (entry == ValueUp || entry == ValueDown) ? Editor : -1; - case QAccessible::Right: - return entry == Editor ? ValueUp : -1; - case QAccessible::Up: - return entry == ValueDown ? ValueUp : -1; - case QAccessible::Down: - return entry == ValueUp ? ValueDown : -1; - default: - break; - } - return QAccessibleWidget::navigate(rel, entry, target); -} - -/*! \reimp */ -QString QAccessibleAbstractSpinBox::text(Text t, int child) const -{ - if (!abstractSpinBox()->isVisible()) - return QString(); - switch (t) { - case Name: - switch (child) { - case ValueUp: - return QSpinBox::tr("More"); - case ValueDown: - return QSpinBox::tr("Less"); - } - break; - case Value: - if (child == Editor || child == SpinBoxSelf) - return abstractSpinBox()->text(); - break; - default: - break; - } - return QAccessibleWidget::text(t, 0); -} - -/*! \reimp */ -QAccessible::Role QAccessibleAbstractSpinBox::role(int child) const -{ - switch(child) { - case Editor: - return EditableText; - case ValueUp: - case ValueDown: - return PushButton; - default: - break; - } - return QAccessibleWidget::role(child); -} - -/*! \reimp */ -bool QAccessibleAbstractSpinBox::doAction(int action, int child, const QVariantList ¶ms) -{ - if (!widget()->isEnabled()) - return false; - - if (action == Press) { - switch(child) { - case ValueUp: - abstractSpinBox()->stepUp(); - return true; - case ValueDown: - abstractSpinBox()->stepDown(); - return true; - default: - break; - } - } - return QAccessibleWidget::doAction(action, 0, params); -} - -QVariant QAccessibleAbstractSpinBox::currentValue() -{ - QVariant result = abstractSpinBox()->property("value"); - QVariant::Type type = result.type(); - - // IA2 only allows numeric types - if (type == QVariant::Int || type == QVariant::UInt || type == QVariant::LongLong - || type == QVariant::ULongLong || type == QVariant::Double) - return result; - - return QVariant(); -} - -void QAccessibleAbstractSpinBox::setCurrentValue(const QVariant &value) -{ - abstractSpinBox()->setProperty("value", value); -} - -QVariant QAccessibleAbstractSpinBox::maximumValue() -{ - return abstractSpinBox()->property("maximum"); -} - -QVariant QAccessibleAbstractSpinBox::minimumValue() -{ - return abstractSpinBox()->property("minimum"); -} - -QVariant QAccessibleAbstractSpinBox::invokeMethod(Method method, int child, const QVariantList ¶ms) -{ - switch (method) { - case ListSupportedMethods: { - QSet set; - set << ListSupportedMethods; - return QVariant::fromValue(set | qvariant_cast >( - QAccessibleWidget::invokeMethod(method, child, params))); - } - default: - return QAccessibleWidget::invokeMethod(method, child, params); - } -} - - -/*! - \class QAccessibleSpinBox - \brief The QAccessibleSpinBox class implements the QAccessibleInterface for spinbox widgets. - \internal - - \ingroup accessibility -*/ - -/*! - \enum QAccessibleAbstractSpinBox::SpinBoxElements - - This enum identifies the components of the spin box. - - \value SpinBoxSelf The spin box as a whole - \value Editor The line edit sub-widget. - \value ValueUp The up sub-widget (i.e. the up arrow or + button) - \value ValueDown The down sub-widget (i.e. the down arrow or - button) -*/ - -/*! - Constructs a QAccessibleSpinWidget object for \a w. -*/ -QAccessibleSpinBox::QAccessibleSpinBox(QWidget *w) -: QAccessibleAbstractSpinBox(w) -{ - Q_ASSERT(spinBox()); - addControllingSignal(QLatin1String("valueChanged(int)")); - addControllingSignal(QLatin1String("valueChanged(QString)")); -} - -/*! - Returns the underlying QSpinBox. -*/ -QSpinBox *QAccessibleSpinBox::spinBox() const -{ - return qobject_cast(object()); -} - -/*! \reimp */ -QAccessible::State QAccessibleSpinBox::state(int child) const -{ - State state = QAccessibleAbstractSpinBox::state(child); - switch(child) { - case ValueUp: - if (spinBox()->value() >= spinBox()->maximum()) - state |= Unavailable; - return state; - case ValueDown: - if (spinBox()->value() <= spinBox()->minimum()) - state |= Unavailable; - return state; - default: - break; - } - return state; -} - -/*! \reimp */ -bool QAccessibleSpinBox::doAction(int action, int child, const QVariantList ¶ms) -{ - if (!widget()->isEnabled()) - return false; - - if (action == Press) { - switch(child) { - case ValueUp: - if (spinBox()->value() >= spinBox()->maximum()) - return false; - spinBox()->stepUp(); - return true; - case ValueDown: - if (spinBox()->value() <= spinBox()->minimum()) - return false; - spinBox()->stepDown(); - return true; - default: - break; - } - } - return QAccessibleAbstractSpinBox::doAction(action, 0, params); -} - -// ================================== QAccessibleDoubleSpinBox ================================== -QAccessibleDoubleSpinBox::QAccessibleDoubleSpinBox(QWidget *widget) - : QAccessibleWidget(widget, SpinBox) -{ - Q_ASSERT(qobject_cast(widget)); - addControllingSignal(QLatin1String("valueChanged(double)")); - addControllingSignal(QLatin1String("valueChanged(QString)")); -} - -/*! - Returns the underlying QDoubleSpinBox. -*/ -QDoubleSpinBox *QAccessibleDoubleSpinBox::doubleSpinBox() const -{ - return static_cast(object()); -} - -/*! \reimp */ -int QAccessibleDoubleSpinBox::childCount() const -{ - return ValueDown; -} - -/*! \reimp */ -QRect QAccessibleDoubleSpinBox::rect(int child) const -{ - QRect rect; - if (!doubleSpinBox()->isVisible()) - return rect; - QStyleOptionSpinBox spinBoxOption; - spinBoxOption.initFrom(doubleSpinBox()); - switch (child) { - case Editor: - rect = doubleSpinBox()->style()->subControlRect(QStyle::CC_SpinBox, &spinBoxOption, - QStyle::SC_SpinBoxEditField, doubleSpinBox()); - break; - case ValueUp: - rect = doubleSpinBox()->style()->subControlRect(QStyle::CC_SpinBox, &spinBoxOption, - QStyle::SC_SpinBoxUp, doubleSpinBox()); - break; - case ValueDown: - rect = doubleSpinBox()->style()->subControlRect(QStyle::CC_SpinBox, &spinBoxOption, - QStyle::SC_SpinBoxDown, doubleSpinBox()); - break; - default: - rect = spinBoxOption.rect; - break; - } - const QPoint globalPos = doubleSpinBox()->mapToGlobal(QPoint(0, 0)); - return QRect(globalPos.x() + rect.x(), globalPos.y() + rect.y(), rect.width(), rect.height()); -} - -/*! \reimp */ -int QAccessibleDoubleSpinBox::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - if (entry <= 0) - return QAccessibleWidget::navigate(relation, entry, target); - - *target = 0; - switch (relation) { - case Child: - return entry <= childCount() ? entry : -1; - case QAccessible::Left: - return (entry == ValueUp || entry == ValueDown) ? Editor : -1; - case QAccessible::Right: - return entry == Editor ? ValueUp : -1; - case QAccessible::Up: - return entry == ValueDown ? ValueUp : -1; - case QAccessible::Down: - return entry == ValueUp ? ValueDown : -1; - default: - break; - } - return QAccessibleWidget::navigate(relation, entry, target); -} - -QVariant QAccessibleDoubleSpinBox::invokeMethod(QAccessible::Method, int, const QVariantList &) -{ - return QVariant(); -} - -/*! \reimp */ -QString QAccessibleDoubleSpinBox::text(Text textType, int child) const -{ - switch (textType) { - case Name: - if (child == ValueUp) - return QDoubleSpinBox::tr("More"); - else if (child == ValueDown) - return QDoubleSpinBox::tr("Less"); - break; - case Value: - if (child == Editor || child == SpinBoxSelf) - return doubleSpinBox()->textFromValue(doubleSpinBox()->value()); - break; - default: - break; - } - return QAccessibleWidget::text(textType, 0); -} - -/*! \reimp */ -QAccessible::Role QAccessibleDoubleSpinBox::role(int child) const -{ - switch (child) { - case Editor: - return EditableText; - case ValueUp: - case ValueDown: - return PushButton; - default: - break; - } - return QAccessibleWidget::role(child); -} - -/*! \reimp */ -QAccessible::State QAccessibleDoubleSpinBox::state(int child) const -{ - State state = QAccessibleWidget::state(child); - switch (child) { - case ValueUp: - if (doubleSpinBox()->value() >= doubleSpinBox()->maximum()) - state |= Unavailable; - break; - case ValueDown: - if (doubleSpinBox()->value() <= doubleSpinBox()->minimum()) - state |= Unavailable; - break; - default: - break; - } - return state; -} -#endif // QT_NO_SPINBOX - -#ifndef QT_NO_SCROLLBAR -/*! - \class QAccessibleScrollBar - \brief The QAccessibleScrollBar class implements the QAccessibleInterface for scroll bars. - \internal - - \ingroup accessibility -*/ - -/*! - \enum QAccessibleScrollBar::ScrollBarElements - - This enum identifies the components of the scroll bar. - - \value ScrollBarSelf The scroll bar as a whole. - \value LineUp The up arrow button. - \value PageUp The area between the position and the up arrow button. - \value Position The position marking rectangle. - \value PageDown The area between the position and the down arrow button. - \value LineDown The down arrow button. -*/ - -/*! - Constructs a QAccessibleScrollBar object for \a w. - \a name is propagated to the QAccessibleWidget constructor. -*/ -QAccessibleScrollBar::QAccessibleScrollBar(QWidget *w) -: QAccessibleAbstractSlider(w, ScrollBar) -{ - Q_ASSERT(scrollBar()); - addControllingSignal(QLatin1String("valueChanged(int)")); -} - -/*! Returns the scroll bar. */ -QScrollBar *QAccessibleScrollBar::scrollBar() const -{ - return qobject_cast(object()); -} - -/*! \reimp */ -QRect QAccessibleScrollBar::rect(int child) const -{ - if (!scrollBar()->isVisible()) - return QRect(); - - QStyle::SubControl subControl; - switch (child) { - case LineUp: - subControl = QStyle ::SC_ScrollBarSubLine; - break; - case PageUp: - subControl = QStyle::SC_ScrollBarSubPage; - break; - case Position: - subControl = QStyle::SC_ScrollBarSlider; - break; - case PageDown: - subControl = QStyle::SC_ScrollBarAddPage; - break; - case LineDown: - subControl = QStyle::SC_ScrollBarAddLine; - break; - default: - return QAccessibleAbstractSlider::rect(child); - } - - const QStyleOptionSlider option = qt_qscrollbarStyleOption(scrollBar()); - const QRect rect = scrollBar()->style()->subControlRect(QStyle::CC_ScrollBar, &option, - subControl, scrollBar()); - const QPoint tp = scrollBar()->mapToGlobal(QPoint(0,0)); - return QRect(tp.x() + rect.x(), tp.y() + rect.y(), rect.width(), rect.height()); -} - -/*! \reimp */ -int QAccessibleScrollBar::childCount() const -{ - return LineDown; -} - -/*! \reimp */ -QString QAccessibleScrollBar::text(Text t, int child) const -{ - switch (t) { - case Value: - if (!child || child == Position) - return QString::number(scrollBar()->value()); - return QString(); - case Name: - switch (child) { - case LineUp: - return QScrollBar::tr("Line up"); - case PageUp: - return QScrollBar::tr("Page up"); - case Position: - return QScrollBar::tr("Position"); - case PageDown: - return QScrollBar::tr("Page down"); - case LineDown: - return QScrollBar::tr("Line down"); - } - break; - default: - break; - } - return QAccessibleAbstractSlider::text(t, child); -} - -/*! \reimp */ -QAccessible::Role QAccessibleScrollBar::role(int child) const -{ - switch (child) { - case LineUp: - case PageUp: - case PageDown: - case LineDown: - return PushButton; - case Position: - return Indicator; - default: - return ScrollBar; - } -} - -/*! \reimp */ -QAccessible::State QAccessibleScrollBar::state(int child) const -{ - const State parentState = QAccessibleAbstractSlider::state(0); - - if (child == 0) - return parentState; - - // Inherit the Invisible state from parent. - State state = parentState & QAccessible::Invisible; - - // Disable left/right if we are at the minimum/maximum. - const QScrollBar * const scrollBar = QAccessibleScrollBar::scrollBar(); - switch (child) { - case LineUp: - case PageUp: - if (scrollBar->value() <= scrollBar->minimum()) - state |= Unavailable; - break; - case LineDown: - case PageDown: - if (scrollBar->value() >= scrollBar->maximum()) - state |= Unavailable; - break; - case Position: - default: - break; - } - - return state; -} -#endif // QT_NO_SCROLLBAR - -#ifndef QT_NO_SLIDER -/*! - \class QAccessibleSlider - \brief The QAccessibleSlider class implements the QAccessibleInterface for sliders. - \internal - - \ingroup accessibility -*/ - -/*! - \enum QAccessibleSlider::SliderElements - - This enum identifies the components of the slider. - - \value SliderSelf The slider as a whole. - \value PageLeft The area to the left of the position. - \value Position The position indicator. - \value PageRight The area to the right of the position. -*/ - -/*! - Constructs a QAccessibleScrollBar object for \a w. - \a name is propagated to the QAccessibleWidget constructor. -*/ -QAccessibleSlider::QAccessibleSlider(QWidget *w) -: QAccessibleAbstractSlider(w) -{ - Q_ASSERT(slider()); - addControllingSignal(QLatin1String("valueChanged(int)")); -} - -/*! Returns the slider. */ -QSlider *QAccessibleSlider::slider() const -{ - return qobject_cast(object()); -} - -/*! \reimp */ -QRect QAccessibleSlider::rect(int child) const -{ - QRect rect; - if (!slider()->isVisible()) - return rect; - const QStyleOptionSlider option = qt_qsliderStyleOption(slider()); - QRect srect = slider()->style()->subControlRect(QStyle::CC_Slider, &option, - QStyle::SC_SliderHandle, slider()); - - switch (child) { - case PageLeft: - if (slider()->orientation() == Qt::Vertical) - rect = QRect(0, 0, slider()->width(), srect.y()); - else - rect = QRect(0, 0, srect.x(), slider()->height()); - break; - case Position: - rect = srect; - break; - case PageRight: - if (slider()->orientation() == Qt::Vertical) - rect = QRect(0, srect.y() + srect.height(), slider()->width(), slider()->height()- srect.y() - srect.height()); - else - rect = QRect(srect.x() + srect.width(), 0, slider()->width() - srect.x() - srect.width(), slider()->height()); - break; - default: - return QAccessibleAbstractSlider::rect(child); - } - - QPoint tp = slider()->mapToGlobal(QPoint(0,0)); - return QRect(tp.x() + rect.x(), tp.y() + rect.y(), rect.width(), rect.height()); -} - -/*! \reimp */ -int QAccessibleSlider::childCount() const -{ - return PageRight; -} - -/*! \reimp */ -QString QAccessibleSlider::text(Text t, int child) const -{ - switch (t) { - case Value: - if (!child || child == 2) - return QString::number(slider()->value()); - return QString(); - case Name: - switch (child) { - case PageLeft: - return slider()->orientation() == Qt::Horizontal ? - QSlider::tr("Page left") : QSlider::tr("Page up"); - case Position: - return QSlider::tr("Position"); - case PageRight: - return slider()->orientation() == Qt::Horizontal ? - QSlider::tr("Page right") : QSlider::tr("Page down"); - } - break; - default: - break; - } - return QAccessibleAbstractSlider::text(t, child); -} - -/*! \reimp */ -QAccessible::Role QAccessibleSlider::role(int child) const -{ - switch (child) { - case PageLeft: - case PageRight: - return PushButton; - case Position: - return Indicator; - default: - return Slider; - } -} - -/*! \reimp */ -QAccessible::State QAccessibleSlider::state(int child) const -{ - const State parentState = QAccessibleAbstractSlider::state(0); - - if (child == 0) - return parentState; - - // Inherit the Invisible state from parent. - State state = parentState & QAccessible::Invisible; - - // Disable left/right if we are at the minimum/maximum. - const QSlider * const slider = QAccessibleSlider::slider(); - switch (child) { - case PageLeft: - if (slider->value() <= slider->minimum()) - state |= Unavailable; - break; - case PageRight: - if (slider->value() >= slider->maximum()) - state |= Unavailable; - break; - case Position: - default: - break; - } - - return state; -} - -/*! - \fn int QAccessibleSlider::defaultAction(int child) const - - Returns the default action for the given \a child. The base class - implementation returns 0. -*/ -int QAccessibleSlider::defaultAction(int /*child*/) const -{ -/* - switch (child) { - case SliderSelf: - return SetFocus; - case PageLeft: - return Press; - case PageRight: - return Press; - } -*/ - return 0; -} - -/*! \internal */ -QString QAccessibleSlider::actionText(int /*action*/, Text /*t*/, int /*child*/) const -{ - return QLatin1String(""); -} - -QAccessibleAbstractSlider::QAccessibleAbstractSlider(QWidget *w, Role r) - : QAccessibleWidget(w, r) -{ - Q_ASSERT(qobject_cast(w)); -} - -QVariant QAccessibleAbstractSlider::invokeMethod(Method method, int child, const QVariantList ¶ms) -{ - switch (method) { - case ListSupportedMethods: { - QSet set; - set << ListSupportedMethods; - return QVariant::fromValue(set | qvariant_cast >( - QAccessibleWidget::invokeMethod(method, child, params))); - } - default: - return QAccessibleWidget::invokeMethod(method, child, params); - } -} - -QVariant QAccessibleAbstractSlider::currentValue() -{ - return abstractSlider()->value(); -} - -void QAccessibleAbstractSlider::setCurrentValue(const QVariant &value) -{ - abstractSlider()->setValue(value.toInt()); -} - -QVariant QAccessibleAbstractSlider::maximumValue() -{ - return abstractSlider()->maximum(); -} - -QVariant QAccessibleAbstractSlider::minimumValue() -{ - return abstractSlider()->minimum(); -} - -QAbstractSlider *QAccessibleAbstractSlider::abstractSlider() const -{ - return static_cast(object()); -} - -#endif // QT_NO_SLIDER - -#ifndef QT_NO_DIAL -// ======================================= QAccessibleDial ====================================== -QAccessibleDial::QAccessibleDial(QWidget *widget) - : QAccessibleWidget(widget, Dial) -{ - Q_ASSERT(qobject_cast(widget)); - addControllingSignal(QLatin1String("valueChanged(int)")); -} - -QRect QAccessibleDial::rect(int child) const -{ - QRect rect; - if (!dial()->isVisible()) - return rect; - switch (child) { - case Self: - return QAccessibleWidget::rect(child); - case SpeedoMeter: { - // Mixture from qcommonstyle.cpp (focus rect). - int width = dial()->width(); - int height = dial()->height(); - qreal radius = qMin(width, height) / 2.0; - qreal delta = radius / 6.0; - qreal dx = delta + (width - 2 * radius) / 2.0; - qreal dy = delta + (height - 2 * radius) / 2.0; - rect = QRect(int(dx), int(dy), int(radius * 2 - 2 * delta), int(radius * 2 - 2 * delta)); - if (dial()->notchesVisible()) { - rect.translate(int(-radius / 6), int(-radius / 6)); - rect.setWidth(rect.width() + int(radius / 3)); - rect.setHeight(rect.height() + int(radius / 3)); - } - break; - } - case SliderHandle: { - // Mixture from qcommonstyle.cpp and qdial.cpp. - int sliderValue = !dial()->invertedAppearance() ? dial()->value() - : (dial()->maximum() - dial()->value()); - qreal angle = 0; - if (dial()->maximum() == dial()->minimum()) { - angle = M_PI_2; - } else if (dial()->wrapping()) { - angle = M_PI * 3 / 2 - (sliderValue - dial()->minimum()) * 2 * M_PI - / (dial()->maximum() - dial()->minimum()); - } else { - angle = (M_PI * 8 - (sliderValue - dial()->minimum()) * 10 * M_PI - / (dial()->maximum() - dial()->minimum())) / 6; - } - - int width = dial()->rect().width(); - int height = dial()->rect().height(); - int radius = qMin(width, height) / 2; - int xc = width / 2; - int yc = height / 2; - int bigLineSize = radius / 6; - if (bigLineSize < 4) - bigLineSize = 4; - if (bigLineSize > radius / 2) - bigLineSize = radius / 2; - int len = radius - bigLineSize - 5; - if (len < 5) - len = 5; - int back = len / 2; - - QPolygonF arrow(3); - arrow[0] = QPointF(0.5 + xc + len * qCos(angle), - 0.5 + yc - len * qSin(angle)); - arrow[1] = QPointF(0.5 + xc + back * qCos(angle + M_PI * 5 / 6), - 0.5 + yc - back * qSin(angle + M_PI * 5 / 6)); - arrow[2] = QPointF(0.5 + xc + back * qCos(angle - M_PI * 5 / 6), - 0.5 + yc - back * qSin(angle - M_PI * 5 / 6)); - rect = arrow.boundingRect().toRect(); - break; - } - default: - return QRect(); - } - - QPoint globalPos = dial()->mapToGlobal(QPoint(0,0)); - return QRect(globalPos.x() + rect.x(), globalPos.y() + rect.y(), rect.width(), rect.height()); -} - -int QAccessibleDial::childCount() const -{ - return SliderHandle; -} - -QString QAccessibleDial::text(Text textType, int child) const -{ - if (textType == Value && child >= Self && child <= SliderHandle) - return QString::number(dial()->value()); - if (textType == Name) { - switch (child) { - case Self: - if (!widget()->accessibleName().isEmpty()) - return widget()->accessibleName(); - return QDial::tr("QDial"); - case SpeedoMeter: - return QDial::tr("SpeedoMeter"); - case SliderHandle: - return QDial::tr("SliderHandle"); - } - } - return QAccessibleWidget::text(textType, child); -} - -QAccessible::Role QAccessibleDial::role(int child) const -{ - if (child == SpeedoMeter) - return Slider; - else if (child == SliderHandle) - return Indicator; - return QAccessibleWidget::role(child); -} - -QAccessible::State QAccessibleDial::state(int child) const -{ - const State parentState = QAccessibleWidget::state(0); - if (child == SliderHandle) - return parentState | HotTracked; - return parentState; -} - -QVariant QAccessibleDial::invokeMethod(Method, int, const QVariantList &) -{ - return QVariant(); -} - -QDial *QAccessibleDial::dial() const -{ - return static_cast(object()); -} -#endif // QT_NO_DIAL - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE diff --git a/src/plugins/accessible/widgets/rangecontrols.h b/src/plugins/accessible/widgets/rangecontrols.h deleted file mode 100644 index 2c13b0ffc..000000000 --- a/src/plugins/accessible/widgets/rangecontrols.h +++ /dev/null @@ -1,215 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the plugins of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef RANGECONTROLS_H -#define RANGECONTROLS_H - -#include -#include - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACCESSIBILITY - -class QAbstractSpinBox; -class QAbstractSlider; -class QScrollBar; -class QSlider; -class QSpinBox; -class QDoubleSpinBox; -class QDial; - -#ifndef QT_NO_SPINBOX -class QAccessibleAbstractSpinBox: public QAccessibleWidget, public QAccessibleValueInterface -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleAbstractSpinBox(QWidget *w); - - enum SpinBoxElements { - SpinBoxSelf = 0, - Editor, - ValueUp, - ValueDown - }; - - int childCount() const; - QRect rect(int child) const; - - int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const; - - QString text(Text t, int child) const; - Role role(int child) const; - - bool doAction(int action, int child, const QVariantList ¶ms); - - QVariant invokeMethod(Method method, int child, const QVariantList ¶ms); - - // QAccessibleValueInterface - QVariant currentValue(); - void setCurrentValue(const QVariant &value); - QVariant maximumValue(); - QVariant minimumValue(); - -protected: - QAbstractSpinBox *abstractSpinBox() const; -}; - -class QAccessibleSpinBox : public QAccessibleAbstractSpinBox -{ -public: - explicit QAccessibleSpinBox(QWidget *w); - - State state(int child) const; - - bool doAction(int action, int child, const QVariantList ¶ms); - -protected: - QSpinBox *spinBox() const; -}; - -class QAccessibleDoubleSpinBox : public QAccessibleWidget -{ -public: - explicit QAccessibleDoubleSpinBox(QWidget *widget); - - enum DoubleSpinBoxElements { - SpinBoxSelf = 0, - Editor, - ValueUp, - ValueDown - }; - - int childCount() const; - QRect rect(int child) const; - int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const; - QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms); - QString text(Text t, int child) const; - Role role(int child) const; - State state(int child) const; - -protected: - QDoubleSpinBox *doubleSpinBox() const; -}; -#endif // QT_NO_SPINBOX - -class QAccessibleAbstractSlider: public QAccessibleWidget, public QAccessibleValueInterface -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleAbstractSlider(QWidget *w, Role r = Slider); - - QVariant invokeMethod(Method method, int child, const QVariantList ¶ms); - - // QAccessibleValueInterface - QVariant currentValue(); - void setCurrentValue(const QVariant &value); - QVariant maximumValue(); - QVariant minimumValue(); - -protected: - QAbstractSlider *abstractSlider() const; -}; - -#ifndef QT_NO_SCROLLBAR -class QAccessibleScrollBar : public QAccessibleAbstractSlider -{ -public: - explicit QAccessibleScrollBar(QWidget *w); - - enum ScrollBarElements { - ScrollBarSelf = 0, - LineUp, - PageUp, - Position, - PageDown, - LineDown - }; - - int childCount() const; - - QRect rect(int child) const; - QString text(Text t, int child) const; - Role role(int child) const; - State state(int child) const; - -protected: - QScrollBar *scrollBar() const; -}; -#endif // QT_NO_SCROLLBAR - -#ifndef QT_NO_SLIDER -class QAccessibleSlider : public QAccessibleAbstractSlider -{ -public: - explicit QAccessibleSlider(QWidget *w); - - enum SliderElements { - SliderSelf = 0, - PageLeft, - Position, - PageRight - }; - - int childCount() const; - - QRect rect(int child) const; - QString text(Text t, int child) const; - Role role(int child) const; - State state(int child) const; - - int defaultAction(int child) const; - QString actionText(int action, Text t, int child) const; - -protected: - QSlider *slider() const; -}; -#endif // QT_NO_SLIDER - -#ifndef QT_NO_DIAL -class QAccessibleDial : public QAccessibleWidget -{ -public: - explicit QAccessibleDial(QWidget *w); - - enum DialElements { - Self = 0, - SpeedoMeter, - SliderHandle - }; - - int childCount() const; - QRect rect(int child) const; - QString text(Text textType, int child) const; - Role role(int child) const; - State state(int child) const; - QVariant invokeMethod(Method method, int child, const QVariantList ¶ms); - -protected: - QDial *dial() const; -}; -#endif // QT_NO_DIAL - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - -#endif // RANGECONTROLS_H diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp deleted file mode 100644 index e1693cf24..000000000 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ /dev/null @@ -1,994 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the plugins of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simplewidgets.h" - -#include "qabstractbutton.h" -#include "qcheckbox.h" -#include "qpushbutton.h" -#include "qprogressbar.h" -#include "qstatusbar.h" -#include "qradiobutton.h" -#include "qtoolbutton.h" -#include "qlabel.h" -#include "qgroupbox.h" -#include "qlcdnumber.h" -#include "qtextdocument.h" -#include "qlineedit.h" -#include "qlineedit_p.h" -#include "qstyle.h" -#include "qstyleoption.h" - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACCESSIBILITY - -using namespace QAccessible2; -extern QList childWidgets(const QWidget *widget, bool includeTopLevel = false); - -QString Q_GUI_EXPORT qt_accStripAmp(const QString &text); -QString Q_GUI_EXPORT qt_accHotKey(const QString &text); - -QString Q_GUI_EXPORT qTextBeforeOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset, const QString& text); -QString Q_GUI_EXPORT qTextAtOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset, const QString& text); -QString Q_GUI_EXPORT qTextAfterOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset, const QString& text); - -/*! - \class QAccessibleButton - \brief The QAccessibleButton class implements the QAccessibleInterface for button type widgets. - \internal - - \ingroup accessibility -*/ - -/*! - Creates a QAccessibleButton object for \a w. - \a role is propagated to the QAccessibleWidget constructor. -*/ -QAccessibleButton::QAccessibleButton(QWidget *w, Role role) -: QAccessibleWidget(w, role) -{ - Q_ASSERT(button()); - if (button()->isCheckable()) - addControllingSignal(QLatin1String("toggled(bool)")); - else - addControllingSignal(QLatin1String("clicked()")); -} - -/*! Returns the button. */ -QAbstractButton *QAccessibleButton::button() const -{ - return qobject_cast(object()); -} - -/*! \reimp */ -QString QAccessibleButton::actionText(int action, Text text, int child) const -{ - if (child) - return QString(); - - if (text == Name) switch (action) { - case Press: - case DefaultAction: // press, checking or open - switch (role(0)) { - case ButtonMenu: - return QPushButton::tr("Open"); - case CheckBox: - { - if (state(child) & Checked) - return QCheckBox::tr("Uncheck"); - QCheckBox *cb = qobject_cast(object()); - if (!cb || !cb->isTristate() || cb->checkState() == Qt::PartiallyChecked) - return QCheckBox::tr("Check"); - return QCheckBox::tr("Toggle"); - } - break; - case RadioButton: - return QRadioButton::tr("Check"); - default: - break; - } - break; - } - return QAccessibleWidget::actionText(action, text, child); -} - -/*! \reimp */ -bool QAccessibleButton::doAction(int action, int child, const QVariantList ¶ms) -{ - if (child || !widget()->isEnabled()) - return false; - - switch (action) { - case DefaultAction: - case Press: - { -#ifndef QT_NO_MENU - QPushButton *pb = qobject_cast(object()); - if (pb && pb->menu()) - pb->showMenu(); - else -#endif - button()->animateClick(); - } - return true; - } - return QAccessibleWidget::doAction(action, child, params); -} - -/*! \reimp */ -QString QAccessibleButton::text(Text t, int child) const -{ - QString str; - switch (t) { - case Accelerator: - { -#ifndef QT_NO_SHORTCUT - QPushButton *pb = qobject_cast(object()); - if (pb && pb->isDefault()) - str = QKeySequence(Qt::Key_Enter).toString(); -#endif - if (str.isEmpty()) - str = qt_accHotKey(button()->text()); - } - break; - case Name: - str = widget()->accessibleName(); - if (str.isEmpty()) - str = button()->text(); - break; - default: - break; - } - if (str.isEmpty()) - str = QAccessibleWidget::text(t, child); - return qt_accStripAmp(str); -} - -/*! \reimp */ -QAccessible::State QAccessibleButton::state(int child) const -{ - State state = QAccessibleWidget::state(child); - - QAbstractButton *b = button(); - QCheckBox *cb = qobject_cast(b); - if (b->isChecked()) - state |= Checked; - else if (cb && cb->checkState() == Qt::PartiallyChecked) - state |= Mixed; - if (b->isDown()) - state |= Pressed; - QPushButton *pb = qobject_cast(b); - if (pb) { - if (pb->isDefault()) - state |= DefaultButton; -#ifndef QT_NO_MENU - if (pb->menu()) - state |= HasPopup; -#endif - } - - return state; -} - -int QAccessibleButton::actionCount() -{ - return 1; -} - -void QAccessibleButton::doAction(int actionIndex) -{ - switch (actionIndex) { - case 0: - button()->click(); - break; - } -} - -QString QAccessibleButton::description(int actionIndex) -{ - switch (actionIndex) { - case 0: - if (button()->isCheckable()) { - return QLatin1String("Toggles the button."); - } - return QLatin1String("Clicks the button."); - default: - return QString(); - } -} - -QString QAccessibleButton::name(int actionIndex) -{ - switch (actionIndex) { - case 0: - if (button()->isCheckable()) { - if (button()->isChecked()) { - return QLatin1String("Uncheck"); - } else { - return QLatin1String("Check"); - } - } - return QLatin1String("Press"); - default: - return QString(); - } -} - -QString QAccessibleButton::localizedName(int actionIndex) -{ - switch (actionIndex) { - case 0: - if (button()->isCheckable()) { - if (button()->isChecked()) { - return tr("Uncheck"); - } else { - return tr("Check"); - } - } - return tr("Press"); - default: - return QString(); - } -} - -QStringList QAccessibleButton::keyBindings(int actionIndex) -{ - switch (actionIndex) { -#ifndef QT_NO_SHORTCUT - case 0: - return QStringList() << button()->shortcut().toString(); -#endif - default: - return QStringList(); - } -} - -#ifndef QT_NO_TOOLBUTTON -/*! - \class QAccessibleToolButton - \brief The QAccessibleToolButton class implements the QAccessibleInterface for tool buttons. - \internal - - \ingroup accessibility -*/ - -/*! - \enum QAccessibleToolButton::ToolButtonElements - - This enum identifies the components of the tool button. - - \value ToolButtonSelf The tool button as a whole. - \value ButtonExecute The button. - \value ButtonDropMenu The drop down menu. -*/ - -/*! - Creates a QAccessibleToolButton object for \a w. - \a role is propagated to the QAccessibleWidget constructor. -*/ -QAccessibleToolButton::QAccessibleToolButton(QWidget *w, Role role) -: QAccessibleButton(w, role) -{ - Q_ASSERT(toolButton()); -} - -/*! Returns the button. */ -QToolButton *QAccessibleToolButton::toolButton() const -{ - return qobject_cast(object()); -} - -/*! - Returns true if this tool button is a split button. -*/ -bool QAccessibleToolButton::isSplitButton() const -{ -#ifndef QT_NO_MENU - return toolButton()->menu() && toolButton()->popupMode() == QToolButton::MenuButtonPopup; -#else - return false; -#endif -} - -/*! \reimp */ -QAccessible::Role QAccessibleToolButton::role(int child) const -{ - if (isSplitButton()) switch(child) { - case ButtonExecute: - return PushButton; - case ButtonDropMenu: - return ButtonMenu; - } - return QAccessibleButton::role(child); -} - -/*! \reimp */ -QAccessible::State QAccessibleToolButton::state(int child) const -{ - QAccessible::State st = QAccessibleButton::state(child); - if (toolButton()->autoRaise()) - st |= HotTracked; -#ifndef QT_NO_MENU - if (toolButton()->menu() && child != ButtonExecute) - st |= HasPopup; -#endif - return st; -} - -/*! \reimp */ -int QAccessibleToolButton::childCount() const -{ - if (!toolButton()->isVisible()) - return 0; - return isSplitButton() ? ButtonDropMenu : 0; -} - -/*! - \internal - - Returns the rectangle occupied by this button, depending on \a - child. -*/ -QRect QAccessibleToolButton::rect(int child) const -{ - if (!toolButton()->isVisible()) - return QRect(); - if (!child) - return QAccessibleButton::rect(child); - - QStyleOptionToolButton opt; - opt.init(widget()); - QRect subrect = widget()->style()->subControlRect(QStyle::CC_ToolButton, &opt, - QStyle::SC_ToolButtonMenu, toolButton()); - - if (child == ButtonExecute) - subrect = QRect(0, 0, subrect.x(), widget()->height()); - - QPoint ntl = widget()->mapToGlobal(subrect.topLeft()); - subrect.moveTopLeft(ntl); - return subrect; -} - -/*! - \internal - - Returns the button's text label, depending on the text \a t, and - the \a child. -*/ -QString QAccessibleToolButton::text(Text t, int child) const -{ - QString str; - switch (t) { - case Name: - str = toolButton()->accessibleName(); - if (str.isEmpty()) - str = toolButton()->text(); - break; - default: - break; - } - if (str.isEmpty()) - str = QAccessibleButton::text(t, child);; - return qt_accStripAmp(str); -} - -/*! - \internal - - If \a text is \c Name, then depending on the \a child or the \a - action, an action text is returned. This is a translated string - which in English is one of "Press", "Open", or "Set Focus". If \a - text is not \c Name, an empty string is returned. -*/ -QString QAccessibleToolButton::actionText(int action, Text text, int child) const -{ - if (text == Name) switch(child) { - case ButtonExecute: - return QToolButton::tr("Press"); - case ButtonDropMenu: - return QToolButton::tr("Open"); - default: - switch(action) { - case 0: - return QToolButton::tr("Press"); - case 1: -#ifndef QT_NO_MENU - if (toolButton()->menu()) - return QToolButton::tr("Open"); -#endif - //fall through - case 2: - return QLatin1String("Set Focus"); - } - } - return QString(); -} - -/*! - \internal -*/ -bool QAccessibleToolButton::doAction(int action, int child, const QVariantList ¶ms) -{ - if (!widget()->isEnabled()) - return false; - if (action == 1 || child == ButtonDropMenu) { - if(!child) - toolButton()->setDown(true); -#ifndef QT_NO_MENU - toolButton()->showMenu(); -#endif - return true; - } - return QAccessibleButton::doAction(action, 0, params); -} - -#endif // QT_NO_TOOLBUTTON - -/*! - \class QAccessibleDisplay - \brief The QAccessibleDisplay class implements the QAccessibleInterface for widgets that display information. - \internal - - \ingroup accessibility -*/ - -/*! - Constructs a QAccessibleDisplay object for \a w. - \a role is propagated to the QAccessibleWidget constructor. -*/ -QAccessibleDisplay::QAccessibleDisplay(QWidget *w, Role role) -: QAccessibleWidget(w, role) -{ -} - -/*! \reimp */ -QAccessible::Role QAccessibleDisplay::role(int child) const -{ - QLabel *l = qobject_cast(object()); - if (l) { - if (l->pixmap()) - return Graphic; -#ifndef QT_NO_MOVIE - if (l->movie()) - return Animation; -#endif -#ifndef QT_NO_PROGRESSBAR - } else if (qobject_cast(object())) { - return ProgressBar; -#endif - } else if (qobject_cast(object())) { - return StatusBar; - } - return QAccessibleWidget::role(child); -} - -/*! \reimp */ -QString QAccessibleDisplay::text(Text t, int child) const -{ - QString str; - switch (t) { - case Name: - str = widget()->accessibleName(); - if (str.isEmpty()) { - if (qobject_cast(object())) { - QLabel *label = qobject_cast(object()); - str = label->text(); - if (label->textFormat() == Qt::RichText - || (label->textFormat() == Qt::AutoText && Qt::mightBeRichText(str))) { - QTextDocument doc; - doc.setHtml(str); - str = doc.toPlainText(); - } -#ifndef QT_NO_LCDNUMBER - } else if (qobject_cast(object())) { - QLCDNumber *l = qobject_cast(object()); - if (l->digitCount()) - str = QString::number(l->value()); - else - str = QString::number(l->intValue()); -#endif - } else if (qobject_cast(object())) { - return qobject_cast(object())->currentMessage(); - } - } - break; - case Value: -#ifndef QT_NO_PROGRESSBAR - if (qobject_cast(object())) - str = QString::number(qobject_cast(object())->value()); -#endif - break; - default: - break; - } - if (str.isEmpty()) - str = QAccessibleWidget::text(t, child);; - return qt_accStripAmp(str); -} - -/*! \reimp */ -QAccessible::Relation QAccessibleDisplay::relationTo(int child, const QAccessibleInterface *other, - int otherChild) const -{ - Relation relation = QAccessibleWidget::relationTo(child, other, otherChild); - if (child || otherChild) - return relation; - - QObject *o = other->object(); - QLabel *label = qobject_cast(object()); - if (label) { -#ifndef QT_NO_SHORTCUT - if (o == label->buddy()) - relation |= Label; -#endif - } - return relation; -} - -/*! \reimp */ -int QAccessibleDisplay::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const -{ - *target = 0; - if (rel == Labelled) { - QObject *targetObject = 0; - QLabel *label = qobject_cast(object()); - if (label) { -#ifndef QT_NO_SHORTCUT - if (entry == 1) - targetObject = label->buddy(); -#endif - } - *target = QAccessible::queryAccessibleInterface(targetObject); - if (*target) - return 0; - } - return QAccessibleWidget::navigate(rel, entry, target); -} - -/*! \internal */ -QString QAccessibleDisplay::imageDescription() -{ -#ifndef QT_NO_TOOLTIP - return widget()->toolTip(); -#else - return QString(); -#endif -} - -/*! \internal */ -QSize QAccessibleDisplay::imageSize() -{ - QLabel *label = qobject_cast(widget()); - if (!label) - return QSize(); - const QPixmap *pixmap = label->pixmap(); - if (!pixmap) - return QSize(); - return pixmap->size(); -} - -/*! \internal */ -QRect QAccessibleDisplay::imagePosition(QAccessible2::CoordinateType coordType) -{ - QLabel *label = qobject_cast(widget()); - if (!label) - return QRect(); - const QPixmap *pixmap = label->pixmap(); - if (!pixmap) - return QRect(); - - switch (coordType) { - case QAccessible2::RelativeToScreen: - return QRect(label->mapToGlobal(label->pos()), label->size()); - case QAccessible2::RelativeToParent: - return label->geometry(); - } - - return QRect(); -} - -#ifndef QT_NO_GROUPBOX -QAccessibleGroupBox::QAccessibleGroupBox(QWidget *w) - : QAccessibleWidget(w, Grouping) -{ -} - -QGroupBox* QAccessibleGroupBox::groupBox() const -{ - return static_cast(widget()); -} - -QString QAccessibleGroupBox::text(QAccessible::Text t, int child) const -{ - QString txt = QAccessibleWidget::text(t, child); - - if (txt.isEmpty()) { - switch (t) { - case Name: - txt = qt_accStripAmp(groupBox()->title()); - case Description: - txt = qt_accStripAmp(groupBox()->title()); - default: - break; - } - } - - return txt; -} - -QAccessible::State QAccessibleGroupBox::state(int child) const -{ - QAccessible::State st = QAccessibleWidget::state(child); - - if (groupBox()->isChecked()) - st |= QAccessible::Checked; - - return st; -} - -QAccessible::Role QAccessibleGroupBox::role(int child) const -{ - if (child) - return QAccessibleWidget::role(child); - - return groupBox()->isCheckable() ? QAccessible::CheckBox : QAccessible::Grouping; -} - -int QAccessibleGroupBox::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const -{ - if ((rel == Labelled) && !groupBox()->title().isEmpty()) - rel = Child; - return QAccessibleWidget::navigate(rel, entry, target); -} - -QAccessible::Relation QAccessibleGroupBox::relationTo(int child, const QAccessibleInterface* other, int otherChild) const -{ - QGroupBox *groupbox = this->groupBox(); - - QAccessible::Relation relation = QAccessibleWidget::relationTo(child, other, otherChild); - - if (!child && !otherChild && !groupbox->title().isEmpty()) { - QObject *o = other->object(); - if (groupbox->children().contains(o)) - relation |= Label; - } - - return relation; -} - -int QAccessibleGroupBox::actionCount() -{ - return groupBox()->isCheckable() ? 1 : 0; -} - -void QAccessibleGroupBox::doAction(int actionIndex) -{ - if ((actionIndex == 0) && groupBox()->isCheckable()) { - groupBox()->setChecked(!groupBox()->isChecked()); - } -} - -QString QAccessibleGroupBox::description(int actionIndex) -{ - if ((actionIndex == 0) && (groupBox()->isCheckable())) { - return QLatin1String("Toggles the button."); - } - return QString(); -} - -QString QAccessibleGroupBox::name(int actionIndex) -{ - if (actionIndex || !groupBox()->isCheckable()) - return QString(); - - return QLatin1String("Toggle"); -} - -QString QAccessibleGroupBox::localizedName(int actionIndex) -{ - if (actionIndex || !groupBox()->isCheckable()) - return QString(); - - return QGroupBox::tr("Toggle"); -} - -QStringList QAccessibleGroupBox::keyBindings(int actionIndex) -{ - Q_UNUSED(actionIndex) - return QStringList(); -} - -#endif - -#ifndef QT_NO_LINEEDIT -/*! - \class QAccessibleLineEdit - \brief The QAccessibleLineEdit class implements the QAccessibleInterface for widgets with editable text - \internal - - \ingroup accessibility -*/ - -/*! - Constructs a QAccessibleLineEdit object for \a w. - \a name is propagated to the QAccessibleWidget constructor. -*/ -QAccessibleLineEdit::QAccessibleLineEdit(QWidget *w, const QString &name) -: QAccessibleWidget(w, EditableText, name), QAccessibleSimpleEditableTextInterface(this) -{ - addControllingSignal(QLatin1String("textChanged(const QString&)")); - addControllingSignal(QLatin1String("returnPressed()")); -} - -/*! Returns the line edit. */ -QLineEdit *QAccessibleLineEdit::lineEdit() const -{ - return qobject_cast(object()); -} - -/*! \reimp */ -QString QAccessibleLineEdit::text(Text t, int child) const -{ - QString str; - switch (t) { - case Value: - if (lineEdit()->echoMode() == QLineEdit::Normal) - str = lineEdit()->text(); - break; - default: - break; - } - if (str.isEmpty()) - str = QAccessibleWidget::text(t, child);; - return qt_accStripAmp(str); -} - -/*! \reimp */ -void QAccessibleLineEdit::setText(Text t, int control, const QString &text) -{ - if (t != Value || control) { - QAccessibleWidget::setText(t, control, text); - return; - } - - QString newText = text; - if (lineEdit()->validator()) { - int pos = 0; - if (lineEdit()->validator()->validate(newText, pos) != QValidator::Acceptable) - return; - } - lineEdit()->setText(newText); -} - -/*! \reimp */ -QAccessible::State QAccessibleLineEdit::state(int child) const -{ - State state = QAccessibleWidget::state(child); - - QLineEdit *l = lineEdit(); - if (l->isReadOnly()) - state |= ReadOnly; - if (l->echoMode() != QLineEdit::Normal) - state |= Protected; - state |= Selectable; - if (l->hasSelectedText()) - state |= Selected; - - if (l->contextMenuPolicy() != Qt::NoContextMenu - && l->contextMenuPolicy() != Qt::PreventContextMenu) - state |= HasPopup; - - return state; -} - -QVariant QAccessibleLineEdit::invokeMethod(QAccessible::Method method, int child, - const QVariantList ¶ms) -{ - if (child) - return QVariant(); - - switch (method) { - case ListSupportedMethods: { - QSet set; - set << ListSupportedMethods << SetCursorPosition << GetCursorPosition; - return QVariant::fromValue(set | qvariant_cast >( - QAccessibleWidget::invokeMethod(method, child, params))); - } - case SetCursorPosition: - setCursorPosition(params.value(0).toInt()); - return true; - case GetCursorPosition: - return cursorPosition(); - default: - return QAccessibleWidget::invokeMethod(method, child, params); - } -} - -void QAccessibleLineEdit::addSelection(int startOffset, int endOffset) -{ - setSelection(0, startOffset, endOffset); -} - -QString QAccessibleLineEdit::attributes(int offset, int *startOffset, int *endOffset) -{ - // QLineEdit doesn't have text attributes - *startOffset = *endOffset = offset; - return QString(); -} - -int QAccessibleLineEdit::cursorPosition() -{ - return lineEdit()->cursorPosition(); -} - -QRect QAccessibleLineEdit::characterRect(int offset, CoordinateType coordType) -{ - int left, top, right, bottom; - lineEdit()->getTextMargins(&left, &top, &right, &bottom); - int x = lineEdit()->d_func()->control->cursorToX(offset); - int y = top; - QFontMetrics fm(lineEdit()->font()); - const QString ch = text(offset, offset + 1); - int w = fm.width(ch); - int h = fm.height(); - - QRect r(x, y, w, h); - if (coordType == QAccessible2::RelativeToScreen) - r.moveTo(lineEdit()->mapToGlobal(r.topLeft())); - - return r; -} - -int QAccessibleLineEdit::selectionCount() -{ - return lineEdit()->hasSelectedText() ? 1 : 0; -} - -int QAccessibleLineEdit::offsetAtPoint(const QPoint &point, CoordinateType coordType) -{ - QPoint p = point; - if (coordType == RelativeToScreen) - p = lineEdit()->mapFromGlobal(p); - - return lineEdit()->cursorPositionAt(p); -} - -void QAccessibleLineEdit::selection(int selectionIndex, int *startOffset, int *endOffset) -{ - *startOffset = *endOffset = 0; - if (selectionIndex != 0) - return; - - *startOffset = lineEdit()->selectionStart(); - *endOffset = *startOffset + lineEdit()->selectedText().count(); -} - -QString QAccessibleLineEdit::text(int startOffset, int endOffset) -{ - if (startOffset > endOffset) - return QString(); - - if (lineEdit()->echoMode() != QLineEdit::Normal) - return QString(); - - return lineEdit()->text().mid(startOffset, endOffset - startOffset); -} - -QString QAccessibleLineEdit::textBeforeOffset(int offset, BoundaryType boundaryType, - int *startOffset, int *endOffset) -{ - if (lineEdit()->echoMode() != QLineEdit::Normal) { - *startOffset = *endOffset = -1; - return QString(); - } - return qTextBeforeOffsetFromString(offset, boundaryType, startOffset, endOffset, lineEdit()->text()); -} - -QString QAccessibleLineEdit::textAfterOffset(int offset, BoundaryType boundaryType, - int *startOffset, int *endOffset) -{ - if (lineEdit()->echoMode() != QLineEdit::Normal) { - *startOffset = *endOffset = -1; - return QString(); - } - return qTextAfterOffsetFromString(offset, boundaryType, startOffset, endOffset, lineEdit()->text()); -} - -QString QAccessibleLineEdit::textAtOffset(int offset, BoundaryType boundaryType, - int *startOffset, int *endOffset) -{ - if (lineEdit()->echoMode() != QLineEdit::Normal) { - *startOffset = *endOffset = -1; - return QString(); - } - return qTextAtOffsetFromString(offset, boundaryType, startOffset, endOffset, lineEdit()->text()); -} - -void QAccessibleLineEdit::removeSelection(int selectionIndex) -{ - if (selectionIndex != 0) - return; - - lineEdit()->deselect(); -} - -void QAccessibleLineEdit::setCursorPosition(int position) -{ - lineEdit()->setCursorPosition(position); -} - -void QAccessibleLineEdit::setSelection(int selectionIndex, int startOffset, int endOffset) -{ - if (selectionIndex != 0) - return; - - lineEdit()->setSelection(startOffset, endOffset - startOffset); -} - -int QAccessibleLineEdit::characterCount() -{ - return lineEdit()->text().count(); -} - -void QAccessibleLineEdit::scrollToSubstring(int startIndex, int endIndex) -{ - lineEdit()->setCursorPosition(endIndex); - lineEdit()->setCursorPosition(startIndex); -} - -#endif // QT_NO_LINEEDIT - -#ifndef QT_NO_PROGRESSBAR -QAccessibleProgressBar::QAccessibleProgressBar(QWidget *o) - : QAccessibleDisplay(o) -{ - Q_ASSERT(progressBar()); -} - -QVariant QAccessibleProgressBar::currentValue() -{ - return progressBar()->value(); -} - -QVariant QAccessibleProgressBar::maximumValue() -{ - return progressBar()->maximum(); -} - -QVariant QAccessibleProgressBar::minimumValue() -{ - return progressBar()->minimum(); -} - -QProgressBar *QAccessibleProgressBar::progressBar() const -{ - return qobject_cast(object()); -} -#endif - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - diff --git a/src/plugins/accessible/widgets/simplewidgets.h b/src/plugins/accessible/widgets/simplewidgets.h deleted file mode 100644 index 6c04e1b66..000000000 --- a/src/plugins/accessible/widgets/simplewidgets.h +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the plugins of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMPLEWIDGETS_H -#define SIMPLEWIDGETS_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACCESSIBILITY - -class QAbstractButton; -class QLineEdit; -class QToolButton; -class QGroupBox; -class QProgressBar; - -class QAccessibleButton : public QAccessibleWidget, public QAccessibleActionInterface -{ - Q_ACCESSIBLE_OBJECT - Q_DECLARE_TR_FUNCTIONS(QAccessibleButton) -public: - QAccessibleButton(QWidget *w, Role r); - - QString text(Text t, int child) const; - State state(int child) const; - - QString actionText(int action, Text text, int child) const; - bool doAction(int action, int child, const QVariantList ¶ms); - - // QAccessibleActionInterface - int actionCount(); - void doAction(int actionIndex); - QString description(int actionIndex); - QString name(int actionIndex); - QString localizedName(int actionIndex); - QStringList keyBindings(int actionIndex); - -protected: - QAbstractButton *button() const; -}; - -#ifndef QT_NO_TOOLBUTTON -class QAccessibleToolButton : public QAccessibleButton -{ -public: - QAccessibleToolButton(QWidget *w, Role role); - - enum ToolButtonElements { - ToolButtonSelf = 0, - ButtonExecute, - ButtonDropMenu - }; - - Role role(int child) const; - State state(int child) const; - - int childCount() const; - QRect rect(int child) const; - - QString text(Text t, int child) const; - - QString actionText(int action, Text text, int child) const; - bool doAction(int action, int child, const QVariantList ¶ms); - -protected: - QToolButton *toolButton() const; - - bool isSplitButton() const; -}; -#endif // QT_NO_TOOLBUTTON - -class QAccessibleDisplay : public QAccessibleWidget, public QAccessibleImageInterface -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleDisplay(QWidget *w, Role role = StaticText); - - QString text(Text t, int child) const; - Role role(int child) const; - - Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const; - int navigate(RelationFlag, int entry, QAccessibleInterface **target) const; - - // QAccessibleImageInterface - QString imageDescription(); - QSize imageSize(); - QRect imagePosition(QAccessible2::CoordinateType coordType); -}; - -#ifndef QT_NO_GROUPBOX -class QAccessibleGroupBox : public QAccessibleWidget, - public QAccessibleActionInterface -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleGroupBox(QWidget *w); - - State state(int child) const; - Role role(int child) const; - QString text(Text t, int child) const; - - Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const; - int navigate(RelationFlag rel, int entry, QAccessibleInterface** target) const; - - //QAccessibleActionInterface - int actionCount(); - QString description(int actionIndex); - void doAction(int actionIndex); - QString name(int actionIndex); - QString localizedName(int actionIndex); - QStringList keyBindings(int actionIndex); - -private: - QGroupBox *groupBox() const; -}; -#endif - -#ifndef QT_NO_LINEEDIT -class QAccessibleLineEdit : public QAccessibleWidget, public QAccessibleTextInterface, - public QAccessibleSimpleEditableTextInterface -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleLineEdit(QWidget *o, const QString &name = QString()); - - QString text(Text t, int child) const; - void setText(Text t, int control, const QString &text); - State state(int child) const; - QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms); - - // QAccessibleTextInterface - void addSelection(int startOffset, int endOffset); - QString attributes(int offset, int *startOffset, int *endOffset); - int cursorPosition(); - QRect characterRect(int offset, QAccessible2::CoordinateType coordType); - int selectionCount(); - int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType); - void selection(int selectionIndex, int *startOffset, int *endOffset); - QString text(int startOffset, int endOffset); - QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset); - QString textAfterOffset(int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset); - QString textAtOffset(int offset, QAccessible2::BoundaryType boundaryType, - int *startOffset, int *endOffset); - void removeSelection(int selectionIndex); - void setCursorPosition(int position); - void setSelection(int selectionIndex, int startOffset, int endOffset); - int characterCount(); - void scrollToSubstring(int startIndex, int endIndex); - -protected: - QLineEdit *lineEdit() const; -}; -#endif // QT_NO_LINEEDIT - -#ifndef QT_NO_PROGRESSBAR -class QAccessibleProgressBar : public QAccessibleDisplay, public QAccessibleValueInterface -{ - Q_ACCESSIBLE_OBJECT -public: - explicit QAccessibleProgressBar(QWidget *o); - - // QAccessibleValueInterface - QVariant currentValue(); - QVariant maximumValue(); - QVariant minimumValue(); - inline void setCurrentValue(const QVariant &) {} - -protected: - QProgressBar *progressBar() const; -}; -#endif - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - -#endif // SIMPLEWIDGETS_H diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index df5e28ef1..ea26708e8 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -32,7 +32,6 @@ include_directories( set(TEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/qbenchmark.h ${CMAKE_CURRENT_SOURCE_DIR}/qsignalspy.h - ${CMAKE_CURRENT_SOURCE_DIR}/qtestaccessible.h ${CMAKE_CURRENT_SOURCE_DIR}/qtestassert.h ${CMAKE_CURRENT_SOURCE_DIR}/qtestbasicstreamer.h ${CMAKE_CURRENT_SOURCE_DIR}/qtestcase.h diff --git a/src/test/qtestaccessible.h b/src/test/qtestaccessible.h deleted file mode 100644 index 4d21ea83a..000000000 --- a/src/test/qtestaccessible.h +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtTest module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTESTACCESSIBLE_H -#define QTESTACCESSIBLE_H - -#ifndef QT_NO_ACCESSIBILITY - -#define QTEST_ACCESSIBILITY - -#define QVERIFY_EVENT(object, child, event) \ - QVERIFY(QTestAccessibility::verifyEvent(object, child, (int)event)) - -#include -#include -#include - - -QT_BEGIN_NAMESPACE - -class QObject; - -struct QTestAccessibilityEvent -{ - QTestAccessibilityEvent(QObject* o = 0, int c = 0, int e = 0) - : object(o), child(c), event(e) {} - - bool operator==(const QTestAccessibilityEvent &o) const - { - return o.object == object && o.child == child && o.event == event; - } - - QObject* object; - int child; - int event; -}; - -typedef QList EventList; - -class QTestAccessibility -{ -public: - static void initialize() - { - if (!instance()) { - instance() = new QTestAccessibility; - qAddPostRoutine(cleanup); - } - } - static void cleanup() - { - delete instance(); - instance() = 0; - } - static void clearEvents() { eventList().clear(); } - static EventList events() { return eventList(); } - static bool verifyEvent(const QTestAccessibilityEvent& ev) - { - if (eventList().isEmpty()) - return false; - return eventList().takeFirst() == ev; - } - - static bool verifyEvent(QObject *o, int c, int e) - { - return verifyEvent(QTestAccessibilityEvent(o, c, e)); - } - -private: - QTestAccessibility() - { - QAccessible::installUpdateHandler(updateHandler); - QAccessible::installRootObjectHandler(rootObjectHandler); - } - - ~QTestAccessibility() - { - QAccessible::installUpdateHandler(0); - QAccessible::installRootObjectHandler(0); - } - - static void rootObjectHandler(QObject *object) - { - // qDebug("rootObjectHandler called %p", object); - if (object) { - QApplication* app = qobject_cast(object); - if ( !app ) - qWarning("QTEST_ACCESSIBILITY: root Object is not a QApplication!"); - } else { - qWarning("QTEST_ACCESSIBILITY: root Object called with 0 pointer"); - } - } - - static void updateHandler(QObject *o, int c, QAccessible::Event e) - { - // qDebug("updateHandler called: %p %d %d", o, c, (int)e); - eventList().append(QTestAccessibilityEvent(o, c, (int)e)); - } - - static EventList &eventList() - { - static EventList list; - return list; - } - - static QTestAccessibility *&instance() - { - static QTestAccessibility *ta = 0; - return ta; - } -}; - -#endif - -QT_END_NAMESPACE - - -#endif diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp index 753d36e6e..a53c4bc9d 100644 --- a/src/tools/uic/cpp/cppwriteincludes.cpp +++ b/src/tools/uic/cpp/cppwriteincludes.cpp @@ -82,26 +82,6 @@ static const struct ClassTblData { { QLatin1String("QAbstractTableModel"), QLatin1String("QtCore/qabstractitemmodel.h") }, { QLatin1String("QAbstractTextDocumentLayout"), QLatin1String("QtGui/qabstracttextdocumentlayout.h") }, { QLatin1String("QAbstractUndoItem"), QLatin1String("QtGui/qtextdocument.h") }, - { QLatin1String("QAccessible"), QLatin1String("QtGui/qaccessible.h") }, - { QLatin1String("QAccessible2Interface"), QLatin1String("QtGui/qaccessible2.h") }, - { QLatin1String("QAccessibleActionInterface"), QLatin1String("QtGui/qaccessible2.h") }, - { QLatin1String("QAccessibleApplication"), QLatin1String("QtGui/qaccessibleobject.h") }, - { QLatin1String("QAccessibleBridgeFactoryInterface"), QLatin1String("QtGui/qaccessiblebridge.h") }, - { QLatin1String("QAccessibleBridgePlugin"), QLatin1String("QtGui/qaccessiblebridge.h") }, - { QLatin1String("QAccessibleEditableTextInterface"), QLatin1String("QtGui/qaccessible2.h") }, - { QLatin1String("QAccessibleEvent"), QLatin1String("QtGui/qaccessible.h") }, - { QLatin1String("QAccessibleFactoryInterface"), QLatin1String("QtGui/qaccessibleplugin.h") }, - { QLatin1String("QAccessibleImageInterface"), QLatin1String("QtGui/qaccessible2.h") }, - { QLatin1String("QAccessibleInterface"), QLatin1String("QtGui/qaccessible.h") }, - { QLatin1String("QAccessibleObject"), QLatin1String("QtGui/qaccessibleobject.h") }, - { QLatin1String("QAccessiblePlugin"), QLatin1String("QtGui/qaccessibleplugin.h") }, - { QLatin1String("QAccessibleSimpleEditableTextInterface"), QLatin1String("QtGui/qaccessible2.h") }, - { QLatin1String("QAccessibleTable2CellInterface"), QLatin1String("QtGui/qaccessible2.h") }, - { QLatin1String("QAccessibleTable2Interface"), QLatin1String("QtGui/qaccessible2.h") }, - { QLatin1String("QAccessibleTableInterface"), QLatin1String("QtGui/qaccessible2.h") }, - { QLatin1String("QAccessibleTextInterface"), QLatin1String("QtGui/qaccessible2.h") }, - { QLatin1String("QAccessibleValueInterface"), QLatin1String("QtGui/qaccessible2.h") }, - { QLatin1String("QAccessibleWidget"), QLatin1String("QtGui/qaccessiblewidget.h") }, { QLatin1String("QAction"), QLatin1String("QtGui/qaction.h") }, { QLatin1String("QActionEvent"), QLatin1String("QtGui/qevent.h") }, { QLatin1String("QActionGroup"), QLatin1String("QtGui/qactiongroup.h") }, diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 2dcf99b8d..05585b10e 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -162,7 +162,6 @@ namespace { inline void openIfndef(QTextStream &str, const QString &symbol) { if (!symbol.isEmpty()) str << QLatin1String("#ifndef ") << symbol << endl; } inline void closeIfndef(QTextStream &str, const QString &symbol) { if (!symbol.isEmpty()) str << QLatin1String("#endif // ") << symbol << endl; } - const char *accessibilityDefineC = "QT_NO_ACCESSIBILITY"; const char *toolTipDefineC = "QT_NO_TOOLTIP"; const char *whatsThisDefineC = "QT_NO_WHATSTHIS"; const char *statusTipDefineC = "QT_NO_STATUSTIP"; @@ -1403,8 +1402,6 @@ void WriteInitialization::writeProperties(const QString &varName, defineC = whatsThisDefineC; else if (propertyName == QLatin1String("statusTip")) defineC = statusTipDefineC; - else if (propertyName == QLatin1String("accessibleName") || propertyName == QLatin1String("accessibleDescription")) - defineC = accessibilityDefineC; QTextStream &o = autoTrOutput(p->elementString()); diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index f6497445a..aaed61c3a 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -2976,7 +2976,7 @@ void tst_QObject::deleteQObjectWhenDeletingEvent() }; QObject o; - QApplication::postEvent(&o, new MyEvent); + QCoreApplication::postEvent(&o, new MyEvent); QCoreApplication::removePostedEvents(&o); // here you would get a deadlock } diff --git a/tests/auto/qstandarditem/tst_qstandarditem.cpp b/tests/auto/qstandarditem/tst_qstandarditem.cpp index 6e3141dc2..d3d85e4c7 100644 --- a/tests/auto/qstandarditem/tst_qstandarditem.cpp +++ b/tests/auto/qstandarditem/tst_qstandarditem.cpp @@ -177,15 +177,7 @@ void tst_QStandardItem::getSetData() Qt::CheckState checkState((i == 1) ? Qt::PartiallyChecked : Qt::Checked); item.setCheckState(checkState); QCOMPARE(item.checkState(), checkState); - - QString accessibleText = QString("accessibleText %0").arg(i); - item.setAccessibleText(accessibleText); - QCOMPARE(item.accessibleText(), accessibleText); - - QString accessibleDescription = QString("accessibleDescription %0").arg(i); - item.setAccessibleDescription(accessibleDescription); - QCOMPARE(item.accessibleDescription(), accessibleDescription); - + QCOMPARE(item.text(), text); QCOMPARE(item.icon(), icon); QCOMPARE(item.toolTip(), toolTip); @@ -197,8 +189,6 @@ void tst_QStandardItem::getSetData() QCOMPARE(item.background().color(), backgroundColor); QCOMPARE(item.foreground().color(), textColor); QCOMPARE(item.checkState(), checkState); - QCOMPARE(item.accessibleText(), accessibleText); - QCOMPARE(item.accessibleDescription(), accessibleDescription); QCOMPARE(qvariant_cast(item.data(Qt::DisplayRole)), text); QCOMPARE(qvariant_cast(item.data(Qt::DecorationRole)), icon); @@ -211,8 +201,6 @@ void tst_QStandardItem::getSetData() QCOMPARE(qvariant_cast(item.data(Qt::BackgroundRole)), QBrush(backgroundColor)); QCOMPARE(qvariant_cast(item.data(Qt::ForegroundRole)), QBrush(textColor)); QCOMPARE(qvariant_cast(item.data(Qt::CheckStateRole)), int(checkState)); - QCOMPARE(qvariant_cast(item.data(Qt::AccessibleTextRole)), accessibleText); - QCOMPARE(qvariant_cast(item.data(Qt::AccessibleDescriptionRole)), accessibleDescription); item.setBackground(pixmap); QCOMPARE(item.background().texture(), pixmap); @@ -229,8 +217,6 @@ void tst_QStandardItem::getSetData() item.setData(QVariant(), Qt::BackgroundRole); item.setData(QVariant(), Qt::ForegroundRole); item.setData(QVariant(), Qt::CheckStateRole); - item.setData(QVariant(), Qt::AccessibleTextRole); - item.setData(QVariant(), Qt::AccessibleDescriptionRole); QCOMPARE(item.data(Qt::DisplayRole), QVariant()); QCOMPARE(item.data(Qt::DecorationRole), QVariant()); @@ -243,8 +229,6 @@ void tst_QStandardItem::getSetData() QCOMPARE(item.data(Qt::BackgroundRole), QVariant()); QCOMPARE(item.data(Qt::ForegroundRole), QVariant()); QCOMPARE(item.data(Qt::CheckStateRole), QVariant()); - QCOMPARE(item.data(Qt::AccessibleTextRole), QVariant()); - QCOMPARE(item.data(Qt::AccessibleDescriptionRole), QVariant()); } } @@ -887,8 +871,6 @@ void tst_QStandardItem::streamItem() item.setBackground(QColor(Qt::blue)); item.setForeground(QColor(Qt::green)); item.setCheckState(Qt::PartiallyChecked); - item.setAccessibleText(QLatin1String("accessibleText")); - item.setAccessibleDescription(QLatin1String("accessibleDescription")); QByteArray ba; { @@ -909,8 +891,6 @@ void tst_QStandardItem::streamItem() QCOMPARE(streamedItem.background(), item.background()); QCOMPARE(streamedItem.foreground(), item.foreground()); QCOMPARE(streamedItem.checkState(), item.checkState()); - QCOMPARE(streamedItem.accessibleText(), item.accessibleText()); - QCOMPARE(streamedItem.accessibleDescription(), item.accessibleDescription()); QCOMPARE(streamedItem.flags(), item.flags()); } } @@ -948,8 +928,6 @@ void tst_QStandardItem::clone() item.setBackground(QColor(Qt::blue)); item.setForeground(QColor(Qt::green)); item.setCheckState(Qt::PartiallyChecked); - item.setAccessibleText(QLatin1String("accessibleText")); - item.setAccessibleDescription(QLatin1String("accessibleDescription")); item.setFlags(Qt::ItemIsEnabled | Qt::ItemIsDropEnabled); QStandardItem *clone = item.clone(); @@ -963,8 +941,6 @@ void tst_QStandardItem::clone() QCOMPARE(clone->background(), item.background()); QCOMPARE(clone->foreground(), item.foreground()); QCOMPARE(clone->checkState(), item.checkState()); - QCOMPARE(clone->accessibleText(), item.accessibleText()); - QCOMPARE(clone->accessibleDescription(), item.accessibleDescription()); QCOMPARE(clone->flags(), item.flags()); QVERIFY(!(*clone < item)); delete clone; diff --git a/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp index c1543f735..447bb0b0a 100644 --- a/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp +++ b/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp @@ -1103,10 +1103,6 @@ void tst_QStandardItemModel::getSetItemData() roles.insert(Qt::ForegroundRole, textColor); Qt::CheckState checkState(Qt::PartiallyChecked); roles.insert(Qt::CheckStateRole, int(checkState)); - QLatin1String accessibleText("accessibleText"); - roles.insert(Qt::AccessibleTextRole, accessibleText); - QLatin1String accessibleDescription("accessibleDescription"); - roles.insert(Qt::AccessibleDescriptionRole, accessibleDescription); QStandardItemModel model; model.insertRows(0, 1); diff --git a/tests/auto/quuid/tst_quuid.cpp b/tests/auto/quuid/tst_quuid.cpp index c2b467bb4..106e33299 100644 --- a/tests/auto/quuid/tst_quuid.cpp +++ b/tests/auto/quuid/tst_quuid.cpp @@ -27,6 +27,7 @@ #include #include #include +#include //TESTED_CLASS= //TESTED_FILES= diff --git a/translations/qt.pot b/translations/qt.pot index 8a75466bd..ec197cc4f 100644 --- a/translations/qt.pot +++ b/translations/qt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-01-10 12:09+0200\n" +"POT-Creation-Date: 2022-01-26 19:24+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -422,12 +422,12 @@ msgstr "" msgid "Cannot anchor a vertical edge to a horizontal edge." msgstr "" -#: src/declarative/graphicsitems/qdeclarativetextinput.cpp:872 -#: src/declarative/graphicsitems/qdeclarativetextinput.cpp:880 +#: src/declarative/graphicsitems/qdeclarativetextinput.cpp:870 +#: src/declarative/graphicsitems/qdeclarativetextinput.cpp:878 msgid "Could not load cursor delegate" msgstr "" -#: src/declarative/graphicsitems/qdeclarativetextinput.cpp:891 +#: src/declarative/graphicsitems/qdeclarativetextinput.cpp:889 msgid "Could not instantiate cursor delegate" msgstr "" @@ -1181,15 +1181,6 @@ msgstr "" msgid "Animation is an abstract class" msgstr "" -#: src/gui/accessible/qaccessibleobject.cpp:322 -#: src/plugins/accessible/widgets/complexwidgets.cpp:1597 -msgid "Activate" -msgstr "" - -#: src/gui/accessible/qaccessibleobject.cpp:324 -msgid "Activates the program's main window" -msgstr "" - #: src/gui/dialogs/qwizard.cpp:578 msgid "Go Back" msgstr "" @@ -1323,19 +1314,19 @@ msgstr "" msgid "Computer" msgstr "" -#: src/gui/dialogs/qmessagebox.cpp:105 +#: src/gui/dialogs/qmessagebox.cpp:102 msgid "Show Details..." msgstr "" -#: src/gui/dialogs/qmessagebox.cpp:105 +#: src/gui/dialogs/qmessagebox.cpp:102 msgid "Hide Details..." msgstr "" -#: src/gui/dialogs/qmessagebox.cpp:1454 +#: src/gui/dialogs/qmessagebox.cpp:1448 msgid "

About Katie

This program uses Katie version %1.

" msgstr "" -#: src/gui/dialogs/qmessagebox.cpp:1458 +#: src/gui/dialogs/qmessagebox.cpp:1452 msgid "" "

Katie is a C++ toolkit derived from the Qt 4.8 framework.

Katie is " "licensed under the GNU LGPL version 2.1

Copyright (C) 2015 The Qt " @@ -1344,7 +1335,7 @@ msgid "" "katie for more information.

" msgstr "" -#: src/gui/dialogs/qmessagebox.cpp:1466 +#: src/gui/dialogs/qmessagebox.cpp:1460 msgid "About Katie" msgstr "" @@ -1358,7 +1349,7 @@ msgctxt "QPrintPreviewDialog" msgid "Page Setup" msgstr "" -#: src/gui/dialogs/qdialog.cpp:491 src/gui/kernel/qwhatsthis.cpp:469 +#: src/gui/dialogs/qdialog.cpp:487 src/gui/kernel/qwhatsthis.cpp:461 msgid "What's This?" msgstr "" @@ -1659,14 +1650,6 @@ msgid "Find Directory" msgstr "" #: src/gui/dialogs/qfiledialog.cpp:495 -#: src/plugins/accessible/widgets/simplewidgets.cpp:96 -#: src/plugins/accessible/widgets/simplewidgets.cpp:411 -#: src/plugins/accessible/widgets/simplewidgets.cpp:419 -#: src/plugins/accessible/widgets/qaccessiblemenu.cpp:138 -#: src/plugins/accessible/widgets/qaccessiblemenu.cpp:363 -#: src/plugins/accessible/widgets/qaccessiblemenu.cpp:417 -#: src/plugins/accessible/widgets/complexwidgets.cpp:1829 -#: src/plugins/accessible/widgets/complexwidgets.cpp:1895 msgid "Open" msgstr "" @@ -1860,94 +1843,88 @@ msgctxt "QImageReader" msgid "Unknown error" msgstr "" -#: src/gui/widgets/qtabbar.cpp:2175 +#: src/gui/widgets/qtabbar.cpp:2163 msgid "Close Tab" msgstr "" -#: src/gui/widgets/qlineedit.cpp:1755 src/gui/text/qtextcontrol.cpp:1858 +#: src/gui/widgets/qlineedit.cpp:1710 src/gui/text/qtextcontrol.cpp:1849 msgid "&Undo" msgstr "" -#: src/gui/widgets/qlineedit.cpp:1759 src/gui/text/qtextcontrol.cpp:1860 +#: src/gui/widgets/qlineedit.cpp:1714 src/gui/text/qtextcontrol.cpp:1851 msgid "&Redo" msgstr "" -#: src/gui/widgets/qlineedit.cpp:1768 src/gui/text/qtextcontrol.cpp:1864 +#: src/gui/widgets/qlineedit.cpp:1723 src/gui/text/qtextcontrol.cpp:1855 msgid "Cu&t" msgstr "" -#: src/gui/widgets/qlineedit.cpp:1774 src/gui/text/qtextcontrol.cpp:1869 +#: src/gui/widgets/qlineedit.cpp:1729 src/gui/text/qtextcontrol.cpp:1860 msgid "&Copy" msgstr "" -#: src/gui/widgets/qlineedit.cpp:1780 src/gui/text/qtextcontrol.cpp:1882 +#: src/gui/widgets/qlineedit.cpp:1735 src/gui/text/qtextcontrol.cpp:1873 msgid "&Paste" msgstr "" -#: src/gui/widgets/qlineedit.cpp:1787 src/gui/text/qtextcontrol.cpp:1885 +#: src/gui/widgets/qlineedit.cpp:1742 src/gui/text/qtextcontrol.cpp:1876 #: src/scripttools/debugging/qscriptbreakpointswidget.cpp:279 msgid "Delete" msgstr "" -#: src/gui/widgets/qlineedit.cpp:1795 src/gui/text/qtextcontrol.cpp:1892 +#: src/gui/widgets/qlineedit.cpp:1750 src/gui/text/qtextcontrol.cpp:1883 msgid "Select All" msgstr "" -#: src/gui/widgets/qscrollbar.cpp:382 +#: src/gui/widgets/qscrollbar.cpp:380 msgid "Scroll here" msgstr "" -#: src/gui/widgets/qscrollbar.cpp:384 +#: src/gui/widgets/qscrollbar.cpp:382 msgid "Left edge" msgstr "" -#: src/gui/widgets/qscrollbar.cpp:384 +#: src/gui/widgets/qscrollbar.cpp:382 msgid "Top" msgstr "" -#: src/gui/widgets/qscrollbar.cpp:385 +#: src/gui/widgets/qscrollbar.cpp:383 msgid "Right edge" msgstr "" -#: src/gui/widgets/qscrollbar.cpp:385 +#: src/gui/widgets/qscrollbar.cpp:383 msgid "Bottom" msgstr "" -#: src/gui/widgets/qscrollbar.cpp:387 -#: src/plugins/accessible/widgets/rangecontrols.cpp:685 +#: src/gui/widgets/qscrollbar.cpp:385 msgid "Page left" msgstr "" -#: src/gui/widgets/qscrollbar.cpp:387 -#: src/plugins/accessible/widgets/rangecontrols.cpp:532 -#: src/plugins/accessible/widgets/rangecontrols.cpp:685 +#: src/gui/widgets/qscrollbar.cpp:385 msgid "Page up" msgstr "" -#: src/gui/widgets/qscrollbar.cpp:388 -#: src/plugins/accessible/widgets/rangecontrols.cpp:690 +#: src/gui/widgets/qscrollbar.cpp:386 msgid "Page right" msgstr "" -#: src/gui/widgets/qscrollbar.cpp:388 -#: src/plugins/accessible/widgets/rangecontrols.cpp:536 -#: src/plugins/accessible/widgets/rangecontrols.cpp:690 +#: src/gui/widgets/qscrollbar.cpp:386 msgid "Page down" msgstr "" -#: src/gui/widgets/qscrollbar.cpp:390 +#: src/gui/widgets/qscrollbar.cpp:388 msgid "Scroll left" msgstr "" -#: src/gui/widgets/qscrollbar.cpp:390 +#: src/gui/widgets/qscrollbar.cpp:388 msgid "Scroll up" msgstr "" -#: src/gui/widgets/qscrollbar.cpp:391 +#: src/gui/widgets/qscrollbar.cpp:389 msgid "Scroll right" msgstr "" -#: src/gui/widgets/qscrollbar.cpp:391 +#: src/gui/widgets/qscrollbar.cpp:389 msgid "Scroll down" msgstr "" @@ -2091,11 +2068,6 @@ msgid "Restore" msgstr "" #: src/gui/widgets/qmdisubwindow.cpp:309 src/gui/widgets/qworkspace.cpp:93 -#: src/plugins/accessible/widgets/qaccessiblemenu.cpp:137 -#: src/plugins/accessible/widgets/qaccessiblemenu.cpp:362 -#: src/plugins/accessible/widgets/qaccessiblewidgets.cpp:1309 -#: src/plugins/accessible/widgets/complexwidgets.cpp:1594 -#: src/plugins/accessible/widgets/complexwidgets.cpp:1895 #: src/scripttools/debugging/qscriptbreakpointswidget.cpp:56 #: src/scripttools/debugging/qscriptdebuggercodefinderwidget.cpp:116 msgid "Close" @@ -2141,28 +2113,28 @@ msgstr "" msgid "&Unshade" msgstr "" -#: src/gui/widgets/qmenubar.cpp:1599 +#: src/gui/widgets/qmenubar.cpp:1500 msgctxt "QMenuBar" msgid "Corner Toolbar" msgstr "" -#: src/gui/widgets/qabstractspinbox.cpp:1152 +#: src/gui/widgets/qabstractspinbox.cpp:1144 msgid "&Select All" msgstr "" -#: src/gui/widgets/qabstractspinbox.cpp:1158 +#: src/gui/widgets/qabstractspinbox.cpp:1150 msgid "&Step up" msgstr "" -#: src/gui/widgets/qabstractspinbox.cpp:1160 +#: src/gui/widgets/qabstractspinbox.cpp:1152 msgid "Step &down" msgstr "" -#: src/gui/kernel/qwidget.cpp:5039 +#: src/gui/kernel/qwidget.cpp:5031 msgid "*" msgstr "" -#: src/gui/kernel/qapplication.cpp:1647 +#: src/gui/kernel/qapplication.cpp:1646 msgid "QT_LAYOUT_DIRECTION" msgstr "" @@ -4514,96 +4486,91 @@ msgstr "" msgid "" msgstr "" -#: src/gui/text/qfontdatabase.cpp:185 +#: src/gui/text/qfontdatabase.cpp:683 msgctxt "QFontDatabase" msgid "Black" msgstr "" -#: src/gui/text/qfontdatabase.cpp:187 +#: src/gui/text/qfontdatabase.cpp:685 msgctxt "QFontDatabase" msgid "Bold" msgstr "" -#: src/gui/text/qfontdatabase.cpp:189 +#: src/gui/text/qfontdatabase.cpp:687 msgctxt "QFontDatabase" msgid "Demi Bold" msgstr "" -#: src/gui/text/qfontdatabase.cpp:191 +#: src/gui/text/qfontdatabase.cpp:689 msgctxt "QFontDatabase" msgid "Light" msgstr "" -#: src/gui/text/qfontdatabase.cpp:194 +#: src/gui/text/qfontdatabase.cpp:693 msgctxt "QFontDatabase" msgid "Italic" msgstr "" -#: src/gui/text/qfontdatabase.cpp:196 +#: src/gui/text/qfontdatabase.cpp:695 msgctxt "QFontDatabase" msgid "Oblique" msgstr "" -#: src/gui/text/qfontdatabase.cpp:199 -msgctxt "QFontDatabase" -msgid "Normal" -msgstr "" - -#: src/gui/text/qtextcontrol.cpp:1876 +#: src/gui/text/qtextcontrol.cpp:1867 msgid "Copy &Link Location" msgstr "" -#: src/gui/text/qtextcontrol.cpp:2790 +#: src/gui/text/qtextcontrol.cpp:2781 msgctxt "QUnicodeControlCharacterMenu" msgid "LRM Left-to-right mark" msgstr "" -#: src/gui/text/qtextcontrol.cpp:2791 +#: src/gui/text/qtextcontrol.cpp:2782 msgctxt "QUnicodeControlCharacterMenu" msgid "RLM Right-to-left mark" msgstr "" -#: src/gui/text/qtextcontrol.cpp:2792 +#: src/gui/text/qtextcontrol.cpp:2783 msgctxt "QUnicodeControlCharacterMenu" msgid "ZWJ Zero width joiner" msgstr "" -#: src/gui/text/qtextcontrol.cpp:2793 +#: src/gui/text/qtextcontrol.cpp:2784 msgctxt "QUnicodeControlCharacterMenu" msgid "ZWNJ Zero width non-joiner" msgstr "" -#: src/gui/text/qtextcontrol.cpp:2794 +#: src/gui/text/qtextcontrol.cpp:2785 msgctxt "QUnicodeControlCharacterMenu" msgid "ZWSP Zero width space" msgstr "" -#: src/gui/text/qtextcontrol.cpp:2795 +#: src/gui/text/qtextcontrol.cpp:2786 msgctxt "QUnicodeControlCharacterMenu" msgid "LRE Start of left-to-right embedding" msgstr "" -#: src/gui/text/qtextcontrol.cpp:2796 +#: src/gui/text/qtextcontrol.cpp:2787 msgctxt "QUnicodeControlCharacterMenu" msgid "RLE Start of right-to-left embedding" msgstr "" -#: src/gui/text/qtextcontrol.cpp:2797 +#: src/gui/text/qtextcontrol.cpp:2788 msgctxt "QUnicodeControlCharacterMenu" msgid "LRO Start of left-to-right override" msgstr "" -#: src/gui/text/qtextcontrol.cpp:2798 +#: src/gui/text/qtextcontrol.cpp:2789 msgctxt "QUnicodeControlCharacterMenu" msgid "RLO Start of right-to-left override" msgstr "" -#: src/gui/text/qtextcontrol.cpp:2799 +#: src/gui/text/qtextcontrol.cpp:2790 msgctxt "QUnicodeControlCharacterMenu" msgid "PDF Pop directional formatting" msgstr "" -#: src/gui/text/qtextcontrol.cpp:2805 +#: src/gui/text/qtextcontrol.cpp:2796 msgid "Insert Unicode control character" msgstr "" @@ -5356,94 +5323,6 @@ msgctxt "QNetworkAccessFileBackend" msgid "Read error reading from %1: %2" msgstr "" -#: src/plugins/accessible/widgets/simplewidgets.cpp:100 -#: src/plugins/accessible/widgets/simplewidgets.cpp:245 -msgid "Uncheck" -msgstr "" - -#: src/plugins/accessible/widgets/simplewidgets.cpp:103 -#: src/plugins/accessible/widgets/simplewidgets.cpp:108 -#: src/plugins/accessible/widgets/simplewidgets.cpp:247 -msgid "Check" -msgstr "" - -#: src/plugins/accessible/widgets/simplewidgets.cpp:104 -#: src/plugins/accessible/widgets/simplewidgets.cpp:714 -msgid "Toggle" -msgstr "" - -#: src/plugins/accessible/widgets/simplewidgets.cpp:250 -#: src/plugins/accessible/widgets/simplewidgets.cpp:409 -#: src/plugins/accessible/widgets/simplewidgets.cpp:415 -#: src/plugins/accessible/widgets/complexwidgets.cpp:1599 -msgid "Press" -msgstr "" - -#: src/plugins/accessible/widgets/qaccessiblemenu.cpp:140 -#: src/plugins/accessible/widgets/qaccessiblemenu.cpp:365 -#: src/plugins/accessible/widgets/qaccessiblemenu.cpp:418 -msgid "Execute" -msgstr "" - -#: src/plugins/accessible/widgets/rangecontrols.cpp:128 -#: src/plugins/accessible/widgets/rangecontrols.cpp:391 -msgid "More" -msgstr "" - -#: src/plugins/accessible/widgets/rangecontrols.cpp:130 -#: src/plugins/accessible/widgets/rangecontrols.cpp:393 -msgid "Less" -msgstr "" - -#: src/plugins/accessible/widgets/rangecontrols.cpp:530 -msgid "Line up" -msgstr "" - -#: src/plugins/accessible/widgets/rangecontrols.cpp:534 -#: src/plugins/accessible/widgets/rangecontrols.cpp:687 -msgid "Position" -msgstr "" - -#: src/plugins/accessible/widgets/rangecontrols.cpp:538 -msgid "Line down" -msgstr "" - -#: src/plugins/accessible/widgets/rangecontrols.cpp:912 -msgid "QDial" -msgstr "" - -#: src/plugins/accessible/widgets/rangecontrols.cpp:914 -msgid "SpeedoMeter" -msgstr "" - -#: src/plugins/accessible/widgets/rangecontrols.cpp:916 -msgid "SliderHandle" -msgstr "" - -#: src/plugins/accessible/widgets/qaccessiblewidgets.cpp:1311 -msgid "Dock" -msgstr "" - -#: src/plugins/accessible/widgets/qaccessiblewidgets.cpp:1312 -msgid "Float" -msgstr "" - -#: src/plugins/accessible/widgets/complexwidgets.cpp:1495 -msgid "Scroll Left" -msgstr "" - -#: src/plugins/accessible/widgets/complexwidgets.cpp:1495 -msgid "Scroll Right" -msgstr "" - -#: src/plugins/accessible/widgets/complexwidgets.cpp:1604 -msgid "Close the tab" -msgstr "" - -#: src/plugins/accessible/widgets/complexwidgets.cpp:1607 -msgid "Activate the tab" -msgstr "" - #: src/scripttools/debugging/qscriptedit.cpp:391 #: src/scripttools/debugging/qscriptdebugger.cpp:1767 msgid "Toggle Breakpoint" @@ -5706,12 +5585,12 @@ msgctxt "QFormBuilder" msgid "The enumeration-type property %1 could not be read." msgstr "" -#: src/uitools/properties.cpp:292 +#: src/uitools/properties.cpp:289 msgctxt "QFormBuilder" msgid "Reading properties of the type %1 is not supported yet." msgstr "" -#: src/uitools/properties.cpp:565 +#: src/uitools/properties.cpp:558 msgctxt "QFormBuilder" msgid "The property %1 could not be written. The type %2 is not supported yet." msgstr "" @@ -5807,14 +5686,14 @@ msgctxt "QAbstractFormBuilder" msgid "This version of the uitools library is linked without script support." msgstr "" -#: src/uitools/properties_p.h:109 +#: src/uitools/properties_p.h:107 msgctxt "QFormBuilder" msgid "" "The enumeration-value '%1' is invalid. The default value '%2' will be used " "instead." msgstr "" -#: src/uitools/properties_p.h:123 +#: src/uitools/properties_p.h:121 msgctxt "QFormBuilder" msgid "The flag-value '%1' is invalid. Zero will be used instead." msgstr "" diff --git a/translations/qt_tools.pot b/translations/qt_tools.pot index 4ab5f2262..d57913fb2 100644 --- a/translations/qt_tools.pot +++ b/translations/qt_tools.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-01-10 12:09+0200\n" +"POT-Creation-Date: 2022-01-26 19:24+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -99,11 +99,11 @@ msgstr "" msgid "Katie Configuration" msgstr "" -#: src/tools/qtconfig/mainwindow.cpp:540 +#: src/tools/qtconfig/mainwindow.cpp:546 msgid "Save Changes" msgstr "" -#: src/tools/qtconfig/mainwindow.cpp:541 +#: src/tools/qtconfig/mainwindow.cpp:547 msgid "Save changes to settings?" msgstr ""