summaryrefslogtreecommitdiffstats
path: root/src/gui/accessible/qaccessible.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/accessible/qaccessible.h')
-rw-r--r--src/gui/accessible/qaccessible.h155
1 files changed, 148 insertions, 7 deletions
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)