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

Last change on this file since 104 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 12.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the plugins of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** 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 are unsure which license is appropriate for your use, please
37** contact the sales department 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 } else if (classname == QLatin1String("QProgressBar")) {
238 iface = new QAccessibleDisplay(widget);
239 } else if (classname == QLatin1String("QToolBar")) {
240 iface = new QAccessibleWidgetEx(widget, ToolBar, widget->windowTitle());
241#ifndef QT_NO_MENUBAR
242 } else if (classname == QLatin1String("QMenuBar")) {
243 iface = new QAccessibleMenuBar(widget);
244#endif
245#ifndef QT_NO_MENU
246 } else if (classname == QLatin1String("QMenu")) {
247 iface = new QAccessibleMenu(widget);
248 } else if (classname == QLatin1String("Q3PopupMenu")) {
249 iface = new QAccessibleMenu(widget);
250#endif
251#ifndef QT_NO_ITEMVIEWS
252 } else if (classname == QLatin1String("QHeaderView")) {
253 iface = new QAccessibleHeader(widget);
254 } else if (classname == QLatin1String("QAbstractItemView")) {
255 iface = new QAccessibleItemView(widget);
256 } else if (classname == QLatin1String("QWidget")
257 && widget->objectName() == QLatin1String("qt_scrollarea_viewport")
258 && qobject_cast<QAbstractItemView*>(widget->parentWidget())) {
259 iface = new QAccessibleItemView(widget);
260#endif
261#ifndef QT_NO_TABBAR
262 } else if (classname == QLatin1String("QTabBar")) {
263 iface = new QAccessibleTabBar(widget);
264#endif
265 } else if (classname == QLatin1String("QWorkspaceChild")) {
266 iface = new QAccessibleWidgetEx(widget, Window);
267 } else if (classname == QLatin1String("QSizeGrip")) {
268 iface = new QAccessibleWidgetEx(widget, Grip);
269#ifndef QT_NO_SPLITTER
270 } else if (classname == QLatin1String("QSplitter")) {
271 iface = new QAccessibleWidgetEx(widget, Splitter);
272 } else if (classname == QLatin1String("QSplitterHandle")) {
273 iface = new QAccessibleWidgetEx(widget, Grip);
274#endif
275#ifndef QT_NO_TEXTEDIT
276 } else if (classname == QLatin1String("QTextEdit")) {
277 iface = new QAccessibleTextEdit(widget);
278#endif
279 } else if (classname == QLatin1String("QTipLabel")) {
280 iface = new QAccessibleDisplay(widget, ToolTip);
281 } else if (classname == QLatin1String("QFrame")) {
282 iface = new QAccessibleWidget(widget, Border);
283#ifndef QT_NO_STACKEDWIDGET
284 } else if (classname == QLatin1String("QStackedWidget")) {
285 iface = new QAccessibleStackedWidget(widget);
286#endif
287#ifndef QT_NO_TOOLBOX
288 } else if (classname == QLatin1String("QToolBox")) {
289 iface = new QAccessibleToolBox(widget);
290#endif
291#ifndef QT_NO_MDIAREA
292 } else if (classname == QLatin1String("QMdiArea")) {
293 iface = new QAccessibleMdiArea(widget);
294 } else if (classname == QLatin1String("QMdiSubWindow")) {
295 iface = new QAccessibleMdiSubWindow(widget);
296#endif
297#ifndef QT_NO_WORKSPACE
298 } else if (classname == QLatin1String("QWorkspace")) {
299 iface = new QAccessibleWorkspace(widget);
300#endif
301 } else if (classname == QLatin1String("QDialogButtonBox")) {
302 iface = new QAccessibleDialogButtonBox(widget);
303#ifndef QT_NO_DIAL
304 } else if (classname == QLatin1String("QDial")) {
305 iface = new QAccessibleDial(widget);
306#endif
307#ifndef QT_NO_RUBBERBAND
308 } else if (classname == QLatin1String("QRubberBand")) {
309 iface = new QAccessibleWidgetEx(widget, QAccessible::Border);
310#endif
311#ifndef QT_NO_TEXTBROWSER
312 } else if (classname == QLatin1String("QTextBrowser")) {
313 iface = new QAccessibleTextBrowser(widget);
314#endif
315#ifndef QT_NO_SCROLLAREA
316 } else if (classname == QLatin1String("QAbstractScrollArea")) {
317 iface = new QAccessibleAbstractScrollArea(widget);
318 } else if (classname == QLatin1String("QScrollArea")) {
319 iface = new QAccessibleScrollArea(widget);
320#endif
321#ifndef QT_NO_CALENDARWIDGET
322 } else if (classname == QLatin1String("QCalendarWidget")) {
323 iface = new QAccessibleCalendarWidget(widget);
324#endif
325#ifndef QT_NO_DOCKWIDGET
326 } else if (classname == QLatin1String("QDockWidget")) {
327 iface = new QAccessibleDockWidget(widget);
328#endif
329 }
330
331 return iface;
332}
333
334Q_EXPORT_STATIC_PLUGIN(AccessibleFactory)
335Q_EXPORT_PLUGIN2(qtaccessiblewidgets, AccessibleFactory)
336
337QT_END_NAMESPACE
338
339#endif // QT_NO_ACCESSIBILITY
Note: See TracBrowser for help on using the repository browser.