diff options
author | Frederik Gladhorn <frederik.gladhorn@nokia.com> | 2011-11-30 17:07:39 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-08 08:51:35 +0100 |
commit | 1e37a053ed6d52cd2ea662f84c97c718b38367c9 (patch) | |
tree | d44140459f45052a20e99ae279d39503359a4307 /src/gui | |
parent | 59fb0328392a5fc47e3a013403fe192c215d8aa7 (diff) |
Create a class to contain accessibilty enums.
This is needed in order to expose the enums to qml.
Do not inherit QAccessible.
Change-Id: I220a0ea3add2d790e4fa6e93ce3deda762859e1a
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/accessible/qaccessible.cpp | 6 | ||||
-rw-r--r-- | src/gui/accessible/qaccessible.h | 45 | ||||
-rw-r--r-- | src/gui/accessible/qaccessible2.h | 3 | ||||
-rw-r--r-- | src/gui/accessible/qaccessibleobject.cpp | 26 | ||||
-rw-r--r-- | src/gui/accessible/qaccessibleobject.h | 12 | ||||
-rw-r--r-- | src/gui/accessible/qaccessibleplugin.h | 2 |
6 files changed, 55 insertions, 39 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 29b9a20b93..c65e7df327 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -859,7 +859,7 @@ const QAccessibleInterface *other, int otherChild) const */ QAccessible::Relation QAccessibleInterface::relationTo(const QAccessibleInterface *) const { - return Unrelated; + return QAccessible::Unrelated; } /*! @@ -871,7 +871,7 @@ QAccessible::Relation QAccessibleInterface::relationTo(const QAccessibleInterfac */ QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > QAccessibleInterface::relations() const { - return QVector<QPair<QAccessibleInterface*, Relation> >(); + return QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >(); } /*! @@ -1191,7 +1191,7 @@ QWindow *QAccessibleInterface::window() const Returns an invalid QVariant if the object doesn't support the action. */ -QVariant QAccessibleInterface::invokeMethod(Method method, const QVariantList ¶ms) +QVariant QAccessibleInterface::invokeMethod(QAccessible::Method method, const QVariantList ¶ms) { Q_UNUSED(method) Q_UNUSED(params) diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h index dca398a9f7..6ee1885a3d 100644 --- a/src/gui/accessible/qaccessible.h +++ b/src/gui/accessible/qaccessible.h @@ -62,9 +62,16 @@ QT_MODULE(Gui) class QAccessibleInterface; class QWindow; +// We need to inherit QObject to expose the enums to QML. class Q_GUI_EXPORT QAccessible +#ifndef qdoc + :public QObject +#endif { + Q_OBJECT + Q_ENUMS(Role Event State) public: + enum Event { SoundPlayed = 0x0001, Alert = 0x0002, @@ -141,6 +148,7 @@ public: AcceleratorChanged = 0x80C0 }; + enum StateFlag { Normal = 0x00000000, Unavailable = 0x00000001, @@ -152,11 +160,11 @@ public: ReadOnly = 0x00000040, HotTracked = 0x00000080, DefaultButton = 0x00000100, - // #### Qt5 Expandable Expanded = 0x00000200, Collapsed = 0x00000400, Busy = 0x00000800, // Floating = 0x00001000, + Expandable = 0x00001000, Marqueed = 0x00002000, Animated = 0x00004000, Invisible = 0x00008000, @@ -180,6 +188,7 @@ public: }; Q_DECLARE_FLAGS(State, StateFlag) + enum Role { NoRole = 0x00000000, TitleBar = 0x00000001, @@ -224,7 +233,10 @@ public: Graphic = 0x00000028, StaticText = 0x00000029, EditableText = 0x0000002A, // Editable, selectable, etc. - PushButton = 0x0000002B, + Button = 0x0000002B, +#ifndef qdoc + PushButton = Button, // deprecated +#endif CheckBox = 0x0000002C, RadioButton = 0x0000002D, ComboBox = 0x0000002E, @@ -321,6 +333,12 @@ public: private: static UpdateHandler updateHandler; static RootObjectHandler rootObjectHandler; + + /*! @internal + This class is purely a collection of enums and static functions, + it is not supposed to be instantiated. + */ + QAccessible() {} }; Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::State) @@ -338,7 +356,7 @@ class QAccessibleImageInterface; class QAccessibleTableInterface; class QAccessibleTableCellInterface; -class Q_GUI_EXPORT QAccessibleInterface : public QAccessible +class Q_GUI_EXPORT QAccessibleInterface { public: virtual ~QAccessibleInterface() {} @@ -348,8 +366,8 @@ public: virtual QWindow *window() const; // relations - virtual Relation relationTo(const QAccessibleInterface *other) const; - virtual QVector<QPair<QAccessibleInterface*, Relation> > relations() const; + virtual QAccessible::Relation relationTo(const QAccessibleInterface *other) const; + virtual QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > relations() const; virtual int childAt(int x, int y) const = 0; @@ -358,22 +376,23 @@ public: virtual QAccessibleInterface *child(int index) const = 0; virtual int childCount() const = 0; virtual int indexOfChild(const QAccessibleInterface *) const = 0; - virtual int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const = 0; + virtual int navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const = 0; // properties and state - virtual QString text(Text t) const = 0; - virtual void setText(Text t, const QString &text) = 0; + virtual QString text(QAccessible::Text t) const = 0; + virtual void setText(QAccessible::Text t, const QString &text) = 0; virtual QRect rect() const = 0; - virtual Role role() const = 0; - virtual State state() const = 0; + virtual QAccessible::Role role() const = 0; + virtual QAccessible::State state() const = 0; + // FIXME virtual QSet<QAccessible::State> states() const = 0; virtual QColor foregroundColor() const; virtual QColor backgroundColor() const; - virtual QVariant invokeMethod(Method method, const QVariantList ¶ms = QVariantList()); + virtual QVariant invokeMethod(QAccessible::Method method, const QVariantList ¶ms = QVariantList()); - inline QSet<Method> supportedMethods() - { return qvariant_cast<QSet<Method> >(invokeMethod(ListSupportedMethods)); } + inline QSet<QAccessible::Method> supportedMethods() + { return qvariant_cast<QSet<QAccessible::Method> >(invokeMethod(QAccessible::ListSupportedMethods)); } inline QAccessibleTextInterface *textInterface() { return reinterpret_cast<QAccessibleTextInterface *>(interface_cast(QAccessible::TextInterface)); } diff --git a/src/gui/accessible/qaccessible2.h b/src/gui/accessible/qaccessible2.h index 4155a1679a..93db869364 100644 --- a/src/gui/accessible/qaccessible2.h +++ b/src/gui/accessible/qaccessible2.h @@ -184,9 +184,6 @@ public: 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 QAccessibleInterface* table() const = 0; - - // #### Qt5 this should not be here but part of the state - virtual bool isExpandable() const = 0; }; class Q_GUI_EXPORT QAccessibleTableInterface diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp index 695c66654e..18941437fe 100644 --- a/src/gui/accessible/qaccessibleobject.cpp +++ b/src/gui/accessible/qaccessibleobject.cpp @@ -150,7 +150,7 @@ QRect QAccessibleObject::rect() const } /*! \reimp */ -void QAccessibleObject::setText(Text, const QString &) +void QAccessibleObject::setText(QAccessible::Text, const QString &) { } @@ -231,13 +231,13 @@ QAccessible::Relation QAccessibleApplication::relationTo(const QAccessibleInterf { QObject *o = other ? other->object() : 0; if (!o) - return Unrelated; + return QAccessible::Unrelated; if(o == object()) { - return Self; + return QAccessible::Self; } - return Unrelated; + return QAccessible::Unrelated; } QAccessibleInterface *QAccessibleApplication::parent() const @@ -254,7 +254,7 @@ QAccessibleInterface *QAccessibleApplication::child(int index) const } /*! \reimp */ -int QAccessibleApplication::navigate(RelationFlag relation, int, +int QAccessibleApplication::navigate(QAccessible::RelationFlag relation, int, QAccessibleInterface **target) const { if (!target) @@ -264,16 +264,16 @@ int QAccessibleApplication::navigate(RelationFlag relation, int, QObject *targetObject = 0; switch (relation) { - case Self: + case QAccessible::Self: targetObject = object(); break; - case FocusChild: + case QAccessible::FocusChild: if (QWindow *window = QGuiApplication::activeWindow()) { *target = window->accessibleRoot(); return 0; } break; - case Ancestor: + case QAccessible::Ancestor: *target = parent(); return 0; default: @@ -284,12 +284,12 @@ int QAccessibleApplication::navigate(RelationFlag relation, int, } /*! \reimp */ -QString QAccessibleApplication::text(Text t) const +QString QAccessibleApplication::text(QAccessible::Text t) const { switch (t) { - case Name: + case QAccessible::Name: return QGuiApplication::applicationName(); - case Description: + case QAccessible::Description: return QGuiApplication::applicationFilePath(); default: break; @@ -300,13 +300,13 @@ QString QAccessibleApplication::text(Text t) const /*! \reimp */ QAccessible::Role QAccessibleApplication::role() const { - return Application; + return QAccessible::Application; } /*! \reimp */ QAccessible::State QAccessibleApplication::state() const { - return QGuiApplication::activeWindow() ? Focused : Normal; + return QGuiApplication::activeWindow() ? QAccessible::Focused : QAccessible::Normal; } diff --git a/src/gui/accessible/qaccessibleobject.h b/src/gui/accessible/qaccessibleobject.h index 75d277f05b..f2a9fd0430 100644 --- a/src/gui/accessible/qaccessibleobject.h +++ b/src/gui/accessible/qaccessibleobject.h @@ -66,7 +66,7 @@ public: // properties QRect rect() const; - void setText(Text t, const QString &text); + void setText(QAccessible::Text t, const QString &text); protected: virtual ~QAccessibleObject(); @@ -85,18 +85,18 @@ public: // relations int childCount() const; int indexOfChild(const QAccessibleInterface*) const; - Relation relationTo(const QAccessibleInterface *other) const; + QAccessible::Relation relationTo(const QAccessibleInterface *other) const; // navigation QAccessibleInterface *parent() const; int childAt(int x, int y) const; QAccessibleInterface *child(int index) const; - int navigate(RelationFlag, int, QAccessibleInterface **) const; + int navigate(QAccessible::RelationFlag, int, QAccessibleInterface **) const; // properties and state - QString text(Text t) const; - Role role() const; - State state() const; + QString text(QAccessible::Text t) const; + QAccessible::Role role() const; + QAccessible::State state() const; }; #endif // QT_NO_ACCESSIBILITY diff --git a/src/gui/accessible/qaccessibleplugin.h b/src/gui/accessible/qaccessibleplugin.h index 3db84469ca..4e09034dfd 100644 --- a/src/gui/accessible/qaccessibleplugin.h +++ b/src/gui/accessible/qaccessibleplugin.h @@ -56,7 +56,7 @@ QT_MODULE(Gui) class QStringList; class QAccessibleInterface; -struct Q_GUI_EXPORT QAccessibleFactoryInterface : public QAccessible, public QFactoryInterface +struct Q_GUI_EXPORT QAccessibleFactoryInterface : public QFactoryInterface { virtual QAccessibleInterface* create(const QString &key, QObject *object) = 0; }; |