~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the accessibility module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#include "qaccessiblewidgets.h"
 
30
#include "qaccessiblemenu.h"
 
31
#include "simplewidgets.h"
 
32
#include "rangecontrols.h"
 
33
#include "complexwidgets.h"
 
34
 
 
35
#include <qaccessibleplugin.h>
 
36
#include <qplugin.h>
 
37
#include <qpushbutton.h>
 
38
#include <qtoolbutton.h>
 
39
#include <qvariant.h>
 
40
#include <qaccessible.h>
 
41
 
 
42
class AccessibleFactory : public QAccessiblePlugin
 
43
{
 
44
public:
 
45
    AccessibleFactory();
 
46
 
 
47
    QStringList keys() const;
 
48
    QAccessibleInterface *create(const QString &classname, QObject *object);
 
49
};
 
50
 
 
51
AccessibleFactory::AccessibleFactory()
 
52
{
 
53
}
 
54
 
 
55
QStringList AccessibleFactory::keys() const
 
56
{
 
57
    QStringList list;
 
58
    list << "QLineEdit";
 
59
    list << "QComboBox";
 
60
    list << "QSpinBox";
 
61
    list << "QScrollBar";
 
62
    list << "QSlider";
 
63
    list << "QToolButton";
 
64
    list << "QCheckBox";
 
65
    list << "QRadioButton";
 
66
    list << "QPushButton";
 
67
    list << "QButton";
 
68
    list << "QAbstractScrollAreaWidget";
 
69
    list << "QClipperWidget";
 
70
    list << "QDialog";
 
71
    list << "QMessageBox";
 
72
    list << "QMainWindow";
 
73
    list << "QLabel";
 
74
    list << "QLCDNumber";
 
75
    list << "QGroupBox";
 
76
    list << "QStatusBar";
 
77
    list << "QProgressBar";
 
78
    list << "QMenuBar";
 
79
    list << "Q3PopupMenu";
 
80
    list << "QMenu";
 
81
    list << "QHeaderView";
 
82
    list << "QTabBar";
 
83
    list << "QToolBar";
 
84
    list << "QWorkspaceChild";
 
85
    list << "QSizeGrip";
 
86
    list << "QSplitter";
 
87
    list << "QSplitterHandle";
 
88
    list << "QTipLabel";
 
89
    list << "QFrame";
 
90
    list << "QWidgetStack";
 
91
 
 
92
    return list;
 
93
}
 
94
 
 
95
QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObject *object)
 
96
{
 
97
    QAccessibleInterface *iface = 0;
 
98
    if (!object || !object->isWidgetType())
 
99
        return iface;
 
100
    QWidget *widget = static_cast<QWidget*>(object);
 
101
 
 
102
    if (classname == "QLineEdit") {
 
103
        iface = new QAccessibleLineEdit(widget);
 
104
    } else if (classname == "QComboBox") {
 
105
        iface = new QAccessibleComboBox(widget);
 
106
    } else if (classname == "QSpinBox") {
 
107
        iface = new QAccessibleSpinBox(widget);
 
108
    } else if (classname == "QScrollBar") {
 
109
        iface = new QAccessibleScrollBar(widget);
 
110
    } else if (classname == "QSlider") {
 
111
        iface = new QAccessibleSlider(widget);
 
112
    } else if (classname == "QToolButton") {
 
113
        Role role = NoRole;
 
114
        QToolButton *tb = qobject_cast<QToolButton*>(widget);
 
115
        if (!tb->menu())
 
116
            role = tb->isCheckable() ? CheckBox : PushButton;
 
117
        else if (!tb->popupMode() != QToolButton::DelayedPopup)
 
118
            role = ButtonDropDown;
 
119
        else
 
120
            role = ButtonMenu;
 
121
        iface = new QAccessibleToolButton(widget, role);
 
122
    } else if (classname == "QCheckBox") {
 
123
        iface = new QAccessibleButton(widget, CheckBox);
 
124
    } else if (classname == "QRadioButton") {
 
125
        iface = new QAccessibleButton(widget, RadioButton);
 
126
    } else if (classname == "QPushButton") {
 
127
        Role role = NoRole;
 
128
        QPushButton *pb = qobject_cast<QPushButton*>(widget);
 
129
        if (pb->menu())
 
130
            role = ButtonMenu;
 
131
        else if (pb->isCheckable())
 
132
            role = CheckBox;
 
133
        else
 
134
            role = PushButton;
 
135
        iface = new QAccessibleButton(widget, role);
 
136
    } else if (classname == "QButton") {
 
137
        iface = new QAccessibleButton(widget, PushButton);
 
138
    } else if (classname == "QAbstractScrollAreaWidget") {
 
139
        iface = new QAccessibleViewport(widget, widget->parentWidget());
 
140
    } else if (classname == "QClipperWidget") {
 
141
        iface = new QAccessibleViewport(widget, widget->parentWidget()->parentWidget());
 
142
    } else if (classname == "QDialog") {
 
143
        iface = new QAccessibleWidget(widget, Dialog);
 
144
    } else if (classname == "QMessageBox") {
 
145
        iface = new QAccessibleWidget(widget, AlertMessage);
 
146
    } else if (classname == "QMainWindow") {
 
147
        iface = new QAccessibleWidget(widget, Application);
 
148
    } else if (classname == "QLabel" || classname == "QLCDNumber") {
 
149
        iface = new QAccessibleDisplay(widget);
 
150
    } else if (classname == "QGroupBox") {
 
151
        iface = new QAccessibleDisplay(widget, Grouping);
 
152
    } else if (classname == "QStatusBar") {
 
153
        iface = new QAccessibleWidget(widget, StatusBar);
 
154
    } else if (classname == "QProgressBar") {
 
155
        iface = new QAccessibleDisplay(widget);
 
156
    } else if (classname == "QToolBar") {
 
157
        iface = new QAccessibleWidget(widget, ToolBar, widget->windowTitle());
 
158
    } else if (classname == "QMenuBar") {
 
159
        iface = new QAccessibleMenuBar(widget);
 
160
    } else if (classname == "QMenu") {
 
161
        iface = new QAccessibleMenu(widget);
 
162
    } else if (classname == "Q3PopupMenu") {
 
163
        iface = new QAccessibleMenu(widget);
 
164
    } else if (classname == "QHeaderView") {
 
165
        iface = new QAccessibleHeader(widget);
 
166
    } else if (classname == "QTabBar") {
 
167
        iface = new QAccessibleTabBar(widget);
 
168
    } else if (classname == "QWorkspaceChild") {
 
169
        iface = new QAccessibleWidget(widget, Window);
 
170
    } else if (classname == "QSizeGrip") {
 
171
        iface = new QAccessibleWidget(widget, Grip);
 
172
    } else if (classname == "QSplitter") {
 
173
        iface = new QAccessibleWidget(widget, Splitter);
 
174
    } else if (classname == "QSplitterHandle") {
 
175
        iface = new QAccessibleWidget(widget, Grip);
 
176
    } else if (classname == "QTipLabel") {
 
177
        iface = new QAccessibleWidget(widget, ToolTip);
 
178
    } else if (classname == "QFrame") {
 
179
        iface = new QAccessibleWidget(widget, Border);
 
180
    }
 
181
 
 
182
    return iface;
 
183
}
 
184
 
 
185
Q_EXPORT_PLUGIN(AccessibleFactory)