~ubuntu-branches/ubuntu/wily/qtbase-opensource-src/wily

« back to all changes in this revision

Viewing changes to src/plugins/accessible/widgets/main.cpp

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 12:46:17 UTC
  • Revision ID: package-import@ubuntu.com-20130205124617-c8jouts182j002fx
Tags: upstream-5.0.1+dfsg
ImportĀ upstreamĀ versionĀ 5.0.1+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2012 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
 
 
59
QT_BEGIN_NAMESPACE
 
60
 
 
61
 
 
62
class AccessibleFactory : public QAccessiblePlugin
 
63
{
 
64
    Q_OBJECT
 
65
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QAccessibleFactoryInterface" FILE "widgets.json")
 
66
 
 
67
public:
 
68
    AccessibleFactory();
 
69
 
 
70
    QAccessibleInterface *create(const QString &classname, QObject *object);
 
71
};
 
72
 
 
73
AccessibleFactory::AccessibleFactory()
 
74
{
 
75
}
 
76
 
 
77
QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObject *object)
 
78
{
 
79
    QAccessibleInterface *iface = 0;
 
80
    if (!object || !object->isWidgetType())
 
81
        return iface;
 
82
    QWidget *widget = static_cast<QWidget*>(object);
 
83
 
 
84
    if (false) {
 
85
#ifndef QT_NO_LINEEDIT
 
86
    } else if (classname == QLatin1String("QLineEdit")) {
 
87
        iface = new QAccessibleLineEdit(widget);
 
88
#endif
 
89
#ifndef QT_NO_COMBOBOX
 
90
    } else if (classname == QLatin1String("QComboBox")) {
 
91
        iface = new QAccessibleComboBox(widget);
 
92
#endif
 
93
#ifndef QT_NO_SPINBOX
 
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);
 
100
#endif
 
101
#ifndef QT_NO_SCROLLBAR
 
102
    } else if (classname == QLatin1String("QScrollBar")) {
 
103
        iface = new QAccessibleScrollBar(widget);
 
104
#endif
 
105
    } else if (classname == QLatin1String("QAbstractSlider")) {
 
106
        iface = new QAccessibleAbstractSlider(widget);
 
107
#ifndef QT_NO_SLIDER
 
108
    } else if (classname == QLatin1String("QSlider")) {
 
109
        iface = new QAccessibleSlider(widget);
 
110
#endif
 
111
#ifndef QT_NO_TOOLBUTTON
 
112
    } else if (classname == QLatin1String("QToolButton")) {
 
113
        QAccessible::Role role = QAccessible::NoRole;
 
114
#ifndef QT_NO_MENU
 
115
        QToolButton *tb = qobject_cast<QToolButton*>(widget);
 
116
        if (!tb->menu())
 
117
            role = tb->isCheckable() ? QAccessible::CheckBox : QAccessible::PushButton;
 
118
        else if (!tb->popupMode() != QToolButton::DelayedPopup)
 
119
            role = QAccessible::ButtonDropDown;
 
120
        else
 
121
#endif
 
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);
 
132
#ifndef QT_NO_MENU
 
133
        if (pb->menu())
 
134
            role = QAccessible::ButtonMenu;
 
135
        else
 
136
#endif
 
137
        if (pb->isCheckable())
 
138
            role = QAccessible::CheckBox;
 
139
        else
 
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);
 
151
#endif
 
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);
 
157
#endif
 
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);
 
163
#endif
 
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);
 
169
#endif
 
170
#ifndef QT_NO_MENU
 
171
    } else if (classname == QLatin1String("QMenu")) {
 
172
        iface = new QAccessibleMenu(widget);
 
173
#endif
 
174
#ifndef QT_NO_ITEMVIEWS
 
175
    } else if (classname == QLatin1String("QAbstractItemView")) {
 
176
        if (qobject_cast<const QTreeView*>(widget)) {
 
177
            iface = new QAccessibleTree(widget);
 
178
        } else {
 
179
            iface = new QAccessibleTable(widget);
 
180
        }
 
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());
 
186
        } else {
 
187
            iface = new QAccessibleTable(widget->parentWidget());
 
188
        }
 
189
#endif // QT_NO_ITEMVIEWS
 
190
#ifndef QT_NO_TABBAR
 
191
    } else if (classname == QLatin1String("QTabBar")) {
 
192
        iface = new QAccessibleTabBar(widget);
 
193
#endif
 
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);
 
201
#endif
 
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);
 
207
#endif
 
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);
 
215
#endif
 
216
#ifndef QT_NO_TOOLBOX
 
217
    } else if (classname == QLatin1String("QToolBox")) {
 
218
        iface = new QAccessibleToolBox(widget);
 
219
#endif
 
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);
 
225
#endif
 
226
    } else if (classname == QLatin1String("QDialogButtonBox")) {
 
227
        iface = new QAccessibleDialogButtonBox(widget);
 
228
#ifndef QT_NO_DIAL
 
229
    } else if (classname == QLatin1String("QDial")) {
 
230
        iface = new QAccessibleDial(widget);
 
231
#endif
 
232
#ifndef QT_NO_RUBBERBAND
 
233
    } else if (classname == QLatin1String("QRubberBand")) {
 
234
        iface = new QAccessibleWidget(widget, QAccessible::Border);
 
235
#endif
 
236
#if !defined(QT_NO_TEXTBROWSER) && !defined(QT_NO_CURSOR)
 
237
    } else if (classname == QLatin1String("QTextBrowser")) {
 
238
        iface = new QAccessibleTextBrowser(widget);
 
239
#endif
 
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);
 
245
#endif
 
246
#ifndef QT_NO_CALENDARWIDGET
 
247
    } else if (classname == QLatin1String("QCalendarWidget")) {
 
248
        iface = new QAccessibleCalendarWidget(widget);
 
249
#endif
 
250
#ifndef QT_NO_DOCKWIDGET
 
251
    } else if (classname == QLatin1String("QDockWidget")) {
 
252
        iface = new QAccessibleDockWidget(widget);
 
253
#endif
 
254
    } else {
 
255
        iface = new QAccessibleWidget(widget);
 
256
    }
 
257
 
 
258
    return iface;
 
259
}
 
260
 
 
261
 
 
262
QT_END_NAMESPACE
 
263
 
 
264
#include "main.moc"
 
265
 
 
266
#endif // QT_NO_ACCESSIBILITY