source: trunk/src/plugins/accessible/widgets/main.cpp@ 561

Last change on this file since 561 was 561, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.1 sources.

File size: 12.3 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the plugins of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "qaccessiblewidgets.h"
43#include "qaccessiblemenu.h"
44#include "simplewidgets.h"
45#include "rangecontrols.h"
46#include "complexwidgets.h"
47
48#include <qaccessibleplugin.h>
49#include <qplugin.h>
50#include <qpushbutton.h>
51#include <qtoolbutton.h>
52#include <qvariant.h>
53#include <qaccessible.h>
54
55#ifndef QT_NO_ACCESSIBILITY
56
57QT_BEGIN_NAMESPACE
58
59class AccessibleFactory : public QAccessiblePlugin
60{
61public:
62 AccessibleFactory();
63
64 QStringList keys() const;
65 QAccessibleInterface *create(const QString &classname, QObject *object);
66};
67
68AccessibleFactory::AccessibleFactory()
69{
70}
71
72QStringList AccessibleFactory::keys() const
73{
74 QStringList list;
75#ifndef QT_NO_LINEEDIT
76 list << QLatin1String("QLineEdit");
77#endif
78#ifndef QT_NO_COMBOBOX
79 list << QLatin1String("QComboBox");
80#endif
81#ifndef QT_NO_SPINBOX
82 list << QLatin1String("QAbstractSpinBox");
83 list << QLatin1String("QSpinBox");
84 list << QLatin1String("QDoubleSpinBox");
85#endif
86#ifndef QT_NO_SCROLLBAR
87 list << QLatin1String("QScrollBar");
88#endif
89#ifndef QT_NO_SLIDER
90 list << QLatin1String("QSlider");
91#endif
92 list << QLatin1String("QAbstractSlider");
93#ifndef QT_NO_TOOLBUTTON
94 list << QLatin1String("QToolButton");
95#endif
96 list << QLatin1String("QCheckBox");
97 list << QLatin1String("QRadioButton");
98 list << QLatin1String("QPushButton");
99 list << QLatin1String("QAbstractButton");
100 list << QLatin1String("QDialog");
101 list << QLatin1String("QMessageBox");
102 list << QLatin1String("QMainWindow");
103 list << QLatin1String("QLabel");
104 list << QLatin1String("QLCDNumber");
105 list << QLatin1String("QGroupBox");
106 list << QLatin1String("QStatusBar");
107 list << QLatin1String("QProgressBar");
108 list << QLatin1String("QMenuBar");
109 list << QLatin1String("Q3PopupMenu");
110 list << QLatin1String("QMenu");
111 list << QLatin1String("QHeaderView");
112 list << QLatin1String("QTabBar");
113 list << QLatin1String("QToolBar");
114 list << QLatin1String("QWorkspaceChild");
115 list << QLatin1String("QSizeGrip");
116 list << QLatin1String("QAbstractItemView");
117 list << QLatin1String("QWidget");
118#ifndef QT_NO_SPLITTER
119 list << QLatin1String("QSplitter");
120 list << QLatin1String("QSplitterHandle");
121#endif
122#ifndef QT_NO_TEXTEDIT
123 list << QLatin1String("QTextEdit");
124#endif
125 list << QLatin1String("QTipLabel");
126 list << QLatin1String("QFrame");
127 list << QLatin1String("QStackedWidget");
128 list << QLatin1String("QToolBox");
129 list << QLatin1String("QMdiArea");
130 list << QLatin1String("QMdiSubWindow");
131 list << QLatin1String("QWorkspace");
132 list << QLatin1String("QDialogButtonBox");
133#ifndef QT_NO_DIAL
134 list << QLatin1String("QDial");
135#endif
136#ifndef QT_NO_RUBBERBAND
137 list << QLatin1String("QRubberBand");
138#endif
139#ifndef QT_NO_TEXTBROWSER
140 list << QLatin1String("QTextBrowser");
141#endif
142#ifndef QT_NO_SCROLLAREA
143 list << QLatin1String("QAbstractScrollArea");
144 list << QLatin1String("QScrollArea");
145#endif
146#ifndef QT_NO_CALENDARWIDGET
147 list << QLatin1String("QCalendarWidget");
148#endif
149
150#ifndef QT_NO_DOCKWIDGET
151 list << QLatin1String("QDockWidget");
152#endif
153 return list;
154}
155
156QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObject *object)
157{
158 QAccessibleInterface *iface = 0;
159 if (!object || !object->isWidgetType())
160 return iface;
161 QWidget *widget = static_cast<QWidget*>(object);
162
163 if (false) {
164#ifndef QT_NO_LINEEDIT
165 } else if (classname == QLatin1String("QLineEdit")) {
166 iface = new QAccessibleLineEdit(widget);
167#endif
168#ifndef QT_NO_COMBOBOX
169 } else if (classname == QLatin1String("QComboBox")) {
170 iface = new QAccessibleComboBox(widget);
171#endif
172#ifndef QT_NO_SPINBOX
173 } else if (classname == QLatin1String("QAbstractSpinBox")) {
174 iface = new QAccessibleAbstractSpinBox(widget);
175 } else if (classname == QLatin1String("QSpinBox")) {
176 iface = new QAccessibleSpinBox(widget);
177 } else if (classname == QLatin1String("QDoubleSpinBox")) {
178 iface = new QAccessibleDoubleSpinBox(widget);
179#endif
180#ifndef QT_NO_SCROLLBAR
181 } else if (classname == QLatin1String("QScrollBar")) {
182 iface = new QAccessibleScrollBar(widget);
183#endif
184 } else if (classname == QLatin1String("QAbstractSlider")) {
185 iface = new QAccessibleAbstractSlider(widget);
186#ifndef QT_NO_SLIDER
187 } else if (classname == QLatin1String("QSlider")) {
188 iface = new QAccessibleSlider(widget);
189#endif
190#ifndef QT_NO_TOOLBUTTON
191 } else if (classname == QLatin1String("QToolButton")) {
192 Role role = NoRole;
193#ifndef QT_NO_MENU
194 QToolButton *tb = qobject_cast<QToolButton*>(widget);
195 if (!tb->menu())
196 role = tb->isCheckable() ? CheckBox : PushButton;
197 else if (!tb->popupMode() != QToolButton::DelayedPopup)
198 role = ButtonDropDown;
199 else
200#endif
201 role = ButtonMenu;
202 iface = new QAccessibleToolButton(widget, role);
203#endif // QT_NO_TOOLBUTTON
204 } else if (classname == QLatin1String("QCheckBox")) {
205 iface = new QAccessibleButton(widget, CheckBox);
206 } else if (classname == QLatin1String("QRadioButton")) {
207 iface = new QAccessibleButton(widget, RadioButton);
208 } else if (classname == QLatin1String("QPushButton")) {
209 Role role = NoRole;
210 QPushButton *pb = qobject_cast<QPushButton*>(widget);
211#ifndef QT_NO_MENU
212 if (pb->menu())
213 role = ButtonMenu;
214 else
215#endif
216 if (pb->isCheckable())
217 role = CheckBox;
218 else
219 role = PushButton;
220 iface = new QAccessibleButton(widget, role);
221 } else if (classname == QLatin1String("QAbstractButton")) {
222 iface = new QAccessibleButton(widget, PushButton);
223 } else if (classname == QLatin1String("QDialog")) {
224 iface = new QAccessibleWidgetEx(widget, Dialog);
225 } else if (classname == QLatin1String("QMessageBox")) {
226 iface = new QAccessibleWidgetEx(widget, AlertMessage);
227#ifndef QT_NO_MAINWINDOW
228 } else if (classname == QLatin1String("QMainWindow")) {
229 iface = new QAccessibleMainWindow(widget);
230#endif
231 } else if (classname == QLatin1String("QLabel") || classname == QLatin1String("QLCDNumber")) {
232 iface = new QAccessibleDisplay(widget);
233 } else if (classname == QLatin1String("QGroupBox")) {
234 iface = new QAccessibleDisplay(widget, Grouping);
235 } else if (classname == QLatin1String("QStatusBar")) {
236 iface = new QAccessibleWidgetEx(widget, StatusBar);
237#ifndef QT_NO_PROGRESSBAR
238 } else if (classname == QLatin1String("QProgressBar")) {
239 iface = new QAccessibleProgressBar(widget);
240#endif
241 } else if (classname == QLatin1String("QToolBar")) {
242 iface = new QAccessibleWidgetEx(widget, ToolBar, widget->windowTitle());
243#ifndef QT_NO_MENUBAR
244 } else if (classname == QLatin1String("QMenuBar")) {
245 iface = new QAccessibleMenuBar(widget);
246#endif
247#ifndef QT_NO_MENU
248 } else if (classname == QLatin1String("QMenu")) {
249 iface = new QAccessibleMenu(widget);
250 } else if (classname == QLatin1String("Q3PopupMenu")) {
251 iface = new QAccessibleMenu(widget);
252#endif
253#ifndef QT_NO_ITEMVIEWS
254 } else if (classname == QLatin1String("QHeaderView")) {
255 iface = new QAccessibleHeader(widget);
256 } else if (classname == QLatin1String("QAbstractItemView")) {
257 iface = new QAccessibleItemView(widget);
258 } else if (classname == QLatin1String("QWidget")
259 && widget->objectName() == QLatin1String("qt_scrollarea_viewport")
260 && qobject_cast<QAbstractItemView*>(widget->parentWidget())) {
261 iface = new QAccessibleItemView(widget);
262#endif
263#ifndef QT_NO_TABBAR
264 } else if (classname == QLatin1String("QTabBar")) {
265 iface = new QAccessibleTabBar(widget);
266#endif
267 } else if (classname == QLatin1String("QWorkspaceChild")) {
268 iface = new QAccessibleWidgetEx(widget, Window);
269 } else if (classname == QLatin1String("QSizeGrip")) {
270 iface = new QAccessibleWidgetEx(widget, Grip);
271#ifndef QT_NO_SPLITTER
272 } else if (classname == QLatin1String("QSplitter")) {
273 iface = new QAccessibleWidgetEx(widget, Splitter);
274 } else if (classname == QLatin1String("QSplitterHandle")) {
275 iface = new QAccessibleWidgetEx(widget, Grip);
276#endif
277#ifndef QT_NO_TEXTEDIT
278 } else if (classname == QLatin1String("QTextEdit")) {
279 iface = new QAccessibleTextEdit(widget);
280#endif
281 } else if (classname == QLatin1String("QTipLabel")) {
282 iface = new QAccessibleDisplay(widget, ToolTip);
283 } else if (classname == QLatin1String("QFrame")) {
284 iface = new QAccessibleWidget(widget, Border);
285#ifndef QT_NO_STACKEDWIDGET
286 } else if (classname == QLatin1String("QStackedWidget")) {
287 iface = new QAccessibleStackedWidget(widget);
288#endif
289#ifndef QT_NO_TOOLBOX
290 } else if (classname == QLatin1String("QToolBox")) {
291 iface = new QAccessibleToolBox(widget);
292#endif
293#ifndef QT_NO_MDIAREA
294 } else if (classname == QLatin1String("QMdiArea")) {
295 iface = new QAccessibleMdiArea(widget);
296 } else if (classname == QLatin1String("QMdiSubWindow")) {
297 iface = new QAccessibleMdiSubWindow(widget);
298#endif
299#ifndef QT_NO_WORKSPACE
300 } else if (classname == QLatin1String("QWorkspace")) {
301 iface = new QAccessibleWorkspace(widget);
302#endif
303 } else if (classname == QLatin1String("QDialogButtonBox")) {
304 iface = new QAccessibleDialogButtonBox(widget);
305#ifndef QT_NO_DIAL
306 } else if (classname == QLatin1String("QDial")) {
307 iface = new QAccessibleDial(widget);
308#endif
309#ifndef QT_NO_RUBBERBAND
310 } else if (classname == QLatin1String("QRubberBand")) {
311 iface = new QAccessibleWidgetEx(widget, QAccessible::Border);
312#endif
313#ifndef QT_NO_TEXTBROWSER
314 } else if (classname == QLatin1String("QTextBrowser")) {
315 iface = new QAccessibleTextBrowser(widget);
316#endif
317#ifndef QT_NO_SCROLLAREA
318 } else if (classname == QLatin1String("QAbstractScrollArea")) {
319 iface = new QAccessibleAbstractScrollArea(widget);
320 } else if (classname == QLatin1String("QScrollArea")) {
321 iface = new QAccessibleScrollArea(widget);
322#endif
323#ifndef QT_NO_CALENDARWIDGET
324 } else if (classname == QLatin1String("QCalendarWidget")) {
325 iface = new QAccessibleCalendarWidget(widget);
326#endif
327#ifndef QT_NO_DOCKWIDGET
328 } else if (classname == QLatin1String("QDockWidget")) {
329 iface = new QAccessibleDockWidget(widget);
330#endif
331 }
332
333 return iface;
334}
335
336Q_EXPORT_STATIC_PLUGIN(AccessibleFactory)
337Q_EXPORT_PLUGIN2(qtaccessiblewidgets, AccessibleFactory)
338
339QT_END_NAMESPACE
340
341#endif // QT_NO_ACCESSIBILITY
Note: See TracBrowser for help on using the repository browser.