Add accessibility updates.
authorFrederik Gladhorn <frederik.gladhorn@nokia.com>
Tue, 20 Mar 2012 12:56:48 +0000 (13:56 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 23 Mar 2012 10:47:58 +0000 (11:47 +0100)
Re-add all accessibility updates with new api.

Change-Id: Iec91c41a0137911ccf6e9f4fa907a378d9dd335a
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
src/quick/items/qquickaccessibleattached.cpp
src/quick/items/qquickaccessibleattached_p.h
src/quick/items/qquickitem.cpp
src/quick/items/qquicktextinput.cpp

index 46f8541..27efebc 100644 (file)
@@ -144,6 +144,10 @@ QQuickAccessibleAttached::QQuickAccessibleAttached(QObject *parent)
     // Enable accessibility for items with accessible content. This also
     // enables accessibility for the ancestors of souch items.
     item->d_func()->setAccessibleFlagAndListener();
+#ifndef QT_NO_ACCESSIBILITY
+    QAccessibleEvent ev(item, QAccessible::ObjectCreated);
+    QAccessible::updateAccessibility(&ev);
+#endif
 }
 
 QQuickAccessibleAttached::~QQuickAccessibleAttached()
index 129c3ef..419f21a 100644 (file)
@@ -85,6 +85,10 @@ public:
         if (name != m_name) {
             m_name = name;
             emit nameChanged();
+#ifndef QT_NO_ACCESSIBILITY
+            QAccessibleEvent ev(parent(), QAccessible::NameChanged);
+            QAccessible::updateAccessibility(&ev);
+#endif
         }
     }
 
@@ -94,6 +98,10 @@ public:
         if (m_description != description) {
             m_description = description;
             emit descriptionChanged();
+#ifndef QT_NO_ACCESSIBILITY
+            QAccessibleEvent ev(parent(), QAccessible::DescriptionChanged);
+            QAccessible::updateAccessibility(&ev);
+#endif
         }
     }
 
index a5b70bb..caf1195 100644 (file)
@@ -3122,6 +3122,10 @@ void QQuickItem::inputMethodEvent(QInputMethodEvent *event)
 
 void QQuickItem::focusInEvent(QFocusEvent *)
 {
+#ifndef QT_NO_ACCESSIBILITY
+    QAccessibleEvent ev(this, QAccessible::Focus);
+    QAccessible::updateAccessibility(&ev);
+#endif
 }
 
 void QQuickItem::focusOutEvent(QFocusEvent *)
@@ -4085,7 +4089,12 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
         childVisibilityChanged |= QQuickItemPrivate::get(childItems.at(ii))->setEffectiveVisibleRecur(newEffectiveVisible);
 
     itemChange(QQuickItem::ItemVisibleHasChanged, effectiveVisible);
-
+#ifndef QT_NO_ACCESSIBILITY
+    if (isAccessible) {
+        QAccessibleEvent ev(q, effectiveVisible ? QAccessible::ObjectShow : QAccessible::ObjectHide);
+        QAccessible::updateAccessibility(&ev);
+    }
+#endif
     emit q->visibleChanged();
     if (childVisibilityChanged)
         emit q->visibleChildrenChanged();
index 7d7fe85..94856b6 100644 (file)
@@ -3302,6 +3302,7 @@ bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bo
 */
 void QQuickTextInputPrivate::internalSetText(const QString &txt, int pos, bool edited)
 {
+    Q_Q(QQuickTextInput);
     internalDeselect();
     QString oldText = m_text;
     if (m_maskData) {
@@ -3315,7 +3316,15 @@ void QQuickTextInputPrivate::internalSetText(const QString &txt, int pos, bool e
     m_cursor = (pos < 0 || pos > m_text.length()) ? m_text.length() : pos;
     m_textDirty = (oldText != m_text);
 
-    finishChange(-1, true, edited);
+    bool changed = finishChange(-1, true, edited);
+#ifdef QT_NO_ACCESSIBILITY
+    Q_UNUSED(changed)
+#else
+    if (changed) {
+        QAccessibleTextUpdateEvent ev(q, 0, oldText, m_text);
+        QAccessible::updateAccessibility(&ev);
+    }
+#endif
 }
 
 
@@ -3939,6 +3948,11 @@ bool QQuickTextInputPrivate::emitCursorPositionChanged()
             }
         }
 
+#ifndef QT_NO_ACCESSIBILITY
+        QAccessibleTextCursorEvent ev(q, m_cursor);
+        QAccessible::updateAccessibility(&ev);
+#endif
+
         return true;
     }
     return false;