qaccessiblebridgeutils.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/platformsupport/accessibility/qaccessiblebridgeutils.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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 QtGui module 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#include "qaccessiblebridgeutils_p.h"-
34#include <QtCore/qmath.h>-
35-
36#ifndef QT_NO_ACCESSIBILITY-
37-
38QT_BEGIN_NAMESPACE-
39-
40namespace QAccessibleBridgeUtils {-
41-
42static bool performAction(QAccessibleInterface *iface, const QString &actionName)-
43{-
44 if (QAccessibleActionInterface *actionIface = iface->actionInterface()) {
QAccessibleAct...ionInterface()Description
TRUEnever evaluated
FALSEnever evaluated
0
45 if (actionIface->actionNames().contains(actionName)) {
actionIface->a...ns(actionName)Description
TRUEnever evaluated
FALSEnever evaluated
0
46 actionIface->doAction(actionName);-
47 return true;
never executed: return true;
0
48 }-
49 }
never executed: end of block
0
50 return false;
never executed: return false;
0
51}-
52-
53QStringList effectiveActionNames(QAccessibleInterface *iface)-
54{-
55 QStringList actions;-
56 if (QAccessibleActionInterface *actionIface = iface->actionInterface())
QAccessibleAct...ionInterface()Description
TRUEnever evaluated
FALSEnever evaluated
0
57 actions = actionIface->actionNames();
never executed: actions = actionIface->actionNames();
0
58-
59 if (iface->valueInterface()) {
iface->valueInterface()Description
TRUEnever evaluated
FALSEnever evaluated
0
60 if (!actions.contains(QAccessibleActionInterface::increaseAction()))
!actions.conta...reaseAction())Description
TRUEnever evaluated
FALSEnever evaluated
0
61 actions << QAccessibleActionInterface::increaseAction();
never executed: actions << QAccessibleActionInterface::increaseAction();
0
62 if (!actions.contains(QAccessibleActionInterface::decreaseAction()))
!actions.conta...reaseAction())Description
TRUEnever evaluated
FALSEnever evaluated
0
63 actions << QAccessibleActionInterface::decreaseAction();
never executed: actions << QAccessibleActionInterface::decreaseAction();
0
64 }
never executed: end of block
0
65 return actions;
never executed: return actions;
0
66}-
67-
68bool performEffectiveAction(QAccessibleInterface *iface, const QString &actionName)-
69{-
70 if (!iface)
!ifaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
71 return false;
never executed: return false;
0
72 if (performAction(iface, actionName))
performAction(...e, actionName)Description
TRUEnever evaluated
FALSEnever evaluated
0
73 return true;
never executed: return true;
0
74 if (actionName != QAccessibleActionInterface::increaseAction()
actionName != ...creaseAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
75 && actionName != QAccessibleActionInterface::decreaseAction())
actionName != ...creaseAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
76 return false;
never executed: return false;
0
77-
78 QAccessibleValueInterface *valueIface = iface->valueInterface();-
79 if (!valueIface)
!valueIfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
80 return false;
never executed: return false;
0
81 bool success;-
82 const QVariant currentVariant = valueIface->currentValue();-
83 double stepSize = valueIface->minimumStepSize().toDouble(&success);-
84 if (!success || qFuzzyIsNull(stepSize)) {
!successDescription
TRUEnever evaluated
FALSEnever evaluated
qFuzzyIsNull(stepSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
85 const double min = valueIface->minimumValue().toDouble(&success);-
86 if (!success)
!successDescription
TRUEnever evaluated
FALSEnever evaluated
0
87 return false;
never executed: return false;
0
88 const double max = valueIface->maximumValue().toDouble(&success);-
89 if (!success)
!successDescription
TRUEnever evaluated
FALSEnever evaluated
0
90 return false;
never executed: return false;
0
91 stepSize = (max - min) / 10; // this is pretty arbitrary, we just need to provide something-
92 const int typ = currentVariant.type();-
93 if (typ != QMetaType::Float && typ != QMetaType::Double) {
typ != QMetaType::FloatDescription
TRUEnever evaluated
FALSEnever evaluated
typ != QMetaType::DoubleDescription
TRUEnever evaluated
FALSEnever evaluated
0
94 // currentValue is an integer. Round it up to ensure stepping in case it was below 1-
95 stepSize = qCeil(stepSize);-
96 }
never executed: end of block
0
97 }
never executed: end of block
0
98 const double current = currentVariant.toDouble(&success);-
99 if (!success)
!successDescription
TRUEnever evaluated
FALSEnever evaluated
0
100 return false;
never executed: return false;
0
101 if (actionName == QAccessibleActionInterface::decreaseAction())
actionName == ...creaseAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
102 stepSize = -stepSize;
never executed: stepSize = -stepSize;
0
103 valueIface->setCurrentValue(current + stepSize);-
104 return true;
never executed: return true;
0
105}-
106-
107} //namespace-
108-
109QT_END_NAMESPACE-
110-
111#endif-
Source codeSwitch to Preprocessed file

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