1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the plugins of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
42
#include "qaccessiblewidgets.h"
43
#include "qaccessiblemenu.h"
44
#include "simplewidgets.h"
45
#include "rangecontrols.h"
46
#include "complexwidgets.h"
47
#include "itemviews.h"
49
#include <qaccessibleplugin.h>
51
#include <qpushbutton.h>
52
#include <qtoolbutton.h>
53
#include <qtreeview.h>
55
#include <qaccessible.h>
57
#ifndef QT_NO_ACCESSIBILITY
62
class AccessibleFactory : public QAccessiblePlugin
65
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QAccessibleFactoryInterface" FILE "widgets.json")
70
QAccessibleInterface *create(const QString &classname, QObject *object);
73
AccessibleFactory::AccessibleFactory()
77
QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObject *object)
79
QAccessibleInterface *iface = 0;
80
if (!object || !object->isWidgetType())
82
QWidget *widget = static_cast<QWidget*>(object);
85
#ifndef QT_NO_LINEEDIT
86
} else if (classname == QLatin1String("QLineEdit")) {
87
iface = new QAccessibleLineEdit(widget);
89
#ifndef QT_NO_COMBOBOX
90
} else if (classname == QLatin1String("QComboBox")) {
91
iface = new QAccessibleComboBox(widget);
94
} else if (classname == QLatin1String("QAbstractSpinBox")) {
95
iface = new QAccessibleAbstractSpinBox(widget);
96
} else if (classname == QLatin1String("QSpinBox")) {
97
iface = new QAccessibleSpinBox(widget);
98
} else if (classname == QLatin1String("QDoubleSpinBox")) {
99
iface = new QAccessibleDoubleSpinBox(widget);
101
#ifndef QT_NO_SCROLLBAR
102
} else if (classname == QLatin1String("QScrollBar")) {
103
iface = new QAccessibleScrollBar(widget);
105
} else if (classname == QLatin1String("QAbstractSlider")) {
106
iface = new QAccessibleAbstractSlider(widget);
108
} else if (classname == QLatin1String("QSlider")) {
109
iface = new QAccessibleSlider(widget);
111
#ifndef QT_NO_TOOLBUTTON
112
} else if (classname == QLatin1String("QToolButton")) {
113
QAccessible::Role role = QAccessible::NoRole;
115
QToolButton *tb = qobject_cast<QToolButton*>(widget);
117
role = tb->isCheckable() ? QAccessible::CheckBox : QAccessible::PushButton;
118
else if (!tb->popupMode() != QToolButton::DelayedPopup)
119
role = QAccessible::ButtonDropDown;
122
role = QAccessible::ButtonMenu;
123
iface = new QAccessibleToolButton(widget, role);
124
#endif // QT_NO_TOOLBUTTON
125
} else if (classname == QLatin1String("QCheckBox")) {
126
iface = new QAccessibleButton(widget, QAccessible::CheckBox);
127
} else if (classname == QLatin1String("QRadioButton")) {
128
iface = new QAccessibleButton(widget, QAccessible::RadioButton);
129
} else if (classname == QLatin1String("QPushButton")) {
130
QAccessible::Role role = QAccessible::NoRole;
131
QPushButton *pb = qobject_cast<QPushButton*>(widget);
134
role = QAccessible::ButtonMenu;
137
if (pb->isCheckable())
138
role = QAccessible::CheckBox;
140
role = QAccessible::PushButton;
141
iface = new QAccessibleButton(widget, role);
142
} else if (classname == QLatin1String("QAbstractButton")) {
143
iface = new QAccessibleButton(widget, QAccessible::PushButton);
144
} else if (classname == QLatin1String("QDialog")) {
145
iface = new QAccessibleWidget(widget, QAccessible::Dialog);
146
} else if (classname == QLatin1String("QMessageBox")) {
147
iface = new QAccessibleWidget(widget, QAccessible::AlertMessage);
148
#ifndef QT_NO_MAINWINDOW
149
} else if (classname == QLatin1String("QMainWindow")) {
150
iface = new QAccessibleMainWindow(widget);
152
} else if (classname == QLatin1String("QLabel") || classname == QLatin1String("QLCDNumber")) {
153
iface = new QAccessibleDisplay(widget);
154
#ifndef QT_NO_GROUPBOX
155
} else if (classname == QLatin1String("QGroupBox")) {
156
iface = new QAccessibleGroupBox(widget);
158
} else if (classname == QLatin1String("QStatusBar")) {
159
iface = new QAccessibleDisplay(widget);
160
#ifndef QT_NO_PROGRESSBAR
161
} else if (classname == QLatin1String("QProgressBar")) {
162
iface = new QAccessibleProgressBar(widget);
164
} else if (classname == QLatin1String("QToolBar")) {
165
iface = new QAccessibleWidget(widget, QAccessible::ToolBar, widget->windowTitle());
166
#ifndef QT_NO_MENUBAR
167
} else if (classname == QLatin1String("QMenuBar")) {
168
iface = new QAccessibleMenuBar(widget);
171
} else if (classname == QLatin1String("QMenu")) {
172
iface = new QAccessibleMenu(widget);
174
#ifndef QT_NO_ITEMVIEWS
175
} else if (classname == QLatin1String("QAbstractItemView")) {
176
if (qobject_cast<const QTreeView*>(widget)) {
177
iface = new QAccessibleTree(widget);
179
iface = new QAccessibleTable(widget);
181
} else if (classname == QLatin1String("QWidget")
182
&& widget->objectName() == QLatin1String("qt_scrollarea_viewport")
183
&& qobject_cast<QAbstractItemView*>(widget->parentWidget())) {
184
if (qobject_cast<const QTreeView*>(widget->parentWidget())) {
185
iface = new QAccessibleTree(widget->parentWidget());
187
iface = new QAccessibleTable(widget->parentWidget());
189
#endif // QT_NO_ITEMVIEWS
191
} else if (classname == QLatin1String("QTabBar")) {
192
iface = new QAccessibleTabBar(widget);
194
} else if (classname == QLatin1String("QSizeGrip")) {
195
iface = new QAccessibleWidget(widget, QAccessible::Grip);
196
#ifndef QT_NO_SPLITTER
197
} else if (classname == QLatin1String("QSplitter")) {
198
iface = new QAccessibleWidget(widget, QAccessible::Splitter);
199
} else if (classname == QLatin1String("QSplitterHandle")) {
200
iface = new QAccessibleWidget(widget, QAccessible::Grip);
202
#if !defined(QT_NO_TEXTEDIT) && !defined(QT_NO_CURSOR)
203
} else if (classname == QLatin1String("QTextEdit")) {
204
iface = new QAccessibleTextEdit(widget);
205
} else if (classname == QLatin1String("QPlainTextEdit")) {
206
iface = new QAccessiblePlainTextEdit(widget);
208
} else if (classname == QLatin1String("QTipLabel")) {
209
iface = new QAccessibleDisplay(widget, QAccessible::ToolTip);
210
} else if (classname == QLatin1String("QFrame")) {
211
iface = new QAccessibleWidget(widget, QAccessible::Border);
212
#ifndef QT_NO_STACKEDWIDGET
213
} else if (classname == QLatin1String("QStackedWidget")) {
214
iface = new QAccessibleStackedWidget(widget);
216
#ifndef QT_NO_TOOLBOX
217
} else if (classname == QLatin1String("QToolBox")) {
218
iface = new QAccessibleToolBox(widget);
220
#ifndef QT_NO_MDIAREA
221
} else if (classname == QLatin1String("QMdiArea")) {
222
iface = new QAccessibleMdiArea(widget);
223
} else if (classname == QLatin1String("QMdiSubWindow")) {
224
iface = new QAccessibleMdiSubWindow(widget);
226
} else if (classname == QLatin1String("QDialogButtonBox")) {
227
iface = new QAccessibleDialogButtonBox(widget);
229
} else if (classname == QLatin1String("QDial")) {
230
iface = new QAccessibleDial(widget);
232
#ifndef QT_NO_RUBBERBAND
233
} else if (classname == QLatin1String("QRubberBand")) {
234
iface = new QAccessibleWidget(widget, QAccessible::Border);
236
#if !defined(QT_NO_TEXTBROWSER) && !defined(QT_NO_CURSOR)
237
} else if (classname == QLatin1String("QTextBrowser")) {
238
iface = new QAccessibleTextBrowser(widget);
240
#ifndef QT_NO_SCROLLAREA
241
} else if (classname == QLatin1String("QAbstractScrollArea")) {
242
iface = new QAccessibleAbstractScrollArea(widget);
243
} else if (classname == QLatin1String("QScrollArea")) {
244
iface = new QAccessibleScrollArea(widget);
246
#ifndef QT_NO_CALENDARWIDGET
247
} else if (classname == QLatin1String("QCalendarWidget")) {
248
iface = new QAccessibleCalendarWidget(widget);
250
#ifndef QT_NO_DOCKWIDGET
251
} else if (classname == QLatin1String("QDockWidget")) {
252
iface = new QAccessibleDockWidget(widget);
255
iface = new QAccessibleWidget(widget);
266
#endif // QT_NO_ACCESSIBILITY