summaryrefslogtreecommitdiffstats
path: root/src/plugins/accessible/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/accessible/widgets')
-rw-r--r--src/plugins/accessible/widgets/complexwidgets.cpp1574
-rw-r--r--src/plugins/accessible/widgets/complexwidgets.h138
-rw-r--r--src/plugins/accessible/widgets/itemviews.cpp197
-rw-r--r--src/plugins/accessible/widgets/itemviews.h33
-rw-r--r--src/plugins/accessible/widgets/main.cpp2
-rw-r--r--src/plugins/accessible/widgets/qaccessiblemenu.cpp120
-rw-r--r--src/plugins/accessible/widgets/qaccessiblemenu.h15
-rw-r--r--src/plugins/accessible/widgets/qaccessiblewidgets.cpp448
-rw-r--r--src/plugins/accessible/widgets/qaccessiblewidgets.h49
-rw-r--r--src/plugins/accessible/widgets/rangecontrols.cpp14
-rw-r--r--src/plugins/accessible/widgets/rangecontrols.h14
-rw-r--r--src/plugins/accessible/widgets/simplewidgets.cpp87
-rw-r--r--src/plugins/accessible/widgets/simplewidgets.h37
13 files changed, 291 insertions, 2437 deletions
diff --git a/src/plugins/accessible/widgets/complexwidgets.cpp b/src/plugins/accessible/widgets/complexwidgets.cpp
index 1ceeb31b16..2c1330f188 100644
--- a/src/plugins/accessible/widgets/complexwidgets.cpp
+++ b/src/plugins/accessible/widgets/complexwidgets.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -68,1378 +68,6 @@ QT_BEGIN_NAMESPACE
QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
-#if 0
-#ifndef QT_NO_ITEMVIEWS
-/*
-The MSDN article "Exposing Data Tables through Microsoft Active Accessibility" explains
-how data tables should be exposed. Url: http://msdn2.microsoft.com/en-us/library/ms971325.aspx
-Basically, the model is like this:
-
-ROLE_SYSTEM_TABLE
- |- ROLE_SYSTEM_ROW
- | |- ROLE_SYSTEM_ROWHEADER
- | |- ROLE_SYSTEM_COLUMNHEADER
- | |- ROLE_SYSTEM_COLUMNHEADER
- | |- ROLE_SYSTEM_COLUMNHEADER
- | '- ..
- |- ROLE_SYSTEM_ROW
- | |- ROLE_SYSTEM_ROWHEADER
- | |- ROLE_SYSTEM_CELL
- | |- ROLE_SYSTEM_CELL
- | |- ROLE_SYSTEM_CELL
- | '- ..
- |- ROLE_SYSTEM_ROW
- | |- ROLE_SYSTEM_ROWHEADER
- | |- ROLE_SYSTEM_CELL
- | |- ROLE_SYSTEM_CELL
- | |- ROLE_SYSTEM_CELL
- | '- ..
- '- ..
-
-The headers of QTreeView is also represented like this.
-*/
-QAccessibleItemRow::QAccessibleItemRow(QAbstractItemView *aView, const QModelIndex &index, bool isHeader)
- : row(index), view(aView), m_header(isHeader)
-{
-}
-
-QHeaderView *QAccessibleItemRow::horizontalHeader() const
-{
- QHeaderView *header = 0;
- if (m_header) {
- if (false) {
-#ifndef QT_NO_TABLEVIEW
- } else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) {
- header = tv->horizontalHeader();
-#endif
-#ifndef QT_NO_TREEVIEW
- } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(view)) {
- header = tv->header();
-#endif
- }
- }
- return header;
-}
-
-QHeaderView *QAccessibleItemRow::verticalHeader() const
-{
- QHeaderView *header = 0;
-#ifndef QT_NO_TABLEVIEW
- if (const QTableView *tv = qobject_cast<const QTableView*>(view))
- header = tv->verticalHeader();
-#endif
- return header;
-}
-
-int QAccessibleItemRow::logicalFromChild(QHeaderView *header, int child) const
-{
- int logical = -1;
- if (header->sectionsHidden()) {
- int kid = 0;
- for (int i = 0; i < header->count(); ++i) {
- if (!header->isSectionHidden(i))
- ++kid;
- if (kid == child) {
- logical = i;
- break;
- }
- }
- } else {
- logical = child - 1;
- }
- return logical;
-}
-
-QRect QAccessibleItemRow::rect(int child) const
-{
- QRect r;
- if (view && view->isVisible()) {
- if (QHeaderView *header = horizontalHeader()) {
- if (!child) {
- r = header->rect();
- } else {
- if (QHeaderView *vheader = verticalHeader()) {
- if (child == 1) {
- int w = vheader->width();
- int h = header->height();
- r.setRect(0, 0, w, h);
- }
- --child;
- }
- if (child) {
- int logical = logicalFromChild(header, child);
- int w = header->sectionSize(logical);
- r.setRect(header->sectionViewportPosition(logical), 0, w, header->height());
- r.translate(header->mapTo(view, QPoint(0, 0)));
- }
- }
- } else if (row.isValid()) {
- if (!child) {
- QModelIndex parent = row.parent();
- const int colCount = row.model()->columnCount(parent);
- for (int i = 0; i < colCount; ++i)
- r |= view->visualRect(row.model()->index(row.row(), i, parent));
- r.translate(view->viewport()->mapTo(view, QPoint(0,0)));
-
- if (const QHeaderView *vheader = verticalHeader()) { // include the section of the vertical header
- QRect re;
- int logicalRow = row.row();
- int h = vheader->sectionSize(logicalRow);
- re.setRect(0, vheader->sectionViewportPosition(logicalRow), vheader->width(), h);
- re.translate(vheader->mapTo(view, QPoint(0, 0)));
- r |= re;
- }
- } else {
- if (QHeaderView *vheader = verticalHeader()) {
- if (child == 1) {
- int logicalRow = row.row();
- int h = vheader->sectionSize(logicalRow);
- r.setRect(0, vheader->sectionViewportPosition(logicalRow), vheader->width(), h);
- r.translate(vheader->mapTo(view, QPoint(0, 0)));
- }
- --child;
- }
- if (child) {
- r = view->visualRect(childIndex(child));
- r.translate(view->viewport()->mapTo(view, QPoint(0,0)));
- }
- }
- }
- }
- if (!r.isNull())
- r.translate(view->mapToGlobal(QPoint(0, 0)));
-
- return r;
-}
-
-int QAccessibleItemRow::treeLevel() const
-{
- int level = 0;
- QModelIndex idx = row;
- while (idx.isValid()) {
- idx = idx.parent();
- ++level;
- }
- return level;
-}
-
-QString QAccessibleItemRow::text_helper(int child) const
-{
- QString value;
- if (m_header) {
- if (!child)
- return QString();
- if (verticalHeader()) {
- if (child == 1)
- return QString();
- --child;
- }
- QHeaderView *header = horizontalHeader();
- int logical = logicalFromChild(header, child);
- value = view->model()->headerData(logical, Qt::Horizontal, Qt::AccessibleTextRole).toString();
- if (value.isEmpty())
- value = view->model()->headerData(logical, Qt::Horizontal).toString();
- return value;
- } else {
- if (!child) { // for one-column views (i.e. QListView)
- if (children().count() >= 1)
- child = 1;
- else
- return QString();
- }
- if (verticalHeader()) {
- if (child == 1) {
- int logical = row.row();
- value = view->model()->headerData(logical, Qt::Vertical, Qt::AccessibleTextRole).toString();
- if (value.isEmpty())
- value = view->model()->headerData(logical, Qt::Vertical).toString();
- return value;
- } else {
- --child;
- }
- }
- }
- if (value.isEmpty()) {
- QModelIndex idx = childIndex(child);
- if (idx.isValid()) {
- value = idx.model()->data(idx, Qt::AccessibleTextRole).toString();
- if (value.isEmpty())
- value = idx.model()->data(idx, Qt::DisplayRole).toString();
- }
- }
- return value;
-}
-
-QString QAccessibleItemRow::text(QAccessible::Text t, int child) const
-{
- QString value;
- if (t == Name) {
- value = text_helper(child);
- } else if (t == Value) {
-#ifndef QT_NO_TREEVIEW
- if (qobject_cast<const QTreeView*>(view)) {
- if (child == 0)
- value = QString::number(treeLevel());
- } else
-#endif
- {
- value = text_helper(child);
- }
- } else if (t == Description) {
-#ifndef QT_NO_TREEVIEW
- if (child == 0 && qobject_cast<const QTreeView*>(view)) {
- // We store the tree coordinates of the current item in the description.
- // This enables some screen readers to report where the focus is
- // in a tree view. (works in JAWS). Also, Firefox does the same thing.
- // For instance the description "L2, 4 of 25 with 24" means
- // "L2": Tree Level 2
- // "4 of 25": We are item 4 out of in total 25 other siblings
- // "with 24": We have 24 children. (JAWS does not read this number)
-
- // level
- int level = treeLevel();
-
- QAbstractItemModel *m = view->model();
- // totalSiblings and itemIndex
- QModelIndex parent = row.parent();
- int rowCount = m->rowCount(parent);
- int itemIndex = -1;
- int totalSiblings = 0;
- for (int i = 0 ; i < rowCount; ++i) {
- QModelIndex sibling = row.sibling(i, 0);
- if (!view->isIndexHidden(sibling))
- ++totalSiblings;
- if (row == sibling)
- itemIndex = totalSiblings;
- }
- int totalChildren = m->rowCount(row); // JAWS does not report child count, so we do
- // this simple and efficient.
- // (don't check if they are all visible).
- value = QString::fromAscii("L%1, %2 of %3 with %4").arg(level).arg(itemIndex).arg(totalSiblings).arg(totalChildren);
- } else
-#endif // QT_NO_TREEVIEW
- {
- if (!m_header) {
- if (child == 0 && children().count() >= 1)
- child = 1;
- if (verticalHeader()) {
- if (child == 1) {
- value = view->model()->headerData(row.row(), Qt::Vertical).toString();
- }
- --child;
- }
- if (child) {
- QModelIndex idx = childIndex(child);
- value = idx.model()->data(idx, Qt::AccessibleDescriptionRole).toString();
- }
-
- }
- }
- }
- return value;
-}
-
-void QAccessibleItemRow::setText(QAccessible::Text t, int child, const QString &text)
-{
- if (m_header) {
- if (child)
- view->model()->setHeaderData(child - 1, Qt::Horizontal, text);
- // child == 0 means the cell to the left of the horizontal header, which is empty!?
- } else {
- if (!child) {
- if (children().count() == 1)
- child = 1;
- else
- return;
- }
-
- if (verticalHeader()) {
- if (child == 1) {
- view->model()->setHeaderData(row.row(), Qt::Vertical, text);
- return;
- }
- --child;
- }
- QModelIndex idx = childIndex(child);
- if (!idx.isValid())
- return;
-
- switch (t) {
- case Description:
- const_cast<QAbstractItemModel *>(idx.model())->setData(idx, text,
- Qt::AccessibleDescriptionRole);
- break;
- case Value:
- const_cast<QAbstractItemModel *>(idx.model())->setData(idx, text, Qt::EditRole);
- break;
- default:
- break;
- }
- }
-}
-
-QModelIndex QAccessibleItemRow::childIndex(int child) const
-{
- QList<QModelIndex> kids = children();
- Q_ASSERT(child >= 1 && child <= kids.count());
- return kids.at(child - 1);
-}
-
-QList<QModelIndex> QAccessibleItemRow::children() const
-{
- QList<QModelIndex> kids;
- for (int i = 0; i < row.model()->columnCount(row.parent()); ++i) {
- QModelIndex idx = row.model()->index(row.row(), i, row.parent());
- if (!view->isIndexHidden(idx)) {
- kids << idx;
- }
- }
- return kids;
-}
-
-bool QAccessibleItemRow::isValid() const
-{
- return m_header ? true : row.isValid();
-}
-
-QObject *QAccessibleItemRow::object() const
-{
- return 0;
-}
-
-int QAccessibleItemRow::childCount() const
-{
- int count = 0;
- if (QHeaderView *header = horizontalHeader()) {
- count = header->count() - header->hiddenSectionCount();
- } else {
- count = children().count();
- }
-#ifndef QT_NO_TABLEVIEW
- if (qobject_cast<const QTableView*>(view)) {
- if (verticalHeader())
- ++count;
- }
-#endif
- return count;
-}
-
-int QAccessibleItemRow::indexOfChild(const QAccessibleInterface *iface) const
-{
- if (!iface || iface->role() != Row)
- return -1;
-
- //### meaningless code?
- QList<QModelIndex> kids = children();
- QModelIndex idx = static_cast<const QAccessibleItemRow *>(iface)->row;
- if (!idx.isValid())
- return -1;
- return kids.indexOf(idx) + 1;
-}
-
-QAccessible::Relation QAccessibleItemRow::relationTo(int child, const QAccessibleInterface *other,
- int otherChild) const
-{
- if (!child && !otherChild && other->object() == view)
- return Child;
- if (!child && !otherChild && other == this)
- return Self;
- if (!child && otherChild && other == this)
- return Ancestor;
- if (child && otherChild && other == this)
- return Sibling;
- return Unrelated;
-}
-
-int QAccessibleItemRow::childAt(int x, int y) const
-{
- if (!view || !view->isVisible())
- return -1;
-
- for (int i = childCount(); i >= 0; --i) {
- if (rect(i).contains(x, y))
- return i;
- }
- return -1;
-}
-
-QAbstractItemView::CursorAction QAccessibleItemRow::toCursorAction(
- QAccessible::Relation rel)
-{
- switch (rel) {
- case QAccessible::Up:
- return QAbstractItemView::MoveUp;
- case QAccessible::Down:
- return QAbstractItemView::MoveDown;
- case QAccessible::Left:
- return QAbstractItemView::MoveLeft;
- case QAccessible::Right:
- return QAbstractItemView::MoveRight;
- default:
- Q_ASSERT(false);
- }
- // should never be reached.
- return QAbstractItemView::MoveRight;
-}
-
-QAccessibleInterface *QAccessibleItemRow::parent() const
-{
- return new QAccessibleItemView(view->viewport());
-}
-
-QAccessibleInterface *QAccessibleItemRow::child(int) const
-{
- // FIXME? port to IA2 table2.
- return 0;
-}
-
-int QAccessibleItemRow::navigate(RelationFlag relation, int index,
- QAccessibleInterface **iface) const
-{
- *iface = 0;
- if (!view)
- return -1;
-
- switch (relation) {
- case Ancestor:
- *iface = parent();
- return *iface ? 0 : -1;
- case Child: {
- if (!index)
- return -1;
- if (index < 1 && index > childCount())
- return -1;
-
- return index;}
- case Sibling:
- if (index) {
- QAccessibleInterface *ifaceParent = parent();
- if (ifaceParent) {
- *iface = ifaceParent->child(index - 1);
- delete ifaceParent;
- return *iface ? 0 : -1;
- }
- }
- return -1;
- case Up:
- case Down:
- case Left:
- case Right: {
- // This is in the "not so nice" category. In order to find out which item
- // is geometrically around, we have to set the current index, navigate
- // and restore the index as well as the old selection
- view->setUpdatesEnabled(false);
- const QModelIndex oldIdx = view->currentIndex();
- QList<QModelIndex> kids = children();
- const QModelIndex currentIndex = index ? kids.at(index - 1) : QModelIndex(row);
- const QItemSelection oldSelection = view->selectionModel()->selection();
- view->setCurrentIndex(currentIndex);
- const QModelIndex idx = view->moveCursor(toCursorAction(relation), Qt::NoModifier);
- view->setCurrentIndex(oldIdx);
- view->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect);
- view->setUpdatesEnabled(true);
- if (!idx.isValid())
- return -1;
-
- if (idx.parent() != row.parent() || idx.row() != row.row())
- *iface = new QAccessibleItemRow(view, idx);
- return index ? kids.indexOf(idx) + 1 : 0; }
- default:
- break;
- }
-
- return -1;
-}
-
-QAccessible::Role QAccessibleItemRow::role(int child) const
-{
- if (false) {
-#ifndef QT_NO_TREEVIEW
- } else if (qobject_cast<const QTreeView*>(view)) {
- if (horizontalHeader()) {
- if (!child)
- return Row;
- return ColumnHeader;
- }
- return TreeItem;
-#endif
-#ifndef QT_NO_LISTVIEW
- } else if (qobject_cast<const QListView*>(view)) {
- return ListItem;
-#endif
-#ifndef QT_NO_TABLEVIEW
- } else if (qobject_cast<const QTableView *>(view)) {
- if (!child)
- return Row;
- if (child == 1) {
- if (verticalHeader())
- return RowHeader;
- }
- if (m_header)
- return ColumnHeader;
-#endif
- }
- return Cell;
-}
-
-QAccessible::State QAccessibleItemRow::state(int child) const
-{
- State st = Normal;
-
- if (!view)
- return st;
-
- QAccessibleInterface *parentIface = parent();
- QRect globalRect;
- if (parentIface) {
- globalRect = parentIface->rect(0);
- delete parentIface;
- }
- if (!globalRect.intersects(rect(child)))
- st |= Invisible;
-
- if (!horizontalHeader()) {
- if (!(st & Invisible)) {
- if (child) {
- if (QHeaderView *vheader = verticalHeader() ) {
- if (child == 1) {
- if (!vheader->isVisible())
- st |= Invisible;
- }
- --child;
- }
- if (child) {
- QModelIndex idx = childIndex(child);
- if (!idx.isValid())
- return st;
-
- if (view->selectionModel()->isSelected(idx))
- st |= Selected;
- if (view->selectionModel()->currentIndex() == idx)
- st |= Focused;
- if (idx.model()->data(idx, Qt::CheckStateRole).toInt() == Qt::Checked)
- st |= Checked;
-
- Qt::ItemFlags flags = idx.flags();
- if (flags & Qt::ItemIsSelectable) {
- st |= Selectable;
- if (view->selectionMode() == QAbstractItemView::MultiSelection)
- st |= MultiSelectable;
- if (view->selectionMode() == QAbstractItemView::ExtendedSelection)
- st |= ExtSelectable;
- }
- }
- } else {
- Qt::ItemFlags flags = row.flags();
- if (flags & Qt::ItemIsSelectable) {
- st |= Selectable;
- st |= Focusable;
- }
- if (view->selectionModel()->isRowSelected(row.row(), row.parent()))
- st |= Selected;
- if (view->selectionModel()->currentIndex().row() == row.row())
- st |= Focused;
- }
- }
- }
-
- return st;
-}
-
-int QAccessibleItemRow::userActionCount(int) const
-{
- return 0;
-}
-
-QString QAccessibleItemRow::actionText(int, Text, int) const
-{
- return QString();
-}
-
-static QItemSelection rowAt(const QModelIndex &idx)
-{
- return QItemSelection(idx.sibling(idx.row(), 0),
- idx.sibling(idx.row(), idx.model()->columnCount(idx.parent())));
-}
-
-bool QAccessibleItemRow::doAction(int action, int child, const QVariantList & /*params*/)
-{
- if (!view)
- return false;
-
- if (verticalHeader())
- --child;
-
- QModelIndex idx = child ? childIndex(child) : QModelIndex(row);
- if (!idx.isValid())
- return false;
-
- QItemSelectionModel::SelectionFlags command = QItemSelectionModel::NoUpdate;
-
- switch (action) {
- case SetFocus:
- view->setCurrentIndex(idx);
- return true;
- case ExtendSelection:
- if (!child)
- return false;
- view->selectionModel()->select(QItemSelection(view->currentIndex(), idx),
- QItemSelectionModel::SelectCurrent);
- return true;
- case Select:
- command = QItemSelectionModel::ClearAndSelect;
- break;
- case ClearSelection:
- command = QItemSelectionModel::Clear;
- break;
- case RemoveSelection:
- command = QItemSelectionModel::Deselect;
- break;
- case AddToSelection:
- command = QItemSelectionModel::SelectCurrent;
- break;
- }
- if (command == QItemSelectionModel::NoUpdate)
- return false;
-
- if (child)
- view->selectionModel()->select(idx, command);
- else
- view->selectionModel()->select(rowAt(row), command);
- return true;
-}
-
-class ModelIndexIterator
-{
-public:
- ModelIndexIterator(QAbstractItemView *view, const QModelIndex &start = QModelIndex()) : m_view(view)
- {
-#ifndef QT_NO_LISTVIEW
- list = qobject_cast<QListView*>(m_view);
-#endif
-#ifndef QT_NO_TREEVIEW
- tree = qobject_cast<QTreeView*>(m_view);
-#endif
-#ifndef QT_NO_TABLEVIEW
- table = qobject_cast<QTableView*>(m_view);
-#endif
- if (start.isValid()) {
- m_current = start;
- } else if (m_view && m_view->model()) {
- m_current = view->rootIndex().isValid() ?
- view->rootIndex().child(0,0) : view->model()->index(0, 0);
- }
- }
-
- bool next(int count = 1) {
- for (int i = 0; i < count; ++i) {
- do {
- if (m_current.isValid()) {
- const QAbstractItemModel *m = m_current.model();
-#ifndef QT_NO_TREEVIEW
- if (tree && m_current.model()->hasChildren(m_current) && tree->isExpanded(m_current)) {
- m_current = m_current.child(0, 0);
- } else
-#endif
- {
- int row = m_current.row();
- QModelIndex par = m_current.parent();
-
- // Go up to the parent if we reach the end of the rows
- // If m_curent becomses invalid, stop going up.
- while (row + 1 >= m->rowCount(par)) {
- m_current = par;
- if (m_current.isValid()) {
- row = m_current.row();
- par = m_current.parent();
- } else {
- row = 0;
- par = QModelIndex();
- break;
- }
- }
-
- if (m_current.isValid())
- m_current = m_current.sibling(row + 1, 0);
- }
- }
- } while (isHidden());
- }
- return m_current.isValid();
- }
-
- bool isHidden() const {
- if (false) {
-#ifndef QT_NO_LISTVIEW
- } else if (list) {
- return list->isRowHidden(m_current.row());
-#endif
-#ifndef QT_NO_TREEVIEW
- } else if (tree) {
- return tree->isRowHidden(m_current.row(), m_current.parent());
-#endif
-#ifndef QT_NO_TABLEVIEW
- } else if (table) {
- return table->isRowHidden(m_current.row());
-#endif
- }
- return false;
- }
-
- QModelIndex current() const {
- return m_current;
- }
-
-private:
- QModelIndex m_current;
- QAbstractItemView *m_view;
-
-#ifndef QT_NO_TREEVIEW
- QTreeView *tree;
-#endif
-#ifndef QT_NO_LISTVIEW
- QListView *list;
-#endif
-#ifndef QT_NO_TABLEVIEW
- QTableView *table;
-#endif
-};
-
-QAccessibleItemView::QAccessibleItemView(QWidget *w)
- : QAccessibleAbstractScrollArea(w->objectName() == QLatin1String("qt_scrollarea_viewport") ? w->parentWidget() : w)
-{
- atVP = w->objectName() == QLatin1String("qt_scrollarea_viewport");
-
-}
-
-
-QHeaderView *QAccessibleItemView::horizontalHeader() const
-{
- QHeaderView *header = 0;
- if (false) {
-#ifndef QT_NO_TABLEVIEW
- } else if (const QTableView *tv = qobject_cast<const QTableView*>(itemView())) {
- header = tv->horizontalHeader();
-#endif
-#ifndef QT_NO_TREEVIEW
- } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(itemView())) {
- header = tv->header();
-#endif
- }
- return header;
-}
-
-QHeaderView *QAccessibleItemView::verticalHeader() const
-{
- QHeaderView *header = 0;
- if (false) {
-#ifndef QT_NO_TABLEVIEW
- } else if (const QTableView *tv = qobject_cast<const QTableView*>(itemView())) {
- header = tv->verticalHeader();
-#endif
- }
- return header;
-}
-
-
-bool QAccessibleItemView::isValidChildRole(QAccessible::Role role) const
-{
- if (atViewport()) {
- if (false) {
-#ifndef QT_NO_TREEVIEW
- } else if (qobject_cast<const QTreeView*>(itemView())) {
- return (role == TreeItem || role == Row);
-#endif
-#ifndef QT_NO_LISTVIEW
- } else if (qobject_cast<const QListView*>(itemView())) {
- return (role == ListItem);
-#endif
- }
- // TableView
- return role == Row;
- } else {
- if (false) {
-#ifndef QT_NO_TREEVIEW
- } else if (qobject_cast<const QTreeView*>(itemView())) {
- return (role == Tree);
-#endif
-#ifndef QT_NO_LISTVIEW
- } else if (qobject_cast<const QListView*>(itemView())) {
- return (role == List);
-#endif
- }
- // TableView
- return (role == Table);
- }
-}
-
-QObject *QAccessibleItemView::object() const
-{
- QObject *view = QAccessibleAbstractScrollArea::object();
- Q_ASSERT(qobject_cast<const QAbstractItemView *>(view));
- if (atViewport())
- view = qobject_cast<const QAbstractItemView *>(view)->viewport();
- return view;
-}
-
-QAbstractItemView *QAccessibleItemView::itemView() const
-{
- return qobject_cast<QAbstractItemView *>(QAccessibleAbstractScrollArea::object());
-}
-
-int QAccessibleItemView::indexOfChild(const QAccessibleInterface *iface) const
-{
- if (atViewport()) {
- if (!iface || !isValidChildRole(iface->role(0)))
- return -1;
-
- int entry = -1;
- // ### This will fail if a row is hidden.
- const QAccessibleItemRow *ifRow = static_cast<const QAccessibleItemRow *>(iface);
- if (ifRow->horizontalHeader())
- return 1;
-
- QModelIndex idx = ifRow->row;
- if (!idx.isValid())
- return -1;
-
- entry = entryFromIndex(idx);
- if (horizontalHeader())
- ++entry;
-
- return entry;
-
- } else {
- return QAccessibleAbstractScrollArea::indexOfChild(iface);
- }
-}
-
-QModelIndex QAccessibleItemView::childIndex(int child) const
-{
- if (!atViewport())
- return QModelIndex();
- ModelIndexIterator it(itemView());
- it.next(child - 1);
- return it.current();
-}
-
-int QAccessibleItemView::entryFromIndex(const QModelIndex &index) const
-{
- int entry = -1;
- if (false) {
-#ifndef QT_NO_TREEVIEW
- } else if (QTreeView *tree = qobject_cast<QTreeView*>(itemView())) {
- entry = tree->visualIndex(index) + 1;
-#endif
-#ifndef QT_NO_LISTVIEW
- } else if (QListView *list = qobject_cast<QListView*>(itemView())) {
- entry = list->visualIndex(index) + 1;
-#endif
-#ifndef QT_NO_TABLEVIEW
- } else if (QTableView *table = qobject_cast<QTableView*>(itemView())) {
- entry = table->visualIndex(index) + 1;
-#endif
- }
- return entry;
-}
-
-int QAccessibleItemView::childCount() const
-{
- if (atViewport()) {
- if (itemView()->model() == 0)
- return 0;
- QAbstractItemModel *m = itemView()->model();
- QModelIndex idx = m->index(0,0);
- if (!idx.isValid())
- return 0;
- ModelIndexIterator it(itemView());
- int count = 1;
- while (it.next()) {
- ++count;
- }
- if (horizontalHeader())
- ++count;
-
- return count;
- } else {
- return QAccessibleAbstractScrollArea::childCount();
- }
-}
-
-QString QAccessibleItemView::text(QAccessible::Text t, int child) const
-{
- if (atViewport()) {
- if (!child)
- return QAccessibleAbstractScrollArea::text(t, child);
-
- QAccessibleItemRow item(itemView(), childIndex(child));
- if (item.isValid()) {
- return item.text(t, 1);
- } else {
- return QString();
- }
- } else {
- return QAccessibleAbstractScrollArea::text(t, child);
- }
-}
-
-void QAccessibleItemView::setText(QAccessible::Text t, int child, const QString &text)
-{
- if (atViewport()) {
- if (!child) {
- QAccessibleAbstractScrollArea::setText(t, child, text);
- return;
- }
-
- QAccessibleItemRow item(itemView(), childIndex(child));
- item.setText(t, 1, text);
- } else {
- QAccessibleAbstractScrollArea::setText(t, child, text);
- }
-}
-
-QRect QAccessibleItemView::rect(int childIndex) const
-{
- if (atViewport()) {
- QRect r;
- if (!childIndex) {
- // Make sure that the rect *include* the vertical and horizontal headers, while
- // not including the potential vertical and horizontal scrollbars.
- QAbstractItemView *w = itemView();
-
- int vscrollWidth = 0;
- const QScrollBar *sb = w->verticalScrollBar();
- if (sb && sb->isVisible())
- vscrollWidth = sb->width();
-
- int hscrollHeight = 0;
- sb = w->horizontalScrollBar();
- if (sb && sb->isVisible())
- hscrollHeight = sb->height();
-
- QPoint globalPos = w->mapToGlobal(QPoint(0,0));
- r = w->rect().translated(globalPos);
- if (w->isRightToLeft()) {
- r.adjust(vscrollWidth, 0, 0, -hscrollHeight);
- } else {
- r.adjust(0, 0, -vscrollWidth, -hscrollHeight);
- }
- } else {
- QAccessibleInterface *iface = child(childIndex - 1);
- if (iface) {
- r = iface->rect(0);
- delete iface;
- }
- }
- return r;
- } else {
- QRect r = QAccessibleAbstractScrollArea::rect(childIndex);
- if (childIndex == 1) {
- // include the potential vertical and horizontal headers
-
- const QHeaderView *header = verticalHeader();
- int headerWidth = (header && header->isVisible()) ? header->width() : 0;
- header = horizontalHeader();
- int headerHeight= (header && header->isVisible()) ? header->height() : 0;
- if (itemView()->isRightToLeft()) {
- r.adjust(0, -headerHeight, headerWidth, 0);
- } else {
- r.adjust(-headerWidth, -headerHeight, 0, 0);
- }
- }
- return r;
- }
-}
-
-int QAccessibleItemView::childAt(int x, int y) const
-{
- if (atViewport()) {
- QPoint p(x, y);
- for (int i = childCount(); i >= 0; --i) {
- if (rect(i).contains(p))
- return i;
- }
- return -1;
- } else {
- return QAccessibleAbstractScrollArea::childAt(x, y);
- }
-}
-
-QAccessible::Role QAccessibleItemView::role(int child) const
-{
- if ((!atViewport() && child) || (atViewport() && child == 0)) {
- QAbstractItemView *view = itemView();
-#ifndef QT_NO_TABLEVIEW
- if (qobject_cast<QTableView *>(view))
- return Table;
-#endif
-#ifndef QT_NO_LISTVIEW
- if (qobject_cast<QListView *>(view))
- return List;
-#endif
- return Tree;
- }
- if (atViewport()) {
- if (child)
- return Row;
- }
-
- return QAccessibleAbstractScrollArea::role(child);
-}
-
-QAccessible::State QAccessibleItemView::state(int child) const
-{
- State st = Normal;
-
- if (itemView() == 0)
- return State(Unavailable);
-
- bool queryViewPort = (atViewport() && child == 0) || (!atViewport() && child == 1);
- if (queryViewPort) {
- if (itemView()->selectionMode() != QAbstractItemView::NoSelection) {
- st |= Selectable;
- st |= Focusable;
- }
- } else if (atViewport()) { // children of viewport
- if (horizontalHeader())
- --child;
- if (child) {
- QAccessibleItemRow item(itemView(), childIndex(child));
- st |= item.state(0);
- }
- } else if (!atViewport() && child != 1) {
- st = QAccessibleAbstractScrollArea::state(child);
- }
- return st;
-}
-
-bool QAccessibleItemView::isValid() const
-{
- if (atViewport())
- return QAccessibleWidget::isValid();
- else
- return QAccessibleAbstractScrollArea::isValid();
-}
-
-int QAccessibleItemView::navigate(RelationFlag relation, int index,
- QAccessibleInterface **iface) const
-{
- if (atViewport()) {
- if (relation == Ancestor && index == 1) {
- *iface = new QAccessibleItemView(itemView());
- return 0;
- } else if (relation == Child && index >= 1) {
- if (horizontalHeader()) {
- if (index == 1) {
- *iface = new QAccessibleItemRow(itemView(), QModelIndex(), true);
- return 0;
- }
- --index;
- }
-
- //###JAS hidden rows..
- QModelIndex idx = childIndex(index);
- if (idx.isValid()) {
- *iface = new QAccessibleItemRow(itemView(), idx);
- return 0;
- }
- } else if (relation == Sibling && index >= 1) {
- QAccessibleInterface *parent = new QAccessibleItemView(itemView());
- return parent->navigate(Child, index, iface);
- }
- *iface = 0;
- return -1;
- } else {
- return QAccessibleAbstractScrollArea::navigate(relation, index, iface);
- }
-}
-
-/* returns the model index for a given row and column */
-QModelIndex QAccessibleItemView::index(int row, int column) const
-{
- return itemView()->model()->index(row, column);
-}
-
-QAccessibleInterface *QAccessibleItemView::accessibleAt(int row, int column)
-{
- QWidget *indexWidget = itemView()->indexWidget(index(row, column));
- return QAccessible::queryAccessibleInterface(indexWidget);
-}
-
-/* We don't have a concept of a "caption" in Qt's standard widgets */
-QAccessibleInterface *QAccessibleItemView::caption()
-{
- return 0;
-}
-
-/* childIndex is row * columnCount + columnIndex */
-int QAccessibleItemView::childIndex(int rowIndex, int columnIndex)
-{
- return rowIndex * itemView()->model()->columnCount() + columnIndex;
-}
-
-/* Return the header data as column description */
-QString QAccessibleItemView::columnDescription(int column)
-{
- return itemView()->model()->headerData(column, Qt::Horizontal).toString();
-}
-
-/* We don't support column spanning atm */
-int QAccessibleItemView::columnSpan(int /* row */, int /* column */)
-{
- return 1;
-}
-
-/* Return the horizontal header view */
-QAccessibleInterface *QAccessibleItemView::columnHeader()
-{
-#ifndef QT_NO_TREEVIEW
- if (QTreeView *tree = qobject_cast<QTreeView *>(itemView()))
- return QAccessible::queryAccessibleInterface(tree->header());
-#endif
-#ifndef QT_NO_TABLEVIEW
- if (QTableView *table = qobject_cast<QTableView *>(itemView()))
- return QAccessible::queryAccessibleInterface(table->horizontalHeader());
-#endif
- return 0;
-}
-
-int QAccessibleItemView::columnIndex(int childIndex)
-{
- int columnCount = itemView()->model()->columnCount();
- if (!columnCount)
- return 0;
-
- return childIndex % columnCount;
-}
-
-int QAccessibleItemView::columnCount()
-{
- return itemView()->model()->columnCount();
-}
-
-int QAccessibleItemView::rowCount()
-{
- return itemView()->model()->rowCount();
-}
-
-int QAccessibleItemView::selectedColumnCount()
-{
- return itemView()->selectionModel()->selectedColumns().count();
-}
-
-int QAccessibleItemView::selectedRowCount()
-{
- return itemView()->selectionModel()->selectedRows().count();
-}
-
-QString QAccessibleItemView::rowDescription(int row)
-{
- return itemView()->model()->headerData(row, Qt::Vertical).toString();
-}
-
-/* We don't support row spanning */
-int QAccessibleItemView::rowSpan(int /*row*/, int /*column*/)
-{
- return 1;
-}
-
-QAccessibleInterface *QAccessibleItemView::rowHeader()
-{
-#ifndef QT_NO_TABLEVIEW
- if (QTableView *table = qobject_cast<QTableView *>(itemView()))
- return QAccessible::queryAccessibleInterface(table->verticalHeader());
-#endif
- return 0;
-}
-
-int QAccessibleItemView::rowIndex(int childIndex)
-{
- int columnCount = itemView()->model()->columnCount();
- if (!columnCount)
- return 0;
-
- return int(childIndex / columnCount);
-}
-
-int QAccessibleItemView::selectedRows(int maxRows, QList<int> *rows)
-{
- Q_ASSERT(rows);
-
- const QModelIndexList selRows = itemView()->selectionModel()->selectedRows();
- int maxCount = qMin(selRows.count(), maxRows);
-
- for (int i = 0; i < maxCount; ++i)
- rows->append(selRows.at(i).row());
-
- return maxCount;
-}
-
-int QAccessibleItemView::selectedColumns(int maxColumns, QList<int> *columns)
-{
- Q_ASSERT(columns);
-
- const QModelIndexList selColumns = itemView()->selectionModel()->selectedColumns();
- int maxCount = qMin(selColumns.count(), maxColumns);
-
- for (int i = 0; i < maxCount; ++i)
- columns->append(selColumns.at(i).row());
-
- return maxCount;
-}
-
-/* Qt widgets don't have a concept of a summary */
-QAccessibleInterface *QAccessibleItemView::summary()
-{
- return 0;
-}
-
-bool QAccessibleItemView::isColumnSelected(int column)
-{
- return itemView()->selectionModel()->isColumnSelected(column, QModelIndex());
-}
-
-bool QAccessibleItemView::isRowSelected(int row)
-{
- return itemView()->selectionModel()->isRowSelected(row, QModelIndex());
-}
-
-bool QAccessibleItemView::isSelected(int row, int column)
-{
- return itemView()->selectionModel()->isSelected(index(row, column));
-}
-
-void QAccessibleItemView::selectRow(int row)
-{
- QItemSelectionModel *s = itemView()->selectionModel();
- s->select(index(row, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
-}
-
-void QAccessibleItemView::selectColumn(int column)
-{
- QItemSelectionModel *s = itemView()->selectionModel();
- s->select(index(0, column), QItemSelectionModel::Select | QItemSelectionModel::Columns);
-}
-
-void QAccessibleItemView::unselectRow(int row)
-{
- QItemSelectionModel *s = itemView()->selectionModel();
- s->select(index(row, 0), QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
-}
-
-void QAccessibleItemView::unselectColumn(int column)
-{
- QItemSelectionModel *s = itemView()->selectionModel();
- s->select(index(0, column), QItemSelectionModel::Deselect | QItemSelectionModel::Columns);
-}
-
-void QAccessibleItemView::cellAtIndex(int index, int *row, int *column, int *rSpan,
- int *cSpan, bool *isSelect)
-{
- *row = rowIndex(index);
- *column = columnIndex(index);
- *rSpan = rowSpan(*row, *column);
- *cSpan = columnSpan(*row, *column);
- *isSelect = isSelected(*row, *column);
-}
-
-/*!
- \class QAccessibleHeader
- \brief The QAccessibleHeader class implements the QAccessibleInterface for header widgets.
- \internal
-
- \ingroup accessibility
-*/
-
-/*!
- Constructs a QAccessibleHeader object for \a w.
-*/
-QAccessibleHeader::QAccessibleHeader(QWidget *w)
-: QAccessibleWidget(w)
-{
- Q_ASSERT(header());
- addControllingSignal(QLatin1String("sectionClicked(int)"));
-}
-
-/*! Returns the QHeaderView. */
-QHeaderView *QAccessibleHeader::header() const
-{
- return qobject_cast<QHeaderView*>(object());
-}
-
-QRect QAccessibleHeader::rect(int child) const
-{
- if (!child)
- return QAccessibleWidget::rect(0);
-
- QHeaderView *h = header();
- QPoint zero = h->mapToGlobal(QPoint(0, 0));
- int sectionSize = h->sectionSize(child - 1);
- int sectionPos = h->sectionPosition(child - 1);
- return h->orientation() == Qt::Horizontal
- ? QRect(zero.x() + sectionPos, zero.y(), sectionSize, h->height())
- : QRect(zero.x(), zero.y() + sectionPos, h->width(), sectionSize);
-}
-
-int QAccessibleHeader::childCount() const
-{
- return header()->count();
-}
-
-QString QAccessibleHeader::text(QAccessible::Text t, int child) const
-{
- QString str;
-
- if (child > 0 && child <= childCount()) {
- switch (t) {
- case Name:
- str = header()->model()->headerData(child - 1, header()->orientation()).toString();
- break;
- case Description: {
- QAccessibleEvent event(QEvent::AccessibilityDescription, child);
- if (QApplication::sendEvent(widget(), &event))
- str = event.value();
- break; }
- case Help: {
- QAccessibleEvent event(QEvent::AccessibilityHelp, child);
- if (QApplication::sendEvent(widget(), &event))
- str = event.value();
- break; }
- default:
- break;
- }
- }
- if (str.isEmpty())
- str = QAccessibleWidget::text(t, child);
- return str;
-}
-
-QAccessible::Role QAccessibleHeader::role(int) const
-{
- return (header()->orientation() == Qt::Horizontal) ? ColumnHeader : RowHeader;
-}
-
-QAccessible::State QAccessibleHeader::state(int child) const
-{
- State state = QAccessibleWidget::state(child);
-
- if (child) {
- int section = child - 1;
- if (header()->isSectionHidden(section))
- state |= Invisible;
- if (header()->resizeMode(section) != QHeaderView::Custom)
- state |= Sizeable;
- } else {
- if (header()->isMovable())
- state |= Movable;
- }
- if (!header()->isClickable())
- state |= Unavailable;
- return state;
-}
-#endif // QT_NO_ITEMVIEWS
-#endif // 0
-
#ifndef QT_NO_TABBAR
/*!
\class QAccessibleTabBar
@@ -1483,7 +111,7 @@ public:
bool isValid() const { return true; }// (!m_parent.isNull()) && m_parent->count() > m_index; }
- int childAt(int, int) const { return 0; }
+ QAccessibleInterface *childAt(int, int) const { return 0; }
int childCount() const { return 0; }
int indexOfChild(const QAccessibleInterface *) const { return -1; }
@@ -1496,17 +124,11 @@ public:
QAccessibleInterface *child(int) const { return 0; }
int navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const
{
- if (relation == QAccessible::Ancestor && index == 1) {
- *iface = parent();
- return 0;
- }
+ Q_UNUSED(relation);
+ Q_UNUSED(index);
+ Q_UNUSED(iface);
return -1;
}
- QAccessible::Relation relationTo(const QAccessibleInterface *) const
- {
- return QAccessible::Unrelated;
- }
-
// action interface
QStringList actionNames() const
{
@@ -1544,18 +166,6 @@ QTabBar *QAccessibleTabBar::tabBar() const
return qobject_cast<QTabBar*>(object());
}
-int QAccessibleTabBar::navigate(QAccessible::RelationFlag rel, int entry, QAccessibleInterface **target) const
-{
- if (rel == QAccessible::Child) {
- *target = child(entry - 1);
- if (*target) {
- return 0;
- }
- return -1;
- }
- return QAccessibleWidget::navigate(rel, entry, target);
-}
-
QAccessibleInterface* QAccessibleTabBar::child(int index) const
{
// first the tabs, then 2 buttons
@@ -1577,11 +187,13 @@ QAccessibleInterface* QAccessibleTabBar::child(int index) const
int QAccessibleTabBar::indexOfChild(const QAccessibleInterface *child) const
{
+ // FIXME this looks broken
+
if (child->object() && child->object() == tabBar()->d_func()->leftB)
- return tabBar()->count() + 1; // fixme - one based
+ return tabBar()->count();
if (child->object() && child->object() == tabBar()->d_func()->rightB)
- return tabBar()->count() + 2; // fixme - one based
- return 0;
+ return tabBar()->count() + 1;
+ return -1;
}
int QAccessibleTabBar::childCount() const
@@ -1661,7 +273,7 @@ QComboBox *QAccessibleComboBox::comboBox() const
return qobject_cast<QComboBox*>(object());
}
-QAccessibleInterface* QAccessibleComboBox::child(int index) const
+QAccessibleInterface *QAccessibleComboBox::child(int index) const
{
if (index == 0) {
QAbstractItemView *view = comboBox()->view();
@@ -1679,10 +291,10 @@ int QAccessibleComboBox::childCount() const
return comboBox()->isEditable() ? 2 : 1;
}
-int QAccessibleComboBox::childAt(int x, int y) const
+QAccessibleInterface *QAccessibleComboBox::childAt(int x, int y) const
{
if (comboBox()->isEditable() && comboBox()->lineEdit()->rect().contains(x, y))
- return 1;
+ return child(1);
return 0;
}
@@ -1775,11 +387,6 @@ QAccessibleAbstractScrollArea::QAccessibleAbstractScrollArea(QWidget *widget)
Q_ASSERT(qobject_cast<QAbstractScrollArea *>(widget));
}
-QVariant QAccessibleAbstractScrollArea::invokeMethod(QAccessible::Method, int, const QVariantList &)
-{
- return QVariant();
-}
-
QAccessibleInterface *QAccessibleAbstractScrollArea::child(int index) const
{
return QAccessible::queryAccessibleInterface(accessibleChildren().at(index));
@@ -1794,10 +401,7 @@ int QAccessibleAbstractScrollArea::indexOfChild(const QAccessibleInterface *chil
{
if (!child || !child->object())
return -1;
- int index = accessibleChildren().indexOf(qobject_cast<QWidget *>(child->object()));
- if (index >= 0)
- return ++index;
- return -1;
+ return accessibleChildren().indexOf(qobject_cast<QWidget *>(child->object()));
}
bool QAccessibleAbstractScrollArea::isValid() const
@@ -1805,152 +409,20 @@ bool QAccessibleAbstractScrollArea::isValid() const
return (QAccessibleWidget::isValid() && abstractScrollArea() && abstractScrollArea()->viewport());
}
-int QAccessibleAbstractScrollArea::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
+QAccessibleInterface *QAccessibleAbstractScrollArea::childAt(int x, int y) const
{
- if (!target)
- return -1;
-
- *target = 0;
-
- QWidget *targetWidget = 0;
- QWidget *entryWidget = 0;
-
- if (relation == QAccessible::Child ||
- relation == QAccessible::Left || relation == QAccessible::Up || relation == QAccessible::Right || relation == QAccessible::Down) {
- QWidgetList children = accessibleChildren();
- if (entry < 0 || entry > children.count())
- return -1;
+ if (!abstractScrollArea()->isVisible())
+ return 0;
- if (entry == Self)
- entryWidget = abstractScrollArea();
- else
- entryWidget = children.at(entry - 1);
- AbstractScrollAreaElement entryElement = elementType(entryWidget);
-
- // Not one of the most beautiful switches I've ever seen, but I believe it has
- // to be like this since each case need special handling.
- // It might be possible to make it more general, but I'll leave that as an exercise
- // to the reader. :-)
- switch (relation) {
- case QAccessible::Child:
- if (entry > 0) {
- *target = child(entry - 1);
- return *target ? 0 : -1;
- }
- case QAccessible::Left:
- if (entry < 1)
- break;
- switch (entryElement) {
- case Viewport:
- if (!isLeftToRight())
- targetWidget = abstractScrollArea()->verticalScrollBar();
- break;
- case HorizontalContainer:
- if (!isLeftToRight())
- targetWidget = abstractScrollArea()->cornerWidget();
- break;
- case VerticalContainer:
- if (isLeftToRight())
- targetWidget = abstractScrollArea()->viewport();
- break;
- case CornerWidget:
- if (isLeftToRight())
- targetWidget = abstractScrollArea()->horizontalScrollBar();
- break;
- default:
- break;
- }
- break;
- case QAccessible::Right:
- if (entry < 1)
- break;
- switch (entryElement) {
- case Viewport:
- if (isLeftToRight())
- targetWidget = abstractScrollArea()->verticalScrollBar();
- break;
- case HorizontalContainer:
- targetWidget = abstractScrollArea()->cornerWidget();
- break;
- case VerticalContainer:
- if (!isLeftToRight())
- targetWidget = abstractScrollArea()->viewport();
- break;
- case CornerWidget:
- if (!isLeftToRight())
- targetWidget = abstractScrollArea()->horizontalScrollBar();
- break;
- default:
- break;
- }
- break;
- case QAccessible::Up:
- if (entry < 1)
- break;
- switch (entryElement) {
- case HorizontalContainer:
- targetWidget = abstractScrollArea()->viewport();
- break;
- case CornerWidget:
- targetWidget = abstractScrollArea()->verticalScrollBar();
- break;
- default:
- break;
- }
- break;
- case QAccessible::Down:
- if (entry < 1)
- break;
- switch (entryElement) {
- case Viewport:
- targetWidget = abstractScrollArea()->horizontalScrollBar();
- break;
- case VerticalContainer:
- targetWidget = abstractScrollArea()->cornerWidget();
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- } else {
- return QAccessibleWidget::navigate(relation, entry, target);
+ for (int i = 0; i < childCount(); ++i) {
+ QPoint wpos = accessibleChildren().at(i)->mapToGlobal(QPoint(0, 0));
+ QRect rect = QRect(wpos, accessibleChildren().at(i)->size());
+ if (rect.contains(x, y))
+ return child(i);
}
-
- if (qobject_cast<const QScrollBar *>(targetWidget))
- targetWidget = targetWidget->parentWidget();
- *target = QAccessible::queryAccessibleInterface(targetWidget);
- return *target ? 0: -1;
+ return 0;
}
-//int QAccessibleAbstractScrollArea::childAt(int x, int y) const
-//{
-// if (!abstractScrollArea()->isVisible())
-// return -1;
-//#if 0
-// const QRect globalSelfGeometry = rect(Self);
-// if (!globalSelfGeometry.isValid() || !globalSelfGeometry.contains(QPoint(x, y)))
-// return -1;
-// const QWidgetList children = accessibleChildren();
-// for (int i = 0; i < children.count(); ++i) {
-// const QWidget *child = children.at(i);
-// const QRect globalChildGeometry = QRect(child->mapToGlobal(QPoint(0, 0)), child->size());
-// if (globalChildGeometry.contains(QPoint(x, y))) {
-// return ++i;
-// }
-// }
-// return 0;
-//#else
-// for (int i = childCount(); i >= 0; --i) {
-// if (rect().contains(x, y))
-// return i;
-// }
-// return -1;
-//#endif
-//}
-
QAbstractScrollArea *QAccessibleAbstractScrollArea::abstractScrollArea() const
{
return static_cast<QAbstractScrollArea *>(object());
diff --git a/src/plugins/accessible/widgets/complexwidgets.h b/src/plugins/accessible/widgets/complexwidgets.h
index 2dde422b12..c596e0b348 100644
--- a/src/plugins/accessible/widgets/complexwidgets.h
+++ b/src/plugins/accessible/widgets/complexwidgets.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -75,12 +75,10 @@ public:
};
QAccessibleInterface *child(int index) const;
- QVariant invokeMethod(QAccessible::Method method, int, const QVariantList &params);
int childCount() const;
int indexOfChild(const QAccessibleInterface *child) const;
bool isValid() const;
- int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
-// int childAt(int x, int y) const;
+ QAccessibleInterface *childAt(int x, int y) const;
//protected:
QAbstractScrollArea *abstractScrollArea() const;
@@ -96,137 +94,8 @@ class QAccessibleScrollArea : public QAccessibleAbstractScrollArea
public:
explicit QAccessibleScrollArea(QWidget *widget);
};
-
#endif // QT_NO_SCROLLAREA
-#if 0
-#ifndef QT_NO_ITEMVIEWS
-class QAccessibleHeader : public QAccessibleWidget
-{
-public:
- explicit QAccessibleHeader(QWidget *w);
-
- int childCount() const;
-
- QRect rect(int child) const;
- QString text(QAccessible::Text t, int child) const;
- Role role(int child) const;
- State state(int child) const;
-
-protected:
- QHeaderView *header() const;
-};
-
-class QAccessibleItemRow: public QAccessibleInterface
-{
- friend class QAccessibleItemView;
-public:
- QAccessibleItemRow(QAbstractItemView *view, const QModelIndex &index = QModelIndex(), bool isHeader = false);
- QRect rect(int child) const;
- QString text(QAccessible::Text t, int child) const;
- void setText(QAccessible::Text t, int child, const QString &text);
- bool isValid() const;
- QObject *object() const;
- Role role(int child) const;
- State state(int child) const;
-
- int childCount() const;
- int indexOfChild(const QAccessibleInterface *) const;
- QList<QModelIndex> children() const;
-
- Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
- int childAt(int x, int y) const;
- QAccessibleInterface *parent() const;
- QAccessibleInterface *child(int index) const;
- int navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const;
-
- int userActionCount(int child) const;
- QString actionText(int action, Text t, int child) const;
- bool doAction(int action, int child, const QVariantList &params = QVariantList());
-
- QModelIndex childIndex(int child) const;
-
- QHeaderView *horizontalHeader() const; //used by QAccessibleItemView
-private:
- static QAbstractItemView::CursorAction toCursorAction(Relation rel);
- int logicalFromChild(QHeaderView *header, int child) const;
- int treeLevel() const;
- QHeaderView *verticalHeader() const;
- QString text_helper(int child) const;
-
- QPersistentModelIndex row;
- QPointer<QAbstractItemView> view;
- bool m_header;
-};
-
-class QAccessibleItemView: public QAccessibleAbstractScrollArea, public QAccessibleTableInterface
-{
-public:
- explicit QAccessibleItemView(QWidget *w);
-
- QObject *object() const;
- Role role(int child) const;
- State state(int child) const;
- QRect rect(int child) const;
- int childAt(int x, int y) const;
- int childCount() const;
- QString text(QAccessible::Text t, int child) const;
- void setText(QAccessible::Text t, int child, const QString &text);
- int indexOfChild(const QAccessibleInterface *iface) const;
-
- QModelIndex childIndex(int child) const;
- int entryFromIndex(const QModelIndex &index) const;
- bool isValid() const;
- int navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const;
-
- QAccessibleInterface *accessibleAt(int row, int column);
- QAccessibleInterface *caption();
- int childIndex(int rowIndex, int columnIndex);
- QString columnDescription(int column);
- int columnSpan(int row, int column);
- QAccessibleInterface *columnHeader();
- int columnIndex(int childIndex);
- int columnCount();
- int rowCount();
- int selectedColumnCount();
- int selectedRowCount();
- QString rowDescription(int row);
- int rowSpan(int row, int column);
- QAccessibleInterface *rowHeader();
- int rowIndex(int childIndex);
- int selectedRows(int maxRows, QList<int> *rows);
- int selectedColumns(int maxColumns, QList<int> *columns);
- QAccessibleInterface *summary();
- bool isColumnSelected(int column);
- bool isRowSelected(int row);
- bool isSelected(int row, int column);
- void selectRow(int row);
- void selectColumn(int column);
- void unselectRow(int row);
- void unselectColumn(int column);
- void cellAtIndex(int index, int *row, int *column, int *rowSpan,
- int *columnSpan, bool *isSelected);
-
- QHeaderView *horizontalHeader() const;
- QHeaderView *verticalHeader() const;
- bool isValidChildRole(QAccessible::Role role) const;
-
-protected:
- QAbstractItemView *itemView() const;
- QModelIndex index(int row, int column) const;
-
-private:
- inline bool atViewport() const {
- return atVP;
- };
- QAccessible::Role expectedRoleOfChildren() const;
-
- bool atVP;
-};
-
-#endif
-#endif
-
#ifndef QT_NO_TABBAR
class QAccessibleTabBar : public QAccessibleWidget
{
@@ -241,7 +110,6 @@ public:
QAccessibleInterface* child(int index) const;
int indexOfChild(const QAccessibleInterface *child) const;
- int navigate(QAccessible::RelationFlag rel, int entry, QAccessibleInterface **target) const;
protected:
QTabBar *tabBar() const;
@@ -255,7 +123,7 @@ public:
explicit QAccessibleComboBox(QWidget *w);
int childCount() const;
- int childAt(int x, int y) const;
+ QAccessibleInterface *childAt(int x, int y) const;
int indexOfChild(const QAccessibleInterface *child) const;
QAccessibleInterface* child(int index) const;
diff --git a/src/plugins/accessible/widgets/itemviews.cpp b/src/plugins/accessible/widgets/itemviews.cpp
index b33260099f..a7989ccd4e 100644
--- a/src/plugins/accessible/widgets/itemviews.cpp
+++ b/src/plugins/accessible/widgets/itemviews.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -363,10 +363,10 @@ QAccessible::Role QAccessibleTable::role() const
QAccessible::State QAccessibleTable::state() const
{
- return QAccessible::Normal;
+ return QAccessible::State();
}
-int QAccessibleTable::childAt(int x, int y) const
+QAccessibleInterface *QAccessibleTable::childAt(int x, int y) const
{
QPoint viewportOffset = view->viewport()->mapTo(view, QPoint(0,0));
QPoint indexPosition = view->mapFromGlobal(QPoint(x, y) - viewportOffset);
@@ -374,9 +374,9 @@ int QAccessibleTable::childAt(int x, int y) const
QModelIndex index = view->indexAt(indexPosition);
if (index.isValid()) {
- return logicalIndex(index);
+ return childFromLogical(logicalIndex(index));
}
- return -1;
+ return 0;
}
int QAccessibleTable::childCount() const
@@ -393,15 +393,15 @@ int QAccessibleTable::indexOfChild(const QAccessibleInterface *iface) const
Q_ASSERT(iface->role() != QAccessible::TreeItem); // should be handled by tree class
if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) {
const QAccessibleTableCell* cell = static_cast<const QAccessibleTableCell*>(iface);
- return logicalIndex(cell->m_index);
+ return logicalIndex(cell->m_index) - 1;
} else if (iface->role() == QAccessible::ColumnHeader){
const QAccessibleTableHeaderCell* cell = static_cast<const QAccessibleTableHeaderCell*>(iface);
- return cell->index + (verticalHeader() ? 1 : 0) + 1;
+ return cell->index + (verticalHeader() ? 1 : 0);
} else if (iface->role() == QAccessible::RowHeader){
const QAccessibleTableHeaderCell* cell = static_cast<const QAccessibleTableHeaderCell*>(iface);
- return (cell->index+1) * (view->model()->rowCount()+1) + 1;
+ return (cell->index+1) * (view->model()->rowCount()+1);
} else if (iface->role() == QAccessible::Pane) {
- return 1; // corner button
+ return 0; // corner button
} else {
qWarning() << "WARNING QAccessibleTable::indexOfChild Fix my children..."
<< iface->role() << iface->text(QAccessible::Name);
@@ -444,31 +444,12 @@ QAccessibleInterface *QAccessibleTable::child(int index) const
int QAccessibleTable::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const
{
+ Q_UNUSED(relation);
+ Q_UNUSED(index);
*iface = 0;
- switch (relation) {
- case QAccessible::Ancestor: {
- *iface = parent();
- return *iface ? 0 : -1;
- }
- case QAccessible::Child: {
- Q_ASSERT(index > 0);
- *iface = child(index - 1);
- if (*iface) {
- return 0;
- }
- break;
- }
- default:
- break;
- }
return -1;
}
-QAccessible::Relation QAccessibleTable::relationTo(const QAccessibleInterface *) const
-{
- return QAccessible::Unrelated;
-}
-
void *QAccessibleTable::interface_cast(QAccessible::InterfaceType t)
{
if (t == QAccessible::TableInterface)
@@ -489,14 +470,14 @@ QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const
return modelIndex;
}
-int QAccessibleTree::childAt(int x, int y) const
+QAccessibleInterface *QAccessibleTree::childAt(int x, int y) const
{
QPoint viewportOffset = view->viewport()->mapTo(view, QPoint(0,0));
QPoint indexPosition = view->mapFromGlobal(QPoint(x, y) - viewportOffset);
QModelIndex index = view->indexAt(indexPosition);
if (!index.isValid())
- return -1;
+ return 0;
const QTreeView *treeView = qobject_cast<const QTreeView*>(view);
int row = treeView->d_func()->viewIndex(index) + (horizontalHeader() ? 1 : 0);
@@ -504,7 +485,7 @@ int QAccessibleTree::childAt(int x, int y) const
int i = row * view->model()->columnCount() + column + 1;
Q_ASSERT(i > view->model()->columnCount());
- return i;
+ return child(i - 1);
}
int QAccessibleTree::childCount() const
@@ -518,6 +499,29 @@ int QAccessibleTree::childCount() const
return (treeView->d_func()->viewItems.count() + hHeader)* view->model()->columnCount();
}
+
+QAccessibleInterface *QAccessibleTree::child(int index) const
+{
+ Q_ASSERT(index >= 0);
+ int hHeader = horizontalHeader() ? 1 : 0;
+
+ if (hHeader) {
+ if (index < view->model()->columnCount()) {
+ return new QAccessibleTableHeaderCell(view, index, Qt::Horizontal);
+ } else {
+ index -= view->model()->columnCount();
+ }
+ }
+
+ int row = index / view->model()->columnCount();
+ int column = index % view->model()->columnCount();
+ QModelIndex modelIndex = indexFromLogical(row, column);
+ if (modelIndex.isValid()) {
+ return cell(modelIndex);
+ }
+ return 0;
+}
+
int QAccessibleTree::rowCount() const
{
const QTreeView *treeView = qobject_cast<const QTreeView*>(view);
@@ -534,14 +538,14 @@ int QAccessibleTree::indexOfChild(const QAccessibleInterface *iface) const
int row = treeView->d_func()->viewIndex(cell->m_index) + (horizontalHeader() ? 1 : 0);
int column = cell->m_index.column();
- int index = row * view->model()->columnCount() + column + 1;
+ int index = row * view->model()->columnCount() + column;
//qDebug() << "QAccessibleTree::indexOfChild r " << row << " c " << column << "index " << index;
- Q_ASSERT(index > treeView->model()->columnCount());
+ Q_ASSERT(index >= treeView->model()->columnCount());
return index;
} else if (iface->role() == QAccessible::ColumnHeader){
const QAccessibleTableHeaderCell* cell = static_cast<const QAccessibleTableHeaderCell*>(iface);
//qDebug() << "QAccessibleTree::indexOfChild header " << cell->index << "is: " << cell->index + 1;
- return cell->index + 1;
+ return cell->index;
} else {
qWarning() << "WARNING QAccessibleTable::indexOfChild invalid child"
<< iface->role() << iface->text(QAccessible::Name);
@@ -550,43 +554,6 @@ int QAccessibleTree::indexOfChild(const QAccessibleInterface *iface) const
return -1;
}
-int QAccessibleTree::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const
-{
- switch (relation) {
- case QAccessible::Child: {
- Q_ASSERT(index > 0);
- --index;
- int hHeader = horizontalHeader() ? 1 : 0;
-
- if (hHeader) {
- if (index < view->model()->columnCount()) {
- *iface = new QAccessibleTableHeaderCell(view, index, Qt::Horizontal);
- return 0;
- } else {
- index -= view->model()->columnCount();
- }
- }
-
- int row = index / view->model()->columnCount();
- int column = index % view->model()->columnCount();
- QModelIndex modelIndex = indexFromLogical(row, column);
- if (modelIndex.isValid()) {
- *iface = cell(modelIndex);
- return 0;
- }
- return -1;
- }
- default:
- break;
- }
- return QAccessibleTable::navigate(relation, index, iface);
-}
-
-QAccessible::Relation QAccessibleTree::relationTo(const QAccessibleInterface *) const
-{
- return QAccessible::Unrelated;
-}
-
QAccessibleInterface *QAccessibleTree::cellAt(int row, int column) const
{
QModelIndex index = indexFromLogical(row, column);
@@ -724,34 +691,34 @@ QAccessible::Role QAccessibleTableCell::role() const
QAccessible::State QAccessibleTableCell::state() const
{
- QAccessible::State st = QAccessible::Normal;
+ QAccessible::State st;
QRect globalRect = view->rect();
globalRect.translate(view->mapToGlobal(QPoint(0,0)));
if (!globalRect.intersects(rect()))
- st |= QAccessible::Invisible;
+ st.invisible = true;
if (view->selectionModel()->isSelected(m_index))
- st |= QAccessible::Selected;
+ st.selected = true;
if (view->selectionModel()->currentIndex() == m_index)
- st |= QAccessible::Focused;
+ st.focused = true;
if (m_index.model()->data(m_index, Qt::CheckStateRole).toInt() == Qt::Checked)
- st |= QAccessible::Checked;
+ st.checked = true;
Qt::ItemFlags flags = m_index.flags();
if (flags & Qt::ItemIsSelectable) {
- st |= QAccessible::Selectable;
- st |= QAccessible::Focusable;
+ st.selectable = true;
+ st.focusable = true;
if (view->selectionMode() == QAbstractItemView::MultiSelection)
- st |= QAccessible::MultiSelectable;
+ st.multiSelectable = true;
if (view->selectionMode() == QAbstractItemView::ExtendedSelection)
- st |= QAccessible::ExtSelectable;
+ st.extSelectable = true;
}
if (m_role == QAccessible::TreeItem) {
const QTreeView *treeView = qobject_cast<const QTreeView*>(view);
if (treeView->model()->hasChildren(m_index))
- st |= QAccessible::Expandable;
+ st.expandable = true;
if (treeView->isExpanded(m_index))
- st |= QAccessible::Expanded;
+ st.expanded = true;
}
return st;
}
@@ -815,29 +782,10 @@ QAccessibleInterface *QAccessibleTableCell::child(int) const
int QAccessibleTableCell::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const
{
- if (relation == QAccessible::Ancestor && index == 1) {
- *iface = parent();
- return 0;
- }
-
- *iface = 0;
- if (!view)
- return -1;
-
- switch (relation) {
-
- case QAccessible::Child: {
- return -1;
- }
- case QAccessible::Sibling:
- if (index > 0) {
- QAccessibleInterface *parent = QAccessible::queryAccessibleInterface(view);
- *iface = parent->child(index - 1);
- delete parent;
- return *iface ? 0 : -1;
- }
- return -1;
+ Q_UNUSED(index);
+ Q_UNUSED(relation);
+// switch (relation) {
// From table1 implementation:
// case Up:
// case Down:
@@ -862,28 +810,11 @@ int QAccessibleTableCell::navigate(QAccessible::RelationFlag relation, int index
// if (idx.parent() != row.parent() || idx.row() != row.row())
// *iface = cell(idx);
// return index ? kids.indexOf(idx) + 1 : 0; }
- default:
- break;
- }
-
+// }
+ *iface = 0;
return -1;
}
-QAccessible::Relation QAccessibleTableCell::relationTo(const QAccessibleInterface *other) const
-{
- // we only check for parent-child relationships in trees
- if (m_role == QAccessible::TreeItem && other->role() == QAccessible::TreeItem) {
- QModelIndex otherIndex = static_cast<const QAccessibleTableCell*>(other)->m_index;
- // is the other our parent?
- if (otherIndex.parent() == m_index)
- return QAccessible::Ancestor;
- // are we the other's child?
- if (m_index.parent() == otherIndex)
- return QAccessible::Child;
- }
- return QAccessible::Unrelated;
-}
-
QAccessibleTableHeaderCell::QAccessibleTableHeaderCell(QAbstractItemView *view_, int index_, Qt::Orientation orientation_)
: view(view_), index(index_), orientation(orientation_)
{
@@ -899,7 +830,7 @@ QAccessible::Role QAccessibleTableHeaderCell::role() const
QAccessible::State QAccessibleTableHeaderCell::state() const
{
- return QAccessible::Normal;
+ return QAccessible::State();
}
QRect QAccessibleTableHeaderCell::rect() const
@@ -976,17 +907,11 @@ QAccessibleInterface *QAccessibleTableHeaderCell::child(int) const
int QAccessibleTableHeaderCell::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const
{
- if (relation == QAccessible::Ancestor && index == 1) {
- *iface = parent();
- return *iface ? 0 : -1;
- }
- *iface = 0;
- return -1;
-}
+ Q_UNUSED(relation);
+ Q_UNUSED(index);
+ Q_UNUSED(iface);
-QAccessible::Relation QAccessibleTableHeaderCell::relationTo(int, const QAccessibleInterface *, int) const
-{
- return QAccessible::Unrelated;
+ return -1;
}
#endif // QT_NO_ITEMVIEWS
diff --git a/src/plugins/accessible/widgets/itemviews.h b/src/plugins/accessible/widgets/itemviews.h
index 08e0bbb487..4b5112350f 100644
--- a/src/plugins/accessible/widgets/itemviews.h
+++ b/src/plugins/accessible/widgets/itemviews.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -71,16 +71,14 @@ public:
QString text(QAccessible::Text t) const;
QRect rect() const;
- int childAt(int x, int y) const;
+ QAccessibleInterface *childAt(int x, int y) const;
int childCount() const;
int indexOfChild(const QAccessibleInterface *) const;
QAccessibleInterface *parent() const;
QAccessibleInterface *child(int index) const;
int navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const;
- QAccessible::Relation relationTo(const QAccessibleInterface *other) const;
- QVariant invokeMethod(QAccessible::Method, const QVariantList &) { return QVariant(); }
void *interface_cast(QAccessible::InterfaceType t);
// table interface
@@ -153,15 +151,14 @@ public:
virtual ~QAccessibleTree() {}
- int childAt(int x, int y) const;
+ QAccessibleInterface *childAt(int x, int y) const;
int childCount() const;
+ QAccessibleInterface *child(int index) const;
+
int indexOfChild(const QAccessibleInterface *) const;
int rowCount() const;
- int navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const;
- QAccessible::Relation relationTo(const QAccessibleInterface *other) const;
-
// table interface
QAccessibleInterface *cellAt(int row, int column) const;
QString rowDescription(int row) const;
@@ -184,7 +181,7 @@ public:
QRect rect() const;
bool isValid() const;
- int childAt(int, int) const { return 0; }
+ QAccessibleInterface *childAt(int, int) const { return 0; }
int childCount() const { return 0; }
int indexOfChild(const QAccessibleInterface *) const { return -1; }
@@ -194,7 +191,6 @@ public:
QAccessibleInterface *parent() const;
QAccessibleInterface *child(int) const;
int navigate(QAccessible::RelationFlag relation, int m_index, QAccessibleInterface **iface) const;
- QAccessible::Relation relationTo(const QAccessibleInterface *other) const;
// cell interface
virtual int columnExtent() const;
@@ -231,7 +227,7 @@ public:
QRect rect() const;
bool isValid() const;
- int childAt(int, int) const { return 0; }
+ QAccessibleInterface *childAt(int, int) const { return 0; }
int childCount() const { return 0; }
int indexOfChild(const QAccessibleInterface *) const { return -1; }
@@ -241,7 +237,6 @@ public:
QAccessibleInterface *parent() const;
QAccessibleInterface *child(int index) const;
int navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const;
- QAccessible::Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
private:
QAbstractItemView *view;
@@ -264,11 +259,11 @@ public:
QObject *object() const { return 0; }
QAccessible::Role role() const { return QAccessible::Pane; }
- QAccessible::State state() const { return QAccessible::Normal; }
+ QAccessible::State state() const { return QAccessible::State(); }
QRect rect() const { return QRect(); }
bool isValid() const { return true; }
- int childAt(int, int) const { return 0; }
+ QAccessibleInterface *childAt(int, int) const { return 0; }
int childCount() const { return 0; }
int indexOfChild(const QAccessibleInterface *) const { return -1; }
@@ -283,16 +278,10 @@ public:
}
int navigate(QAccessible::RelationFlag relation, int, QAccessibleInterface **iface) const
{
- if (relation == QAccessible::Ancestor) {
- *iface = parent();
- return *iface ? 0 : -1;
- }
+ Q_UNUSED(relation);
+ Q_UNUSED(iface);
return -1;
}
- QAccessible::Relation relationTo(int, const QAccessibleInterface *, int) const
- {
- return QAccessible::Unrelated;
- }
private:
QAbstractItemView *view;
diff --git a/src/plugins/accessible/widgets/main.cpp b/src/plugins/accessible/widgets/main.cpp
index 821b219b36..67e1a46703 100644
--- a/src/plugins/accessible/widgets/main.cpp
+++ b/src/plugins/accessible/widgets/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.cpp b/src/plugins/accessible/widgets/qaccessiblemenu.cpp
index 2fe67fedfe..fcd118e745 100644
--- a/src/plugins/accessible/widgets/qaccessiblemenu.cpp
+++ b/src/plugins/accessible/widgets/qaccessiblemenu.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -71,12 +71,12 @@ int QAccessibleMenu::childCount() const
return menu()->actions().count();
}
-int QAccessibleMenu::childAt(int x, int y) const
+QAccessibleInterface *QAccessibleMenu::childAt(int x, int y) const
{
QAction *act = menu()->actionAt(menu()->mapFromGlobal(QPoint(x,y)));
if(act && act->isSeparator())
act = 0;
- return menu()->actions().indexOf(act) + 1;
+ return act ? new QAccessibleMenuItem(menu(), act) : 0;
}
QString QAccessibleMenu::text(QAccessible::Text t) const
@@ -111,31 +111,13 @@ QAccessibleInterface *QAccessibleMenu::parent() const
return QAccessibleWidget::parent();
}
-int QAccessibleMenu::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
-{
- Q_ASSERT(entry >= 0);
- switch (relation) {
- case QAccessible::Child:
- *target = child(entry - 1);
- return *target ? 0 : -1;
- case QAccessible::Ancestor:
- *target = parent();
- return *target ? 0 : -1;
- default:
- return QAccessibleWidget::navigate(relation, entry, target);
- }
-}
-
int QAccessibleMenu::indexOfChild( const QAccessibleInterface *child) const
{
- int index = -1;
QAccessible::Role r = child->role();
if ((r == QAccessible::MenuItem || r == QAccessible::Separator) && menu()) {
- index = menu()->actions().indexOf(qobject_cast<QAction*>(child->object()));
- if (index != -1)
- ++index;
+ return menu()->actions().indexOf(qobject_cast<QAction*>(child->object()));
}
- return index;
+ return -1;
}
#ifndef QT_NO_MENUBAR
@@ -162,25 +144,13 @@ QAccessibleInterface *QAccessibleMenuBar::child(int index) const
return 0;
}
-int QAccessibleMenuBar::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
-{
- if (relation == QAccessible::Child) {
- *target = child(entry - 1);
- return *target ? 0 : -1;
- }
- return QAccessibleWidget::navigate(relation, entry, target);
-}
-
int QAccessibleMenuBar::indexOfChild(const QAccessibleInterface *child) const
{
- int index = -1;
QAccessible::Role r = child->role();
if ((r == QAccessible::MenuItem || r == QAccessible::Separator) && menuBar()) {
- index = menuBar()->actions().indexOf(qobject_cast<QAction*>(child->object()));
- if (index != -1)
- ++index;
+ return menuBar()->actions().indexOf(qobject_cast<QAction*>(child->object()));
}
- return index;
+ return -1;
}
#endif // QT_NO_MENUBAR
@@ -193,17 +163,16 @@ QAccessibleMenuItem::QAccessibleMenuItem(QWidget *owner, QAction *action)
QAccessibleMenuItem::~QAccessibleMenuItem()
{}
-int QAccessibleMenuItem::childAt(int x, int y ) const
+QAccessibleInterface *QAccessibleMenuItem::childAt(int x, int y ) const
{
for (int i = childCount(); i >= 0; --i) {
QAccessibleInterface *childInterface = child(i);
if (childInterface->rect().contains(x,y)) {
- delete childInterface;
- return i;
+ return childInterface;
}
delete childInterface;
}
- return -1;
+ return 0;
}
int QAccessibleMenuItem::childCount() const
@@ -213,10 +182,8 @@ int QAccessibleMenuItem::childCount() const
int QAccessibleMenuItem::indexOfChild(const QAccessibleInterface * child) const
{
- Q_ASSERT(child == 0);
- if (child->role() == QAccessible::PopupMenu && child->object() == m_action->menu())
- return 1;
-
+ if (child && child->role() == QAccessible::PopupMenu && child->object() == m_action->menu())
+ return 0;
return -1;
}
@@ -239,43 +206,10 @@ QAccessibleInterface *QAccessibleMenuItem::child(int index) const
int QAccessibleMenuItem::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
{
+ Q_UNUSED(relation);
+ Q_UNUSED(entry);
*target = 0;
- if (entry < 0) {
- return -1;
- }
-
- switch (relation) {
- case QAccessible::Child:
- *target = child(entry - 1);
- break;
- case QAccessible::Ancestor:
- *target = parent();
- break;
- case QAccessible::Up:
- case QAccessible::Down:{
- QAccessibleInterface *parentIface = parent();
- if (parentIface) {
- int index = parentIface->indexOfChild(this);
- if (index != -1) {
- index += (relation == QAccessible::Down ? +1 : -1);
- *target = parentIface->child(index - 1);
- }
- }
- delete parentIface;
- break;
- }
- case QAccessible::Sibling: {
- QAccessibleInterface *parentIface = parent();
- if (parentIface)
- *target = parentIface->child(entry - 1);
- delete parentIface;
- break;
- }
- default:
- break;
-
- }
- return *target ? 0 : -1;
+ return -1;
}
void *QAccessibleMenuItem::interface_cast(QAccessible::InterfaceType t)
@@ -309,16 +243,6 @@ QRect QAccessibleMenuItem::rect() const
return rect;
}
-QAccessible::Relation QAccessibleMenuItem::relationTo(const QAccessibleInterface *other) const
-{
- if (other->object() == owner()) {
- return QAccessible::Child;
- }
- Q_UNUSED(other)
- // ###
- return QAccessible::Unrelated;
-}
-
QAccessible::Role QAccessibleMenuItem::role() const
{
return m_action->isSeparator() ? QAccessible::Separator : QAccessible::MenuItem;
@@ -330,28 +254,28 @@ void QAccessibleMenuItem::setText(QAccessible::Text /*t*/, const QString & /*tex
QAccessible::State QAccessibleMenuItem::state() const
{
- QAccessible::State s = QAccessible::Normal;
+ QAccessible::State s;
QWidget *own = owner();
if (own->testAttribute(Qt::WA_WState_Visible) == false || m_action->isVisible() == false) {
- s |= QAccessible::Invisible;
+ s.invisible = true;
}
if (QMenu *menu = qobject_cast<QMenu*>(own)) {
if (menu->activeAction() == m_action)
- s |= QAccessible::Focused;
+ s.focused = true;
#ifndef QT_NO_MENUBAR
} else if (QMenuBar *menuBar = qobject_cast<QMenuBar*>(own)) {
if (menuBar->activeAction() == m_action)
- s |= QAccessible::Focused;
+ s.focused = true;
#endif
}
if (own->style()->styleHint(QStyle::SH_Menu_MouseTracking))
- s |= QAccessible::HotTracked;
+ s.hotTracked = true;
if (m_action->isSeparator() || !m_action->isEnabled())
- s |= QAccessible::Unavailable;
+ s.disabled = true;
if (m_action->isChecked())
- s |= QAccessible::Checked;
+ s.checked = true;
return s;
}
diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.h b/src/plugins/accessible/widgets/qaccessiblemenu.h
index cf6a703b0c..873aacd5d4 100644
--- a/src/plugins/accessible/widgets/qaccessiblemenu.h
+++ b/src/plugins/accessible/widgets/qaccessiblemenu.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -59,13 +59,12 @@ public:
explicit QAccessibleMenu(QWidget *w);
int childCount() const;
- int childAt(int x, int y) const;
+ QAccessibleInterface *childAt(int x, int y) const;
QString text(QAccessible::Text t) const;
QAccessible::Role role() const;
QAccessibleInterface *child(int index) const;
QAccessibleInterface *parent() const;
- int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
int indexOfChild( const QAccessibleInterface *child ) const;
protected:
@@ -81,7 +80,6 @@ public:
QAccessibleInterface *child(int index) const;
int childCount() const;
- int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
int indexOfChild(const QAccessibleInterface *child) const;
protected:
@@ -95,20 +93,19 @@ class QAccessibleMenuItem : public QAccessibleInterface, public QAccessibleActio
public:
explicit QAccessibleMenuItem(QWidget *owner, QAction *w);
- virtual ~QAccessibleMenuItem();
-
+ ~QAccessibleMenuItem();
void *interface_cast(QAccessible::InterfaceType t);
- int childAt(int x, int y) const;
+
int childCount() const;
- int indexOfChild(const QAccessibleInterface * child) const;
+ QAccessibleInterface *childAt(int x, int y) const;
bool isValid() const;
+ int indexOfChild(const QAccessibleInterface * child) const;
QAccessibleInterface *parent() const;
QAccessibleInterface *child(int index) const;
int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface ** target) const;
QObject * object() const;
QRect rect() const;
- QAccessible::Relation relationTo(const QAccessibleInterface *other) const;
QAccessible::Role role() const;
void setText(QAccessible::Text t, const QString & text);
QAccessible::State state() const;
diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
index c1cdd7c45d..70d1a7bf48 100644
--- a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
+++ b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -98,121 +98,6 @@ QList<QWidget*> childWidgets(const QWidget *widget, bool includeTopLevel)
return widgets;
}
-static inline int distance(QWidget *source, QWidget *target,
- QAccessible::RelationFlag relation)
-{
- if (!source || !target)
- return -1;
-
- int returnValue = -1;
- switch (relation) {
- case QAccessible::Up:
- if (target->y() <= source->y())
- returnValue = source->y() - target->y();
- break;
- case QAccessible::Down:
- if (target->y() >= source->y() + source->height())
- returnValue = target->y() - (source->y() + source->height());
- break;
- case QAccessible::Right:
- if (target->x() >= source->x() + source->width())
- returnValue = target->x() - (source->x() + source->width());
- break;
- case QAccessible::Left:
- if (target->x() <= source->x())
- returnValue = source->x() - target->x();
- break;
- default:
- break;
- }
- return returnValue;
-}
-
-static inline QWidget *mdiAreaNavigate(QWidget *area,
- QAccessible::RelationFlag relation, int entry)
-{
-#if defined(QT_NO_MDIAREA) && defined(QT_NO_WORKSPACE)
- Q_UNUSED(area);
-#endif
-#ifndef QT_NO_MDIAREA
- const QMdiArea *mdiArea = qobject_cast<QMdiArea *>(area);
-#endif
-#ifndef QT_NO_WORKSPACE
- const QWorkspace *workspace = qobject_cast<QWorkspace *>(area);
-#endif
- if (true
-#ifndef QT_NO_MDIAREA
- && !mdiArea
-#endif
-#ifndef QT_NO_WORKSPACE
- && !workspace
-#endif
- )
- return 0;
-
- QWidgetList windows;
-#ifndef QT_NO_MDIAREA
- if (mdiArea) {
- foreach (QMdiSubWindow *window, mdiArea->subWindowList())
- windows.append(window);
- } else
-#endif
- {
-#ifndef QT_NO_WORKSPACE
- foreach (QWidget *window, workspace->windowList())
- windows.append(window->parentWidget());
-#endif
- }
-
- if (windows.isEmpty() || entry < 1 || entry > windows.count())
- return 0;
-
- QWidget *source = windows.at(entry - 1);
- QMap<int, QWidget *> candidates;
- foreach (QWidget *window, windows) {
- if (source == window)
- continue;
- int candidateDistance = distance(source, window, relation);
- if (candidateDistance >= 0)
- candidates.insert(candidateDistance, window);
- }
-
- int minimumDistance = INT_MAX;
- QWidget *target = 0;
- foreach (QWidget *candidate, candidates) {
- switch (relation) {
- case QAccessible::Up:
- case QAccessible::Down:
- if (qAbs(candidate->x() - source->x()) < minimumDistance) {
- target = candidate;
- minimumDistance = qAbs(candidate->x() - source->x());
- }
- break;
- case QAccessible::Left:
- case QAccessible::Right:
- if (qAbs(candidate->y() - source->y()) < minimumDistance) {
- target = candidate;
- minimumDistance = qAbs(candidate->y() - source->y());
- }
- break;
- default:
- break;
- }
- if (minimumDistance == 0)
- break;
- }
-
-#ifndef QT_NO_WORKSPACE
- if (workspace) {
- foreach (QWidget *widget, workspace->windowList()) {
- if (widget->parentWidget() == target)
- target = widget;
- }
- }
-#endif
- return target;
-}
-
#ifndef QT_NO_TEXTEDIT
/*!
@@ -282,26 +167,6 @@ void QAccessibleTextEdit::setText(QAccessible::Text t, const QString &text)
textEdit()->setText(text);
}
-QVariant QAccessibleTextEdit::invokeMethod(QAccessible::Method method,
- const QVariantList &params)
-{
- switch (method) {
- case QAccessible::ListSupportedMethods: {
- QSet<QAccessible::Method> set;
- set << QAccessible::ListSupportedMethods << QAccessible::SetCursorPosition << QAccessible::GetCursorPosition;
- return QVariant::fromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
- QAccessibleWidget::invokeMethod(method, params)));
- }
- case QAccessible::SetCursorPosition:
- setCursorPosition(params.value(0).toInt());
- return true;
- case QAccessible::GetCursorPosition:
- return textEdit()->textCursor().position();
- default:
- return QAccessibleWidget::invokeMethod(method, params);
- }
-}
-
void *QAccessibleTextEdit::interface_cast(QAccessible::InterfaceType t)
{
if (t == QAccessible::TextInterface)
@@ -316,7 +181,7 @@ void QAccessibleTextEdit::addSelection(int startOffset, int endOffset)
setSelection(0, startOffset, endOffset);
}
-QString QAccessibleTextEdit::attributes(int offset, int *startOffset, int *endOffset)
+QString QAccessibleTextEdit::attributes(int offset, int *startOffset, int *endOffset) const
{
/* The list of attributes can be found at:
http://linuxfoundation.org/collaborate/workgroups/accessibility/iaccessible2/textattributes
@@ -426,12 +291,12 @@ QString QAccessibleTextEdit::attributes(int offset, int *startOffset, int *endOf
return result;
}
-int QAccessibleTextEdit::cursorPosition()
+int QAccessibleTextEdit::cursorPosition() const
{
return textEdit()->textCursor().position();
}
-QRect QAccessibleTextEdit::characterRect(int offset, CoordinateType coordType)
+QRect QAccessibleTextEdit::characterRect(int offset, CoordinateType coordType) const
{
QTextEdit *edit = textEdit();
QTextCursor cursor(edit->document());
@@ -463,12 +328,12 @@ QRect QAccessibleTextEdit::characterRect(int offset, CoordinateType coordType)
return r;
}
-int QAccessibleTextEdit::selectionCount()
+int QAccessibleTextEdit::selectionCount() const
{
return textEdit()->textCursor().hasSelection() ? 1 : 0;
}
-int QAccessibleTextEdit::offsetAtPoint(const QPoint &point, CoordinateType coordType)
+int QAccessibleTextEdit::offsetAtPoint(const QPoint &point, CoordinateType coordType) const
{
QTextEdit *edit = textEdit();
@@ -481,7 +346,7 @@ int QAccessibleTextEdit::offsetAtPoint(const QPoint &point, CoordinateType coord
return edit->document()->documentLayout()->hitTest(p, Qt::ExactHit);
}
-void QAccessibleTextEdit::selection(int selectionIndex, int *startOffset, int *endOffset)
+void QAccessibleTextEdit::selection(int selectionIndex, int *startOffset, int *endOffset) const
{
*startOffset = *endOffset = 0;
QTextCursor cursor = textEdit()->textCursor();
@@ -493,7 +358,7 @@ void QAccessibleTextEdit::selection(int selectionIndex, int *startOffset, int *e
*endOffset = cursor.selectionEnd();
}
-QString QAccessibleTextEdit::text(int startOffset, int endOffset)
+QString QAccessibleTextEdit::text(int startOffset, int endOffset) const
{
QTextCursor cursor(textEdit()->document());
@@ -504,7 +369,7 @@ QString QAccessibleTextEdit::text(int startOffset, int endOffset)
}
QString QAccessibleTextEdit::textBeforeOffset (int offset, BoundaryType boundaryType,
- int *startOffset, int *endOffset)
+ int *startOffset, int *endOffset) const
{
// TODO - what exactly is before?
Q_UNUSED(offset);
@@ -515,7 +380,7 @@ QString QAccessibleTextEdit::textBeforeOffset (int offset, BoundaryType boundary
}
QString QAccessibleTextEdit::textAfterOffset(int offset, BoundaryType boundaryType,
- int *startOffset, int *endOffset)
+ int *startOffset, int *endOffset) const
{
// TODO - what exactly is after?
Q_UNUSED(offset);
@@ -526,7 +391,7 @@ QString QAccessibleTextEdit::textAfterOffset(int offset, BoundaryType boundaryTy
}
QString QAccessibleTextEdit::textAtOffset(int offset, BoundaryType boundaryType,
- int *startOffset, int *endOffset)
+ int *startOffset, int *endOffset) const
{
Q_ASSERT(startOffset);
Q_ASSERT(endOffset);
@@ -607,7 +472,7 @@ void QAccessibleTextEdit::setSelection(int selectionIndex, int startOffset, int
textEdit()->setTextCursor(cursor);
}
-int QAccessibleTextEdit::characterCount()
+int QAccessibleTextEdit::characterCount() const
{
return textEdit()->toPlainText().count();
}
@@ -640,7 +505,7 @@ static QTextCursor cursorForRange(QTextEdit *textEdit, int startOffset, int endO
return cursor;
}
-void QAccessibleTextEdit::copyText(int startOffset, int endOffset)
+void QAccessibleTextEdit::copyText(int startOffset, int endOffset) const
{
QTextCursor cursor = cursorForRange(textEdit(), startOffset, endOffset);
@@ -716,23 +581,17 @@ QAccessibleStackedWidget::QAccessibleStackedWidget(QWidget *widget)
Q_ASSERT(qobject_cast<QStackedWidget *>(widget));
}
-QVariant QAccessibleStackedWidget::invokeMethod(QAccessible::Method, int, const QVariantList &)
-{
- return QVariant();
-}
-
-
-int QAccessibleStackedWidget::childAt(int x, int y) const
+QAccessibleInterface *QAccessibleStackedWidget::childAt(int x, int y) const
{
if (!stackedWidget()->isVisible())
- return -1;
+ return 0;
QWidget *currentWidget = stackedWidget()->currentWidget();
if (!currentWidget)
- return -1;
+ return 0;
QPoint position = currentWidget->mapFromGlobal(QPoint(x, y));
if (currentWidget->rect().contains(position))
- return 1;
- return -1;
+ return child(stackedWidget()->currentIndex());
+ return 0;
}
int QAccessibleStackedWidget::childCount() const
@@ -746,10 +605,7 @@ int QAccessibleStackedWidget::indexOfChild(const QAccessibleInterface *child) co
return -1;
QWidget* widget = qobject_cast<QWidget*>(child->object());
- int index = stackedWidget()->indexOf(widget);
- if (index >= 0) // one based counting of children
- return index + 1;
- return -1;
+ return stackedWidget()->indexOf(widget);
}
QAccessibleInterface *QAccessibleStackedWidget::child(int index) const
@@ -759,17 +615,6 @@ QAccessibleInterface *QAccessibleStackedWidget::child(int index) const
return QAccessible::queryAccessibleInterface(stackedWidget()->widget(index));
}
-int QAccessibleStackedWidget::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
-{
- switch (relation) {
- case QAccessible::Child:
- *target = child(entry - 1);
- return *target ? 0 : -1;
- default:
- return QAccessibleWidget::navigate(relation, entry, target);
- }
-}
-
QStackedWidget *QAccessibleStackedWidget::stackedWidget() const
{
return static_cast<QStackedWidget *>(object());
@@ -803,42 +648,26 @@ int QAccessibleMdiArea::childCount() const
return mdiArea()->subWindowList().count();
}
+QAccessibleInterface *QAccessibleMdiArea::child(int index) const
+{
+ QList<QMdiSubWindow *> subWindows = mdiArea()->subWindowList();
+ QWidget *targetObject = subWindows.value(index);
+ if (!targetObject)
+ return 0;
+ return QAccessible::queryAccessibleInterface(targetObject);
+}
+
+
int QAccessibleMdiArea::indexOfChild(const QAccessibleInterface *child) const
{
if (!child || !child->object() || mdiArea()->subWindowList().isEmpty())
return -1;
if (QMdiSubWindow *window = qobject_cast<QMdiSubWindow *>(child->object())) {
- int index = mdiArea()->subWindowList().indexOf(window);
- if (index != -1)
- return ++index;
+ return mdiArea()->subWindowList().indexOf(window);
}
return -1;
}
-int QAccessibleMdiArea::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
-{
- *target = 0;
- QWidget *targetObject = 0;
- QList<QMdiSubWindow *> subWindows = mdiArea()->subWindowList();
- switch (relation) {
- case QAccessible::Child:
- if (entry < 1 || subWindows.isEmpty() || entry > subWindows.count())
- return -1;
- targetObject = subWindows.at(entry - 1);
- break;
- case QAccessible::Up:
- case QAccessible::Down:
- case QAccessible::Left:
- case QAccessible::Right:
- targetObject = mdiAreaNavigate(mdiArea(), relation, entry);
- break;
- default:
- return QAccessibleWidget::navigate(relation, entry, target);
- }
- *target = QAccessible::queryAccessibleInterface(targetObject);
- return *target ? 0: -1;
-}
-
QMdiArea *QAccessibleMdiArea::mdiArea() const
{
return static_cast<QMdiArea *>(object());
@@ -871,18 +700,21 @@ void QAccessibleMdiSubWindow::setText(QAccessible::Text textType, const QString
QAccessible::State QAccessibleMdiSubWindow::state() const
{
- QAccessible::State state = QAccessible::Normal | QAccessible::Focusable;
- if (!mdiSubWindow()->isMaximized())
- state |= (QAccessible::Movable | QAccessible::Sizeable);
+ QAccessible::State state;
+ state.focusable = true;
+ if (!mdiSubWindow()->isMaximized()) {
+ state.movable = true;
+ state.sizeable = true;
+ }
if (mdiSubWindow()->isAncestorOf(QApplication::focusWidget())
|| QApplication::focusWidget() == mdiSubWindow())
- state |= QAccessible::Focused;
+ state.focused = true;
if (!mdiSubWindow()->isVisible())
- state |= QAccessible::Invisible;
+ state.invisible = true;
if (!mdiSubWindow()->parentWidget()->contentsRect().contains(mdiSubWindow()->geometry()))
- state |= QAccessible::Offscreen;
+ state.offscreen = true;
if (!mdiSubWindow()->isEnabled())
- state |= QAccessible::Unavailable;
+ state.disabled = true;
return state;
}
@@ -893,54 +725,20 @@ int QAccessibleMdiSubWindow::childCount() const
return 0;
}
-int QAccessibleMdiSubWindow::indexOfChild(const QAccessibleInterface *child) const
+QAccessibleInterface *QAccessibleMdiSubWindow::child(int index) const
{
- if (child && child->object() && child->object() == mdiSubWindow()->widget())
- return 1;
- return -1;
+ QMdiSubWindow *source = mdiSubWindow();
+ if (index != 0 || !source->widget())
+ return 0;
+
+ return QAccessible::queryAccessibleInterface(source->widget());
}
-int QAccessibleMdiSubWindow::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
+int QAccessibleMdiSubWindow::indexOfChild(const QAccessibleInterface *child) const
{
- *target = 0;
-
- if (!mdiSubWindow()->parent())
- return QAccessibleWidget::navigate(relation, entry, target);
-
- QWidget *targetObject = 0;
- QMdiSubWindow *source = mdiSubWindow();
- switch (relation) {
- case QAccessible::Child:
- if (entry != 1 || !source->widget())
- return -1;
- targetObject = source->widget();
- break;
- case QAccessible::Up:
- case QAccessible::Down:
- case QAccessible::Left:
- case QAccessible::Right: {
- if (entry != 0)
- break;
- QWidget *parent = source->parentWidget();
- while (parent && !parent->inherits("QMdiArea"))
- parent = parent->parentWidget();
- QMdiArea *mdiArea = qobject_cast<QMdiArea *>(parent);
- if (!mdiArea)
- break;
- int index = mdiArea->subWindowList().indexOf(source);
- if (index == -1)
- break;
- if (QWidget *dest = mdiAreaNavigate(mdiArea, relation, index + 1)) {
- *target = QAccessible::queryAccessibleInterface(dest);
- return *target ? 0 : -1;
- }
- break;
- }
- default:
- return QAccessibleWidget::navigate(relation, entry, target);
- }
- *target = QAccessible::queryAccessibleInterface(targetObject);
- return *target ? 0: -1;
+ if (child && child->object() && child->object() == mdiSubWindow()->widget())
+ return 0;
+ return -1;
}
QRect QAccessibleMdiSubWindow::rect() const
@@ -953,25 +751,6 @@ QRect QAccessibleMdiSubWindow::rect() const
return QRect(pos, mdiSubWindow()->size());
}
-int QAccessibleMdiSubWindow::childAt(int x, int y) const
-{
- if (!mdiSubWindow()->isVisible())
- return -1;
- if (!mdiSubWindow()->parent())
- return QAccessibleWidget::childAt(x, y);
- const QRect globalGeometry = rect();
- if (!globalGeometry.isValid())
- return -1;
- QAccessibleInterface *childIface = child(0);
- const QRect globalChildGeometry = childIface->rect();
- delete childIface;
- if (globalChildGeometry.isValid() && globalChildGeometry.contains(QPoint(x, y)))
- return 1;
- if (globalGeometry.contains(QPoint(x, y)))
- return 0;
- return -1;
-}
-
QMdiSubWindow *QAccessibleMdiSubWindow::mdiSubWindow() const
{
return static_cast<QMdiSubWindow *>(object());
@@ -991,42 +770,25 @@ int QAccessibleWorkspace::childCount() const
return workspace()->windowList().count();
}
+QAccessibleInterface *QAccessibleWorkspace::child(int index) const
+{
+ QWidgetList subWindows = workspace()->windowList();
+ if (index < 0 || subWindows.isEmpty() || index >= subWindows.count())
+ return 0;
+ QObject *targetObject = subWindows.at(index);
+ return QAccessible::queryAccessibleInterface(targetObject);
+}
+
int QAccessibleWorkspace::indexOfChild(const QAccessibleInterface *child) const
{
if (!child || !child->object() || workspace()->windowList().isEmpty())
return -1;
if (QWidget *window = qobject_cast<QWidget *>(child->object())) {
- int index = workspace()->windowList().indexOf(window);
- if (index != -1)
- return ++index;
+ return workspace()->windowList().indexOf(window);
}
return -1;
}
-int QAccessibleWorkspace::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
-{
- *target = 0;
- QWidget *targetObject = 0;
- QWidgetList subWindows = workspace()->windowList();
- switch (relation) {
- case QAccessible::Child:
- if (entry < 1 || subWindows.isEmpty() || entry > subWindows.count())
- return -1;
- targetObject = subWindows.at(entry - 1);
- break;
- case QAccessible::Up:
- case QAccessible::Down:
- case QAccessible::Left:
- case QAccessible::Right:
- targetObject = mdiAreaNavigate(workspace(), relation, entry);
- break;
- default:
- return QAccessibleWidget::navigate(relation, entry, target);
- }
- *target = QAccessible::queryAccessibleInterface(targetObject);
- return *target ? 0: -1;
-}
-
QWorkspace *QAccessibleWorkspace::workspace() const
{
return static_cast<QWorkspace *>(object());
@@ -1041,10 +803,6 @@ QAccessibleDialogButtonBox::QAccessibleDialogButtonBox(QWidget *widget)
Q_ASSERT(qobject_cast<QDialogButtonBox*>(widget));
}
-QVariant QAccessibleDialogButtonBox::invokeMethod(QAccessible::Method, int, const QVariantList &)
-{
- return QVariant();
-}
#endif // QT_NO_DIALOGBUTTONBOX
#ifndef QT_NO_TEXTBROWSER
@@ -1068,11 +826,6 @@ QAccessibleCalendarWidget::QAccessibleCalendarWidget(QWidget *widget)
Q_ASSERT(qobject_cast<QCalendarWidget *>(widget));
}
-QVariant QAccessibleCalendarWidget::invokeMethod(QAccessible::Method, int, const QVariantList &)
-{
- return QVariant();
-}
-
int QAccessibleCalendarWidget::childCount() const
{
return calendarWidget()->isNavigationBarVisible() ? 2 : 1;
@@ -1083,8 +836,8 @@ int QAccessibleCalendarWidget::indexOfChild(const QAccessibleInterface *child) c
if (!child || !child->object() || childCount() <= 0)
return -1;
if (qobject_cast<QAbstractItemView *>(child->object()))
- return childCount();
- return 1;
+ return childCount() - 1; // FIXME
+ return 0;
}
QAccessibleInterface *QAccessibleCalendarWidget::child(int index) const
@@ -1098,31 +851,6 @@ QAccessibleInterface *QAccessibleCalendarWidget::child(int index) const
return QAccessible::queryAccessibleInterface(calendarView());
}
-int QAccessibleCalendarWidget::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
-{
- *target = 0;
- if (entry <= 0 || entry > childCount())
- return QAccessibleWidget::navigate(relation, entry, target);
- QWidget *targetWidget = 0;
- switch (relation) {
- case QAccessible::Child:
- *target = child(entry - 1);
- return *target ? 0 : -1;
- case QAccessible::Up:
- if (entry == 2)
- targetWidget = navigationBar();
- break;
- case QAccessible::Down:
- if (entry == 1 && childCount() == 2)
- targetWidget = calendarView();
- break;
- default:
- return QAccessibleWidget::navigate(relation, entry, target);
- }
- *target = QAccessible::queryAccessibleInterface(targetWidget);
- return *target ? 0 : -1;
-}
-
QCalendarWidget *QAccessibleCalendarWidget::calendarWidget() const
{
return static_cast<QCalendarWidget *>(object());
@@ -1173,9 +901,9 @@ int QAccessibleDockWidget::indexOfChild(const QAccessibleInterface *child) const
{
if (child) {
if (child->role() == QAccessible::TitleBar) {
- return 1;
+ return 0;
} else {
- return 2; //###
+ return 1; // FIXME
}
}
return -1;
@@ -1240,9 +968,6 @@ QAccessibleInterface *QAccessibleTitleBar::child(int index) const
int QAccessibleTitleBar::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **iface) const
{
switch (relation) {
- case QAccessible::Child:
- *iface = child(entry - 1);
- return *iface ? 0 : -1;
case QAccessible::FocusChild:
// ###
if (entry >= 1) {
@@ -1261,9 +986,6 @@ int QAccessibleTitleBar::navigate(QAccessible::RelationFlag relation, int entry,
return role > QDockWidgetLayout::FloatButton ? -1 : index;
}
break;
- case QAccessible::Ancestor:
- *iface = parent();
- return iface ? 0 : -1;
default:
break;
}
@@ -1271,11 +993,6 @@ int QAccessibleTitleBar::navigate(QAccessible::RelationFlag relation, int entry,
return -1;
}
-QAccessible::Relation QAccessibleTitleBar::relationTo(const QAccessibleInterface * /*otherChild*/) const
-{
- return QAccessible::Unrelated; //###
-}
-
int QAccessibleTitleBar::indexOfChild(const QAccessibleInterface * /*child*/) const
{
return -1;
@@ -1303,17 +1020,17 @@ QString QAccessibleTitleBar::text(QAccessible::Text t) const
QAccessible::State QAccessibleTitleBar::state() const
{
- QAccessible::State state = QAccessible::Normal;
+ QAccessible::State state;
QDockWidget *w = dockWidget();
if (w->testAttribute(Qt::WA_WState_Visible) == false)
- state |= QAccessible::Invisible;
+ state.invisible = true;
if (w->focusPolicy() != Qt::NoFocus && w->isActiveWindow())
- state |= QAccessible::Focusable;
+ state.focusable = true;
if (w->hasFocus())
- state |= QAccessible::Focused;
+ state.focused = true;
if (!w->isEnabled())
- state |= QAccessible::Unavailable;
+ state.disabled = true;
return state;
}
@@ -1344,17 +1061,16 @@ QRect QAccessibleTitleBar::rect() const
return rect;
}
-int QAccessibleTitleBar::childAt(int x, int y) const
+QAccessibleInterface *QAccessibleTitleBar::childAt(int x, int y) const
{
- for (int i = childCount(); i >= 0; --i) {
- QAccessibleInterface *childIface = child(i - 1);
+ for (int i = 0; i < childCount(); ++i) {
+ QAccessibleInterface *childIface = child(i);
if (childIface->rect().contains(x,y)) {
- delete childIface;
- return i;
+ return childIface;
}
delete childIface;
}
- return -1;
+ return 0;
}
QObject *QAccessibleTitleBar::object() const
@@ -1436,11 +1152,6 @@ bool QAccessibleTitleBar::isValid() const
QAccessibleMainWindow::QAccessibleMainWindow(QWidget *widget)
: QAccessibleWidget(widget, QAccessible::Window) { }
-QVariant QAccessibleMainWindow::invokeMethod(QAccessible::Method /*method*/, int /*child*/, const QVariantList & /*params*/)
-{
- return QVariant();
-}
-
QAccessibleInterface *QAccessibleMainWindow::child(int index) const
{
QList<QWidget*> kids = childWidgets(mainWindow(), true);
@@ -1459,25 +1170,24 @@ int QAccessibleMainWindow::childCount() const
int QAccessibleMainWindow::indexOfChild(const QAccessibleInterface *iface) const
{
QList<QWidget*> kids = childWidgets(mainWindow(), true);
- int childIndex = kids.indexOf(static_cast<QWidget*>(iface->object()));
- return childIndex == -1 ? -1 : ++childIndex;
+ return kids.indexOf(static_cast<QWidget*>(iface->object()));
}
-int QAccessibleMainWindow::childAt(int x, int y) const
+QAccessibleInterface *QAccessibleMainWindow::childAt(int x, int y) const
{
QWidget *w = widget();
if (!w->isVisible())
- return -1;
+ return 0;
QPoint gp = w->mapToGlobal(QPoint(0, 0));
if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y))
- return -1;
+ return 0;
QWidgetList kids = childWidgets(mainWindow(), true);
QPoint rp = mainWindow()->mapFromGlobal(QPoint(x, y));
for (int i = 0; i < kids.size(); ++i) {
QWidget *child = kids.at(i);
if (!child->isWindow() && !child->isHidden() && child->geometry().contains(rp)) {
- return i + 1;
+ return QAccessible::queryAccessibleInterface(child);
}
}
return 0;
diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.h b/src/plugins/accessible/widgets/qaccessiblewidgets.h
index 232293b32a..b53138636f 100644
--- a/src/plugins/accessible/widgets/qaccessiblewidgets.h
+++ b/src/plugins/accessible/widgets/qaccessiblewidgets.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -75,32 +75,31 @@ public:
QString text(QAccessible::Text t) const;
void setText(QAccessible::Text t, const QString &text);
- QVariant invokeMethod(QAccessible::Method method, const QVariantList &params);
void *interface_cast(QAccessible::InterfaceType t);
// QAccessibleTextInterface
void addSelection(int startOffset, int endOffset);
- QString attributes(int offset, int *startOffset, int *endOffset);
- int cursorPosition();
- QRect characterRect(int offset, QAccessible2::CoordinateType coordType);
- int selectionCount();
- int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType);
- void selection(int selectionIndex, int *startOffset, int *endOffset);
- QString text(int startOffset, int endOffset);
+ QString attributes(int offset, int *startOffset, int *endOffset) const;
+ int cursorPosition() const;
+ QRect characterRect(int offset, QAccessible2::CoordinateType coordType) const;
+ int selectionCount() const;
+ int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType) const;
+ void selection(int selectionIndex, int *startOffset, int *endOffset) const;
+ QString text(int startOffset, int endOffset) const;
QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType,
- int *startOffset, int *endOffset);
+ int *startOffset, int *endOffset) const;
QString textAfterOffset(int offset, QAccessible2::BoundaryType boundaryType,
- int *startOffset, int *endOffset);
+ int *startOffset, int *endOffset) const;
QString textAtOffset(int offset, QAccessible2::BoundaryType boundaryType,
- int *startOffset, int *endOffset);
+ int *startOffset, int *endOffset) const;
void removeSelection(int selectionIndex);
void setCursorPosition(int position);
void setSelection(int selectionIndex, int startOffset, int endOffset);
- int characterCount();
+ int characterCount() const;
void scrollToSubstring(int startIndex, int endIndex);
// QAccessibleEditableTextInterface
- void copyText(int startOffset, int endOffset);
+ void copyText(int startOffset, int endOffset) const;
void deleteText(int startOffset, int endOffset);
void insertText(int offset, const QString &text);
void cutText(int startOffset, int endOffset);
@@ -121,12 +120,10 @@ class QAccessibleStackedWidget : public QAccessibleWidget
public:
explicit QAccessibleStackedWidget(QWidget *widget);
- QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList &params);
- int childAt(int x, int y) const;
+ QAccessibleInterface *childAt(int x, int y) const;
int childCount() const;
int indexOfChild(const QAccessibleInterface *child) const;
QAccessibleInterface *child(int index) const;
- int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
protected:
QStackedWidget *stackedWidget() const;
@@ -154,8 +151,8 @@ public:
explicit QAccessibleMdiArea(QWidget *widget);
int childCount() const;
+ QAccessibleInterface *child(int index) const;
int indexOfChild(const QAccessibleInterface *child) const;
- int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
protected:
QMdiArea *mdiArea() const;
@@ -170,10 +167,9 @@ public:
void setText(QAccessible::Text textType, const QString &text);
QAccessible::State state() const;
int childCount() const;
+ QAccessibleInterface *child(int index) const;
int indexOfChild(const QAccessibleInterface *child) const;
- int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
QRect rect() const;
- int childAt(int x, int y) const;
protected:
QMdiSubWindow *mdiSubWindow() const;
@@ -187,8 +183,8 @@ public:
explicit QAccessibleWorkspace(QWidget *widget);
int childCount() const;
+ QAccessibleInterface *child(int index) const;
int indexOfChild(const QAccessibleInterface *child) const;
- int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
protected:
QWorkspace *workspace() const;
@@ -199,8 +195,6 @@ class QAccessibleDialogButtonBox : public QAccessibleWidget
{
public:
explicit QAccessibleDialogButtonBox(QWidget *widget);
-
- QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList &params);
};
#ifndef QT_NO_TEXTBROWSER
@@ -221,12 +215,9 @@ public:
int childCount() const;
int indexOfChild(const QAccessibleInterface *child) const;
- int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
QAccessibleInterface *child(int index) const;
-
- QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList &params);
protected:
QCalendarWidget *calendarWidget() const;
@@ -260,13 +251,12 @@ public:
int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **iface) const;
int indexOfChild(const QAccessibleInterface *child) const;
int childCount() const;
- QAccessible::Relation relationTo(const QAccessibleInterface *other) const;
+ QAccessibleInterface *childAt(int x, int y) const;
void setText(QAccessible::Text t, const QString &text);
QString text(QAccessible::Text t) const;
QAccessible::Role role() const;
QRect rect () const;
QAccessible::State state() const;
- int childAt(int x, int y) const;
QObject *object() const;
bool isValid() const;
@@ -287,10 +277,9 @@ public:
QAccessibleInterface *child(int index) const;
int childCount() const;
int indexOfChild(const QAccessibleInterface *iface) const;
- int childAt(int x, int y) const;
+ QAccessibleInterface *childAt(int x, int y) const;
QMainWindow *mainWindow() const;
- QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList &params);
};
#endif //QT_NO_MAINWINDOW
diff --git a/src/plugins/accessible/widgets/rangecontrols.cpp b/src/plugins/accessible/widgets/rangecontrols.cpp
index 06ff8e2cbf..6c439a71f0 100644
--- a/src/plugins/accessible/widgets/rangecontrols.cpp
+++ b/src/plugins/accessible/widgets/rangecontrols.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -94,7 +94,7 @@ void *QAccessibleAbstractSpinBox::interface_cast(QAccessible::InterfaceType t)
return QAccessibleWidget::interface_cast(t);
}
-QVariant QAccessibleAbstractSpinBox::currentValue()
+QVariant QAccessibleAbstractSpinBox::currentValue() const
{
QVariant result = abstractSpinBox()->property("value");
QVariant::Type type = result.type();
@@ -112,12 +112,12 @@ void QAccessibleAbstractSpinBox::setCurrentValue(const QVariant &value)
abstractSpinBox()->setProperty("value", value);
}
-QVariant QAccessibleAbstractSpinBox::maximumValue()
+QVariant QAccessibleAbstractSpinBox::maximumValue() const
{
return abstractSpinBox()->property("maximum");
}
-QVariant QAccessibleAbstractSpinBox::minimumValue()
+QVariant QAccessibleAbstractSpinBox::minimumValue() const
{
return abstractSpinBox()->property("minimum");
}
@@ -258,7 +258,7 @@ void *QAccessibleAbstractSlider::interface_cast(QAccessible::InterfaceType t)
return QAccessibleWidget::interface_cast(t);
}
-QVariant QAccessibleAbstractSlider::currentValue()
+QVariant QAccessibleAbstractSlider::currentValue() const
{
return abstractSlider()->value();
}
@@ -268,12 +268,12 @@ void QAccessibleAbstractSlider::setCurrentValue(const QVariant &value)
abstractSlider()->setValue(value.toInt());
}
-QVariant QAccessibleAbstractSlider::maximumValue()
+QVariant QAccessibleAbstractSlider::maximumValue() const
{
return abstractSlider()->maximum();
}
-QVariant QAccessibleAbstractSlider::minimumValue()
+QVariant QAccessibleAbstractSlider::minimumValue() const
{
return abstractSlider()->minimum();
}
diff --git a/src/plugins/accessible/widgets/rangecontrols.h b/src/plugins/accessible/widgets/rangecontrols.h
index f6cbcc6900..218c48184c 100644
--- a/src/plugins/accessible/widgets/rangecontrols.h
+++ b/src/plugins/accessible/widgets/rangecontrols.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -67,10 +67,10 @@ public:
void *interface_cast(QAccessible::InterfaceType t);
// QAccessibleValueInterface
- QVariant currentValue();
+ QVariant currentValue() const;
void setCurrentValue(const QVariant &value);
- QVariant maximumValue();
- QVariant minimumValue();
+ QVariant maximumValue() const;
+ QVariant minimumValue() const;
// FIXME Action interface
@@ -106,10 +106,10 @@ public:
void *interface_cast(QAccessible::InterfaceType t);
// QAccessibleValueInterface
- QVariant currentValue();
+ QVariant currentValue() const;
void setCurrentValue(const QVariant &value);
- QVariant maximumValue();
- QVariant minimumValue();
+ QVariant maximumValue() const;
+ QVariant minimumValue() const;
protected:
QAbstractSlider *abstractSlider() const;
diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp
index 8f4fed48fe..d645ad2d22 100644
--- a/src/plugins/accessible/widgets/simplewidgets.cpp
+++ b/src/plugins/accessible/widgets/simplewidgets.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -140,18 +140,18 @@ QAccessible::State QAccessibleButton::state() const
QAbstractButton *b = button();
QCheckBox *cb = qobject_cast<QCheckBox *>(b);
if (b->isChecked())
- state |= QAccessible::Checked;
+ state.checked = true;
else if (cb && cb->checkState() == Qt::PartiallyChecked)
- state |= QAccessible::Mixed;
+ state.checkStateMixed = true;
if (b->isDown())
- state |= QAccessible::Pressed;
+ state.pressed = true;
QPushButton *pb = qobject_cast<QPushButton*>(b);
if (pb) {
if (pb->isDefault())
- state |= QAccessible::DefaultButton;
+ state.defaultButton = true;
#ifndef QT_NO_MENU
if (pb->menu())
- state |= QAccessible::HasPopup;
+ state.hasPopup = true;
#endif
}
@@ -171,7 +171,7 @@ QStringList QAccessibleButton::actionNames() const
break;
default:
if (button()->isCheckable()) {
- if (state() & QAccessible::Checked) {
+ if (state().checked) {
names << uncheckAction();
} else {
// FIXME
@@ -263,10 +263,10 @@ QAccessible::State QAccessibleToolButton::state() const
{
QAccessible::State st = QAccessibleButton::state();
if (toolButton()->autoRaise())
- st |= QAccessible::HotTracked;
+ st.hotTracked = true;
#ifndef QT_NO_MENU
if (toolButton()->menu())
- st |= QAccessible::HasPopup;
+ st.hasPopup = true;
#endif
return st;
}
@@ -464,10 +464,11 @@ int QAccessibleDisplay::navigate(QAccessible::RelationFlag rel, int entry, QAcce
} else {
QGroupBox *groupbox = qobject_cast<QGroupBox*>(object());
if (groupbox && !groupbox->title().isEmpty())
- rel = QAccessible::Child;
+ *target = child(entry - 1);
#endif
}
- *target = QAccessible::queryAccessibleInterface(targetObject);
+ if (targetObject)
+ *target = QAccessible::queryAccessibleInterface(targetObject);
if (*target)
return 0;
}
@@ -482,7 +483,7 @@ void *QAccessibleDisplay::interface_cast(QAccessible::InterfaceType t)
}
/*! \internal */
-QString QAccessibleDisplay::imageDescription()
+QString QAccessibleDisplay::imageDescription() const
{
#ifndef QT_NO_TOOLTIP
return widget()->toolTip();
@@ -492,7 +493,7 @@ QString QAccessibleDisplay::imageDescription()
}
/*! \internal */
-QSize QAccessibleDisplay::imageSize()
+QSize QAccessibleDisplay::imageSize() const
{
QLabel *label = qobject_cast<QLabel *>(widget());
if (!label)
@@ -504,7 +505,7 @@ QSize QAccessibleDisplay::imageSize()
}
/*! \internal */
-QRect QAccessibleDisplay::imagePosition(QAccessible2::CoordinateType coordType)
+QRect QAccessibleDisplay::imagePosition(QAccessible2::CoordinateType coordType) const
{
QLabel *label = qobject_cast<QLabel *>(widget());
if (!label)
@@ -587,40 +588,20 @@ QAccessible::State QAccessibleLineEdit::state() const
QLineEdit *l = lineEdit();
if (l->isReadOnly())
- state |= QAccessible::ReadOnly;
+ state.readOnly = true;
if (l->echoMode() != QLineEdit::Normal)
- state |= QAccessible::Protected;
- state |= QAccessible::Selectable;
+ state.passwordEdit = true;
+ state.selectable = true;
if (l->hasSelectedText())
- state |= QAccessible::Selected;
+ state.selected = true;
if (l->contextMenuPolicy() != Qt::NoContextMenu
&& l->contextMenuPolicy() != Qt::PreventContextMenu)
- state |= QAccessible::HasPopup;
+ state.hasPopup = true;
return state;
}
-QVariant QAccessibleLineEdit::invokeMethod(QAccessible::Method method,
- const QVariantList &params)
-{
- switch (method) {
- case QAccessible::ListSupportedMethods: {
- QSet<QAccessible::Method> set;
- set << QAccessible::ListSupportedMethods << QAccessible::SetCursorPosition << QAccessible::GetCursorPosition;
- return QVariant::fromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
- QAccessibleWidget::invokeMethod(method, params)));
- }
- case QAccessible::SetCursorPosition:
- setCursorPosition(params.value(0).toInt());
- return true;
- case QAccessible::GetCursorPosition:
- return cursorPosition();
- default:
- return QAccessibleWidget::invokeMethod(method, params);
- }
-}
-
void *QAccessibleLineEdit::interface_cast(QAccessible::InterfaceType t)
{
if (t == QAccessible::TextInterface)
@@ -635,30 +616,30 @@ void QAccessibleLineEdit::addSelection(int startOffset, int endOffset)
setSelection(0, startOffset, endOffset);
}
-QString QAccessibleLineEdit::attributes(int offset, int *startOffset, int *endOffset)
+QString QAccessibleLineEdit::attributes(int offset, int *startOffset, int *endOffset) const
{
// QLineEdit doesn't have text attributes
*startOffset = *endOffset = offset;
return QString();
}
-int QAccessibleLineEdit::cursorPosition()
+int QAccessibleLineEdit::cursorPosition() const
{
return lineEdit()->cursorPosition();
}
-QRect QAccessibleLineEdit::characterRect(int /*offset*/, CoordinateType /*coordType*/)
+QRect QAccessibleLineEdit::characterRect(int /*offset*/, CoordinateType /*coordType*/) const
{
// QLineEdit doesn't hand out character rects
return QRect();
}
-int QAccessibleLineEdit::selectionCount()
+int QAccessibleLineEdit::selectionCount() const
{
return lineEdit()->hasSelectedText() ? 1 : 0;
}
-int QAccessibleLineEdit::offsetAtPoint(const QPoint &point, CoordinateType coordType)
+int QAccessibleLineEdit::offsetAtPoint(const QPoint &point, CoordinateType coordType) const
{
QPoint p = point;
if (coordType == RelativeToScreen)
@@ -667,7 +648,7 @@ int QAccessibleLineEdit::offsetAtPoint(const QPoint &point, CoordinateType coord
return lineEdit()->cursorPositionAt(p);
}
-void QAccessibleLineEdit::selection(int selectionIndex, int *startOffset, int *endOffset)
+void QAccessibleLineEdit::selection(int selectionIndex, int *startOffset, int *endOffset) const
{
*startOffset = *endOffset = 0;
if (selectionIndex != 0)
@@ -677,7 +658,7 @@ void QAccessibleLineEdit::selection(int selectionIndex, int *startOffset, int *e
*endOffset = *startOffset + lineEdit()->selectedText().count();
}
-QString QAccessibleLineEdit::text(int startOffset, int endOffset)
+QString QAccessibleLineEdit::text(int startOffset, int endOffset) const
{
if (startOffset > endOffset)
return QString();
@@ -689,7 +670,7 @@ QString QAccessibleLineEdit::text(int startOffset, int endOffset)
}
QString QAccessibleLineEdit::textBeforeOffset(int offset, BoundaryType boundaryType,
- int *startOffset, int *endOffset)
+ int *startOffset, int *endOffset) const
{
if (lineEdit()->echoMode() != QLineEdit::Normal) {
*startOffset = *endOffset = -1;
@@ -699,7 +680,7 @@ QString QAccessibleLineEdit::textBeforeOffset(int offset, BoundaryType boundaryT
}
QString QAccessibleLineEdit::textAfterOffset(int offset, BoundaryType boundaryType,
- int *startOffset, int *endOffset)
+ int *startOffset, int *endOffset) const
{
if (lineEdit()->echoMode() != QLineEdit::Normal) {
*startOffset = *endOffset = -1;
@@ -709,7 +690,7 @@ QString QAccessibleLineEdit::textAfterOffset(int offset, BoundaryType boundaryTy
}
QString QAccessibleLineEdit::textAtOffset(int offset, BoundaryType boundaryType,
- int *startOffset, int *endOffset)
+ int *startOffset, int *endOffset) const
{
if (lineEdit()->echoMode() != QLineEdit::Normal) {
*startOffset = *endOffset = -1;
@@ -739,7 +720,7 @@ void QAccessibleLineEdit::setSelection(int selectionIndex, int startOffset, int
lineEdit()->setSelection(startOffset, endOffset - startOffset);
}
-int QAccessibleLineEdit::characterCount()
+int QAccessibleLineEdit::characterCount() const
{
return lineEdit()->text().count();
}
@@ -766,17 +747,17 @@ void *QAccessibleProgressBar::interface_cast(QAccessible::InterfaceType t)
return QAccessibleDisplay::interface_cast(t);
}
-QVariant QAccessibleProgressBar::currentValue()
+QVariant QAccessibleProgressBar::currentValue() const
{
return progressBar()->value();
}
-QVariant QAccessibleProgressBar::maximumValue()
+QVariant QAccessibleProgressBar::maximumValue() const
{
return progressBar()->maximum();
}
-QVariant QAccessibleProgressBar::minimumValue()
+QVariant QAccessibleProgressBar::minimumValue() const
{
return progressBar()->minimum();
}
diff --git a/src/plugins/accessible/widgets/simplewidgets.h b/src/plugins/accessible/widgets/simplewidgets.h
index 40386153be..88bc931336 100644
--- a/src/plugins/accessible/widgets/simplewidgets.h
+++ b/src/plugins/accessible/widgets/simplewidgets.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -109,9 +109,9 @@ public:
void *interface_cast(QAccessible::InterfaceType t);
// QAccessibleImageInterface
- QString imageDescription();
- QSize imageSize();
- QRect imagePosition(QAccessible2::CoordinateType coordType);
+ QString imageDescription() const;
+ QSize imageSize() const;
+ QRect imagePosition(QAccessible2::CoordinateType coordType) const;
};
#ifndef QT_NO_LINEEDIT
@@ -124,28 +124,27 @@ public:
QString text(QAccessible::Text t) const;
void setText(QAccessible::Text t, const QString &text);
QAccessible::State state() const;
- QVariant invokeMethod(QAccessible::Method method, const QVariantList &params);
void *interface_cast(QAccessible::InterfaceType t);
// QAccessibleTextInterface
void addSelection(int startOffset, int endOffset);
- QString attributes(int offset, int *startOffset, int *endOffset);
- int cursorPosition();
- QRect characterRect(int offset, QAccessible2::CoordinateType coordType);
- int selectionCount();
- int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType);
- void selection(int selectionIndex, int *startOffset, int *endOffset);
- QString text(int startOffset, int endOffset);
+ QString attributes(int offset, int *startOffset, int *endOffset) const;
+ int cursorPosition() const;
+ QRect characterRect(int offset, QAccessible2::CoordinateType coordType) const;
+ int selectionCount() const;
+ int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType) const;
+ void selection(int selectionIndex, int *startOffset, int *endOffset) const;
+ QString text(int startOffset, int endOffset) const;
QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType,
- int *startOffset, int *endOffset);
+ int *startOffset, int *endOffset) const;
QString textAfterOffset(int offset, QAccessible2::BoundaryType boundaryType,
- int *startOffset, int *endOffset);
+ int *startOffset, int *endOffset) const;
QString textAtOffset(int offset, QAccessible2::BoundaryType boundaryType,
- int *startOffset, int *endOffset);
+ int *startOffset, int *endOffset) const;
void removeSelection(int selectionIndex);
void setCursorPosition(int position);
void setSelection(int selectionIndex, int startOffset, int endOffset);
- int characterCount();
+ int characterCount() const;
void scrollToSubstring(int startIndex, int endIndex);
protected:
@@ -161,9 +160,9 @@ public:
void *interface_cast(QAccessible::InterfaceType t);
// QAccessibleValueInterface
- QVariant currentValue();
- QVariant maximumValue();
- QVariant minimumValue();
+ QVariant currentValue() const;
+ QVariant maximumValue() const;
+ QVariant minimumValue() const;
inline void setCurrentValue(const QVariant &) {}
protected: