Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/accessible/complexwidgets.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||
2 | ** | - | ||||||||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||
5 | ** | - | ||||||||||||||||||
6 | ** This file is part of the plugins of the Qt Toolkit. | - | ||||||||||||||||||
7 | ** | - | ||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||
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 The Qt Company. For licensing terms | - | ||||||||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
15 | ** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free | - | ||||||||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||
25 | ** | - | ||||||||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||
29 | ** | - | ||||||||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
31 | ** | - | ||||||||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||||||||
33 | - | |||||||||||||||||||
34 | #include "complexwidgets_p.h" | - | ||||||||||||||||||
35 | - | |||||||||||||||||||
36 | #include <qaccessible.h> | - | ||||||||||||||||||
37 | #include <qapplication.h> | - | ||||||||||||||||||
38 | #include <qabstractbutton.h> | - | ||||||||||||||||||
39 | #include <qevent.h> | - | ||||||||||||||||||
40 | #include <qheaderview.h> | - | ||||||||||||||||||
41 | #include <qtabbar.h> | - | ||||||||||||||||||
42 | #include <qcombobox.h> | - | ||||||||||||||||||
43 | #include <qlistview.h> | - | ||||||||||||||||||
44 | #include <qtableview.h> | - | ||||||||||||||||||
45 | #include <qlineedit.h> | - | ||||||||||||||||||
46 | #include <qstyle.h> | - | ||||||||||||||||||
47 | #include <qstyleoption.h> | - | ||||||||||||||||||
48 | #include <qtooltip.h> | - | ||||||||||||||||||
49 | #include <qwhatsthis.h> | - | ||||||||||||||||||
50 | #include <qtreeview.h> | - | ||||||||||||||||||
51 | #include <private/qtabbar_p.h> | - | ||||||||||||||||||
52 | #include <QAbstractScrollArea> | - | ||||||||||||||||||
53 | #include <QScrollArea> | - | ||||||||||||||||||
54 | #include <QScrollBar> | - | ||||||||||||||||||
55 | #include <QDebug> | - | ||||||||||||||||||
56 | - | |||||||||||||||||||
57 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
58 | - | |||||||||||||||||||
59 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
60 | - | |||||||||||||||||||
61 | QString qt_accStripAmp(const QString &text); | - | ||||||||||||||||||
62 | QString qt_accHotKey(const QString &text); | - | ||||||||||||||||||
63 | - | |||||||||||||||||||
64 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
65 | /*! | - | ||||||||||||||||||
66 | \class QAccessibleTabBar | - | ||||||||||||||||||
67 | \brief The QAccessibleTabBar class implements the QAccessibleInterface for tab bars. | - | ||||||||||||||||||
68 | \internal | - | ||||||||||||||||||
69 | - | |||||||||||||||||||
70 | \ingroup accessibility | - | ||||||||||||||||||
71 | */ | - | ||||||||||||||||||
72 | - | |||||||||||||||||||
73 | class QAccessibleTabButton: public QAccessibleInterface, public QAccessibleActionInterface | - | ||||||||||||||||||
74 | { | - | ||||||||||||||||||
75 | public: | - | ||||||||||||||||||
76 | QAccessibleTabButton(QTabBar *parent, int index) | - | ||||||||||||||||||
77 | : m_parent(parent), m_index(index) | - | ||||||||||||||||||
78 | {} never executed: end of block | 0 | ||||||||||||||||||
79 | - | |||||||||||||||||||
80 | void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE { | - | ||||||||||||||||||
81 | if (t == QAccessible::ActionInterface) {
| 0 | ||||||||||||||||||
82 | return static_cast<QAccessibleActionInterface*>(this); never executed: return static_cast<QAccessibleActionInterface*>(this); | 0 | ||||||||||||||||||
83 | } | - | ||||||||||||||||||
84 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
85 | } | - | ||||||||||||||||||
86 | - | |||||||||||||||||||
87 | QObject *object() const Q_DECL_OVERRIDE { return 0; } never executed: return 0; | 0 | ||||||||||||||||||
88 | QAccessible::Role role() const Q_DECL_OVERRIDE { return QAccessible::PageTab; } never executed: return QAccessible::PageTab; | 0 | ||||||||||||||||||
89 | QAccessible::State state() const Q_DECL_OVERRIDE { | - | ||||||||||||||||||
90 | if (!isValid()) {
| 0 | ||||||||||||||||||
91 | QAccessible::State s; | - | ||||||||||||||||||
92 | s.invalid = true; | - | ||||||||||||||||||
93 | return s; never executed: return s; | 0 | ||||||||||||||||||
94 | } | - | ||||||||||||||||||
95 | return parent()->state(); never executed: return parent()->state(); | 0 | ||||||||||||||||||
96 | } | - | ||||||||||||||||||
97 | QRect rect() const Q_DECL_OVERRIDE { | - | ||||||||||||||||||
98 | if (!isValid())
| 0 | ||||||||||||||||||
99 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||
100 | - | |||||||||||||||||||
101 | QPoint tp = m_parent->mapToGlobal(QPoint(0,0)); | - | ||||||||||||||||||
102 | QRect rec = m_parent->tabRect(m_index); | - | ||||||||||||||||||
103 | rec = QRect(tp.x() + rec.x(), tp.y() + rec.y(), rec.width(), rec.height()); | - | ||||||||||||||||||
104 | return rec; never executed: return rec; | 0 | ||||||||||||||||||
105 | } | - | ||||||||||||||||||
106 | - | |||||||||||||||||||
107 | bool isValid() const Q_DECL_OVERRIDE { return m_parent.data() && m_parent->count() > m_index; } never executed: return m_parent.data() && m_parent->count() > m_index;
| 0 | ||||||||||||||||||
108 | - | |||||||||||||||||||
109 | QAccessibleInterface *childAt(int, int) const Q_DECL_OVERRIDE { return 0; } never executed: return 0; | 0 | ||||||||||||||||||
110 | int childCount() const Q_DECL_OVERRIDE { return 0; } never executed: return 0; | 0 | ||||||||||||||||||
111 | int indexOfChild(const QAccessibleInterface *) const Q_DECL_OVERRIDE { return -1; } never executed: return -1; | 0 | ||||||||||||||||||
112 | - | |||||||||||||||||||
113 | QString text(QAccessible::Text t) const Q_DECL_OVERRIDE | - | ||||||||||||||||||
114 | { | - | ||||||||||||||||||
115 | if (!isValid())
| 0 | ||||||||||||||||||
116 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
117 | switch (t) { | - | ||||||||||||||||||
118 | case QAccessible::Name: never executed: case QAccessible::Name: | 0 | ||||||||||||||||||
119 | return qt_accStripAmp(m_parent->tabText(m_index)); never executed: return qt_accStripAmp(m_parent->tabText(m_index)); | 0 | ||||||||||||||||||
120 | case QAccessible::Accelerator: never executed: case QAccessible::Accelerator: | 0 | ||||||||||||||||||
121 | return qt_accHotKey(m_parent->tabText(m_index)); never executed: return qt_accHotKey(m_parent->tabText(m_index)); | 0 | ||||||||||||||||||
122 | case QAccessible::Description: never executed: case QAccessible::Description: | 0 | ||||||||||||||||||
123 | return m_parent->tabToolTip(m_index); never executed: return m_parent->tabToolTip(m_index); | 0 | ||||||||||||||||||
124 | case QAccessible::Help: never executed: case QAccessible::Help: | 0 | ||||||||||||||||||
125 | return m_parent->tabWhatsThis(m_index); never executed: return m_parent->tabWhatsThis(m_index); | 0 | ||||||||||||||||||
126 | default: never executed: default: | 0 | ||||||||||||||||||
127 | break; never executed: break; | 0 | ||||||||||||||||||
128 | } | - | ||||||||||||||||||
129 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
130 | } | - | ||||||||||||||||||
131 | - | |||||||||||||||||||
132 | void setText(QAccessible::Text, const QString &) Q_DECL_OVERRIDE {} | - | ||||||||||||||||||
133 | - | |||||||||||||||||||
134 | QAccessibleInterface *parent() const Q_DECL_OVERRIDE { | - | ||||||||||||||||||
135 | return QAccessible::queryAccessibleInterface(m_parent.data()); never executed: return QAccessible::queryAccessibleInterface(m_parent.data()); | 0 | ||||||||||||||||||
136 | } | - | ||||||||||||||||||
137 | QAccessibleInterface *child(int) const Q_DECL_OVERRIDE { return 0; } never executed: return 0; | 0 | ||||||||||||||||||
138 | - | |||||||||||||||||||
139 | // action interface | - | ||||||||||||||||||
140 | QStringList actionNames() const Q_DECL_OVERRIDE | - | ||||||||||||||||||
141 | { | - | ||||||||||||||||||
142 | return QStringList(pressAction()); never executed: return QStringList(pressAction()); | 0 | ||||||||||||||||||
143 | } | - | ||||||||||||||||||
144 | - | |||||||||||||||||||
145 | void doAction(const QString &actionName) Q_DECL_OVERRIDE | - | ||||||||||||||||||
146 | { | - | ||||||||||||||||||
147 | if (isValid() && actionName == pressAction())
| 0 | ||||||||||||||||||
148 | m_parent->setCurrentIndex(m_index); never executed: m_parent->setCurrentIndex(m_index); | 0 | ||||||||||||||||||
149 | } never executed: end of block | 0 | ||||||||||||||||||
150 | - | |||||||||||||||||||
151 | QStringList keyBindingsForAction(const QString &) const Q_DECL_OVERRIDE | - | ||||||||||||||||||
152 | { | - | ||||||||||||||||||
153 | return QStringList(); never executed: return QStringList(); | 0 | ||||||||||||||||||
154 | } | - | ||||||||||||||||||
155 | - | |||||||||||||||||||
156 | int index() const { return m_index; } never executed: return m_index; | 0 | ||||||||||||||||||
157 | - | |||||||||||||||||||
158 | private: | - | ||||||||||||||||||
159 | QPointer<QTabBar> m_parent; | - | ||||||||||||||||||
160 | int m_index; | - | ||||||||||||||||||
161 | - | |||||||||||||||||||
162 | }; | - | ||||||||||||||||||
163 | - | |||||||||||||||||||
164 | /*! | - | ||||||||||||||||||
165 | Constructs a QAccessibleTabBar object for \a w. | - | ||||||||||||||||||
166 | */ | - | ||||||||||||||||||
167 | QAccessibleTabBar::QAccessibleTabBar(QWidget *w) | - | ||||||||||||||||||
168 | : QAccessibleWidget(w, QAccessible::PageTabList) | - | ||||||||||||||||||
169 | { | - | ||||||||||||||||||
170 | Q_ASSERT(tabBar()); | - | ||||||||||||||||||
171 | } never executed: end of block | 0 | ||||||||||||||||||
172 | - | |||||||||||||||||||
173 | QAccessibleTabBar::~QAccessibleTabBar() | - | ||||||||||||||||||
174 | { | - | ||||||||||||||||||
175 | foreach (QAccessible::Id id, m_childInterfaces) | - | ||||||||||||||||||
176 | QAccessible::deleteAccessibleInterface(id); never executed: QAccessible::deleteAccessibleInterface(id); | 0 | ||||||||||||||||||
177 | } never executed: end of block | 0 | ||||||||||||||||||
178 | - | |||||||||||||||||||
179 | /*! Returns the QTabBar. */ | - | ||||||||||||||||||
180 | QTabBar *QAccessibleTabBar::tabBar() const | - | ||||||||||||||||||
181 | { | - | ||||||||||||||||||
182 | return qobject_cast<QTabBar*>(object()); never executed: return qobject_cast<QTabBar*>(object()); | 0 | ||||||||||||||||||
183 | } | - | ||||||||||||||||||
184 | - | |||||||||||||||||||
185 | QAccessibleInterface* QAccessibleTabBar::child(int index) const | - | ||||||||||||||||||
186 | { | - | ||||||||||||||||||
187 | if (QAccessible::Id id = m_childInterfaces.value(index))
| 0 | ||||||||||||||||||
188 | return QAccessible::accessibleInterface(id); never executed: return QAccessible::accessibleInterface(id); | 0 | ||||||||||||||||||
189 | - | |||||||||||||||||||
190 | // first the tabs, then 2 buttons | - | ||||||||||||||||||
191 | if (index < tabBar()->count()) {
| 0 | ||||||||||||||||||
192 | QAccessibleTabButton *button = new QAccessibleTabButton(tabBar(), index); | - | ||||||||||||||||||
193 | QAccessible::registerAccessibleInterface(button); | - | ||||||||||||||||||
194 | m_childInterfaces.insert(index, QAccessible::uniqueId(button)); | - | ||||||||||||||||||
195 | return button; never executed: return button; | 0 | ||||||||||||||||||
196 | } else if (index >= tabBar()->count()) {
| 0 | ||||||||||||||||||
197 | // left button | - | ||||||||||||||||||
198 | if (index - tabBar()->count() == 0) {
| 0 | ||||||||||||||||||
199 | return QAccessible::queryAccessibleInterface(tabBar()->d_func()->leftB); never executed: return QAccessible::queryAccessibleInterface(tabBar()->d_func()->leftB); | 0 | ||||||||||||||||||
200 | } | - | ||||||||||||||||||
201 | // right button | - | ||||||||||||||||||
202 | if (index - tabBar()->count() == 1) {
| 0 | ||||||||||||||||||
203 | return QAccessible::queryAccessibleInterface(tabBar()->d_func()->rightB); never executed: return QAccessible::queryAccessibleInterface(tabBar()->d_func()->rightB); | 0 | ||||||||||||||||||
204 | } | - | ||||||||||||||||||
205 | } never executed: end of block | 0 | ||||||||||||||||||
206 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
207 | } | - | ||||||||||||||||||
208 | - | |||||||||||||||||||
209 | int QAccessibleTabBar::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
210 | { | - | ||||||||||||||||||
211 | if (child->object() && child->object() == tabBar()->d_func()->leftB)
| 0 | ||||||||||||||||||
212 | return tabBar()->count(); never executed: return tabBar()->count(); | 0 | ||||||||||||||||||
213 | if (child->object() && child->object() == tabBar()->d_func()->rightB)
| 0 | ||||||||||||||||||
214 | return tabBar()->count() + 1; never executed: return tabBar()->count() + 1; | 0 | ||||||||||||||||||
215 | if (child->role() == QAccessible::PageTab) {
| 0 | ||||||||||||||||||
216 | QAccessibleInterface *parent = child->parent(); | - | ||||||||||||||||||
217 | if (parent == this) {
| 0 | ||||||||||||||||||
218 | const QAccessibleTabButton *tabButton = static_cast<const QAccessibleTabButton *>(child); | - | ||||||||||||||||||
219 | return tabButton->index(); never executed: return tabButton->index(); | 0 | ||||||||||||||||||
220 | } | - | ||||||||||||||||||
221 | } never executed: end of block | 0 | ||||||||||||||||||
222 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
223 | } | - | ||||||||||||||||||
224 | - | |||||||||||||||||||
225 | int QAccessibleTabBar::childCount() const | - | ||||||||||||||||||
226 | { | - | ||||||||||||||||||
227 | // tabs + scroll buttons | - | ||||||||||||||||||
228 | return tabBar()->count() + 2; never executed: return tabBar()->count() + 2; | 0 | ||||||||||||||||||
229 | } | - | ||||||||||||||||||
230 | - | |||||||||||||||||||
231 | QString QAccessibleTabBar::text(QAccessible::Text t) const | - | ||||||||||||||||||
232 | { | - | ||||||||||||||||||
233 | if (t == QAccessible::Name) {
| 0 | ||||||||||||||||||
234 | return qt_accStripAmp(tabBar()->tabText(tabBar()->currentIndex())); never executed: return qt_accStripAmp(tabBar()->tabText(tabBar()->currentIndex())); | 0 | ||||||||||||||||||
235 | } else if (t == QAccessible::Accelerator) {
| 0 | ||||||||||||||||||
236 | return qt_accHotKey(tabBar()->tabText(tabBar()->currentIndex())); never executed: return qt_accHotKey(tabBar()->tabText(tabBar()->currentIndex())); | 0 | ||||||||||||||||||
237 | } | - | ||||||||||||||||||
238 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
239 | } | - | ||||||||||||||||||
240 | - | |||||||||||||||||||
241 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||
242 | - | |||||||||||||||||||
243 | #ifndef QT_NO_COMBOBOX | - | ||||||||||||||||||
244 | /*! | - | ||||||||||||||||||
245 | \class QAccessibleComboBox | - | ||||||||||||||||||
246 | \brief The QAccessibleComboBox class implements the QAccessibleInterface for editable and read-only combo boxes. | - | ||||||||||||||||||
247 | \internal | - | ||||||||||||||||||
248 | - | |||||||||||||||||||
249 | \ingroup accessibility | - | ||||||||||||||||||
250 | */ | - | ||||||||||||||||||
251 | - | |||||||||||||||||||
252 | /*! | - | ||||||||||||||||||
253 | Constructs a QAccessibleComboBox object for \a w. | - | ||||||||||||||||||
254 | */ | - | ||||||||||||||||||
255 | QAccessibleComboBox::QAccessibleComboBox(QWidget *w) | - | ||||||||||||||||||
256 | : QAccessibleWidget(w, QAccessible::ComboBox) | - | ||||||||||||||||||
257 | { | - | ||||||||||||||||||
258 | Q_ASSERT(comboBox()); | - | ||||||||||||||||||
259 | } never executed: end of block | 0 | ||||||||||||||||||
260 | - | |||||||||||||||||||
261 | /*! | - | ||||||||||||||||||
262 | Returns the combobox. | - | ||||||||||||||||||
263 | */ | - | ||||||||||||||||||
264 | QComboBox *QAccessibleComboBox::comboBox() const | - | ||||||||||||||||||
265 | { | - | ||||||||||||||||||
266 | return qobject_cast<QComboBox*>(object()); never executed: return qobject_cast<QComboBox*>(object()); | 0 | ||||||||||||||||||
267 | } | - | ||||||||||||||||||
268 | - | |||||||||||||||||||
269 | QAccessibleInterface *QAccessibleComboBox::child(int index) const | - | ||||||||||||||||||
270 | { | - | ||||||||||||||||||
271 | if (index == 0) {
| 0 | ||||||||||||||||||
272 | QAbstractItemView *view = comboBox()->view(); | - | ||||||||||||||||||
273 | //QWidget *parent = view ? view->parentWidget() : 0; | - | ||||||||||||||||||
274 | return QAccessible::queryAccessibleInterface(view); never executed: return QAccessible::queryAccessibleInterface(view); | 0 | ||||||||||||||||||
275 | } else if (index == 1 && comboBox()->isEditable()) {
| 0 | ||||||||||||||||||
276 | return QAccessible::queryAccessibleInterface(comboBox()->lineEdit()); never executed: return QAccessible::queryAccessibleInterface(comboBox()->lineEdit()); | 0 | ||||||||||||||||||
277 | } | - | ||||||||||||||||||
278 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
279 | } | - | ||||||||||||||||||
280 | - | |||||||||||||||||||
281 | int QAccessibleComboBox::childCount() const | - | ||||||||||||||||||
282 | { | - | ||||||||||||||||||
283 | // list and text edit | - | ||||||||||||||||||
284 | return comboBox()->isEditable() ? 2 : 1; never executed: return comboBox()->isEditable() ? 2 : 1;
| 0 | ||||||||||||||||||
285 | } | - | ||||||||||||||||||
286 | - | |||||||||||||||||||
287 | QAccessibleInterface *QAccessibleComboBox::childAt(int x, int y) const | - | ||||||||||||||||||
288 | { | - | ||||||||||||||||||
289 | if (comboBox()->isEditable() && comboBox()->lineEdit()->rect().contains(x, y))
| 0 | ||||||||||||||||||
290 | return child(1); never executed: return child(1); | 0 | ||||||||||||||||||
291 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
292 | } | - | ||||||||||||||||||
293 | - | |||||||||||||||||||
294 | int QAccessibleComboBox::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
295 | { | - | ||||||||||||||||||
296 | if (comboBox()->view() == child->object())
| 0 | ||||||||||||||||||
297 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
298 | if (comboBox()->isEditable() && comboBox()->lineEdit() == child->object())
| 0 | ||||||||||||||||||
299 | return 1; never executed: return 1; | 0 | ||||||||||||||||||
300 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
301 | } | - | ||||||||||||||||||
302 | - | |||||||||||||||||||
303 | /*! \reimp */ | - | ||||||||||||||||||
304 | QString QAccessibleComboBox::text(QAccessible::Text t) const | - | ||||||||||||||||||
305 | { | - | ||||||||||||||||||
306 | QString str; | - | ||||||||||||||||||
307 | - | |||||||||||||||||||
308 | switch (t) { | - | ||||||||||||||||||
309 | case QAccessible::Name: never executed: case QAccessible::Name: | 0 | ||||||||||||||||||
310 | #ifndef Q_OS_UNIX // on Linux we use relations for this, name is text (fall through to Value) | - | ||||||||||||||||||
311 | str = QAccessibleWidget::text(t); | - | ||||||||||||||||||
312 | break; | - | ||||||||||||||||||
313 | #endif | - | ||||||||||||||||||
314 | case QAccessible::Value: never executed: case QAccessible::Value: | 0 | ||||||||||||||||||
315 | if (comboBox()->isEditable())
| 0 | ||||||||||||||||||
316 | str = comboBox()->lineEdit()->text(); never executed: str = comboBox()->lineEdit()->text(); | 0 | ||||||||||||||||||
317 | else | - | ||||||||||||||||||
318 | str = comboBox()->currentText(); never executed: str = comboBox()->currentText(); | 0 | ||||||||||||||||||
319 | break; never executed: break; | 0 | ||||||||||||||||||
320 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||
321 | case QAccessible::Accelerator: never executed: case QAccessible::Accelerator: | 0 | ||||||||||||||||||
322 | str = QKeySequence(Qt::Key_Down).toString(QKeySequence::NativeText); | - | ||||||||||||||||||
323 | break; never executed: break; | 0 | ||||||||||||||||||
324 | #endif | - | ||||||||||||||||||
325 | default: never executed: default: | 0 | ||||||||||||||||||
326 | break; never executed: break; | 0 | ||||||||||||||||||
327 | } | - | ||||||||||||||||||
328 | if (str.isEmpty())
| 0 | ||||||||||||||||||
329 | str = QAccessibleWidget::text(t); never executed: str = QAccessibleWidget::text(t); | 0 | ||||||||||||||||||
330 | return str; never executed: return str; | 0 | ||||||||||||||||||
331 | } | - | ||||||||||||||||||
332 | - | |||||||||||||||||||
333 | QStringList QAccessibleComboBox::actionNames() const | - | ||||||||||||||||||
334 | { | - | ||||||||||||||||||
335 | return QStringList() << showMenuAction() << pressAction(); never executed: return QStringList() << showMenuAction() << pressAction(); | 0 | ||||||||||||||||||
336 | } | - | ||||||||||||||||||
337 | - | |||||||||||||||||||
338 | QString QAccessibleComboBox::localizedActionDescription(const QString &actionName) const | - | ||||||||||||||||||
339 | { | - | ||||||||||||||||||
340 | if (actionName == showMenuAction() || actionName == pressAction())
| 0 | ||||||||||||||||||
341 | return QComboBox::tr("Open the combo box selection popup"); never executed: return QComboBox::tr("Open the combo box selection popup"); | 0 | ||||||||||||||||||
342 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
343 | } | - | ||||||||||||||||||
344 | - | |||||||||||||||||||
345 | void QAccessibleComboBox::doAction(const QString &actionName) | - | ||||||||||||||||||
346 | { | - | ||||||||||||||||||
347 | if (actionName == showMenuAction() || actionName == pressAction()) {
| 0 | ||||||||||||||||||
348 | if (comboBox()->view()->isVisible()) {
| 0 | ||||||||||||||||||
349 | comboBox()->hidePopup(); | - | ||||||||||||||||||
350 | } else { never executed: end of block | 0 | ||||||||||||||||||
351 | comboBox()->showPopup(); | - | ||||||||||||||||||
352 | } never executed: end of block | 0 | ||||||||||||||||||
353 | } | - | ||||||||||||||||||
354 | } never executed: end of block | 0 | ||||||||||||||||||
355 | - | |||||||||||||||||||
356 | QStringList QAccessibleComboBox::keyBindingsForAction(const QString &/*actionName*/) const | - | ||||||||||||||||||
357 | { | - | ||||||||||||||||||
358 | return QStringList(); never executed: return QStringList(); | 0 | ||||||||||||||||||
359 | } | - | ||||||||||||||||||
360 | - | |||||||||||||||||||
361 | #endif // QT_NO_COMBOBOX | - | ||||||||||||||||||
362 | - | |||||||||||||||||||
363 | #ifndef QT_NO_SCROLLAREA | - | ||||||||||||||||||
364 | // ======================= QAccessibleAbstractScrollArea ======================= | - | ||||||||||||||||||
365 | QAccessibleAbstractScrollArea::QAccessibleAbstractScrollArea(QWidget *widget) | - | ||||||||||||||||||
366 | : QAccessibleWidget(widget, QAccessible::Client) | - | ||||||||||||||||||
367 | { | - | ||||||||||||||||||
368 | Q_ASSERT(qobject_cast<QAbstractScrollArea *>(widget)); | - | ||||||||||||||||||
369 | } never executed: end of block | 0 | ||||||||||||||||||
370 | - | |||||||||||||||||||
371 | QAccessibleInterface *QAccessibleAbstractScrollArea::child(int index) const | - | ||||||||||||||||||
372 | { | - | ||||||||||||||||||
373 | return QAccessible::queryAccessibleInterface(accessibleChildren().at(index)); never executed: return QAccessible::queryAccessibleInterface(accessibleChildren().at(index)); | 0 | ||||||||||||||||||
374 | } | - | ||||||||||||||||||
375 | - | |||||||||||||||||||
376 | int QAccessibleAbstractScrollArea::childCount() const | - | ||||||||||||||||||
377 | { | - | ||||||||||||||||||
378 | return accessibleChildren().count(); never executed: return accessibleChildren().count(); | 0 | ||||||||||||||||||
379 | } | - | ||||||||||||||||||
380 | - | |||||||||||||||||||
381 | int QAccessibleAbstractScrollArea::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
382 | { | - | ||||||||||||||||||
383 | if (!child || !child->object())
| 0 | ||||||||||||||||||
384 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
385 | return accessibleChildren().indexOf(qobject_cast<QWidget *>(child->object())); never executed: return accessibleChildren().indexOf(qobject_cast<QWidget *>(child->object())); | 0 | ||||||||||||||||||
386 | } | - | ||||||||||||||||||
387 | - | |||||||||||||||||||
388 | bool QAccessibleAbstractScrollArea::isValid() const | - | ||||||||||||||||||
389 | { | - | ||||||||||||||||||
390 | return (QAccessibleWidget::isValid() && abstractScrollArea() && abstractScrollArea()->viewport()); never executed: return (QAccessibleWidget::isValid() && abstractScrollArea() && abstractScrollArea()->viewport());
| 0 | ||||||||||||||||||
391 | } | - | ||||||||||||||||||
392 | - | |||||||||||||||||||
393 | QAccessibleInterface *QAccessibleAbstractScrollArea::childAt(int x, int y) const | - | ||||||||||||||||||
394 | { | - | ||||||||||||||||||
395 | if (!abstractScrollArea()->isVisible())
| 0 | ||||||||||||||||||
396 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
397 | - | |||||||||||||||||||
398 | for (int i = 0; i < childCount(); ++i) {
| 0 | ||||||||||||||||||
399 | QPoint wpos = accessibleChildren().at(i)->mapToGlobal(QPoint(0, 0)); | - | ||||||||||||||||||
400 | QRect rect = QRect(wpos, accessibleChildren().at(i)->size()); | - | ||||||||||||||||||
401 | if (rect.contains(x, y))
| 0 | ||||||||||||||||||
402 | return child(i); never executed: return child(i); | 0 | ||||||||||||||||||
403 | } never executed: end of block | 0 | ||||||||||||||||||
404 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
405 | } | - | ||||||||||||||||||
406 | - | |||||||||||||||||||
407 | QAbstractScrollArea *QAccessibleAbstractScrollArea::abstractScrollArea() const | - | ||||||||||||||||||
408 | { | - | ||||||||||||||||||
409 | return static_cast<QAbstractScrollArea *>(object()); never executed: return static_cast<QAbstractScrollArea *>(object()); | 0 | ||||||||||||||||||
410 | } | - | ||||||||||||||||||
411 | - | |||||||||||||||||||
412 | QWidgetList QAccessibleAbstractScrollArea::accessibleChildren() const | - | ||||||||||||||||||
413 | { | - | ||||||||||||||||||
414 | QWidgetList children; | - | ||||||||||||||||||
415 | - | |||||||||||||||||||
416 | // Viewport. | - | ||||||||||||||||||
417 | QWidget * viewport = abstractScrollArea()->viewport(); | - | ||||||||||||||||||
418 | if (viewport)
| 0 | ||||||||||||||||||
419 | children.append(viewport); never executed: children.append(viewport); | 0 | ||||||||||||||||||
420 | - | |||||||||||||||||||
421 | // Horizontal scrollBar container. | - | ||||||||||||||||||
422 | QScrollBar *horizontalScrollBar = abstractScrollArea()->horizontalScrollBar(); | - | ||||||||||||||||||
423 | if (horizontalScrollBar && horizontalScrollBar->isVisible()) {
| 0 | ||||||||||||||||||
424 | children.append(horizontalScrollBar->parentWidget()); | - | ||||||||||||||||||
425 | } never executed: end of block | 0 | ||||||||||||||||||
426 | - | |||||||||||||||||||
427 | // Vertical scrollBar container. | - | ||||||||||||||||||
428 | QScrollBar *verticalScrollBar = abstractScrollArea()->verticalScrollBar(); | - | ||||||||||||||||||
429 | if (verticalScrollBar && verticalScrollBar->isVisible()) {
| 0 | ||||||||||||||||||
430 | children.append(verticalScrollBar->parentWidget()); | - | ||||||||||||||||||
431 | } never executed: end of block | 0 | ||||||||||||||||||
432 | - | |||||||||||||||||||
433 | // CornerWidget. | - | ||||||||||||||||||
434 | QWidget *cornerWidget = abstractScrollArea()->cornerWidget(); | - | ||||||||||||||||||
435 | if (cornerWidget && cornerWidget->isVisible())
| 0 | ||||||||||||||||||
436 | children.append(cornerWidget); never executed: children.append(cornerWidget); | 0 | ||||||||||||||||||
437 | - | |||||||||||||||||||
438 | return children; never executed: return children; | 0 | ||||||||||||||||||
439 | } | - | ||||||||||||||||||
440 | - | |||||||||||||||||||
441 | QAccessibleAbstractScrollArea::AbstractScrollAreaElement | - | ||||||||||||||||||
442 | QAccessibleAbstractScrollArea::elementType(QWidget *widget) const | - | ||||||||||||||||||
443 | { | - | ||||||||||||||||||
444 | if (!widget)
| 0 | ||||||||||||||||||
445 | return Undefined; never executed: return Undefined; | 0 | ||||||||||||||||||
446 | - | |||||||||||||||||||
447 | if (widget == abstractScrollArea())
| 0 | ||||||||||||||||||
448 | return Self; never executed: return Self; | 0 | ||||||||||||||||||
449 | if (widget == abstractScrollArea()->viewport())
| 0 | ||||||||||||||||||
450 | return Viewport; never executed: return Viewport; | 0 | ||||||||||||||||||
451 | if (widget->objectName() == QLatin1String("qt_scrollarea_hcontainer"))
| 0 | ||||||||||||||||||
452 | return HorizontalContainer; never executed: return HorizontalContainer; | 0 | ||||||||||||||||||
453 | if (widget->objectName() == QLatin1String("qt_scrollarea_vcontainer"))
| 0 | ||||||||||||||||||
454 | return VerticalContainer; never executed: return VerticalContainer; | 0 | ||||||||||||||||||
455 | if (widget == abstractScrollArea()->cornerWidget())
| 0 | ||||||||||||||||||
456 | return CornerWidget; never executed: return CornerWidget; | 0 | ||||||||||||||||||
457 | - | |||||||||||||||||||
458 | return Undefined; never executed: return Undefined; | 0 | ||||||||||||||||||
459 | } | - | ||||||||||||||||||
460 | - | |||||||||||||||||||
461 | bool QAccessibleAbstractScrollArea::isLeftToRight() const | - | ||||||||||||||||||
462 | { | - | ||||||||||||||||||
463 | return abstractScrollArea()->isLeftToRight(); never executed: return abstractScrollArea()->isLeftToRight(); | 0 | ||||||||||||||||||
464 | } | - | ||||||||||||||||||
465 | - | |||||||||||||||||||
466 | // ======================= QAccessibleScrollArea =========================== | - | ||||||||||||||||||
467 | QAccessibleScrollArea::QAccessibleScrollArea(QWidget *widget) | - | ||||||||||||||||||
468 | : QAccessibleAbstractScrollArea(widget) | - | ||||||||||||||||||
469 | { | - | ||||||||||||||||||
470 | Q_ASSERT(qobject_cast<QScrollArea *>(widget)); | - | ||||||||||||||||||
471 | } never executed: end of block | 0 | ||||||||||||||||||
472 | #endif // QT_NO_SCROLLAREA | - | ||||||||||||||||||
473 | - | |||||||||||||||||||
474 | QT_END_NAMESPACE | - | ||||||||||||||||||
475 | - | |||||||||||||||||||
476 | #endif // QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |