Qt 4.8
main.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
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.
16 **
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.
24 **
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.
28 **
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.
36 **
37 **
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 #include "itemviews.h"
48 
49 #include <qaccessibleplugin.h>
50 #include <qplugin.h>
51 #include <qpushbutton.h>
52 #include <qtoolbutton.h>
53 #include <qtreeview.h>
54 #include <qvariant.h>
55 #include <qaccessible.h>
56 
57 #ifndef QT_NO_ACCESSIBILITY
58 
60 
61 
63 {
64 public:
66 
67  QStringList keys() const;
68  QAccessibleInterface *create(const QString &classname, QObject *object);
69 };
70 
72 {
73 }
74 
76 {
77  QStringList list;
78 #ifndef QT_NO_LINEEDIT
79  list << QLatin1String("QLineEdit");
80 #endif
81 #ifndef QT_NO_COMBOBOX
82  list << QLatin1String("QComboBox");
83 #endif
84 #ifndef QT_NO_SPINBOX
85  list << QLatin1String("QAbstractSpinBox");
86  list << QLatin1String("QSpinBox");
87  list << QLatin1String("QDoubleSpinBox");
88 #endif
89 #ifndef QT_NO_SCROLLBAR
90  list << QLatin1String("QScrollBar");
91 #endif
92 #ifndef QT_NO_SLIDER
93  list << QLatin1String("QSlider");
94 #endif
95  list << QLatin1String("QAbstractSlider");
96 #ifndef QT_NO_TOOLBUTTON
97  list << QLatin1String("QToolButton");
98 #endif
99  list << QLatin1String("QCheckBox");
100  list << QLatin1String("QRadioButton");
101  list << QLatin1String("QPushButton");
102  list << QLatin1String("QAbstractButton");
103  list << QLatin1String("QDialog");
104  list << QLatin1String("QMessageBox");
105  list << QLatin1String("QMainWindow");
106  list << QLatin1String("QLabel");
107  list << QLatin1String("QLCDNumber");
108  list << QLatin1String("QGroupBox");
109  list << QLatin1String("QStatusBar");
110  list << QLatin1String("QProgressBar");
111  list << QLatin1String("QMenuBar");
112  list << QLatin1String("Q3PopupMenu");
113  list << QLatin1String("QMenu");
114  list << QLatin1String("QHeaderView");
115  list << QLatin1String("QTabBar");
116  list << QLatin1String("QToolBar");
117  list << QLatin1String("QWorkspaceChild");
118  list << QLatin1String("QSizeGrip");
119  list << QLatin1String("QAbstractItemView");
120  list << QLatin1String("QWidget");
121 #ifndef QT_NO_SPLITTER
122  list << QLatin1String("QSplitter");
123  list << QLatin1String("QSplitterHandle");
124 #endif
125 #ifndef QT_NO_TEXTEDIT
126  list << QLatin1String("QTextEdit");
127 #endif
128  list << QLatin1String("QPlainTextEdit");
129  list << QLatin1String("QTipLabel");
130  list << QLatin1String("QFrame");
131  list << QLatin1String("QStackedWidget");
132  list << QLatin1String("QToolBox");
133  list << QLatin1String("QMdiArea");
134  list << QLatin1String("QMdiSubWindow");
135  list << QLatin1String("QWorkspace");
136  list << QLatin1String("QDialogButtonBox");
137 #ifndef QT_NO_DIAL
138  list << QLatin1String("QDial");
139 #endif
140 #ifndef QT_NO_RUBBERBAND
141  list << QLatin1String("QRubberBand");
142 #endif
143 #ifndef QT_NO_TEXTBROWSER
144  list << QLatin1String("QTextBrowser");
145 #endif
146 #ifndef QT_NO_SCROLLAREA
147  list << QLatin1String("QAbstractScrollArea");
148  list << QLatin1String("QScrollArea");
149 #endif
150 #ifndef QT_NO_CALENDARWIDGET
151  list << QLatin1String("QCalendarWidget");
152 #endif
153 
154 #ifndef QT_NO_DOCKWIDGET
155  list << QLatin1String("QDockWidget");
156 #endif
157  return list;
158 }
159 
161 {
162  QAccessibleInterface *iface = 0;
163  if (!object || !object->isWidgetType())
164  return iface;
165  QWidget *widget = static_cast<QWidget*>(object);
166 
167  if (false) {
168 #ifndef QT_NO_LINEEDIT
169  } else if (classname == QLatin1String("QLineEdit")) {
170  iface = new QAccessibleLineEdit(widget);
171 #endif
172 #ifndef QT_NO_COMBOBOX
173  } else if (classname == QLatin1String("QComboBox")) {
174  iface = new QAccessibleComboBox(widget);
175 #endif
176 #ifndef QT_NO_SPINBOX
177  } else if (classname == QLatin1String("QAbstractSpinBox")) {
178  iface = new QAccessibleAbstractSpinBox(widget);
179  } else if (classname == QLatin1String("QSpinBox")) {
180  iface = new QAccessibleSpinBox(widget);
181  } else if (classname == QLatin1String("QDoubleSpinBox")) {
182  iface = new QAccessibleDoubleSpinBox(widget);
183 #endif
184 #ifndef QT_NO_SCROLLBAR
185  } else if (classname == QLatin1String("QScrollBar")) {
186  iface = new QAccessibleScrollBar(widget);
187 #endif
188  } else if (classname == QLatin1String("QAbstractSlider")) {
189  iface = new QAccessibleAbstractSlider(widget);
190 #ifndef QT_NO_SLIDER
191  } else if (classname == QLatin1String("QSlider")) {
192  iface = new QAccessibleSlider(widget);
193 #endif
194 #ifndef QT_NO_TOOLBUTTON
195  } else if (classname == QLatin1String("QToolButton")) {
196  Role role = NoRole;
197 #ifndef QT_NO_MENU
199  if (!tb->menu())
200  role = tb->isCheckable() ? CheckBox : PushButton;
201  else if (!tb->popupMode() != QToolButton::DelayedPopup)
202  role = ButtonDropDown;
203  else
204 #endif
205  role = ButtonMenu;
206  iface = new QAccessibleToolButton(widget, role);
207 #endif // QT_NO_TOOLBUTTON
208  } else if (classname == QLatin1String("QCheckBox")) {
209  iface = new QAccessibleButton(widget, CheckBox);
210  } else if (classname == QLatin1String("QRadioButton")) {
211  iface = new QAccessibleButton(widget, RadioButton);
212  } else if (classname == QLatin1String("QPushButton")) {
213  Role role = NoRole;
215 #ifndef QT_NO_MENU
216  if (pb->menu())
217  role = ButtonMenu;
218  else
219 #endif
220  if (pb->isCheckable())
221  role = CheckBox;
222  else
223  role = PushButton;
224  iface = new QAccessibleButton(widget, role);
225  } else if (classname == QLatin1String("QAbstractButton")) {
226  iface = new QAccessibleButton(widget, PushButton);
227  } else if (classname == QLatin1String("QDialog")) {
228  iface = new QAccessibleWidgetEx(widget, Dialog);
229  } else if (classname == QLatin1String("QMessageBox")) {
230  iface = new QAccessibleWidgetEx(widget, AlertMessage);
231 #ifndef QT_NO_MAINWINDOW
232  } else if (classname == QLatin1String("QMainWindow")) {
233  iface = new QAccessibleMainWindow(widget);
234 #endif
235  } else if (classname == QLatin1String("QLabel") || classname == QLatin1String("QLCDNumber")) {
236  iface = new QAccessibleDisplay(widget);
237 #ifndef QT_NO_GROUPBOX
238  } else if (classname == QLatin1String("QGroupBox")) {
239  iface = new QAccessibleGroupBox(widget);
240 #endif
241  } else if (classname == QLatin1String("QStatusBar")) {
242  iface = new QAccessibleDisplay(widget);
243 #ifndef QT_NO_PROGRESSBAR
244  } else if (classname == QLatin1String("QProgressBar")) {
245  iface = new QAccessibleProgressBar(widget);
246 #endif
247  } else if (classname == QLatin1String("QToolBar")) {
248  iface = new QAccessibleWidgetEx(widget, ToolBar, widget->windowTitle());
249 #ifndef QT_NO_MENUBAR
250  } else if (classname == QLatin1String("QMenuBar")) {
251  iface = new QAccessibleMenuBar(widget);
252 #endif
253 #ifndef QT_NO_MENU
254  } else if (classname == QLatin1String("QMenu")) {
255  iface = new QAccessibleMenu(widget);
256  } else if (classname == QLatin1String("Q3PopupMenu")) {
257  iface = new QAccessibleMenu(widget);
258 #endif
259 #ifndef QT_NO_ITEMVIEWS
260 #ifdef Q_WS_X11
261  } else if (classname == QLatin1String("QAbstractItemView")) {
262  if (qobject_cast<const QTreeView*>(widget)) {
263  iface = new QAccessibleTree(widget);
264  } else {
265  iface = new QAccessibleTable2(widget);
266  }
267  } else if (classname == QLatin1String("QWidget")
268  && widget->objectName() == QLatin1String("qt_scrollarea_viewport")
269  && qobject_cast<QAbstractItemView*>(widget->parentWidget())) {
270  if (qobject_cast<const QTreeView*>(widget->parentWidget())) {
271  iface = new QAccessibleTree(widget->parentWidget());
272  } else {
273  iface = new QAccessibleTable2(widget->parentWidget());
274  }
275 #else
276  } else if (classname == QLatin1String("QHeaderView")) {
277  iface = new QAccessibleHeader(widget);
278  } else if (classname == QLatin1String("QAbstractItemView")) {
279  iface = new QAccessibleItemView(widget);
280  } else if (classname == QLatin1String("QWidget")
281  && widget->objectName() == QLatin1String("qt_scrollarea_viewport")
282  && qobject_cast<QAbstractItemView*>(widget->parentWidget())) {
283  iface = new QAccessibleItemView(widget);
284 #endif // Q_WS_X11
285 #endif // QT_NO_ITEMVIEWS
286 #ifndef QT_NO_TABBAR
287  } else if (classname == QLatin1String("QTabBar")) {
288  iface = new QAccessibleTabBar(widget);
289 #endif
290  } else if (classname == QLatin1String("QWorkspaceChild")) {
291  iface = new QAccessibleWidgetEx(widget, Window);
292  } else if (classname == QLatin1String("QSizeGrip")) {
293  iface = new QAccessibleWidgetEx(widget, Grip);
294 #ifndef QT_NO_SPLITTER
295  } else if (classname == QLatin1String("QSplitter")) {
296  iface = new QAccessibleWidgetEx(widget, Splitter);
297  } else if (classname == QLatin1String("QSplitterHandle")) {
298  iface = new QAccessibleWidgetEx(widget, Grip);
299 #endif
300 #ifndef QT_NO_TEXTEDIT
301  } else if (classname == QLatin1String("QTextEdit")) {
302  iface = new QAccessibleTextEdit(widget);
303 #endif
304  } else if (classname == QLatin1String("QPlainTextEdit")) {
305  iface = new QAccessiblePlainTextEdit(widget);
306  } else if (classname == QLatin1String("QTipLabel")) {
307  iface = new QAccessibleDisplay(widget, ToolTip);
308  } else if (classname == QLatin1String("QFrame")) {
309  iface = new QAccessibleWidget(widget, Border);
310 #ifndef QT_NO_STACKEDWIDGET
311  } else if (classname == QLatin1String("QStackedWidget")) {
312  iface = new QAccessibleStackedWidget(widget);
313 #endif
314 #ifndef QT_NO_TOOLBOX
315  } else if (classname == QLatin1String("QToolBox")) {
316  iface = new QAccessibleToolBox(widget);
317 #endif
318 #ifndef QT_NO_MDIAREA
319  } else if (classname == QLatin1String("QMdiArea")) {
320  iface = new QAccessibleMdiArea(widget);
321  } else if (classname == QLatin1String("QMdiSubWindow")) {
322  iface = new QAccessibleMdiSubWindow(widget);
323 #endif
324 #ifndef QT_NO_WORKSPACE
325  } else if (classname == QLatin1String("QWorkspace")) {
326  iface = new QAccessibleWorkspace(widget);
327 #endif
328  } else if (classname == QLatin1String("QDialogButtonBox")) {
329  iface = new QAccessibleDialogButtonBox(widget);
330 #ifndef QT_NO_DIAL
331  } else if (classname == QLatin1String("QDial")) {
332  iface = new QAccessibleDial(widget);
333 #endif
334 #ifndef QT_NO_RUBBERBAND
335  } else if (classname == QLatin1String("QRubberBand")) {
336  iface = new QAccessibleWidgetEx(widget, QAccessible::Border);
337 #endif
338 #ifndef QT_NO_TEXTBROWSER
339  } else if (classname == QLatin1String("QTextBrowser")) {
340  iface = new QAccessibleTextBrowser(widget);
341 #endif
342 #ifndef QT_NO_SCROLLAREA
343  } else if (classname == QLatin1String("QAbstractScrollArea")) {
344  iface = new QAccessibleAbstractScrollArea(widget);
345  } else if (classname == QLatin1String("QScrollArea")) {
346  iface = new QAccessibleScrollArea(widget);
347 #endif
348 #ifndef QT_NO_CALENDARWIDGET
349  } else if (classname == QLatin1String("QCalendarWidget")) {
350  iface = new QAccessibleCalendarWidget(widget);
351 #endif
352 #ifndef QT_NO_DOCKWIDGET
353  } else if (classname == QLatin1String("QDockWidget")) {
354  iface = new QAccessibleDockWidget(widget);
355 #endif
356  }
357 
358  return iface;
359 }
360 
362 Q_EXPORT_PLUGIN2(qtaccessiblewidgets, AccessibleFactory)
363 
365 
366 #endif // QT_NO_ACCESSIBILITY
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QWidget > widget
Role
This enum defines the role of an accessible object.
Definition: qaccessible.h:188
The QAccessibleLineEdit class implements the QAccessibleInterface for widgets with editable text...
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QPushButton widget provides a command button.
Definition: qpushbutton.h:57
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QAccessiblePlugin class provides an abstract base for accessibility plugins.
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
The QAccessibleComboBox class implements the QAccessibleInterface for editable and read-only combo bo...
The QAccessibleHeader class implements the QAccessibleInterface for header widgets.
Q_EXPORT_PLUGIN2(qjpcodecs, JPTextCodecs)
Q_EXPORT_STATIC_PLUGIN(JPTextCodecs)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
The QAccessibleDisplay class implements the QAccessibleInterface for widgets that display information...
QString windowTitle
the window title (caption)
Definition: qwidget.h:198
QAccessibleInterface * create(const QString &classname, QObject *object)
Creates and returns a QAccessibleInterface implementation for the class key and the object object...
Definition: main.cpp:160
The QAccessibleButton class implements the QAccessibleInterface for button type widgets.
Definition: simplewidgets.h:59
QMenu * menu() const
Returns the button&#39;s associated popup menu or 0 if no popup menu has been set.
bool isCheckable() const
The QAccessibleWidget class implements the QAccessibleInterface for QWidgets.
The QAbstractItemView class provides the basic functionality for item view classes.
The QAccessibleTextEdit class implements the QAccessibleInterface for richtext editors.
The QAccessibleToolButton class implements the QAccessibleInterface for tool buttons.
Definition: simplewidgets.h:85
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
The QAccessibleSlider class implements the QAccessibleInterface for sliders.
The QAccessibleInterface class defines an interface that exposes information about accessible objects...
Definition: qaccessible.h:370
QMenu * menu() const
Returns the associated menu, or 0 if no menu has been defined.
QString objectName() const
ToolButtonPopupMode popupMode
describes the way that popup menus are used with tool buttons
Definition: qtoolbutton.h:64
QStringList keys() const
Returns the list of keys this plugin supports.
Definition: main.cpp:75
The QAccessibleTabBar class implements the QAccessibleInterface for tab bars.
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59
The QAccessibleSpinBox class implements the QAccessibleInterface for spinbox widgets.
Definition: rangecontrols.h:96
The QAccessibleScrollBar class implements the QAccessibleInterface for scroll bars.