diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-03-23 13:36:29 +0100 |
---|---|---|
committer | Kent Hansen <kent.hansen@nokia.com> | 2012-03-23 14:10:58 +0100 |
commit | 3b512ae142017f105f297467f74dc28d3cb9030a (patch) | |
tree | 9e131e23c01537f051851a1da9576c1e1ddf5ba2 /src/gui/accessible | |
parent | e20c4730192f312881591fb50e571af0a88fe421 (diff) | |
parent | f956f9a83603a3df5651e3238c24e8df37558d6e (diff) |
Merge master into api_changes
Change-Id: I93551e4d13a1b0815b359b9415060e9089477db1
Diffstat (limited to 'src/gui/accessible')
-rw-r--r-- | src/gui/accessible/qaccessible.cpp | 17 | ||||
-rw-r--r-- | src/gui/accessible/qaccessible.h | 155 |
2 files changed, 157 insertions, 15 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 59794a5a06..7b1da21095 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -268,16 +268,16 @@ QT_BEGIN_NAMESPACE 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. + \omitvalue TextAttributeChanged + \omitvalue 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. + \omitvalue TextInserted Text has been inserted into an editable widget. + \omitvalue TextRemoved Text has been removed from an editable widget. + \omitvalue TextSelectionChanged The selected text has changed in an editable widget. + \omitvalue TextUpdated The text has been update in an editable widget. + \omitvalue 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 @@ -648,7 +648,8 @@ void QAccessible::setRootObject(QObject *object) void QAccessible::updateAccessibility(QObject *object, int child, Event reason) { Q_ASSERT(object); - QAccessibleEvent ev(reason, object, child); + + QAccessibleEvent ev(object, reason); updateAccessibility(&ev); } diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h index 4d79fe78ee..91726f194b 100644 --- a/src/gui/accessible/qaccessible.h +++ b/src/gui/accessible/qaccessible.h @@ -145,7 +145,9 @@ public: ParentChanged = 0x800F, HelpChanged = 0x80A0, DefaultActionChanged = 0x80B0, - AcceleratorChanged = 0x80C0 + AcceleratorChanged = 0x80C0, + + InvalidEvent }; // 64 bit enums seem hard on some platforms (windows...) @@ -432,10 +434,19 @@ class Q_GUI_EXPORT QAccessibleEvent { Q_DISABLE_COPY(QAccessibleEvent) public: - inline QAccessibleEvent(QAccessible::Event typ, QObject *obj, int chld = -1) - : m_type(typ), m_object(obj), m_child(chld) + inline QAccessibleEvent(QObject *obj, QAccessible::Event typ) + : m_type(typ), m_object(obj), m_child(-1) { Q_ASSERT(obj); + // All events below have a subclass of QAccessibleEvent. + // Use the subclass, since it's expected that it's possible to cast to that. + Q_ASSERT(m_type != QAccessible::ValueChanged); + Q_ASSERT(m_type != QAccessible::StateChanged); + Q_ASSERT(m_type != QAccessible::TextCaretMoved); + Q_ASSERT(m_type != QAccessible::TextSelectionChanged); + Q_ASSERT(m_type != QAccessible::TextInserted); + Q_ASSERT(m_type != QAccessible::TextRemoved); + Q_ASSERT(m_type != QAccessible::TextUpdated); } virtual ~QAccessibleEvent() @@ -443,12 +454,13 @@ public: QAccessible::Event type() const { return m_type; } QObject *object() const { return m_object; } + + void setChild(int chld) { m_child = chld; } int child() const { return m_child; } QAccessibleInterface *accessibleInterface() const; protected: - QAccessible::Event m_type; QObject *m_object; int m_child; @@ -457,9 +469,11 @@ protected: class Q_GUI_EXPORT QAccessibleStateChangeEvent :public QAccessibleEvent { public: - inline QAccessibleStateChangeEvent(QAccessible::State state, QObject *obj, int chld = -1) - : QAccessibleEvent(QAccessible::StateChanged, obj, chld), m_changedStates(state) - {} + inline QAccessibleStateChangeEvent(QObject *obj, QAccessible::State state) + : QAccessibleEvent(obj, QAccessible::InvalidEvent), m_changedStates(state) + { + m_type = QAccessible::StateChanged; + } QAccessible::State changedStates() const { return m_changedStates; @@ -469,6 +483,133 @@ protected: QAccessible::State m_changedStates; }; +// Update the cursor and optionally the selection. +class Q_GUI_EXPORT QAccessibleTextCursorEvent : public QAccessibleEvent +{ +public: + inline QAccessibleTextCursorEvent(QObject *obj, int cursorPos) + : QAccessibleEvent(obj, QAccessible::InvalidEvent) + , m_cursorPosition(cursorPos) + { + m_type = QAccessible::TextCaretMoved; + } + + void setCursorPosition(int position) { m_cursorPosition = position; } + int cursorPosition() const { return m_cursorPosition; } + +protected: + int m_cursorPosition; +}; + +// Updates the cursor position simultaneously. By default the cursor is set to the end of the selection. +class Q_GUI_EXPORT QAccessibleTextSelectionEvent : public QAccessibleTextCursorEvent +{ +public: + inline QAccessibleTextSelectionEvent(QObject *obj, int start, int end) + : QAccessibleTextCursorEvent(obj, (start == -1) ? 0 : end) + , m_selectionStart(start), m_selectionEnd(end) + { + m_type = QAccessible::TextSelectionChanged; + } + + void setSelection(int start, int end) { + m_selectionStart = start; + m_selectionEnd = end; + } + + int selectionStart() const { return m_selectionStart; } + int selectionEnd() const { return m_selectionEnd; } + +protected: + int m_selectionStart; + int m_selectionEnd; +}; + +class Q_GUI_EXPORT QAccessibleTextInsertEvent : public QAccessibleTextCursorEvent +{ +public: + inline QAccessibleTextInsertEvent(QObject *obj, int position, const QString &text) + : QAccessibleTextCursorEvent(obj, position + text.length()) + , m_position(position), m_text(text) + { + m_type = QAccessible::TextInserted; + } + + QString textInserted() const { + return m_text; + } + int changePosition() const { + return m_position; + } + +protected: + int m_position; + QString m_text; +}; + +class Q_GUI_EXPORT QAccessibleTextRemoveEvent : public QAccessibleTextCursorEvent +{ +public: + inline QAccessibleTextRemoveEvent(QObject *obj, int position, const QString &text) + : QAccessibleTextCursorEvent(obj, position) + , m_position(position), m_text(text) + { + m_type = QAccessible::TextRemoved; + } + + QString textRemoved() const { + return m_text; + } + int changePosition() const { + return m_position; + } + +protected: + int m_position; + QString m_text; +}; + +class Q_GUI_EXPORT QAccessibleTextUpdateEvent : public QAccessibleTextCursorEvent +{ +public: + inline QAccessibleTextUpdateEvent(QObject *obj, int position, const QString &oldText, const QString &text) + : QAccessibleTextCursorEvent(obj, position + text.length()) + , m_position(position), m_oldText(oldText), m_text(text) + { + m_type = QAccessible::TextUpdated; + } + QString textRemoved() const { + return m_oldText; + } + QString textInserted() const { + return m_text; + } + int changePosition() const { + return m_position; + } + +protected: + int m_position; + QString m_oldText; + QString m_text; +}; + +class Q_GUI_EXPORT QAccessibleValueChangeEvent : public QAccessibleEvent +{ +public: + inline QAccessibleValueChangeEvent(QObject *obj, const QVariant &val) + : QAccessibleEvent(obj, QAccessible::InvalidEvent) + , m_value(val) + { + m_type = QAccessible::ValueChanged; + } + + void setValue(const QVariant & val) { m_value= val; } + QVariant value() const { return m_value; } + +protected: + QVariant m_value; +}; #define QAccessibleInterface_iid "org.qt-project.Qt.QAccessibleInterface" Q_DECLARE_INTERFACE(QAccessibleInterface, QAccessibleInterface_iid) |