Remove QAccessibleEvent child parameter.

This makes the api cleaner and generally the child should not be there.
It is only sometimes more convenient not to create a QAccessibleInterface
instance, so the functionallity is kept.

Change-Id: I26018a6d3e0549f4d79856775b4167c5660e229d
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
This commit is contained in:
Frederik Gladhorn 2012-03-12 19:43:03 +01:00 committed by Qt by Nokia
parent d1fb20943d
commit c2e8db5841
26 changed files with 151 additions and 146 deletions

View File

@ -648,7 +648,8 @@ void QAccessible::setRootObject(QObject *object)
void QAccessible::updateAccessibility(QObject *object, int child, Event reason)
{
Q_ASSERT(object);
QAccessibleEvent ev(reason, object, child);
QAccessibleEvent ev(object, reason);
updateAccessibility(&ev);
}

View File

@ -434,8 +434,8 @@ class Q_GUI_EXPORT QAccessibleEvent
{
Q_DISABLE_COPY(QAccessibleEvent)
public:
inline QAccessibleEvent(QAccessible::Event typ, QObject *obj, int chld = -1)
: m_type(typ), m_object(obj), m_child(chld)
inline QAccessibleEvent(QObject *obj, QAccessible::Event typ)
: m_type(typ), m_object(obj), m_child(-1)
{
Q_ASSERT(obj);
// All events below have a subclass of QAccessibleEvent.
@ -454,6 +454,8 @@ public:
QAccessible::Event type() const { return m_type; }
QObject *object() const { return m_object; }
void setChild(int chld) { m_child = chld; }
int child() const { return m_child; }
QAccessibleInterface *accessibleInterface() const;
@ -467,8 +469,8 @@ protected:
class Q_GUI_EXPORT QAccessibleStateChangeEvent :public QAccessibleEvent
{
public:
inline QAccessibleStateChangeEvent(QAccessible::State state, QObject *obj, int chld = -1)
: QAccessibleEvent(QAccessible::InvalidEvent, obj, chld), m_changedStates(state)
inline QAccessibleStateChangeEvent(QObject *obj, QAccessible::State state)
: QAccessibleEvent(obj, QAccessible::InvalidEvent), m_changedStates(state)
{
m_type = QAccessible::StateChanged;
}
@ -485,8 +487,8 @@ protected:
class Q_GUI_EXPORT QAccessibleTextCursorEvent : public QAccessibleEvent
{
public:
inline QAccessibleTextCursorEvent(int cursorPos, QObject *obj, int chld = -1)
: QAccessibleEvent(QAccessible::InvalidEvent, obj, chld)
inline QAccessibleTextCursorEvent(QObject *obj, int cursorPos)
: QAccessibleEvent(obj, QAccessible::InvalidEvent)
, m_cursorPosition(cursorPos)
{
m_type = QAccessible::TextCaretMoved;
@ -503,8 +505,8 @@ protected:
class Q_GUI_EXPORT QAccessibleTextSelectionEvent : public QAccessibleTextCursorEvent
{
public:
inline QAccessibleTextSelectionEvent(int start, int end, QObject *obj, int chld = -1)
: QAccessibleTextCursorEvent((start == -1) ? 0 : end, obj, chld)
inline QAccessibleTextSelectionEvent(QObject *obj, int start, int end)
: QAccessibleTextCursorEvent(obj, (start == -1) ? 0 : end)
, m_selectionStart(start), m_selectionEnd(end)
{
m_type = QAccessible::TextSelectionChanged;
@ -526,8 +528,8 @@ protected:
class Q_GUI_EXPORT QAccessibleTextInsertEvent : public QAccessibleTextCursorEvent
{
public:
inline QAccessibleTextInsertEvent(int position, const QString &text, QObject *obj, int chld = -1)
: QAccessibleTextCursorEvent(position + text.length(), obj, chld)
inline QAccessibleTextInsertEvent(QObject *obj, int position, const QString &text)
: QAccessibleTextCursorEvent(obj, position + text.length())
, m_position(position), m_text(text)
{
m_type = QAccessible::TextInserted;
@ -548,8 +550,8 @@ protected:
class Q_GUI_EXPORT QAccessibleTextRemoveEvent : public QAccessibleTextCursorEvent
{
public:
inline QAccessibleTextRemoveEvent(int position, const QString &text, QObject *obj, int chld = -1)
: QAccessibleTextCursorEvent(position, obj, chld)
inline QAccessibleTextRemoveEvent(QObject *obj, int position, const QString &text)
: QAccessibleTextCursorEvent(obj, position)
, m_position(position), m_text(text)
{
m_type = QAccessible::TextRemoved;
@ -570,8 +572,8 @@ protected:
class Q_GUI_EXPORT QAccessibleTextUpdateEvent : public QAccessibleTextCursorEvent
{
public:
inline QAccessibleTextUpdateEvent(int position, const QString &oldText, const QString &text, QObject *obj, int chld = -1)
: QAccessibleTextCursorEvent(position + text.length(), obj, chld)
inline QAccessibleTextUpdateEvent(QObject *obj, int position, const QString &oldText, const QString &text)
: QAccessibleTextCursorEvent(obj, position + text.length())
, m_position(position), m_oldText(oldText), m_text(text)
{
m_type = QAccessible::TextUpdated;
@ -595,8 +597,8 @@ protected:
class Q_GUI_EXPORT QAccessibleValueChangeEvent : public QAccessibleEvent
{
public:
inline QAccessibleValueChangeEvent(const QVariant &val, QObject *obj, int chld = -1)
: QAccessibleEvent(QAccessible::InvalidEvent, obj, chld)
inline QAccessibleValueChangeEvent(QObject *obj, const QVariant &val)
: QAccessibleEvent(obj, QAccessible::InvalidEvent)
, m_value(val)
{
m_type = QAccessible::ValueChanged;

View File

@ -183,35 +183,39 @@ private:
}
static QAccessibleEvent *copyEvent(QAccessibleEvent *event)
{
QAccessibleEvent *ev;
if (event->type() == QAccessible::StateChanged) {
return new QAccessibleStateChangeEvent(static_cast<QAccessibleStateChangeEvent*>(event)->changedStates(),
event->object(), event->child());
ev = new QAccessibleStateChangeEvent(event->object(),
static_cast<QAccessibleStateChangeEvent*>(event)->changedStates());
} else if (event->type() == QAccessible::TextCaretMoved) {
return new QAccessibleTextCursorEvent(static_cast<QAccessibleTextCursorEvent*>(event)->cursorPosition(), event->object(), event->child());
ev = new QAccessibleTextCursorEvent(event->object(), static_cast<QAccessibleTextCursorEvent*>(event)->cursorPosition());
} else if (event->type() == QAccessible::TextSelectionChanged) {
const QAccessibleTextSelectionEvent *original = static_cast<QAccessibleTextSelectionEvent*>(event);
QAccessibleTextSelectionEvent *ev = new QAccessibleTextSelectionEvent(original->selectionStart(), original->selectionEnd(), event->object(), event->child());
ev->setCursorPosition(original->cursorPosition());
return ev;
QAccessibleTextSelectionEvent *sel = new QAccessibleTextSelectionEvent(event->object(), original->selectionStart(), original->selectionEnd());
sel->setCursorPosition(original->cursorPosition());
ev = sel;
} else if (event->type() == QAccessible::TextInserted) {
const QAccessibleTextInsertEvent *original = static_cast<QAccessibleTextInsertEvent*>(event);
QAccessibleTextInsertEvent *ev = new QAccessibleTextInsertEvent(original->changePosition(), original->textInserted(), event->object(), event->child());
ev->setCursorPosition(original->cursorPosition());
return ev;
QAccessibleTextInsertEvent *ins = new QAccessibleTextInsertEvent(event->object(), original->changePosition(), original->textInserted());
ins->setCursorPosition(original->cursorPosition());
ev = ins;
} else if (event->type() == QAccessible::TextRemoved) {
const QAccessibleTextRemoveEvent *original = static_cast<QAccessibleTextRemoveEvent*>(event);
QAccessibleTextRemoveEvent *ev = new QAccessibleTextRemoveEvent(original->changePosition(), original->textRemoved(), event->object(), event->child());
ev->setCursorPosition(original->cursorPosition());
return ev;
QAccessibleTextRemoveEvent *rem = new QAccessibleTextRemoveEvent(event->object(), original->changePosition(), original->textRemoved());
rem->setCursorPosition(original->cursorPosition());
ev = rem;
} else if (event->type() == QAccessible::TextUpdated) {
const QAccessibleTextUpdateEvent *original = static_cast<QAccessibleTextUpdateEvent*>(event);
QAccessibleTextUpdateEvent *ev = new QAccessibleTextUpdateEvent(original->changePosition(), original->textRemoved(), original->textInserted(), event->object(), event->child());
ev->setCursorPosition(original->cursorPosition());
return ev;
QAccessibleTextUpdateEvent *upd = new QAccessibleTextUpdateEvent(event->object(), original->changePosition(), original->textRemoved(), original->textInserted());
upd->setCursorPosition(original->cursorPosition());
ev = upd;
} else if (event->type() == QAccessible::ValueChanged) {
return new QAccessibleValueChangeEvent(static_cast<QAccessibleValueChangeEvent*>(event)->value(), event->object(), event->child());
ev = new QAccessibleValueChangeEvent(event->object(), static_cast<QAccessibleValueChangeEvent*>(event)->value());
} else {
ev = new QAccessibleEvent(event->object(), event->type());
}
return new QAccessibleEvent(event->type(), event->object(), event->child());
ev->setChild(event->child());
return ev;
}
static EventList &eventList()

View File

@ -754,7 +754,7 @@ void QDialog::setVisible(bool visible)
}
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(QAccessible::DialogStart, this);
QAccessibleEvent event(this, QAccessible::DialogStart);
QAccessible::updateAccessibility(&event);
#endif
@ -764,7 +764,7 @@ void QDialog::setVisible(bool visible)
#ifndef QT_NO_ACCESSIBILITY
if (isVisible()) {
QAccessibleEvent event(QAccessible::DialogEnd, this);
QAccessibleEvent event(this, QAccessible::DialogEnd);
QAccessible::updateAccessibility(&event);
}
#endif

View File

@ -1463,7 +1463,7 @@ void QMessageBox::showEvent(QShowEvent *e)
d->updateSize();
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(QAccessible::Alert, this);
QAccessibleEvent event(this, QAccessible::Alert);
QAccessible::updateAccessibility(&event);
#endif
#ifdef Q_OS_WIN

View File

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

View File

@ -1112,7 +1112,7 @@ void QAbstractItemView::reset()
#ifdef Q_WS_X11
if (QAccessible::isActive()) {
QAccessible::queryAccessibleInterface(this)->table2Interface()->modelReset();
QAccessibleEvent event(QAccessible::TableModelChanged, this, 0);
QAccessibleEvent event(this, QAccessible::TableModelChanged);
QAccessible::updateAccessibility(&event);
}
#endif

View File

@ -3169,7 +3169,8 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
if (QAccessible::isActive()) {
if (current.isValid()) {
int entry = visualIndex(current) + 1;
QAccessibleEvent event(QAccessible::Focus, this, entry);
QAccessibleEvent event(this, QAccessible::Focus);
event.setChild(entry);
QAccessible::updateAccessibility(&event);
}
}
@ -3189,13 +3190,15 @@ void QListView::selectionChanged(const QItemSelection &selected,
QModelIndex sel = selected.indexes().value(0);
if (sel.isValid()) {
int entry = visualIndex(sel) + 1;
QAccessibleEvent event(QAccessible::Selection, this, entry);
QAccessibleEvent event(this, QAccessible::Selection);
event.setChild(entry);
QAccessible::updateAccessibility(&event);
}
QModelIndex desel = deselected.indexes().value(0);
if (desel.isValid()) {
int entry = visualIndex(desel) + 1;
QAccessibleEvent event(QAccessible::SelectionRemove, this, entry);
QAccessibleEvent event(this, QAccessible::SelectionRemove);
event.setChild(entry);
QAccessible::updateAccessibility(&event);
}
}

View File

@ -3182,7 +3182,8 @@ void QTableView::currentChanged(const QModelIndex &current, const QModelIndex &p
if (current.isValid()) {
Q_D(QTableView);
int entry = d->accessibleTable2Index(current);
QAccessibleEvent event(QAccessible::Focus, this, entry);
QAccessibleEvent event(this, QAccessible::Focus);
event.setChild(entry);
QAccessible::updateAccessibility(&event);
}
}
@ -3204,13 +3205,15 @@ void QTableView::selectionChanged(const QItemSelection &selected,
QModelIndex sel = selected.indexes().value(0);
if (sel.isValid()) {
int entry = d->accessibleTable2Index(sel);
QAccessibleEvent event(QAccessible::Selection, this, entry);
QAccessibleEvent event(this, QAccessible::Selection);
event.setChild(entry);
QAccessible::updateAccessibility(&event);
}
QModelIndex desel = deselected.indexes().value(0);
if (desel.isValid()) {
int entry = d->accessibleTable2Index(desel);
QAccessibleEvent event(QAccessible::SelectionRemove, this, entry);
QAccessibleEvent event(this, QAccessible::SelectionRemove);
event.setChild(entry);
QAccessible::updateAccessibility(&event);
}
}

View File

@ -2934,14 +2934,6 @@ void QTreeViewPrivate::insertViewItems(int pos, int count, const QTreeViewItem &
for (int i = pos + count; i < viewItems.count(); i++)
if (items[i].parentItem >= pos)
items[i].parentItem += count;
#ifndef QT_NO_ACCESSIBILITY
#ifdef Q_OS_UNIX
if (QAccessible::isActive()) {
QAccessibleEvent event(QAccessible::TableModelChanged, q, 0);
QAccessible::updateAccessibility(&event);
}
#endif
#endif
}
void QTreeViewPrivate::removeViewItems(int pos, int count)
@ -2953,14 +2945,6 @@ void QTreeViewPrivate::removeViewItems(int pos, int count)
for (int i = pos; i < viewItems.count(); i++)
if (items[i].parentItem >= pos)
items[i].parentItem -= count;
#ifndef QT_NO_ACCESSIBILITY
#ifdef Q_OS_UNIX
if (QAccessible::isActive()) {
QAccessibleEvent event(QAccessible::TableModelChanged, q, 0);
QAccessible::updateAccessibility(&event);
}
#endif
#endif
}
#if 0
@ -3769,16 +3753,10 @@ void QTreeView::currentChanged(const QModelIndex &current, const QModelIndex &pr
}
#ifndef QT_NO_ACCESSIBILITY
if (QAccessible::isActive() && current.isValid()) {
#ifdef Q_OS_UNIX
int entry = (visualIndex(current) + (header()?1:0))*current.model()->columnCount()+current.column() + 1;
QAccessibleEvent event(QAccessible::Focus, this, entry);
QAccessibleEvent event(this, QAccessible::Focus);
event.setChild(entry);
QAccessible::updateAccessibility(&event);
#else
int entry = visualIndex(current) + 1;
if (header())
++entry;
QAccessible::updateAccessibility(viewport(), entry, QAccessible::Focus);
#endif
}
#endif
}
@ -3797,14 +3775,16 @@ void QTreeView::selectionChanged(const QItemSelection &selected,
if (sel.isValid()) {
int entry = (visualIndex(sel) + (header()?1:0))*sel.model()->columnCount()+sel.column() + 1;
Q_ASSERT(entry > 0);
QAccessibleEvent event(QAccessible::Selection, this, entry);
QAccessibleEvent event(this, QAccessible::Selection);
event.setChild(entry);
QAccessible::updateAccessibility(&event);
}
QModelIndex desel = deselected.indexes().value(0);
if (desel.isValid()) {
int entry = (visualIndex(desel) + (header()?1:0))*desel.model()->columnCount()+desel.column() + 1;
Q_ASSERT(entry > 0);
QAccessibleEvent event(QAccessible::SelectionRemove, this, entry);
QAccessibleEvent event(this, QAccessible::SelectionRemove);
event.setChild(entry);
QAccessible::updateAccessibility(&event);
}
}

View File

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

View File

@ -5967,7 +5967,7 @@ void QWidget::setFocus(Qt::FocusReason reason)
if (!(f->inherits("QMenuBar") || f->inherits("QMenu") || f->inherits("QMenuItem")))
# endif
{
QAccessibleEvent event(QAccessible::Focus, f);
QAccessibleEvent event(f, QAccessible::Focus);
QAccessible::updateAccessibility(&event);
}
#endif
@ -6049,7 +6049,7 @@ void QWidget::clearFocus()
#endif
{
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(QAccessible::Focus, this);
QAccessibleEvent event(this, QAccessible::Focus);
QAccessible::updateAccessibility(&event);
#endif
}
@ -7057,7 +7057,7 @@ void QWidgetPrivate::show_helper()
#ifndef QT_NO_ACCESSIBILITY
if (q->windowType() != Qt::ToolTip) { // Tooltips are read aloud twice in MS narrator.
QAccessibleEvent event(QAccessible::ObjectShow, q);
QAccessibleEvent event(q, QAccessible::ObjectShow);
QAccessible::updateAccessibility(&event);
}
#endif
@ -7150,7 +7150,7 @@ void QWidgetPrivate::hide_helper()
#ifndef QT_NO_ACCESSIBILITY
if (wasVisible) {
QAccessibleEvent event(QAccessible::ObjectHide, q);
QAccessibleEvent event(q, QAccessible::ObjectHide);
QAccessible::updateAccessibility(&event);
}
#endif
@ -7384,7 +7384,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous)
qApp->d_func()->sendSyntheticEnterLeave(widget);
#ifndef QT_NO_ACCESSIBILITY
if (!spontaneous) {
QAccessibleEvent event(QAccessible::ObjectHide, widget);
QAccessibleEvent event(widget, QAccessible::ObjectHide);
QAccessible::updateAccessibility(&event);
}
#endif
@ -8261,7 +8261,7 @@ void QWidget::changeEvent(QEvent * event)
#ifndef QT_NO_ACCESSIBILITY
QAccessible::State s;
s.disabled = true;
QAccessibleStateChangeEvent event(s, this);
QAccessibleStateChangeEvent event(this, s);
QAccessible::updateAccessibility(&event);
#endif
break;
@ -10403,7 +10403,7 @@ void QWidget::setAccessibleName(const QString &name)
{
Q_D(QWidget);
d->accessibleName = name;
QAccessibleEvent event(QAccessible::NameChanged, this);
QAccessibleEvent event(this, QAccessible::NameChanged);
QAccessible::updateAccessibility(&event);
}
@ -10426,7 +10426,7 @@ void QWidget::setAccessibleDescription(const QString &description)
{
Q_D(QWidget);
d->accessibleDescription = description;
QAccessibleEvent event(QAccessible::DescriptionChanged, this);
QAccessibleEvent event(this, QAccessible::DescriptionChanged);
QAccessible::updateAccessibility(&event);
}

View File

@ -644,7 +644,7 @@ void QAbstractButton::setText(const QString &text)
update();
updateGeometry();
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(QAccessible::NameChanged, this);
QAccessibleEvent event(this, QAccessible::NameChanged);
QAccessible::updateAccessibility(&event);
#endif
}
@ -770,7 +770,7 @@ void QAbstractButton::setChecked(bool checked)
#ifndef QT_NO_ACCESSIBILITY
QAccessible::State s;
s.checked = true;
QAccessibleStateChangeEvent event(s, this);
QAccessibleStateChangeEvent event(this, s);
QAccessible::updateAccessibility(&event);
#endif
}

View File

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

View File

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

View File

@ -983,7 +983,7 @@ void QComboBoxPrivate::_q_dataChanged(const QModelIndex &topLeft, const QModelIn
q->update();
}
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(QAccessible::NameChanged, q, 0);
QAccessibleEvent event(q, QAccessible::NameChanged);
QAccessible::updateAccessibility(&event);
#endif
}
@ -1240,7 +1240,7 @@ void QComboBoxPrivate::_q_emitCurrentIndexChanged(const QModelIndex &index)
emit q->currentIndexChanged(index.row());
emit q->currentIndexChanged(itemText(index));
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(QAccessible::NameChanged, q, 0);
QAccessibleEvent event(q, QAccessible::NameChanged);
QAccessible::updateAccessibility(&event);
#endif
}
@ -2589,7 +2589,7 @@ void QComboBox::clear()
Q_D(QComboBox);
d->model->removeRows(0, d->model->rowCount(d->root), d->root);
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(QAccessible::NameChanged, this, 0);
QAccessibleEvent event(this, QAccessible::NameChanged);
QAccessible::updateAccessibility(&event);
#endif
}
@ -2609,7 +2609,7 @@ void QComboBox::clearEditText()
if (d->lineEdit)
d->lineEdit->clear();
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(QAccessible::NameChanged, this, 0);
QAccessibleEvent event(this, QAccessible::NameChanged);
QAccessible::updateAccessibility(&event);
#endif
}
@ -2623,7 +2623,7 @@ void QComboBox::setEditText(const QString &text)
if (d->lineEdit)
d->lineEdit->setText(text);
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(QAccessible::NameChanged, this, 0);
QAccessibleEvent event(this, QAccessible::NameChanged);
QAccessible::updateAccessibility(&event);
#endif
}

View File

@ -249,7 +249,7 @@ void QGroupBox::setTitle(const QString &title)
update();
updateGeometry();
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(QAccessible::NameChanged, this, 0);
QAccessibleEvent event(this, QAccessible::NameChanged);
QAccessible::updateAccessibility(&event);
#endif
}

View File

@ -316,7 +316,7 @@ void QLabel::setText(const QString &text)
#ifndef QT_NO_ACCESSIBILITY
if (accessibleName().isEmpty()) {
QAccessibleEvent event(QAccessible::NameChanged, this, 0);
QAccessibleEvent event(this, QAccessible::NameChanged);
QAccessible::updateAccessibility(&event);
}
#endif

View File

@ -144,7 +144,7 @@ void QLineEditPrivate::_q_selectionChanged()
emit q->selectionChanged();
#ifndef QT_NO_ACCESSIBILITY
QAccessibleTextSelectionEvent ev(control->selectionStart(), control->selectionEnd(), q);
QAccessibleTextSelectionEvent ev(q, control->selectionStart(), control->selectionEnd());
ev.setCursorPosition(control->cursorPosition());
QAccessible::updateAccessibility(&ev);
#endif

View File

@ -1076,9 +1076,11 @@ void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e
#ifndef QT_NO_ACCESSIBILITY
if (QAccessible::isActive()) {
int actionIndex = indexOf(action);
QAccessibleEvent focusEvent(QAccessible::Focus, q, actionIndex);
QAccessibleEvent focusEvent(q, QAccessible::Focus);
focusEvent.setChild(actionIndex);
QAccessible::updateAccessibility(&focusEvent);
QAccessibleEvent selectionEvent(QAccessible::Selection, q, actionIndex);
QAccessibleEvent selectionEvent(q, QAccessible::Selection);
focusEvent.setChild(actionIndex);
QAccessible::updateAccessibility(&selectionEvent);
}
#endif
@ -1972,7 +1974,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
}
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(QAccessible::PopupMenuStart, this ,0);
QAccessibleEvent event(this, QAccessible::PopupMenuStart);
QAccessible::updateAccessibility(&event);
#endif
}
@ -2094,7 +2096,7 @@ void QMenu::hideEvent(QHideEvent *)
d->eventLoop->exit();
d->setCurrentAction(0);
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(QAccessible::PopupMenuEnd, this);
QAccessibleEvent event(this, QAccessible::PopupMenuEnd);
QAccessible::updateAccessibility(&event);
#endif
#ifndef QT_NO_MENUBAR

