Call updateAccessibility with the right index.

In Qt 4 index 0 was the widget itself.
With the cleanup of child index this now changed.
The default constructor uses -1 as parameter to signify that
the widget is the cause, not a child.

Change-Id: I329a1cc91bf2d1d1d8534739acbddfe107f40364
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
This commit is contained in:
Frederik Gladhorn 2012-03-07 13:39:57 +01:00 committed by Qt by Nokia
parent 316b050324
commit b55ed97e79
13 changed files with 36 additions and 36 deletions

View File

@ -754,7 +754,7 @@ void QDialog::setVisible(bool visible)
} }
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::DialogStart, this, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::DialogStart, this));
#endif #endif
} else { } else {
@ -763,7 +763,7 @@ void QDialog::setVisible(bool visible)
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
if (isVisible()) if (isVisible())
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::DialogEnd, this, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::DialogEnd, this));
#endif #endif
// Reimplemented to exit a modal event loop when the dialog is hidden. // Reimplemented to exit a modal event loop when the dialog is hidden.

View File

@ -1463,7 +1463,7 @@ void QMessageBox::showEvent(QShowEvent *e)
d->updateSize(); d->updateSize();
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Alert, this, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Alert, this));
#endif #endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if (const HMENU systemMenu = qt_getWindowsSystemMenu(this)) { if (const HMENU systemMenu = qt_getWindowsSystemMenu(this)) {

View File

@ -843,7 +843,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
if (focusItem) { if (focusItem) {
if (QGraphicsObject *focusObj = focusItem->toGraphicsObject()) { if (QGraphicsObject *focusObj = focusItem->toGraphicsObject()) {
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Focus, focusObj, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Focus, focusObj));
} }
} }
#endif #endif

View File

@ -412,7 +412,7 @@ QWhatsThisPrivate::QWhatsThisPrivate()
#endif #endif
} }
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ContextHelpStart, this, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ContextHelpStart, this));
#endif #endif
} }
@ -424,7 +424,7 @@ QWhatsThisPrivate::~QWhatsThisPrivate()
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
#endif #endif
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ContextHelpEnd, this, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ContextHelpEnd, this));
#endif #endif
instance = 0; instance = 0;
} }

View File

@ -5965,7 +5965,7 @@ void QWidget::setFocus(Qt::FocusReason reason)
// menus update the focus manually and this would create bogus events // menus update the focus manually and this would create bogus events
if (!(f->inherits("QMenuBar") || f->inherits("QMenu") || f->inherits("QMenuItem"))) if (!(f->inherits("QMenuBar") || f->inherits("QMenu") || f->inherits("QMenuItem")))
# endif # endif
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Focus, f, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Focus, f));
#endif #endif
#ifndef QT_NO_GRAPHICSVIEW #ifndef QT_NO_GRAPHICSVIEW
if (QWExtra *topData = window()->d_func()->extra) { if (QWExtra *topData = window()->d_func()->extra) {
@ -6045,7 +6045,7 @@ void QWidget::clearFocus()
#endif #endif
{ {
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Focus, this, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Focus, this));
#endif #endif
} }
} }
@ -7052,7 +7052,7 @@ void QWidgetPrivate::show_helper()
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
if (q->windowType() != Qt::ToolTip) // Tooltips are read aloud twice in MS narrator. if (q->windowType() != Qt::ToolTip) // Tooltips are read aloud twice in MS narrator.
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ObjectShow, q, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ObjectShow, q));
#endif #endif
if (QApplicationPrivate::hidden_focus_widget == q) { if (QApplicationPrivate::hidden_focus_widget == q) {
@ -7143,7 +7143,7 @@ void QWidgetPrivate::hide_helper()
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
if (wasVisible) if (wasVisible)
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ObjectHide, q, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ObjectHide, q));
#endif #endif
} }
@ -7375,7 +7375,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous)
qApp->d_func()->sendSyntheticEnterLeave(widget); qApp->d_func()->sendSyntheticEnterLeave(widget);
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
if (!spontaneous) if (!spontaneous)
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ObjectHide, widget, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ObjectHide, widget));
#endif #endif
} }
} }
@ -10386,7 +10386,7 @@ void QWidget::setAccessibleName(const QString &name)
{ {
Q_D(QWidget); Q_D(QWidget);
d->accessibleName = name; d->accessibleName = name;
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::NameChanged, this, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::NameChanged, this));
} }
QString QWidget::accessibleName() const QString QWidget::accessibleName() const
@ -10408,7 +10408,7 @@ void QWidget::setAccessibleDescription(const QString &description)
{ {
Q_D(QWidget); Q_D(QWidget);
d->accessibleDescription = description; d->accessibleDescription = description;
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::DescriptionChanged, this, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::DescriptionChanged, this));
} }
QString QWidget::accessibleDescription() const QString QWidget::accessibleDescription() const

View File

