Call QAccessible::updateAccessibility when caret moves in QTextEdit

Change-Id: I3b9e5d8e67b4928558b642a4d23aa60ae9dfde60
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
This commit is contained in:
José Millán Soto 2012-09-13 16:50:31 +02:00 committed by The Qt Project
parent 568b278b75
commit 6e713cf03d
4 changed files with 18 additions and 1 deletions

View File

@ -53,6 +53,9 @@
#include <qmenu.h>
#include <qstyle.h>
#include <qtimer.h>
#ifndef QT_NO_ACCESSIBILITY
#include <qaccessible.h>
#endif
#include "private/qtextdocumentlayout_p.h"
#include "qtextdocument.h"
#include "private/qtextdocument_p.h"
@ -154,7 +157,7 @@ void QTextEditPrivate::init(const QString &html)
QObject::connect(control, SIGNAL(redoAvailable(bool)), q, SIGNAL(redoAvailable(bool)));
QObject::connect(control, SIGNAL(copyAvailable(bool)), q, SIGNAL(copyAvailable(bool)));
QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged()));
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(_q_cursorPositionChanged()));
QObject::connect(control, SIGNAL(textChanged()), q, SLOT(updateMicroFocus()));
@ -206,6 +209,16 @@ void QTextEditPrivate::_q_repaintContents(const QRectF &contentsRect)
viewport->update(r);
}
void QTextEditPrivate::_q_cursorPositionChanged()
{
Q_Q(QTextEdit);
emit q->cursorPositionChanged();
#ifndef QT_NO_ACCESSIBILITY
QAccessibleTextCursorEvent event(q, q->textCursor().position());
QAccessible::updateAccessibility(&event);
#endif
}
void QTextEditPrivate::pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode)
{
QTextCursor cursor = control->textCursor();

View File

@ -304,6 +304,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_currentCharFormatChanged(const QTextCharFormat &))
Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars())
Q_PRIVATE_SLOT(d_func(), void _q_ensureVisible(const QRectF &))
Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged())
friend class QTextEditControl;
friend class QTextDocument;
friend class QWidgetTextControl;

View File

@ -99,6 +99,7 @@ public:
{ control->processEvent(e, QPointF(horizontalOffset(), verticalOffset()), viewport); }
void _q_currentCharFormatChanged(const QTextCharFormat &format);
void _q_cursorPositionChanged();
void updateDefaultTextOption();

View File

@ -1583,6 +1583,8 @@ void tst_QAccessibility::textEditTest()
edit.setTextCursor(c);
QAccessibleTextSelectionEvent sel(&edit, 2, 4);
QVERIFY_EVENT(&sel);
QAccessibleTextCursorEvent cursor(&edit, 4);
QVERIFY_EVENT(&cursor);
edit.selectAll();
int end = edit.textCursor().position();