View File

@ -531,9 +531,11 @@ void QMenuBarPrivate::_q_actionHovered()
#ifndef QT_NO_ACCESSIBILITY
if (QAccessible::isActive()) {
int actionIndex = actions.indexOf(action);
QAccessibleEvent focusEvent(QAccessible::Focus, q, actionIndex);
QAccessibleEvent focusEvent(q, QAccessible::Focus);
focusEvent.setChild(actionIndex);
QAccessible::updateAccessibility(&focusEvent);
QAccessibleEvent selectionEvent(QAccessible::Selection, q, actionIndex);
QAccessibleEvent selectionEvent(q, QAccessible::Selection);
selectionEvent.setChild(actionIndex);
QAccessible::updateAccessibility(&selectionEvent);
}
#endif //QT_NO_ACCESSIBILITY

View File

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

View File

@ -378,7 +378,7 @@ void QPushButton::setDefault(bool enable)
#ifndef QT_NO_ACCESSIBILITY
QAccessible::State s;
s.defaultButton = true;
QAccessibleStateChangeEvent event(s, this);
QAccessibleStateChangeEvent event(this, s);
QAccessible::updateAccessibility(&event);
#endif
}

View File

@ -1185,9 +1185,11 @@ void QTabBar::setCurrentIndex(int index)
d->layoutTab(index);
#ifndef QT_NO_ACCESSIBILITY
if (QAccessible::isActive()) {
QAccessibleEvent focusEvent(QAccessible::Focus, this, index);
QAccessibleEvent focusEvent(this, QAccessible::Focus);
focusEvent.setChild(index);
QAccessible::updateAccessibility(&focusEvent);
QAccessibleEvent selectionEvent(QAccessible::Selection, this, index);
QAccessibleEvent selectionEvent(this, QAccessible::Selection);
selectionEvent.setChild(index);
QAccessible::updateAccessibility(&selectionEvent);
}
#endif