@ -647,7 +647,7 @@ void QAbstractButton::setText(const QString &text)
update(); update();
updateGeometry(); updateGeometry();
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::NameChanged, this, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::NameChanged, this));
#endif #endif
} }

View File

@ -538,7 +538,7 @@ void QAbstractSlider::setValue(int value)
emit sliderMoved((d->position = value)); emit sliderMoved((d->position = value));
} }
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ValueChanged, this, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ValueChanged, this));
#endif #endif
sliderChange(SliderValueChange); sliderChange(SliderValueChange);
emit valueChanged(value); emit valueChanged(value);

View File

@ -976,7 +976,7 @@ void QAbstractSpinBox::keyPressEvent(QKeyEvent *event)
} }
} }
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ValueChanged, this, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ValueChanged, this));
#endif #endif
return; return;
} }
@ -1595,7 +1595,7 @@ void QAbstractSpinBoxPrivate::updateState(bool up, bool fromKeyboard /* = false
buttonState = (up ? Up : Down) | (fromKeyboard ? Keyboard : Mouse); buttonState = (up ? Up : Down) | (fromKeyboard ? Keyboard : Mouse);
q->stepBy(up ? 1 : -1); q->stepBy(up ? 1 : -1);
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ValueChanged, q, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ValueChanged, q));
#endif #endif
} }
} }

View File

@ -144,7 +144,7 @@ void QLineEditPrivate::_q_selectionChanged()
emit q->selectionChanged(); emit q->selectionChanged();
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::TextSelectionChanged, q, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::TextSelectionChanged, q));
#endif #endif
} }

View File

@ -2091,7 +2091,7 @@ void QMenu::hideEvent(QHideEvent *)
d->eventLoop->exit(); d->eventLoop->exit();
d->setCurrentAction(0); d->setCurrentAction(0);
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::PopupMenuEnd, this, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::PopupMenuEnd, this));
#endif #endif
#ifndef QT_NO_MENUBAR #ifndef QT_NO_MENUBAR
if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)) if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget))

View File

@ -314,7 +314,7 @@ void QProgressBar::setValue(int value)
d->value = value; d->value = value;
emit valueChanged(value); emit valueChanged(value);
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ValueChanged, this, 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ValueChanged, this));
#endif #endif
if (d->repaintRequired()) if (d->repaintRequired())
repaint(); repaint();

View File

@ -768,7 +768,7 @@ void QWidgetLineControl::internalSetText(const QString &txt, int pos, bool edite
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
if (changed) if (changed)
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::TextUpdated, parent(), 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::TextUpdated, parent()));
#endif #endif
} }
@ -1367,7 +1367,7 @@ void QWidgetLineControl::emitCursorPositionChanged()
m_lastCursorPos = m_cursor; m_lastCursorPos = m_cursor;
cursorPositionChanged(oldLast, m_cursor); cursorPositionChanged(oldLast, m_cursor);
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::TextCaretMoved, parent(), 0)); QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::TextCaretMoved, parent()));
#endif #endif
} }
} }

View File

@ -415,7 +415,7 @@ void tst_QAccessibility::eventTest()
button->setObjectName(QString("Olaf")); button->setObjectName(QString("Olaf"));
button->show(); button->show();
QVERIFY_EVENT(button, 0, QAccessible::ObjectShow); QVERIFY_EVENT(button, -1, QAccessible::ObjectShow);
button->setFocus(Qt::MouseFocusReason); button->setFocus(Qt::MouseFocusReason);
QTestAccessibility::clearEvents(); QTestAccessibility::clearEvents();
QTest::mouseClick(button, Qt::LeftButton, 0); QTest::mouseClick(button, Qt::LeftButton, 0);
@ -423,12 +423,12 @@ void tst_QAccessibility::eventTest()
QVERIFY_EVENT(button, 0, QAccessible::StateChanged); QVERIFY_EVENT(button, 0, QAccessible::StateChanged);
button->setAccessibleName("Olaf the second"); button->setAccessibleName("Olaf the second");
QVERIFY_EVENT(button, 0, QAccessible::NameChanged); QVERIFY_EVENT(button, -1, QAccessible::NameChanged);
button->setAccessibleDescription("This is a button labeled Olaf"); button->setAccessibleDescription("This is a button labeled Olaf");
QVERIFY_EVENT(button, 0, QAccessible::DescriptionChanged); QVERIFY_EVENT(button, -1, QAccessible::DescriptionChanged);
button->hide(); button->hide();
QVERIFY_EVENT(button, 0, QAccessible::ObjectHide); QVERIFY_EVENT(button, -1, QAccessible::ObjectHide);
delete button; delete button;
} }
@ -732,16 +732,16 @@ void tst_QAccessibility::hideShowTest()
window->show(); window->show();
QVERIFY(!state(window).invisible); QVERIFY(!state(window).invisible);
QVERIFY(!state(child).invisible); QVERIFY(!state(child).invisible);
QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(window, 0, QAccessible::ObjectShow))); QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(window, -1, QAccessible::ObjectShow)));
QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(child, 0, QAccessible::ObjectShow))); QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(child, -1, QAccessible::ObjectShow)));
QTestAccessibility::clearEvents(); QTestAccessibility::clearEvents();
// hide() and veryfy that both window and child are invisible and get ObjectHide events. // hide() and veryfy that both window and child are invisible and get ObjectHide events.
window->hide(); window->hide();
QVERIFY(state(window).invisible); QVERIFY(state(window).invisible);
QVERIFY(state(child).invisible); QVERIFY(state(child).invisible);
QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(window, 0, QAccessible::ObjectHide))); QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(window, -1, QAccessible::ObjectHide)));
QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(child, 0, QAccessible::ObjectHide))); QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(child, -1, QAccessible::ObjectHide)));
QTestAccessibility::clearEvents(); QTestAccessibility::clearEvents();
delete window; delete window;
@ -822,7 +822,7 @@ void tst_QAccessibility::mainWindowTest()
QLatin1String name = QLatin1String("I am the main window"); QLatin1String name = QLatin1String("I am the main window");
mw->setWindowTitle(name); mw->setWindowTitle(name);
QTest::qWaitForWindowShown(mw); QTest::qWaitForWindowShown(mw);
QVERIFY_EVENT(mw, 0, QAccessible::ObjectShow); QVERIFY_EVENT(mw, -1, QAccessible::ObjectShow);
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(mw); QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(mw);
QCOMPARE(interface->text(QAccessible::Name), name); QCOMPARE(interface->text(QAccessible::Name), name);
@ -1052,12 +1052,12 @@ void tst_QAccessibility::scrollBarTest()
scrollBar->resize(200, 50); scrollBar->resize(200, 50);
scrollBar->show(); scrollBar->show();
QVERIFY(!scrollBarInterface->state().invisible); QVERIFY(!scrollBarInterface->state().invisible);
QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(scrollBar, 0, QAccessible::ObjectShow))); QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(scrollBar, -1, QAccessible::ObjectShow)));
QTestAccessibility::clearEvents(); QTestAccessibility::clearEvents();
scrollBar->hide(); scrollBar->hide();
QVERIFY(scrollBarInterface->state().invisible); QVERIFY(scrollBarInterface->state().invisible);
QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(scrollBar, 0, QAccessible::ObjectHide))); QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(scrollBar, -1, QAccessible::ObjectHide)));
QTestAccessibility::clearEvents(); QTestAccessibility::clearEvents();
// Test that the left/right subcontrols are set to unavailable when the scrollBar is at the minimum/maximum. // Test that the left/right subcontrols are set to unavailable when the scrollBar is at the minimum/maximum.
@ -1498,7 +1498,7 @@ void tst_QAccessibility::spinBoxTest()
QTest::keyPress(spinBox, Qt::Key_Up); QTest::keyPress(spinBox, Qt::Key_Up);
QTest::qWait(200); QTest::qWait(200);
EventList events = QTestAccessibility::events(); EventList events = QTestAccessibility::events();
QTestAccessibilityEvent expectedEvent(spinBox, 0, (int)QAccessible::ValueChanged); QTestAccessibilityEvent expectedEvent(spinBox, -1, (int)QAccessible::ValueChanged);
QVERIFY(events.contains(expectedEvent)); QVERIFY(events.contains(expectedEvent));
delete spinBox; delete spinBox;
QTestAccessibility::clearEvents(); QTestAccessibility::clearEvents();
@ -1769,7 +1769,7 @@ void tst_QAccessibility::lineEditTest()
le->setFocus(Qt::TabFocusReason); le->setFocus(Qt::TabFocusReason);
QTestAccessibility::clearEvents(); QTestAccessibility::clearEvents();
le2->setFocus(Qt::TabFocusReason); le2->setFocus(Qt::TabFocusReason);
QTRY_VERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(le2, 0, QAccessible::Focus))); QTRY_VERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(le2, -1, QAccessible::Focus)));
le->setText(QLatin1String("500")); le->setText(QLatin1String("500"));
le->setValidator(new QIntValidator()); le->setValidator(new QIntValidator());
@ -1789,7 +1789,7 @@ void tst_QAccessibility::lineEditTest()
le3->deselect(); le3->deselect();
le3->setCursorPosition(3); le3->setCursorPosition(3);
QCOMPARE(textIface->cursorPosition(), 3); QCOMPARE(textIface->cursorPosition(), 3);
QTRY_VERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(le3, 0, QAccessible::TextCaretMoved))); QTRY_VERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(le3, -1, QAccessible::TextCaretMoved)));
QCOMPARE(textIface->selectionCount(), 0); QCOMPARE(textIface->selectionCount(), 0);
QTestAccessibility::clearEvents(); QTestAccessibility::clearEvents();