/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
QT_BEGIN_NAMESPACE
+#ifndef QT_NO_ACCESSIBILITY
+
QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
- : QDeclarativeAccessible(item)
+ : QQmlAccessible(item)
{
}
QRect QAccessibleQuickItem::viewRect() const
{
- // ### no canvas in some cases.
- if (!item()->canvas()) {
+ // ### no window in some cases.
+ if (!item()->window()) {
return QRect();
}
- QQuickCanvas *canvas = item()->canvas();
- QPoint screenPos = canvas->mapToGlobal(QPoint(0,0));
- return QRect(screenPos, canvas->size());
+ QQuickWindow *window = item()->window();
+ QPoint screenPos = window->mapToGlobal(QPoint(0,0));
+ return QRect(screenPos, window->size());
}
{
QQuickItem *parent = item()->parentItem();
if (parent) {
- QQuickCanvas *canvas = item()->canvas();
+ QQuickWindow *window = item()->window();
// Jump out to the scene widget if the parent is the root item.
- // There are two root items, QQuickCanvas::rootItem and
+ // There are two root items, QQuickWindow::rootItem and
// QQuickView::declarativeRoot. The former is the true root item,
// but is not a part of the accessibility tree. Check if we hit
// it here and return an interface for the scene instead.
- if (parent == canvas->rootItem()) {
- return QAccessible::queryAccessibleInterface(canvas);
+ if (window && (parent == window->contentItem())) {
+ return QAccessible::queryAccessibleInterface(window);
} else {
- QDeclarativeAccessible *ancestor = new QAccessibleQuickItem(parent);
- return ancestor;
+ return QAccessible::queryAccessibleInterface(parent);
}
}
return 0;
if (!child) // FIXME can this happen?
return 0;
- return new QAccessibleQuickItem(child);
-}
-
-int QAccessibleQuickItem::navigate(QAccessible::RelationFlag rel, int entry, QAccessibleInterface **target) const
-{
- Q_UNUSED(rel);
- Q_UNUSED(entry);
- Q_UNUSED(target);
- *target = 0;
- if (entry == 0) {
- *target = new QAccessibleQuickItem(item());
- return 0;
- }
- return -1;
+ return QAccessible::queryAccessibleInterface(child);
}
int QAccessibleQuickItem::indexOfChild(const QAccessibleInterface *iface) const
role() == QAccessible::PageTab ||
role() == QAccessible::ProgressBar)
return QList<QQuickItem *>();
- return item()->childItems();
+
+ QList<QQuickItem *> items;
+ Q_FOREACH (QQuickItem *child, item()->childItems()) {
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(child);
+ if (itemPrivate->isAccessible)
+ items.append(child);
+ }
+ return items;
}
QAccessible::State QAccessibleQuickItem::state() const
if (item()->hasActiveFocus())
state.focused = true;
+ if (!item()->window() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+ state.invisible = true;
+
QAccessible::Role r = role();
switch (r) {
case QAccessible::Button: {
}
case QAccessible::CheckBox:
case QAccessible::RadioButton: {
- // FIXME when states are extended: state.checkable = true;
+ state.checkable = true;
state.checked = item()->property("checked").toBool();
break;
}
#ifdef Q_ACCESSIBLE_QUICK_ITEM_ENABLE_DEBUG_DESCRIPTION
case QAccessible::DebugDescription: {
QString debugString;
- debugString = QString::fromAscii(object()->metaObject()->className()) + QLatin1Char(' ');
+ debugString = QString::fromLatin1(object()->metaObject()->className()) + QLatin1Char(' ');
debugString += isAccessible() ? QLatin1String("enabled") : QLatin1String("disabled");
return debugString;
break; }
} else if (textType == QAccessible::Name) {
return object()->objectName();
}
- } else {
- if (textType == QAccessible::Name) {
- QVariant text = object()->property("text");
- return text.toString();
- }
}
return QString();
*/
QRect itemScreenRect(QQuickItem *item)
{
- // ### no canvas in some cases.
+ // ### no window in some cases.
// ### Should we really check for 0 opacity?
- if (!item->canvas() ||!item->isVisible() || qFuzzyIsNull(item->opacity())) {
+ if (!item->window() ||!item->isVisible() || qFuzzyIsNull(item->opacity())) {
return QRect();
}
// parent size. WE MIGHT HAVE TO REVISIT THESE FALLBACKS.
if (itemSize.isEmpty()) {
itemSize = QSize((int)item->implicitWidth(), (int)item->implicitHeight());
- if (itemSize.isEmpty())
+ if (itemSize.isEmpty() && item->parentItem())
// ### Seems that the above fallback is not enough, fallback to use the parent size...
itemSize = QSize((int)item->parentItem()->width(), (int)item->parentItem()->height());
}
QPointF scenePoint = item->mapToScene(QPointF(0, 0));
- QPoint screenPos = item->canvas()->mapToGlobal(scenePoint.toPoint());
+ QPoint screenPos = item->window()->mapToGlobal(scenePoint.toPoint());
return QRect(screenPos, itemSize);
}
-
+#endif // QT_NO_ACCESSIBILITY
QT_END_NAMESPACE