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 | #include "qaccessiblebridgeutils_p.h" | - |
34 | #include <QtCore/qmath.h> | - |
35 | | - |
36 | #ifndef QT_NO_ACCESSIBILITY | - |
37 | | - |
38 | QT_BEGIN_NAMESPACE | - |
39 | | - |
40 | namespace QAccessibleBridgeUtils { | - |
41 | | - |
42 | static bool performAction(QAccessibleInterface *iface, const QString &actionName) | - |
43 | { | - |
44 | if (QAccessibleActionInterface *actionIface = iface->actionInterface()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
45 | if (actionIface->actionNames().contains(actionName)) {TRUE | never evaluated | FALSE | never 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 | | - |
53 | QStringList effectiveActionNames(QAccessibleInterface *iface) | - |
54 | { | - |
55 | QStringList actions; | - |
56 | if (QAccessibleActionInterface *actionIface = iface->actionInterface())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
57 | actions = actionIface->actionNames(); never executed: actions = actionIface->actionNames(); | 0 |
58 | | - |
59 | if (iface->valueInterface()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
60 | if (!actions.contains(QAccessibleActionInterface::increaseAction()))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
61 | actions << QAccessibleActionInterface::increaseAction(); never executed: actions << QAccessibleActionInterface::increaseAction(); | 0 |
62 | if (!actions.contains(QAccessibleActionInterface::decreaseAction()))TRUE | never evaluated | FALSE | never 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 | | - |
68 | bool performEffectiveAction(QAccessibleInterface *iface, const QString &actionName) | - |
69 | { | - |
70 | if (!iface)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
71 | return false; never executed: return false; | 0 |
72 | if (performAction(iface, actionName))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
73 | return true; never executed: return true; | 0 |
74 | if (actionName != QAccessibleActionInterface::increaseAction()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
75 | && actionName != QAccessibleActionInterface::decreaseAction())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
76 | return false; never executed: return false; | 0 |
77 | | - |
78 | QAccessibleValueInterface *valueIface = iface->valueInterface(); | - |
79 | if (!valueIface)TRUE | never evaluated | FALSE | never 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)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
85 | const double min = valueIface->minimumValue().toDouble(&success); | - |
86 | if (!success)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
87 | return false; never executed: return false; | 0 |
88 | const double max = valueIface->maximumValue().toDouble(&success); | - |
89 | if (!success)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
90 | return false; never executed: return false; | 0 |
91 | stepSize = (max - min) / 10; | - |
92 | const int typ = currentVariant.type(); | - |
93 | if (typ != QMetaType::Float && typ != QMetaType::Double) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
94 | | - |
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)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
100 | return false; never executed: return false; | 0 |
101 | if (actionName == QAccessibleActionInterface::decreaseAction())TRUE | never evaluated | FALSE | never 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 | } | - |
108 | | - |
109 | QT_END_NAMESPACE | - |
110 | | - |
111 | #endif | - |
| | |