Make QLineControl send accessibility updates.
authorFrederik Gladhorn <frederik.gladhorn@nokia.com>
Tue, 26 Apr 2011 16:41:15 +0000 (18:41 +0200)
committerThierry Bastian <thierry.bastian@nokia.com>
Thu, 12 May 2011 13:59:33 +0000 (15:59 +0200)
To make it emit the signals for the right object, it needs its parent to
be the QGraphicsItem/SGItem/QLineEdit.
According to IA2 it should emit TextUpdated and CursorMoved signals.
TextChanged is deprecated.
More fine grained signals would be desireable but this makes changes work at all.

Reviewed-by: Morten Sorvig
src/gui/accessible/qaccessible.h
src/gui/widgets/qlinecontrol.cpp
src/gui/widgets/qlinecontrol_p.h
src/gui/widgets/qlineedit_p.cpp
src/gui/widgets/qlineedit_p.h

index 871ca58..1e9e55e 100644 (file)
@@ -111,8 +111,8 @@ public:
         TableSummaryChanged,
         TextAttributeChanged,
         TextCaretMoved,
-        TextChanged,
-        TextColumnChanged,
+        // TextChanged, deprecated, use TextUpdated
+        TextColumnChanged = TextCaretMoved + 2,
         TextInserted,
         TextRemoved,
         TextUpdated,
index 40ebb65..2a15555 100644 (file)
@@ -651,7 +651,12 @@ void QLineControl::internalSetText(const QString &txt, int pos, bool edited)
     m_modifiedState =  m_undoState = 0;
     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);
+
+#ifndef QT_NO_ACCESSIBILITY
+    if (changed)
+        QAccessible::updateAccessibility(parent(), 0, QAccessible::TextUpdated);
+#endif
 }
 
 
@@ -1238,6 +1243,9 @@ void QLineControl::emitCursorPositionChanged()
         const int oldLast = m_lastCursorPos;
         m_lastCursorPos = m_cursor;
         cursorPositionChanged(oldLast, m_cursor);
+#ifndef QT_NO_ACCESSIBILITY
+        QAccessible::updateAccessibility(parent(), 0, QAccessible::TextCaretMoved);
+#endif
     }
 }
 
index 6918b83..9764ba9 100644 (file)
 #include "QtGui/qtextlayout.h"
 #include "QtGui/qstyleoption.h"
 #include "QtCore/qpointer.h"
-#include "QtGui/qlineedit.h"
 #include "QtGui/qclipboard.h"
 #include "QtCore/qpoint.h"
 #include "QtGui/qcompleter.h"
+#include "QtGui/qaccessible.h"
 
 QT_BEGIN_HEADER
 
index 23ac613..03716d4 100644 (file)
@@ -153,6 +153,7 @@ void QLineEditPrivate::init(const QString& txt)
 {
     Q_Q(QLineEdit);
     control = new QLineControl(txt);
+    control->setParent(q);
     control->setFont(q->font());
     QObject::connect(control, SIGNAL(textChanged(QString)),
             q, SIGNAL(textChanged(QString)));
index 32f6077..3169776 100644 (file)
@@ -84,7 +84,6 @@ public:
 
     ~QLineEditPrivate()
     {
-        delete control;
     }
 
     QLineControl *control;