View File

@ -769,15 +769,15 @@ void QWidgetLineControl::internalSetText(const QString &txt, int pos, bool edite
#ifndef QT_NO_ACCESSIBILITY
if (changed) {
if (oldText.isEmpty()) {
QAccessibleTextInsertEvent event(0, txt, parent());
QAccessibleTextInsertEvent event(parent(), 0, txt);
event.setCursorPosition(m_cursor);
QAccessible::updateAccessibility(&event);
} else if (txt.isEmpty()) {
QAccessibleTextRemoveEvent event(0, oldText, parent());
QAccessibleTextRemoveEvent event(parent(), 0, oldText);
event.setCursorPosition(m_cursor);
QAccessible::updateAccessibility(&event);
} else {
QAccessibleTextUpdateEvent event(0, oldText, txt, parent());
QAccessibleTextUpdateEvent event(parent(), 0, oldText, txt);
event.setCursorPosition(m_cursor);
QAccessible::updateAccessibility(&event);
}
@ -828,7 +828,7 @@ void QWidgetLineControl::internalInsert(const QString &s)
if (m_maskData) {
QString ms = maskString(m_cursor, s);
#ifndef QT_NO_ACCESSIBILITY
QAccessibleTextInsertEvent insertEvent(m_cursor, ms, parent());
QAccessibleTextInsertEvent insertEvent(parent(), m_cursor, ms);
QAccessible::updateAccessibility(&insertEvent);
#endif
for (int i = 0; i < (int) ms.length(); ++i) {
@ -840,14 +840,14 @@ void QWidgetLineControl::internalInsert(const QString &s)
m_cursor = nextMaskBlank(m_cursor);
m_textDirty = true;
#ifndef QT_NO_ACCESSIBILITY
QAccessibleTextCursorEvent event(m_cursor, parent());
QAccessibleTextCursorEvent event(parent(), m_cursor);
QAccessible::updateAccessibility(&event);
#endif
} else {
int remaining = m_maxLength - m_text.length();
if (remaining != 0) {
#ifndef QT_NO_ACCESSIBILITY
QAccessibleTextInsertEvent insertEvent(m_cursor, s, parent());
QAccessibleTextInsertEvent insertEvent(parent(), m_cursor, s);
QAccessible::updateAccessibility(&insertEvent);
#endif
m_text.insert(m_cursor, s.left(remaining));
@ -878,7 +878,7 @@ void QWidgetLineControl::internalDelete(bool wasBackspace)
addCommand(Command((CommandType)((m_maskData ? 2 : 0) + (wasBackspace ? Remove : Delete)),
m_cursor, m_text.at(m_cursor), -1, -1));
#ifndef QT_NO_ACCESSIBILITY
QAccessibleTextRemoveEvent event(m_cursor, m_text.at(m_cursor), parent());
QAccessibleTextRemoveEvent event(parent(), m_cursor, m_text.at(m_cursor));
QAccessible::updateAccessibility(&event);
#endif
if (m_maskData) {
@ -919,7 +919,7 @@ void QWidgetLineControl::removeSelectedText()
addCommand (Command(RemoveSelection, i, m_text.at(i), -1, -1));
}
#ifndef QT_NO_ACCESSIBILITY
QAccessibleTextRemoveEvent event(m_selstart, m_text.mid(m_selstart, m_selend - m_selstart), parent());
QAccessibleTextRemoveEvent event(parent(), m_selstart, m_text.mid(m_selstart, m_selend - m_selstart));
QAccessible::updateAccessibility(&event);
#endif
if (m_maskData) {
@ -1402,7 +1402,7 @@ void QWidgetLineControl::emitCursorPositionChanged()
#ifndef QT_NO_ACCESSIBILITY
// otherwise we send a selection update which includes the cursor
if (!hasSelectedText()) {
QAccessibleTextCursorEvent event(m_cursor, parent());
QAccessibleTextCursorEvent event(parent(), m_cursor);
QAccessible::updateAccessibility(&event);
}
#endif

View File

@ -369,21 +369,21 @@ void tst_QAccessibility::eventTest()
button->setObjectName(QString("Olaf"));
button->show();
QAccessibleEvent showEvent(QAccessible::ObjectShow, button, -1);
QAccessibleEvent showEvent(button, QAccessible::ObjectShow);
QVERIFY_EVENT(&showEvent);
button->setFocus(Qt::MouseFocusReason);
QTestAccessibility::clearEvents();
QTest::mouseClick(button, Qt::LeftButton, 0);
button->setAccessibleName("Olaf the second");
QAccessibleEvent nameEvent(QAccessible::NameChanged, button);
QAccessibleEvent nameEvent(button, QAccessible::NameChanged);
QVERIFY_EVENT(&nameEvent);
button->setAccessibleDescription("This is a button labeled Olaf");
QAccessibleEvent descEvent(QAccessible::DescriptionChanged, button);
QAccessibleEvent descEvent(button, QAccessible::DescriptionChanged);
QVERIFY_EVENT(&descEvent);
button->hide();
QAccessibleEvent hideEvent(QAccessible::ObjectHide, button);
QAccessibleEvent hideEvent(button, QAccessible::ObjectHide);
QVERIFY_EVENT(&hideEvent);
delete button;
@ -688,9 +688,10 @@ void tst_QAccessibility::hideShowTest()
window->show();
QVERIFY(!state(window).invisible);
QVERIFY(!state(child).invisible);
QAccessibleEvent show(QAccessible::ObjectShow, window);
QAccessibleEvent show(window, QAccessible::ObjectShow);
QVERIFY(QTestAccessibility::containsEvent(&show));
QAccessibleEvent showChild(QAccessible::ObjectShow, child);
QAccessibleEvent showChild(child, QAccessible::ObjectShow);
QVERIFY(QTestAccessibility::containsEvent(&showChild));
QTestAccessibility::clearEvents();
@ -698,9 +699,9 @@ void tst_QAccessibility::hideShowTest()
window->hide();
QVERIFY(state(window).invisible);
QVERIFY(state(child).invisible);
QAccessibleEvent hide(QAccessible::ObjectHide, window);
QAccessibleEvent hide(window, QAccessible::ObjectHide);
QVERIFY(QTestAccessibility::containsEvent(&hide));
QAccessibleEvent hideChild(QAccessible::ObjectHide, child);
QAccessibleEvent hideChild(child, QAccessible::ObjectHide);
QVERIFY(QTestAccessibility::containsEvent(&hideChild));
QTestAccessibility::clearEvents();
@ -782,7 +783,7 @@ void tst_QAccessibility::mainWindowTest()
QLatin1String name = QLatin1String("I am the main window");
mw->setWindowTitle(name);
QTest::qWaitForWindowShown(mw);
QAccessibleEvent show(QAccessible::ObjectShow, mw);
QAccessibleEvent show(mw, QAccessible::ObjectShow);
QVERIFY_EVENT(&show);
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(mw);
@ -943,7 +944,7 @@ void tst_QAccessibility::buttonTest()
QVERIFY(checkBox.isChecked());
QAccessible::State st;
st.checked = true;
QAccessibleStateChangeEvent ev(st, &checkBox);
QAccessibleStateChangeEvent ev(&checkBox, st);
QVERIFY_EVENT(&ev);
checkBox.setChecked(false);
QVERIFY_EVENT(&ev);
@ -964,7 +965,7 @@ void tst_QAccessibility::buttonTest()
QVERIFY(radio.isChecked());
QAccessible::State st;
st.checked = true;
QAccessibleStateChangeEvent ev(st, &radio);
QAccessibleStateChangeEvent ev(&radio, st);
QVERIFY_EVENT(&ev);
delete interface;
}
@ -1028,13 +1029,13 @@ void tst_QAccessibility::scrollBarTest()
scrollBar->resize(200, 50);
scrollBar->show();
QVERIFY(!scrollBarInterface->state().invisible);
QAccessibleEvent show(QAccessible::ObjectShow, scrollBar);
QAccessibleEvent show(scrollBar, QAccessible::ObjectShow);
QVERIFY(QTestAccessibility::containsEvent(&show));
QTestAccessibility::clearEvents();
scrollBar->hide();
QVERIFY(scrollBarInterface->state().invisible);
QAccessibleEvent hide(QAccessible::ObjectHide, scrollBar);
QAccessibleEvent hide(scrollBar, QAccessible::ObjectHide);
QVERIFY(QTestAccessibility::containsEvent(&hide));
QTestAccessibility::clearEvents();
@ -1475,7 +1476,7 @@ void tst_QAccessibility::spinBoxTest()
QTestAccessibility::clearEvents();
QTest::keyPress(spinBox, Qt::Key_Up);
QTest::qWait(200);
QAccessibleValueChangeEvent expectedEvent(spinBox->value(), spinBox);
QAccessibleValueChangeEvent expectedEvent(spinBox, spinBox->value());
QVERIFY(QTestAccessibility::containsEvent(&expectedEvent));
delete spinBox;
QTestAccessibility::clearEvents();
@ -1747,7 +1748,7 @@ void tst_QAccessibility::lineEditTest()
le->setFocus(Qt::TabFocusReason);
QTestAccessibility::clearEvents();
le2->setFocus(Qt::TabFocusReason);
QAccessibleEvent ev(QAccessible::Focus, le2);
QAccessibleEvent ev(le2, QAccessible::Focus);
QTRY_VERIFY(QTestAccessibility::containsEvent(&ev));
le->setText(QLatin1String("500"));
@ -1771,7 +1772,7 @@ void tst_QAccessibility::lineEditTest()
le3->setCursorPosition(3);
QCOMPARE(textIface->cursorPosition(), 3);
QAccessibleTextCursorEvent caretEvent(3, le3);
QAccessibleTextCursorEvent caretEvent(le3, 3);
QTRY_VERIFY(QTestAccessibility::containsEvent(&caretEvent));
QCOMPARE(textIface->selectionCount(), 0);
QTestAccessibility::clearEvents();
@ -1828,7 +1829,7 @@ void tst_QAccessibility::lineEditTest()
QTestAccessibility::clearEvents();
// cursor
lineEdit->setCursorPosition(5);
QAccessibleTextCursorEvent cursorEvent(5, lineEdit);
QAccessibleTextCursorEvent cursorEvent(lineEdit, 5);
QVERIFY_EVENT(&cursorEvent);
lineEdit->setCursorPosition(0);
cursorEvent.setCursorPosition(0);
@ -1837,7 +1838,7 @@ void tst_QAccessibility::lineEditTest()
// selection
lineEdit->setSelection(2, 4);
QAccessibleTextSelectionEvent sel(2, 2+4, lineEdit);
QAccessibleTextSelectionEvent sel(lineEdit, 2, 2+4);
QVERIFY_EVENT(&sel);
lineEdit->selectAll();
@ -1847,24 +1848,24 @@ void tst_QAccessibility::lineEditTest()
lineEdit->setSelection(10, -4);
QCOMPARE(lineEdit->cursorPosition(), 6);
QAccessibleTextSelectionEvent sel2(6, 10, lineEdit);
QAccessibleTextSelectionEvent sel2(lineEdit, 6, 10);
sel2.setCursorPosition(6);
QVERIFY_EVENT(&sel2);
lineEdit->deselect();
QAccessibleTextSelectionEvent sel3(-1, -1, lineEdit);
QAccessibleTextSelectionEvent sel3(lineEdit, -1, -1);
sel3.setCursorPosition(6);
QVERIFY_EVENT(&sel3);
// editing
lineEdit->clear();
// FIXME: improve redundant updates
QAccessibleTextRemoveEvent remove(0, text, lineEdit);
QAccessibleTextRemoveEvent remove(lineEdit, 0, text);
QVERIFY_EVENT(&remove);
QAccessibleTextSelectionEvent noSel(-1, -1, lineEdit);
QAccessibleTextSelectionEvent noSel(lineEdit, -1, -1);
QVERIFY_EVENT(&noSel);
QAccessibleTextCursorEvent cursor(0, lineEdit);
QAccessibleTextCursorEvent cursor(lineEdit, 0);
QVERIFY_EVENT(&cursor);
lineEdit->setText("foo");
@ -1872,11 +1873,11 @@ void tst_QAccessibility::lineEditTest()
cursorEvent.setCursorPosition(3);
QVERIFY_EVENT(&cursorEvent);
QAccessibleTextInsertEvent e(0, "foo", lineEdit);
QAccessibleTextInsertEvent e(lineEdit, 0, "foo");
QVERIFY(QTestAccessibility::containsEvent(&e));
lineEdit->setText("bar");
QAccessibleTextUpdateEvent update(0, "foo", "bar", lineEdit);
QAccessibleTextUpdateEvent update(lineEdit, 0, "foo", "bar");
QVERIFY(QTestAccessibility::containsEvent(&update));
// QTestEventList keys;
@ -2214,15 +2215,20 @@ void tst_QAccessibility::listTest()
// Check for events
QTest::mouseClick(listView->viewport(), Qt::LeftButton, 0, listView->visualItemRect(listView->item(1)).center());
QAccessibleEvent selectList2(QAccessible::Selection, listView, 2);
QVERIFY(QTestAccessibility::containsEvent(&selectList2));
QAccessibleEvent focusList2(QAccessible::Focus, listView, 2);
QVERIFY(QTestAccessibility::containsEvent(&focusList2));
QAccessibleEvent selectionEvent(listView, QAccessible::Selection);
selectionEvent.setChild(2);
QAccessibleEvent focusEvent(listView, QAccessible::Focus);
focusEvent.setChild(2);
QVERIFY(QTestAccessibility::containsEvent(&selectionEvent));
QVERIFY(QTestAccessibility::containsEvent(&focusEvent));
QTest::mouseClick(listView->viewport(), Qt::LeftButton, 0, listView->visualItemRect(listView->item(2)).center());
QAccessibleEvent selectList3(QAccessible::Selection, listView, 3);
QVERIFY(QTestAccessibility::containsEvent(&selectList3));
QAccessibleEvent focusList3(QAccessible::Focus, listView, 3);
QVERIFY(QTestAccessibility::containsEvent(&focusList3));
QAccessibleEvent selectionEvent2(listView, QAccessible::Selection);
selectionEvent2.setChild(3);
QAccessibleEvent focusEvent2(listView, QAccessible::Focus);
focusEvent2.setChild(3);
QVERIFY(QTestAccessibility::containsEvent(&selectionEvent2));
QVERIFY(QTestAccessibility::containsEvent(&focusEvent2));
listView->addItem("Munich");
QCOMPARE(iface->childCount(), 4);