diff options
Diffstat (limited to 'src/gui/accessible')
-rw-r--r-- | src/gui/accessible/accessible.pri | 1 | ||||
-rw-r--r-- | src/gui/accessible/qaccessible.cpp | 41 | ||||
-rw-r--r-- | src/gui/accessible/qaccessible.h | 72 | ||||
-rw-r--r-- | src/gui/accessible/qaccessible2_p.h | 45 |
4 files changed, 107 insertions, 52 deletions
diff --git a/src/gui/accessible/accessible.pri b/src/gui/accessible/accessible.pri index 9453ac20d0..615323dbec 100644 --- a/src/gui/accessible/accessible.pri +++ b/src/gui/accessible/accessible.pri @@ -4,7 +4,6 @@ contains(QT_CONFIG, accessibility) { HEADERS += \ accessible/qaccessible.h \ accessible/qaccessiblecache_p.h \ - accessible/qaccessible2_p.h \ accessible/qaccessibleobject.h \ accessible/qaccessibleplugin.h \ accessible/qplatformaccessibility.h diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index b8771ec583..5d28512697 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -1270,8 +1270,16 @@ QAccessibleInterface::~QAccessibleInterface() /*! \fn QAccessibleEvent::QAccessibleEvent(QObject *object, QAccessible::Event type) Constructs a QAccessibleEvent to notify that \a object has changed. - The event \a type explains what changed. - */ + The event \a type describes what changed. +*/ + +/*! \fn QAccessibleEvent::QAccessibleEvent(QAccessibleInterface *interface, QAccessible::Event type) + + Constructs a QAccessibleEvent to notify that \a interface has changed. + The event \a type describes what changed. + Use this function if you already have a QAccessibleInterface or no QObject, otherwise consider + the overload taking a \l QObject parameter as it might be cheaper. +*/ /*! \fn QAccessibleEvent::~QAccessibleEvent() Destroys the event. @@ -1293,6 +1301,22 @@ QAccessibleInterface::~QAccessibleInterface() Returns the child index. */ +/*! + \internal + Returns the uniqueId of the QAccessibleInterface represented by this event. + + In case the object() function returns 0 this is the only way to access the + interface. +*/ +QAccessible::Id QAccessibleEvent::uniqueId() const +{ + if (!m_object) + return m_uniqueId; + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(m_object); + if (m_child != -1) + iface = iface->child(m_child); + return QAccessible::uniqueId(iface); +} /*! \class QAccessibleValueChangeEvent @@ -1530,6 +1554,9 @@ QAccessibleInterface::~QAccessibleInterface() */ QAccessibleInterface *QAccessibleEvent::accessibleInterface() const { + if (m_object == 0) + return QAccessible::accessibleInterface(m_uniqueId); + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(m_object); if (!iface || !iface->isValid()) { static bool hasWarned = false; @@ -1681,9 +1708,13 @@ QDebug operator<<(QDebug d, const QAccessibleEvent &ev) d << "QAccessibleEvent(null)"; return d; } - d.nospace() << "QAccessibleEvent(object=" << hex << ev.object(); - d.nospace() << dec; - d.nospace() << "child=" << ev.child(); + d.nospace() << "QAccessibleEvent("; + if (ev.object()) { + d.nospace() << "object=" << hex << ev.object() << dec; + d.nospace() << "child=" << ev.child(); + } else { + d.nospace() << "no object, uniqueId=" << ev.uniqueId(); + } d << " event=" << qAccessibleEventString(ev.type()); if (ev.type() == QAccessible::StateChanged) { QAccessible::State changed = static_cast<const QAccessibleStateChangeEvent*>(&ev)->changedStates(); diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h index d5b0af550e..25ce161940 100644 --- a/src/gui/accessible/qaccessible.h +++ b/src/gui/accessible/qaccessible.h @@ -597,6 +597,7 @@ class Q_GUI_EXPORT QAccessibleEvent { Q_DISABLE_COPY(QAccessibleEvent) public: + inline QAccessibleEvent(QObject *obj, QAccessible::Event typ) : m_type(typ), m_object(obj), m_child(-1) { @@ -613,11 +614,27 @@ public: Q_ASSERT(m_type != QAccessible::TableModelChanged); } + inline QAccessibleEvent(QAccessibleInterface *iface, QAccessible::Event typ) + : m_type(typ), m_object(0) + { + Q_ASSERT(iface); + 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); + Q_ASSERT(m_type != QAccessible::TableModelChanged); + m_uniqueId = QAccessible::uniqueId(iface); + } + virtual ~QAccessibleEvent() {} QAccessible::Event type() const { return m_type; } QObject *object() const { return m_object; } + QAccessible::Id uniqueId() const; void setChild(int chld) { m_child = chld; } int child() const { return m_child; } @@ -627,7 +644,11 @@ public: protected: QAccessible::Event m_type; QObject *m_object; - int m_child; + union { + int m_child; + QAccessible::Id m_uniqueId; + }; + }; class Q_GUI_EXPORT QAccessibleStateChangeEvent :public QAccessibleEvent @@ -638,6 +659,11 @@ public: { m_type = QAccessible::StateChanged; } + inline QAccessibleStateChangeEvent(QAccessibleInterface *iface, QAccessible::State state) + : QAccessibleEvent(iface, QAccessible::InvalidEvent), m_changedStates(state) + { + m_type = QAccessible::StateChanged; + } QAccessible::State changedStates() const { return m_changedStates; @@ -657,6 +683,12 @@ public: { m_type = QAccessible::TextCaretMoved; } + inline QAccessibleTextCursorEvent(QAccessibleInterface *iface, int cursorPos) + : QAccessibleEvent(iface, QAccessible::InvalidEvent) + , m_cursorPosition(cursorPos) + { + m_type = QAccessible::TextCaretMoved; + } void setCursorPosition(int position) { m_cursorPosition = position; } int cursorPosition() const { return m_cursorPosition; } @@ -675,6 +707,12 @@ public: { m_type = QAccessible::TextSelectionChanged; } + inline QAccessibleTextSelectionEvent(QAccessibleInterface *iface, int start, int end) + : QAccessibleTextCursorEvent(iface, (start == -1) ? 0 : end) + , m_selectionStart(start), m_selectionEnd(end) + { + m_type = QAccessible::TextSelectionChanged; + } void setSelection(int start, int end) { m_selectionStart = start; @@ -698,6 +736,12 @@ public: { m_type = QAccessible::TextInserted; } + inline QAccessibleTextInsertEvent(QAccessibleInterface *iface, int position, const QString &text) + : QAccessibleTextCursorEvent(iface, position + text.length()) + , m_position(position), m_text(text) + { + m_type = QAccessible::TextInserted; + } QString textInserted() const { return m_text; @@ -720,6 +764,12 @@ public: { m_type = QAccessible::TextRemoved; } + inline QAccessibleTextRemoveEvent(QAccessibleInterface *iface, int position, const QString &text) + : QAccessibleTextCursorEvent(iface, position) + , m_position(position), m_text(text) + { + m_type = QAccessible::TextRemoved; + } QString textRemoved() const { return m_text; @@ -742,6 +792,12 @@ public: { m_type = QAccessible::TextUpdated; } + inline QAccessibleTextUpdateEvent(QAccessibleInterface *iface, int position, const QString &oldText, const QString &text) + : QAccessibleTextCursorEvent(iface, position + text.length()) + , m_position(position), m_oldText(oldText), m_text(text) + { + m_type = QAccessible::TextUpdated; + } QString textRemoved() const { return m_oldText; } @@ -767,6 +823,12 @@ public: { m_type = QAccessible::ValueChanged; } + inline QAccessibleValueChangeEvent(QAccessibleInterface *iface, const QVariant &val) + : QAccessibleEvent(iface, QAccessible::InvalidEvent) + , m_value(val) + { + m_type = QAccessible::ValueChanged; + } void setValue(const QVariant & val) { m_value= val; } QVariant value() const { return m_value; } @@ -794,6 +856,14 @@ public: { m_type = QAccessible::TableModelChanged; } + inline QAccessibleTableModelChangeEvent(QAccessibleInterface *iface, ModelChangeType changeType) + : QAccessibleEvent(iface, QAccessible::InvalidEvent) + , m_modelChangeType(changeType) + , m_firstRow(-1), m_firstColumn(-1), m_lastRow(-1), m_lastColumn(-1) + { + m_type = QAccessible::TableModelChanged; + } + void setModelChangeType(ModelChangeType changeType) { m_modelChangeType = changeType; } ModelChangeType modelChangeType() const { return m_modelChangeType; } diff --git a/src/gui/accessible/qaccessible2_p.h b/src/gui/accessible/qaccessible2_p.h deleted file mode 100644 index bb5ddf6edf..0000000000 --- a/src/gui/accessible/qaccessible2_p.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QACCESSIBLE2_H -#define QACCESSIBLE2_H - -#endif |