rangecontrols.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/accessible/rangecontrols.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
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 The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://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 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "rangecontrols_p.h"-
41-
42#include <qslider.h>-
43#include <qdial.h>-
44#include <qspinbox.h>-
45#include <qscrollbar.h>-
46#include <qstyle.h>-
47#include <qstyleoption.h>-
48#include <qdebug.h>-
49#include <qglobal.h>-
50#include <QDoubleSpinBox>-
51#include <QDial>-
52#include <QtWidgets/qlineedit.h>-
53#include <qmath.h>-
54#include <private/qmath_p.h>-
55-
56#include "simplewidgets_p.h" // let spinbox use line edit's interface-
57-
58QT_BEGIN_NAMESPACE-
59-
60#ifndef QT_NO_ACCESSIBILITY-
61-
62#ifndef QT_NO_SPINBOX-
63QAccessibleAbstractSpinBox::QAccessibleAbstractSpinBox(QWidget *w)-
64: QAccessibleWidget(w, QAccessible::SpinBox), lineEdit(Q_NULLPTR)-
65{-
66 Q_ASSERT(abstractSpinBox());-
67}
never executed: end of block
0
68-
69QAccessibleAbstractSpinBox::~QAccessibleAbstractSpinBox()-
70{-
71 delete lineEdit;-
72}
never executed: end of block
0
73-
74/*!-
75 Returns the underlying QAbstractSpinBox.-
76*/-
77QAbstractSpinBox *QAccessibleAbstractSpinBox::abstractSpinBox() const-
78{-
79 return qobject_cast<QAbstractSpinBox*>(object());
never executed: return qobject_cast<QAbstractSpinBox*>(object());
0
80}-
81-
82QAccessibleInterface *QAccessibleAbstractSpinBox::lineEditIface() const-
83{-
84 // QAccessibleLineEdit is only used to forward the text functions-
85 if (!lineEdit)
!lineEditDescription
TRUEnever evaluated
FALSEnever evaluated
0
86 lineEdit = new QAccessibleLineEdit(abstractSpinBox()->lineEdit());
never executed: lineEdit = new QAccessibleLineEdit(abstractSpinBox()->lineEdit());
0
87 return lineEdit;
never executed: return lineEdit;
0
88}-
89-
90QString QAccessibleAbstractSpinBox::text(QAccessible::Text t) const-
91{-
92 if (t == QAccessible::Value)
t == QAccessible::ValueDescription
TRUEnever evaluated
FALSEnever evaluated
0
93 return abstractSpinBox()->text();
never executed: return abstractSpinBox()->text();
0
94 return QAccessibleWidget::text(t);
never executed: return QAccessibleWidget::text(t);
0
95}-
96-
97void *QAccessibleAbstractSpinBox::interface_cast(QAccessible::InterfaceType t)-
98{-
99 if (t == QAccessible::ValueInterface)
t == QAccessib...ValueInterfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
100 return static_cast<QAccessibleValueInterface*>(this);
never executed: return static_cast<QAccessibleValueInterface*>(this);
0
101 if (t == QAccessible::TextInterface)
t == QAccessib...:TextInterfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
102 return static_cast<QAccessibleTextInterface*>(this);
never executed: return static_cast<QAccessibleTextInterface*>(this);
0
103 if (t == QAccessible::EditableTextInterface)
t == QAccessib...eTextInterfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
104 return static_cast<QAccessibleEditableTextInterface*>(this);
never executed: return static_cast<QAccessibleEditableTextInterface*>(this);
0
105 return QAccessibleWidget::interface_cast(t);
never executed: return QAccessibleWidget::interface_cast(t);
0
106}-
107-
108QVariant QAccessibleAbstractSpinBox::currentValue() const-
109{-
110 return abstractSpinBox()->property("value");
never executed: return abstractSpinBox()->property("value");
0
111}-
112-
113void QAccessibleAbstractSpinBox::setCurrentValue(const QVariant &value)-
114{-
115 abstractSpinBox()->setProperty("value", value);-
116}
never executed: end of block
0
117-
118QVariant QAccessibleAbstractSpinBox::maximumValue() const-
119{-
120 return abstractSpinBox()->property("maximum");
never executed: return abstractSpinBox()->property("maximum");
0
121}-
122-
123QVariant QAccessibleAbstractSpinBox::minimumValue() const-
124{-
125 return abstractSpinBox()->property("minimum");
never executed: return abstractSpinBox()->property("minimum");
0
126}-
127-
128QVariant QAccessibleAbstractSpinBox::minimumStepSize() const-
129{-
130 return abstractSpinBox()->property("stepSize");
never executed: return abstractSpinBox()->property("stepSize");
0
131}-
132-
133void QAccessibleAbstractSpinBox::addSelection(int startOffset, int endOffset)-
134{-
135 lineEditIface()->textInterface()->addSelection(startOffset, endOffset);-
136}
never executed: end of block
0
137-
138QString QAccessibleAbstractSpinBox::attributes(int offset, int *startOffset, int *endOffset) const-
139{-
140 return lineEditIface()->textInterface()->attributes(offset, startOffset, endOffset);
never executed: return lineEditIface()->textInterface()->attributes(offset, startOffset, endOffset);
0
141}-
142-
143int QAccessibleAbstractSpinBox::cursorPosition() const-
144{-
145 return lineEditIface()->textInterface()->cursorPosition();
never executed: return lineEditIface()->textInterface()->cursorPosition();
0
146}-
147-
148QRect QAccessibleAbstractSpinBox::characterRect(int offset) const-
149{-
150 return lineEditIface()->textInterface()->characterRect(offset);
never executed: return lineEditIface()->textInterface()->characterRect(offset);
0
151}-
152-
153int QAccessibleAbstractSpinBox::selectionCount() const-
154{-
155 return lineEditIface()->textInterface()->selectionCount();
never executed: return lineEditIface()->textInterface()->selectionCount();
0
156}-
157-
158int QAccessibleAbstractSpinBox::offsetAtPoint(const QPoint &point) const-
159{-
160 return lineEditIface()->textInterface()->offsetAtPoint(point);
never executed: return lineEditIface()->textInterface()->offsetAtPoint(point);
0
161}-
162-
163void QAccessibleAbstractSpinBox::selection(int selectionIndex, int *startOffset, int *endOffset) const-
164{-
165 lineEditIface()->textInterface()->selection(selectionIndex, startOffset, endOffset);-
166}
never executed: end of block
0
167-
168QString QAccessibleAbstractSpinBox::text(int startOffset, int endOffset) const-
169{-
170 return lineEditIface()->textInterface()->text(startOffset, endOffset);
never executed: return lineEditIface()->textInterface()->text(startOffset, endOffset);
0
171}-
172-
173QString QAccessibleAbstractSpinBox::textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const-
174{-
175 return lineEditIface()->textInterface()->textBeforeOffset(offset, boundaryType, startOffset, endOffset);
never executed: return lineEditIface()->textInterface()->textBeforeOffset(offset, boundaryType, startOffset, endOffset);
0
176}-
177-
178QString QAccessibleAbstractSpinBox::textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const-
179{-
180 return lineEditIface()->textInterface()->textAfterOffset(offset, boundaryType, startOffset, endOffset);
never executed: return lineEditIface()->textInterface()->textAfterOffset(offset, boundaryType, startOffset, endOffset);
0
181}-
182-
183QString QAccessibleAbstractSpinBox::textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const-
184{-
185 return lineEditIface()->textInterface()->textAtOffset(offset, boundaryType, startOffset, endOffset);
never executed: return lineEditIface()->textInterface()->textAtOffset(offset, boundaryType, startOffset, endOffset);
0
186}-
187-
188void QAccessibleAbstractSpinBox::removeSelection(int selectionIndex)-
189{-
190 lineEditIface()->textInterface()->removeSelection(selectionIndex);-
191}
never executed: end of block
0
192-
193void QAccessibleAbstractSpinBox::setCursorPosition(int position)-
194{-
195 lineEditIface()->textInterface()->setCursorPosition(position);-
196}
never executed: end of block
0
197-
198void QAccessibleAbstractSpinBox::setSelection(int selectionIndex, int startOffset, int endOffset)-
199{-
200 lineEditIface()->textInterface()->setSelection(selectionIndex, startOffset, endOffset);-
201}
never executed: end of block
0
202-
203int QAccessibleAbstractSpinBox::characterCount() const-
204{-
205 return lineEditIface()->textInterface()->characterCount();
never executed: return lineEditIface()->textInterface()->characterCount();
0
206}-
207-
208void QAccessibleAbstractSpinBox::scrollToSubstring(int startIndex, int endIndex)-
209{-
210 lineEditIface()->textInterface()->scrollToSubstring(startIndex, endIndex);-
211}
never executed: end of block
0
212-
213void QAccessibleAbstractSpinBox::deleteText(int startOffset, int endOffset)-
214{-
215 lineEditIface()->editableTextInterface()->deleteText(startOffset, endOffset);-
216}
never executed: end of block
0
217-
218void QAccessibleAbstractSpinBox::insertText(int offset, const QString &text)-
219{-
220 lineEditIface()->editableTextInterface()->insertText(offset, text);-
221}
never executed: end of block
0
222-
223void QAccessibleAbstractSpinBox::replaceText(int startOffset, int endOffset, const QString &text)-
224{-
225 lineEditIface()->editableTextInterface()->replaceText(startOffset, endOffset, text);-
226}
never executed: end of block
0
227-
228-
229/*!-
230 \class QAccessibleSpinBox-
231 \brief The QAccessibleSpinBox class implements the QAccessibleInterface for spinbox widgets.-
232 \internal-
233-
234 \ingroup accessibility-
235*/-
236-
237/*!-
238 Constructs a QAccessibleSpinWidget object for \a w.-
239*/-
240QAccessibleSpinBox::QAccessibleSpinBox(QWidget *w)-
241: QAccessibleAbstractSpinBox(w)-
242{-
243 Q_ASSERT(spinBox());-
244 addControllingSignal(QLatin1String("valueChanged(int)"));-
245 addControllingSignal(QLatin1String("valueChanged(QString)"));-
246}
never executed: end of block
0
247-
248/*!-
249 Returns the underlying QSpinBox.-
250*/-
251QSpinBox *QAccessibleSpinBox::spinBox() const-
252{-
253 return qobject_cast<QSpinBox*>(object());
never executed: return qobject_cast<QSpinBox*>(object());
0
254}-
255-
256-
257// ================================== QAccessibleDoubleSpinBox ==================================-
258QAccessibleDoubleSpinBox::QAccessibleDoubleSpinBox(QWidget *widget)-
259 : QAccessibleAbstractSpinBox(widget)-
260{-
261 Q_ASSERT(qobject_cast<QDoubleSpinBox *>(widget));-
262 addControllingSignal(QLatin1String("valueChanged(double)"));-
263 addControllingSignal(QLatin1String("valueChanged(QString)"));-
264}
never executed: end of block
0
265-
266/*!-
267 Returns the underlying QDoubleSpinBox.-
268*/-
269QDoubleSpinBox *QAccessibleDoubleSpinBox::doubleSpinBox() const-
270{-
271 return static_cast<QDoubleSpinBox*>(object());
never executed: return static_cast<QDoubleSpinBox*>(object());
0
272}-
273-
274QString QAccessibleDoubleSpinBox::text(QAccessible::Text textType) const-
275{-
276 if (textType == QAccessible::Value)
textType == QAccessible::ValueDescription
TRUEnever evaluated
FALSEnever evaluated
0
277 return doubleSpinBox()->textFromValue(doubleSpinBox()->value());
never executed: return doubleSpinBox()->textFromValue(doubleSpinBox()->value());
0
278 return QAccessibleWidget::text(textType);
never executed: return QAccessibleWidget::text(textType);
0
279}-
280-
281#endif // QT_NO_SPINBOX-
282-
283#ifndef QT_NO_SCROLLBAR-
284/*!-
285 \class QAccessibleScrollBar-
286 \brief The QAccessibleScrollBar class implements the QAccessibleInterface for scroll bars.-
287 \internal-
288-
289 \ingroup accessibility-
290*/-
291-
292/*!-
293 Constructs a QAccessibleScrollBar object for \a w.-
294 \a name is propagated to the QAccessibleWidget constructor.-
295*/-
296QAccessibleScrollBar::QAccessibleScrollBar(QWidget *w)-
297: QAccessibleAbstractSlider(w, QAccessible::ScrollBar)-
298{-
299 Q_ASSERT(scrollBar());-
300 addControllingSignal(QLatin1String("valueChanged(int)"));-
301}
never executed: end of block
0
302-
303/*! Returns the scroll bar. */-
304QScrollBar *QAccessibleScrollBar::scrollBar() const-
305{-
306 return qobject_cast<QScrollBar*>(object());
never executed: return qobject_cast<QScrollBar*>(object());
0
307}-
308-
309QString QAccessibleScrollBar::text(QAccessible::Text t) const-
310{-
311 if (t == QAccessible::Value)
t == QAccessible::ValueDescription
TRUEnever evaluated
FALSEnever evaluated
0
312 return QString::number(scrollBar()->value());
never executed: return QString::number(scrollBar()->value());
0
313 return QAccessibleAbstractSlider::text(t);
never executed: return QAccessibleAbstractSlider::text(t);
0
314}-
315-
316#endif // QT_NO_SCROLLBAR-
317-
318#ifndef QT_NO_SLIDER-
319/*!-
320 \class QAccessibleSlider-
321 \brief The QAccessibleSlider class implements the QAccessibleInterface for sliders.-
322 \internal-
323-
324 \ingroup accessibility-
325*/-
326-
327/*!-
328 Constructs a QAccessibleScrollBar object for \a w.-
329 \a name is propagated to the QAccessibleWidget constructor.-
330*/-
331QAccessibleSlider::QAccessibleSlider(QWidget *w)-
332: QAccessibleAbstractSlider(w)-
333{-
334 Q_ASSERT(slider());-
335 addControllingSignal(QLatin1String("valueChanged(int)"));-
336}
never executed: end of block
0
337-
338/*! Returns the slider. */-
339QSlider *QAccessibleSlider::slider() const-
340{-
341 return qobject_cast<QSlider*>(object());
never executed: return qobject_cast<QSlider*>(object());
0
342}-
343-
344QString QAccessibleSlider::text(QAccessible::Text t) const-
345{-
346 if (t == QAccessible::Value)
t == QAccessible::ValueDescription
TRUEnever evaluated
FALSEnever evaluated
0
347 return QString::number(slider()->value());
never executed: return QString::number(slider()->value());
0
348-
349 return QAccessibleAbstractSlider::text(t);
never executed: return QAccessibleAbstractSlider::text(t);
0
350}-
351-
352QAccessibleAbstractSlider::QAccessibleAbstractSlider(QWidget *w, QAccessible::Role r)-
353 : QAccessibleWidget(w, r)-
354{-
355 Q_ASSERT(qobject_cast<QAbstractSlider *>(w));-
356}
never executed: end of block
0
357-
358void *QAccessibleAbstractSlider::interface_cast(QAccessible::InterfaceType t)-
359{-
360 if (t == QAccessible::ValueInterface)
t == QAccessib...ValueInterfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
361 return static_cast<QAccessibleValueInterface*>(this);
never executed: return static_cast<QAccessibleValueInterface*>(this);
0
362 return QAccessibleWidget::interface_cast(t);
never executed: return QAccessibleWidget::interface_cast(t);
0
363}-
364-
365QVariant QAccessibleAbstractSlider::currentValue() const-
366{-
367 return abstractSlider()->value();
never executed: return abstractSlider()->value();
0
368}-
369-
370void QAccessibleAbstractSlider::setCurrentValue(const QVariant &value)-
371{-
372 abstractSlider()->setValue(value.toInt());-
373}
never executed: end of block
0
374-
375QVariant QAccessibleAbstractSlider::maximumValue() const-
376{-
377 return abstractSlider()->maximum();
never executed: return abstractSlider()->maximum();
0
378}-
379-
380QVariant QAccessibleAbstractSlider::minimumValue() const-
381{-
382 return abstractSlider()->minimum();
never executed: return abstractSlider()->minimum();
0
383}-
384-
385QVariant QAccessibleAbstractSlider::minimumStepSize() const-
386{-
387 return abstractSlider()->singleStep();
never executed: return abstractSlider()->singleStep();
0
388}-
389-
390QAbstractSlider *QAccessibleAbstractSlider::abstractSlider() const-
391{-
392 return static_cast<QAbstractSlider *>(object());
never executed: return static_cast<QAbstractSlider *>(object());
0
393}-
394-
395#endif // QT_NO_SLIDER-
396-
397#ifndef QT_NO_DIAL-
398// ======================================= QAccessibleDial ======================================-
399QAccessibleDial::QAccessibleDial(QWidget *widget)-
400 : QAccessibleAbstractSlider(widget, QAccessible::Dial)-
401{-
402 Q_ASSERT(qobject_cast<QDial *>(widget));-
403 addControllingSignal(QLatin1String("valueChanged(int)"));-
404}
never executed: end of block
0
405-
406QString QAccessibleDial::text(QAccessible::Text textType) const-
407{-
408 if (textType == QAccessible::Value)
textType == QAccessible::ValueDescription
TRUEnever evaluated
FALSEnever evaluated
0
409 return QString::number(dial()->value());
never executed: return QString::number(dial()->value());
0
410-
411 return QAccessibleAbstractSlider::text(textType);
never executed: return QAccessibleAbstractSlider::text(textType);
0
412}-
413-
414QDial *QAccessibleDial::dial() const-
415{-
416 return static_cast<QDial*>(object());
never executed: return static_cast<QDial*>(object());
0
417}-
418#endif // QT_NO_DIAL-
419-
420#endif // QT_NO_ACCESSIBILITY-
421-
422QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9