1 | #include "qaccessiblewidget.h"
|
---|
2 | #include "qaccessiblemenu.h"
|
---|
3 |
|
---|
4 | #include <qtoolbutton.h>
|
---|
5 | #include <qtoolbar.h>
|
---|
6 | #include <qvariant.h>
|
---|
7 |
|
---|
8 | class AccessibleFactory : public QAccessibleFactoryInterface, public QLibraryInterface
|
---|
9 | {
|
---|
10 | public:
|
---|
11 | AccessibleFactory();
|
---|
12 |
|
---|
13 | QRESULT queryInterface( const QUuid &, QUnknownInterface **iface );
|
---|
14 | Q_REFCOUNT
|
---|
15 |
|
---|
16 | QStringList featureList() const;
|
---|
17 | QRESULT createAccessibleInterface( const QString &classname, QObject *object, QAccessibleInterface **iface );
|
---|
18 |
|
---|
19 | bool init();
|
---|
20 | void cleanup();
|
---|
21 | bool canUnload() const;
|
---|
22 | };
|
---|
23 |
|
---|
24 | AccessibleFactory::AccessibleFactory()
|
---|
25 | {
|
---|
26 | }
|
---|
27 |
|
---|
28 | QRESULT AccessibleFactory::queryInterface( const QUuid &iid, QUnknownInterface **iface )
|
---|
29 | {
|
---|
30 | *iface = 0;
|
---|
31 | if ( iid == IID_QUnknown )
|
---|
32 | *iface = (QUnknownInterface*)(QFeatureListInterface*)(QAccessibleFactoryInterface*)this;
|
---|
33 | else if ( iid == IID_QFeatureList )
|
---|
34 | *iface = (QFeatureListInterface*)this;
|
---|
35 | else if ( iid == IID_QAccessibleFactory )
|
---|
36 | *iface = (QAccessibleFactoryInterface*)this;
|
---|
37 | else if ( iid == IID_QLibrary )
|
---|
38 | *iface = (QLibraryInterface*)this;
|
---|
39 | else
|
---|
40 | return QE_NOINTERFACE;
|
---|
41 |
|
---|
42 | (*iface)->addRef();
|
---|
43 | return QS_OK;
|
---|
44 | }
|
---|
45 |
|
---|
46 | QStringList AccessibleFactory::featureList() const
|
---|
47 | {
|
---|
48 | QStringList list;
|
---|
49 | list << "QLineEdit";
|
---|
50 | list << "QComboBox";
|
---|
51 | list << "QSpinBox";
|
---|
52 | list << "QSpinWidget";
|
---|
53 | list << "QDial";
|
---|
54 | list << "QScrollBar";
|
---|
55 | list << "QSlider";
|
---|
56 | list << "QToolButton";
|
---|
57 | list << "QCheckBox";
|
---|
58 | list << "QRadioButton";
|
---|
59 | list << "QButton";
|
---|
60 | list << "QViewportWidget";
|
---|
61 | list << "QClipperWidget";
|
---|
62 | list << "QTextEdit";
|
---|
63 | #ifndef QT_NO_ICONVIEW
|
---|
64 | list << "QIconView";
|
---|
65 | #endif
|
---|
66 | list << "QListView";
|
---|
67 | list << "QListBox";
|
---|
68 | list << "QTable";
|
---|
69 | list << "QDialog";
|
---|
70 | list << "QMessageBox";
|
---|
71 | list << "QMainWindow";
|
---|
72 | list << "QLabel";
|
---|
73 | list << "QGroupBox";
|
---|
74 | list << "QStatusBar";
|
---|
75 | list << "QProgressBar";
|
---|
76 | list << "QToolBar";
|
---|
77 | list << "QMenuBar";
|
---|
78 | list << "QPopupMenu";
|
---|
79 | list << "QHeader";
|
---|
80 | list << "QTabBar";
|
---|
81 | list << "QTitleBar";
|
---|
82 | list << "QWorkspaceChild";
|
---|
83 | list << "QSizeGrip";
|
---|
84 | list << "QSplitterHandle";
|
---|
85 | list << "QToolBarSeparator";
|
---|
86 | list << "QDockWindowHandle";
|
---|
87 | list << "QDockWindowResizeHandle";
|
---|
88 | list << "QTipLabel";
|
---|
89 | list << "QFrame";
|
---|
90 | list << "QWidgetStack";
|
---|
91 | list << "QWidget";
|
---|
92 | list << "QScrollView";
|
---|
93 |
|
---|
94 | return list;
|
---|
95 | }
|
---|
96 |
|
---|
97 | QRESULT AccessibleFactory::createAccessibleInterface( const QString &classname, QObject *object, QAccessibleInterface **iface )
|
---|
98 | {
|
---|
99 | *iface = 0;
|
---|
100 |
|
---|
101 | if ( classname == "QLineEdit" ) {
|
---|
102 | *iface = new QAccessibleText( object, EditableText );
|
---|
103 | } else if ( classname == "QComboBox" ) {
|
---|
104 | *iface = new QAccessibleComboBox( object );
|
---|
105 | } else if ( classname == "QSpinBox" ) {
|
---|
106 | *iface = new QAccessibleRangeControl( object, SpinBox );
|
---|
107 | } else if ( classname == "QSpinWidget" ) {
|
---|
108 | *iface = new QAccessibleSpinWidget( object );
|
---|
109 | } else if ( classname == "QDial" ) {
|
---|
110 | *iface = new QAccessibleRangeControl( object, Dial );
|
---|
111 | } else if ( classname == "QScrollBar" ) {
|
---|
112 | *iface = new QAccessibleScrollBar( object );
|
---|
113 | } else if ( classname == "QSlider" ) {
|
---|
114 | *iface = new QAccessibleSlider( object );
|
---|
115 | } else if ( classname == "QToolButton" ) {
|
---|
116 | QToolButton *tb = (QToolButton*)object;
|
---|
117 | if ( !tb->popup() )
|
---|
118 | *iface = new QAccessibleButton( object, PushButton );
|
---|
119 | else if ( !tb->popupDelay() )
|
---|
120 | *iface = new QAccessibleButton( object, ButtonDropDown );
|
---|
121 | else
|
---|
122 | *iface = new QAccessibleButton( object, ButtonMenu );
|
---|
123 | } else if ( classname == "QCheckBox" ) {
|
---|
124 | *iface = new QAccessibleButton( object, CheckBox );
|
---|
125 | } else if ( classname == "QRadioButton" ) {
|
---|
126 | *iface = new QAccessibleButton( object, RadioButton );
|
---|
127 | } else if ( classname == "QButton" ) {
|
---|
128 | *iface = new QAccessibleButton( object, PushButton );
|
---|
129 | } else if ( classname == "QViewportWidget" ) {
|
---|
130 | *iface = new QAccessibleViewport( object, object->parent() );
|
---|
131 | } else if ( classname == "QClipperWidget" ) {
|
---|
132 | *iface = new QAccessibleViewport( object, object->parent()->parent() );
|
---|
133 | } else if ( classname == "QTextEdit" ) {
|
---|
134 | *iface = new QAccessibleTextEdit( object );
|
---|
135 | #ifndef QT_NO_ICONVIEW
|
---|
136 | } else if ( classname == "QIconView" ) {
|
---|
137 | *iface = new QAccessibleIconView( object );
|
---|
138 | #endif
|
---|
139 | } else if ( classname == "QListView" ) {
|
---|
140 | *iface = new QAccessibleListView( object );
|
---|
141 | } else if ( classname == "QListBox" ) {
|
---|
142 | *iface = new QAccessibleListBox( object );
|
---|
143 | } else if ( classname == "QTable" ) {
|
---|
144 | *iface = new QAccessibleScrollView( object, Table );
|
---|
145 | } else if ( classname == "QDialog" ) {
|
---|
146 | *iface = new QAccessibleWidget( object, Dialog );
|
---|
147 | } else if ( classname == "QMessageBox" ) {
|
---|
148 | *iface = new QAccessibleWidget( object, AlertMessage );
|
---|
149 | } else if ( classname == "QMainWindow" ) {
|
---|
150 | *iface = new QAccessibleWidget( object, Application );
|
---|
151 | } else if ( classname == "QLabel" || classname == "QLCDNumber" ) {
|
---|
152 | *iface = new QAccessibleDisplay( object, StaticText );
|
---|
153 | } else if ( classname == "QGroupBox" ) {
|
---|
154 | *iface = new QAccessibleDisplay( object, Grouping );
|
---|
155 | } else if ( classname == "QStatusBar" ) {
|
---|
156 | *iface = new QAccessibleWidget( object, StatusBar );
|
---|
157 | } else if ( classname == "QProgressBar" ) {
|
---|
158 | *iface = new QAccessibleRangeControl( object, ProgressBar );
|
---|
159 | } else if ( classname == "QToolBar" ) {
|
---|
160 | QToolBar *tb = (QToolBar*)object;
|
---|
161 | *iface = new QAccessibleWidget( object, ToolBar, tb->label() );
|
---|
162 | } else if ( classname == "QMenuBar" ) {
|
---|
163 | *iface = new QAccessibleMenuBar( object );
|
---|
164 | } else if ( classname == "QPopupMenu" ) {
|
---|
165 | *iface = new QAccessiblePopup( object );
|
---|
166 | } else if ( classname == "QHeader" ) {
|
---|
167 | *iface = new QAccessibleHeader( object );
|
---|
168 | } else if ( classname == "QTabBar" ) {
|
---|
169 | *iface = new QAccessibleTabBar( object );
|
---|
170 | } else if ( classname == "QTitleBar" ) {
|
---|
171 | *iface = new QAccessibleTitleBar( object );
|
---|
172 | } else if ( classname == "QWorkspaceChild" ) {
|
---|
173 | *iface = new QAccessibleWidget( object, Window );
|
---|
174 | } else if ( classname == "QSizeGrip" ) {
|
---|
175 | *iface = new QAccessibleWidget( object, Grip );
|
---|
176 | } else if ( classname == "QSplitterHandle" ) {
|
---|
177 | *iface = new QAccessibleWidget( object, Separator, QString::null,
|
---|
178 | QString::null, QString::null, QString::null,
|
---|
179 | QString::null, QString::null, QAccessible::Moveable );
|
---|
180 | } else if ( classname == "QToolBarSeparator" ) {
|
---|
181 | *iface = new QAccessibleWidget( object, QAccessible::Separator, QString::null,
|
---|
182 | QString::null, QString::null, QString::null,
|
---|
183 | QString::null, QString::null, QAccessible::Unavailable );
|
---|
184 | } else if ( classname == "QDockWindowHandle" ) {
|
---|
185 | *iface = new QAccessibleWidget( object, QAccessible::Grip, object->property( "caption" ).toString(),
|
---|
186 | QString::null, QString::null, QString::null,
|
---|
187 | QString::null, QString::null, QAccessible::Moveable );
|
---|
188 | } else if ( classname == "QDockWindowResizeHandle" ) {
|
---|
189 | *iface = new QAccessibleWidget( object, QAccessible::Separator, QString::null,
|
---|
190 | QString::null, QString::null, QString::null,
|
---|
191 | QString::null, QString::null, QAccessible::Moveable );
|
---|
192 | } else if ( classname == "QTipLabel" ) {
|
---|
193 | *iface = new QAccessibleWidget( object, ToolTip );
|
---|
194 | } else if ( classname == "QFrame" ) {
|
---|
195 | *iface = new QAccessibleWidget( object, Border );
|
---|
196 | } else if ( classname == "QWidgetStack" ) {
|
---|
197 | *iface = new QAccessibleWidgetStack( object );
|
---|
198 | } else if ( classname == "QWidget" ) {
|
---|
199 | *iface = new QAccessibleWidget( object );
|
---|
200 | } else if ( classname == "QScrollView" ) {
|
---|
201 | *iface = new QAccessibleScrollView( object, Client );
|
---|
202 | } else
|
---|
203 | return QE_NOINTERFACE;
|
---|
204 |
|
---|
205 | (*iface)->addRef();
|
---|
206 | return QS_OK;
|
---|
207 | }
|
---|
208 |
|
---|
209 | bool AccessibleFactory::init()
|
---|
210 | {
|
---|
211 | return TRUE;
|
---|
212 | }
|
---|
213 |
|
---|
214 | void AccessibleFactory::cleanup()
|
---|
215 | {
|
---|
216 | }
|
---|
217 |
|
---|
218 | bool AccessibleFactory::canUnload() const
|
---|
219 | {
|
---|
220 | return (QAccessibleWidget::objects == 0);
|
---|
221 | }
|
---|
222 |
|
---|
223 | Q_EXPORT_COMPONENT()
|
---|
224 | {
|
---|
225 | Q_CREATE_INSTANCE( AccessibleFactory )
|
---|
226 | }
|
---|