summaryrefslogtreecommitdiffstats
path: root/src/plugins/accessible/compat
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-23 09:18:55 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-23 09:18:55 (GMT)
commite5fcad302d86d316390c6b0f62759a067313e8a9 (patch)
treec2afbf6f1066b6ce261f14341cf6d310e5595bc1 /src/plugins/accessible/compat
downloadQt-e5fcad302d86d316390c6b0f62759a067313e8a9.zip
Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.gz
Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.bz2
Long live Qt 4.5!
Diffstat (limited to 'src/plugins/accessible/compat')
-rw-r--r--src/plugins/accessible/compat/compat.pro20
-rw-r--r--src/plugins/accessible/compat/main.cpp130
-rw-r--r--src/plugins/accessible/compat/q3complexwidgets.cpp340
-rw-r--r--src/plugins/accessible/compat/q3complexwidgets.h88
-rw-r--r--src/plugins/accessible/compat/q3simplewidgets.cpp133
-rw-r--r--src/plugins/accessible/compat/q3simplewidgets.h63
-rw-r--r--src/plugins/accessible/compat/qaccessiblecompat.cpp843
-rw-r--r--src/plugins/accessible/compat/qaccessiblecompat.h168
8 files changed, 1785 insertions, 0 deletions
diff --git a/src/plugins/accessible/compat/compat.pro b/src/plugins/accessible/compat/compat.pro
new file mode 100644
index 0000000..0ad5a9a
--- /dev/null
+++ b/src/plugins/accessible/compat/compat.pro
@@ -0,0 +1,20 @@
+TARGET = qtaccessiblecompatwidgets
+CONFIG += qt_no_compat_warning
+include(../../qpluginbase.pri)
+include (../qaccessiblebase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/accessible
+
+QTDIR_build:REQUIRES += "contains(QT_CONFIG, accessibility)"
+
+QT += qt3support
+
+SOURCES += main.cpp \
+ q3simplewidgets.cpp \
+ q3complexwidgets.cpp \
+ qaccessiblecompat.cpp
+
+HEADERS += qaccessiblecompat.h \
+ q3complexwidgets.h \
+ q3simplewidgets.h
+
diff --git a/src/plugins/accessible/compat/main.cpp b/src/plugins/accessible/compat/main.cpp
new file mode 100644
index 0000000..fae5595
--- /dev/null
+++ b/src/plugins/accessible/compat/main.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qaccessiblecompat.h"
+#include "q3simplewidgets.h"
+#include "q3complexwidgets.h"
+
+#include <qaccessibleplugin.h>
+#include <qplugin.h>
+#include <qstringlist.h>
+#include <q3toolbar.h>
+
+QT_BEGIN_NAMESPACE
+
+class CompatAccessibleFactory : public QAccessiblePlugin
+{
+public:
+ CompatAccessibleFactory();
+
+ QStringList keys() const;
+ QAccessibleInterface *create(const QString &classname, QObject *object);
+};
+
+CompatAccessibleFactory::CompatAccessibleFactory()
+{
+}
+
+QStringList CompatAccessibleFactory::keys() const
+{
+ QStringList list;
+ list << QLatin1String("Q3TextEdit");
+ list << QLatin1String("Q3IconView");
+ list << QLatin1String("Q3ListView");
+ list << QLatin1String("Q3WidgetStack");
+ list << QLatin1String("Q3GroupBox");
+ list << QLatin1String("Q3ToolBar");
+ list << QLatin1String("Q3ToolBarSeparator");
+ list << QLatin1String("Q3DockWindowHandle");
+ list << QLatin1String("Q3DockWindowResizeHandle");
+ list << QLatin1String("Q3MainWindow");
+ list << QLatin1String("Q3Header");
+ list << QLatin1String("Q3ListBox");
+ list << QLatin1String("Q3Table");
+ list << QLatin1String("Q3TitleBar");
+
+ return list;
+}
+
+QAccessibleInterface *CompatAccessibleFactory::create(const QString &classname, QObject *object)
+{
+ QAccessibleInterface *iface = 0;
+ if (!object || !object->isWidgetType())
+ return iface;
+ QWidget *widget = static_cast<QWidget*>(object);
+
+ if (classname == QLatin1String("Q3TextEdit")) {
+ iface = new Q3AccessibleTextEdit(widget);
+ } else if (classname == QLatin1String("Q3IconView")) {
+ iface = new QAccessibleIconView(widget);
+ } else if (classname == QLatin1String("Q3ListView")) {
+ iface = new QAccessibleListView(widget);
+ } else if (classname == QLatin1String("Q3WidgetStack")) {
+ iface = new QAccessibleWidgetStack(widget);
+ } else if (classname == QLatin1String("Q3ListBox")) {
+ iface = new QAccessibleListBox(widget);
+ } else if (classname == QLatin1String("Q3Table")) {
+ iface = new Q3AccessibleScrollView(widget, Table);
+ } else if (classname == QLatin1String("Q3GroupBox")) {
+ iface = new Q3AccessibleDisplay(widget, Grouping);
+ } else if (classname == QLatin1String("Q3ToolBar")) {
+ iface = new QAccessibleWidget(widget, ToolBar, static_cast<Q3ToolBar *>(widget)->label());
+ } else if (classname == QLatin1String("Q3MainWindow")) {
+ iface = new QAccessibleWidget(widget, Application);
+ } else if (classname == QLatin1String("Q3ToolBarSeparator")) {
+ iface = new QAccessibleWidget(widget, Separator);
+ } else if (classname == QLatin1String("Q3DockWindowHandle")) {
+ iface = new QAccessibleWidget(widget, Grip);
+ } else if (classname == QLatin1String("Q3DockWindowResizeHandle")) {
+ iface = new QAccessibleWidget(widget, Grip);
+ } else if (classname == QLatin1String("Q3Header")) {
+ iface = new Q3AccessibleHeader(widget);
+ } else if (classname == QLatin1String("Q3TitleBar")) {
+ iface = new Q3AccessibleTitleBar(widget);
+ }
+
+ return iface;
+}
+
+Q_EXPORT_STATIC_PLUGIN(CompatAccessibleFactory)
+Q_EXPORT_PLUGIN2(qtaccessiblecompatwidgets, CompatAccessibleFactory)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/accessible/compat/q3complexwidgets.cpp b/src/plugins/accessible/compat/q3complexwidgets.cpp
new file mode 100644
index 0000000..ab7e698
--- /dev/null
+++ b/src/plugins/accessible/compat/q3complexwidgets.cpp
@@ -0,0 +1,340 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "q3complexwidgets.h"
+
+#include <q3header.h>
+#include <private/q3titlebar_p.h>
+
+#include <qapplication.h>
+
+QT_BEGIN_NAMESPACE
+
+Q3AccessibleHeader::Q3AccessibleHeader(QWidget *w)
+ : QAccessibleWidget(w)
+{
+ Q_ASSERT(header());
+ addControllingSignal(QLatin1String("clicked(int)"));
+}
+
+/*! Returns the Q3Header. */
+Q3Header *Q3AccessibleHeader::header() const
+{
+ return qobject_cast<Q3Header*>(object());
+}
+
+/*! \reimp */
+QRect Q3AccessibleHeader::rect(int child) const
+{
+ QPoint zero = header()->mapToGlobal(QPoint(0, 0));
+ QRect sect = header()->sectionRect(child - 1);
+ return QRect(sect.x() + zero.x(), sect.y() + zero.y(), sect.width(), sect.height());
+}
+
+/*! \reimp */
+int Q3AccessibleHeader::childCount() const
+{
+ return header()->count();
+}
+
+/*! \reimp */
+QString Q3AccessibleHeader::text(Text t, int child) const
+{
+ QString str;
+
+ if (child <= childCount()) {
+ switch (t) {
+ case Name:
+ str = header()->label(child - 1);
+ 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;
+}
+
+/*! \reimp */
+QAccessible::Role Q3AccessibleHeader::role(int) const
+{
+ return (header()->orientation() == Qt::Horizontal) ? ColumnHeader : RowHeader;
+}
+
+/*! \reimp */
+QAccessible::State Q3AccessibleHeader::state(int child) const
+{
+ State state = QAccessibleWidget::state(child);
+
+ int section = child ? child - 1 : -1;
+ if (!header()->isClickEnabled(section))
+ state |= Unavailable;
+ else
+ state |= Selectable;
+ if (child && section == header()->sortIndicatorSection())
+ state |= Selected;
+ if (header()->isResizeEnabled(section))
+ state |= Sizeable;
+ if (child && header()->isMovingEnabled())
+ state |= Movable;
+ return state;
+}
+
+/*!
+ \class Q3AccessibleTitleBar
+ \brief The Q3AccessibleTitleBar class implements the QAccessibleInterface for title bars.
+ \internal
+
+ \ingroup accessibility
+*/
+
+/*!
+ Constructs a Q3AccessibleTitleBar object for \a w.
+*/
+Q3AccessibleTitleBar::Q3AccessibleTitleBar(QWidget *w)
+: QAccessibleWidget(w, TitleBar)
+{
+ Q_ASSERT(titleBar());
+}
+
+/*!
+ Returns the title bar.
+*/
+Q3TitleBar *Q3AccessibleTitleBar::titleBar() const
+{
+ return qobject_cast<Q3TitleBar*>(object());
+}
+
+/*! \reimp */
+QRect Q3AccessibleTitleBar::rect(int child) const
+{
+ if (!child)
+ return QAccessibleWidget::rect(child);
+
+ QStyle::SubControl sc;
+ switch (child) {
+ case 1:
+ sc = QStyle::SC_TitleBarSysMenu;
+ break;
+ case 2:
+ sc = QStyle::SC_TitleBarLabel;
+ break;
+ case 3:
+ sc = QStyle::SC_TitleBarMinButton;
+ break;
+ case 4:
+ sc = QStyle::SC_TitleBarMaxButton;
+ break;
+ case 5:
+ sc = QStyle::SC_TitleBarCloseButton;
+ break;
+ default:
+ sc = QStyle::SC_None;
+ break;
+ }
+
+ QRect r;
+ if (sc != QStyle::SC_None) {
+ QStyleOptionTitleBar option;
+ r = titleBar()->style()->subControlRect(QStyle::CC_TitleBar, &option, sc, titleBar());
+ }
+
+ QPoint tp = titleBar()->mapToGlobal(QPoint(0,0));
+ return QRect(tp.x() + r.x(), tp.y() + r.y(), r.width(), r.height());
+}
+
+/* \reimp
+int Q3AccessibleTitleBar::navigate(NavDirection direction, int startControl) const
+{
+ if (direction != NavFirstChild && direction != NavLastChild && direction != NavFocusChild && !startControl)
+ return QAccessibleWidget::navigate(direction, startControl);
+
+ switch (direction) {
+ case NavFirstChild:
+ return 1;
+ break;
+ case NavLastChild:
+ return childCount();
+ break;
+ case NavNext:
+ case NavRight:
+ return startControl + 1 > childCount() ? -1 : startControl + 1;
+ case NavPrevious:
+ case NavLeft:
+ return startControl -1 < 1 ? -1 : startControl - 1;
+ default:
+ break;
+ }
+ return -1;
+}
+*/
+
+/*! \reimp */
+int Q3AccessibleTitleBar::childCount() const
+{
+ if (!(titleBar()->windowFlags() & Qt::WStyle_SysMenu))
+ return 0;
+ int control = 3;
+ if (!(titleBar()->windowFlags() & Qt::WStyle_Minimize))
+ ++control;
+ if (!(titleBar()->windowFlags() & Qt::WStyle_Maximize))
+ ++control;
+ return control;
+}
+
+/*! \reimp */
+QString Q3AccessibleTitleBar::text(Text t, int child) const
+{
+ QString str = QAccessibleWidget::text(t, child);
+ if (str.size())
+ return str;
+
+ QWidget *window = titleBar()->window();
+ switch (t) {
+ case Name:
+ switch (child) {
+ case 1:
+ return Q3TitleBar::tr("System");
+ case 3:
+ if (window && window->isMinimized())
+ return Q3TitleBar::tr("Restore up");
+ return Q3TitleBar::tr("Minimize");
+ case 4:
+ if (window && window->isMaximized())
+ return Q3TitleBar::tr("Restore down");
+ return Q3TitleBar::tr("Maximize");
+ case 5:
+ return Q3TitleBar::tr("Close");
+ default:
+ break;
+ }
+ break;
+ case Value:
+ if (!child || child == 2)
+ return window ? window->windowTitle() : QString();
+ break;
+/*
+ case DefaultAction:
+ if (child > 2)
+ return Q3TitleBar::tr("Press");
+ break;
+*/
+ case Description:
+ switch (child) {
+ case 1:
+ return Q3TitleBar::tr("Contains commands to manipulate the window");
+ case 3:
+ if (window && window->isMinimized())
+ return Q3TitleBar::tr("Puts a minimized back to normal");
+ return Q3TitleBar::tr("Moves the window out of the way");
+ case 4:
+ if (window && window->isMaximized())
+ return Q3TitleBar::tr("Puts a maximized window back to normal");
+ return Q3TitleBar::tr("Makes the window full screen");
+ case 5:
+ return Q3TitleBar::tr("Closes the window");
+ default:
+ return Q3TitleBar::tr("Displays the name of the window and contains controls to manipulate it");
+ }
+ default:
+ break;
+ }
+ return str;
+}
+
+/*! \reimp */
+QAccessible::Role Q3AccessibleTitleBar::role(int child) const
+{
+ switch (child)
+ {
+ case 1:
+ case 3:
+ case 4:
+ case 5:
+ return PushButton;
+ default:
+ return TitleBar;
+ }
+}
+
+/*! \reimp */
+QAccessible::State Q3AccessibleTitleBar::state(int child) const
+{
+ return QAccessibleWidget::state(child);
+}
+
+/*! \reimp */
+bool Q3AccessibleTitleBar::doAction(int, int child, const QVariantList &)
+{
+ switch (child) {
+ case 3:
+ if (titleBar()->window()->isMinimized())
+ titleBar()->window()->showNormal();
+ else
+ titleBar()->window()->showMinimized();
+ return true;
+ case 4:
+ if (titleBar()->window()->isMaximized())
+ titleBar()->window()->showNormal();
+ else
+ titleBar()->window()->showMaximized();
+ return true;
+ case 5:
+ titleBar()->window()->close();
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/accessible/compat/q3complexwidgets.h b/src/plugins/accessible/compat/q3complexwidgets.h
new file mode 100644
index 0000000..e434a16
--- /dev/null
+++ b/src/plugins/accessible/compat/q3complexwidgets.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef Q3COMPLEXWIDGETS_H
+#define Q3COMPLEXWIDGETS_H
+
+#include <QtGui/qaccessiblewidget.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q3Header;
+class Q3TitleBar;
+
+class Q3AccessibleHeader : public QAccessibleWidget
+{
+public:
+ explicit Q3AccessibleHeader(QWidget *w);
+
+ int childCount() const;
+
+ QRect rect(int child) const;
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+
+protected:
+ Q3Header *header() const;
+};
+
+class Q3AccessibleTitleBar : public QAccessibleWidget
+{
+public:
+ explicit Q3AccessibleTitleBar(QWidget *w);
+
+ int childCount() const;
+
+ QString text(Text t, int child) const;
+ QRect rect(int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+
+ bool doAction(int action, int child, const QVariantList &params);
+
+protected:
+ Q3TitleBar *titleBar() const;
+};
+
+QT_END_NAMESPACE
+
+#endif // Q3COMPLEXWIDGETS_H
diff --git a/src/plugins/accessible/compat/q3simplewidgets.cpp b/src/plugins/accessible/compat/q3simplewidgets.cpp
new file mode 100644
index 0000000..686e235
--- /dev/null
+++ b/src/plugins/accessible/compat/q3simplewidgets.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "q3simplewidgets.h"
+
+#include <q3groupbox.h>
+#include <qlabel.h>
+
+QT_BEGIN_NAMESPACE
+
+QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
+
+Q3AccessibleDisplay::Q3AccessibleDisplay(QWidget *w, Role role)
+: QAccessibleWidget(w, role)
+{
+}
+
+/*! \reimp */
+QAccessible::Role Q3AccessibleDisplay::role(int child) const
+{
+ QLabel *l = qobject_cast<QLabel*>(object());
+ if (l) {
+ if (l->pixmap() || l->picture())
+ return Graphic;
+ if (l->picture())
+ return Graphic;
+ if (l->movie())
+ return Animation;
+ }
+ return QAccessibleWidget::role(child);
+}
+
+/*! \reimp */
+QString Q3AccessibleDisplay::text(Text t, int child) const
+{
+ QString str;
+ switch (t) {
+ case Name:
+ if (qobject_cast<QLabel*>(object())) {
+ str = qobject_cast<QLabel*>(object())->text();
+ } else if (qobject_cast<Q3GroupBox*>(object())) {
+ str = qobject_cast<Q3GroupBox*>(object())->title();
+ }
+ break;
+ default:
+ break;
+ }
+ if (str.isEmpty())
+ str = QAccessibleWidget::text(t, child);;
+ return qt_accStripAmp(str);
+}
+
+/*! \reimp */
+QAccessible::Relation Q3AccessibleDisplay::relationTo(int child, const QAccessibleInterface *other,
+ int otherChild) const
+{
+ Relation relation = QAccessibleWidget::relationTo(child, other, otherChild);
+ if (child || otherChild)
+ return relation;
+
+ QObject *o = other->object();
+ QLabel *label = qobject_cast<QLabel*>(object());
+ Q3GroupBox *groupbox = qobject_cast<Q3GroupBox*>(object());
+ if (label) {
+ if (o == label->buddy())
+ relation |= Label;
+ } else if (groupbox && !groupbox->title().isEmpty()) {
+ if (groupbox->children().contains(o))
+ relation |= Label;
+ }
+ return relation;
+}
+
+/*! \reimp */
+int Q3AccessibleDisplay::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const
+{
+ *target = 0;
+ if (rel == Labelled) {
+ QObject *targetObject = 0;
+ QLabel *label = qobject_cast<QLabel*>(object());
+ Q3GroupBox *groupbox = qobject_cast<Q3GroupBox*>(object());
+ if (label) {
+ if (entry == 1)
+ targetObject = label->buddy();
+ } else if (groupbox && !groupbox->title().isEmpty()) {
+ rel = Child;
+ }
+ *target = QAccessible::queryAccessibleInterface(targetObject);
+ if (*target)
+ return 0;
+ }
+ return QAccessibleWidget::navigate(rel, entry, target);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/accessible/compat/q3simplewidgets.h b/src/plugins/accessible/compat/q3simplewidgets.h
new file mode 100644
index 0000000..5719e3a
--- /dev/null
+++ b/src/plugins/accessible/compat/q3simplewidgets.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef Q3SIMPLEWIDGETS_H
+#define Q3SIMPLEWIDGETS_H
+
+#include <QtGui/qaccessiblewidget.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q3AccessibleDisplay : public QAccessibleWidget
+{
+public:
+ explicit Q3AccessibleDisplay(QWidget *w, Role role = StaticText);
+
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+
+ Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
+ int navigate(RelationFlag, int entry, QAccessibleInterface **target) const;
+};
+
+QT_END_NAMESPACE
+
+#endif // Q3SIMPLEWIDGETS_H
diff --git a/src/plugins/accessible/compat/qaccessiblecompat.cpp b/src/plugins/accessible/compat/qaccessiblecompat.cpp
new file mode 100644
index 0000000..28637a3
--- /dev/null
+++ b/src/plugins/accessible/compat/qaccessiblecompat.cpp
@@ -0,0 +1,843 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qaccessiblecompat.h"
+#include "q3widgetstack.h"
+
+#include <q3listview.h>
+#include <q3textedit.h>
+#include <q3iconview.h>
+#include <q3listbox.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+\fn Q3AccessibleScrollView::Q3AccessibleScrollView(QWidget* widget, Role role)
+
+Constructs a Q3AccessibleScrollView object for a \a widget.
+The \a role is propagated to the QAccessibleWidget constructor.
+*/
+Q3AccessibleScrollView::Q3AccessibleScrollView(QWidget *w, Role role)
+: QAccessibleWidget(w, role)
+{
+}
+
+/*!
+ Returns the ID of the item at viewport position \a x, \a y.
+*/
+int Q3AccessibleScrollView::itemAt(int /*x*/, int /*y*/) const
+{
+ return 0;
+}
+
+/*!
+ Returns the location in viewport coordinates of the item with ID \a
+ item.
+*/
+QRect Q3AccessibleScrollView::itemRect(int /*item*/) const
+{
+ return QRect();
+}
+
+/*!
+ Returns the number of items in the scroll view.
+*/
+int Q3AccessibleScrollView::itemCount() const
+{
+ return 0;
+}
+
+/*!
+ \class QAccessibleListView
+ \brief The QAccessibleListView class implements the QAccessibleInterface for list views.
+ \internal
+*/
+
+static Q3ListViewItem *findLVItem(Q3ListView* listView, int child)
+{
+ int id = 1;
+ Q3ListViewItemIterator it(listView);
+ Q3ListViewItem *item = it.current();
+ while (item && id < child) {
+ ++it;
+ ++id;
+ item = it.current();
+ }
+ return item;
+}
+
+/*!
+ \fn QAccessibleListView::QAccessibleListView(QWidget* widget)
+
+ Constructs a QAccessibleListView object for a \a widget.
+*/
+QAccessibleListView::QAccessibleListView(QWidget *o)
+ : Q3AccessibleScrollView(o, Tree)
+{
+}
+
+/*! Returns the list view. */
+Q3ListView *QAccessibleListView::listView() const
+{
+ Q_ASSERT(widget()->inherits("Q3ListView"));
+ return (Q3ListView*)widget();
+}
+
+/*! \reimp */
+int QAccessibleListView::itemAt(int x, int y) const
+{
+ Q3ListViewItem *item = listView()->itemAt(QPoint(x, y));
+ if (!item)
+ return 0;
+
+ Q3ListViewItemIterator it(listView());
+ int c = 1;
+ while (it.current()) {
+ if (it.current() == item)
+ return c;
+ ++c;
+ ++it;
+ }
+ return 0;
+}
+
+/*! \reimp */
+QRect QAccessibleListView::itemRect(int child) const
+{
+ Q3ListViewItem *item = findLVItem(listView(), child);
+ if (!item)
+ return QRect();
+ return listView()->itemRect(item);
+}
+
+/*! \reimp */
+int QAccessibleListView::itemCount() const
+{
+ Q3ListViewItemIterator it(listView());
+ int c = 0;
+ while (it.current()) {
+ ++c;
+ ++it;
+ }
+
+ return c;
+}
+
+/*! \reimp */
+QString QAccessibleListView::text(Text t, int child) const
+{
+ if (!child || t != Name)
+ return Q3AccessibleScrollView::text(t, child);
+
+ Q3ListViewItem *item = findLVItem(listView(), child);
+ if (!item)
+ return QString();
+ return item->text(0);
+}
+
+/*! \reimp */
+QAccessible::Role QAccessibleListView::role(int child) const
+{
+ if (!child)
+ return Q3AccessibleScrollView::role(child);
+ return TreeItem;
+}
+
+/*! \reimp */
+QAccessible::State QAccessibleListView::state(int child) const
+{
+ State state = Q3AccessibleScrollView::state(child);
+ Q3ListViewItem *item;
+ if (!child || !(item = findLVItem(listView(), child)))
+ return state;
+
+ if (item->isSelectable()) {
+ if (listView()->selectionMode() == Q3ListView::Multi)
+ state |= MultiSelectable;
+ else if (listView()->selectionMode() == Q3ListView::Extended)
+ state |= ExtSelectable;
+ else if (listView()->selectionMode() == Q3ListView::Single)
+ state |= Selectable;
+ if (item->isSelected())
+ state |= Selected;
+ }
+ if (listView()->focusPolicy() != Qt::NoFocus) {
+ state |= Focusable;
+ if (item == listView()->currentItem())
+ state |= Focused;
+ }
+ if (item->childCount()) {
+ if (item->isOpen())
+ state |= Expanded;
+ else
+ state |= Collapsed;
+ }
+ if (!listView()->itemRect(item).isValid())
+ state |= Invisible;
+
+ if (item->rtti() == Q3CheckListItem::RTTI) {
+ if (((Q3CheckListItem*)item)->isOn())
+ state|=Checked;
+ }
+ return state;
+}
+
+/* \reimp
+QAccessibleInterface *QAccessibleListView::focusChild(int *child) const
+{
+ Q3ListViewItem *item = listView()->currentItem();
+ if (!item)
+ return 0;
+
+ Q3ListViewItemIterator it(listView());
+ int c = 1;
+ while (it.current()) {
+ if (it.current() == item) {
+ *child = c;
+ return (QAccessibleInterface*)this;
+ }
+ ++c;
+ ++it;
+ }
+ return 0;
+}
+*/
+/* \reimp
+bool QAccessibleListView::setFocus(int child)
+{
+ bool res = Q3AccessibleScrollView::setFocus(0);
+ if (!child || !res)
+ return res;
+
+ Q3ListViewItem *item = findLVItem(listView(), child);
+ if (!item)
+ return false;
+ listView()->setCurrentItem(item);
+ return true;
+}*/
+
+/*! \internal */
+bool QAccessibleListView::setSelected(int child, bool on, bool extend)
+{
+ if (!child || (extend &&
+ listView()->selectionMode() != Q3ListView::Extended &&
+ listView()->selectionMode() != Q3ListView::Multi))
+ return false;
+
+ Q3ListViewItem *item = findLVItem(listView(), child);
+ if (!item)
+ return false;
+ if (!extend) {
+ listView()->setSelected(item, on);
+ } else {
+ Q3ListViewItem *current = listView()->currentItem();
+ if (!current)
+ return false;
+ bool down = item->itemPos() > current->itemPos();
+ Q3ListViewItemIterator it(current);
+ while (it.current()) {
+ listView()->setSelected(it.current(), on);
+ if (it.current() == item)
+ break;
+ if (down)
+ ++it;
+ else
+ --it;
+ }
+ }
+ return true;
+}
+
+/*! \internal */
+void QAccessibleListView::clearSelection()
+{
+ listView()->clearSelection();
+}
+
+/*! \internal */
+QVector<int> QAccessibleListView::selection() const
+{
+ QVector<int> array;
+ uint size = 0;
+ int id = 1;
+ array.resize(size);
+ Q3ListViewItemIterator it(listView());
+ while (it.current()) {
+ if (it.current()->isSelected()) {
+ ++size;
+ array.resize(size);
+ array[(int)size-1] = id;
+ }
+ ++it;
+ ++id;
+ }
+ return array;
+}
+
+/*!
+ \class QAccessibleIconView
+ \brief The QAccessibleIconView class implements the QAccessibleInterface for icon views.
+ \internal
+*/
+
+static Q3IconViewItem *findIVItem(Q3IconView *iconView, int child)
+{
+ int id = 1;
+ Q3IconViewItem *item = iconView->firstItem();
+ while (item && id < child) {
+ item = item->nextItem();
+ ++id;
+ }
+
+ return item;
+}
+
+/*!
+ \fn QAccessibleIconView::QAccessibleIconView(QWidget* widget)
+
+ Constructs a QAccessibleIconView object for a \a widget.
+*/
+QAccessibleIconView::QAccessibleIconView(QWidget *o)
+ : Q3AccessibleScrollView(o, List)
+{
+ Q_ASSERT(widget()->inherits("Q3IconView"));
+}
+
+/*! Returns the icon view. */
+Q3IconView *QAccessibleIconView::iconView() const
+{
+ return (Q3IconView*)widget();
+}
+
+/*! \internal */
+int QAccessibleIconView::itemAt(int x, int y) const
+{
+ Q3IconViewItem *item = iconView()->findItem(QPoint(x, y));
+ return iconView()->index(item) + 1;
+}
+
+/*! \internal */
+QRect QAccessibleIconView::itemRect(int child) const
+{
+ Q3IconViewItem *item = findIVItem(iconView(), child);
+
+ if (!item)
+ return QRect();
+ return item->rect();
+}
+
+/*! \internal */
+int QAccessibleIconView::itemCount() const
+{
+ return iconView()->count();
+}
+
+/*! \internal */
+QString QAccessibleIconView::text(Text t, int child) const
+{
+ if (!child || t != Name)
+ return Q3AccessibleScrollView::text(t, child);
+
+ Q3IconViewItem *item = findIVItem(iconView(), child);
+ if (!item)
+ return QString();
+ return item->text();
+}
+
+/*! \internal */
+QAccessible::Role QAccessibleIconView::role(int child) const
+{
+ if (!child)
+ return Q3AccessibleScrollView::role(child);
+ return ListItem;
+}
+
+/*! \internal */
+QAccessible::State QAccessibleIconView::state(int child) const
+{
+ State state = Q3AccessibleScrollView::state(child);
+ Q3IconViewItem *item;
+ if (!child || !(item = findIVItem(iconView(), child)))
+ return state;
+
+ if (item->isSelectable()) {
+ if (iconView()->selectionMode() == Q3IconView::Multi)
+ state |= MultiSelectable;
+ else if (iconView()->selectionMode() == Q3IconView::Extended)
+ state |= ExtSelectable;
+ else if (iconView()->selectionMode() == Q3IconView::Single)
+ state |= Selectable;
+ if (item->isSelected())
+ state |= Selected;
+ }
+ if (iconView()->itemsMovable())
+ state |= Movable;
+ if (iconView()->focusPolicy() != Qt::NoFocus) {
+ state |= Focusable;
+ if (item == iconView()->currentItem())
+ state |= Focused;
+ }
+
+ return state;
+}
+
+/* \reimp
+QAccessibleInterface *QAccessibleIconView::focusChild(int *child) const
+{
+ Q3IconViewItem *item = iconView()->currentItem();
+ if (!item)
+ return 0;
+
+ *child = iconView()->index(item);
+ return (QAccessibleInterface*)this;
+}
+*/
+/* \reimp
+bool QAccessibleIconView::setFocus(int child)
+{
+ bool res = Q3AccessibleScrollView::setFocus(0);
+ if (!child || !res)
+ return res;
+
+ Q3IconViewItem *item = findIVItem(iconView(), child);
+ if (!item)
+ return false;
+ iconView()->setCurrentItem(item);
+ return true;
+}*/
+
+/*! \internal */
+bool QAccessibleIconView::setSelected(int child, bool on, bool extend)
+{
+ if (!child || (extend &&
+ iconView()->selectionMode() != Q3IconView::Extended &&
+ iconView()->selectionMode() != Q3IconView::Multi))
+ return false;
+
+ Q3IconViewItem *item = findIVItem(iconView(), child);
+ if (!item)
+ return false;
+ if (!extend) {
+ iconView()->setSelected(item, on, true);
+ } else {
+ Q3IconViewItem *current = iconView()->currentItem();
+ if (!current)
+ return false;
+ bool down = false;
+ Q3IconViewItem *temp = current;
+ while ((temp = temp->nextItem())) {
+ if (temp == item) {
+ down = true;
+ break;
+ }
+ }
+ temp = current;
+ if (down) {
+ while ((temp = temp->nextItem())) {
+ iconView()->setSelected(temp, on, true);
+ if (temp == item)
+ break;
+ }
+ } else {
+ while ((temp = temp->prevItem())) {
+ iconView()->setSelected(temp, on, true);
+ if (temp == item)
+ break;
+ }
+ }
+ }
+ return true;
+}
+
+/*! \internal */
+void QAccessibleIconView::clearSelection()
+{
+ iconView()->clearSelection();
+}
+
+/*! \internal */
+QVector<int> QAccessibleIconView::selection() const
+{
+ QVector<int> array;
+ uint size = 0;
+ int id = 1;
+ array.resize(iconView()->count());
+ Q3IconViewItem *item = iconView()->firstItem();
+ while (item) {
+ if (item->isSelected()) {
+ ++size;
+ array[(int)size-1] = id;
+ }
+ item = item->nextItem();
+ ++id;
+ }
+ array.resize(size);
+ return array;
+}
+
+
+/*!
+ \class Q3AccessibleTextEdit
+ \brief The Q3AccessibleTextEdit class implements the QAccessibleInterface for richtext editors.
+ \internal
+*/
+
+/*!
+ \fn Q3AccessibleTextEdit::Q3AccessibleTextEdit(QWidget* widget)
+
+ Constructs a Q3AccessibleTextEdit object for a \a widget.
+*/
+Q3AccessibleTextEdit::Q3AccessibleTextEdit(QWidget *o)
+: Q3AccessibleScrollView(o, Pane)
+{
+ Q_ASSERT(widget()->inherits("Q3TextEdit"));
+}
+
+/*! Returns the text edit. */
+Q3TextEdit *Q3AccessibleTextEdit::textEdit() const
+{
+
+ return (Q3TextEdit*)widget();
+}
+
+/*! \reimp */
+int Q3AccessibleTextEdit::itemAt(int x, int y) const
+{
+ int p;
+ QPoint cp = textEdit()->viewportToContents(QPoint(x,y));
+ textEdit()->charAt(cp , &p);
+ return p + 1;
+}
+
+/*! \reimp */
+QRect Q3AccessibleTextEdit::itemRect(int item) const
+{
+ QRect rect = textEdit()->paragraphRect(item - 1);
+ if (!rect.isValid())
+ return QRect();
+ QPoint ntl = textEdit()->contentsToViewport(QPoint(rect.x(), rect.y()));
+ return QRect(ntl.x(), ntl.y(), rect.width(), rect.height());
+}
+
+/*! \reimp */
+int Q3AccessibleTextEdit::itemCount() const
+{
+ return textEdit()->paragraphs();
+}
+
+/*! \reimp */
+QString Q3AccessibleTextEdit::text(Text t, int child) const
+{
+ if (t == Name && child > 0)
+ return textEdit()->text(child - 1);
+ if (t == Value) {
+ if (child > 0)
+ return textEdit()->text(child - 1);
+ else
+ return textEdit()->text();
+ }
+
+ return Q3AccessibleScrollView::text(t, child);
+}
+
+/*! \reimp */
+void Q3AccessibleTextEdit::setText(Text t, int control, const QString &text)
+{
+ if (t != Value || control) {
+ Q3AccessibleScrollView::setText(t, control, text);
+ return;
+ }
+ textEdit()->setText(text);
+}
+
+/*! \reimp */
+QAccessible::Role Q3AccessibleTextEdit::role(int child) const
+{
+ if (child)
+ return EditableText;
+ return Q3AccessibleScrollView::role(child);
+}
+
+/*!
+ \class QAccessibleWidgetStack
+ \brief The QAccessibleWidgetStack class implements the QAccessibleInterface for widget stacks.
+
+ \ingroup accessibility
+ \internal
+*/
+
+/*!
+ \fn QAccessibleWidgetStack::QAccessibleWidgetStack(QWidget* widget)
+
+ Creates a QAccessibleWidgetStack object for a \a widget.
+*/
+QAccessibleWidgetStack::QAccessibleWidgetStack(QWidget *w)
+: QAccessibleWidget(w, LayeredPane)
+{
+ Q_ASSERT(widgetStack());
+ setDescription(QLatin1String("This is a widgetstack"));
+}
+
+/*! Returns the widget stack. */
+Q3WidgetStack *QAccessibleWidgetStack::widgetStack() const
+{
+ return qobject_cast<Q3WidgetStack*>(object());
+}
+
+/*! \reimp */
+int QAccessibleWidgetStack::childCount() const
+{
+ // a widget stack has always only one accessible widget
+ return 1;
+}
+
+/*! \reimp */
+int QAccessibleWidgetStack::indexOfChild(const QAccessibleInterface *child) const
+{
+ QObject *childObject = child ? child->object() : 0;
+ if (childObject != widgetStack()->visibleWidget())
+ return -1;
+ return 1;
+}
+
+/*! \reimp */
+int QAccessibleWidgetStack::childAt(int, int) const
+{
+ QWidget *curPage = widgetStack()->visibleWidget();
+ if (!curPage)
+ return 0;
+ return 1;
+}
+
+/*! \reimp */
+int QAccessibleWidgetStack::navigate(RelationFlag rel, int entry,
+ QAccessibleInterface **target) const
+{
+ *target = 0;
+ QObject *targetObject = 0;
+ switch (rel) {
+ // Hierarchical
+ case Child:
+ if (entry != 1)
+ return -1;
+ targetObject = widgetStack()->visibleWidget();
+ break;
+ default:
+ return QAccessibleWidget::navigate(rel, entry, target);
+ }
+ *target = QAccessible::queryAccessibleInterface(targetObject);
+ return *target ? 0 : -1;
+}
+
+/*!
+ \class QAccessibleListBox
+ \brief The QAccessibleListBox class implements the QAccessibleInterface for list boxes.
+
+ \ingroup accessibility
+ \internal
+*/
+
+/*!
+ \fn QAccessibleListBox::QAccessibleListBox(QWidget* widget)
+
+ Constructs a QAccessibleListBox object for a \a widget.
+*/
+QAccessibleListBox::QAccessibleListBox(QWidget *o)
+ : Q3AccessibleScrollView(o, List)
+{
+ Q_ASSERT(widget()->inherits("Q3ListBox"));
+}
+
+/*! Returns the list box. */
+Q3ListBox *QAccessibleListBox::listBox() const
+{
+ return (Q3ListBox*)widget();
+}
+
+/*! \reimp */
+int QAccessibleListBox::itemAt(int x, int y) const
+{
+ Q3ListBoxItem *item = listBox()->itemAt(QPoint(x, y));
+ return listBox()->index(item) + 1;
+}
+
+/*! \reimp */
+QRect QAccessibleListBox::itemRect(int item) const
+{
+ return listBox()->itemRect(listBox()->item(item-1));
+}
+
+/*! \reimp */
+int QAccessibleListBox::itemCount() const
+{
+ return listBox()->count();
+}
+
+/*! \reimp */
+QString QAccessibleListBox::text(Text t, int child) const
+{
+ if (!child || t != Name)
+ return Q3AccessibleScrollView::text(t, child);
+
+ Q3ListBoxItem *item = listBox()->item(child - 1);
+ if (item)
+ return item->text();
+ return QString();
+}
+
+/*! \reimp */
+QAccessible::Role QAccessibleListBox::role(int child) const
+{
+ if (!child)
+ return Q3AccessibleScrollView::role(child);
+ return ListItem;
+}
+
+/*! \reimp */
+QAccessible::State QAccessibleListBox::state(int child) const
+{
+ State state = Q3AccessibleScrollView::state(child);
+ Q3ListBoxItem *item;
+ if (!child || !(item = listBox()->item(child - 1)))
+ return state;
+
+ if (item->isSelectable()) {
+ if (listBox()->selectionMode() == Q3ListBox::Multi)
+ state |= MultiSelectable;
+ else if (listBox()->selectionMode() == Q3ListBox::Extended)
+ state |= ExtSelectable;
+ else if (listBox()->selectionMode() == Q3ListBox::Single)
+ state |= Selectable;
+ if (item->isSelected())
+ state |= Selected;
+ }
+ if (listBox()->focusPolicy() != Qt::NoFocus) {
+ state |= Focusable;
+ if (item->isCurrent())
+ state |= Focused;
+ }
+ if (!listBox()->itemVisible(item))
+ state |= Invisible;
+
+ return state;
+}
+
+/* \reimp
+bool QAccessibleListBox::setFocus(int child)
+{
+ bool res = Q3AccessibleScrollView::setFocus(0);
+ if (!child || !res)
+ return res;
+
+ Q3ListBoxItem *item = listBox()->item(child -1);
+ if (!item)
+ return false;
+ listBox()->setCurrentItem(item);
+ return true;
+}*/
+
+/*!
+ Selects the item with index \a child if \a on is true; otherwise
+ unselects it. If \a extend is true and the selection mode is not
+ \c Single and there is an existing selection, the selection is
+ extended to include all the items from the existing selection up
+ to and including the item with index \a child. Returns true if a
+ selection was made or extended; otherwise returns false.
+
+ \sa selection() clearSelection()
+*/
+bool QAccessibleListBox::setSelected(int child, bool on, bool extend)
+{
+ if (!child || (extend &&
+ listBox()->selectionMode() != Q3ListBox::Extended &&
+ listBox()->selectionMode() != Q3ListBox::Multi))
+ return false;
+
+ Q3ListBoxItem *item = listBox()->item(child -1);
+ if (!item)
+ return false;
+ if (!extend) {
+ listBox()->setSelected(item, on);
+ } else {
+ int current = listBox()->currentItem();
+ bool down = child > current;
+ for (int i = current; i != child;) {
+ down ? i++ : i--;
+ listBox()->setSelected(i, on);
+ }
+
+ }
+ return true;
+}
+
+/*!
+ Sets all the items in the list box to be unselected.
+
+ \sa setSelected() selection()
+*/
+void QAccessibleListBox::clearSelection()
+{
+ listBox()->clearSelection();
+}
+
+/*!
+ Returns a (possibly empty) list of indexes of the items selected
+ in the list box.
+
+ \sa setSelected() clearSelection()
+*/
+QVector<int> QAccessibleListBox::selection() const
+{
+ QVector<int> array;
+ uint size = 0;
+ const uint c = listBox()->count();
+ array.resize(c);
+ for (uint i = 0; i < c; ++i) {
+ if (listBox()->isSelected(i)) {
+ ++size;
+ array[(int)size-1] = i+1;
+ }
+ }
+ array.resize(size);
+ return array;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/accessible/compat/qaccessiblecompat.h b/src/plugins/accessible/compat/qaccessiblecompat.h
new file mode 100644
index 0000000..5417e4c
--- /dev/null
+++ b/src/plugins/accessible/compat/qaccessiblecompat.h
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QACCESSIBLECOMPAT_H
+#define QACCESSIBLECOMPAT_H
+
+#include <QtGui/qaccessiblewidget.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_ACCESSIBILITY
+
+class Q3ListView;
+class Q3TextEdit;
+class Q3IconView;
+class Q3ListBox;
+
+class Q3AccessibleScrollView : public QAccessibleWidget
+{
+public:
+ Q3AccessibleScrollView(QWidget *w, Role role);
+
+ virtual int itemAt(int x, int y) const;
+ virtual QRect itemRect(int item) const;
+ virtual int itemCount() const;
+};
+
+class QAccessibleListView : public Q3AccessibleScrollView
+{
+public:
+ explicit QAccessibleListView(QWidget *o);
+
+ int itemAt(int x, int y) const;
+ QRect itemRect(int item) const;
+ int itemCount() const;
+
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+
+ bool setSelected(int child, bool on, bool extend);
+ void clearSelection();
+ QVector<int> selection() const;
+
+protected:
+ Q3ListView *listView() const;
+};
+
+class QAccessibleIconView : public Q3AccessibleScrollView
+{
+public:
+ explicit QAccessibleIconView(QWidget *o);
+
+ int itemAt(int x, int y) const;
+ QRect itemRect(int item) const;
+ int itemCount() const;
+
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+
+ bool setSelected(int child, bool on, bool extend);
+ void clearSelection();
+ QVector<int> selection() const;
+
+protected:
+ Q3IconView *iconView() const;
+};
+
+class Q3AccessibleTextEdit : public Q3AccessibleScrollView
+{
+public:
+ explicit Q3AccessibleTextEdit(QWidget *o);
+
+ int itemAt(int x, int y) const;
+ QRect itemRect(int item) const;
+ int itemCount() const;
+
+ QString text(Text t, int child) const;
+ void setText(Text t, int control, const QString &text);
+ Role role(int child) const;
+
+protected:
+ Q3TextEdit *textEdit() const;
+};
+
+class Q3WidgetStack;
+
+class QAccessibleWidgetStack : public QAccessibleWidget
+{
+public:
+ explicit QAccessibleWidgetStack(QWidget *o);
+
+ int childCount() const;
+ int indexOfChild(const QAccessibleInterface*) const;
+
+ int childAt(int x, int y) const;
+
+ int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const;
+
+protected:
+ Q3WidgetStack *widgetStack() const;
+};
+
+class QAccessibleListBox : public Q3AccessibleScrollView
+{
+public:
+ explicit QAccessibleListBox(QWidget *o);
+
+ int itemAt(int x, int y) const;
+ QRect itemRect(int item) const;
+ int itemCount() const;
+
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+
+ bool setSelected(int child, bool on, bool extend);
+ void clearSelection();
+ QVector<int> selection() const;
+
+protected:
+ Q3ListBox *listBox() const;
+};
+
+#endif // QT_NO_ACCESSIBILITY
+
+QT_END_NAMESPACE
+
+#endif // QACCESSIBLECOMPAT_H