Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | #include "qaccessiblebridgeutils_p.h" | - |
40 | #include <QtCore/qmath.h> | - |
41 | | - |
42 | #ifndef QT_NO_ACCESSIBILITY | - |
43 | | - |
44 | QT_BEGIN_NAMESPACE | - |
45 | | - |
46 | namespace QAccessibleBridgeUtils { | - |
47 | | - |
48 | static bool performAction(QAccessibleInterface *iface, const QString &actionName) | - |
49 | { | - |
50 | if (QAccessibleActionInterface *actionIface = iface->actionInterface()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
51 | if (actionIface->actionNames().contains(actionName)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
52 | actionIface->doAction(actionName); | - |
53 | return true; never executed: return true; | 0 |
54 | } | - |
55 | } never executed: end of block | 0 |
56 | return false; never executed: return false; | 0 |
57 | } | - |
58 | | - |
59 | QStringList effectiveActionNames(QAccessibleInterface *iface) | - |
60 | { | - |
61 | QStringList actions; | - |
62 | if (QAccessibleActionInterface *actionIface = iface->actionInterface())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
63 | actions = actionIface->actionNames(); never executed: actions = actionIface->actionNames(); | 0 |
64 | | - |
65 | if (iface->valueInterface()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
66 | if (!actions.contains(QAccessibleActionInterface::increaseAction()))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
67 | actions << QAccessibleActionInterface::increaseAction(); never executed: actions << QAccessibleActionInterface::increaseAction(); | 0 |
68 | if (!actions.contains(QAccessibleActionInterface::decreaseAction()))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
69 | actions << QAccessibleActionInterface::decreaseAction(); never executed: actions << QAccessibleActionInterface::decreaseAction(); | 0 |
70 | } never executed: end of block | 0 |
71 | return actions; never executed: return actions; | 0 |
72 | } | - |
73 | | - |
74 | bool performEffectiveAction(QAccessibleInterface *iface, const QString &actionName) | - |
75 | { | - |
76 | if (!iface)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
77 | return false; never executed: return false; | 0 |
78 | if (performAction(iface, actionName))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
79 | return true; never executed: return true; | 0 |
80 | if (actionName != QAccessibleActionInterface::increaseAction()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
81 | && actionName != QAccessibleActionInterface::decreaseAction())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
82 | return false; never executed: return false; | 0 |
83 | | - |
84 | QAccessibleValueInterface *valueIface = iface->valueInterface(); | - |
85 | if (!valueIface)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
86 | return false; never executed: return false; | 0 |
87 | bool success; | - |
88 | const QVariant currentVariant = valueIface->currentValue(); | - |
89 | double stepSize = valueIface->minimumStepSize().toDouble(&success); | - |
90 | if (!success || qFuzzyIsNull(stepSize)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
91 | const double min = valueIface->minimumValue().toDouble(&success); | - |
92 | if (!success)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
93 | return false; never executed: return false; | 0 |
94 | const double max = valueIface->maximumValue().toDouble(&success); | - |
95 | if (!success)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
96 | return false; never executed: return false; | 0 |
97 | stepSize = (max - min) / 10; | - |
98 | const int typ = currentVariant.type(); | - |
99 | if (typ != QMetaType::Float && typ != QMetaType::Double) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
100 | | - |
101 | stepSize = qCeil(stepSize); | - |
102 | } never executed: end of block | 0 |
103 | } never executed: end of block | 0 |
104 | const double current = currentVariant.toDouble(&success); | - |
105 | if (!success)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
106 | return false; never executed: return false; | 0 |
107 | if (actionName == QAccessibleActionInterface::decreaseAction())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
108 | stepSize = -stepSize; never executed: stepSize = -stepSize; | 0 |
109 | valueIface->setCurrentValue(current + stepSize); | - |
110 | return true; never executed: return true; | 0 |
111 | } | - |
112 | | - |
113 | } | - |
114 | | - |
115 | QT_END_NAMESPACE | - |
116 | | - |
117 | #endif | - |
| | |