Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickitem.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 QtQuick module 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 "qquickitem.h" | - | ||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | #include "qquickwindow.h" | - | ||||||||||||||||||||||||
43 | #include "qquickrendercontrol.h" | - | ||||||||||||||||||||||||
44 | #include <QtQml/qjsengine.h> | - | ||||||||||||||||||||||||
45 | #include "qquickwindow_p.h" | - | ||||||||||||||||||||||||
46 | - | |||||||||||||||||||||||||
47 | #include "qquickevents_p_p.h" | - | ||||||||||||||||||||||||
48 | #include "qquickscreen_p.h" | - | ||||||||||||||||||||||||
49 | - | |||||||||||||||||||||||||
50 | #include <QtQml/qqmlengine.h> | - | ||||||||||||||||||||||||
51 | #include <QtQml/qqmlcomponent.h> | - | ||||||||||||||||||||||||
52 | #include <QtQml/qqmlinfo.h> | - | ||||||||||||||||||||||||
53 | #include <QtGui/qpen.h> | - | ||||||||||||||||||||||||
54 | #include <QtGui/qguiapplication.h> | - | ||||||||||||||||||||||||
55 | #include <QtGui/qstylehints.h> | - | ||||||||||||||||||||||||
56 | #include <QtGui/private/qguiapplication_p.h> | - | ||||||||||||||||||||||||
57 | #include <QtGui/qinputmethod.h> | - | ||||||||||||||||||||||||
58 | #include <QtCore/qcoreevent.h> | - | ||||||||||||||||||||||||
59 | #include <QtCore/private/qnumeric_p.h> | - | ||||||||||||||||||||||||
60 | #include <QtGui/qpa/qplatformtheme.h> | - | ||||||||||||||||||||||||
61 | #include <QtCore/qloggingcategory.h> | - | ||||||||||||||||||||||||
62 | - | |||||||||||||||||||||||||
63 | #include <private/qqmlglobal_p.h> | - | ||||||||||||||||||||||||
64 | #include <private/qqmlengine_p.h> | - | ||||||||||||||||||||||||
65 | #include <QtQuick/private/qquickstategroup_p.h> | - | ||||||||||||||||||||||||
66 | #include <private/qqmlopenmetaobject_p.h> | - | ||||||||||||||||||||||||
67 | #include <QtQuick/private/qquickstate_p.h> | - | ||||||||||||||||||||||||
68 | #include <private/qquickitem_p.h> | - | ||||||||||||||||||||||||
69 | #include <QtQuick/private/qquickaccessibleattached_p.h> | - | ||||||||||||||||||||||||
70 | #include <QtQuick/private/qquickhoverhandler_p.h> | - | ||||||||||||||||||||||||
71 | #include <QtQuick/private/qquickpointerhandler_p.h> | - | ||||||||||||||||||||||||
72 | - | |||||||||||||||||||||||||
73 | #include <private/qv4engine_p.h> | - | ||||||||||||||||||||||||
74 | #include <private/qv4object_p.h> | - | ||||||||||||||||||||||||
75 | #include <private/qv4qobjectwrapper_p.h> | - | ||||||||||||||||||||||||
76 | #include <private/qdebug_p.h> | - | ||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||
78 | #if QT_CONFIG(cursor) | - | ||||||||||||||||||||||||
79 | # include <QtGui/qcursor.h> | - | ||||||||||||||||||||||||
80 | #endif | - | ||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||
82 | #include <algorithm> | - | ||||||||||||||||||||||||
83 | #include <limits> | - | ||||||||||||||||||||||||
84 | - | |||||||||||||||||||||||||
85 | // XXX todo Check that elements that create items handle memory correctly after visual ownership change | - | ||||||||||||||||||||||||
86 | - | |||||||||||||||||||||||||
87 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
88 | - | |||||||||||||||||||||||||
89 | Q_DECLARE_LOGGING_CATEGORY(DBG_MOUSE_TARGET) | - | ||||||||||||||||||||||||
90 | Q_DECLARE_LOGGING_CATEGORY(DBG_HOVER_TRACE) | - | ||||||||||||||||||||||||
91 | Q_DECLARE_LOGGING_CATEGORY(lcTransient) | - | ||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||
93 | void debugFocusTree(QQuickItem *item, QQuickItem *scope = nullptr, int depth = 1) | - | ||||||||||||||||||||||||
94 | { | - | ||||||||||||||||||||||||
95 | if (DBG_FOCUS().isEnabled(QtDebugMsg)) {
| 0 | ||||||||||||||||||||||||
96 | qCDebug(DBG_FOCUS) never executed: QMessageLogger(__FILE__, 96, __PRETTY_FUNCTION__, DBG_FOCUS().categoryName()).debug() << QByteArray(depth, '\t').constData() << (scope && QQuickItemPrivate::get(scope)->subFocusItem == item ? '*' : ' ') << item->hasFocus() << item->hasActiveFocus() << item->isFocusScope() << item;
| 0 | ||||||||||||||||||||||||
97 | << QByteArray(depth, '\t').constData() never executed: QMessageLogger(__FILE__, 96, __PRETTY_FUNCTION__, DBG_FOCUS().categoryName()).debug() << QByteArray(depth, '\t').constData() << (scope && QQuickItemPrivate::get(scope)->subFocusItem == item ? '*' : ' ') << item->hasFocus() << item->hasActiveFocus() << item->isFocusScope() << item; | 0 | ||||||||||||||||||||||||
98 | << (scope && QQuickItemPrivate::get(scope)->subFocusItem == item ? '*' : ' ') never executed: QMessageLogger(__FILE__, 96, __PRETTY_FUNCTION__, DBG_FOCUS().categoryName()).debug() << QByteArray(depth, '\t').constData() << (scope && QQuickItemPrivate::get(scope)->subFocusItem == item ? '*' : ' ') << item->hasFocus() << item->hasActiveFocus() << item->isFocusScope() << item; | 0 | ||||||||||||||||||||||||
99 | << item->hasFocus() never executed: QMessageLogger(__FILE__, 96, __PRETTY_FUNCTION__, DBG_FOCUS().categoryName()).debug() << QByteArray(depth, '\t').constData() << (scope && QQuickItemPrivate::get(scope)->subFocusItem == item ? '*' : ' ') << item->hasFocus() << item->hasActiveFocus() << item->isFocusScope() << item; | 0 | ||||||||||||||||||||||||
100 | << item->hasActiveFocus() never executed: QMessageLogger(__FILE__, 96, __PRETTY_FUNCTION__, DBG_FOCUS().categoryName()).debug() << QByteArray(depth, '\t').constData() << (scope && QQuickItemPrivate::get(scope)->subFocusItem == item ? '*' : ' ') << item->hasFocus() << item->hasActiveFocus() << item->isFocusScope() << item; | 0 | ||||||||||||||||||||||||
101 | << item->isFocusScope() never executed: QMessageLogger(__FILE__, 96, __PRETTY_FUNCTION__, DBG_FOCUS().categoryName()).debug() << QByteArray(depth, '\t').constData() << (scope && QQuickItemPrivate::get(scope)->subFocusItem == item ? '*' : ' ') << item->hasFocus() << item->hasActiveFocus() << item->isFocusScope() << item; | 0 | ||||||||||||||||||||||||
102 | << item; never executed: QMessageLogger(__FILE__, 96, __PRETTY_FUNCTION__, DBG_FOCUS().categoryName()).debug() << QByteArray(depth, '\t').constData() << (scope && QQuickItemPrivate::get(scope)->subFocusItem == item ? '*' : ' ') << item->hasFocus() << item->hasActiveFocus() << item->isFocusScope() << item; | 0 | ||||||||||||||||||||||||
103 | const auto childItems = item->childItems(); | - | ||||||||||||||||||||||||
104 | for (QQuickItem *child : childItems) { | - | ||||||||||||||||||||||||
105 | debugFocusTree( | - | ||||||||||||||||||||||||
106 | child, | - | ||||||||||||||||||||||||
107 | item->isFocusScope() || !scope ? item : scope, | - | ||||||||||||||||||||||||
108 | item->isFocusScope() || !scope ? depth + 1 : depth); | - | ||||||||||||||||||||||||
109 | } never executed: end of block | 0 | ||||||||||||||||||||||||
110 | } never executed: end of block | 0 | ||||||||||||||||||||||||
111 | } never executed: end of block | 0 | ||||||||||||||||||||||||
112 | - | |||||||||||||||||||||||||
113 | /*! | - | ||||||||||||||||||||||||
114 | \qmltype Transform | - | ||||||||||||||||||||||||
115 | \instantiates QQuickTransform | - | ||||||||||||||||||||||||
116 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
117 | \ingroup qtquick-visual-transforms | - | ||||||||||||||||||||||||
118 | \brief For specifying advanced transformations on Items. | - | ||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||
120 | The Transform type is a base type which cannot be instantiated directly. | - | ||||||||||||||||||||||||
121 | The following concrete Transform types are available: | - | ||||||||||||||||||||||||
122 | - | |||||||||||||||||||||||||
123 | \list | - | ||||||||||||||||||||||||
124 | \li \l Rotation | - | ||||||||||||||||||||||||
125 | \li \l Scale | - | ||||||||||||||||||||||||
126 | \li \l Translate | - | ||||||||||||||||||||||||
127 | \li \l Matrix4x4 | - | ||||||||||||||||||||||||
128 | \endlist | - | ||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||
130 | The Transform types let you create and control advanced transformations that can be configured | - | ||||||||||||||||||||||||
131 | independently using specialized properties. | - | ||||||||||||||||||||||||
132 | - | |||||||||||||||||||||||||
133 | You can assign any number of Transforms to an \l Item. Each Transform is applied in order, | - | ||||||||||||||||||||||||
134 | one at a time. | - | ||||||||||||||||||||||||
135 | */ | - | ||||||||||||||||||||||||
136 | QQuickTransformPrivate::QQuickTransformPrivate() | - | ||||||||||||||||||||||||
137 | { | - | ||||||||||||||||||||||||
138 | } | - | ||||||||||||||||||||||||
139 | - | |||||||||||||||||||||||||
140 | QQuickTransform::QQuickTransform(QObject *parent) | - | ||||||||||||||||||||||||
141 | : QObject(*(new QQuickTransformPrivate), parent) | - | ||||||||||||||||||||||||
142 | { | - | ||||||||||||||||||||||||
143 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||||||||||||||
144 | - | |||||||||||||||||||||||||
145 | QQuickTransform::QQuickTransform(QQuickTransformPrivate &dd, QObject *parent) | - | ||||||||||||||||||||||||
146 | : QObject(dd, parent) | - | ||||||||||||||||||||||||
147 | { | - | ||||||||||||||||||||||||
148 | } executed 858 times by 7 tests: end of block Executed by:
| 858 | ||||||||||||||||||||||||
149 | - | |||||||||||||||||||||||||
150 | QQuickTransform::~QQuickTransform() | - | ||||||||||||||||||||||||
151 | { | - | ||||||||||||||||||||||||
152 | Q_D(QQuickTransform); | - | ||||||||||||||||||||||||
153 | for (int ii = 0; ii < d->items.count(); ++ii) {
| 0-856 | ||||||||||||||||||||||||
154 | QQuickItemPrivate *p = QQuickItemPrivate::get(d->items.at(ii)); | - | ||||||||||||||||||||||||
155 | p->transforms.removeOne(this); | - | ||||||||||||||||||||||||
156 | p->dirty(QQuickItemPrivate::Transform); | - | ||||||||||||||||||||||||
157 | } never executed: end of block | 0 | ||||||||||||||||||||||||
158 | } executed 856 times by 5 tests: end of block Executed by:
| 856 | ||||||||||||||||||||||||
159 | - | |||||||||||||||||||||||||
160 | void QQuickTransform::update() | - | ||||||||||||||||||||||||
161 | { | - | ||||||||||||||||||||||||
162 | Q_D(QQuickTransform); | - | ||||||||||||||||||||||||
163 | for (int ii = 0; ii < d->items.count(); ++ii) {
| 1720-2602 | ||||||||||||||||||||||||
164 | QQuickItemPrivate *p = QQuickItemPrivate::get(d->items.at(ii)); | - | ||||||||||||||||||||||||
165 | p->dirty(QQuickItemPrivate::Transform); | - | ||||||||||||||||||||||||
166 | } executed 1720 times by 4 tests: end of block Executed by:
| 1720 | ||||||||||||||||||||||||
167 | } executed 2602 times by 5 tests: end of block Executed by:
| 2602 | ||||||||||||||||||||||||
168 | - | |||||||||||||||||||||||||
169 | QQuickContents::QQuickContents(QQuickItem *item) | - | ||||||||||||||||||||||||
170 | : m_item(item) | - | ||||||||||||||||||||||||
171 | { | - | ||||||||||||||||||||||||
172 | } executed 94 times by 5 tests: end of block Executed by:
| 94 | ||||||||||||||||||||||||
173 | - | |||||||||||||||||||||||||
174 | QQuickContents::~QQuickContents() | - | ||||||||||||||||||||||||
175 | { | - | ||||||||||||||||||||||||
176 | QList<QQuickItem *> children = m_item->childItems(); | - | ||||||||||||||||||||||||
177 | for (int i = 0; i < children.count(); ++i) {
| 0-92 | ||||||||||||||||||||||||
178 | QQuickItem *child = children.at(i); | - | ||||||||||||||||||||||||
179 | QQuickItemPrivate::get(child)->removeItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Destroyed); | - | ||||||||||||||||||||||||
180 | } never executed: end of block | 0 | ||||||||||||||||||||||||
181 | } executed 92 times by 5 tests: end of block Executed by:
| 92 | ||||||||||||||||||||||||
182 | - | |||||||||||||||||||||||||
183 | bool QQuickContents::calcHeight(QQuickItem *changed) | - | ||||||||||||||||||||||||
184 | { | - | ||||||||||||||||||||||||
185 | qreal oldy = m_contents.y(); | - | ||||||||||||||||||||||||
186 | qreal oldheight = m_contents.height(); | - | ||||||||||||||||||||||||
187 | - | |||||||||||||||||||||||||
188 | if (changed) {
| 12-220 | ||||||||||||||||||||||||
189 | qreal top = oldy; | - | ||||||||||||||||||||||||
190 | qreal bottom = oldy + oldheight; | - | ||||||||||||||||||||||||
191 | qreal y = changed->y(); | - | ||||||||||||||||||||||||
192 | if (y + changed->height() > bottom)
| 4-8 | ||||||||||||||||||||||||
193 | bottom = y + changed->height(); executed 4 times by 1 test: bottom = y + changed->height(); Executed by:
| 4 | ||||||||||||||||||||||||
194 | if (y < top)
| 0-12 | ||||||||||||||||||||||||
195 | top = y; never executed: top = y; | 0 | ||||||||||||||||||||||||
196 | m_contents.setY(top); | - | ||||||||||||||||||||||||
197 | m_contents.setHeight(bottom - top); | - | ||||||||||||||||||||||||
198 | } else { executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
199 | qreal top = std::numeric_limits<qreal>::max(); | - | ||||||||||||||||||||||||
200 | qreal bottom = -std::numeric_limits<qreal>::max(); | - | ||||||||||||||||||||||||
201 | QList<QQuickItem *> children = m_item->childItems(); | - | ||||||||||||||||||||||||
202 | for (int i = 0; i < children.count(); ++i) {
| 204-220 | ||||||||||||||||||||||||
203 | QQuickItem *child = children.at(i); | - | ||||||||||||||||||||||||
204 | qreal y = child->y(); | - | ||||||||||||||||||||||||
205 | if (y + child->height() > bottom)
| 32-172 | ||||||||||||||||||||||||
206 | bottom = y + child->height(); executed 172 times by 3 tests: bottom = y + child->height(); Executed by:
| 172 | ||||||||||||||||||||||||
207 | if (y < top)
| 70-134 | ||||||||||||||||||||||||
208 | top = y; executed 134 times by 3 tests: top = y; Executed by:
| 134 | ||||||||||||||||||||||||
209 | } executed 204 times by 3 tests: end of block Executed by:
| 204 | ||||||||||||||||||||||||
210 | if (!children.isEmpty())
| 94-126 | ||||||||||||||||||||||||
211 | m_contents.setY(top); executed 126 times by 3 tests: m_contents.setY(top); Executed by:
| 126 | ||||||||||||||||||||||||
212 | m_contents.setHeight(qMax(bottom - top, qreal(0.0))); | - | ||||||||||||||||||||||||
213 | } executed 220 times by 5 tests: end of block Executed by:
| 220 | ||||||||||||||||||||||||
214 | - | |||||||||||||||||||||||||
215 | return (m_contents.height() != oldheight || m_contents.y() != oldy); executed 232 times by 5 tests: return (m_contents.height() != oldheight || m_contents.y() != oldy); Executed by:
| 232 | ||||||||||||||||||||||||
216 | } | - | ||||||||||||||||||||||||
217 | - | |||||||||||||||||||||||||
218 | bool QQuickContents::calcWidth(QQuickItem *changed) | - | ||||||||||||||||||||||||
219 | { | - | ||||||||||||||||||||||||
220 | qreal oldx = m_contents.x(); | - | ||||||||||||||||||||||||
221 | qreal oldwidth = m_contents.width(); | - | ||||||||||||||||||||||||
222 | - | |||||||||||||||||||||||||
223 | if (changed) {
| 12-210 | ||||||||||||||||||||||||
224 | qreal left = oldx; | - | ||||||||||||||||||||||||
225 | qreal right = oldx + oldwidth; | - | ||||||||||||||||||||||||
226 | qreal x = changed->x(); | - | ||||||||||||||||||||||||
227 | if (x + changed->width() > right)
| 4-8 | ||||||||||||||||||||||||
228 | right = x + changed->width(); executed 4 times by 1 test: right = x + changed->width(); Executed by:
| 4 | ||||||||||||||||||||||||
229 | if (x < left)
| 0-12 | ||||||||||||||||||||||||
230 | left = x; never executed: left = x; | 0 | ||||||||||||||||||||||||
231 | m_contents.setX(left); | - | ||||||||||||||||||||||||
232 | m_contents.setWidth(right - left); | - | ||||||||||||||||||||||||
233 | } else { executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
234 | qreal left = std::numeric_limits<qreal>::max(); | - | ||||||||||||||||||||||||
235 | qreal right = -std::numeric_limits<qreal>::max(); | - | ||||||||||||||||||||||||
236 | QList<QQuickItem *> children = m_item->childItems(); | - | ||||||||||||||||||||||||
237 | for (int i = 0; i < children.count(); ++i) {
| 184-210 | ||||||||||||||||||||||||
238 | QQuickItem *child = children.at(i); | - | ||||||||||||||||||||||||
239 | qreal x = child->x(); | - | ||||||||||||||||||||||||
240 | if (x + child->width() > right)
| 28-156 | ||||||||||||||||||||||||
241 | right = x + child->width(); executed 156 times by 3 tests: right = x + child->width(); Executed by:
| 156 | ||||||||||||||||||||||||
242 | if (x < left)
| 60-124 | ||||||||||||||||||||||||
243 | left = x; executed 124 times by 3 tests: left = x; Executed by:
| 124 | ||||||||||||||||||||||||
244 | } executed 184 times by 3 tests: end of block Executed by:
| 184 | ||||||||||||||||||||||||
245 | if (!children.isEmpty())
| 94-116 | ||||||||||||||||||||||||
246 | m_contents.setX(left); executed 116 times by 3 tests: m_contents.setX(left); Executed by:
| 116 | ||||||||||||||||||||||||
247 | m_contents.setWidth(qMax(right - left, qreal(0.0))); | - | ||||||||||||||||||||||||
248 | } executed 210 times by 5 tests: end of block Executed by:
| 210 | ||||||||||||||||||||||||
249 | - | |||||||||||||||||||||||||
250 | return (m_contents.width() != oldwidth || m_contents.x() != oldx); executed 222 times by 5 tests: return (m_contents.width() != oldwidth || m_contents.x() != oldx); Executed by:
| 222 | ||||||||||||||||||||||||
251 | } | - | ||||||||||||||||||||||||
252 | - | |||||||||||||||||||||||||
253 | void QQuickContents::complete() | - | ||||||||||||||||||||||||
254 | { | - | ||||||||||||||||||||||||
255 | QQuickItemPrivate::get(m_item)->addItemChangeListener(this, QQuickItemPrivate::Children); | - | ||||||||||||||||||||||||
256 | - | |||||||||||||||||||||||||
257 | QList<QQuickItem *> children = m_item->childItems(); | - | ||||||||||||||||||||||||
258 | for (int i = 0; i < children.count(); ++i) {
| 88-94 | ||||||||||||||||||||||||
259 | QQuickItem *child = children.at(i); | - | ||||||||||||||||||||||||
260 | QQuickItemPrivate::get(child)->addItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Destroyed); | - | ||||||||||||||||||||||||
261 | //###what about changes to visibility? | - | ||||||||||||||||||||||||
262 | } executed 88 times by 3 tests: end of block Executed by:
| 88 | ||||||||||||||||||||||||
263 | calcGeometry(); | - | ||||||||||||||||||||||||
264 | } executed 94 times by 5 tests: end of block Executed by:
| 94 | ||||||||||||||||||||||||
265 | - | |||||||||||||||||||||||||
266 | void QQuickContents::updateRect() | - | ||||||||||||||||||||||||
267 | { | - | ||||||||||||||||||||||||
268 | QQuickItemPrivate::get(m_item)->emitChildrenRectChanged(rectF()); | - | ||||||||||||||||||||||||
269 | } executed 202 times by 3 tests: end of block Executed by:
| 202 | ||||||||||||||||||||||||
270 | - | |||||||||||||||||||||||||
271 | void QQuickContents::itemGeometryChanged(QQuickItem *changed, QQuickGeometryChange change, const QRectF &) | - | ||||||||||||||||||||||||
272 | { | - | ||||||||||||||||||||||||
273 | Q_UNUSED(changed) | - | ||||||||||||||||||||||||
274 | bool wChanged = false; | - | ||||||||||||||||||||||||
275 | bool hChanged = false; | - | ||||||||||||||||||||||||
276 | //### we can only pass changed if the left edge has moved left, or the right edge has moved right | - | ||||||||||||||||||||||||
277 | if (change.horizontalChange())
| 16-26 | ||||||||||||||||||||||||
278 | wChanged = calcWidth(/*changed*/); executed 16 times by 1 test: wChanged = calcWidth( ); Executed by:
| 16 | ||||||||||||||||||||||||
279 | if (change.verticalChange())
| 16-26 | ||||||||||||||||||||||||
280 | hChanged = calcHeight(/*changed*/); executed 26 times by 1 test: hChanged = calcHeight( ); Executed by:
| 26 | ||||||||||||||||||||||||
281 | if (wChanged || hChanged)
| 0-26 | ||||||||||||||||||||||||
282 | updateRect(); executed 42 times by 1 test: updateRect(); Executed by:
| 42 | ||||||||||||||||||||||||
283 | } executed 42 times by 1 test: end of block Executed by:
| 42 | ||||||||||||||||||||||||
284 | - | |||||||||||||||||||||||||
285 | void QQuickContents::itemDestroyed(QQuickItem *item) | - | ||||||||||||||||||||||||
286 | { | - | ||||||||||||||||||||||||
287 | if (item)
| 0 | ||||||||||||||||||||||||
288 | QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Destroyed); never executed: QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Destroyed); | 0 | ||||||||||||||||||||||||
289 | calcGeometry(); | - | ||||||||||||||||||||||||
290 | } never executed: end of block | 0 | ||||||||||||||||||||||||
291 | - | |||||||||||||||||||||||||
292 | void QQuickContents::itemChildRemoved(QQuickItem *, QQuickItem *item) | - | ||||||||||||||||||||||||
293 | { | - | ||||||||||||||||||||||||
294 | if (item)
| 0-100 | ||||||||||||||||||||||||
295 | QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Destroyed); executed 100 times by 3 tests: QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Destroyed); Executed by:
| 100 | ||||||||||||||||||||||||
296 | calcGeometry(); | - | ||||||||||||||||||||||||
297 | } executed 100 times by 3 tests: end of block Executed by:
| 100 | ||||||||||||||||||||||||
298 | - | |||||||||||||||||||||||||
299 | void QQuickContents::itemChildAdded(QQuickItem *, QQuickItem *item) | - | ||||||||||||||||||||||||
300 | { | - | ||||||||||||||||||||||||
301 | if (item)
| 0-12 | ||||||||||||||||||||||||
302 | QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Destroyed); executed 12 times by 1 test: QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Destroyed); Executed by:
| 12 | ||||||||||||||||||||||||
303 | calcGeometry(item); | - | ||||||||||||||||||||||||
304 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
305 | - | |||||||||||||||||||||||||
306 | QQuickItemKeyFilter::QQuickItemKeyFilter(QQuickItem *item) | - | ||||||||||||||||||||||||
307 | : m_processPost(false), m_next(nullptr) | - | ||||||||||||||||||||||||
308 | { | - | ||||||||||||||||||||||||
309 | QQuickItemPrivate *p = item?QQuickItemPrivate::get(item):nullptr;
| 0-464 | ||||||||||||||||||||||||
310 | if (p) {
| 0-464 | ||||||||||||||||||||||||
311 | m_next = p->extra.value().keyHandler; | - | ||||||||||||||||||||||||
312 | p->extra->keyHandler = this; | - | ||||||||||||||||||||||||
313 | } executed 464 times by 9 tests: end of block Executed by:
| 464 | ||||||||||||||||||||||||
314 | } executed 464 times by 9 tests: end of block Executed by:
| 464 | ||||||||||||||||||||||||
315 | - | |||||||||||||||||||||||||
316 | QQuickItemKeyFilter::~QQuickItemKeyFilter() | - | ||||||||||||||||||||||||
317 | { | - | ||||||||||||||||||||||||
318 | } | - | ||||||||||||||||||||||||
319 | - | |||||||||||||||||||||||||
320 | void QQuickItemKeyFilter::keyPressed(QKeyEvent *event, bool post) | - | ||||||||||||||||||||||||
321 | { | - | ||||||||||||||||||||||||
322 | if (m_next) m_next->keyPressed(event, post); executed 34 times by 1 test: m_next->keyPressed(event, post); Executed by:
| 34-244 | ||||||||||||||||||||||||
323 | } executed 278 times by 4 tests: end of block Executed by:
| 278 | ||||||||||||||||||||||||
324 | - | |||||||||||||||||||||||||
325 | void QQuickItemKeyFilter::keyReleased(QKeyEvent *event, bool post) | - | ||||||||||||||||||||||||
326 | { | - | ||||||||||||||||||||||||
327 | if (m_next) m_next->keyReleased(event, post); executed 32 times by 1 test: m_next->keyReleased(event, post); Executed by:
| 32-182 | ||||||||||||||||||||||||
328 | } executed 214 times by 4 tests: end of block Executed by:
| 214 | ||||||||||||||||||||||||
329 | - | |||||||||||||||||||||||||
330 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
331 | void QQuickItemKeyFilter::inputMethodEvent(QInputMethodEvent *event, bool post) | - | ||||||||||||||||||||||||
332 | { | - | ||||||||||||||||||||||||
333 | if (m_next)
| 0 | ||||||||||||||||||||||||
334 | m_next->inputMethodEvent(event, post); never executed: m_next->inputMethodEvent(event, post); | 0 | ||||||||||||||||||||||||
335 | else | - | ||||||||||||||||||||||||
336 | event->ignore(); never executed: event->ignore(); | 0 | ||||||||||||||||||||||||
337 | } | - | ||||||||||||||||||||||||
338 | - | |||||||||||||||||||||||||
339 | QVariant QQuickItemKeyFilter::inputMethodQuery(Qt::InputMethodQuery query) const | - | ||||||||||||||||||||||||
340 | { | - | ||||||||||||||||||||||||
341 | if (m_next) return m_next->inputMethodQuery(query); executed 8 times by 1 test: return m_next->inputMethodQuery(query); Executed by:
| 8-146 | ||||||||||||||||||||||||
342 | return QVariant(); executed 146 times by 5 tests: return QVariant(); Executed by:
| 146 | ||||||||||||||||||||||||
343 | } | - | ||||||||||||||||||||||||
344 | #endif // im | - | ||||||||||||||||||||||||
345 | - | |||||||||||||||||||||||||
346 | void QQuickItemKeyFilter::shortcutOverride(QKeyEvent *event) | - | ||||||||||||||||||||||||
347 | { | - | ||||||||||||||||||||||||
348 | if (m_next)
| 0-4 | ||||||||||||||||||||||||
349 | m_next->shortcutOverride(event); executed 4 times by 1 test: m_next->shortcutOverride(event); Executed by:
| 4 | ||||||||||||||||||||||||
350 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
351 | - | |||||||||||||||||||||||||
352 | void QQuickItemKeyFilter::componentComplete() | - | ||||||||||||||||||||||||
353 | { | - | ||||||||||||||||||||||||
354 | if (m_next) m_next->componentComplete(); executed 6 times by 1 test: m_next->componentComplete(); Executed by:
| 6-120 | ||||||||||||||||||||||||
355 | } executed 126 times by 5 tests: end of block Executed by:
| 126 | ||||||||||||||||||||||||
356 | /*! | - | ||||||||||||||||||||||||
357 | \qmltype KeyNavigation | - | ||||||||||||||||||||||||
358 | \instantiates QQuickKeyNavigationAttached | - | ||||||||||||||||||||||||
359 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
360 | \ingroup qtquick-input | - | ||||||||||||||||||||||||
361 | \brief Supports key navigation by arrow keys. | - | ||||||||||||||||||||||||
362 | - | |||||||||||||||||||||||||
363 | Key-based user interfaces commonly allow the use of arrow keys to navigate between | - | ||||||||||||||||||||||||
364 | focusable items. The KeyNavigation attached property enables this behavior by providing a | - | ||||||||||||||||||||||||
365 | convenient way to specify the item that should gain focus when an arrow or tab key is pressed. | - | ||||||||||||||||||||||||
366 | - | |||||||||||||||||||||||||
367 | The following example provides key navigation for a 2x2 grid of items: | - | ||||||||||||||||||||||||
368 | - | |||||||||||||||||||||||||
369 | \snippet qml/keynavigation.qml 0 | - | ||||||||||||||||||||||||
370 | - | |||||||||||||||||||||||||
371 | The top-left item initially receives focus by setting \l {Item::}{focus} to | - | ||||||||||||||||||||||||
372 | \c true. When an arrow key is pressed, the focus will move to the | - | ||||||||||||||||||||||||
373 | appropriate item, as defined by the value that has been set for | - | ||||||||||||||||||||||||
374 | the KeyNavigation \l left, \l right, \l up or \l down properties. | - | ||||||||||||||||||||||||
375 | - | |||||||||||||||||||||||||
376 | Note that if a KeyNavigation attached property receives the key press and release | - | ||||||||||||||||||||||||
377 | events for a requested arrow or tab key, the event is accepted and does not | - | ||||||||||||||||||||||||
378 | propagate any further. | - | ||||||||||||||||||||||||
379 | - | |||||||||||||||||||||||||
380 | By default, KeyNavigation receives key events after the item to which it is attached. | - | ||||||||||||||||||||||||
381 | If the item accepts the key event, the KeyNavigation attached property will not | - | ||||||||||||||||||||||||
382 | receive an event for that key. Setting the \l priority property to | - | ||||||||||||||||||||||||
383 | \c KeyNavigation.BeforeItem allows the event to be used for key navigation | - | ||||||||||||||||||||||||
384 | before the item, rather than after. | - | ||||||||||||||||||||||||
385 | - | |||||||||||||||||||||||||
386 | If the item to which the focus is switching is not enabled or visible, an attempt will | - | ||||||||||||||||||||||||
387 | be made to skip this item and focus on the next. This is possible if there are | - | ||||||||||||||||||||||||
388 | a chain of items with the same KeyNavigation handler. If multiple items in a row are not enabled | - | ||||||||||||||||||||||||
389 | or visible, they will also be skipped. | - | ||||||||||||||||||||||||
390 | - | |||||||||||||||||||||||||
391 | KeyNavigation will implicitly set the other direction to return focus to this item. So if you set | - | ||||||||||||||||||||||||
392 | \l left to another item, \l right will be set on that item's KeyNavigation to set focus back to this | - | ||||||||||||||||||||||||
393 | item. However, if that item's KeyNavigation has had right explicitly set then no change will occur. | - | ||||||||||||||||||||||||
394 | This means that the example above could achieve the same behavior without specifying | - | ||||||||||||||||||||||||
395 | KeyNavigation.right or KeyNavigation.down for any of the items. | - | ||||||||||||||||||||||||
396 | - | |||||||||||||||||||||||||
397 | \sa {Keys}{Keys attached property} | - | ||||||||||||||||||||||||
398 | */ | - | ||||||||||||||||||||||||
399 | - | |||||||||||||||||||||||||
400 | /*! | - | ||||||||||||||||||||||||
401 | \qmlproperty Item QtQuick::KeyNavigation::left | - | ||||||||||||||||||||||||
402 | - | |||||||||||||||||||||||||
403 | This property holds the item to assign focus to | - | ||||||||||||||||||||||||
404 | when the left cursor key is pressed. | - | ||||||||||||||||||||||||
405 | */ | - | ||||||||||||||||||||||||
406 | - | |||||||||||||||||||||||||
407 | /*! | - | ||||||||||||||||||||||||
408 | \qmlproperty Item QtQuick::KeyNavigation::right | - | ||||||||||||||||||||||||
409 | - | |||||||||||||||||||||||||
410 | This property holds the item to assign focus to | - | ||||||||||||||||||||||||
411 | when the right cursor key is pressed. | - | ||||||||||||||||||||||||
412 | */ | - | ||||||||||||||||||||||||
413 | - | |||||||||||||||||||||||||
414 | /*! | - | ||||||||||||||||||||||||
415 | \qmlproperty Item QtQuick::KeyNavigation::up | - | ||||||||||||||||||||||||
416 | - | |||||||||||||||||||||||||
417 | This property holds the item to assign focus to | - | ||||||||||||||||||||||||
418 | when the up cursor key is pressed. | - | ||||||||||||||||||||||||
419 | */ | - | ||||||||||||||||||||||||
420 | - | |||||||||||||||||||||||||
421 | /*! | - | ||||||||||||||||||||||||
422 | \qmlproperty Item QtQuick::KeyNavigation::down | - | ||||||||||||||||||||||||
423 | - | |||||||||||||||||||||||||
424 | This property holds the item to assign focus to | - | ||||||||||||||||||||||||
425 | when the down cursor key is pressed. | - | ||||||||||||||||||||||||
426 | */ | - | ||||||||||||||||||||||||
427 | - | |||||||||||||||||||||||||
428 | /*! | - | ||||||||||||||||||||||||
429 | \qmlproperty Item QtQuick::KeyNavigation::tab | - | ||||||||||||||||||||||||
430 | - | |||||||||||||||||||||||||
431 | This property holds the item to assign focus to | - | ||||||||||||||||||||||||
432 | when the Tab key is pressed. | - | ||||||||||||||||||||||||
433 | */ | - | ||||||||||||||||||||||||
434 | - | |||||||||||||||||||||||||
435 | /*! | - | ||||||||||||||||||||||||
436 | \qmlproperty Item QtQuick::KeyNavigation::backtab | - | ||||||||||||||||||||||||
437 | - | |||||||||||||||||||||||||
438 | This property holds the item to assign focus to | - | ||||||||||||||||||||||||
439 | when the Shift+Tab key combination (Backtab) is pressed. | - | ||||||||||||||||||||||||
440 | */ | - | ||||||||||||||||||||||||
441 | - | |||||||||||||||||||||||||
442 | QQuickKeyNavigationAttached::QQuickKeyNavigationAttached(QObject *parent) | - | ||||||||||||||||||||||||
443 | : QObject(*(new QQuickKeyNavigationAttachedPrivate), parent), | - | ||||||||||||||||||||||||
444 | QQuickItemKeyFilter(qmlobject_cast<QQuickItem*>(parent)) | - | ||||||||||||||||||||||||
445 | { | - | ||||||||||||||||||||||||
446 | m_processPost = true; | - | ||||||||||||||||||||||||
447 | } executed 144 times by 5 tests: end of block Executed by:
| 144 | ||||||||||||||||||||||||
448 | - | |||||||||||||||||||||||||
449 | QQuickKeyNavigationAttached * | - | ||||||||||||||||||||||||
450 | QQuickKeyNavigationAttached::qmlAttachedProperties(QObject *obj) | - | ||||||||||||||||||||||||
451 | { | - | ||||||||||||||||||||||||
452 | return new QQuickKeyNavigationAttached(obj); executed 144 times by 5 tests: return new QQuickKeyNavigationAttached(obj); Executed by:
| 144 | ||||||||||||||||||||||||
453 | } | - | ||||||||||||||||||||||||
454 | - | |||||||||||||||||||||||||
455 | QQuickItem *QQuickKeyNavigationAttached::left() const | - | ||||||||||||||||||||||||
456 | { | - | ||||||||||||||||||||||||
457 | Q_D(const QQuickKeyNavigationAttached); | - | ||||||||||||||||||||||||
458 | return d->left; executed 14 times by 1 test: return d->left; Executed by:
| 14 | ||||||||||||||||||||||||
459 | } | - | ||||||||||||||||||||||||
460 | - | |||||||||||||||||||||||||
461 | void QQuickKeyNavigationAttached::setLeft(QQuickItem *i) | - | ||||||||||||||||||||||||
462 | { | - | ||||||||||||||||||||||||
463 | Q_D(QQuickKeyNavigationAttached); | - | ||||||||||||||||||||||||
464 | if (d->leftSet && d->left == i)
| 0-56 | ||||||||||||||||||||||||
465 | return; never executed: return; | 0 | ||||||||||||||||||||||||
466 | d->left = i; | - | ||||||||||||||||||||||||
467 | d->leftSet = true; | - | ||||||||||||||||||||||||
468 | QQuickKeyNavigationAttached* other = | - | ||||||||||||||||||||||||
469 | qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i)); | - | ||||||||||||||||||||||||
470 | if (other && !other->d_func()->rightSet){
| 0-56 | ||||||||||||||||||||||||
471 | other->d_func()->right = qobject_cast<QQuickItem*>(parent()); | - | ||||||||||||||||||||||||
472 | emit other->rightChanged(); | - | ||||||||||||||||||||||||
473 | } executed 56 times by 5 tests: end of block Executed by:
| 56 | ||||||||||||||||||||||||
474 | emit leftChanged(); | - | ||||||||||||||||||||||||
475 | } executed 56 times by 5 tests: end of block Executed by:
| 56 | ||||||||||||||||||||||||
476 | - | |||||||||||||||||||||||||
477 | QQuickItem *QQuickKeyNavigationAttached::right() const | - | ||||||||||||||||||||||||
478 | { | - | ||||||||||||||||||||||||
479 | Q_D(const QQuickKeyNavigationAttached); | - | ||||||||||||||||||||||||
480 | return d->right; executed 16 times by 1 test: return d->right; Executed by:
| 16 | ||||||||||||||||||||||||
481 | } | - | ||||||||||||||||||||||||
482 | - | |||||||||||||||||||||||||
483 | void QQuickKeyNavigationAttached::setRight(QQuickItem *i) | - | ||||||||||||||||||||||||
484 | { | - | ||||||||||||||||||||||||
485 | Q_D(QQuickKeyNavigationAttached); | - | ||||||||||||||||||||||||
486 | if (d->rightSet && d->right == i)
| 0-52 | ||||||||||||||||||||||||
487 | return; never executed: return; | 0 | ||||||||||||||||||||||||
488 | d->right = i; | - | ||||||||||||||||||||||||
489 | d->rightSet = true; | - | ||||||||||||||||||||||||
490 | QQuickKeyNavigationAttached* other = | - | ||||||||||||||||||||||||
491 | qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i)); | - | ||||||||||||||||||||||||
492 | if (other && !other->d_func()->leftSet){
| 0-52 | ||||||||||||||||||||||||
493 | other->d_func()->left = qobject_cast<QQuickItem*>(parent()); | - | ||||||||||||||||||||||||
494 | emit other->leftChanged(); | - | ||||||||||||||||||||||||
495 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
496 | emit rightChanged(); | - | ||||||||||||||||||||||||
497 | } executed 52 times by 5 tests: end of block Executed by:
| 52 | ||||||||||||||||||||||||
498 | - | |||||||||||||||||||||||||
499 | QQuickItem *QQuickKeyNavigationAttached::up() const | - | ||||||||||||||||||||||||
500 | { | - | ||||||||||||||||||||||||
501 | Q_D(const QQuickKeyNavigationAttached); | - | ||||||||||||||||||||||||
502 | return d->up; executed 14 times by 1 test: return d->up; Executed by:
| 14 | ||||||||||||||||||||||||
503 | } | - | ||||||||||||||||||||||||
504 | - | |||||||||||||||||||||||||
505 | void QQuickKeyNavigationAttached::setUp(QQuickItem *i) | - | ||||||||||||||||||||||||
506 | { | - | ||||||||||||||||||||||||
507 | Q_D(QQuickKeyNavigationAttached); | - | ||||||||||||||||||||||||
508 | if (d->upSet && d->up == i)
| 0-58 | ||||||||||||||||||||||||
509 | return; never executed: return; | 0 | ||||||||||||||||||||||||
510 | d->up = i; | - | ||||||||||||||||||||||||
511 | d->upSet = true; | - | ||||||||||||||||||||||||
512 | QQuickKeyNavigationAttached* other = | - | ||||||||||||||||||||||||
513 | qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i)); | - | ||||||||||||||||||||||||
514 | if (other && !other->d_func()->downSet){
| 0-58 | ||||||||||||||||||||||||
515 | other->d_func()->down = qobject_cast<QQuickItem*>(parent()); | - | ||||||||||||||||||||||||
516 | emit other->downChanged(); | - | ||||||||||||||||||||||||
517 | } executed 58 times by 5 tests: end of block Executed by:
| 58 | ||||||||||||||||||||||||
518 | emit upChanged(); | - | ||||||||||||||||||||||||
519 | } executed 58 times by 5 tests: end of block Executed by:
| 58 | ||||||||||||||||||||||||
520 | - | |||||||||||||||||||||||||
521 | QQuickItem *QQuickKeyNavigationAttached::down() const | - | ||||||||||||||||||||||||
522 | { | - | ||||||||||||||||||||||||
523 | Q_D(const QQuickKeyNavigationAttached); | - | ||||||||||||||||||||||||
524 | return d->down; executed 20 times by 1 test: return d->down; Executed by:
| 20 | ||||||||||||||||||||||||
525 | } | - | ||||||||||||||||||||||||
526 | - | |||||||||||||||||||||||||
527 | void QQuickKeyNavigationAttached::setDown(QQuickItem *i) | - | ||||||||||||||||||||||||
528 | { | - | ||||||||||||||||||||||||
529 | Q_D(QQuickKeyNavigationAttached); | - | ||||||||||||||||||||||||
530 | if (d->downSet && d->down == i)
| 0-60 | ||||||||||||||||||||||||
531 | return; never executed: return; | 0 | ||||||||||||||||||||||||
532 | d->down = i; | - | ||||||||||||||||||||||||
533 | d->downSet = true; | - | ||||||||||||||||||||||||
534 | QQuickKeyNavigationAttached* other = | - | ||||||||||||||||||||||||
535 | qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i)); | - | ||||||||||||||||||||||||
536 | if (other && !other->d_func()->upSet) {
| 0-60 | ||||||||||||||||||||||||
537 | other->d_func()->up = qobject_cast<QQuickItem*>(parent()); | - | ||||||||||||||||||||||||
538 | emit other->upChanged(); | - | ||||||||||||||||||||||||
539 | } executed 30 times by 4 tests: end of block Executed by:
| 30 | ||||||||||||||||||||||||
540 | emit downChanged(); | - | ||||||||||||||||||||||||
541 | } executed 60 times by 5 tests: end of block Executed by:
| 60 | ||||||||||||||||||||||||
542 | - | |||||||||||||||||||||||||
543 | QQuickItem *QQuickKeyNavigationAttached::tab() const | - | ||||||||||||||||||||||||
544 | { | - | ||||||||||||||||||||||||
545 | Q_D(const QQuickKeyNavigationAttached); | - | ||||||||||||||||||||||||
546 | return d->tab; executed 36 times by 1 test: return d->tab; Executed by:
| 36 | ||||||||||||||||||||||||
547 | } | - | ||||||||||||||||||||||||
548 | - | |||||||||||||||||||||||||
549 | void QQuickKeyNavigationAttached::setTab(QQuickItem *i) | - | ||||||||||||||||||||||||
550 | { | - | ||||||||||||||||||||||||
551 | Q_D(QQuickKeyNavigationAttached); | - | ||||||||||||||||||||||||
552 | if (d->tabSet && d->tab == i)
| 0-52 | ||||||||||||||||||||||||
553 | return; never executed: return; | 0 | ||||||||||||||||||||||||
554 | d->tab = i; | - | ||||||||||||||||||||||||
555 | d->tabSet = true; | - | ||||||||||||||||||||||||
556 | QQuickKeyNavigationAttached* other = | - | ||||||||||||||||||||||||
557 | qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i)); | - | ||||||||||||||||||||||||
558 | if (other && !other->d_func()->backtabSet) {
| 0-52 | ||||||||||||||||||||||||
559 | other->d_func()->backtab = qobject_cast<QQuickItem*>(parent()); | - | ||||||||||||||||||||||||
560 | emit other->backtabChanged(); | - | ||||||||||||||||||||||||
561 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||||||||||||||
562 | emit tabChanged(); | - | ||||||||||||||||||||||||
563 | } executed 52 times by 2 tests: end of block Executed by:
| 52 | ||||||||||||||||||||||||
564 | - | |||||||||||||||||||||||||
565 | QQuickItem *QQuickKeyNavigationAttached::backtab() const | - | ||||||||||||||||||||||||
566 | { | - | ||||||||||||||||||||||||
567 | Q_D(const QQuickKeyNavigationAttached); | - | ||||||||||||||||||||||||
568 | return d->backtab; executed 36 times by 1 test: return d->backtab; Executed by:
| 36 | ||||||||||||||||||||||||
569 | } | - | ||||||||||||||||||||||||
570 | - | |||||||||||||||||||||||||
571 | void QQuickKeyNavigationAttached::setBacktab(QQuickItem *i) | - | ||||||||||||||||||||||||
572 | { | - | ||||||||||||||||||||||||
573 | Q_D(QQuickKeyNavigationAttached); | - | ||||||||||||||||||||||||
574 | if (d->backtabSet && d->backtab == i)
| 0-52 | ||||||||||||||||||||||||
575 | return; never executed: return; | 0 | ||||||||||||||||||||||||
576 | d->backtab = i; | - | ||||||||||||||||||||||||
577 | d->backtabSet = true; | - | ||||||||||||||||||||||||
578 | QQuickKeyNavigationAttached* other = | - | ||||||||||||||||||||||||
579 | qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i)); | - | ||||||||||||||||||||||||
580 | if (other && !other->d_func()->tabSet) {
| 0-52 | ||||||||||||||||||||||||
581 | other->d_func()->tab = qobject_cast<QQuickItem*>(parent()); | - | ||||||||||||||||||||||||
582 | emit other->tabChanged(); | - | ||||||||||||||||||||||||
583 | } executed 40 times by 2 tests: end of block Executed by:
| 40 | ||||||||||||||||||||||||
584 | emit backtabChanged(); | - | ||||||||||||||||||||||||
585 | } executed 52 times by 2 tests: end of block Executed by:
| 52 | ||||||||||||||||||||||||
586 | - | |||||||||||||||||||||||||
587 | /*! | - | ||||||||||||||||||||||||
588 | \qmlproperty enumeration QtQuick::KeyNavigation::priority | - | ||||||||||||||||||||||||
589 | - | |||||||||||||||||||||||||
590 | This property determines whether the keys are processed before | - | ||||||||||||||||||||||||
591 | or after the attached item's own key handling. | - | ||||||||||||||||||||||||
592 | - | |||||||||||||||||||||||||
593 | \list | - | ||||||||||||||||||||||||
594 | \li KeyNavigation.BeforeItem - process the key events before normal | - | ||||||||||||||||||||||||
595 | item key processing. If the event is used for key navigation, it will be accepted and will not | - | ||||||||||||||||||||||||
596 | be passed on to the item. | - | ||||||||||||||||||||||||
597 | \li KeyNavigation.AfterItem (default) - process the key events after normal item key | - | ||||||||||||||||||||||||
598 | handling. If the item accepts the key event it will not be | - | ||||||||||||||||||||||||
599 | handled by the KeyNavigation attached property handler. | - | ||||||||||||||||||||||||
600 | \endlist | - | ||||||||||||||||||||||||
601 | */ | - | ||||||||||||||||||||||||
602 | QQuickKeyNavigationAttached::Priority QQuickKeyNavigationAttached::priority() const | - | ||||||||||||||||||||||||
603 | { | - | ||||||||||||||||||||||||
604 | return m_processPost ? AfterItem : BeforeItem; never executed: return m_processPost ? AfterItem : BeforeItem; | 0 | ||||||||||||||||||||||||
605 | } | - | ||||||||||||||||||||||||
606 | - | |||||||||||||||||||||||||
607 | void QQuickKeyNavigationAttached::setPriority(Priority order) | - | ||||||||||||||||||||||||
608 | { | - | ||||||||||||||||||||||||
609 | bool processPost = order == AfterItem; | - | ||||||||||||||||||||||||
610 | if (processPost != m_processPost) {
| 0 | ||||||||||||||||||||||||
611 | m_processPost = processPost; | - | ||||||||||||||||||||||||
612 | emit priorityChanged(); | - | ||||||||||||||||||||||||
613 | } never executed: end of block | 0 | ||||||||||||||||||||||||
614 | } never executed: end of block | 0 | ||||||||||||||||||||||||
615 | - | |||||||||||||||||||||||||
616 | void QQuickKeyNavigationAttached::keyPressed(QKeyEvent *event, bool post) | - | ||||||||||||||||||||||||
617 | { | - | ||||||||||||||||||||||||
618 | Q_D(QQuickKeyNavigationAttached); | - | ||||||||||||||||||||||||
619 | event->ignore(); | - | ||||||||||||||||||||||||
620 | - | |||||||||||||||||||||||||
621 | if (post != m_processPost) {
| 126-148 | ||||||||||||||||||||||||
622 | QQuickItemKeyFilter::keyPressed(event, post); | - | ||||||||||||||||||||||||
623 | return; executed 148 times by 4 tests: return; Executed by:
| 148 | ||||||||||||||||||||||||
624 | } | - | ||||||||||||||||||||||||
625 | - | |||||||||||||||||||||||||
626 | bool mirror = false; | - | ||||||||||||||||||||||||
627 | switch (event->key()) { | - | ||||||||||||||||||||||||
628 | case Qt::Key_Left: { executed 34 times by 3 tests: case Qt::Key_Left: Executed by:
| 34 | ||||||||||||||||||||||||
629 | if (QQuickItem *parentItem = qobject_cast<QQuickItem*>(parent()))
| 0-34 | ||||||||||||||||||||||||
630 | mirror = QQuickItemPrivate::get(parentItem)->effectiveLayoutMirror; executed 34 times by 3 tests: mirror = QQuickItemPrivate::get(parentItem)->effectiveLayoutMirror; Executed by:
| 34 | ||||||||||||||||||||||||
631 | QQuickItem* leftItem = mirror ? d->right : d->left;
| 2-32 | ||||||||||||||||||||||||
632 | if (leftItem) {
| 0-34 | ||||||||||||||||||||||||
633 | setFocusNavigation(leftItem, mirror ? "right" : "left", mirror ? Qt::TabFocusReason : Qt::BacktabFocusReason); | - | ||||||||||||||||||||||||
634 | event->accept(); | - | ||||||||||||||||||||||||
635 | } executed 34 times by 3 tests: end of block Executed by:
| 34 | ||||||||||||||||||||||||
636 | break; executed 34 times by 3 tests: break; Executed by:
| 34 | ||||||||||||||||||||||||
637 | } | - | ||||||||||||||||||||||||
638 | case Qt::Key_Right: { executed 38 times by 4 tests: case Qt::Key_Right: Executed by:
| 38 | ||||||||||||||||||||||||
639 | if (QQuickItem *parentItem = qobject_cast<QQuickItem*>(parent()))
| 0-38 | ||||||||||||||||||||||||
640 | mirror = QQuickItemPrivate::get(parentItem)->effectiveLayoutMirror; executed 38 times by 4 tests: mirror = QQuickItemPrivate::get(parentItem)->effectiveLayoutMirror; Executed by:
| 38 | ||||||||||||||||||||||||
641 | QQuickItem* rightItem = mirror ? d->left : d->right;
| 2-36 | ||||||||||||||||||||||||
642 | if (rightItem) {
| 0-38 | ||||||||||||||||||||||||
643 | setFocusNavigation(rightItem, mirror ? "left" : "right", mirror ? Qt::BacktabFocusReason : Qt::TabFocusReason); | - | ||||||||||||||||||||||||
644 | event->accept(); | - | ||||||||||||||||||||||||
645 | } executed 38 times by 4 tests: end of block Executed by:
| 38 | ||||||||||||||||||||||||
646 | break; executed 38 times by 4 tests: break; Executed by:
| 38 | ||||||||||||||||||||||||
647 | } | - | ||||||||||||||||||||||||
648 | case Qt::Key_Up: executed 8 times by 2 tests: case Qt::Key_Up: Executed by:
| 8 | ||||||||||||||||||||||||
649 | if (d->up) {
| 0-8 | ||||||||||||||||||||||||
650 | setFocusNavigation(d->up, "up", Qt::BacktabFocusReason); | - | ||||||||||||||||||||||||
651 | event->accept(); | - | ||||||||||||||||||||||||
652 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||
653 | break; executed 8 times by 2 tests: break; Executed by:
| 8 | ||||||||||||||||||||||||
654 | case Qt::Key_Down: executed 20 times by 3 tests: case Qt::Key_Down: Executed by:
| 20 | ||||||||||||||||||||||||
655 | if (d->down) {
| 4-16 | ||||||||||||||||||||||||
656 | setFocusNavigation(d->down, "down", Qt::TabFocusReason); | - | ||||||||||||||||||||||||
657 | event->accept(); | - | ||||||||||||||||||||||||
658 | } executed 16 times by 3 tests: end of block Executed by:
| 16 | ||||||||||||||||||||||||
659 | break; executed 20 times by 3 tests: break; Executed by:
| 20 | ||||||||||||||||||||||||
660 | case Qt::Key_Tab: executed 12 times by 1 test: case Qt::Key_Tab: Executed by:
| 12 | ||||||||||||||||||||||||
661 | if (d->tab) {
| 0-12 | ||||||||||||||||||||||||
662 | setFocusNavigation(d->tab, "tab", Qt::TabFocusReason); | - | ||||||||||||||||||||||||
663 | event->accept(); | - | ||||||||||||||||||||||||
664 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
665 | break; executed 12 times by 1 test: break; Executed by:
| 12 | ||||||||||||||||||||||||
666 | case Qt::Key_Backtab: executed 14 times by 1 test: case Qt::Key_Backtab: Executed by:
| 14 | ||||||||||||||||||||||||
667 | if (d->backtab) {
| 0-14 | ||||||||||||||||||||||||
668 | setFocusNavigation(d->backtab, "backtab", Qt::BacktabFocusReason); | - | ||||||||||||||||||||||||
669 | event->accept(); | - | ||||||||||||||||||||||||
670 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||
671 | break; executed 14 times by 1 test: break; Executed by:
| 14 | ||||||||||||||||||||||||
672 | default: never executed: default: | 0 | ||||||||||||||||||||||||
673 | break; never executed: break; | 0 | ||||||||||||||||||||||||
674 | } | - | ||||||||||||||||||||||||
675 | - | |||||||||||||||||||||||||
676 | if (!event->isAccepted()) QQuickItemKeyFilter::keyPressed(event, post); executed 4 times by 1 test: QQuickItemKeyFilter::keyPressed(event, post); Executed by:
| 4-122 | ||||||||||||||||||||||||
677 | } executed 126 times by 4 tests: end of block Executed by:
| 126 | ||||||||||||||||||||||||
678 | - | |||||||||||||||||||||||||
679 | void QQuickKeyNavigationAttached::keyReleased(QKeyEvent *event, bool post) | - | ||||||||||||||||||||||||
680 | { | - | ||||||||||||||||||||||||
681 | Q_D(QQuickKeyNavigationAttached); | - | ||||||||||||||||||||||||
682 | event->ignore(); | - | ||||||||||||||||||||||||
683 | - | |||||||||||||||||||||||||
684 | if (post != m_processPost) {
| 50-80 | ||||||||||||||||||||||||
685 | QQuickItemKeyFilter::keyReleased(event, post); | - | ||||||||||||||||||||||||
686 | return; executed 80 times by 3 tests: return; Executed by:
| 80 | ||||||||||||||||||||||||
687 | } | - | ||||||||||||||||||||||||
688 | - | |||||||||||||||||||||||||
689 | bool mirror = false; | - | ||||||||||||||||||||||||
690 | switch (event->key()) { | - | ||||||||||||||||||||||||
691 | case Qt::Key_Left: executed 18 times by 2 tests: case Qt::Key_Left: Executed by:
| 18 | ||||||||||||||||||||||||
692 | if (QQuickItem *parentItem = qobject_cast<QQuickItem*>(parent()))
| 0-18 | ||||||||||||||||||||||||
693 | mirror = QQuickItemPrivate::get(parentItem)->effectiveLayoutMirror; executed 18 times by 2 tests: mirror = QQuickItemPrivate::get(parentItem)->effectiveLayoutMirror; Executed by:
| 18 | ||||||||||||||||||||||||
694 | if (mirror ? d->right : d->left)
| 0-18 | ||||||||||||||||||||||||
695 | event->accept(); executed 6 times by 1 test: event->accept(); Executed by:
| 6 | ||||||||||||||||||||||||
696 | break; executed 18 times by 2 tests: break; Executed by:
| 18 | ||||||||||||||||||||||||
697 | case Qt::Key_Right: executed 26 times by 3 tests: case Qt::Key_Right: Executed by:
| 26 | ||||||||||||||||||||||||
698 | if (QQuickItem *parentItem = qobject_cast<QQuickItem*>(parent()))
| 0-26 | ||||||||||||||||||||||||
699 | mirror = QQuickItemPrivate::get(parentItem)->effectiveLayoutMirror; executed 26 times by 3 tests: mirror = QQuickItemPrivate::get(parentItem)->effectiveLayoutMirror; Executed by:
| 26 | ||||||||||||||||||||||||
700 | if (mirror ? d->left : d->right)
| 0-26 | ||||||||||||||||||||||||
701 | event->accept(); executed 6 times by 1 test: event->accept(); Executed by:
| 6 | ||||||||||||||||||||||||
702 | break; executed 26 times by 3 tests: break; Executed by:
| 26 | ||||||||||||||||||||||||
703 | case Qt::Key_Up: executed 2 times by 1 test: case Qt::Key_Up: Executed by:
| 2 | ||||||||||||||||||||||||
704 | if (d->up) {
| 0-2 | ||||||||||||||||||||||||
705 | event->accept(); | - | ||||||||||||||||||||||||
706 | } never executed: end of block | 0 | ||||||||||||||||||||||||
707 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
708 | case Qt::Key_Down: executed 4 times by 2 tests: case Qt::Key_Down: Executed by:
| 4 | ||||||||||||||||||||||||
709 | if (d->down) {
| 2 | ||||||||||||||||||||||||
710 | event->accept(); | - | ||||||||||||||||||||||||
711 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
712 | break; executed 4 times by 2 tests: break; Executed by:
| 4 | ||||||||||||||||||||||||
713 | case Qt::Key_Tab: never executed: case Qt::Key_Tab: | 0 | ||||||||||||||||||||||||
714 | if (d->tab) {
| 0 | ||||||||||||||||||||||||
715 | event->accept(); | - | ||||||||||||||||||||||||
716 | } never executed: end of block | 0 | ||||||||||||||||||||||||
717 | break; never executed: break; | 0 | ||||||||||||||||||||||||
718 | case Qt::Key_Backtab: never executed: case Qt::Key_Backtab: | 0 | ||||||||||||||||||||||||
719 | if (d->backtab) {
| 0 | ||||||||||||||||||||||||
720 | event->accept(); | - | ||||||||||||||||||||||||
721 | } never executed: end of block | 0 | ||||||||||||||||||||||||
722 | break; never executed: break; | 0 | ||||||||||||||||||||||||
723 | default: never executed: default: | 0 | ||||||||||||||||||||||||
724 | break; never executed: break; | 0 | ||||||||||||||||||||||||
725 | } | - | ||||||||||||||||||||||||
726 | - | |||||||||||||||||||||||||
727 | if (!event->isAccepted()) QQuickItemKeyFilter::keyReleased(event, post); executed 36 times by 3 tests: QQuickItemKeyFilter::keyReleased(event, post); Executed by:
| 14-36 | ||||||||||||||||||||||||
728 | } executed 50 times by 3 tests: end of block Executed by:
| 50 | ||||||||||||||||||||||||
729 | - | |||||||||||||||||||||||||
730 | void QQuickKeyNavigationAttached::setFocusNavigation(QQuickItem *currentItem, const char *dir, | - | ||||||||||||||||||||||||
731 | Qt::FocusReason reason) | - | ||||||||||||||||||||||||
732 | { | - | ||||||||||||||||||||||||
733 | QQuickItem *initialItem = currentItem; | - | ||||||||||||||||||||||||
734 | bool isNextItem = false; | - | ||||||||||||||||||||||||
735 | QVector<QQuickItem *> visitedItems; | - | ||||||||||||||||||||||||
736 | do { | - | ||||||||||||||||||||||||
737 | isNextItem = false; | - | ||||||||||||||||||||||||
738 | if (currentItem->isVisible() && currentItem->isEnabled()) {
| 6-124 | ||||||||||||||||||||||||
739 | currentItem->forceActiveFocus(reason); | - | ||||||||||||||||||||||||
740 | } else { executed 118 times by 4 tests: end of block Executed by:
| 118 | ||||||||||||||||||||||||
741 | QObject *attached = | - | ||||||||||||||||||||||||
742 | qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(currentItem, false); | - | ||||||||||||||||||||||||
743 | if (attached) {
| 0-20 | ||||||||||||||||||||||||
744 | QQuickItem *tempItem = qvariant_cast<QQuickItem*>(attached->property(dir)); | - | ||||||||||||||||||||||||
745 | if (tempItem) {
| 2-18 | ||||||||||||||||||||||||
746 | visitedItems.append(currentItem); | - | ||||||||||||||||||||||||
747 | currentItem = tempItem; | - | ||||||||||||||||||||||||
748 | isNextItem = true; | - | ||||||||||||||||||||||||
749 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
750 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||
751 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||
752 | } | - | ||||||||||||||||||||||||
753 | while (currentItem != initialItem && isNextItem && !visitedItems.contains(currentItem));
| 2-112 | ||||||||||||||||||||||||
754 | } executed 122 times by 4 tests: end of block Executed by:
| 122 | ||||||||||||||||||||||||
755 | - | |||||||||||||||||||||||||
756 | struct SigMap { | - | ||||||||||||||||||||||||
757 | int key; | - | ||||||||||||||||||||||||
758 | const char *sig; | - | ||||||||||||||||||||||||
759 | }; | - | ||||||||||||||||||||||||
760 | - | |||||||||||||||||||||||||
761 | const SigMap sigMap[] = { | - | ||||||||||||||||||||||||
762 | { Qt::Key_Left, "leftPressed" }, | - | ||||||||||||||||||||||||
763 | { Qt::Key_Right, "rightPressed" }, | - | ||||||||||||||||||||||||
764 | { Qt::Key_Up, "upPressed" }, | - | ||||||||||||||||||||||||
765 | { Qt::Key_Down, "downPressed" }, | - | ||||||||||||||||||||||||
766 | { Qt::Key_Tab, "tabPressed" }, | - | ||||||||||||||||||||||||
767 | { Qt::Key_Backtab, "backtabPressed" }, | - | ||||||||||||||||||||||||
768 | { Qt::Key_Asterisk, "asteriskPressed" }, | - | ||||||||||||||||||||||||
769 | { Qt::Key_NumberSign, "numberSignPressed" }, | - | ||||||||||||||||||||||||
770 | { Qt::Key_Escape, "escapePressed" }, | - | ||||||||||||||||||||||||
771 | { Qt::Key_Return, "returnPressed" }, | - | ||||||||||||||||||||||||
772 | { Qt::Key_Enter, "enterPressed" }, | - | ||||||||||||||||||||||||
773 | { Qt::Key_Delete, "deletePressed" }, | - | ||||||||||||||||||||||||
774 | { Qt::Key_Space, "spacePressed" }, | - | ||||||||||||||||||||||||
775 | { Qt::Key_Back, "backPressed" }, | - | ||||||||||||||||||||||||
776 | { Qt::Key_Cancel, "cancelPressed" }, | - | ||||||||||||||||||||||||
777 | { Qt::Key_Select, "selectPressed" }, | - | ||||||||||||||||||||||||
778 | { Qt::Key_Yes, "yesPressed" }, | - | ||||||||||||||||||||||||
779 | { Qt::Key_No, "noPressed" }, | - | ||||||||||||||||||||||||
780 | { Qt::Key_Context1, "context1Pressed" }, | - | ||||||||||||||||||||||||
781 | { Qt::Key_Context2, "context2Pressed" }, | - | ||||||||||||||||||||||||
782 | { Qt::Key_Context3, "context3Pressed" }, | - | ||||||||||||||||||||||||
783 | { Qt::Key_Context4, "context4Pressed" }, | - | ||||||||||||||||||||||||
784 | { Qt::Key_Call, "callPressed" }, | - | ||||||||||||||||||||||||
785 | { Qt::Key_Hangup, "hangupPressed" }, | - | ||||||||||||||||||||||||
786 | { Qt::Key_Flip, "flipPressed" }, | - | ||||||||||||||||||||||||
787 | { Qt::Key_Menu, "menuPressed" }, | - | ||||||||||||||||||||||||
788 | { Qt::Key_VolumeUp, "volumeUpPressed" }, | - | ||||||||||||||||||||||||
789 | { Qt::Key_VolumeDown, "volumeDownPressed" }, | - | ||||||||||||||||||||||||
790 | { 0, nullptr } | - | ||||||||||||||||||||||||
791 | }; | - | ||||||||||||||||||||||||
792 | - | |||||||||||||||||||||||||
793 | QByteArray QQuickKeysAttached::keyToSignal(int key) | - | ||||||||||||||||||||||||
794 | { | - | ||||||||||||||||||||||||
795 | QByteArray keySignal; | - | ||||||||||||||||||||||||
796 | if (key >= Qt::Key_0 && key <= Qt::Key_9) {
| 0-88 | ||||||||||||||||||||||||
797 | keySignal = "digit0Pressed"; | - | ||||||||||||||||||||||||
798 | keySignal[5] = '0' + (key - Qt::Key_0); | - | ||||||||||||||||||||||||
799 | } else { executed 12 times by 2 tests: end of block Executed by:
| 12 | ||||||||||||||||||||||||
800 | int i = 0; | - | ||||||||||||||||||||||||
801 | while (sigMap[i].key && sigMap[i].key != key)
| 34-1242 | ||||||||||||||||||||||||
802 | ++i; executed 1200 times by 3 tests: ++i; Executed by:
| 1200 | ||||||||||||||||||||||||
803 | keySignal = sigMap[i].sig; | - | ||||||||||||||||||||||||
804 | } executed 76 times by 3 tests: end of block Executed by:
| 76 | ||||||||||||||||||||||||
805 | return keySignal; executed 88 times by 3 tests: return keySignal; Executed by:
| 88 | ||||||||||||||||||||||||
806 | } | - | ||||||||||||||||||||||||
807 | - | |||||||||||||||||||||||||
808 | bool QQuickKeysAttached::isConnected(const char *signalName) const | - | ||||||||||||||||||||||||
809 | { | - | ||||||||||||||||||||||||
810 | Q_D(const QQuickKeysAttached); | - | ||||||||||||||||||||||||
811 | int signal_index = d->signalIndex(signalName); | - | ||||||||||||||||||||||||
812 | return d->isSignalConnected(signal_index); executed 54 times by 3 tests: return d->isSignalConnected(signal_index); Executed by:
| 54 | ||||||||||||||||||||||||
813 | } | - | ||||||||||||||||||||||||
814 | - | |||||||||||||||||||||||||
815 | /*! | - | ||||||||||||||||||||||||
816 | \qmltype Keys | - | ||||||||||||||||||||||||
817 | \instantiates QQuickKeysAttached | - | ||||||||||||||||||||||||
818 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
819 | \ingroup qtquick-input | - | ||||||||||||||||||||||||
820 | \brief Provides key handling to Items. | - | ||||||||||||||||||||||||
821 | - | |||||||||||||||||||||||||
822 | All visual primitives support key handling via the Keys | - | ||||||||||||||||||||||||
823 | attached property. Keys can be handled via the onPressed | - | ||||||||||||||||||||||||
824 | and onReleased signal properties. | - | ||||||||||||||||||||||||
825 | - | |||||||||||||||||||||||||
826 | The signal properties have a \l KeyEvent parameter, named | - | ||||||||||||||||||||||||
827 | \e event which contains details of the event. If a key is | - | ||||||||||||||||||||||||
828 | handled \e event.accepted should be set to true to prevent the | - | ||||||||||||||||||||||||
829 | event from propagating up the item hierarchy. | - | ||||||||||||||||||||||||
830 | - | |||||||||||||||||||||||||
831 | \section1 Example Usage | - | ||||||||||||||||||||||||
832 | - | |||||||||||||||||||||||||
833 | The following example shows how the general onPressed handler can | - | ||||||||||||||||||||||||
834 | be used to test for a certain key; in this case, the left cursor | - | ||||||||||||||||||||||||
835 | key: | - | ||||||||||||||||||||||||
836 | - | |||||||||||||||||||||||||
837 | \snippet qml/keys/keys-pressed.qml key item | - | ||||||||||||||||||||||||
838 | - | |||||||||||||||||||||||||
839 | Some keys may alternatively be handled via specific signal properties, | - | ||||||||||||||||||||||||
840 | for example \e onSelectPressed. These handlers automatically set | - | ||||||||||||||||||||||||
841 | \e event.accepted to true. | - | ||||||||||||||||||||||||
842 | - | |||||||||||||||||||||||||
843 | \snippet qml/keys/keys-handler.qml key item | - | ||||||||||||||||||||||||
844 | - | |||||||||||||||||||||||||
845 | See \l{Qt::Key}{Qt.Key} for the list of keyboard codes. | - | ||||||||||||||||||||||||
846 | - | |||||||||||||||||||||||||
847 | \section1 Key Handling Priorities | - | ||||||||||||||||||||||||
848 | - | |||||||||||||||||||||||||
849 | The Keys attached property can be configured to handle key events | - | ||||||||||||||||||||||||
850 | before or after the item it is attached to. This makes it possible | - | ||||||||||||||||||||||||
851 | to intercept events in order to override an item's default behavior, | - | ||||||||||||||||||||||||
852 | or act as a fallback for keys not handled by the item. | - | ||||||||||||||||||||||||
853 | - | |||||||||||||||||||||||||
854 | If \l priority is Keys.BeforeItem (default) the order of key event processing is: | - | ||||||||||||||||||||||||
855 | - | |||||||||||||||||||||||||
856 | \list 1 | - | ||||||||||||||||||||||||
857 | \li Items specified in \c forwardTo | - | ||||||||||||||||||||||||
858 | \li specific key handlers, e.g. onReturnPressed | - | ||||||||||||||||||||||||
859 | \li onPressed, onReleased handlers | - | ||||||||||||||||||||||||
860 | \li Item specific key handling, e.g. TextInput key handling | - | ||||||||||||||||||||||||
861 | \li parent item | - | ||||||||||||||||||||||||
862 | \endlist | - | ||||||||||||||||||||||||
863 | - | |||||||||||||||||||||||||
864 | If priority is Keys.AfterItem the order of key event processing is: | - | ||||||||||||||||||||||||
865 | - | |||||||||||||||||||||||||
866 | \list 1 | - | ||||||||||||||||||||||||
867 | \li Item specific key handling, e.g. TextInput key handling | - | ||||||||||||||||||||||||
868 | \li Items specified in \c forwardTo | - | ||||||||||||||||||||||||
869 | \li specific key handlers, e.g. onReturnPressed | - | ||||||||||||||||||||||||
870 | \li onPressed, onReleased handlers | - | ||||||||||||||||||||||||
871 | \li parent item | - | ||||||||||||||||||||||||
872 | \endlist | - | ||||||||||||||||||||||||
873 | - | |||||||||||||||||||||||||
874 | If the event is accepted during any of the above steps, key | - | ||||||||||||||||||||||||
875 | propagation stops. | - | ||||||||||||||||||||||||
876 | - | |||||||||||||||||||||||||
877 | \sa KeyEvent, {KeyNavigation}{KeyNavigation attached property} | - | ||||||||||||||||||||||||
878 | */ | - | ||||||||||||||||||||||||
879 | - | |||||||||||||||||||||||||
880 | /*! | - | ||||||||||||||||||||||||
881 | \qmlproperty bool QtQuick::Keys::enabled | - | ||||||||||||||||||||||||
882 | - | |||||||||||||||||||||||||
883 | This flags enables key handling if true (default); otherwise | - | ||||||||||||||||||||||||
884 | no key handlers will be called. | - | ||||||||||||||||||||||||
885 | */ | - | ||||||||||||||||||||||||
886 | - | |||||||||||||||||||||||||
887 | /*! | - | ||||||||||||||||||||||||
888 | \qmlproperty enumeration QtQuick::Keys::priority | - | ||||||||||||||||||||||||
889 | - | |||||||||||||||||||||||||
890 | This property determines whether the keys are processed before | - | ||||||||||||||||||||||||
891 | or after the attached item's own key handling. | - | ||||||||||||||||||||||||
892 | - | |||||||||||||||||||||||||
893 | \list | - | ||||||||||||||||||||||||
894 | \li Keys.BeforeItem (default) - process the key events before normal | - | ||||||||||||||||||||||||
895 | item key processing. If the event is accepted it will not | - | ||||||||||||||||||||||||
896 | be passed on to the item. | - | ||||||||||||||||||||||||
897 | \li Keys.AfterItem - process the key events after normal item key | - | ||||||||||||||||||||||||
898 | handling. If the item accepts the key event it will not be | - | ||||||||||||||||||||||||
899 | handled by the Keys attached property handler. | - | ||||||||||||||||||||||||
900 | \endlist | - | ||||||||||||||||||||||||
901 | - | |||||||||||||||||||||||||
902 | \sa {Key Handling Priorities} | - | ||||||||||||||||||||||||
903 | */ | - | ||||||||||||||||||||||||
904 | - | |||||||||||||||||||||||||
905 | /*! | - | ||||||||||||||||||||||||
906 | \qmlproperty list<Object> QtQuick::Keys::forwardTo | - | ||||||||||||||||||||||||
907 | - | |||||||||||||||||||||||||
908 | This property provides a way to forward key presses, key releases, and keyboard input | - | ||||||||||||||||||||||||
909 | coming from input methods to other items. This can be useful when you want | - | ||||||||||||||||||||||||
910 | one item to handle some keys (e.g. the up and down arrow keys), and another item to | - | ||||||||||||||||||||||||
911 | handle other keys (e.g. the left and right arrow keys). Once an item that has been | - | ||||||||||||||||||||||||
912 | forwarded keys accepts the event it is no longer forwarded to items later in the | - | ||||||||||||||||||||||||
913 | list. | - | ||||||||||||||||||||||||
914 | - | |||||||||||||||||||||||||
915 | This example forwards key events to two lists: | - | ||||||||||||||||||||||||
916 | \qml | - | ||||||||||||||||||||||||
917 | Item { | - | ||||||||||||||||||||||||
918 | ListView { | - | ||||||||||||||||||||||||
919 | id: list1 | - | ||||||||||||||||||||||||
920 | // ... | - | ||||||||||||||||||||||||
921 | } | - | ||||||||||||||||||||||||
922 | ListView { | - | ||||||||||||||||||||||||
923 | id: list2 | - | ||||||||||||||||||||||||
924 | // ... | - | ||||||||||||||||||||||||
925 | } | - | ||||||||||||||||||||||||
926 | Keys.forwardTo: [list1, list2] | - | ||||||||||||||||||||||||
927 | focus: true | - | ||||||||||||||||||||||||
928 | } | - | ||||||||||||||||||||||||
929 | \endqml | - | ||||||||||||||||||||||||
930 | - | |||||||||||||||||||||||||
931 | To see the order in which events are received when using forwardTo, see | - | ||||||||||||||||||||||||
932 | \l {Key Handling Priorities}. | - | ||||||||||||||||||||||||
933 | */ | - | ||||||||||||||||||||||||
934 | - | |||||||||||||||||||||||||
935 | /*! | - | ||||||||||||||||||||||||
936 | \qmlsignal QtQuick::Keys::pressed(KeyEvent event) | - | ||||||||||||||||||||||||
937 | - | |||||||||||||||||||||||||
938 | This signal is emitted when a key has been pressed. The \a event | - | ||||||||||||||||||||||||
939 | parameter provides information about the event. | - | ||||||||||||||||||||||||
940 | - | |||||||||||||||||||||||||
941 | The corresponding handler is \c onPressed. | - | ||||||||||||||||||||||||
942 | */ | - | ||||||||||||||||||||||||
943 | - | |||||||||||||||||||||||||
944 | /*! | - | ||||||||||||||||||||||||
945 | \qmlsignal QtQuick::Keys::released(KeyEvent event) | - | ||||||||||||||||||||||||
946 | - | |||||||||||||||||||||||||
947 | This signal is emitted when a key has been released. The \a event | - | ||||||||||||||||||||||||
948 | parameter provides information about the event. | - | ||||||||||||||||||||||||
949 | - | |||||||||||||||||||||||||
950 | The corresponding handler is \c onReleased. | - | ||||||||||||||||||||||||
951 | */ | - | ||||||||||||||||||||||||
952 | - | |||||||||||||||||||||||||
953 | /*! | - | ||||||||||||||||||||||||
954 | \qmlsignal QtQuick::Keys::shortcutOverride(KeyEvent event) | - | ||||||||||||||||||||||||
955 | \since 5.9 | - | ||||||||||||||||||||||||
956 | - | |||||||||||||||||||||||||
957 | This signal is emitted when a key has been pressed that could potentially | - | ||||||||||||||||||||||||
958 | be used as a shortcut. The \a event parameter provides information about | - | ||||||||||||||||||||||||
959 | the event. | - | ||||||||||||||||||||||||
960 | - | |||||||||||||||||||||||||
961 | Set \c event.accepted to \c true if you wish to prevent the pressed key | - | ||||||||||||||||||||||||
962 | from being used as a shortcut by other types, such as \l Shortcut. For | - | ||||||||||||||||||||||||
963 | example: | - | ||||||||||||||||||||||||
964 | - | |||||||||||||||||||||||||
965 | \code | - | ||||||||||||||||||||||||
966 | Item { | - | ||||||||||||||||||||||||
967 | id: escapeItem | - | ||||||||||||||||||||||||
968 | focus: true | - | ||||||||||||||||||||||||
969 | - | |||||||||||||||||||||||||
970 | // Ensure that we get escape key press events first. | - | ||||||||||||||||||||||||
971 | Keys.onShortcutOverride: event.accepted = (event.key === Qt.Key_Escape) | - | ||||||||||||||||||||||||
972 | - | |||||||||||||||||||||||||
973 | Keys.onEscapePressed: { | - | ||||||||||||||||||||||||
974 | console.log("escapeItem is handling escape"); | - | ||||||||||||||||||||||||
975 | // event.accepted is set to true by default for the specific key handlers | - | ||||||||||||||||||||||||
976 | } | - | ||||||||||||||||||||||||
977 | } | - | ||||||||||||||||||||||||
978 | - | |||||||||||||||||||||||||
979 | Shortcut { | - | ||||||||||||||||||||||||
980 | sequence: "Escape" | - | ||||||||||||||||||||||||
981 | onActivated: console.log("Shortcut is handling escape") | - | ||||||||||||||||||||||||
982 | } | - | ||||||||||||||||||||||||
983 | \endcode | - | ||||||||||||||||||||||||
984 | - | |||||||||||||||||||||||||
985 | As with the other signals, \c shortcutOverride will only be emitted for an | - | ||||||||||||||||||||||||
986 | item if that item has \l {Item::}{activeFocus}. | - | ||||||||||||||||||||||||
987 | - | |||||||||||||||||||||||||
988 | The corresponding handler is \c onShortcutOverride. | - | ||||||||||||||||||||||||
989 | - | |||||||||||||||||||||||||
990 | \sa Shortcut | - | ||||||||||||||||||||||||
991 | */ | - | ||||||||||||||||||||||||
992 | - | |||||||||||||||||||||||||
993 | /*! | - | ||||||||||||||||||||||||
994 | \qmlsignal QtQuick::Keys::digit0Pressed(KeyEvent event) | - | ||||||||||||||||||||||||
995 | - | |||||||||||||||||||||||||
996 | This signal is emitted when the digit '0' has been pressed. The \a event | - | ||||||||||||||||||||||||
997 | parameter provides information about the event. | - | ||||||||||||||||||||||||
998 | - | |||||||||||||||||||||||||
999 | The corresponding handler is \c onDigit0Pressed. | - | ||||||||||||||||||||||||
1000 | */ | - | ||||||||||||||||||||||||
1001 | - | |||||||||||||||||||||||||
1002 | /*! | - | ||||||||||||||||||||||||
1003 | \qmlsignal QtQuick::Keys::digit1Pressed(KeyEvent event) | - | ||||||||||||||||||||||||
1004 | - | |||||||||||||||||||||||||
1005 | This signal is emitted when the digit '1' has been pressed. The \a event | - | ||||||||||||||||||||||||
1006 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1007 | - | |||||||||||||||||||||||||
1008 | The corresponding handler is \c onDigit1Pressed. | - | ||||||||||||||||||||||||
1009 | */ | - | ||||||||||||||||||||||||
1010 | - | |||||||||||||||||||||||||
1011 | /*! | - | ||||||||||||||||||||||||
1012 | \qmlsignal QtQuick::Keys::digit2Pressed(KeyEvent event) | - | ||||||||||||||||||||||||
1013 | - | |||||||||||||||||||||||||
1014 | This signal is emitted when the digit '2' has been pressed. The \a event | - | ||||||||||||||||||||||||
1015 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1016 | - | |||||||||||||||||||||||||
1017 | The corresponding handler is \c onDigit2Pressed. | - | ||||||||||||||||||||||||
1018 | */ | - | ||||||||||||||||||||||||
1019 | - | |||||||||||||||||||||||||
1020 | /*! | - | ||||||||||||||||||||||||
1021 | \qmlsignal QtQuick::Keys::digit3Pressed(KeyEvent event) | - | ||||||||||||||||||||||||
1022 | - | |||||||||||||||||||||||||
1023 | This signal is emitted when the digit '3' has been pressed. The \a event | - | ||||||||||||||||||||||||
1024 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1025 | - | |||||||||||||||||||||||||
1026 | The corresponding handler is \c onDigit3Pressed. | - | ||||||||||||||||||||||||
1027 | */ | - | ||||||||||||||||||||||||
1028 | - | |||||||||||||||||||||||||
1029 | /*! | - | ||||||||||||||||||||||||
1030 | \qmlsignal QtQuick::Keys::digit4Pressed(KeyEvent event) | - | ||||||||||||||||||||||||
1031 | - | |||||||||||||||||||||||||
1032 | This signal is emitted when the digit '4' has been pressed. The \a event | - | ||||||||||||||||||||||||
1033 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1034 | - | |||||||||||||||||||||||||
1035 | The corresponding handler is \c onDigit4Pressed. | - | ||||||||||||||||||||||||
1036 | */ | - | ||||||||||||||||||||||||
1037 | - | |||||||||||||||||||||||||
1038 | /*! | - | ||||||||||||||||||||||||
1039 | \qmlsignal QtQuick::Keys::digit5Pressed(KeyEvent event) | - | ||||||||||||||||||||||||
1040 | - | |||||||||||||||||||||||||
1041 | This signal is emitted when the digit '5' has been pressed. The \a event | - | ||||||||||||||||||||||||
1042 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1043 | - | |||||||||||||||||||||||||
1044 | The corresponding handler is \c onDigit5Pressed. | - | ||||||||||||||||||||||||
1045 | */ | - | ||||||||||||||||||||||||
1046 | - | |||||||||||||||||||||||||
1047 | /*! | - | ||||||||||||||||||||||||
1048 | \qmlsignal QtQuick::Keys::digit6Pressed(KeyEvent event) | - | ||||||||||||||||||||||||
1049 | - | |||||||||||||||||||||||||
1050 | This signal is emitted when the digit '6' has been pressed. The \a event | - | ||||||||||||||||||||||||
1051 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1052 | - | |||||||||||||||||||||||||
1053 | The corresponding handler is \c onDigit6Pressed. | - | ||||||||||||||||||||||||
1054 | */ | - | ||||||||||||||||||||||||
1055 | - | |||||||||||||||||||||||||
1056 | /*! | - | ||||||||||||||||||||||||
1057 | \qmlsignal QtQuick::Keys::digit7Pressed(KeyEvent event) | - | ||||||||||||||||||||||||
1058 | - | |||||||||||||||||||||||||
1059 | This signal is emitted when the digit '7' has been pressed. The \a event | - | ||||||||||||||||||||||||
1060 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1061 | - | |||||||||||||||||||||||||
1062 | The corresponding handler is \c onDigit7Pressed. | - | ||||||||||||||||||||||||
1063 | */ | - | ||||||||||||||||||||||||
1064 | - | |||||||||||||||||||||||||
1065 | /*! | - | ||||||||||||||||||||||||
1066 | \qmlsignal QtQuick::Keys::digit8Pressed(KeyEvent event) | - | ||||||||||||||||||||||||
1067 | - | |||||||||||||||||||||||||
1068 | This signal is emitted when the digit '8' has been pressed. The \a event | - | ||||||||||||||||||||||||
1069 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1070 | - | |||||||||||||||||||||||||
1071 | The corresponding handler is \c onDigit8Pressed. | - | ||||||||||||||||||||||||
1072 | */ | - | ||||||||||||||||||||||||
1073 | - | |||||||||||||||||||||||||
1074 | /*! | - | ||||||||||||||||||||||||
1075 | \qmlsignal QtQuick::Keys::digit9Pressed(KeyEvent event) | - | ||||||||||||||||||||||||
1076 | - | |||||||||||||||||||||||||
1077 | This signal is emitted when the digit '9' has been pressed. The \a event | - | ||||||||||||||||||||||||
1078 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1079 | - | |||||||||||||||||||||||||
1080 | The corresponding handler is \c onDigit9Pressed. | - | ||||||||||||||||||||||||
1081 | */ | - | ||||||||||||||||||||||||
1082 | - | |||||||||||||||||||||||||
1083 | /*! | - | ||||||||||||||||||||||||
1084 | \qmlsignal QtQuick::Keys::leftPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1085 | - | |||||||||||||||||||||||||
1086 | This signal is emitted when the Left arrow has been pressed. The \a event | - | ||||||||||||||||||||||||
1087 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1088 | - | |||||||||||||||||||||||||
1089 | The corresponding handler is \c onLeftPressed. | - | ||||||||||||||||||||||||
1090 | */ | - | ||||||||||||||||||||||||
1091 | - | |||||||||||||||||||||||||
1092 | /*! | - | ||||||||||||||||||||||||
1093 | \qmlsignal QtQuick::Keys::rightPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1094 | - | |||||||||||||||||||||||||
1095 | This signal is emitted when the Right arrow has been pressed. The \a event | - | ||||||||||||||||||||||||
1096 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1097 | - | |||||||||||||||||||||||||
1098 | The corresponding handler is \c onRightPressed. | - | ||||||||||||||||||||||||
1099 | */ | - | ||||||||||||||||||||||||
1100 | - | |||||||||||||||||||||||||
1101 | /*! | - | ||||||||||||||||||||||||
1102 | \qmlsignal QtQuick::Keys::upPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1103 | - | |||||||||||||||||||||||||
1104 | This signal is emitted when the Up arrow has been pressed. The \a event | - | ||||||||||||||||||||||||
1105 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1106 | - | |||||||||||||||||||||||||
1107 | The corresponding handler is \c onUpPressed. | - | ||||||||||||||||||||||||
1108 | */ | - | ||||||||||||||||||||||||
1109 | - | |||||||||||||||||||||||||
1110 | /*! | - | ||||||||||||||||||||||||
1111 | \qmlsignal QtQuick::Keys::downPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1112 | - | |||||||||||||||||||||||||
1113 | This signal is emitted when the Down arrow has been pressed. The \a event | - | ||||||||||||||||||||||||
1114 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1115 | - | |||||||||||||||||||||||||
1116 | The corresponding handler is \c onDownPressed. | - | ||||||||||||||||||||||||
1117 | */ | - | ||||||||||||||||||||||||
1118 | - | |||||||||||||||||||||||||
1119 | /*! | - | ||||||||||||||||||||||||
1120 | \qmlsignal QtQuick::Keys::tabPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1121 | - | |||||||||||||||||||||||||
1122 | This signal is emitted when the Tab key has been pressed. The \a event | - | ||||||||||||||||||||||||
1123 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1124 | - | |||||||||||||||||||||||||
1125 | The corresponding handler is \c onTabPressed. | - | ||||||||||||||||||||||||
1126 | */ | - | ||||||||||||||||||||||||
1127 | - | |||||||||||||||||||||||||
1128 | /*! | - | ||||||||||||||||||||||||
1129 | \qmlsignal QtQuick::Keys::backtabPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1130 | - | |||||||||||||||||||||||||
1131 | This signal is emitted when the Shift+Tab key combination (Backtab) has | - | ||||||||||||||||||||||||
1132 | been pressed. The \a event parameter provides information about the event. | - | ||||||||||||||||||||||||
1133 | - | |||||||||||||||||||||||||
1134 | The corresponding handler is \c onBacktabPressed. | - | ||||||||||||||||||||||||
1135 | */ | - | ||||||||||||||||||||||||
1136 | - | |||||||||||||||||||||||||
1137 | /*! | - | ||||||||||||||||||||||||
1138 | \qmlsignal QtQuick::Keys::asteriskPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1139 | - | |||||||||||||||||||||||||
1140 | This signal is emitted when the Asterisk '*' has been pressed. The \a event | - | ||||||||||||||||||||||||
1141 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1142 | - | |||||||||||||||||||||||||
1143 | The corresponding handler is \c onAsteriskPressed. | - | ||||||||||||||||||||||||
1144 | */ | - | ||||||||||||||||||||||||
1145 | - | |||||||||||||||||||||||||
1146 | /*! | - | ||||||||||||||||||||||||
1147 | \qmlsignal QtQuick::Keys::escapePressed(KeyEvent event) | - | ||||||||||||||||||||||||
1148 | - | |||||||||||||||||||||||||
1149 | This signal is emitted when the Escape key has been pressed. The \a event | - | ||||||||||||||||||||||||
1150 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1151 | - | |||||||||||||||||||||||||
1152 | The corresponding handler is \c onEscapePressed. | - | ||||||||||||||||||||||||
1153 | */ | - | ||||||||||||||||||||||||
1154 | - | |||||||||||||||||||||||||
1155 | /*! | - | ||||||||||||||||||||||||
1156 | \qmlsignal QtQuick::Keys::returnPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1157 | - | |||||||||||||||||||||||||
1158 | This signal is emitted when the Return key has been pressed. The \a event | - | ||||||||||||||||||||||||
1159 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1160 | - | |||||||||||||||||||||||||
1161 | The corresponding handler is \c onReturnPressed. | - | ||||||||||||||||||||||||
1162 | */ | - | ||||||||||||||||||||||||
1163 | - | |||||||||||||||||||||||||
1164 | /*! | - | ||||||||||||||||||||||||
1165 | \qmlsignal QtQuick::Keys::enterPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1166 | - | |||||||||||||||||||||||||
1167 | This signal is emitted when the Enter key has been pressed. The \a event | - | ||||||||||||||||||||||||
1168 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1169 | - | |||||||||||||||||||||||||
1170 | The corresponding handler is \c onEnterPressed. | - | ||||||||||||||||||||||||
1171 | */ | - | ||||||||||||||||||||||||
1172 | - | |||||||||||||||||||||||||
1173 | /*! | - | ||||||||||||||||||||||||
1174 | \qmlsignal QtQuick::Keys::deletePressed(KeyEvent event) | - | ||||||||||||||||||||||||
1175 | - | |||||||||||||||||||||||||
1176 | This signal is emitted when the Delete key has been pressed. The \a event | - | ||||||||||||||||||||||||
1177 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1178 | - | |||||||||||||||||||||||||
1179 | The corresponding handler is \c onDeletePressed. | - | ||||||||||||||||||||||||
1180 | */ | - | ||||||||||||||||||||||||
1181 | - | |||||||||||||||||||||||||
1182 | /*! | - | ||||||||||||||||||||||||
1183 | \qmlsignal QtQuick::Keys::spacePressed(KeyEvent event) | - | ||||||||||||||||||||||||
1184 | - | |||||||||||||||||||||||||
1185 | This signal is emitted when the Space key has been pressed. The \a event | - | ||||||||||||||||||||||||
1186 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1187 | - | |||||||||||||||||||||||||
1188 | The corresponding handler is \c onSpacePressed. | - | ||||||||||||||||||||||||
1189 | */ | - | ||||||||||||||||||||||||
1190 | - | |||||||||||||||||||||||||
1191 | /*! | - | ||||||||||||||||||||||||
1192 | \qmlsignal QtQuick::Keys::backPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1193 | - | |||||||||||||||||||||||||
1194 | This signal is emitted when the Back key has been pressed. The \a event | - | ||||||||||||||||||||||||
1195 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1196 | - | |||||||||||||||||||||||||
1197 | The corresponding handler is \c onBackPressed. | - | ||||||||||||||||||||||||
1198 | */ | - | ||||||||||||||||||||||||
1199 | - | |||||||||||||||||||||||||
1200 | /*! | - | ||||||||||||||||||||||||
1201 | \qmlsignal QtQuick::Keys::cancelPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1202 | - | |||||||||||||||||||||||||
1203 | This signal is emitted when the Cancel key has been pressed. The \a event | - | ||||||||||||||||||||||||
1204 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1205 | - | |||||||||||||||||||||||||
1206 | The corresponding handler is \c onCancelPressed. | - | ||||||||||||||||||||||||
1207 | */ | - | ||||||||||||||||||||||||
1208 | - | |||||||||||||||||||||||||
1209 | /*! | - | ||||||||||||||||||||||||
1210 | \qmlsignal QtQuick::Keys::selectPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1211 | - | |||||||||||||||||||||||||
1212 | This signal is emitted when the Select key has been pressed. The \a event | - | ||||||||||||||||||||||||
1213 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1214 | - | |||||||||||||||||||||||||
1215 | The corresponding handler is \c onSelectPressed. | - | ||||||||||||||||||||||||
1216 | */ | - | ||||||||||||||||||||||||
1217 | - | |||||||||||||||||||||||||
1218 | /*! | - | ||||||||||||||||||||||||
1219 | \qmlsignal QtQuick::Keys::yesPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1220 | - | |||||||||||||||||||||||||
1221 | This signal is emitted when the Yes key has been pressed. The \a event | - | ||||||||||||||||||||||||
1222 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1223 | - | |||||||||||||||||||||||||
1224 | The corresponding handler is \c onYesPressed. | - | ||||||||||||||||||||||||
1225 | */ | - | ||||||||||||||||||||||||
1226 | - | |||||||||||||||||||||||||
1227 | /*! | - | ||||||||||||||||||||||||
1228 | \qmlsignal QtQuick::Keys::noPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1229 | - | |||||||||||||||||||||||||
1230 | This signal is emitted when the No key has been pressed. The \a event | - | ||||||||||||||||||||||||
1231 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1232 | - | |||||||||||||||||||||||||
1233 | The corresponding handler is \c onNoPressed. | - | ||||||||||||||||||||||||
1234 | */ | - | ||||||||||||||||||||||||
1235 | - | |||||||||||||||||||||||||
1236 | /*! | - | ||||||||||||||||||||||||
1237 | \qmlsignal QtQuick::Keys::context1Pressed(KeyEvent event) | - | ||||||||||||||||||||||||
1238 | - | |||||||||||||||||||||||||
1239 | This signal is emitted when the Context1 key has been pressed. The \a event | - | ||||||||||||||||||||||||
1240 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1241 | - | |||||||||||||||||||||||||
1242 | The corresponding handler is \c onContext1Pressed. | - | ||||||||||||||||||||||||
1243 | */ | - | ||||||||||||||||||||||||
1244 | - | |||||||||||||||||||||||||
1245 | /*! | - | ||||||||||||||||||||||||
1246 | \qmlsignal QtQuick::Keys::context2Pressed(KeyEvent event) | - | ||||||||||||||||||||||||
1247 | - | |||||||||||||||||||||||||
1248 | This signal is emitted when the Context2 key has been pressed. The \a event | - | ||||||||||||||||||||||||
1249 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1250 | - | |||||||||||||||||||||||||
1251 | The corresponding handler is \c onContext2Pressed. | - | ||||||||||||||||||||||||
1252 | */ | - | ||||||||||||||||||||||||
1253 | - | |||||||||||||||||||||||||
1254 | /*! | - | ||||||||||||||||||||||||
1255 | \qmlsignal QtQuick::Keys::context3Pressed(KeyEvent event) | - | ||||||||||||||||||||||||
1256 | - | |||||||||||||||||||||||||
1257 | This signal is emitted when the Context3 key has been pressed. The \a event | - | ||||||||||||||||||||||||
1258 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1259 | - | |||||||||||||||||||||||||
1260 | The corresponding handler is \c onContext3Pressed. | - | ||||||||||||||||||||||||
1261 | */ | - | ||||||||||||||||||||||||
1262 | - | |||||||||||||||||||||||||
1263 | /*! | - | ||||||||||||||||||||||||
1264 | \qmlsignal QtQuick::Keys::context4Pressed(KeyEvent event) | - | ||||||||||||||||||||||||
1265 | - | |||||||||||||||||||||||||
1266 | This signal is emitted when the Context4 key has been pressed. The \a event | - | ||||||||||||||||||||||||
1267 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1268 | - | |||||||||||||||||||||||||
1269 | The corresponding handler is \c onContext4Pressed. | - | ||||||||||||||||||||||||
1270 | */ | - | ||||||||||||||||||||||||
1271 | - | |||||||||||||||||||||||||
1272 | /*! | - | ||||||||||||||||||||||||
1273 | \qmlsignal QtQuick::Keys::callPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1274 | - | |||||||||||||||||||||||||
1275 | This signal is emitted when the Call key has been pressed. The \a event | - | ||||||||||||||||||||||||
1276 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1277 | - | |||||||||||||||||||||||||
1278 | The corresponding handler is \c onCallPressed. | - | ||||||||||||||||||||||||
1279 | */ | - | ||||||||||||||||||||||||
1280 | - | |||||||||||||||||||||||||
1281 | /*! | - | ||||||||||||||||||||||||
1282 | \qmlsignal QtQuick::Keys::hangupPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1283 | - | |||||||||||||||||||||||||
1284 | This signal is emitted when the Hangup key has been pressed. The \a event | - | ||||||||||||||||||||||||
1285 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1286 | - | |||||||||||||||||||||||||
1287 | The corresponding handler is \c onHangupPressed. | - | ||||||||||||||||||||||||
1288 | */ | - | ||||||||||||||||||||||||
1289 | - | |||||||||||||||||||||||||
1290 | /*! | - | ||||||||||||||||||||||||
1291 | \qmlsignal QtQuick::Keys::flipPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1292 | - | |||||||||||||||||||||||||
1293 | This signal is emitted when the Flip key has been pressed. The \a event | - | ||||||||||||||||||||||||
1294 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1295 | - | |||||||||||||||||||||||||
1296 | The corresponding handler is \c onFlipPressed. | - | ||||||||||||||||||||||||
1297 | */ | - | ||||||||||||||||||||||||
1298 | - | |||||||||||||||||||||||||
1299 | /*! | - | ||||||||||||||||||||||||
1300 | \qmlsignal QtQuick::Keys::menuPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1301 | - | |||||||||||||||||||||||||
1302 | This signal is emitted when the Menu key has been pressed. The \a event | - | ||||||||||||||||||||||||
1303 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1304 | - | |||||||||||||||||||||||||
1305 | The corresponding handler is \c onMenuPressed. | - | ||||||||||||||||||||||||
1306 | */ | - | ||||||||||||||||||||||||
1307 | - | |||||||||||||||||||||||||
1308 | /*! | - | ||||||||||||||||||||||||
1309 | \qmlsignal QtQuick::Keys::volumeUpPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1310 | - | |||||||||||||||||||||||||
1311 | This signal is emitted when the VolumeUp key has been pressed. The \a event | - | ||||||||||||||||||||||||
1312 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1313 | - | |||||||||||||||||||||||||
1314 | The corresponding handler is \c onVolumeUpPressed. | - | ||||||||||||||||||||||||
1315 | */ | - | ||||||||||||||||||||||||
1316 | - | |||||||||||||||||||||||||
1317 | /*! | - | ||||||||||||||||||||||||
1318 | \qmlsignal QtQuick::Keys::volumeDownPressed(KeyEvent event) | - | ||||||||||||||||||||||||
1319 | - | |||||||||||||||||||||||||
1320 | This signal is emitted when the VolumeDown key has been pressed. The \a event | - | ||||||||||||||||||||||||
1321 | parameter provides information about the event. | - | ||||||||||||||||||||||||
1322 | - | |||||||||||||||||||||||||
1323 | The corresponding handler is \c onVolumeDownPressed. | - | ||||||||||||||||||||||||
1324 | */ | - | ||||||||||||||||||||||||
1325 | - | |||||||||||||||||||||||||
1326 | QQuickKeysAttached::QQuickKeysAttached(QObject *parent) | - | ||||||||||||||||||||||||
1327 | : QObject(*(new QQuickKeysAttachedPrivate), parent), | - | ||||||||||||||||||||||||
1328 | QQuickItemKeyFilter(qmlobject_cast<QQuickItem*>(parent)) | - | ||||||||||||||||||||||||
1329 | { | - | ||||||||||||||||||||||||
1330 | Q_D(QQuickKeysAttached); | - | ||||||||||||||||||||||||
1331 | m_processPost = false; | - | ||||||||||||||||||||||||
1332 | d->item = qmlobject_cast<QQuickItem*>(parent); | - | ||||||||||||||||||||||||
1333 | if (d->item != parent)
| 0-320 | ||||||||||||||||||||||||
1334 | qWarning() << "Could not attach Keys property to: " << parent << " is not an Item"; never executed: QMessageLogger(__FILE__, 1334, __PRETTY_FUNCTION__).warning() << "Could not attach Keys property to: " << parent << " is not an Item"; | 0 | ||||||||||||||||||||||||
1335 | } executed 320 times by 8 tests: end of block Executed by:
| 320 | ||||||||||||||||||||||||
1336 | - | |||||||||||||||||||||||||
1337 | QQuickKeysAttached::~QQuickKeysAttached() | - | ||||||||||||||||||||||||
1338 | { | - | ||||||||||||||||||||||||
1339 | } | - | ||||||||||||||||||||||||
1340 | - | |||||||||||||||||||||||||
1341 | QQuickKeysAttached::Priority QQuickKeysAttached::priority() const | - | ||||||||||||||||||||||||
1342 | { | - | ||||||||||||||||||||||||
1343 | return m_processPost ? AfterItem : BeforeItem; executed 4 times by 1 test: return m_processPost ? AfterItem : BeforeItem; Executed by:
| 4 | ||||||||||||||||||||||||
1344 | } | - | ||||||||||||||||||||||||
1345 | - | |||||||||||||||||||||||||
1346 | void QQuickKeysAttached::setPriority(Priority order) | - | ||||||||||||||||||||||||
1347 | { | - | ||||||||||||||||||||||||
1348 | bool processPost = order == AfterItem; | - | ||||||||||||||||||||||||
1349 | if (processPost != m_processPost) {
| 2 | ||||||||||||||||||||||||
1350 | m_processPost = processPost; | - | ||||||||||||||||||||||||
1351 | emit priorityChanged(); | - | ||||||||||||||||||||||||
1352 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1353 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
1354 | - | |||||||||||||||||||||||||
1355 | void QQuickKeysAttached::componentComplete() | - | ||||||||||||||||||||||||
1356 | { | - | ||||||||||||||||||||||||
1357 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
1358 | Q_D(QQuickKeysAttached); | - | ||||||||||||||||||||||||
1359 | if (d->item) {
| 0-320 | ||||||||||||||||||||||||
1360 | for (int ii = 0; ii < d->targets.count(); ++ii) {
| 10-318 | ||||||||||||||||||||||||
1361 | QQuickItem *targetItem = d->targets.at(ii); | - | ||||||||||||||||||||||||
1362 | if (targetItem && (targetItem->flags() & QQuickItem::ItemAcceptsInputMethod)) {
| 0-10 | ||||||||||||||||||||||||
1363 | d->item->setFlag(QQuickItem::ItemAcceptsInputMethod); | - | ||||||||||||||||||||||||
1364 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
1365 | } | - | ||||||||||||||||||||||||
1366 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1367 | } executed 320 times by 8 tests: end of block Executed by:
| 320 | ||||||||||||||||||||||||
1368 | #endif | - | ||||||||||||||||||||||||
1369 | } executed 320 times by 8 tests: end of block Executed by:
| 320 | ||||||||||||||||||||||||
1370 | - | |||||||||||||||||||||||||
1371 | void QQuickKeysAttached::keyPressed(QKeyEvent *event, bool post) | - | ||||||||||||||||||||||||
1372 | { | - | ||||||||||||||||||||||||
1373 | Q_D(QQuickKeysAttached); | - | ||||||||||||||||||||||||
1374 | if (post != m_processPost || !d->enabled || d->inPress) {
| 0-96 | ||||||||||||||||||||||||
1375 | event->ignore(); | - | ||||||||||||||||||||||||
1376 | QQuickItemKeyFilter::keyPressed(event, post); | - | ||||||||||||||||||||||||
1377 | return; executed 60 times by 2 tests: return; Executed by:
| 60 | ||||||||||||||||||||||||
1378 | } | - | ||||||||||||||||||||||||
1379 | - | |||||||||||||||||||||||||
1380 | // first process forwards | - | ||||||||||||||||||||||||
1381 | if (d->item && d->item->window()) {
| 0-94 | ||||||||||||||||||||||||
1382 | d->inPress = true; | - | ||||||||||||||||||||||||
1383 | for (int ii = 0; ii < d->targets.count(); ++ii) {
| 34-88 | ||||||||||||||||||||||||
1384 | QQuickItem *i = d->targets.at(ii); | - | ||||||||||||||||||||||||
1385 | if (i && i->isVisible()) {
| 0-34 | ||||||||||||||||||||||||
1386 | event->accept(); | - | ||||||||||||||||||||||||
1387 | QCoreApplication::sendEvent(i, event); | - | ||||||||||||||||||||||||
1388 | if (event->isAccepted()) {
| 6-24 | ||||||||||||||||||||||||
1389 | d->inPress = false; | - | ||||||||||||||||||||||||
1390 | return; executed 6 times by 1 test: return; Executed by:
| 6 | ||||||||||||||||||||||||
1391 | } | - | ||||||||||||||||||||||||
1392 | } executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||||||||||||||||||||
1393 | } executed 28 times by 1 test: end of block Executed by:
| 28 | ||||||||||||||||||||||||
1394 | d->inPress = false; | - | ||||||||||||||||||||||||
1395 | } executed 88 times by 3 tests: end of block Executed by:
| 88 | ||||||||||||||||||||||||
1396 | - | |||||||||||||||||||||||||
1397 | QQuickKeyEvent &ke = d->theKeyEvent; | - | ||||||||||||||||||||||||
1398 | ke.reset(*event); | - | ||||||||||||||||||||||||
1399 | QByteArray keySignal = keyToSignal(event->key()); | - | ||||||||||||||||||||||||
1400 | if (!keySignal.isEmpty()) {
| 34-54 | ||||||||||||||||||||||||
1401 | keySignal += "(QQuickKeyEvent*)"; | - | ||||||||||||||||||||||||
1402 | if (isConnected(keySignal)) {
| 20-34 | ||||||||||||||||||||||||
1403 | // If we specifically handle a key then default to accepted | - | ||||||||||||||||||||||||
1404 | ke.setAccepted(true); | - | ||||||||||||||||||||||||
1405 | int idx = QQuickKeysAttached::staticMetaObject.indexOfSignal(keySignal); | - | ||||||||||||||||||||||||
1406 | metaObject()->method(idx).invoke(this, Qt::DirectConnection, Q_ARG(QQuickKeyEvent*, &ke)); | - | ||||||||||||||||||||||||
1407 | } executed 20 times by 3 tests: end of block Executed by:
| 20 | ||||||||||||||||||||||||
1408 | } executed 54 times by 3 tests: end of block Executed by:
| 54 | ||||||||||||||||||||||||
1409 | if (!ke.isAccepted())
| 18-70 | ||||||||||||||||||||||||
1410 | emit pressed(&ke); executed 70 times by 2 tests: pressed(&ke); Executed by:
| 70 | ||||||||||||||||||||||||
1411 | event->setAccepted(ke.isAccepted()); | - | ||||||||||||||||||||||||
1412 | - | |||||||||||||||||||||||||
1413 | if (!event->isAccepted()) QQuickItemKeyFilter::keyPressed(event, post); executed 66 times by 2 tests: QQuickItemKeyFilter::keyPressed(event, post); Executed by:
| 22-66 | ||||||||||||||||||||||||
1414 | } executed 88 times by 3 tests: end of block Executed by:
| 88 | ||||||||||||||||||||||||
1415 | - | |||||||||||||||||||||||||
1416 | void QQuickKeysAttached::keyReleased(QKeyEvent *event, bool post) | - | ||||||||||||||||||||||||
1417 | { | - | ||||||||||||||||||||||||
1418 | Q_D(QQuickKeysAttached); | - | ||||||||||||||||||||||||
1419 | if (post != m_processPost || !d->enabled || d->inRelease) {
| 0-66 | ||||||||||||||||||||||||
1420 | event->ignore(); | - | ||||||||||||||||||||||||
1421 | QQuickItemKeyFilter::keyReleased(event, post); | - | ||||||||||||||||||||||||
1422 | return; executed 44 times by 2 tests: return; Executed by:
| 44 | ||||||||||||||||||||||||
1423 | } | - | ||||||||||||||||||||||||
1424 | - | |||||||||||||||||||||||||
1425 | if (d->item && d->item->window()) {
| 0-66 | ||||||||||||||||||||||||
1426 | d->inRelease = true; | - | ||||||||||||||||||||||||
1427 | for (int ii = 0; ii < d->targets.count(); ++ii) {
| 18-60 | ||||||||||||||||||||||||
1428 | QQuickItem *i = d->targets.at(ii); | - | ||||||||||||||||||||||||
1429 | if (i && i->isVisible()) {
| 0-18 | ||||||||||||||||||||||||
1430 | event->accept(); | - | ||||||||||||||||||||||||
1431 | QCoreApplication::sendEvent(i, event); | - | ||||||||||||||||||||||||
1432 | if (event->isAccepted()) {
| 6-12 | ||||||||||||||||||||||||
1433 | d->inRelease = false; | - | ||||||||||||||||||||||||
1434 | return; executed 6 times by 1 test: return; Executed by:
| 6 | ||||||||||||||||||||||||
1435 | } | - | ||||||||||||||||||||||||
1436 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
1437 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
1438 | d->inRelease = false; | - | ||||||||||||||||||||||||
1439 | } executed 60 times by 2 tests: end of block Executed by:
| 60 | ||||||||||||||||||||||||
1440 | - | |||||||||||||||||||||||||
1441 | QQuickKeyEvent &ke = d->theKeyEvent; | - | ||||||||||||||||||||||||
1442 | ke.reset(*event); | - | ||||||||||||||||||||||||
1443 | emit released(&ke); | - | ||||||||||||||||||||||||
1444 | event->setAccepted(ke.isAccepted()); | - | ||||||||||||||||||||||||
1445 | - | |||||||||||||||||||||||||
1446 | if (!event->isAccepted()) QQuickItemKeyFilter::keyReleased(event, post); executed 54 times by 2 tests: QQuickItemKeyFilter::keyReleased(event, post); Executed by:
| 6-54 | ||||||||||||||||||||||||
1447 | } executed 60 times by 2 tests: end of block Executed by:
| 60 | ||||||||||||||||||||||||
1448 | - | |||||||||||||||||||||||||
1449 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
1450 | void QQuickKeysAttached::inputMethodEvent(QInputMethodEvent *event, bool post) | - | ||||||||||||||||||||||||
1451 | { | - | ||||||||||||||||||||||||
1452 | Q_D(QQuickKeysAttached); | - | ||||||||||||||||||||||||
1453 | if (post == m_processPost && d->item && !d->inIM && d->item->window()) {
| 0 | ||||||||||||||||||||||||
1454 | d->inIM = true; | - | ||||||||||||||||||||||||
1455 | for (int ii = 0; ii < d->targets.count(); ++ii) {
| 0 | ||||||||||||||||||||||||
1456 | QQuickItem *targetItem = d->targets.at(ii); | - | ||||||||||||||||||||||||
1457 | if (targetItem && targetItem->isVisible() && (targetItem->flags() & QQuickItem::ItemAcceptsInputMethod)) {
| 0 | ||||||||||||||||||||||||
1458 | QCoreApplication::sendEvent(targetItem, event); | - | ||||||||||||||||||||||||
1459 | if (event->isAccepted()) {
| 0 | ||||||||||||||||||||||||
1460 | d->imeItem = targetItem; | - | ||||||||||||||||||||||||
1461 | d->inIM = false; | - | ||||||||||||||||||||||||
1462 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1463 | } | - | ||||||||||||||||||||||||
1464 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1465 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1466 | d->inIM = false; | - | ||||||||||||||||||||||||
1467 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1468 | QQuickItemKeyFilter::inputMethodEvent(event, post); | - | ||||||||||||||||||||||||
1469 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1470 | - | |||||||||||||||||||||||||
1471 | QVariant QQuickKeysAttached::inputMethodQuery(Qt::InputMethodQuery query) const | - | ||||||||||||||||||||||||
1472 | { | - | ||||||||||||||||||||||||
1473 | Q_D(const QQuickKeysAttached); | - | ||||||||||||||||||||||||
1474 | if (d->item) {
| 0-40 | ||||||||||||||||||||||||
1475 | for (int ii = 0; ii < d->targets.count(); ++ii) {
| 4-40 | ||||||||||||||||||||||||
1476 | QQuickItem *i = d->targets.at(ii); | - | ||||||||||||||||||||||||
1477 | if (i && i->isVisible() && (i->flags() & QQuickItem::ItemAcceptsInputMethod) && i == d->imeItem) {
| 0-4 | ||||||||||||||||||||||||
1478 | //### how robust is i == d->imeItem check? | - | ||||||||||||||||||||||||
1479 | QVariant v = i->inputMethodQuery(query); | - | ||||||||||||||||||||||||
1480 | if (v.userType() == QVariant::RectF)
| 0 | ||||||||||||||||||||||||
1481 | v = d->item->mapRectFromItem(i, v.toRectF()); //### cost? never executed: v = d->item->mapRectFromItem(i, v.toRectF()); | 0 | ||||||||||||||||||||||||
1482 | return v; never executed: return v; | 0 | ||||||||||||||||||||||||
1483 | } | - | ||||||||||||||||||||||||
1484 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
1485 | } executed 40 times by 3 tests: end of block Executed by:
| 40 | ||||||||||||||||||||||||
1486 | return QQuickItemKeyFilter::inputMethodQuery(query); executed 40 times by 3 tests: return QQuickItemKeyFilter::inputMethodQuery(query); Executed by:
| 40 | ||||||||||||||||||||||||
1487 | } | - | ||||||||||||||||||||||||
1488 | #endif // im | - | ||||||||||||||||||||||||
1489 | - | |||||||||||||||||||||||||
1490 | void QQuickKeysAttached::shortcutOverride(QKeyEvent *event) | - | ||||||||||||||||||||||||
1491 | { | - | ||||||||||||||||||||||||
1492 | Q_D(QQuickKeysAttached); | - | ||||||||||||||||||||||||
1493 | QQuickKeyEvent &keyEvent = d->theKeyEvent; | - | ||||||||||||||||||||||||
1494 | keyEvent.reset(*event); | - | ||||||||||||||||||||||||
1495 | emit shortcutOverride(&keyEvent); | - | ||||||||||||||||||||||||
1496 | - | |||||||||||||||||||||||||
1497 | event->setAccepted(keyEvent.isAccepted()); | - | ||||||||||||||||||||||||
1498 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1499 | - | |||||||||||||||||||||||||
1500 | QQuickKeysAttached *QQuickKeysAttached::qmlAttachedProperties(QObject *obj) | - | ||||||||||||||||||||||||
1501 | { | - | ||||||||||||||||||||||||
1502 | return new QQuickKeysAttached(obj); executed 320 times by 8 tests: return new QQuickKeysAttached(obj); Executed by:
| 320 | ||||||||||||||||||||||||
1503 | } | - | ||||||||||||||||||||||||
1504 | - | |||||||||||||||||||||||||
1505 | /*! | - | ||||||||||||||||||||||||
1506 | \qmltype LayoutMirroring | - | ||||||||||||||||||||||||
1507 | \instantiates QQuickLayoutMirroringAttached | - | ||||||||||||||||||||||||
1508 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
1509 | \ingroup qtquick-positioners | - | ||||||||||||||||||||||||
1510 | \ingroup qml-utility-elements | - | ||||||||||||||||||||||||
1511 | \brief Property used to mirror layout behavior. | - | ||||||||||||||||||||||||
1512 | - | |||||||||||||||||||||||||
1513 | The LayoutMirroring attached property is used to horizontally mirror \l {anchor-layout}{Item anchors}, | - | ||||||||||||||||||||||||
1514 | \l{Item Positioners}{positioner} types (such as \l Row and \l Grid) | - | ||||||||||||||||||||||||
1515 | and views (such as \l GridView and horizontal \l ListView). Mirroring is a visual change: left | - | ||||||||||||||||||||||||
1516 | anchors become right anchors, and positioner types like \l Grid and \l Row reverse the | - | ||||||||||||||||||||||||
1517 | horizontal layout of child items. | - | ||||||||||||||||||||||||
1518 | - | |||||||||||||||||||||||||
1519 | Mirroring is enabled for an item by setting the \l enabled property to true. By default, this | - | ||||||||||||||||||||||||
1520 | only affects the item itself; setting the \l childrenInherit property to true propagates the mirroring | - | ||||||||||||||||||||||||
1521 | behavior to all child items as well. If the \c LayoutMirroring attached property has not been defined | - | ||||||||||||||||||||||||
1522 | for an item, mirroring is not enabled. | - | ||||||||||||||||||||||||
1523 | - | |||||||||||||||||||||||||
1524 | \note Since Qt 5.8, \c LayoutMirroring can be attached to a \l Window. In practice, it is the same as | - | ||||||||||||||||||||||||
1525 | attaching \c LayoutMirroring to the window's \c contentItem. | - | ||||||||||||||||||||||||
1526 | - | |||||||||||||||||||||||||
1527 | The following example shows mirroring in action. The \l Row below is specified as being anchored | - | ||||||||||||||||||||||||
1528 | to the left of its parent. However, since mirroring has been enabled, the anchor is horizontally | - | ||||||||||||||||||||||||
1529 | reversed and it is now anchored to the right. Also, since items in a \l Row are positioned | - | ||||||||||||||||||||||||
1530 | from left to right by default, they are now positioned from right to left instead, as demonstrated | - | ||||||||||||||||||||||||
1531 | by the numbering and opacity of the items: | - | ||||||||||||||||||||||||
1532 | - | |||||||||||||||||||||||||
1533 | \snippet qml/layoutmirroring.qml 0 | - | ||||||||||||||||||||||||
1534 | - | |||||||||||||||||||||||||
1535 | \image layoutmirroring.png | - | ||||||||||||||||||||||||
1536 | - | |||||||||||||||||||||||||
1537 | Layout mirroring is useful when it is necessary to support both left-to-right and right-to-left | - | ||||||||||||||||||||||||
1538 | layout versions of an application to target different language areas. The \l childrenInherit | - | ||||||||||||||||||||||||
1539 | property allows layout mirroring to be applied without manually setting layout configurations | - | ||||||||||||||||||||||||
1540 | for every item in an application. Keep in mind, however, that mirroring does not affect any | - | ||||||||||||||||||||||||
1541 | positioning that is defined by the \l Item \l {Item::}{x} coordinate value, so even with | - | ||||||||||||||||||||||||
1542 | mirroring enabled, it will often be necessary to apply some layout fixes to support the | - | ||||||||||||||||||||||||
1543 | desired layout direction. Also, it may be necessary to disable the mirroring of individual | - | ||||||||||||||||||||||||
1544 | child items (by setting \l {enabled}{LayoutMirroring.enabled} to false for such items) if | - | ||||||||||||||||||||||||
1545 | mirroring is not the desired behavior, or if the child item already implements mirroring in | - | ||||||||||||||||||||||||
1546 | some custom way. | - | ||||||||||||||||||||||||
1547 | - | |||||||||||||||||||||||||
1548 | To set the layout direction based on the \l {Default Layout Direction}{default layout direction} | - | ||||||||||||||||||||||||
1549 | of the application, use the following code: | - | ||||||||||||||||||||||||
1550 | - | |||||||||||||||||||||||||
1551 | \code | - | ||||||||||||||||||||||||
1552 | LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft | - | ||||||||||||||||||||||||
1553 | \endcode | - | ||||||||||||||||||||||||
1554 | - | |||||||||||||||||||||||||
1555 | See \l {Right-to-left User Interfaces} for further details on using \c LayoutMirroring and | - | ||||||||||||||||||||||||
1556 | other related features to implement right-to-left support for an application. | - | ||||||||||||||||||||||||
1557 | */ | - | ||||||||||||||||||||||||
1558 | - | |||||||||||||||||||||||||
1559 | /*! | - | ||||||||||||||||||||||||
1560 | \qmlproperty bool QtQuick::LayoutMirroring::enabled | - | ||||||||||||||||||||||||
1561 | - | |||||||||||||||||||||||||
1562 | This property holds whether the item's layout is mirrored horizontally. Setting this to true | - | ||||||||||||||||||||||||
1563 | horizontally reverses \l {anchor-layout}{anchor} settings such that left anchors become right, | - | ||||||||||||||||||||||||
1564 | and right anchors become left. For \l{Item Positioners}{positioner} types | - | ||||||||||||||||||||||||
1565 | (such as \l Row and \l Grid) and view types (such as \l {GridView}{GridView} and \l {ListView}{ListView}) | - | ||||||||||||||||||||||||
1566 | this also mirrors the horizontal layout direction of the item. | - | ||||||||||||||||||||||||
1567 | - | |||||||||||||||||||||||||
1568 | The default value is false. | - | ||||||||||||||||||||||||
1569 | */ | - | ||||||||||||||||||||||||
1570 | - | |||||||||||||||||||||||||
1571 | /*! | - | ||||||||||||||||||||||||
1572 | \qmlproperty bool QtQuick::LayoutMirroring::childrenInherit | - | ||||||||||||||||||||||||
1573 | - | |||||||||||||||||||||||||
1574 | This property holds whether the \l {enabled}{LayoutMirroring.enabled} value for this item | - | ||||||||||||||||||||||||
1575 | is inherited by its children. | - | ||||||||||||||||||||||||
1576 | - | |||||||||||||||||||||||||
1577 | The default value is false. | - | ||||||||||||||||||||||||
1578 | */ | - | ||||||||||||||||||||||||
1579 | - | |||||||||||||||||||||||||
1580 | - | |||||||||||||||||||||||||
1581 | QQuickLayoutMirroringAttached::QQuickLayoutMirroringAttached(QObject *parent) : QObject(parent), itemPrivate(nullptr) | - | ||||||||||||||||||||||||
1582 | { | - | ||||||||||||||||||||||||
1583 | if (QQuickItem *item = qobject_cast<QQuickItem *>(parent))
| 4-142 | ||||||||||||||||||||||||
1584 | itemPrivate = QQuickItemPrivate::get(item); executed 142 times by 5 tests: itemPrivate = QQuickItemPrivate::get(item); Executed by:
| 142 | ||||||||||||||||||||||||
1585 | else if (QQuickWindow *window = qobject_cast<QQuickWindow *>(parent))
| 2 | ||||||||||||||||||||||||
1586 | itemPrivate = QQuickItemPrivate::get(window->contentItem()); executed 2 times by 1 test: itemPrivate = QQuickItemPrivate::get(window->contentItem()); Executed by:
| 2 | ||||||||||||||||||||||||
1587 | - | |||||||||||||||||||||||||
1588 | if (itemPrivate)
| 2-144 | ||||||||||||||||||||||||
1589 | itemPrivate->extra.value().layoutDirectionAttached = this; executed 144 times by 5 tests: itemPrivate->extra.value().layoutDirectionAttached = this; Executed by:
| 144 | ||||||||||||||||||||||||
1590 | else | - | ||||||||||||||||||||||||
1591 | qmlWarning(parent) << tr("LayoutDirection attached property only works with Items and Windows"); executed 2 times by 1 test: qmlWarning(parent) << tr("LayoutDirection attached property only works with Items and Windows"); Executed by:
| 2 | ||||||||||||||||||||||||
1592 | } | - | ||||||||||||||||||||||||
1593 | - | |||||||||||||||||||||||||
1594 | QQuickLayoutMirroringAttached * QQuickLayoutMirroringAttached::qmlAttachedProperties(QObject *object) | - | ||||||||||||||||||||||||
1595 | { | - | ||||||||||||||||||||||||
1596 | return new QQuickLayoutMirroringAttached(object); executed 146 times by 5 tests: return new QQuickLayoutMirroringAttached(object); Executed by:
| 146 | ||||||||||||||||||||||||
1597 | } | - | ||||||||||||||||||||||||
1598 | - | |||||||||||||||||||||||||
1599 | bool QQuickLayoutMirroringAttached::enabled() const | - | ||||||||||||||||||||||||
1600 | { | - | ||||||||||||||||||||||||
1601 | return itemPrivate ? itemPrivate->effectiveLayoutMirror : false; executed 4 times by 1 test: return itemPrivate ? itemPrivate->effectiveLayoutMirror : false; Executed by:
| 4 | ||||||||||||||||||||||||
1602 | } | - | ||||||||||||||||||||||||
1603 | - | |||||||||||||||||||||||||
1604 | void QQuickLayoutMirroringAttached::setEnabled(bool enabled) | - | ||||||||||||||||||||||||
1605 | { | - | ||||||||||||||||||||||||
1606 | if (!itemPrivate)
| 2-148 | ||||||||||||||||||||||||
1607 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
1608 | - | |||||||||||||||||||||||||
1609 | itemPrivate->isMirrorImplicit = false; | - | ||||||||||||||||||||||||
1610 | if (enabled != itemPrivate->effectiveLayoutMirror) {
| 42-106 | ||||||||||||||||||||||||
1611 | itemPrivate->setLayoutMirror(enabled); | - | ||||||||||||||||||||||||
1612 | if (itemPrivate->inheritMirrorFromItem)
| 8-34 | ||||||||||||||||||||||||
1613 | itemPrivate->resolveLayoutMirror(); executed 8 times by 2 tests: itemPrivate->resolveLayoutMirror(); Executed by:
| 8 | ||||||||||||||||||||||||
1614 | } executed 42 times by 5 tests: end of block Executed by:
| 42 | ||||||||||||||||||||||||
1615 | } executed 148 times by 5 tests: end of block Executed by:
| 148 | ||||||||||||||||||||||||
1616 | - | |||||||||||||||||||||||||
1617 | void QQuickLayoutMirroringAttached::resetEnabled() | - | ||||||||||||||||||||||||
1618 | { | - | ||||||||||||||||||||||||
1619 | if (itemPrivate && !itemPrivate->isMirrorImplicit) {
| 0 | ||||||||||||||||||||||||
1620 | itemPrivate->isMirrorImplicit = true; | - | ||||||||||||||||||||||||
1621 | itemPrivate->resolveLayoutMirror(); | - | ||||||||||||||||||||||||
1622 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1623 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1624 | - | |||||||||||||||||||||||||
1625 | bool QQuickLayoutMirroringAttached::childrenInherit() const | - | ||||||||||||||||||||||||
1626 | { | - | ||||||||||||||||||||||||
1627 | return itemPrivate ? itemPrivate->inheritMirrorFromItem : false; never executed: return itemPrivate ? itemPrivate->inheritMirrorFromItem : false; | 0 | ||||||||||||||||||||||||
1628 | } | - | ||||||||||||||||||||||||
1629 | - | |||||||||||||||||||||||||
1630 | void QQuickLayoutMirroringAttached::setChildrenInherit(bool childrenInherit) { | - | ||||||||||||||||||||||||
1631 | if (itemPrivate && childrenInherit != itemPrivate->inheritMirrorFromItem) {
| 2-32 | ||||||||||||||||||||||||
1632 | itemPrivate->inheritMirrorFromItem = childrenInherit; | - | ||||||||||||||||||||||||
1633 | itemPrivate->resolveLayoutMirror(); | - | ||||||||||||||||||||||||
1634 | childrenInheritChanged(); | - | ||||||||||||||||||||||||
1635 | } executed 30 times by 3 tests: end of block Executed by:
| 30 | ||||||||||||||||||||||||
1636 | } executed 34 times by 3 tests: end of block Executed by:
| 34 | ||||||||||||||||||||||||
1637 | - | |||||||||||||||||||||||||
1638 | void QQuickItemPrivate::resolveLayoutMirror() | - | ||||||||||||||||||||||||
1639 | { | - | ||||||||||||||||||||||||
1640 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
1641 | if (QQuickItem *parentItem = q->parentItem()) {
| 24-408974 | ||||||||||||||||||||||||
1642 | QQuickItemPrivate *parentPrivate = QQuickItemPrivate::get(parentItem); | - | ||||||||||||||||||||||||
1643 | setImplicitLayoutMirror(parentPrivate->inheritedLayoutMirror, parentPrivate->inheritMirrorFromParent); | - | ||||||||||||||||||||||||
1644 | } else { executed 408974 times by 106 tests: end of block Executed by:
| 408974 | ||||||||||||||||||||||||
1645 | setImplicitLayoutMirror(isMirrorImplicit ? false : effectiveLayoutMirror, inheritMirrorFromItem); | - | ||||||||||||||||||||||||
1646 | } executed 24 times by 2 tests: end of block Executed by:
| 24 | ||||||||||||||||||||||||
1647 | } | - | ||||||||||||||||||||||||
1648 | - | |||||||||||||||||||||||||
1649 | void QQuickItemPrivate::setImplicitLayoutMirror(bool mirror, bool inherit) | - | ||||||||||||||||||||||||
1650 | { | - | ||||||||||||||||||||||||
1651 | inherit = inherit || inheritMirrorFromItem;
| 28-409022 | ||||||||||||||||||||||||
1652 | if (!isMirrorImplicit && inheritMirrorFromItem)
| 22-409626 | ||||||||||||||||||||||||
1653 | mirror = effectiveLayoutMirror; executed 34 times by 3 tests: mirror = effectiveLayoutMirror; Executed by:
| 34 | ||||||||||||||||||||||||
1654 | if (mirror == inheritedLayoutMirror && inherit == inheritMirrorFromParent)
| 176-409506 | ||||||||||||||||||||||||
1655 | return; executed 408994 times by 106 tests: return; Executed by:
| 408994 | ||||||||||||||||||||||||
1656 | - | |||||||||||||||||||||||||
1657 | inheritMirrorFromParent = inherit; | - | ||||||||||||||||||||||||
1658 | inheritedLayoutMirror = inheritMirrorFromParent ? mirror : false;
| 12-676 | ||||||||||||||||||||||||
1659 | - | |||||||||||||||||||||||||
1660 | if (isMirrorImplicit)
| 38-650 | ||||||||||||||||||||||||
1661 | setLayoutMirror(inherit ? inheritedLayoutMirror : false); executed 650 times by 3 tests: setLayoutMirror(inherit ? inheritedLayoutMirror : false); Executed by:
| 650 | ||||||||||||||||||||||||
1662 | for (int i = 0; i < childItems.count(); ++i) {
| 464-688 | ||||||||||||||||||||||||
1663 | if (QQuickItem *child = qmlobject_cast<QQuickItem *>(childItems.at(i))) {
| 0-464 | ||||||||||||||||||||||||
1664 | QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(child); | - | ||||||||||||||||||||||||
1665 | childPrivate->setImplicitLayoutMirror(inheritedLayoutMirror, inheritMirrorFromParent); | - | ||||||||||||||||||||||||
1666 | } executed 464 times by 3 tests: end of block Executed by:
| 464 | ||||||||||||||||||||||||
1667 | } executed 464 times by 3 tests: end of block Executed by:
| 464 | ||||||||||||||||||||||||
1668 | } executed 688 times by 3 tests: end of block Executed by:
| 688 | ||||||||||||||||||||||||
1669 | - | |||||||||||||||||||||||||
1670 | void QQuickItemPrivate::setLayoutMirror(bool mirror) | - | ||||||||||||||||||||||||
1671 | { | - | ||||||||||||||||||||||||
1672 | if (mirror != effectiveLayoutMirror) {
| 276-512 | ||||||||||||||||||||||||
1673 | effectiveLayoutMirror = mirror; | - | ||||||||||||||||||||||||
1674 | if (_anchors) {
| 116-160 | ||||||||||||||||||||||||
1675 | QQuickAnchorsPrivate *anchor_d = QQuickAnchorsPrivate::get(_anchors); | - | ||||||||||||||||||||||||
1676 | anchor_d->fillChanged(); | - | ||||||||||||||||||||||||
1677 | anchor_d->centerInChanged(); | - | ||||||||||||||||||||||||
1678 | anchor_d->updateHorizontalAnchors(); | - | ||||||||||||||||||||||||
1679 | } executed 116 times by 9 tests: end of block Executed by:
| 116 | ||||||||||||||||||||||||
1680 | mirrorChange(); | - | ||||||||||||||||||||||||
1681 | if (extra.isAllocated() && extra->layoutDirectionAttached) {
| 42-174 | ||||||||||||||||||||||||
1682 | emit extra->layoutDirectionAttached->enabledChanged(); | - | ||||||||||||||||||||||||
1683 | } executed 42 times by 5 tests: end of block Executed by:
| 42 | ||||||||||||||||||||||||
1684 | } executed 276 times by 11 tests: end of block Executed by:
| 276 | ||||||||||||||||||||||||
1685 | } executed 788 times by 11 tests: end of block Executed by:
| 788 | ||||||||||||||||||||||||
1686 | - | |||||||||||||||||||||||||
1687 | /*! | - | ||||||||||||||||||||||||
1688 | \qmltype EnterKey | - | ||||||||||||||||||||||||
1689 | \instantiates QQuickEnterKeyAttached | - | ||||||||||||||||||||||||
1690 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
1691 | \ingroup qtquick-input | - | ||||||||||||||||||||||||
1692 | \since 5.6 | - | ||||||||||||||||||||||||
1693 | \brief Provides a property to manipulate the appearance of Enter key on | - | ||||||||||||||||||||||||
1694 | an on-screen keyboard. | - | ||||||||||||||||||||||||
1695 | - | |||||||||||||||||||||||||
1696 | The EnterKey attached property is used to manipulate the appearance and | - | ||||||||||||||||||||||||
1697 | behavior of the Enter key on an on-screen keyboard. | - | ||||||||||||||||||||||||
1698 | */ | - | ||||||||||||||||||||||||
1699 | - | |||||||||||||||||||||||||
1700 | /*! | - | ||||||||||||||||||||||||
1701 | \qmlattachedproperty enumeration QtQuick::EnterKey::type | - | ||||||||||||||||||||||||
1702 | - | |||||||||||||||||||||||||
1703 | Holds the type of the Enter key. | - | ||||||||||||||||||||||||
1704 | - | |||||||||||||||||||||||||
1705 | \note Not all of these values are supported on all platforms. For | - | ||||||||||||||||||||||||
1706 | unsupported values the default key is used instead. | - | ||||||||||||||||||||||||
1707 | - | |||||||||||||||||||||||||
1708 | \value Qt.EnterKeyDefault The default Enter key. This can be either a | - | ||||||||||||||||||||||||
1709 | button to accept the input and close the | - | ||||||||||||||||||||||||
1710 | keyboard, or a \e Return button to enter a | - | ||||||||||||||||||||||||
1711 | newline in case of a multi-line input field. | - | ||||||||||||||||||||||||
1712 | - | |||||||||||||||||||||||||
1713 | \value Qt.EnterKeyReturn Show a \e Return button that inserts a | - | ||||||||||||||||||||||||
1714 | newline. | - | ||||||||||||||||||||||||
1715 | - | |||||||||||||||||||||||||
1716 | \value Qt.EnterKeyDone Show a \e {"Done"} button. Typically, the | - | ||||||||||||||||||||||||
1717 | keyboard is expected to close when the button | - | ||||||||||||||||||||||||
1718 | is pressed. | - | ||||||||||||||||||||||||
1719 | - | |||||||||||||||||||||||||
1720 | \value Qt.EnterKeyGo Show a \e {"Go"} button. Typically used in an | - | ||||||||||||||||||||||||
1721 | address bar when entering a URL. | - | ||||||||||||||||||||||||
1722 | - | |||||||||||||||||||||||||
1723 | \value Qt.EnterKeySend Show a \e {"Send"} button. | - | ||||||||||||||||||||||||
1724 | - | |||||||||||||||||||||||||
1725 | \value Qt.EnterKeySearch Show a \e {"Search"} button. | - | ||||||||||||||||||||||||
1726 | - | |||||||||||||||||||||||||
1727 | \value Qt.EnterKeyNext Show a \e {"Next"} button. Typically used in a | - | ||||||||||||||||||||||||
1728 | form to allow navigating to the next input | - | ||||||||||||||||||||||||
1729 | field without the keyboard closing. | - | ||||||||||||||||||||||||
1730 | - | |||||||||||||||||||||||||
1731 | \value Qt.EnterKeyPrevious Show a \e {"Previous"} button. | - | ||||||||||||||||||||||||
1732 | */ | - | ||||||||||||||||||||||||
1733 | - | |||||||||||||||||||||||||
1734 | QQuickEnterKeyAttached::QQuickEnterKeyAttached(QObject *parent) | - | ||||||||||||||||||||||||
1735 | : QObject(parent), itemPrivate(nullptr), keyType(Qt::EnterKeyDefault) | - | ||||||||||||||||||||||||
1736 | { | - | ||||||||||||||||||||||||
1737 | if (QQuickItem *item = qobject_cast<QQuickItem*>(parent)) {
| 0 | ||||||||||||||||||||||||
1738 | itemPrivate = QQuickItemPrivate::get(item); | - | ||||||||||||||||||||||||
1739 | itemPrivate->extra.value().enterKeyAttached = this; | - | ||||||||||||||||||||||||
1740 | } else never executed: end of block | 0 | ||||||||||||||||||||||||
1741 | qmlWarning(parent) << tr("EnterKey attached property only works with Items"); never executed: qmlWarning(parent) << tr("EnterKey attached property only works with Items"); | 0 | ||||||||||||||||||||||||
1742 | } | - | ||||||||||||||||||||||||
1743 | - | |||||||||||||||||||||||||
1744 | QQuickEnterKeyAttached *QQuickEnterKeyAttached::qmlAttachedProperties(QObject *object) | - | ||||||||||||||||||||||||
1745 | { | - | ||||||||||||||||||||||||
1746 | return new QQuickEnterKeyAttached(object); never executed: return new QQuickEnterKeyAttached(object); | 0 | ||||||||||||||||||||||||
1747 | } | - | ||||||||||||||||||||||||
1748 | - | |||||||||||||||||||||||||
1749 | Qt::EnterKeyType QQuickEnterKeyAttached::type() const | - | ||||||||||||||||||||||||
1750 | { | - | ||||||||||||||||||||||||
1751 | return keyType; never executed: return keyType; | 0 | ||||||||||||||||||||||||
1752 | } | - | ||||||||||||||||||||||||
1753 | - | |||||||||||||||||||||||||
1754 | void QQuickEnterKeyAttached::setType(Qt::EnterKeyType type) | - | ||||||||||||||||||||||||
1755 | { | - | ||||||||||||||||||||||||
1756 | if (keyType != type) {
| 0 | ||||||||||||||||||||||||
1757 | keyType = type; | - | ||||||||||||||||||||||||
1758 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
1759 | if (itemPrivate && itemPrivate->activeFocus)
| 0 | ||||||||||||||||||||||||
1760 | QGuiApplication::inputMethod()->update(Qt::ImEnterKeyType); never executed: QGuiApplication::inputMethod()->update(Qt::ImEnterKeyType); | 0 | ||||||||||||||||||||||||
1761 | #endif | - | ||||||||||||||||||||||||
1762 | typeChanged(); | - | ||||||||||||||||||||||||
1763 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1764 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1765 | - | |||||||||||||||||||||||||
1766 | void QQuickItemPrivate::setAccessible() | - | ||||||||||||||||||||||||
1767 | { | - | ||||||||||||||||||||||||
1768 | isAccessible = true; | - | ||||||||||||||||||||||||
1769 | } executed 84 times by 2 tests: end of block Executed by:
| 84 | ||||||||||||||||||||||||
1770 | - | |||||||||||||||||||||||||
1771 | /*! | - | ||||||||||||||||||||||||
1772 | Clears all sub focus items from \a scope. | - | ||||||||||||||||||||||||
1773 | If \a focus is true, sets the scope's subFocusItem | - | ||||||||||||||||||||||||
1774 | to be this item. | - | ||||||||||||||||||||||||
1775 | */ | - | ||||||||||||||||||||||||
1776 | void QQuickItemPrivate::updateSubFocusItem(QQuickItem *scope, bool focus) | - | ||||||||||||||||||||||||
1777 | { | - | ||||||||||||||||||||||||
1778 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
1779 | Q_ASSERT(scope); | - | ||||||||||||||||||||||||
1780 | - | |||||||||||||||||||||||||
1781 | QQuickItemPrivate *scopePrivate = QQuickItemPrivate::get(scope); | - | ||||||||||||||||||||||||
1782 | - | |||||||||||||||||||||||||
1783 | QQuickItem *oldSubFocusItem = scopePrivate->subFocusItem; | - | ||||||||||||||||||||||||
1784 | // Correct focus chain in scope | - | ||||||||||||||||||||||||
1785 | if (oldSubFocusItem) {
| 10423-10498 | ||||||||||||||||||||||||
1786 | QQuickItem *sfi = scopePrivate->subFocusItem->parentItem(); | - | ||||||||||||||||||||||||
1787 | while (sfi && sfi != scope) {
| 0-18147 | ||||||||||||||||||||||||
1788 | QQuickItemPrivate::get(sfi)->subFocusItem = nullptr; | - | ||||||||||||||||||||||||
1789 | sfi = sfi->parentItem(); | - | ||||||||||||||||||||||||
1790 | } executed 7724 times by 19 tests: end of block Executed by:
| 7724 | ||||||||||||||||||||||||
1791 | } executed 10423 times by 19 tests: end of block Executed by:
| 10423 | ||||||||||||||||||||||||
1792 | - | |||||||||||||||||||||||||
1793 | if (focus) {
| 9246-11675 | ||||||||||||||||||||||||
1794 | scopePrivate->subFocusItem = q; | - | ||||||||||||||||||||||||
1795 | QQuickItem *sfi = scopePrivate->subFocusItem->parentItem(); | - | ||||||||||||||||||||||||
1796 | while (sfi && sfi != scope) {
| 0-19471 | ||||||||||||||||||||||||
1797 | QQuickItemPrivate::get(sfi)->subFocusItem = q; | - | ||||||||||||||||||||||||
1798 | sfi = sfi->parentItem(); | - | ||||||||||||||||||||||||
1799 | } executed 7796 times by 20 tests: end of block Executed by:
| 7796 | ||||||||||||||||||||||||
1800 | } else { executed 11675 times by 20 tests: end of block Executed by:
| 11675 | ||||||||||||||||||||||||
1801 | scopePrivate->subFocusItem = nullptr; | - | ||||||||||||||||||||||||
1802 | } executed 9246 times by 19 tests: end of block Executed by:
| 9246 | ||||||||||||||||||||||||
1803 | } | - | ||||||||||||||||||||||||
1804 | - | |||||||||||||||||||||||||
1805 | /*! | - | ||||||||||||||||||||||||
1806 | \class QQuickItem | - | ||||||||||||||||||||||||
1807 | \brief The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}. | - | ||||||||||||||||||||||||
1808 | \inmodule QtQuick | - | ||||||||||||||||||||||||
1809 | - | |||||||||||||||||||||||||
1810 | All visual items in Qt Quick inherit from QQuickItem. Although a QQuickItem | - | ||||||||||||||||||||||||
1811 | instance has no visual appearance, it defines all the attributes that are | - | ||||||||||||||||||||||||
1812 | common across visual items, such as x and y position, width and height, | - | ||||||||||||||||||||||||
1813 | \l {Positioning with Anchors}{anchoring} and key handling support. | - | ||||||||||||||||||||||||
1814 | - | |||||||||||||||||||||||||
1815 | You can subclass QQuickItem to provide your own custom visual item | - | ||||||||||||||||||||||||
1816 | that inherits these features. | - | ||||||||||||||||||||||||
1817 | - | |||||||||||||||||||||||||
1818 | \section1 Custom Scene Graph Items | - | ||||||||||||||||||||||||
1819 | - | |||||||||||||||||||||||||
1820 | All visual QML items are rendered using the scene graph, a | - | ||||||||||||||||||||||||
1821 | low-level, high-performance rendering stack, closely tied to | - | ||||||||||||||||||||||||
1822 | OpenGL. It is possible for subclasses of QQuickItem to add their | - | ||||||||||||||||||||||||
1823 | own custom content into the scene graph by setting the | - | ||||||||||||||||||||||||
1824 | QQuickItem::ItemHasContents flag and reimplementing the | - | ||||||||||||||||||||||||
1825 | QQuickItem::updatePaintNode() function. | - | ||||||||||||||||||||||||
1826 | - | |||||||||||||||||||||||||
1827 | \warning It is crucial that OpenGL operations and interaction with | - | ||||||||||||||||||||||||
1828 | the scene graph happens exclusively on the rendering thread, | - | ||||||||||||||||||||||||
1829 | primarily during the updatePaintNode() call. The best rule of | - | ||||||||||||||||||||||||
1830 | thumb is to only use classes with the "QSG" prefix inside the | - | ||||||||||||||||||||||||
1831 | QQuickItem::updatePaintNode() function. | - | ||||||||||||||||||||||||
1832 | - | |||||||||||||||||||||||||
1833 | \note All classes with QSG prefix should be used solely on the scene graph's | - | ||||||||||||||||||||||||
1834 | rendering thread. See \l {Scene Graph and Rendering} for more information. | - | ||||||||||||||||||||||||
1835 | - | |||||||||||||||||||||||||
1836 | \section2 Graphics Resource Handling | - | ||||||||||||||||||||||||
1837 | - | |||||||||||||||||||||||||
1838 | The preferred way to handle cleanup of graphics resources used in | - | ||||||||||||||||||||||||
1839 | the scene graph, is to rely on the automatic cleanup of nodes. A | - | ||||||||||||||||||||||||
1840 | QSGNode returned from QQuickItem::updatePaintNode() is | - | ||||||||||||||||||||||||
1841 | automatically deleted on the right thread at the right time. Trees | - | ||||||||||||||||||||||||
1842 | of QSGNode instances are managed through the use of | - | ||||||||||||||||||||||||
1843 | QSGNode::OwnedByParent, which is set by default. So, for the | - | ||||||||||||||||||||||||
1844 | majority of custom scene graph items, no extra work will be | - | ||||||||||||||||||||||||
1845 | required. | - | ||||||||||||||||||||||||
1846 | - | |||||||||||||||||||||||||
1847 | Implementations that store graphics resources outside the node | - | ||||||||||||||||||||||||
1848 | tree, such as an item implementing QQuickItem::textureProvider(), | - | ||||||||||||||||||||||||
1849 | will need to take care in cleaning it up correctly depending on | - | ||||||||||||||||||||||||
1850 | how the item is used in QML. The situations to handle are: | - | ||||||||||||||||||||||||
1851 | - | |||||||||||||||||||||||||
1852 | \list | - | ||||||||||||||||||||||||
1853 | - | |||||||||||||||||||||||||
1854 | \li The scene graph is invalidated; This can happen, for instance, | - | ||||||||||||||||||||||||
1855 | if the window is hidden using QQuickWindow::hide(). If the item | - | ||||||||||||||||||||||||
1856 | class implements a \c slot named \c invalidateSceneGraph(), this | - | ||||||||||||||||||||||||
1857 | slot will be called on the rendering thread while the GUI thread | - | ||||||||||||||||||||||||
1858 | is blocked. This is equivalent to connecting to | - | ||||||||||||||||||||||||
1859 | QQuickWindow::sceneGraphInvalidated(). The OpenGL context of this | - | ||||||||||||||||||||||||
1860 | item's window will be bound when this slot is called. The only | - | ||||||||||||||||||||||||
1861 | exception is if the native OpenGL has been destroyed outside Qt's | - | ||||||||||||||||||||||||
1862 | control, for instance through \c EGL_CONTEXT_LOST. | - | ||||||||||||||||||||||||
1863 | - | |||||||||||||||||||||||||
1864 | \li The item is removed from the scene; If an item is taken out of | - | ||||||||||||||||||||||||
1865 | the scene, for instance because it's parent was set to \c null or | - | ||||||||||||||||||||||||
1866 | an item in another window, the QQuickItem::releaseResources() will | - | ||||||||||||||||||||||||
1867 | be called on the GUI thread. QQuickWindow::scheduleRenderJob() | - | ||||||||||||||||||||||||
1868 | should be used to schedule cleanup of rendering resources. | - | ||||||||||||||||||||||||
1869 | - | |||||||||||||||||||||||||
1870 | \li The item is deleted; When the destructor if an item runs, it | - | ||||||||||||||||||||||||
1871 | should delete any graphics resources it has. If neither of the two | - | ||||||||||||||||||||||||
1872 | conditions above were already met, the item will be part of a | - | ||||||||||||||||||||||||
1873 | window and it is possible to use QQuickWindow::scheduleRenderJob() | - | ||||||||||||||||||||||||
1874 | to have them cleaned up. If an implementation ignores the call to | - | ||||||||||||||||||||||||
1875 | QQuickItem::releaseResources(), the item will in many cases no | - | ||||||||||||||||||||||||
1876 | longer have access to a QQuickWindow and thus no means of | - | ||||||||||||||||||||||||
1877 | scheduling cleanup. | - | ||||||||||||||||||||||||
1878 | - | |||||||||||||||||||||||||
1879 | \endlist | - | ||||||||||||||||||||||||
1880 | - | |||||||||||||||||||||||||
1881 | When scheduling cleanup of graphics resources using | - | ||||||||||||||||||||||||
1882 | QQuickWindow::scheduleRenderJob(), one should use either | - | ||||||||||||||||||||||||
1883 | QQuickWindow::BeforeSynchronizingStage or | - | ||||||||||||||||||||||||
1884 | QQuickWindow::AfterSynchronizingStage. The \l {Scene Graph and | - | ||||||||||||||||||||||||
1885 | Rendering}{synchronization stage} is where the scene graph is | - | ||||||||||||||||||||||||
1886 | changed as a result of changes to the QML tree. If cleanup is | - | ||||||||||||||||||||||||
1887 | scheduled at any other time, it may result in other parts of the | - | ||||||||||||||||||||||||
1888 | scene graph referencing the newly deleted objects as these parts | - | ||||||||||||||||||||||||
1889 | have not been updated. | - | ||||||||||||||||||||||||
1890 | - | |||||||||||||||||||||||||
1891 | \note Use of QObject::deleteLater() to clean up graphics resources | - | ||||||||||||||||||||||||
1892 | is not recommended as this will run at an arbitrary time and it is | - | ||||||||||||||||||||||||
1893 | unknown if there will be an OpenGL context bound when the deletion | - | ||||||||||||||||||||||||
1894 | takes place. | - | ||||||||||||||||||||||||
1895 | - | |||||||||||||||||||||||||
1896 | \section1 Custom QPainter Items | - | ||||||||||||||||||||||||
1897 | - | |||||||||||||||||||||||||
1898 | The QQuickItem provides a subclass, QQuickPaintedItem, which | - | ||||||||||||||||||||||||
1899 | allows the users to render content using QPainter. | - | ||||||||||||||||||||||||
1900 | - | |||||||||||||||||||||||||
1901 | \warning Using QQuickPaintedItem uses an indirect 2D surface to | - | ||||||||||||||||||||||||
1902 | render its content, either using software rasterization or using | - | ||||||||||||||||||||||||
1903 | an OpenGL framebuffer object (FBO), so the rendering is a two-step | - | ||||||||||||||||||||||||
1904 | operation. First rasterize the surface, then draw the | - | ||||||||||||||||||||||||
1905 | surface. Using scene graph API directly is always significantly | - | ||||||||||||||||||||||||
1906 | faster. | - | ||||||||||||||||||||||||
1907 | - | |||||||||||||||||||||||||
1908 | \section1 Behavior Animations | - | ||||||||||||||||||||||||
1909 | - | |||||||||||||||||||||||||
1910 | If your Item uses the \l Behavior type to define animations for property | - | ||||||||||||||||||||||||
1911 | changes, you should always use either QObject::setProperty(), | - | ||||||||||||||||||||||||
1912 | QQmlProperty(), or QMetaProperty::write() when you need to modify those | - | ||||||||||||||||||||||||
1913 | properties from C++. This ensures that the QML engine knows about the | - | ||||||||||||||||||||||||
1914 | property change. Otherwise, the engine won't be able to carry out your | - | ||||||||||||||||||||||||
1915 | requested animation. | - | ||||||||||||||||||||||||
1916 | Note that these functions incur a slight performance penalty. For more | - | ||||||||||||||||||||||||
1917 | details, see \l {Accessing Members of a QML Object Type from C++}. | - | ||||||||||||||||||||||||
1918 | - | |||||||||||||||||||||||||
1919 | \sa QQuickWindow, QQuickPaintedItem | - | ||||||||||||||||||||||||
1920 | */ | - | ||||||||||||||||||||||||
1921 | - | |||||||||||||||||||||||||
1922 | /*! | - | ||||||||||||||||||||||||
1923 | \qmltype Item | - | ||||||||||||||||||||||||
1924 | \instantiates QQuickItem | - | ||||||||||||||||||||||||
1925 | \inherits QtObject | - | ||||||||||||||||||||||||
1926 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
1927 | \ingroup qtquick-visual | - | ||||||||||||||||||||||||
1928 | \brief A basic visual QML type. | - | ||||||||||||||||||||||||
1929 | - | |||||||||||||||||||||||||
1930 | The Item type is the base type for all visual items in Qt Quick. | - | ||||||||||||||||||||||||
1931 | - | |||||||||||||||||||||||||
1932 | All visual items in Qt Quick inherit from Item. Although an Item | - | ||||||||||||||||||||||||
1933 | object has no visual appearance, it defines all the attributes that are | - | ||||||||||||||||||||||||
1934 | common across visual items, such as x and y position, width and height, | - | ||||||||||||||||||||||||
1935 | \l {Positioning with Anchors}{anchoring} and key handling support. | - | ||||||||||||||||||||||||
1936 | - | |||||||||||||||||||||||||
1937 | The Item type can be useful for grouping several items under a single | - | ||||||||||||||||||||||||
1938 | root visual item. For example: | - | ||||||||||||||||||||||||
1939 | - | |||||||||||||||||||||||||
1940 | \qml | - | ||||||||||||||||||||||||
1941 | import QtQuick 2.0 | - | ||||||||||||||||||||||||
1942 | - | |||||||||||||||||||||||||
1943 | Item { | - | ||||||||||||||||||||||||
1944 | Image { | - | ||||||||||||||||||||||||
1945 | source: "tile.png" | - | ||||||||||||||||||||||||
1946 | } | - | ||||||||||||||||||||||||
1947 | Image { | - | ||||||||||||||||||||||||
1948 | x: 80 | - | ||||||||||||||||||||||||
1949 | width: 100 | - | ||||||||||||||||||||||||
1950 | height: 100 | - | ||||||||||||||||||||||||
1951 | source: "tile.png" | - | ||||||||||||||||||||||||
1952 | } | - | ||||||||||||||||||||||||
1953 | Image { | - | ||||||||||||||||||||||||
1954 | x: 190 | - | ||||||||||||||||||||||||
1955 | width: 100 | - | ||||||||||||||||||||||||
1956 | height: 100 | - | ||||||||||||||||||||||||
1957 | fillMode: Image.Tile | - | ||||||||||||||||||||||||
1958 | source: "tile.png" | - | ||||||||||||||||||||||||
1959 | } | - | ||||||||||||||||||||||||
1960 | } | - | ||||||||||||||||||||||||
1961 | \endqml | - | ||||||||||||||||||||||||
1962 | - | |||||||||||||||||||||||||
1963 | - | |||||||||||||||||||||||||
1964 | \section2 Key Handling | - | ||||||||||||||||||||||||
1965 | - | |||||||||||||||||||||||||
1966 | Key handling is available to all Item-based visual types via the \l Keys | - | ||||||||||||||||||||||||
1967 | attached property. The \e Keys attached property provides basic signals | - | ||||||||||||||||||||||||
1968 | such as \l {Keys::}{pressed} and \l {Keys::}{released}, as well as | - | ||||||||||||||||||||||||
1969 | signals for specific keys, such as \l {Keys::}{spacePressed}. The | - | ||||||||||||||||||||||||
1970 | example below assigns \l {Keyboard Focus in Qt Quick}{keyboard focus} to | - | ||||||||||||||||||||||||
1971 | the item and handles the left key via the general \c onPressed handler | - | ||||||||||||||||||||||||
1972 | and the return key via the \c onReturnPressed handler: | - | ||||||||||||||||||||||||
1973 | - | |||||||||||||||||||||||||
1974 | \qml | - | ||||||||||||||||||||||||
1975 | import QtQuick 2.0 | - | ||||||||||||||||||||||||
1976 | - | |||||||||||||||||||||||||
1977 | Item { | - | ||||||||||||||||||||||||
1978 | focus: true | - | ||||||||||||||||||||||||
1979 | Keys.onPressed: { | - | ||||||||||||||||||||||||
1980 | if (event.key == Qt.Key_Left) { | - | ||||||||||||||||||||||||
1981 | console.log("move left"); | - | ||||||||||||||||||||||||
1982 | event.accepted = true; | - | ||||||||||||||||||||||||
1983 | } | - | ||||||||||||||||||||||||
1984 | } | - | ||||||||||||||||||||||||
1985 | Keys.onReturnPressed: console.log("Pressed return"); | - | ||||||||||||||||||||||||
1986 | } | - | ||||||||||||||||||||||||
1987 | \endqml | - | ||||||||||||||||||||||||
1988 | - | |||||||||||||||||||||||||
1989 | See the \l Keys attached property for detailed documentation. | - | ||||||||||||||||||||||||
1990 | - | |||||||||||||||||||||||||
1991 | \section2 Layout Mirroring | - | ||||||||||||||||||||||||
1992 | - | |||||||||||||||||||||||||
1993 | Item layouts can be mirrored using the \l LayoutMirroring attached | - | ||||||||||||||||||||||||
1994 | property. This causes \l{anchors.top}{anchors} to be horizontally | - | ||||||||||||||||||||||||
1995 | reversed, and also causes items that lay out or position their children | - | ||||||||||||||||||||||||
1996 | (such as ListView or \l Row) to horizontally reverse the direction of | - | ||||||||||||||||||||||||
1997 | their layouts. | - | ||||||||||||||||||||||||
1998 | - | |||||||||||||||||||||||||
1999 | See LayoutMirroring for more details. | - | ||||||||||||||||||||||||
2000 | - | |||||||||||||||||||||||||
2001 | \section1 Item Layers | - | ||||||||||||||||||||||||
2002 | - | |||||||||||||||||||||||||
2003 | An Item will normally be rendered directly into the window it | - | ||||||||||||||||||||||||
2004 | belongs to. However, by setting \l layer.enabled, it is possible | - | ||||||||||||||||||||||||
2005 | to delegate the item and its entire subtree into an offscreen | - | ||||||||||||||||||||||||
2006 | surface. Only the offscreen surface, a texture, will be then drawn | - | ||||||||||||||||||||||||
2007 | into the window. | - | ||||||||||||||||||||||||
2008 | - | |||||||||||||||||||||||||
2009 | If it is desired to have a texture size different from that of the | - | ||||||||||||||||||||||||
2010 | item, this is possible using \l layer.textureSize. To render only | - | ||||||||||||||||||||||||
2011 | a section of the item into the texture, use \l | - | ||||||||||||||||||||||||
2012 | layer.sourceRect. It is also possible to specify \l | - | ||||||||||||||||||||||||
2013 | layer.sourceRect so it extends beyond the bounds of the item. In | - | ||||||||||||||||||||||||
2014 | this case, the exterior will be padded with transparent pixels. | - | ||||||||||||||||||||||||
2015 | - | |||||||||||||||||||||||||
2016 | The item will use linear interpolation for scaling if | - | ||||||||||||||||||||||||
2017 | \l layer.smooth is set to \c true and will use mipmap for | - | ||||||||||||||||||||||||
2018 | downsampling if \l layer.mipmap is set to \c true. Mipmapping may | - | ||||||||||||||||||||||||
2019 | improve visual quality of downscaled items. For mipmapping of | - | ||||||||||||||||||||||||
2020 | single Image items, prefer Image::mipmap. | - | ||||||||||||||||||||||||
2021 | - | |||||||||||||||||||||||||
2022 | \section2 Layer Opacity vs Item Opacity | - | ||||||||||||||||||||||||
2023 | - | |||||||||||||||||||||||||
2024 | When applying \l opacity to an item hierarchy the opacity is | - | ||||||||||||||||||||||||
2025 | applied to each item individually. This can lead to undesired | - | ||||||||||||||||||||||||
2026 | visual results when the opacity is applied to a subtree. Consider | - | ||||||||||||||||||||||||
2027 | the following example: | - | ||||||||||||||||||||||||
2028 | - | |||||||||||||||||||||||||
2029 | \table | - | ||||||||||||||||||||||||
2030 | \row | - | ||||||||||||||||||||||||
2031 | \li \inlineimage qml-blending-nonlayered.png | - | ||||||||||||||||||||||||
2032 | \li \b {Non-layered Opacity} \snippet qml/layerblending.qml non-layered | - | ||||||||||||||||||||||||
2033 | \endtable | - | ||||||||||||||||||||||||
2034 | - | |||||||||||||||||||||||||
2035 | A layer is rendered with the root item's opacity being 1, and then | - | ||||||||||||||||||||||||
2036 | the root item's opacity is applied to the texture when it is | - | ||||||||||||||||||||||||
2037 | drawn. This means that fading in a large item hierarchy from | - | ||||||||||||||||||||||||
2038 | transparent to opaque, or vice versa, can be done without the | - | ||||||||||||||||||||||||
2039 | overlap artifacts that the normal item by item alpha blending | - | ||||||||||||||||||||||||
2040 | has. Here is the same example with layer enabled: | - | ||||||||||||||||||||||||
2041 | - | |||||||||||||||||||||||||
2042 | \table | - | ||||||||||||||||||||||||
2043 | \row | - | ||||||||||||||||||||||||
2044 | \li \image qml-blending-layered.png | - | ||||||||||||||||||||||||
2045 | \li \b {Layered Opacity} \snippet qml/layerblending.qml layered | - | ||||||||||||||||||||||||
2046 | \endtable | - | ||||||||||||||||||||||||
2047 | - | |||||||||||||||||||||||||
2048 | \section2 Combined with ShaderEffects | - | ||||||||||||||||||||||||
2049 | - | |||||||||||||||||||||||||
2050 | Setting \l layer.enabled to true will turn the item into a \l | - | ||||||||||||||||||||||||
2051 | {QQuickItem::isTextureProvider}{texture provider}, making it | - | ||||||||||||||||||||||||
2052 | possible to use the item directly as a texture, for instance | - | ||||||||||||||||||||||||
2053 | in combination with the ShaderEffect type. | - | ||||||||||||||||||||||||
2054 | - | |||||||||||||||||||||||||
2055 | It is possible to apply an effect on a layer at runtime using | - | ||||||||||||||||||||||||
2056 | layer.effect: | - | ||||||||||||||||||||||||
2057 | - | |||||||||||||||||||||||||
2058 | \snippet qml/layerwitheffect.qml 1 | - | ||||||||||||||||||||||||
2059 | - | |||||||||||||||||||||||||
2060 | In this example, we implement the shader effect manually. The \l | - | ||||||||||||||||||||||||
2061 | {Qt Graphical Effects} module contains a suite of ready-made | - | ||||||||||||||||||||||||
2062 | effects for use with Qt Quick. | - | ||||||||||||||||||||||||
2063 | - | |||||||||||||||||||||||||
2064 | See ShaderEffect for more information about using effects. | - | ||||||||||||||||||||||||
2065 | - | |||||||||||||||||||||||||
2066 | \note \l layer.enabled is actually just a more convenient way of using | - | ||||||||||||||||||||||||
2067 | ShaderEffectSource. | - | ||||||||||||||||||||||||
2068 | - | |||||||||||||||||||||||||
2069 | - | |||||||||||||||||||||||||
2070 | \section2 Memory and Performance | - | ||||||||||||||||||||||||
2071 | - | |||||||||||||||||||||||||
2072 | When an item's layer is enabled, the scene graph will allocate memory | - | ||||||||||||||||||||||||
2073 | in the GPU equal to \c {width x height x 4}. In memory constrained | - | ||||||||||||||||||||||||
2074 | configurations, large layers should be used with care. | - | ||||||||||||||||||||||||
2075 | - | |||||||||||||||||||||||||
2076 | In the QPainter / QWidget world, it is some times favorable to | - | ||||||||||||||||||||||||
2077 | cache complex content in a pixmap, image or texture. In Qt Quick, | - | ||||||||||||||||||||||||
2078 | because of the techniques already applied by the \l {Qt Quick | - | ||||||||||||||||||||||||
2079 | Scene Graph OpenGL Renderer} {scene graph renderer}, this will in most | - | ||||||||||||||||||||||||
2080 | cases not be the case. Excessive draw calls are already reduced | - | ||||||||||||||||||||||||
2081 | because of batching and a cache will in most cases end up blending | - | ||||||||||||||||||||||||
2082 | more pixels than the original content. The overhead of rendering | - | ||||||||||||||||||||||||
2083 | to an offscreen and the blending involved with drawing the | - | ||||||||||||||||||||||||
2084 | resulting texture is therefore often more costly than simply | - | ||||||||||||||||||||||||
2085 | letting the item and its children be drawn normally. | - | ||||||||||||||||||||||||
2086 | - | |||||||||||||||||||||||||
2087 | Also, an item using a layer can not be \l {Batching} {batched} during | - | ||||||||||||||||||||||||
2088 | rendering. This means that a scene with many layered items may | - | ||||||||||||||||||||||||
2089 | have performance problems. | - | ||||||||||||||||||||||||
2090 | - | |||||||||||||||||||||||||
2091 | Layering can be convenient and useful for visual effects, but | - | ||||||||||||||||||||||||
2092 | should in most cases be enabled for the duration of the effect and | - | ||||||||||||||||||||||||
2093 | disabled afterwards. | - | ||||||||||||||||||||||||
2094 | - | |||||||||||||||||||||||||
2095 | */ | - | ||||||||||||||||||||||||
2096 | - | |||||||||||||||||||||||||
2097 | /*! | - | ||||||||||||||||||||||||
2098 | \enum QQuickItem::Flag | - | ||||||||||||||||||||||||
2099 | - | |||||||||||||||||||||||||
2100 | This enum type is used to specify various item properties. | - | ||||||||||||||||||||||||
2101 | - | |||||||||||||||||||||||||
2102 | \value ItemClipsChildrenToShape Indicates this item should visually clip | - | ||||||||||||||||||||||||
2103 | its children so that they are rendered only within the boundaries of this | - | ||||||||||||||||||||||||
2104 | item. | - | ||||||||||||||||||||||||
2105 | \value ItemAcceptsInputMethod Indicates the item supports text input | - | ||||||||||||||||||||||||
2106 | methods. | - | ||||||||||||||||||||||||
2107 | \value ItemIsFocusScope Indicates the item is a focus scope. See | - | ||||||||||||||||||||||||
2108 | \l {Keyboard Focus in Qt Quick} for more information. | - | ||||||||||||||||||||||||
2109 | \value ItemHasContents Indicates the item has visual content and should be | - | ||||||||||||||||||||||||
2110 | rendered by the scene graph. | - | ||||||||||||||||||||||||
2111 | \value ItemAcceptsDrops Indicates the item accepts drag and drop events. | - | ||||||||||||||||||||||||
2112 | - | |||||||||||||||||||||||||
2113 | \sa setFlag(), setFlags(), flags() | - | ||||||||||||||||||||||||
2114 | */ | - | ||||||||||||||||||||||||
2115 | - | |||||||||||||||||||||||||
2116 | /*! | - | ||||||||||||||||||||||||
2117 | \enum QQuickItem::ItemChange | - | ||||||||||||||||||||||||
2118 | \brief Used in conjunction with QQuickItem::itemChange() to notify | - | ||||||||||||||||||||||||
2119 | the item about certain types of changes. | - | ||||||||||||||||||||||||
2120 | - | |||||||||||||||||||||||||
2121 | \value ItemChildAddedChange A child was added. ItemChangeData::item contains | - | ||||||||||||||||||||||||
2122 | the added child. | - | ||||||||||||||||||||||||
2123 | - | |||||||||||||||||||||||||
2124 | \value ItemChildRemovedChange A child was removed. ItemChangeData::item | - | ||||||||||||||||||||||||
2125 | contains the removed child. | - | ||||||||||||||||||||||||
2126 | - | |||||||||||||||||||||||||
2127 | \value ItemSceneChange The item was added to or removed from a scene. The | - | ||||||||||||||||||||||||
2128 | QQuickWindow rendering the scene is specified in using ItemChangeData::window. | - | ||||||||||||||||||||||||
2129 | The window parameter is null when the item is removed from a scene. | - | ||||||||||||||||||||||||
2130 | - | |||||||||||||||||||||||||
2131 | \value ItemVisibleHasChanged The item's visibility has changed. | - | ||||||||||||||||||||||||
2132 | ItemChangeData::boolValue contains the new visibility. | - | ||||||||||||||||||||||||
2133 | - | |||||||||||||||||||||||||
2134 | \value ItemParentHasChanged The item's parent has changed. | - | ||||||||||||||||||||||||
2135 | ItemChangeData::item contains the new parent. | - | ||||||||||||||||||||||||
2136 | - | |||||||||||||||||||||||||
2137 | \value ItemOpacityHasChanged The item's opacity has changed. | - | ||||||||||||||||||||||||
2138 | ItemChangeData::realValue contains the new opacity. | - | ||||||||||||||||||||||||
2139 | - | |||||||||||||||||||||||||
2140 | \value ItemActiveFocusHasChanged The item's focus has changed. | - | ||||||||||||||||||||||||
2141 | ItemChangeData::boolValue contains whether the item has focus or not. | - | ||||||||||||||||||||||||
2142 | - | |||||||||||||||||||||||||
2143 | \value ItemRotationHasChanged The item's rotation has changed. | - | ||||||||||||||||||||||||
2144 | ItemChangeData::realValue contains the new rotation. | - | ||||||||||||||||||||||||
2145 | - | |||||||||||||||||||||||||
2146 | \value ItemDevicePixelRatioHasChanged The device pixel ratio of the screen | - | ||||||||||||||||||||||||
2147 | the item is on has changed. ItemChangedData::realValue contains the new | - | ||||||||||||||||||||||||
2148 | device pixel ratio. | - | ||||||||||||||||||||||||
2149 | - | |||||||||||||||||||||||||
2150 | \value ItemAntialiasingHasChanged The antialiasing has changed. The current | - | ||||||||||||||||||||||||
2151 | (boolean) value can be found in QQuickItem::antialiasing. | - | ||||||||||||||||||||||||
2152 | - | |||||||||||||||||||||||||
2153 | \value ItemEnabledHasChanged The item's enabled state has changed. | - | ||||||||||||||||||||||||
2154 | ItemChangeData::boolValue contains the new enabled state. (since Qt 5.10) | - | ||||||||||||||||||||||||
2155 | */ | - | ||||||||||||||||||||||||
2156 | - | |||||||||||||||||||||||||
2157 | /*! | - | ||||||||||||||||||||||||
2158 | \class QQuickItem::ItemChangeData | - | ||||||||||||||||||||||||
2159 | \inmodule QtQuick | - | ||||||||||||||||||||||||
2160 | \brief Adds supplimentary information to the QQuickItem::itemChange() | - | ||||||||||||||||||||||||
2161 | function. | - | ||||||||||||||||||||||||
2162 | - | |||||||||||||||||||||||||
2163 | The meaning of each member of this class is defined by the change type. | - | ||||||||||||||||||||||||
2164 | - | |||||||||||||||||||||||||
2165 | \sa QQuickItem::ItemChange | - | ||||||||||||||||||||||||
2166 | */ | - | ||||||||||||||||||||||||
2167 | - | |||||||||||||||||||||||||
2168 | /*! | - | ||||||||||||||||||||||||
2169 | \fn QQuickItem::ItemChangeData::ItemChangeData(QQuickItem *) | - | ||||||||||||||||||||||||
2170 | \internal | - | ||||||||||||||||||||||||
2171 | */ | - | ||||||||||||||||||||||||
2172 | - | |||||||||||||||||||||||||
2173 | /*! | - | ||||||||||||||||||||||||
2174 | \fn QQuickItem::ItemChangeData::ItemChangeData(QQuickWindow *) | - | ||||||||||||||||||||||||
2175 | \internal | - | ||||||||||||||||||||||||
2176 | */ | - | ||||||||||||||||||||||||
2177 | - | |||||||||||||||||||||||||
2178 | /*! | - | ||||||||||||||||||||||||
2179 | \fn QQuickItem::ItemChangeData::ItemChangeData(qreal) | - | ||||||||||||||||||||||||
2180 | \internal | - | ||||||||||||||||||||||||
2181 | */ | - | ||||||||||||||||||||||||
2182 | - | |||||||||||||||||||||||||
2183 | /*! | - | ||||||||||||||||||||||||
2184 | \fn QQuickItem::ItemChangeData::ItemChangeData(bool) | - | ||||||||||||||||||||||||
2185 | \internal | - | ||||||||||||||||||||||||
2186 | */ | - | ||||||||||||||||||||||||
2187 | - | |||||||||||||||||||||||||
2188 | /*! | - | ||||||||||||||||||||||||
2189 | \variable QQuickItem::ItemChangeData::realValue | - | ||||||||||||||||||||||||
2190 | Contains supplimentary information to the QQuickItem::itemChange() function. | - | ||||||||||||||||||||||||
2191 | \sa QQuickItem::ItemChange | - | ||||||||||||||||||||||||
2192 | */ | - | ||||||||||||||||||||||||
2193 | - | |||||||||||||||||||||||||
2194 | /*! | - | ||||||||||||||||||||||||
2195 | \variable QQuickItem::ItemChangeData::boolValue | - | ||||||||||||||||||||||||
2196 | Contains supplimentary information to the QQuickItem::itemChange() function. | - | ||||||||||||||||||||||||
2197 | \sa QQuickItem::ItemChange | - | ||||||||||||||||||||||||
2198 | */ | - | ||||||||||||||||||||||||
2199 | - | |||||||||||||||||||||||||
2200 | /*! | - | ||||||||||||||||||||||||
2201 | \variable QQuickItem::ItemChangeData::item | - | ||||||||||||||||||||||||
2202 | Contains supplimentary information to the QQuickItem::itemChange() function. | - | ||||||||||||||||||||||||
2203 | \sa QQuickItem::ItemChange | - | ||||||||||||||||||||||||
2204 | */ | - | ||||||||||||||||||||||||
2205 | - | |||||||||||||||||||||||||
2206 | /*! | - | ||||||||||||||||||||||||
2207 | \variable QQuickItem::ItemChangeData::window | - | ||||||||||||||||||||||||
2208 | Contains supplimentary information to the QQuickItem::itemChange() function. | - | ||||||||||||||||||||||||
2209 | \sa QQuickItem::ItemChange | - | ||||||||||||||||||||||||
2210 | */ | - | ||||||||||||||||||||||||
2211 | - | |||||||||||||||||||||||||
2212 | /*! | - | ||||||||||||||||||||||||
2213 | \enum QQuickItem::TransformOrigin | - | ||||||||||||||||||||||||
2214 | - | |||||||||||||||||||||||||
2215 | Controls the point about which simple transforms like scale apply. | - | ||||||||||||||||||||||||
2216 | - | |||||||||||||||||||||||||
2217 | \value TopLeft The top-left corner of the item. | - | ||||||||||||||||||||||||
2218 | \value Top The center point of the top of the item. | - | ||||||||||||||||||||||||
2219 | \value TopRight The top-right corner of the item. | - | ||||||||||||||||||||||||
2220 | \value Left The left most point of the vertical middle. | - | ||||||||||||||||||||||||
2221 | \value Center The center of the item. | - | ||||||||||||||||||||||||
2222 | \value Right The right most point of the vertical middle. | - | ||||||||||||||||||||||||
2223 | \value BottomLeft The bottom-left corner of the item. | - | ||||||||||||||||||||||||
2224 | \value Bottom The center point of the bottom of the item. | - | ||||||||||||||||||||||||
2225 | \value BottomRight The bottom-right corner of the item. | - | ||||||||||||||||||||||||
2226 | - | |||||||||||||||||||||||||
2227 | \sa transformOrigin(), setTransformOrigin() | - | ||||||||||||||||||||||||
2228 | */ | - | ||||||||||||||||||||||||
2229 | - | |||||||||||||||||||||||||
2230 | /*! | - | ||||||||||||||||||||||||
2231 | \fn void QQuickItem::childrenRectChanged(const QRectF &) | - | ||||||||||||||||||||||||
2232 | \internal | - | ||||||||||||||||||||||||
2233 | */ | - | ||||||||||||||||||||||||
2234 | - | |||||||||||||||||||||||||
2235 | /*! | - | ||||||||||||||||||||||||
2236 | \fn void QQuickItem::baselineOffsetChanged(qreal) | - | ||||||||||||||||||||||||
2237 | \internal | - | ||||||||||||||||||||||||
2238 | */ | - | ||||||||||||||||||||||||
2239 | - | |||||||||||||||||||||||||
2240 | /*! | - | ||||||||||||||||||||||||
2241 | \fn void QQuickItem::stateChanged(const QString &state) | - | ||||||||||||||||||||||||
2242 | \internal | - | ||||||||||||||||||||||||
2243 | */ | - | ||||||||||||||||||||||||
2244 | - | |||||||||||||||||||||||||
2245 | /*! | - | ||||||||||||||||||||||||
2246 | \fn void QQuickItem::parentChanged(QQuickItem *) | - | ||||||||||||||||||||||||
2247 | \internal | - | ||||||||||||||||||||||||
2248 | */ | - | ||||||||||||||||||||||||
2249 | - | |||||||||||||||||||||||||
2250 | /*! | - | ||||||||||||||||||||||||
2251 | \fn void QQuickItem::smoothChanged(bool) | - | ||||||||||||||||||||||||
2252 | \internal | - | ||||||||||||||||||||||||
2253 | */ | - | ||||||||||||||||||||||||
2254 | - | |||||||||||||||||||||||||
2255 | /*! | - | ||||||||||||||||||||||||
2256 | \fn void QQuickItem::antialiasingChanged(bool) | - | ||||||||||||||||||||||||
2257 | \internal | - | ||||||||||||||||||||||||
2258 | */ | - | ||||||||||||||||||||||||
2259 | - | |||||||||||||||||||||||||
2260 | /*! | - | ||||||||||||||||||||||||
2261 | \fn void QQuickItem::clipChanged(bool) | - | ||||||||||||||||||||||||
2262 | \internal | - | ||||||||||||||||||||||||
2263 | */ | - | ||||||||||||||||||||||||
2264 | - | |||||||||||||||||||||||||
2265 | /*! | - | ||||||||||||||||||||||||
2266 | \fn void QQuickItem::transformOriginChanged(TransformOrigin) | - | ||||||||||||||||||||||||
2267 | \internal | - | ||||||||||||||||||||||||
2268 | */ | - | ||||||||||||||||||||||||
2269 | - | |||||||||||||||||||||||||
2270 | /*! | - | ||||||||||||||||||||||||
2271 | \fn void QQuickItem::focusChanged(bool) | - | ||||||||||||||||||||||||
2272 | \internal | - | ||||||||||||||||||||||||
2273 | */ | - | ||||||||||||||||||||||||
2274 | - | |||||||||||||||||||||||||
2275 | /*! | - | ||||||||||||||||||||||||
2276 | \fn void QQuickItem::activeFocusChanged(bool) | - | ||||||||||||||||||||||||
2277 | \internal | - | ||||||||||||||||||||||||
2278 | */ | - | ||||||||||||||||||||||||
2279 | - | |||||||||||||||||||||||||
2280 | /*! | - | ||||||||||||||||||||||||
2281 | \fn void QQuickItem::activeFocusOnTabChanged(bool) | - | ||||||||||||||||||||||||
2282 | \internal | - | ||||||||||||||||||||||||
2283 | */ | - | ||||||||||||||||||||||||
2284 | - | |||||||||||||||||||||||||
2285 | /*! | - | ||||||||||||||||||||||||
2286 | \fn void QQuickItem::childrenChanged() | - | ||||||||||||||||||||||||
2287 | \internal | - | ||||||||||||||||||||||||
2288 | */ | - | ||||||||||||||||||||||||
2289 | - | |||||||||||||||||||||||||
2290 | /*! | - | ||||||||||||||||||||||||
2291 | \fn void QQuickItem::opacityChanged() | - | ||||||||||||||||||||||||
2292 | \internal | - | ||||||||||||||||||||||||
2293 | */ | - | ||||||||||||||||||||||||
2294 | - | |||||||||||||||||||||||||
2295 | /*! | - | ||||||||||||||||||||||||
2296 | \fn void QQuickItem::enabledChanged() | - | ||||||||||||||||||||||||
2297 | \internal | - | ||||||||||||||||||||||||
2298 | */ | - | ||||||||||||||||||||||||
2299 | - | |||||||||||||||||||||||||
2300 | /*! | - | ||||||||||||||||||||||||
2301 | \fn void QQuickItem::visibleChanged() | - | ||||||||||||||||||||||||
2302 | \internal | - | ||||||||||||||||||||||||
2303 | */ | - | ||||||||||||||||||||||||
2304 | - | |||||||||||||||||||||||||
2305 | /*! | - | ||||||||||||||||||||||||
2306 | \fn void QQuickItem::visibleChildrenChanged() | - | ||||||||||||||||||||||||
2307 | \internal | - | ||||||||||||||||||||||||
2308 | */ | - | ||||||||||||||||||||||||
2309 | - | |||||||||||||||||||||||||
2310 | /*! | - | ||||||||||||||||||||||||
2311 | \fn void QQuickItem::rotationChanged() | - | ||||||||||||||||||||||||
2312 | \internal | - | ||||||||||||||||||||||||
2313 | */ | - | ||||||||||||||||||||||||
2314 | - | |||||||||||||||||||||||||
2315 | /*! | - | ||||||||||||||||||||||||
2316 | \fn void QQuickItem::scaleChanged() | - | ||||||||||||||||||||||||
2317 | \internal | - | ||||||||||||||||||||||||
2318 | */ | - | ||||||||||||||||||||||||
2319 | - | |||||||||||||||||||||||||
2320 | /*! | - | ||||||||||||||||||||||||
2321 | \fn void QQuickItem::xChanged() | - | ||||||||||||||||||||||||
2322 | \internal | - | ||||||||||||||||||||||||
2323 | */ | - | ||||||||||||||||||||||||
2324 | - | |||||||||||||||||||||||||
2325 | /*! | - | ||||||||||||||||||||||||
2326 | \fn void QQuickItem::yChanged() | - | ||||||||||||||||||||||||
2327 | \internal | - | ||||||||||||||||||||||||
2328 | */ | - | ||||||||||||||||||||||||
2329 | - | |||||||||||||||||||||||||
2330 | /*! | - | ||||||||||||||||||||||||
2331 | \fn void QQuickItem::widthChanged() | - | ||||||||||||||||||||||||
2332 | \internal | - | ||||||||||||||||||||||||
2333 | */ | - | ||||||||||||||||||||||||
2334 | - | |||||||||||||||||||||||||
2335 | /*! | - | ||||||||||||||||||||||||
2336 | \fn void QQuickItem::heightChanged() | - | ||||||||||||||||||||||||
2337 | \internal | - | ||||||||||||||||||||||||
2338 | */ | - | ||||||||||||||||||||||||
2339 | - | |||||||||||||||||||||||||
2340 | /*! | - | ||||||||||||||||||||||||
2341 | \fn void QQuickItem::zChanged() | - | ||||||||||||||||||||||||
2342 | \internal | - | ||||||||||||||||||||||||
2343 | */ | - | ||||||||||||||||||||||||
2344 | - | |||||||||||||||||||||||||
2345 | /*! | - | ||||||||||||||||||||||||
2346 | \fn void QQuickItem::implicitWidthChanged() | - | ||||||||||||||||||||||||
2347 | \internal | - | ||||||||||||||||||||||||
2348 | */ | - | ||||||||||||||||||||||||
2349 | - | |||||||||||||||||||||||||
2350 | /*! | - | ||||||||||||||||||||||||
2351 | \fn void QQuickItem::implicitHeightChanged() | - | ||||||||||||||||||||||||
2352 | \internal | - | ||||||||||||||||||||||||
2353 | */ | - | ||||||||||||||||||||||||
2354 | - | |||||||||||||||||||||||||
2355 | /*! | - | ||||||||||||||||||||||||
2356 | \fn QQuickItem::QQuickItem(QQuickItem *parent) | - | ||||||||||||||||||||||||
2357 | - | |||||||||||||||||||||||||
2358 | Constructs a QQuickItem with the given \a parent. | - | ||||||||||||||||||||||||
2359 | */ | - | ||||||||||||||||||||||||
2360 | QQuickItem::QQuickItem(QQuickItem* parent) | - | ||||||||||||||||||||||||
2361 | : QObject(*(new QQuickItemPrivate), parent) | - | ||||||||||||||||||||||||
2362 | { | - | ||||||||||||||||||||||||
2363 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
2364 | d->init(parent); | - | ||||||||||||||||||||||||
2365 | } executed 71642 times by 119 tests: end of block Executed by:
| 71642 | ||||||||||||||||||||||||
2366 | - | |||||||||||||||||||||||||
2367 | /*! \internal | - | ||||||||||||||||||||||||
2368 | */ | - | ||||||||||||||||||||||||
2369 | QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent) | - | ||||||||||||||||||||||||
2370 | : QObject(dd, parent) | - | ||||||||||||||||||||||||
2371 | { | - | ||||||||||||||||||||||||
2372 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
2373 | d->init(parent); | - | ||||||||||||||||||||||||
2374 | } executed 388658 times by 101 tests: end of block Executed by:
| 388658 | ||||||||||||||||||||||||
2375 | - | |||||||||||||||||||||||||
2376 | /*! | - | ||||||||||||||||||||||||
2377 | Destroys the QQuickItem. | - | ||||||||||||||||||||||||
2378 | */ | - | ||||||||||||||||||||||||
2379 | QQuickItem::~QQuickItem() | - | ||||||||||||||||||||||||
2380 | { | - | ||||||||||||||||||||||||
2381 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
2382 | - | |||||||||||||||||||||||||
2383 | if (d->windowRefCount > 1)
| 4-417086 | ||||||||||||||||||||||||
2384 | d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow(). executed 4 times by 2 tests: d->windowRefCount = 1; Executed by:
| 4 | ||||||||||||||||||||||||
2385 | if (d->parentItem)
| 63042-354048 | ||||||||||||||||||||||||
2386 | setParentItem(nullptr); executed 63042 times by 95 tests: setParentItem(nullptr); Executed by:
| 63042 | ||||||||||||||||||||||||
2387 | else if (d->window)
| 5332-348716 | ||||||||||||||||||||||||
2388 | d->derefWindow(); executed 5332 times by 89 tests: d->derefWindow(); Executed by:
| 5332 | ||||||||||||||||||||||||
2389 | - | |||||||||||||||||||||||||
2390 | // XXX todo - optimize | - | ||||||||||||||||||||||||
2391 | while (!d->childItems.isEmpty())
| 317389-417090 | ||||||||||||||||||||||||
2392 | d->childItems.constFirst()->setParentItem(nullptr); executed 317389 times by 95 tests: d->childItems.constFirst()->setParentItem(nullptr); Executed by:
| 317389 | ||||||||||||||||||||||||
2393 | - | |||||||||||||||||||||||||
2394 | if (!d->changeListeners.isEmpty()) {
| 19836-397254 | ||||||||||||||||||||||||
2395 | const auto listeners = d->changeListeners; // NOTE: intentional copy (QTBUG-54732) | - | ||||||||||||||||||||||||
2396 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { | - | ||||||||||||||||||||||||
2397 | QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate(); | - | ||||||||||||||||||||||||
2398 | if (anchor)
| 11962-13124 | ||||||||||||||||||||||||
2399 | anchor->clearItem(this); executed 11962 times by 70 tests: anchor->clearItem(this); Executed by:
| 11962 | ||||||||||||||||||||||||
2400 | } executed 25086 times by 92 tests: end of block Executed by:
| 25086 | ||||||||||||||||||||||||
2401 | - | |||||||||||||||||||||||||
2402 | /* | - | ||||||||||||||||||||||||
2403 | update item anchors that depended on us unless they are our child (and will also be destroyed), | - | ||||||||||||||||||||||||
2404 | or our sibling, and our parent is also being destroyed. | - | ||||||||||||||||||||||||
2405 | */ | - | ||||||||||||||||||||||||
2406 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { | - | ||||||||||||||||||||||||
2407 | QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate(); | - | ||||||||||||||||||||||||
2408 | if (anchor && anchor->item && anchor->item->parentItem() && anchor->item->parentItem() != this)
| 0-13124 | ||||||||||||||||||||||||
2409 | anchor->update(); never executed: anchor->update(); | 0 | ||||||||||||||||||||||||
2410 | } executed 25086 times by 92 tests: end of block Executed by:
| 25086 | ||||||||||||||||||||||||
2411 | - | |||||||||||||||||||||||||
2412 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { | - | ||||||||||||||||||||||||
2413 | if (change.types & QQuickItemPrivate::Destroyed)
| 14-25072 | ||||||||||||||||||||||||
2414 | change.listener->itemDestroyed(this); executed 14 times by 1 test: change.listener->itemDestroyed(this); Executed by:
| 14 | ||||||||||||||||||||||||
2415 | } executed 25086 times by 92 tests: end of block Executed by:
| 25086 | ||||||||||||||||||||||||
2416 | - | |||||||||||||||||||||||||
2417 | d->changeListeners.clear(); | - | ||||||||||||||||||||||||
2418 | } executed 19836 times by 92 tests: end of block Executed by:
| 19836 | ||||||||||||||||||||||||
2419 | - | |||||||||||||||||||||||||
2420 | /* | - | ||||||||||||||||||||||||
2421 | Remove any references our transforms have to us, in case they try to | - | ||||||||||||||||||||||||
2422 | remove themselves from our list of transforms when that list has already | - | ||||||||||||||||||||||||
2423 | been destroyed after ~QQuickItem() has run. | - | ||||||||||||||||||||||||
2424 | */ | - | ||||||||||||||||||||||||
2425 | for (int ii = 0; ii < d->transforms.count(); ++ii) {
| 852-417090 | ||||||||||||||||||||||||
2426 | QQuickTransform *t = d->transforms.at(ii); | - | ||||||||||||||||||||||||
2427 | QQuickTransformPrivate *tp = QQuickTransformPrivate::get(t); | - | ||||||||||||||||||||||||
2428 | tp->items.removeOne(this); | - | ||||||||||||||||||||||||
2429 | } executed 852 times by 4 tests: end of block Executed by:
| 852 | ||||||||||||||||||||||||
2430 | - | |||||||||||||||||||||||||
2431 | if (d->extra.isAllocated()) {
| 132559-284531 | ||||||||||||||||||||||||
2432 | delete d->extra->contents; d->extra->contents = nullptr; | - | ||||||||||||||||||||||||
2433 | #if QT_CONFIG(quick_shadereffect) | - | ||||||||||||||||||||||||
2434 | delete d->extra->layer; d->extra->layer = nullptr; | - | ||||||||||||||||||||||||
2435 | #endif | - | ||||||||||||||||||||||||
2436 | } executed 132559 times by 117 tests: end of block Executed by:
| 132559 | ||||||||||||||||||||||||
2437 | - | |||||||||||||||||||||||||
2438 | delete d->_anchors; d->_anchors = nullptr; | - | ||||||||||||||||||||||||
2439 | delete d->_stateGroup; d->_stateGroup = nullptr; | - | ||||||||||||||||||||||||
2440 | } executed 417090 times by 123 tests: end of block Executed by:
| 417090 | ||||||||||||||||||||||||
2441 | - | |||||||||||||||||||||||||
2442 | /*! | - | ||||||||||||||||||||||||
2443 | \internal | - | ||||||||||||||||||||||||
2444 | */ | - | ||||||||||||||||||||||||
2445 | bool QQuickItemPrivate::canAcceptTabFocus(QQuickItem *item) | - | ||||||||||||||||||||||||
2446 | { | - | ||||||||||||||||||||||||
2447 | if (!item->window())
| 0 | ||||||||||||||||||||||||
2448 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
2449 | - | |||||||||||||||||||||||||
2450 | if (item == item->window()->contentItem())
| 0 | ||||||||||||||||||||||||
2451 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2452 | - | |||||||||||||||||||||||||
2453 | #if QT_CONFIG(accessibility) | - | ||||||||||||||||||||||||
2454 | if (QObject *acc = qmlAttachedPropertiesObject<QQuickAccessibleAttached>(item, false)) {
| 0 | ||||||||||||||||||||||||
2455 | int role = acc->property("role").toInt(); | - | ||||||||||||||||||||||||
2456 | if (role == QAccessible::EditableText
| 0 | ||||||||||||||||||||||||
2457 | || role == QAccessible::Table
| 0 | ||||||||||||||||||||||||
2458 | || role == QAccessible::List
| 0 | ||||||||||||||||||||||||
2459 | || role == QAccessible::SpinBox) {
| 0 | ||||||||||||||||||||||||
2460 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2461 | } else if (role == QAccessible::ComboBox) {
| 0 | ||||||||||||||||||||||||
2462 | QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(item); | - | ||||||||||||||||||||||||
2463 | return iface->state().editable; never executed: return iface->state().editable; | 0 | ||||||||||||||||||||||||
2464 | } | - | ||||||||||||||||||||||||
2465 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2466 | #endif | - | ||||||||||||||||||||||||
2467 | - | |||||||||||||||||||||||||
2468 | QVariant readonly = item->property("readOnly"); | - | ||||||||||||||||||||||||
2469 | if (readonly.isValid() && !readonly.toBool() && item->property("text").isValid())
| 0 | ||||||||||||||||||||||||
2470 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2471 | - | |||||||||||||||||||||||||
2472 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
2473 | } | - | ||||||||||||||||||||||||
2474 | - | |||||||||||||||||||||||||
2475 | /*! | - | ||||||||||||||||||||||||
2476 | \internal | - | ||||||||||||||||||||||||
2477 | \brief QQuickItemPrivate::focusNextPrev focuses the next/prev item in the tab-focus-chain | - | ||||||||||||||||||||||||
2478 | \param item The item that currently has the focus | - | ||||||||||||||||||||||||
2479 | \param forward The direction | - | ||||||||||||||||||||||||
2480 | \return Whether the next item in the focus chain is found or not | - | ||||||||||||||||||||||||
2481 | - | |||||||||||||||||||||||||
2482 | If \a next is true, the next item visited will be in depth-first order relative to \a item. | - | ||||||||||||||||||||||||
2483 | If \a next is false, the next item visited will be in reverse depth-first order relative to \a item. | - | ||||||||||||||||||||||||
2484 | */ | - | ||||||||||||||||||||||||
2485 | bool QQuickItemPrivate::focusNextPrev(QQuickItem *item, bool forward) | - | ||||||||||||||||||||||||
2486 | { | - | ||||||||||||||||||||||||
2487 | QQuickItem *next = QQuickItemPrivate::nextPrevItemInTabFocusChain(item, forward); | - | ||||||||||||||||||||||||
2488 | - | |||||||||||||||||||||||||
2489 | if (next == item)
| 0-198 | ||||||||||||||||||||||||
2490 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
2491 | - | |||||||||||||||||||||||||
2492 | next->forceActiveFocus(forward ? Qt::TabFocusReason : Qt::BacktabFocusReason); | - | ||||||||||||||||||||||||
2493 | - | |||||||||||||||||||||||||
2494 | return true; executed 198 times by 2 tests: return true; Executed by:
| 198 | ||||||||||||||||||||||||
2495 | } | - | ||||||||||||||||||||||||
2496 | - | |||||||||||||||||||||||||
2497 | QQuickItem *QQuickItemPrivate::nextTabChildItem(const QQuickItem *item, int start) | - | ||||||||||||||||||||||||
2498 | { | - | ||||||||||||||||||||||||
2499 | if (!item) {
| 0-1034 | ||||||||||||||||||||||||
2500 | qWarning() << "QQuickItemPrivate::nextTabChildItem called with null item."; | - | ||||||||||||||||||||||||
2501 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
2502 | } | - | ||||||||||||||||||||||||
2503 | const QList<QQuickItem *> &children = item->childItems(); | - | ||||||||||||||||||||||||
2504 | const int count = children.count(); | - | ||||||||||||||||||||||||
2505 | if (start < 0 || start >= count) {
| 0-1034 | ||||||||||||||||||||||||
2506 | qWarning() << "QQuickItemPrivate::nextTabChildItem: Start index value out of range for item" << item; | - | ||||||||||||||||||||||||
2507 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
2508 | } | - | ||||||||||||||||||||||||
2509 | while (start < count) {
| 0-1066 | ||||||||||||||||||||||||
2510 | QQuickItem *child = children.at(start); | - | ||||||||||||||||||||||||
2511 | if (!child->d_func()->isTabFence)
| 32-1034 | ||||||||||||||||||||||||
2512 | return child; executed 1034 times by 2 tests: return child; Executed by:
| 1034 | ||||||||||||||||||||||||
2513 | ++start; | - | ||||||||||||||||||||||||
2514 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||||||||
2515 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
2516 | } | - | ||||||||||||||||||||||||
2517 | - | |||||||||||||||||||||||||
2518 | QQuickItem *QQuickItemPrivate::prevTabChildItem(const QQuickItem *item, int start) | - | ||||||||||||||||||||||||
2519 | { | - | ||||||||||||||||||||||||
2520 | if (!item) {
| 0-786 | ||||||||||||||||||||||||
2521 | qWarning() << "QQuickItemPrivate::prevTabChildItem called with null item."; | - | ||||||||||||||||||||||||
2522 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
2523 | } | - | ||||||||||||||||||||||||
2524 | const QList<QQuickItem *> &children = item->childItems(); | - | ||||||||||||||||||||||||
2525 | const int count = children.count(); | - | ||||||||||||||||||||||||
2526 | if (start == -1)
| 120-666 | ||||||||||||||||||||||||
2527 | start = count - 1; executed 666 times by 2 tests: start = count - 1; Executed by:
| 666 | ||||||||||||||||||||||||
2528 | if (start < 0 || start >= count) {
| 0-786 | ||||||||||||||||||||||||
2529 | qWarning() << "QQuickItemPrivate::prevTabChildItem: Start index value out of range for item" << item; | - | ||||||||||||||||||||||||
2530 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
2531 | } | - | ||||||||||||||||||||||||
2532 | while (start >= 0) {
| 0-810 | ||||||||||||||||||||||||
2533 | QQuickItem *child = children.at(start); | - | ||||||||||||||||||||||||
2534 | if (!child->d_func()->isTabFence)
| 24-786 | ||||||||||||||||||||||||
2535 | return child; executed 786 times by 2 tests: return child; Executed by:
| 786 | ||||||||||||||||||||||||
2536 | --start; | - | ||||||||||||||||||||||||
2537 | } executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||||||||||||||||||||
2538 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
2539 | } | - | ||||||||||||||||||||||||
2540 | - | |||||||||||||||||||||||||
2541 | QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, bool forward) | - | ||||||||||||||||||||||||
2542 | { | - | ||||||||||||||||||||||||
2543 | Q_ASSERT(item); | - | ||||||||||||||||||||||||
2544 | qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: item:" << item << ", forward:" << forward; never executed: QMessageLogger(__FILE__, 2544, __PRETTY_FUNCTION__, DBG_FOCUS().categoryName()).debug() << "QQuickItemPrivate::nextPrevItemInTabFocusChain: item:" << item << ", forward:" << forward;
| 0-252 | ||||||||||||||||||||||||
2545 | - | |||||||||||||||||||||||||
2546 | if (!item->window())
| 2-250 | ||||||||||||||||||||||||
2547 | return item; executed 2 times by 1 test: return item; Executed by:
| 2 | ||||||||||||||||||||||||
2548 | const QQuickItem * const contentItem = item->window()->contentItem(); | - | ||||||||||||||||||||||||
2549 | if (!contentItem)
| 0-250 | ||||||||||||||||||||||||
2550 | return item; never executed: return item; | 0 | ||||||||||||||||||||||||
2551 | - | |||||||||||||||||||||||||
2552 | bool all = QGuiApplication::styleHints()->tabFocusBehavior() == Qt::TabFocusAllControls; | - | ||||||||||||||||||||||||
2553 | - | |||||||||||||||||||||||||
2554 | QQuickItem *from = nullptr; | - | ||||||||||||||||||||||||
2555 | bool isTabFence = item->d_func()->isTabFence; | - | ||||||||||||||||||||||||
2556 | if (forward) {
| 120-130 | ||||||||||||||||||||||||
2557 | if (!isTabFence)
| 14-106 | ||||||||||||||||||||||||
2558 | from = item->parentItem(); executed 106 times by 1 test: from = item->parentItem(); Executed by:
| 106 | ||||||||||||||||||||||||
2559 | } else { executed 120 times by 1 test: end of block Executed by:
| 120 | ||||||||||||||||||||||||
2560 | if (!item->childItems().isEmpty())
| 52-78 | ||||||||||||||||||||||||
2561 | from = item->d_func()->childItems.constFirst(); executed 52 times by 1 test: from = item->d_func()->childItems.constFirst(); Executed by:
| 52 | ||||||||||||||||||||||||
2562 | else if (!isTabFence)
| 2-76 | ||||||||||||||||||||||||
2563 | from = item->parentItem(); executed 76 times by 2 tests: from = item->parentItem(); Executed by:
| 76 | ||||||||||||||||||||||||
2564 | } executed 130 times by 2 tests: end of block Executed by:
| 130 | ||||||||||||||||||||||||
2565 | bool skip = false; | - | ||||||||||||||||||||||||
2566 | QQuickItem * startItem = item; | - | ||||||||||||||||||||||||
2567 | QQuickItem * firstFromItem = from; | - | ||||||||||||||||||||||||
2568 | QQuickItem *current = item; | - | ||||||||||||||||||||||||
2569 | qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem; never executed: QMessageLogger(__FILE__, 2569, __PRETTY_FUNCTION__, DBG_FOCUS().categoryName()).debug() << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
| 0-250 | ||||||||||||||||||||||||
2570 | qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem; never executed: QMessageLogger(__FILE__, 2570, __PRETTY_FUNCTION__, DBG_FOCUS().categoryName()).debug() << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
| 0-250 | ||||||||||||||||||||||||
2571 | do { | - | ||||||||||||||||||||||||
2572 | qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current; never executed: QMessageLogger(__FILE__, 2572, __PRETTY_FUNCTION__, DBG_FOCUS().categoryName()).debug() << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
| 0-946 | ||||||||||||||||||||||||
2573 | qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from; never executed: QMessageLogger(__FILE__, 2573, __PRETTY_FUNCTION__, DBG_FOCUS().categoryName()).debug() << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
| 0-946 | ||||||||||||||||||||||||
2574 | skip = false; | - | ||||||||||||||||||||||||
2575 | QQuickItem *last = current; | - | ||||||||||||||||||||||||
2576 | - | |||||||||||||||||||||||||
2577 | bool hasChildren = !current->childItems().isEmpty() && current->isEnabled() && current->isVisible();
| 8-682 | ||||||||||||||||||||||||
2578 | QQuickItem *firstChild = nullptr; | - | ||||||||||||||||||||||||
2579 | QQuickItem *lastChild = nullptr; | - | ||||||||||||||||||||||||
2580 | if (hasChildren) {
| 280-666 | ||||||||||||||||||||||||
2581 | firstChild = nextTabChildItem(current, 0); | - | ||||||||||||||||||||||||
2582 | if (!firstChild)
| 0-666 | ||||||||||||||||||||||||
2583 | hasChildren = false; never executed: hasChildren = false; | 0 | ||||||||||||||||||||||||
2584 | else | - | ||||||||||||||||||||||||
2585 | lastChild = prevTabChildItem(current, -1); executed 666 times by 2 tests: lastChild = prevTabChildItem(current, -1); Executed by:
| 666 | ||||||||||||||||||||||||
2586 | } | - | ||||||||||||||||||||||||
2587 | isTabFence = current->d_func()->isTabFence; | - | ||||||||||||||||||||||||
2588 | if (isTabFence && !hasChildren)
| 4-884 | ||||||||||||||||||||||||
2589 | return current; executed 4 times by 1 test: return current; Executed by:
| 4 | ||||||||||||||||||||||||
2590 | - | |||||||||||||||||||||||||
2591 | // coming from parent: check children | - | ||||||||||||||||||||||||
2592 | if (hasChildren && from == current->parentItem()) {
| 190-666 | ||||||||||||||||||||||||
2593 | if (forward) {
| 90-100 | ||||||||||||||||||||||||
2594 | current = firstChild; | - | ||||||||||||||||||||||||
2595 | } else { executed 90 times by 1 test: end of block Executed by:
| 90 | ||||||||||||||||||||||||
2596 | current = lastChild; | - | ||||||||||||||||||||||||
2597 | if (!current->childItems().isEmpty())
| 38-62 | ||||||||||||||||||||||||
2598 | skip = true; executed 38 times by 2 tests: skip = true; Executed by:
| 38 | ||||||||||||||||||||||||
2599 | } executed 100 times by 2 tests: end of block Executed by:
| 100 | ||||||||||||||||||||||||
2600 | } else if (hasChildren && forward && from != lastChild) {
| 102-476 | ||||||||||||||||||||||||
2601 | // not last child going forwards | - | ||||||||||||||||||||||||
2602 | int nextChild = current->childItems().indexOf(from) + 1; | - | ||||||||||||||||||||||||
2603 | current = nextTabChildItem(current, nextChild); | - | ||||||||||||||||||||||||
2604 | } else if (hasChildren && !forward && from != firstChild) { executed 124 times by 1 test: end of block Executed by:
| 102-352 | ||||||||||||||||||||||||
2605 | // not first child going backwards | - | ||||||||||||||||||||||||
2606 | int prevChild = current->childItems().indexOf(from) - 1; | - | ||||||||||||||||||||||||
2607 | current = prevTabChildItem(current, prevChild); | - | ||||||||||||||||||||||||
2608 | if (!current->childItems().isEmpty())
| 56-64 | ||||||||||||||||||||||||
2609 | skip = true; executed 56 times by 1 test: skip = true; Executed by:
| 56 | ||||||||||||||||||||||||
2610 | // back to the parent | - | ||||||||||||||||||||||||
2611 | } else if (QQuickItem *parent = !isTabFence ? current->parentItem() : nullptr) { executed 120 times by 2 tests: end of block Executed by:
| 24-484 | ||||||||||||||||||||||||
2612 | // we would evaluate the parent twice, thus we skip | - | ||||||||||||||||||||||||
2613 | if (forward) {
| 222-244 | ||||||||||||||||||||||||
2614 | skip = true; | - | ||||||||||||||||||||||||
2615 | } else if (QQuickItem *firstSibling = !forward ? nextTabChildItem(parent, 0) : nullptr) { executed 222 times by 1 test: end of block Executed by:
| 0-244 | ||||||||||||||||||||||||
2616 | if (last != firstSibling
| 120-124 | ||||||||||||||||||||||||
2617 | || (parent->isFocusScope() && parent->activeFocusOnTab() && parent->hasActiveFocus()))
| 0-94 | ||||||||||||||||||||||||
2618 | skip = true; executed 126 times by 2 tests: skip = true; Executed by:
| 126 | ||||||||||||||||||||||||
2619 | } executed 244 times by 2 tests: end of block Executed by:
| 244 | ||||||||||||||||||||||||
2620 | current = parent; | - | ||||||||||||||||||||||||
2621 | } else if (hasChildren) { executed 466 times by 2 tests: end of block Executed by:
| 0-466 | ||||||||||||||||||||||||
2622 | // Wrap around after checking all items forward | - | ||||||||||||||||||||||||
2623 | if (forward) {
| 14-28 | ||||||||||||||||||||||||
2624 | current = firstChild; | - | ||||||||||||||||||||||||
2625 | } else { executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||
2626 | current = lastChild; | - | ||||||||||||||||||||||||
2627 | if (!current->childItems().isEmpty())
| 14 | ||||||||||||||||||||||||
2628 | skip = true; executed 14 times by 2 tests: skip = true; Executed by:
| 14 | ||||||||||||||||||||||||
2629 | } executed 28 times by 2 tests: end of block Executed by:
| 28 | ||||||||||||||||||||||||
2630 | } | - | ||||||||||||||||||||||||
2631 | from = last; | - | ||||||||||||||||||||||||
2632 | if (current == startItem && from == firstFromItem) {
| 16-874 | ||||||||||||||||||||||||
2633 | // wrapped around, avoid endless loops | - | ||||||||||||||||||||||||
2634 | if (item == contentItem) {
| 0-16 | ||||||||||||||||||||||||
2635 | qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem"; never executed: QMessageLogger(__FILE__, 2635, __PRETTY_FUNCTION__, DBG_FOCUS().categoryName()).debug() << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
| 0 | ||||||||||||||||||||||||
2636 | return item; never executed: return item; | 0 | ||||||||||||||||||||||||
2637 | } else { | - | ||||||||||||||||||||||||
2638 | qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return " << startItem; never executed: QMessageLogger(__FILE__, 2638, __PRETTY_FUNCTION__, DBG_FOCUS().categoryName()).debug() << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return " << startItem;
| 0-16 | ||||||||||||||||||||||||
2639 | return startItem; executed 16 times by 1 test: return startItem; Executed by:
| 16 | ||||||||||||||||||||||||
2640 | } | - | ||||||||||||||||||||||||
2641 | } | - | ||||||||||||||||||||||||
2642 | if (!firstFromItem) {
| 24-902 | ||||||||||||||||||||||||
2643 | if (startItem->d_func()->isTabFence) {
| 4-20 | ||||||||||||||||||||||||
2644 | if (current == startItem)
| 8-12 | ||||||||||||||||||||||||
2645 | firstFromItem = from; executed 8 times by 1 test: firstFromItem = from; Executed by:
| 8 | ||||||||||||||||||||||||
2646 | } else { //start from root executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||
2647 | startItem = current; | - | ||||||||||||||||||||||||
2648 | firstFromItem = from; | - | ||||||||||||||||||||||||
2649 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
2650 | } | - | ||||||||||||||||||||||||
2651 | } while (skip || !current->activeFocusOnTab() || !current->isEnabled() || !current->isVisible() executed 926 times by 2 tests: end of block Executed by:
| 4-926 | ||||||||||||||||||||||||
2652 | || !(all || QQuickItemPrivate::canAcceptTabFocus(current)));
| 0-230 | ||||||||||||||||||||||||
2653 | - | |||||||||||||||||||||||||
2654 | return current; executed 230 times by 2 tests: return current; Executed by:
| 230 | ||||||||||||||||||||||||
2655 | } | - | ||||||||||||||||||||||||
2656 | - | |||||||||||||||||||||||||
2657 | /*! | - | ||||||||||||||||||||||||
2658 | \qmlproperty Item QtQuick::Item::parent | - | ||||||||||||||||||||||||
2659 | This property holds the visual parent of the item. | - | ||||||||||||||||||||||||
2660 | - | |||||||||||||||||||||||||
2661 | \note The concept of the \e {visual parent} differs from that of the | - | ||||||||||||||||||||||||
2662 | \e {QObject parent}. An item's visual parent may not necessarily be the | - | ||||||||||||||||||||||||
2663 | same as its object parent. See \l {Concepts - Visual Parent in Qt Quick} | - | ||||||||||||||||||||||||
2664 | for more details. | - | ||||||||||||||||||||||||
2665 | */ | - | ||||||||||||||||||||||||
2666 | /*! | - | ||||||||||||||||||||||||
2667 | \property QQuickItem::parent | - | ||||||||||||||||||||||||
2668 | This property holds the visual parent of the item. | - | ||||||||||||||||||||||||
2669 | - | |||||||||||||||||||||||||
2670 | \note The concept of the \e {visual parent} differs from that of the | - | ||||||||||||||||||||||||
2671 | \e {QObject parent}. An item's visual parent may not necessarily be the | - | ||||||||||||||||||||||||
2672 | same as its object parent. See \l {Concepts - Visual Parent in Qt Quick} | - | ||||||||||||||||||||||||
2673 | for more details. | - | ||||||||||||||||||||||||
2674 | */ | - | ||||||||||||||||||||||||
2675 | QQuickItem *QQuickItem::parentItem() const | - | ||||||||||||||||||||||||
2676 | { | - | ||||||||||||||||||||||||
2677 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
2678 | return d->parentItem; executed 3700894 times by 121 tests: return d->parentItem; Executed by:
| 3700894 | ||||||||||||||||||||||||
2679 | } | - | ||||||||||||||||||||||||
2680 | - | |||||||||||||||||||||||||
2681 | void QQuickItem::setParentItem(QQuickItem *parentItem) | - | ||||||||||||||||||||||||
2682 | { | - | ||||||||||||||||||||||||
2683 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
2684 | if (parentItem == d->parentItem)
| 116192-817032 | ||||||||||||||||||||||||
2685 | return; executed 116192 times by 26 tests: return; Executed by:
| 116192 | ||||||||||||||||||||||||
2686 | - | |||||||||||||||||||||||||
2687 | if (parentItem) {
| 408076-408956 | ||||||||||||||||||||||||
2688 | QQuickItem *itemAncestor = parentItem; | - | ||||||||||||||||||||||||
2689 | while (itemAncestor != nullptr) {
| 408954-626979 | ||||||||||||||||||||||||
2690 | if (Q_UNLIKELY(itemAncestor == this)) {
| 2-626977 | ||||||||||||||||||||||||
2691 | qWarning() << "QQuickItem::setParentItem: Parent" << parentItem << "is already part of the subtree of" << this; | - | ||||||||||||||||||||||||
2692 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
2693 | } | - | ||||||||||||||||||||||||
2694 | itemAncestor = itemAncestor->parentItem(); | - | ||||||||||||||||||||||||
2695 | } executed 626977 times by 106 tests: end of block Executed by:
| 626977 | ||||||||||||||||||||||||
2696 | } executed 408954 times by 106 tests: end of block Executed by:
| 408954 | ||||||||||||||||||||||||
2697 | - | |||||||||||||||||||||||||
2698 | d->removeFromDirtyList(); | - | ||||||||||||||||||||||||
2699 | - | |||||||||||||||||||||||||
2700 | QQuickItem *oldParentItem = d->parentItem; | - | ||||||||||||||||||||||||
2701 | QQuickItem *scopeFocusedItem = nullptr; | - | ||||||||||||||||||||||||
2702 | - | |||||||||||||||||||||||||
2703 | if (oldParentItem) {
| 408454-408576 | ||||||||||||||||||||||||
2704 | QQuickItemPrivate *op = QQuickItemPrivate::get(oldParentItem); | - | ||||||||||||||||||||||||
2705 | - | |||||||||||||||||||||||||
2706 | QQuickItem *scopeItem = nullptr; | - | ||||||||||||||||||||||||
2707 | - | |||||||||||||||||||||||||
2708 | if (hasFocus() || op->subFocusItem == this)
| 0-401386 | ||||||||||||||||||||||||
2709 | scopeFocusedItem = this; executed 7190 times by 19 tests: scopeFocusedItem = this; Executed by:
| 7190 | ||||||||||||||||||||||||
2710 | else if (!isFocusScope() && d->subFocusItem)
| 1846-398262 | ||||||||||||||||||||||||
2711 | scopeFocusedItem = d->subFocusItem; executed 1846 times by 14 tests: scopeFocusedItem = d->subFocusItem; Executed by:
| 1846 | ||||||||||||||||||||||||
2712 | - | |||||||||||||||||||||||||
2713 | if (scopeFocusedItem) {
| 9036-399540 | ||||||||||||||||||||||||
2714 | scopeItem = oldParentItem; | - | ||||||||||||||||||||||||
2715 | while (!scopeItem->isFocusScope() && scopeItem->parentItem())
| 1846-7190 | ||||||||||||||||||||||||
2716 | scopeItem = scopeItem->parentItem(); executed 4264 times by 11 tests: scopeItem = scopeItem->parentItem(); Executed by:
| 4264 | ||||||||||||||||||||||||
2717 | if (d->window) {
| 3102-5934 | ||||||||||||||||||||||||
2718 | QQuickWindowPrivate::get(d->window)->clearFocusInScope(scopeItem, scopeFocusedItem, Qt::OtherFocusReason, | - | ||||||||||||||||||||||||
2719 | QQuickWindowPrivate::DontChangeFocusProperty); | - | ||||||||||||||||||||||||
2720 | if (scopeFocusedItem != this)
| 1202-1900 | ||||||||||||||||||||||||
2721 | QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(this, true); executed 1202 times by 13 tests: QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(this, true); Executed by:
| 1202 | ||||||||||||||||||||||||
2722 | } else { executed 3102 times by 15 tests: end of block Executed by:
| 3102 | ||||||||||||||||||||||||
2723 | QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(scopeItem, false); | - | ||||||||||||||||||||||||
2724 | } executed 5934 times by 19 tests: end of block Executed by:
| 5934 | ||||||||||||||||||||||||
2725 | } | - | ||||||||||||||||||||||||
2726 | - | |||||||||||||||||||||||||
2727 | const bool wasVisible = isVisible(); | - | ||||||||||||||||||||||||
2728 | op->removeChild(this); | - | ||||||||||||||||||||||||
2729 | if (wasVisible) {
| 2621-405955 | ||||||||||||||||||||||||
2730 | emit oldParentItem->visibleChildrenChanged(); | - | ||||||||||||||||||||||||
2731 | } executed 405955 times by 104 tests: end of block Executed by:
| 405955 | ||||||||||||||||||||||||
2732 | } else if (d->window) { executed 408576 times by 106 tests: end of block Executed by:
| 0-408576 | ||||||||||||||||||||||||
2733 | QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this); | - | ||||||||||||||||||||||||
2734 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2735 | - | |||||||||||||||||||||||||
2736 | QQuickWindow *parentWindow = parentItem ? QQuickItemPrivate::get(parentItem)->window : nullptr;
| 408076-408954 | ||||||||||||||||||||||||
2737 | if (d->window == parentWindow) {
| 85117-731913 | ||||||||||||||||||||||||
2738 | // Avoid freeing and reallocating resources if the window stays the same. | - | ||||||||||||||||||||||||
2739 | d->parentItem = parentItem; | - | ||||||||||||||||||||||||
2740 | } else { executed 731913 times by 97 tests: end of block Executed by:
| 731913 | ||||||||||||||||||||||||
2741 | if (d->window)
| 33912-51205 | ||||||||||||||||||||||||
2742 | d->derefWindow(); executed 33912 times by 88 tests: d->derefWindow(); Executed by:
| 33912 | ||||||||||||||||||||||||
2743 | d->parentItem = parentItem; | - | ||||||||||||||||||||||||
2744 | if (parentWindow)
| 33908-51209 | ||||||||||||||||||||||||
2745 | d->refWindow(parentWindow); executed 51209 times by 90 tests: d->refWindow(parentWindow); Executed by:
| 51209 | ||||||||||||||||||||||||
2746 | } executed 85117 times by 90 tests: end of block Executed by:
| 85117 | ||||||||||||||||||||||||
2747 | - | |||||||||||||||||||||||||
2748 | d->dirty(QQuickItemPrivate::ParentChanged); | - | ||||||||||||||||||||||||
2749 | - | |||||||||||||||||||||||||
2750 | if (d->parentItem)
| 408076-408954 | ||||||||||||||||||||||||
2751 | QQuickItemPrivate::get(d->parentItem)->addChild(this); executed 408954 times by 106 tests: QQuickItemPrivate::get(d->parentItem)->addChild(this); Executed by:
| 408954 | ||||||||||||||||||||||||
2752 | else if (d->window)
| 2-408074 | ||||||||||||||||||||||||
2753 | QQuickWindowPrivate::get(d->window)->parentlessItems.insert(this); executed 2 times by 1 test: QQuickWindowPrivate::get(d->window)->parentlessItems.insert(this); Executed by:
| 2 | ||||||||||||||||||||||||
2754 | - | |||||||||||||||||||||||||
2755 | d->setEffectiveVisibleRecur(d->calcEffectiveVisible()); | - | ||||||||||||||||||||||||
2756 | d->setEffectiveEnableRecur(nullptr, d->calcEffectiveEnable()); | - | ||||||||||||||||||||||||
2757 | - | |||||||||||||||||||||||||
2758 | if (d->parentItem) {
| 408076-408954 | ||||||||||||||||||||||||
2759 | if (!scopeFocusedItem) {
| 10-408944 | ||||||||||||||||||||||||
2760 | if (hasFocus())
| 1872-407072 | ||||||||||||||||||||||||
2761 | scopeFocusedItem = this; executed 1872 times by 12 tests: scopeFocusedItem = this; Executed by:
| 1872 | ||||||||||||||||||||||||
2762 | else if (!isFocusScope() && d->subFocusItem)
| 1242-403930 | ||||||||||||||||||||||||
2763 | scopeFocusedItem = d->subFocusItem; executed 1242 times by 12 tests: scopeFocusedItem = d->subFocusItem; Executed by:
| 1242 | ||||||||||||||||||||||||
2764 | } executed 408944 times by 106 tests: end of block Executed by:
| 408944 | ||||||||||||||||||||||||
2765 | - | |||||||||||||||||||||||||
2766 | if (scopeFocusedItem) {
| 3124-405830 | ||||||||||||||||||||||||
2767 | // We need to test whether this item becomes scope focused | - | ||||||||||||||||||||||||
2768 | QQuickItem *scopeItem = d->parentItem; | - | ||||||||||||||||||||||||
2769 | while (!scopeItem->isFocusScope() && scopeItem->parentItem())
| 44-1876 | ||||||||||||||||||||||||
2770 | scopeItem = scopeItem->parentItem(); executed 44 times by 4 tests: scopeItem = scopeItem->parentItem(); Executed by:
| 44 | ||||||||||||||||||||||||
2771 | - | |||||||||||||||||||||||||
2772 | if (QQuickItemPrivate::get(scopeItem)->subFocusItem
| 40-3084 | ||||||||||||||||||||||||
2773 | || (!scopeItem->isFocusScope() && scopeItem->hasFocus())) {
| 4-1858 | ||||||||||||||||||||||||
2774 | if (scopeFocusedItem != this)
| 6-38 | ||||||||||||||||||||||||
2775 | QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(this, false); executed 6 times by 2 tests: QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(this, false); Executed by:
| 6 | ||||||||||||||||||||||||
2776 | QQuickItemPrivate::get(scopeFocusedItem)->focus = false; | - | ||||||||||||||||||||||||
2777 | emit scopeFocusedItem->focusChanged(false); | - | ||||||||||||||||||||||||
2778 | } else { executed 44 times by 4 tests: end of block Executed by:
| 44 | ||||||||||||||||||||||||
2779 | if (d->window) {
| 1284-1796 | ||||||||||||||||||||||||
2780 | QQuickWindowPrivate::get(d->window)->setFocusInScope(scopeItem, scopeFocusedItem, Qt::OtherFocusReason, | - | ||||||||||||||||||||||||
2781 | QQuickWindowPrivate::DontChangeFocusProperty); | - | ||||||||||||||||||||||||
2782 | } else { executed 1796 times by 12 tests: end of block Executed by:
| 1796 | ||||||||||||||||||||||||
2783 | QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(scopeItem, true); | - | ||||||||||||||||||||||||
2784 | } executed 1284 times by 12 tests: end of block Executed by:
| 1284 | ||||||||||||||||||||||||
2785 | } | - | ||||||||||||||||||||||||
2786 | } | - | ||||||||||||||||||||||||
2787 | } executed 408954 times by 106 tests: end of block Executed by:
| 408954 | ||||||||||||||||||||||||
2788 | - | |||||||||||||||||||||||||
2789 | if (d->parentItem)
| 408076-408954 | ||||||||||||||||||||||||
2790 | d->resolveLayoutMirror(); executed 408954 times by 106 tests: d->resolveLayoutMirror(); Executed by:
| 408954 | ||||||||||||||||||||||||
2791 | - | |||||||||||||||||||||||||
2792 | d->itemChange(ItemParentHasChanged, d->parentItem); | - | ||||||||||||||||||||||||
2793 | - | |||||||||||||||||||||||||
2794 | emit parentChanged(d->parentItem); | - | ||||||||||||||||||||||||
2795 | if (isVisible() && d->parentItem)
| 2326-814704 | ||||||||||||||||||||||||
2796 | emit d->parentItem->visibleChildrenChanged(); executed 408496 times by 104 tests: d->parentItem->visibleChildrenChanged(); Executed by:
| 408496 | ||||||||||||||||||||||||
2797 | } executed 817030 times by 106 tests: end of block Executed by:
| 817030 | ||||||||||||||||||||||||
2798 | - | |||||||||||||||||||||||||
2799 | /*! | - | ||||||||||||||||||||||||
2800 | Moves the specified \a sibling item to the index before this item | - | ||||||||||||||||||||||||
2801 | within the list of children. The order of children affects both the | - | ||||||||||||||||||||||||
2802 | visual stacking order and tab focus navigation order. | - | ||||||||||||||||||||||||
2803 | - | |||||||||||||||||||||||||
2804 | Assuming the z values of both items are the same, this will cause \a | - | ||||||||||||||||||||||||
2805 | sibling to be rendered above this item. | - | ||||||||||||||||||||||||
2806 | - | |||||||||||||||||||||||||
2807 | If both items have activeFocusOnTab set to \c true, this will also cause | - | ||||||||||||||||||||||||
2808 | the tab focus order to change, with \a sibling receiving focus after this | - | ||||||||||||||||||||||||
2809 | item. | - | ||||||||||||||||||||||||
2810 | - | |||||||||||||||||||||||||
2811 | The given \a sibling must be a sibling of this item; that is, they must | - | ||||||||||||||||||||||||
2812 | have the same immediate \l parent. | - | ||||||||||||||||||||||||
2813 | - | |||||||||||||||||||||||||
2814 | \sa {Concepts - Visual Parent in Qt Quick} | - | ||||||||||||||||||||||||
2815 | */ | - | ||||||||||||||||||||||||
2816 | void QQuickItem::stackBefore(const QQuickItem *sibling) | - | ||||||||||||||||||||||||
2817 | { | - | ||||||||||||||||||||||||
2818 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
2819 | if (!sibling || sibling == this || !d->parentItem || d->parentItem != QQuickItemPrivate::get(sibling)->parentItem) {
| 0-892 | ||||||||||||||||||||||||
2820 | qWarning().nospace() << "QQuickItem::stackBefore: Cannot stack " | - | ||||||||||||||||||||||||
2821 | << this << " before " << sibling << ", which must be a sibling"; | - | ||||||||||||||||||||||||
2822 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2823 | } | - | ||||||||||||||||||||||||
2824 | - | |||||||||||||||||||||||||
2825 | QQuickItemPrivate *parentPrivate = QQuickItemPrivate::get(d->parentItem); | - | ||||||||||||||||||||||||
2826 | - | |||||||||||||||||||||||||
2827 | int myIndex = parentPrivate->childItems.lastIndexOf(this); | - | ||||||||||||||||||||||||
2828 | int siblingIndex = parentPrivate->childItems.lastIndexOf(const_cast<QQuickItem *>(sibling)); | - | ||||||||||||||||||||||||
2829 | - | |||||||||||||||||||||||||
2830 | Q_ASSERT(myIndex != -1 && siblingIndex != -1); | - | ||||||||||||||||||||||||
2831 | - | |||||||||||||||||||||||||
2832 | if (myIndex == siblingIndex - 1)
| 0-892 | ||||||||||||||||||||||||
2833 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2834 | - | |||||||||||||||||||||||||
2835 | parentPrivate->childItems.move(myIndex, myIndex < siblingIndex ? siblingIndex - 1 : siblingIndex); | - | ||||||||||||||||||||||||
2836 | - | |||||||||||||||||||||||||
2837 | parentPrivate->dirty(QQuickItemPrivate::ChildrenStackingChanged); | - | ||||||||||||||||||||||||
2838 | parentPrivate->markSortedChildrenDirty(this); | - | ||||||||||||||||||||||||
2839 | - | |||||||||||||||||||||||||
2840 | for (int ii = qMin(siblingIndex, myIndex); ii < parentPrivate->childItems.count(); ++ii)
| 892-4330 | ||||||||||||||||||||||||
2841 | QQuickItemPrivate::get(parentPrivate->childItems.at(ii))->siblingOrderChanged(); executed 4330 times by 17 tests: QQuickItemPrivate::get(parentPrivate->childItems.at(ii))->siblingOrderChanged(); Executed by:
| 4330 | ||||||||||||||||||||||||
2842 | } executed 892 times by 17 tests: end of block Executed by:
| 892 | ||||||||||||||||||||||||
2843 | - | |||||||||||||||||||||||||
2844 | /*! | - | ||||||||||||||||||||||||
2845 | Moves the specified \a sibling item to the index after this item | - | ||||||||||||||||||||||||
2846 | within the list of children. The order of children affects both the | - | ||||||||||||||||||||||||
2847 | visual stacking order and tab focus navigation order. | - | ||||||||||||||||||||||||
2848 | - | |||||||||||||||||||||||||
2849 | Assuming the z values of both items are the same, this will cause \a | - | ||||||||||||||||||||||||
2850 | sibling to be rendered below this item. | - | ||||||||||||||||||||||||
2851 | - | |||||||||||||||||||||||||
2852 | If both items have activeFocusOnTab set to \c true, this will also cause | - | ||||||||||||||||||||||||
2853 | the tab focus order to change, with \a sibling receiving focus before this | - | ||||||||||||||||||||||||
2854 | item. | - | ||||||||||||||||||||||||
2855 | - | |||||||||||||||||||||||||
2856 | The given \a sibling must be a sibling of this item; that is, they must | - | ||||||||||||||||||||||||
2857 | have the same immediate \l parent. | - | ||||||||||||||||||||||||
2858 | - | |||||||||||||||||||||||||
2859 | \sa {Concepts - Visual Parent in Qt Quick} | - | ||||||||||||||||||||||||
2860 | */ | - | ||||||||||||||||||||||||
2861 | void QQuickItem::stackAfter(const QQuickItem *sibling) | - | ||||||||||||||||||||||||
2862 | { | - | ||||||||||||||||||||||||
2863 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
2864 | if (!sibling || sibling == this || !d->parentItem || d->parentItem != QQuickItemPrivate::get(sibling)->parentItem) {
| 0-8530 | ||||||||||||||||||||||||
2865 | qWarning().nospace() << "QQuickItem::stackAfter: Cannot stack " | - | ||||||||||||||||||||||||
2866 | << this << " after " << sibling << ", which must be a sibling"; | - | ||||||||||||||||||||||||
2867 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2868 | } | - | ||||||||||||||||||||||||
2869 | - | |||||||||||||||||||||||||
2870 | QQuickItemPrivate *parentPrivate = QQuickItemPrivate::get(d->parentItem); | - | ||||||||||||||||||||||||
2871 | - | |||||||||||||||||||||||||
2872 | int myIndex = parentPrivate->childItems.lastIndexOf(this); | - | ||||||||||||||||||||||||
2873 | int siblingIndex = parentPrivate->childItems.lastIndexOf(const_cast<QQuickItem *>(sibling)); | - | ||||||||||||||||||||||||
2874 | - | |||||||||||||||||||||||||
2875 | Q_ASSERT(myIndex != -1 && siblingIndex != -1); | - | ||||||||||||||||||||||||
2876 | - | |||||||||||||||||||||||||
2877 | if (myIndex == siblingIndex + 1)
| 104-8426 | ||||||||||||||||||||||||
2878 | return; executed 104 times by 2 tests: return; Executed by:
| 104 | ||||||||||||||||||||||||
2879 | - | |||||||||||||||||||||||||
2880 | parentPrivate->childItems.move(myIndex, myIndex > siblingIndex ? siblingIndex + 1 : siblingIndex); | - | ||||||||||||||||||||||||
2881 | - | |||||||||||||||||||||||||
2882 | parentPrivate->dirty(QQuickItemPrivate::ChildrenStackingChanged); | - | ||||||||||||||||||||||||
2883 | parentPrivate->markSortedChildrenDirty(this); | - | ||||||||||||||||||||||||
2884 | - | |||||||||||||||||||||||||
2885 | for (int ii = qMin(myIndex, siblingIndex + 1); ii < parentPrivate->childItems.count(); ++ii)
| 8426-18350 | ||||||||||||||||||||||||
2886 | QQuickItemPrivate::get(parentPrivate->childItems.at(ii))->siblingOrderChanged(); executed 18350 times by 17 tests: QQuickItemPrivate::get(parentPrivate->childItems.at(ii))->siblingOrderChanged(); Executed by:
| 18350 | ||||||||||||||||||||||||
2887 | } executed 8426 times by 17 tests: end of block Executed by:
| 8426 | ||||||||||||||||||||||||
2888 | - | |||||||||||||||||||||||||
2889 | /*! \fn void QQuickItem::windowChanged(QQuickWindow *window) | - | ||||||||||||||||||||||||
2890 | This signal is emitted when the item's \a window changes. | - | ||||||||||||||||||||||||
2891 | */ | - | ||||||||||||||||||||||||
2892 | - | |||||||||||||||||||||||||
2893 | /*! | - | ||||||||||||||||||||||||
2894 | Returns the window in which this item is rendered. | - | ||||||||||||||||||||||||
2895 | - | |||||||||||||||||||||||||
2896 | The item does not have a window until it has been assigned into a scene. The | - | ||||||||||||||||||||||||
2897 | \l windowChanged() signal provides a notification both when the item is entered | - | ||||||||||||||||||||||||
2898 | into a scene and when it is removed from a scene. | - | ||||||||||||||||||||||||
2899 | */ | - | ||||||||||||||||||||||||
2900 | QQuickWindow *QQuickItem::window() const | - | ||||||||||||||||||||||||
2901 | { | - | ||||||||||||||||||||||||
2902 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
2903 | return d->window; executed 57774 times by 93 tests: return d->window; Executed by:
| 57774 | ||||||||||||||||||||||||
2904 | } | - | ||||||||||||||||||||||||
2905 | - | |||||||||||||||||||||||||
2906 | static bool itemZOrder_sort(QQuickItem *lhs, QQuickItem *rhs) | - | ||||||||||||||||||||||||
2907 | { | - | ||||||||||||||||||||||||
2908 | return lhs->z() < rhs->z(); executed 363127 times by 13 tests: return lhs->z() < rhs->z(); Executed by:
| 363127 | ||||||||||||||||||||||||
2909 | } | - | ||||||||||||||||||||||||
2910 | - | |||||||||||||||||||||||||
2911 | QList<QQuickItem *> QQuickItemPrivate::paintOrderChildItems() const | - | ||||||||||||||||||||||||
2912 | { | - | ||||||||||||||||||||||||
2913 | if (sortedChildItems)
| 7230-1165296 | ||||||||||||||||||||||||
2914 | return *sortedChildItems; executed 1165296 times by 79 tests: return *sortedChildItems; Executed by:
| 1165296 | ||||||||||||||||||||||||
2915 | - | |||||||||||||||||||||||||
2916 | // If none of the items have set Z then the paint order list is the same as | - | ||||||||||||||||||||||||
2917 | // the childItems list. This is by far the most common case. | - | ||||||||||||||||||||||||
2918 | bool haveZ = false; | - | ||||||||||||||||||||||||
2919 | for (int i = 0; i < childItems.count(); ++i) {
| 40-8763 | ||||||||||||||||||||||||
2920 | if (QQuickItemPrivate::get(childItems.at(i))->z() != 0.) {
| 1573-7190 | ||||||||||||||||||||||||
2921 | haveZ = true; | - | ||||||||||||||||||||||||
2922 | break; executed 7190 times by 13 tests: break; Executed by:
| 7190 | ||||||||||||||||||||||||
2923 | } | - | ||||||||||||||||||||||||
2924 | } executed 1573 times by 9 tests: end of block Executed by:
| 1573 | ||||||||||||||||||||||||
2925 | if (haveZ) {
| 40-7190 | ||||||||||||||||||||||||
2926 | sortedChildItems = new QList<QQuickItem*>(childItems); | - | ||||||||||||||||||||||||
2927 | std::stable_sort(sortedChildItems->begin(), sortedChildItems->end(), itemZOrder_sort); | - | ||||||||||||||||||||||||
2928 | return *sortedChildItems; executed 7190 times by 13 tests: return *sortedChildItems; Executed by:
| 7190 | ||||||||||||||||||||||||
2929 | } | - | ||||||||||||||||||||||||
2930 | - | |||||||||||||||||||||||||
2931 | sortedChildItems = const_cast<QList<QQuickItem*>*>(&childItems); | - | ||||||||||||||||||||||||
2932 | - | |||||||||||||||||||||||||
2933 | return childItems; executed 40 times by 4 tests: return childItems; Executed by:
| 40 | ||||||||||||||||||||||||
2934 | } | - | ||||||||||||||||||||||||
2935 | - | |||||||||||||||||||||||||
2936 | void QQuickItemPrivate::addChild(QQuickItem *child) | - | ||||||||||||||||||||||||
2937 | { | - | ||||||||||||||||||||||||
2938 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
2939 | - | |||||||||||||||||||||||||
2940 | Q_ASSERT(!childItems.contains(child)); | - | ||||||||||||||||||||||||
2941 | - | |||||||||||||||||||||||||
2942 | childItems.append(child); | - | ||||||||||||||||||||||||
2943 | - | |||||||||||||||||||||||||
2944 | QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(child); | - | ||||||||||||||||||||||||
2945 | - | |||||||||||||||||||||||||
2946 | #if QT_CONFIG(cursor) | - | ||||||||||||||||||||||||
2947 | // if the added child has a cursor and we do not currently have any children | - | ||||||||||||||||||||||||
2948 | // with cursors, bubble the notification up | - | ||||||||||||||||||||||||
2949 | if (childPrivate->subtreeCursorEnabled && !subtreeCursorEnabled)
| 1400-404604 | ||||||||||||||||||||||||
2950 | setHasCursorInChild(true); executed 2950 times by 23 tests: setHasCursorInChild(true); Executed by:
| 2950 | ||||||||||||||||||||||||
2951 | #endif | - | ||||||||||||||||||||||||
2952 | - | |||||||||||||||||||||||||
2953 | if (childPrivate->subtreeHoverEnabled && !subtreeHoverEnabled)
| 274-407760 | ||||||||||||||||||||||||
2954 | setHasHoverInChild(true); executed 920 times by 12 tests: setHasHoverInChild(true); Executed by:
| 920 | ||||||||||||||||||||||||
2955 | - | |||||||||||||||||||||||||
2956 | childPrivate->recursiveRefFromEffectItem(extra.value().recursiveEffectRefCount); | - | ||||||||||||||||||||||||
2957 | markSortedChildrenDirty(child); | - | ||||||||||||||||||||||||
2958 | dirty(QQuickItemPrivate::ChildrenChanged); | - | ||||||||||||||||||||||||
2959 | - | |||||||||||||||||||||||||
2960 | itemChange(QQuickItem::ItemChildAddedChange, child); | - | ||||||||||||||||||||||||
2961 | - | |||||||||||||||||||||||||
2962 | emit q->childrenChanged(); | - | ||||||||||||||||||||||||
2963 | } executed 408954 times by 106 tests: end of block Executed by:
| 408954 | ||||||||||||||||||||||||
2964 | - | |||||||||||||||||||||||||
2965 | void QQuickItemPrivate::removeChild(QQuickItem *child) | - | ||||||||||||||||||||||||
2966 | { | - | ||||||||||||||||||||||||
2967 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
2968 | - | |||||||||||||||||||||||||
2969 | Q_ASSERT(child); | - | ||||||||||||||||||||||||
2970 | Q_ASSERT(childItems.contains(child)); | - | ||||||||||||||||||||||||
2971 | childItems.removeOne(child); | - | ||||||||||||||||||||||||
2972 | Q_ASSERT(!childItems.contains(child)); | - | ||||||||||||||||||||||||
2973 | - | |||||||||||||||||||||||||
2974 | QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(child); | - | ||||||||||||||||||||||||
2975 | - | |||||||||||||||||||||||||
2976 | #if QT_CONFIG(cursor) | - | ||||||||||||||||||||||||
2977 | // turn it off, if nothing else is using it | - | ||||||||||||||||||||||||
2978 | if (childPrivate->subtreeCursorEnabled && subtreeCursorEnabled)
| 0-404026 | ||||||||||||||||||||||||
2979 | setHasCursorInChild(false); executed 4550 times by 21 tests: setHasCursorInChild(false); Executed by:
| 4550 | ||||||||||||||||||||||||
2980 | #endif | - | ||||||||||||||||||||||||
2981 | - | |||||||||||||||||||||||||
2982 | if (childPrivate->subtreeHoverEnabled && subtreeHoverEnabled)
| 0-406484 | ||||||||||||||||||||||||
2983 | setHasHoverInChild(false); executed 2092 times by 13 tests: setHasHoverInChild(false); Executed by:
| 2092 | ||||||||||||||||||||||||
2984 | - | |||||||||||||||||||||||||
2985 | childPrivate->recursiveRefFromEffectItem(-extra.value().recursiveEffectRefCount); | - | ||||||||||||||||||||||||
2986 | markSortedChildrenDirty(child); | - | ||||||||||||||||||||||||
2987 | dirty(QQuickItemPrivate::ChildrenChanged); | - | ||||||||||||||||||||||||
2988 | - | |||||||||||||||||||||||||
2989 | itemChange(QQuickItem::ItemChildRemovedChange, child); | - | ||||||||||||||||||||||||
2990 | - | |||||||||||||||||||||||||
2991 | emit q->childrenChanged(); | - | ||||||||||||||||||||||||
2992 | } executed 408576 times by 106 tests: end of block Executed by:
| 408576 | ||||||||||||||||||||||||
2993 | - | |||||||||||||||||||||||||
2994 | void QQuickItemPrivate::refWindow(QQuickWindow *c) | - | ||||||||||||||||||||||||
2995 | { | - | ||||||||||||||||||||||||
2996 | // An item needs a window if it is referenced by another item which has a window. | - | ||||||||||||||||||||||||
2997 | // Typically the item is referenced by a parent, but can also be referenced by a | - | ||||||||||||||||||||||||
2998 | // ShaderEffect or ShaderEffectSource. 'windowRefCount' counts how many items with | - | ||||||||||||||||||||||||
2999 | // a window is referencing this item. When the reference count goes from zero to one, | - | ||||||||||||||||||||||||
3000 | // or one to zero, the window of this item is updated and propagated to the children. | - | ||||||||||||||||||||||||
3001 | // As long as the reference count stays above zero, the window is unchanged. | - | ||||||||||||||||||||||||
3002 | // refWindow() increments the reference count. | - | ||||||||||||||||||||||||
3003 | // derefWindow() decrements the reference count. | - | ||||||||||||||||||||||||
3004 | - | |||||||||||||||||||||||||
3005 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
3006 | Q_ASSERT((window != nullptr) == (windowRefCount > 0)); | - | ||||||||||||||||||||||||
3007 | Q_ASSERT(c); | - | ||||||||||||||||||||||||
3008 | if (++windowRefCount > 1) {
| 161-400819 | ||||||||||||||||||||||||
3009 | if (c != window)
| 0-161 | ||||||||||||||||||||||||
3010 | qWarning("QQuickItem: Cannot use same item on different windows at the same time."); never executed: QMessageLogger(__FILE__, 3010, __PRETTY_FUNCTION__).warning("QQuickItem: Cannot use same item on different windows at the same time."); | 0 | ||||||||||||||||||||||||
3011 | return; // Window already set. executed 161 times by 5 tests: return; Executed by:
| 161 | ||||||||||||||||||||||||
3012 | } | - | ||||||||||||||||||||||||
3013 | - | |||||||||||||||||||||||||
3014 | Q_ASSERT(window == nullptr); | - | ||||||||||||||||||||||||
3015 | window = c; | - | ||||||||||||||||||||||||
3016 | - | |||||||||||||||||||||||||
3017 | if (polishScheduled)
| 176827-223992 | ||||||||||||||||||||||||
3018 | QQuickWindowPrivate::get(window)->itemsToPolish.append(q); executed 176827 times by 37 tests: QQuickWindowPrivate::get(window)->itemsToPolish.append(q); Executed by:
| 176827 | ||||||||||||||||||||||||
3019 | - | |||||||||||||||||||||||||
3020 | if (!parentItem)
| 16-400803 | ||||||||||||||||||||||||
3021 | QQuickWindowPrivate::get(window)->parentlessItems.insert(q); executed 16 times by 3 tests: QQuickWindowPrivate::get(window)->parentlessItems.insert(q); Executed by:
| 16 | ||||||||||||||||||||||||
3022 | - | |||||||||||||||||||||||||
3023 | for (int ii = 0; ii < childItems.count(); ++ii) {
| 349594-400819 | ||||||||||||||||||||||||
3024 | QQuickItem *child = childItems.at(ii); | - | ||||||||||||||||||||||||
3025 | QQuickItemPrivate::get(child)->refWindow(c); | - | ||||||||||||||||||||||||
3026 | } executed 349594 times by 79 tests: end of block Executed by:
| 349594 | ||||||||||||||||||||||||
3027 | - | |||||||||||||||||||||||||
3028 | dirty(Window); | - | ||||||||||||||||||||||||
3029 | - | |||||||||||||||||||||||||
3030 | if (extra.isAllocated() && extra->screenAttached)
| 8-280676 | ||||||||||||||||||||||||
3031 | extra->screenAttached->windowChanged(c); executed 8 times by 2 tests: extra->screenAttached->windowChanged(c); Executed by:
| 8 | ||||||||||||||||||||||||
3032 | itemChange(QQuickItem::ItemSceneChange, c); | - | ||||||||||||||||||||||||
3033 | } executed 400819 times by 90 tests: end of block Executed by:
| 400819 | ||||||||||||||||||||||||
3034 | - | |||||||||||||||||||||||||
3035 | void QQuickItemPrivate::derefWindow() | - | ||||||||||||||||||||||||
3036 | { | - | ||||||||||||||||||||||||
3037 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
3038 | Q_ASSERT((window != nullptr) == (windowRefCount > 0)); | - | ||||||||||||||||||||||||
3039 | - | |||||||||||||||||||||||||
3040 | if (!window)
| 2-406178 | ||||||||||||||||||||||||
3041 | return; // This can happen when destroying recursive shader effect sources. executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
3042 | - | |||||||||||||||||||||||||
3043 | if (--windowRefCount > 0)
| 155-406023 | ||||||||||||||||||||||||
3044 | return; // There are still other references, so don't set window to null yet. executed 155 times by 4 tests: return; Executed by:
| 155 | ||||||||||||||||||||||||
3045 | - | |||||||||||||||||||||||||
3046 | q->releaseResources(); | - | ||||||||||||||||||||||||
3047 | removeFromDirtyList(); | - | ||||||||||||||||||||||||
3048 | QQuickWindowPrivate *c = QQuickWindowPrivate::get(window); | - | ||||||||||||||||||||||||
3049 | if (polishScheduled)
| 72348-333675 | ||||||||||||||||||||||||
3050 | c->itemsToPolish.removeOne(q); executed 72348 times by 23 tests: c->itemsToPolish.removeOne(q); Executed by:
| 72348 | ||||||||||||||||||||||||
3051 | c->removeGrabber(q); | - | ||||||||||||||||||||||||
3052 | #if QT_CONFIG(cursor) | - | ||||||||||||||||||||||||
3053 | if (c->cursorItem == q) {
| 124-405899 | ||||||||||||||||||||||||
3054 | c->cursorItem = nullptr; | - | ||||||||||||||||||||||||
3055 | window->unsetCursor(); | - | ||||||||||||||||||||||||
3056 | } executed 124 times by 8 tests: end of block Executed by:
| 124 | ||||||||||||||||||||||||
3057 | #endif | - | ||||||||||||||||||||||||
3058 | c->hoverItems.removeAll(q); | - | ||||||||||||||||||||||||
3059 | if (itemNodeInstance)
| 89435-316588 | ||||||||||||||||||||||||
3060 | c->cleanup(itemNodeInstance); executed 316588 times by 74 tests: c->cleanup(itemNodeInstance); Executed by:
| 316588 | ||||||||||||||||||||||||
3061 | if (!parentItem)
| 5348-400675 | ||||||||||||||||||||||||
3062 | c->parentlessItems.remove(q); executed 5348 times by 89 tests: c->parentlessItems.remove(q); Executed by:
| 5348 | ||||||||||||||||||||||||
3063 | - | |||||||||||||||||||||||||
3064 | window = nullptr; | - | ||||||||||||||||||||||||
3065 | - | |||||||||||||||||||||||||
3066 | itemNodeInstance = nullptr; | - | ||||||||||||||||||||||||
3067 | - | |||||||||||||||||||||||||
3068 | if (extra.isAllocated()) {
| 130889-275134 | ||||||||||||||||||||||||
3069 | extra->opacityNode = nullptr; | - | ||||||||||||||||||||||||
3070 | extra->clipNode = nullptr; | - | ||||||||||||||||||||||||
3071 | extra->rootNode = nullptr; | - | ||||||||||||||||||||||||
3072 | } executed 130889 times by 89 tests: end of block Executed by:
| 130889 | ||||||||||||||||||||||||
3073 | - | |||||||||||||||||||||||||
3074 | paintNode = nullptr; | - | ||||||||||||||||||||||||
3075 | - | |||||||||||||||||||||||||
3076 | for (int ii = 0; ii < childItems.count(); ++ii) {
| 366765-406023 | ||||||||||||||||||||||||
3077 | QQuickItem *child = childItems.at(ii); | - | ||||||||||||||||||||||||
3078 | QQuickItemPrivate::get(child)->derefWindow(); | - | ||||||||||||||||||||||||
3079 | } executed 366765 times by 78 tests: end of block Executed by:
| 366765 | ||||||||||||||||||||||||
3080 | - | |||||||||||||||||||||||||
3081 | dirty(Window); | - | ||||||||||||||||||||||||
3082 | - | |||||||||||||||||||||||||
3083 | if (extra.isAllocated() && extra->screenAttached)
| 38-275134 | ||||||||||||||||||||||||
3084 | extra->screenAttached->windowChanged(nullptr); executed 38 times by 3 tests: extra->screenAttached->windowChanged(nullptr); Executed by:
| 38 | ||||||||||||||||||||||||
3085 | itemChange(QQuickItem::ItemSceneChange, (QQuickWindow *)nullptr); | - | ||||||||||||||||||||||||
3086 | } executed 406023 times by 89 tests: end of block Executed by:
| 406023 | ||||||||||||||||||||||||
3087 | - | |||||||||||||||||||||||||
3088 | - | |||||||||||||||||||||||||
3089 | /*! | - | ||||||||||||||||||||||||
3090 | Returns a transform that maps points from window space into item space. | - | ||||||||||||||||||||||||
3091 | */ | - | ||||||||||||||||||||||||
3092 | QTransform QQuickItemPrivate::windowToItemTransform() const | - | ||||||||||||||||||||||||
3093 | { | - | ||||||||||||||||||||||||
3094 | // XXX todo - optimize | - | ||||||||||||||||||||||||
3095 | return itemToWindowTransform().inverted(); executed 158822 times by 46 tests: return itemToWindowTransform().inverted(); Executed by:
| 158822 | ||||||||||||||||||||||||
3096 | } | - | ||||||||||||||||||||||||
3097 | - | |||||||||||||||||||||||||
3098 | /*! | - | ||||||||||||||||||||||||
3099 | Returns a transform that maps points from item space into window space. | - | ||||||||||||||||||||||||
3100 | */ | - | ||||||||||||||||||||||||
3101 | QTransform QQuickItemPrivate::itemToWindowTransform() const | - | ||||||||||||||||||||||||
3102 | { | - | ||||||||||||||||||||||||
3103 | // XXX todo | - | ||||||||||||||||||||||||
3104 | QTransform rv = parentItem?QQuickItemPrivate::get(parentItem)->itemToWindowTransform():QTransform();
| 226571-643497 | ||||||||||||||||||||||||
3105 | itemToParentTransform(rv); | - | ||||||||||||||||||||||||
3106 | return rv; executed 870068 times by 60 tests: return rv; Executed by:
| 870068 | ||||||||||||||||||||||||
3107 | } | - | ||||||||||||||||||||||||
3108 | - | |||||||||||||||||||||||||
3109 | /*! | - | ||||||||||||||||||||||||
3110 | Motifies \a t with this items local transform relative to its parent. | - | ||||||||||||||||||||||||
3111 | */ | - | ||||||||||||||||||||||||
3112 | void QQuickItemPrivate::itemToParentTransform(QTransform &t) const | - | ||||||||||||||||||||||||
3113 | { | - | ||||||||||||||||||||||||
3114 | if (x || y) | - | ||||||||||||||||||||||||
3115 | t.translate(x, y); executed 132415 times by 29 tests: t.translate(x, y); Executed by:
| 132415 | ||||||||||||||||||||||||
3116 | - | |||||||||||||||||||||||||
3117 | if (!transforms.isEmpty()) {
| 125-869972 | ||||||||||||||||||||||||
3118 | QMatrix4x4 m(t); | - | ||||||||||||||||||||||||
3119 | for (int ii = transforms.count() - 1; ii >= 0; --ii)
| 125-127 | ||||||||||||||||||||||||
3120 | transforms.at(ii)->applyTo(&m); executed 127 times by 5 tests: transforms.at(ii)->applyTo(&m); Executed by:
| 127 | ||||||||||||||||||||||||
3121 | t = m.toTransform(); | - | ||||||||||||||||||||||||
3122 | } executed 125 times by 5 tests: end of block Executed by:
| 125 | ||||||||||||||||||||||||
3123 | - | |||||||||||||||||||||||||
3124 | if (scale() != 1. || rotation() != 0.) {
| 2250-866194 | ||||||||||||||||||||||||
3125 | QPointF tp = computeTransformOrigin(); | - | ||||||||||||||||||||||||
3126 | t.translate(tp.x(), tp.y()); | - | ||||||||||||||||||||||||
3127 | t.scale(scale(), scale()); | - | ||||||||||||||||||||||||
3128 | t.rotate(rotation()); | - | ||||||||||||||||||||||||
3129 | t.translate(-tp.x(), -tp.y()); | - | ||||||||||||||||||||||||
3130 | } executed 6153 times by 9 tests: end of block Executed by:
| 6153 | ||||||||||||||||||||||||
3131 | } executed 870097 times by 61 tests: end of block Executed by:
| 870097 | ||||||||||||||||||||||||
3132 | - | |||||||||||||||||||||||||
3133 | /*! | - | ||||||||||||||||||||||||
3134 | Returns a transform that maps points from window space into global space. | - | ||||||||||||||||||||||||
3135 | */ | - | ||||||||||||||||||||||||
3136 | QTransform QQuickItemPrivate::windowToGlobalTransform() const | - | ||||||||||||||||||||||||
3137 | { | - | ||||||||||||||||||||||||
3138 | if (Q_UNLIKELY(window == nullptr))
| 10-20 | ||||||||||||||||||||||||
3139 | return QTransform(); executed 10 times by 1 test: return QTransform(); Executed by:
| 10 | ||||||||||||||||||||||||
3140 | - | |||||||||||||||||||||||||
3141 | QPoint quickWidgetOffset; | - | ||||||||||||||||||||||||
3142 | QWindow *renderWindow = QQuickRenderControl::renderWindowFor(window, &quickWidgetOffset); | - | ||||||||||||||||||||||||
3143 | QPointF pos = (renderWindow ? renderWindow : window)->mapToGlobal(quickWidgetOffset);
| 0-20 | ||||||||||||||||||||||||
3144 | return QTransform::fromTranslate(pos.x(), pos.y()); executed 20 times by 1 test: return QTransform::fromTranslate(pos.x(), pos.y()); Executed by:
| 20 | ||||||||||||||||||||||||
3145 | } | - | ||||||||||||||||||||||||
3146 | - | |||||||||||||||||||||||||
3147 | /*! | - | ||||||||||||||||||||||||
3148 | Returns a transform that maps points from global space into window space. | - | ||||||||||||||||||||||||
3149 | */ | - | ||||||||||||||||||||||||
3150 | QTransform QQuickItemPrivate::globalToWindowTransform() const | - | ||||||||||||||||||||||||
3151 | { | - | ||||||||||||||||||||||||
3152 | if (Q_UNLIKELY(window == nullptr))
| 10-20 | ||||||||||||||||||||||||
3153 | return QTransform(); executed 10 times by 1 test: return QTransform(); Executed by:
| 10 | ||||||||||||||||||||||||
3154 | - | |||||||||||||||||||||||||
3155 | QPoint quickWidgetOffset; | - | ||||||||||||||||||||||||
3156 | QWindow *renderWindow = QQuickRenderControl::renderWindowFor(window, &quickWidgetOffset); | - | ||||||||||||||||||||||||
3157 | QPointF pos = (renderWindow ? renderWindow : window)->mapToGlobal(quickWidgetOffset);
| 0-20 | ||||||||||||||||||||||||
3158 | return QTransform::fromTranslate(-pos.x(), -pos.y()); executed 20 times by 1 test: return QTransform::fromTranslate(-pos.x(), -pos.y()); Executed by:
| 20 | ||||||||||||||||||||||||
3159 | } | - | ||||||||||||||||||||||||
3160 | - | |||||||||||||||||||||||||
3161 | /*! | - | ||||||||||||||||||||||||
3162 | Returns true if construction of the QML component is complete; otherwise | - | ||||||||||||||||||||||||
3163 | returns false. | - | ||||||||||||||||||||||||
3164 | - | |||||||||||||||||||||||||
3165 | It is often desirable to delay some processing until the component is | - | ||||||||||||||||||||||||
3166 | completed. | - | ||||||||||||||||||||||||
3167 | - | |||||||||||||||||||||||||
3168 | \sa componentComplete() | - | ||||||||||||||||||||||||
3169 | */ | - | ||||||||||||||||||||||||
3170 | bool QQuickItem::isComponentComplete() const | - | ||||||||||||||||||||||||
3171 | { | - | ||||||||||||||||||||||||
3172 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
3173 | return d->componentComplete; executed 2168729 times by 60 tests: return d->componentComplete; Executed by:
| 2168729 | ||||||||||||||||||||||||
3174 | } | - | ||||||||||||||||||||||||
3175 | - | |||||||||||||||||||||||||
3176 | QQuickItemPrivate::QQuickItemPrivate() | - | ||||||||||||||||||||||||
3177 | : _anchors(nullptr) | - | ||||||||||||||||||||||||
3178 | , _stateGroup(nullptr) | - | ||||||||||||||||||||||||
3179 | , flags(0) | - | ||||||||||||||||||||||||
3180 | , widthValid(false) | - | ||||||||||||||||||||||||
3181 | , heightValid(false) | - | ||||||||||||||||||||||||
3182 | , componentComplete(true) | - | ||||||||||||||||||||||||
3183 | , keepMouse(false) | - | ||||||||||||||||||||||||
3184 | , keepTouch(false) | - | ||||||||||||||||||||||||
3185 | , hoverEnabled(false) | - | ||||||||||||||||||||||||
3186 | , smooth(true) | - | ||||||||||||||||||||||||
3187 | , antialiasing(false) | - | ||||||||||||||||||||||||
3188 | , focus(false) | - | ||||||||||||||||||||||||
3189 | , activeFocus(false) | - | ||||||||||||||||||||||||
3190 | , notifiedFocus(false) | - | ||||||||||||||||||||||||
3191 | , notifiedActiveFocus(false) | - | ||||||||||||||||||||||||
3192 | , filtersChildMouseEvents(false) | - | ||||||||||||||||||||||||
3193 | , explicitVisible(true) | - | ||||||||||||||||||||||||
3194 | , effectiveVisible(true) | - | ||||||||||||||||||||||||
3195 | , explicitEnable(true) | - | ||||||||||||||||||||||||
3196 | , effectiveEnable(true) | - | ||||||||||||||||||||||||
3197 | , polishScheduled(false) | - | ||||||||||||||||||||||||
3198 | , inheritedLayoutMirror(false) | - | ||||||||||||||||||||||||
3199 | , effectiveLayoutMirror(false) | - | ||||||||||||||||||||||||
3200 | , isMirrorImplicit(true) | - | ||||||||||||||||||||||||
3201 | , inheritMirrorFromParent(false) | - | ||||||||||||||||||||||||
3202 | , inheritMirrorFromItem(false) | - | ||||||||||||||||||||||||
3203 | , isAccessible(false) | - | ||||||||||||||||||||||||
3204 | , culled(false) | - | ||||||||||||||||||||||||
3205 | , hasCursor(false) | - | ||||||||||||||||||||||||
3206 | , subtreeCursorEnabled(false) | - | ||||||||||||||||||||||||
3207 | , subtreeHoverEnabled(false) | - | ||||||||||||||||||||||||
3208 | , activeFocusOnTab(false) | - | ||||||||||||||||||||||||
3209 | , implicitAntialiasing(false) | - | ||||||||||||||||||||||||
3210 | , antialiasingValid(false) | - | ||||||||||||||||||||||||
3211 | , isTabFence(false) | - | ||||||||||||||||||||||||
3212 | , replayingPressEvent(false) | - | ||||||||||||||||||||||||
3213 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | - | ||||||||||||||||||||||||
3214 | , touchEnabled(true) | - | ||||||||||||||||||||||||
3215 | #else | - | ||||||||||||||||||||||||
3216 | , touchEnabled(false) | - | ||||||||||||||||||||||||
3217 | #endif | - | ||||||||||||||||||||||||
3218 | , dirtyAttributes(0) | - | ||||||||||||||||||||||||
3219 | , nextDirtyItem(nullptr) | - | ||||||||||||||||||||||||
3220 | , prevDirtyItem(nullptr) | - | ||||||||||||||||||||||||
3221 | , window(nullptr) | - | ||||||||||||||||||||||||
3222 | , windowRefCount(0) | - | ||||||||||||||||||||||||
3223 | , parentItem(nullptr) | - | ||||||||||||||||||||||||
3224 | , sortedChildItems(&childItems) | - | ||||||||||||||||||||||||
3225 | , subFocusItem(nullptr) | - | ||||||||||||||||||||||||
3226 | , x(0) | - | ||||||||||||||||||||||||
3227 | , y(0) | - | ||||||||||||||||||||||||
3228 | , width(0) | - | ||||||||||||||||||||||||
3229 | , height(0) | - | ||||||||||||||||||||||||
3230 | , implicitWidth(0) | - | ||||||||||||||||||||||||
3231 | , implicitHeight(0) | - | ||||||||||||||||||||||||
3232 | , baselineOffset(0) | - | ||||||||||||||||||||||||
3233 | , itemNodeInstance(nullptr) | - | ||||||||||||||||||||||||
3234 | , paintNode(nullptr) | - | ||||||||||||||||||||||||
3235 | { | - | ||||||||||||||||||||||||
3236 | } executed 460300 times by 127 tests: end of block Executed by:
| 460300 | ||||||||||||||||||||||||
3237 | - | |||||||||||||||||||||||||
3238 | QQuickItemPrivate::~QQuickItemPrivate() | - | ||||||||||||||||||||||||
3239 | { | - | ||||||||||||||||||||||||
3240 | if (sortedChildItems != &childItems)
| 4242-412848 | ||||||||||||||||||||||||
3241 | delete sortedChildItems; executed 4242 times by 15 tests: delete sortedChildItems; Executed by:
| 4242 | ||||||||||||||||||||||||
3242 | } executed 417090 times by 123 tests: end of block Executed by:
| 417090 | ||||||||||||||||||||||||
3243 | - | |||||||||||||||||||||||||
3244 | void QQuickItemPrivate::init(QQuickItem *parent) | - | ||||||||||||||||||||||||
3245 | { | - | ||||||||||||||||||||||||
3246 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
3247 | - | |||||||||||||||||||||||||
3248 | baselineOffset = 0.0; | - | ||||||||||||||||||||||||
3249 | - | |||||||||||||||||||||||||
3250 | if (parent) {
| 220-460080 | ||||||||||||||||||||||||
3251 | q->setParentItem(parent); | - | ||||||||||||||||||||||||
3252 | QQuickItemPrivate *parentPrivate = QQuickItemPrivate::get(parent); | - | ||||||||||||||||||||||||
3253 | setImplicitLayoutMirror(parentPrivate->inheritedLayoutMirror, parentPrivate->inheritMirrorFromParent); | - | ||||||||||||||||||||||||
3254 | } executed 220 times by 8 tests: end of block Executed by:
| 220 | ||||||||||||||||||||||||
3255 | } executed 460300 times by 127 tests: end of block Executed by:
| 460300 | ||||||||||||||||||||||||
3256 | - | |||||||||||||||||||||||||
3257 | void QQuickItemPrivate::data_append(QQmlListProperty<QObject> *prop, QObject *o) | - | ||||||||||||||||||||||||
3258 | { | - | ||||||||||||||||||||||||
3259 | if (!o)
| 0-307294 | ||||||||||||||||||||||||
3260 | return; never executed: return; | 0 | ||||||||||||||||||||||||
3261 | - | |||||||||||||||||||||||||
3262 | QQuickItem *that = static_cast<QQuickItem *>(prop->object); | - | ||||||||||||||||||||||||
3263 | - | |||||||||||||||||||||||||
3264 | if (QQuickItem *item = qmlobject_cast<QQuickItem *>(o)) {
| 10090-297204 | ||||||||||||||||||||||||
3265 | item->setParentItem(that); | - | ||||||||||||||||||||||||
3266 | } else { executed 297204 times by 95 tests: end of block Executed by:
| 297204 | ||||||||||||||||||||||||
3267 | if (o->inherits("QGraphicsItem"))
| 0-10090 | ||||||||||||||||||||||||
3268 | qWarning("Cannot add a QtQuick 1.0 item (%s) into a QtQuick 2.0 scene!", o->metaObject()->className()); never executed: QMessageLogger(__FILE__, 3268, __PRETTY_FUNCTION__).warning("Cannot add a QtQuick 1.0 item (%s) into a QtQuick 2.0 scene!", o->metaObject()->className()); | 0 | ||||||||||||||||||||||||
3269 | else if (QQuickPointerHandler *pointerHandler = qmlobject_cast<QQuickPointerHandler *>(o)) {
| 1016-9074 | ||||||||||||||||||||||||
3270 | Q_ASSERT(pointerHandler->parentItem() == that); | - | ||||||||||||||||||||||||
3271 | // Accept all buttons, and leave filtering to pointerEvent() and/or user JS, | - | ||||||||||||||||||||||||
3272 | // because there can be multiple handlers... | - | ||||||||||||||||||||||||
3273 | that->setAcceptedMouseButtons(Qt::AllButtons); | - | ||||||||||||||||||||||||
3274 | QQuickItemPrivate *p = QQuickItemPrivate::get(that); | - | ||||||||||||||||||||||||
3275 | p->extra.value().pointerHandlers.prepend(pointerHandler); | - | ||||||||||||||||||||||||
3276 | } else { executed 1016 times by 6 tests: end of block Executed by:
| 1016 | ||||||||||||||||||||||||
3277 | QQuickWindow *thisWindow = qmlobject_cast<QQuickWindow *>(o); | - | ||||||||||||||||||||||||
3278 | QQuickItem *item = that; | - | ||||||||||||||||||||||||
3279 | QQuickWindow *itemWindow = that->window(); | - | ||||||||||||||||||||||||
3280 | while (!itemWindow && item && item->parentItem()) {
| 0-9060 | ||||||||||||||||||||||||
3281 | item = item->parentItem(); | - | ||||||||||||||||||||||||
3282 | itemWindow = item->window(); | - | ||||||||||||||||||||||||
3283 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3284 | - | |||||||||||||||||||||||||
3285 | if (thisWindow) {
| 8-9066 | ||||||||||||||||||||||||
3286 | if (itemWindow) {
| 2-6 | ||||||||||||||||||||||||
3287 | qCDebug(lcTransient) << thisWindow << "is transient for" << itemWindow; never executed: QMessageLogger(__FILE__, 3287, __PRETTY_FUNCTION__, lcTransient().categoryName()).debug() << thisWindow << "is transient for" << itemWindow;
| 0-2 | ||||||||||||||||||||||||
3288 | thisWindow->setTransientParent(itemWindow); | - | ||||||||||||||||||||||||
3289 | } else { executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3290 | QObject::connect(item, SIGNAL(windowChanged(QQuickWindow*)), | - | ||||||||||||||||||||||||
3291 | thisWindow, SLOT(setTransientParent_helper(QQuickWindow*))); | - | ||||||||||||||||||||||||
3292 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||
3293 | } | - | ||||||||||||||||||||||||
3294 | o->setParent(that); | - | ||||||||||||||||||||||||
3295 | } executed 9074 times by 61 tests: end of block Executed by:
| 9074 | ||||||||||||||||||||||||
3296 | - | |||||||||||||||||||||||||
3297 | resources_append(prop, o); | - | ||||||||||||||||||||||||
3298 | } executed 10090 times by 66 tests: end of block Executed by:
| 10090 | ||||||||||||||||||||||||
3299 | } | - | ||||||||||||||||||||||||
3300 | - | |||||||||||||||||||||||||
3301 | /*! | - | ||||||||||||||||||||||||
3302 | \qmlproperty list<Object> QtQuick::Item::data | - | ||||||||||||||||||||||||
3303 | \default | - | ||||||||||||||||||||||||
3304 | - | |||||||||||||||||||||||||
3305 | The data property allows you to freely mix visual children and resources | - | ||||||||||||||||||||||||
3306 | in an item. If you assign a visual item to the data list it becomes | - | ||||||||||||||||||||||||
3307 | a child and if you assign any other object type, it is added as a resource. | - | ||||||||||||||||||||||||
3308 | - | |||||||||||||||||||||||||
3309 | So you can write: | - | ||||||||||||||||||||||||
3310 | \qml | - | ||||||||||||||||||||||||
3311 | Item { | - | ||||||||||||||||||||||||
3312 | Text {} | - | ||||||||||||||||||||||||
3313 | Rectangle {} | - | ||||||||||||||||||||||||
3314 | Timer {} | - | ||||||||||||||||||||||||
3315 | } | - | ||||||||||||||||||||||||
3316 | \endqml | - | ||||||||||||||||||||||||
3317 | - | |||||||||||||||||||||||||
3318 | instead of: | - | ||||||||||||||||||||||||
3319 | \qml | - | ||||||||||||||||||||||||
3320 | Item { | - | ||||||||||||||||||||||||
3321 | children: [ | - | ||||||||||||||||||||||||
3322 | Text {}, | - | ||||||||||||||||||||||||
3323 | Rectangle {} | - | ||||||||||||||||||||||||
3324 | ] | - | ||||||||||||||||||||||||
3325 | resources: [ | - | ||||||||||||||||||||||||
3326 | Timer {} | - | ||||||||||||||||||||||||
3327 | ] | - | ||||||||||||||||||||||||
3328 | } | - | ||||||||||||||||||||||||
3329 | \endqml | - | ||||||||||||||||||||||||
3330 | - | |||||||||||||||||||||||||
3331 | It should not generally be necessary to refer to the \c data property, | - | ||||||||||||||||||||||||
3332 | as it is the default property for Item and thus all child items are | - | ||||||||||||||||||||||||
3333 | automatically assigned to this property. | - | ||||||||||||||||||||||||
3334 | */ | - | ||||||||||||||||||||||||
3335 | - | |||||||||||||||||||||||||
3336 | int QQuickItemPrivate::data_count(QQmlListProperty<QObject> *property) | - | ||||||||||||||||||||||||
3337 | { | - | ||||||||||||||||||||||||
3338 | QQuickItem *item = static_cast<QQuickItem*>(property->object); | - | ||||||||||||||||||||||||
3339 | QQuickItemPrivate *privateItem = QQuickItemPrivate::get(item); | - | ||||||||||||||||||||||||
3340 | QQmlListProperty<QObject> resourcesProperty = privateItem->resources(); | - | ||||||||||||||||||||||||
3341 | QQmlListProperty<QQuickItem> childrenProperty = privateItem->children(); | - | ||||||||||||||||||||||||
3342 | - | |||||||||||||||||||||||||
3343 | return resources_count(&resourcesProperty) + children_count(&childrenProperty); executed 12 times by 2 tests: return resources_count(&resourcesProperty) + children_count(&childrenProperty); Executed by:
| 12 | ||||||||||||||||||||||||
3344 | } | - | ||||||||||||||||||||||||
3345 | - | |||||||||||||||||||||||||
3346 | QObject *QQuickItemPrivate::data_at(QQmlListProperty<QObject> *property, int i) | - | ||||||||||||||||||||||||
3347 | { | - | ||||||||||||||||||||||||
3348 | QQuickItem *item = static_cast<QQuickItem*>(property->object); | - | ||||||||||||||||||||||||
3349 | QQuickItemPrivate *privateItem = QQuickItemPrivate::get(item); | - | ||||||||||||||||||||||||
3350 | QQmlListProperty<QObject> resourcesProperty = privateItem->resources(); | - | ||||||||||||||||||||||||
3351 | QQmlListProperty<QQuickItem> childrenProperty = privateItem->children(); | - | ||||||||||||||||||||||||
3352 | - | |||||||||||||||||||||||||
3353 | int resourcesCount = resources_count(&resourcesProperty); | - | ||||||||||||||||||||||||
3354 | if (i < resourcesCount)
| 0-6 | ||||||||||||||||||||||||
3355 | return resources_at(&resourcesProperty, i); executed 6 times by 1 test: return resources_at(&resourcesProperty, i); Executed by:
| 6 | ||||||||||||||||||||||||
3356 | const int j = i - resourcesCount; | - | ||||||||||||||||||||||||
3357 | if (j < children_count(&childrenProperty))
| 0 | ||||||||||||||||||||||||
3358 | return children_at(&childrenProperty, j); never executed: return children_at(&childrenProperty, j); | 0 | ||||||||||||||||||||||||
3359 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
3360 | } | - | ||||||||||||||||||||||||
3361 | - | |||||||||||||||||||||||||
3362 | void QQuickItemPrivate::data_clear(QQmlListProperty<QObject> *property) | - | ||||||||||||||||||||||||
3363 | { | - | ||||||||||||||||||||||||
3364 | QQuickItem *item = static_cast<QQuickItem*>(property->object); | - | ||||||||||||||||||||||||
3365 | QQuickItemPrivate *privateItem = QQuickItemPrivate::get(item); | - | ||||||||||||||||||||||||
3366 | QQmlListProperty<QObject> resourcesProperty = privateItem->resources(); | - | ||||||||||||||||||||||||
3367 | QQmlListProperty<QQuickItem> childrenProperty = privateItem->children(); | - | ||||||||||||||||||||||||
3368 | - | |||||||||||||||||||||||||
3369 | resources_clear(&resourcesProperty); | - | ||||||||||||||||||||||||
3370 | children_clear(&childrenProperty); | - | ||||||||||||||||||||||||
3371 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3372 | - | |||||||||||||||||||||||||
3373 | QObject *QQuickItemPrivate::resources_at(QQmlListProperty<QObject> *prop, int index) | - | ||||||||||||||||||||||||
3374 | { | - | ||||||||||||||||||||||||
3375 | QQuickItemPrivate *quickItemPrivate = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object)); | - | ||||||||||||||||||||||||
3376 | return quickItemPrivate->extra.isAllocated() ? quickItemPrivate->extra->resourcesList.value(index) : 0; executed 14 times by 2 tests: return quickItemPrivate->extra.isAllocated() ? quickItemPrivate->extra->resourcesList.value(index) : 0; Executed by:
| 14 | ||||||||||||||||||||||||
3377 | } | - | ||||||||||||||||||||||||
3378 | - | |||||||||||||||||||||||||
3379 | void QQuickItemPrivate::resources_append(QQmlListProperty<QObject> *prop, QObject *object) | - | ||||||||||||||||||||||||
3380 | { | - | ||||||||||||||||||||||||
3381 | QQuickItem *quickItem = static_cast<QQuickItem *>(prop->object); | - | ||||||||||||||||||||||||
3382 | QQuickItemPrivate *quickItemPrivate = QQuickItemPrivate::get(quickItem); | - | ||||||||||||||||||||||||
3383 | if (!quickItemPrivate->extra.value().resourcesList.contains(object)) {
| 0-13540 | ||||||||||||||||||||||||
3384 | quickItemPrivate->extra.value().resourcesList.append(object); | - | ||||||||||||||||||||||||
3385 | qmlobject_connect(object, QObject, SIGNAL(destroyed(QObject*)), executed 158 times by 68 tests: end of block Executed by:
executed 158 times by 68 tests: methodIdx = QQuickItem::staticMetaObject.indexOfSlot(method+1); Executed by:
never executed: methodIdx = QQuickItem::staticMetaObject.indexOfSignal(method+1);
| 0-13382 | ||||||||||||||||||||||||
3386 | quickItem, QQuickItem, SLOT(_q_resourceObjectDeleted(QObject*))); | - | ||||||||||||||||||||||||
3387 | } executed 13540 times by 68 tests: end of block Executed by:
| 13540 | ||||||||||||||||||||||||
3388 | } executed 13540 times by 68 tests: end of block Executed by:
| 13540 | ||||||||||||||||||||||||
3389 | - | |||||||||||||||||||||||||
3390 | int QQuickItemPrivate::resources_count(QQmlListProperty<QObject> *prop) | - | ||||||||||||||||||||||||
3391 | { | - | ||||||||||||||||||||||||
3392 | QQuickItemPrivate *quickItemPrivate = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object)); | - | ||||||||||||||||||||||||
3393 | return quickItemPrivate->extra.isAllocated() ? quickItemPrivate->extra->resourcesList.count() : 0; executed 40 times by 3 tests: return quickItemPrivate->extra.isAllocated() ? quickItemPrivate->extra->resourcesList.count() : 0; Executed by:
| 40 | ||||||||||||||||||||||||
3394 | } | - | ||||||||||||||||||||||||
3395 | - | |||||||||||||||||||||||||
3396 | void QQuickItemPrivate::resources_clear(QQmlListProperty<QObject> *prop) | - | ||||||||||||||||||||||||
3397 | { | - | ||||||||||||||||||||||||
3398 | QQuickItem *quickItem = static_cast<QQuickItem *>(prop->object); | - | ||||||||||||||||||||||||
3399 | QQuickItemPrivate *quickItemPrivate = QQuickItemPrivate::get(quickItem); | - | ||||||||||||||||||||||||
3400 | if (quickItemPrivate->extra.isAllocated()) {//If extra is not allocated resources is empty.
| 0 | ||||||||||||||||||||||||
3401 | for (QObject *object : qAsConst(quickItemPrivate->extra->resourcesList)) { | - | ||||||||||||||||||||||||
3402 | qmlobject_disconnect(object, QObject, SIGNAL(destroyed(QObject*)), never executed: end of block never executed: methodIdx = QQuickItem::staticMetaObject.indexOfSlot(method+1); never executed: methodIdx = QQuickItem::staticMetaObject.indexOfSignal(method+1);
| 0 | ||||||||||||||||||||||||
3403 | quickItem, QQuickItem, SLOT(_q_resourceObjectDeleted(QObject*))); | - | ||||||||||||||||||||||||
3404 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3405 | quickItemPrivate->extra->resourcesList.clear(); | - | ||||||||||||||||||||||||
3406 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3407 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3408 | - | |||||||||||||||||||||||||
3409 | QQuickItem *QQuickItemPrivate::children_at(QQmlListProperty<QQuickItem> *prop, int index) | - | ||||||||||||||||||||||||
3410 | { | - | ||||||||||||||||||||||||
3411 | QQuickItemPrivate *p = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object)); | - | ||||||||||||||||||||||||
3412 | if (index >= p->childItems.count() || index < 0)
| 0-1658 | ||||||||||||||||||||||||
3413 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
3414 | else | - | ||||||||||||||||||||||||
3415 | return p->childItems.at(index); executed 1658 times by 4 tests: return p->childItems.at(index); Executed by:
| 1658 | ||||||||||||||||||||||||
3416 | } | - | ||||||||||||||||||||||||
3417 | - | |||||||||||||||||||||||||
3418 | void QQuickItemPrivate::children_append(QQmlListProperty<QQuickItem> *prop, QQuickItem *o) | - | ||||||||||||||||||||||||
3419 | { | - | ||||||||||||||||||||||||
3420 | if (!o)
| 2-16 | ||||||||||||||||||||||||
3421 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
3422 | - | |||||||||||||||||||||||||
3423 | QQuickItem *that = static_cast<QQuickItem *>(prop->object); | - | ||||||||||||||||||||||||
3424 | if (o->parentItem() == that)
| 0-16 | ||||||||||||||||||||||||
3425 | o->setParentItem(nullptr); never executed: o->setParentItem(nullptr); | 0 | ||||||||||||||||||||||||
3426 | - | |||||||||||||||||||||||||
3427 | o->setParentItem(that); | - | ||||||||||||||||||||||||
3428 | } executed 16 times by 2 tests: end of block Executed by:
| 16 | ||||||||||||||||||||||||
3429 | - | |||||||||||||||||||||||||
3430 | int QQuickItemPrivate::children_count(QQmlListProperty<QQuickItem> *prop) | - | ||||||||||||||||||||||||
3431 | { | - | ||||||||||||||||||||||||
3432 | QQuickItemPrivate *p = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object)); | - | ||||||||||||||||||||||||
3433 | return p->childItems.count(); executed 7238 times by 14 tests: return p->childItems.count(); Executed by:
| 7238 | ||||||||||||||||||||||||
3434 | } | - | ||||||||||||||||||||||||
3435 | - | |||||||||||||||||||||||||
3436 | void QQuickItemPrivate::children_clear(QQmlListProperty<QQuickItem> *prop) | - | ||||||||||||||||||||||||
3437 | { | - | ||||||||||||||||||||||||
3438 | QQuickItem *that = static_cast<QQuickItem *>(prop->object); | - | ||||||||||||||||||||||||
3439 | QQuickItemPrivate *p = QQuickItemPrivate::get(that); | - | ||||||||||||||||||||||||
3440 | while (!p->childItems.isEmpty())
| 0-2 | ||||||||||||||||||||||||
3441 | p->childItems.at(0)->setParentItem(nullptr); never executed: p->childItems.at(0)->setParentItem(nullptr); | 0 | ||||||||||||||||||||||||
3442 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3443 | - | |||||||||||||||||||||||||
3444 | int QQuickItemPrivate::visibleChildren_count(QQmlListProperty<QQuickItem> *prop) | - | ||||||||||||||||||||||||
3445 | { | - | ||||||||||||||||||||||||
3446 | QQuickItemPrivate *p = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object)); | - | ||||||||||||||||||||||||
3447 | int visibleCount = 0; | - | ||||||||||||||||||||||||
3448 | int c = p->childItems.count(); | - | ||||||||||||||||||||||||
3449 | while (c--) {
| 148-534 | ||||||||||||||||||||||||
3450 | if (p->childItems.at(c)->isVisible()) visibleCount++; executed 242 times by 1 test: visibleCount++; Executed by:
| 242-292 | ||||||||||||||||||||||||
3451 | } executed 534 times by 1 test: end of block Executed by:
| 534 | ||||||||||||||||||||||||
3452 | - | |||||||||||||||||||||||||
3453 | return visibleCount; executed 148 times by 2 tests: return visibleCount; Executed by:
| 148 | ||||||||||||||||||||||||
3454 | } | - | ||||||||||||||||||||||||
3455 | - | |||||||||||||||||||||||||
3456 | QQuickItem *QQuickItemPrivate::visibleChildren_at(QQmlListProperty<QQuickItem> *prop, int index) | - | ||||||||||||||||||||||||
3457 | { | - | ||||||||||||||||||||||||
3458 | QQuickItemPrivate *p = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object)); | - | ||||||||||||||||||||||||
3459 | const int childCount = p->childItems.count(); | - | ||||||||||||||||||||||||
3460 | if (index >= childCount || index < 0)
| 0-56 | ||||||||||||||||||||||||
3461 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
3462 | - | |||||||||||||||||||||||||
3463 | int visibleCount = -1; | - | ||||||||||||||||||||||||
3464 | for (int i = 0; i < childCount; i++) {
| 0-110 | ||||||||||||||||||||||||
3465 | if (p->childItems.at(i)->isVisible()) visibleCount++; executed 66 times by 1 test: visibleCount++; Executed by:
| 44-66 | ||||||||||||||||||||||||
3466 | if (visibleCount == index) return p->childItems.at(i); executed 56 times by 1 test: return p->childItems.at(i); Executed by:
| 54-56 | ||||||||||||||||||||||||
3467 | } executed 54 times by 1 test: end of block Executed by:
| 54 | ||||||||||||||||||||||||
3468 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
3469 | } | - | ||||||||||||||||||||||||
3470 | - | |||||||||||||||||||||||||
3471 | int QQuickItemPrivate::transform_count(QQmlListProperty<QQuickTransform> *prop) | - | ||||||||||||||||||||||||
3472 | { | - | ||||||||||||||||||||||||
3473 | QQuickItem *that = static_cast<QQuickItem *>(prop->object); | - | ||||||||||||||||||||||||
3474 | QQuickItemPrivate *p = QQuickItemPrivate::get(that); | - | ||||||||||||||||||||||||
3475 | - | |||||||||||||||||||||||||
3476 | return p->transforms.count(); executed 6 times by 1 test: return p->transforms.count(); Executed by:
| 6 | ||||||||||||||||||||||||
3477 | } | - | ||||||||||||||||||||||||
3478 | - | |||||||||||||||||||||||||
3479 | void QQuickTransform::appendToItem(QQuickItem *item) | - | ||||||||||||||||||||||||
3480 | { | - | ||||||||||||||||||||||||
3481 | Q_D(QQuickTransform); | - | ||||||||||||||||||||||||
3482 | if (!item)
| 0-854 | ||||||||||||||||||||||||
3483 | return; never executed: return; | 0 | ||||||||||||||||||||||||
3484 | - | |||||||||||||||||||||||||
3485 | QQuickItemPrivate *p = QQuickItemPrivate::get(item); | - | ||||||||||||||||||||||||
3486 | - | |||||||||||||||||||||||||
3487 | if (!d->items.isEmpty() && !p->transforms.isEmpty() && p->transforms.contains(this)) {
| 0-854 | ||||||||||||||||||||||||
3488 | p->transforms.removeOne(this); | - | ||||||||||||||||||||||||
3489 | p->transforms.append(this); | - | ||||||||||||||||||||||||
3490 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
3491 | p->transforms.append(this); | - | ||||||||||||||||||||||||
3492 | d->items.append(item); | - | ||||||||||||||||||||||||
3493 | } executed 854 times by 6 tests: end of block Executed by:
| 854 | ||||||||||||||||||||||||
3494 | - | |||||||||||||||||||||||||
3495 | p->dirty(QQuickItemPrivate::Transform); | - | ||||||||||||||||||||||||
3496 | } executed 854 times by 6 tests: end of block Executed by:
| 854 | ||||||||||||||||||||||||
3497 | - | |||||||||||||||||||||||||
3498 | void QQuickTransform::prependToItem(QQuickItem *item) | - | ||||||||||||||||||||||||
3499 | { | - | ||||||||||||||||||||||||
3500 | Q_D(QQuickTransform); | - | ||||||||||||||||||||||||
3501 | if (!item)
| 0-14 | ||||||||||||||||||||||||
3502 | return; never executed: return; | 0 | ||||||||||||||||||||||||
3503 | - | |||||||||||||||||||||||||
3504 | QQuickItemPrivate *p = QQuickItemPrivate::get(item); | - | ||||||||||||||||||||||||
3505 | - | |||||||||||||||||||||||||
3506 | if (!d->items.isEmpty() && !p->transforms.isEmpty() && p->transforms.contains(this)) {
| 0-14 | ||||||||||||||||||||||||
3507 | p->transforms.removeOne(this); | - | ||||||||||||||||||||||||
3508 | p->transforms.prepend(this); | - | ||||||||||||||||||||||||
3509 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
3510 | p->transforms.prepend(this); | - | ||||||||||||||||||||||||
3511 | d->items.append(item); | - | ||||||||||||||||||||||||
3512 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||||||||||||||
3513 | - | |||||||||||||||||||||||||
3514 | p->dirty(QQuickItemPrivate::Transform); | - | ||||||||||||||||||||||||
3515 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||||||||||||||
3516 | - | |||||||||||||||||||||||||
3517 | void QQuickItemPrivate::transform_append(QQmlListProperty<QQuickTransform> *prop, QQuickTransform *transform) | - | ||||||||||||||||||||||||
3518 | { | - | ||||||||||||||||||||||||
3519 | if (!transform)
| 2-854 | ||||||||||||||||||||||||
3520 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
3521 | - | |||||||||||||||||||||||||
3522 | QQuickItem *that = static_cast<QQuickItem *>(prop->object); | - | ||||||||||||||||||||||||
3523 | transform->appendToItem(that); | - | ||||||||||||||||||||||||
3524 | } executed 854 times by 6 tests: end of block Executed by:
| 854 | ||||||||||||||||||||||||
3525 | - | |||||||||||||||||||||||||
3526 | QQuickTransform *QQuickItemPrivate::transform_at(QQmlListProperty<QQuickTransform> *prop, int idx) | - | ||||||||||||||||||||||||
3527 | { | - | ||||||||||||||||||||||||
3528 | QQuickItem *that = static_cast<QQuickItem *>(prop->object); | - | ||||||||||||||||||||||||
3529 | QQuickItemPrivate *p = QQuickItemPrivate::get(that); | - | ||||||||||||||||||||||||
3530 | - | |||||||||||||||||||||||||
3531 | if (idx < 0 || idx >= p->transforms.count())
| 0 | ||||||||||||||||||||||||
3532 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
3533 | else | - | ||||||||||||||||||||||||
3534 | return p->transforms.at(idx); never executed: return p->transforms.at(idx); | 0 | ||||||||||||||||||||||||
3535 | } | - | ||||||||||||||||||||||||
3536 | - | |||||||||||||||||||||||||
3537 | void QQuickItemPrivate::transform_clear(QQmlListProperty<QQuickTransform> *prop) | - | ||||||||||||||||||||||||
3538 | { | - | ||||||||||||||||||||||||
3539 | QQuickItem *that = static_cast<QQuickItem *>(prop->object); | - | ||||||||||||||||||||||||
3540 | QQuickItemPrivate *p = QQuickItemPrivate::get(that); | - | ||||||||||||||||||||||||
3541 | - | |||||||||||||||||||||||||
3542 | for (int ii = 0; ii < p->transforms.count(); ++ii) {
| 0-4 | ||||||||||||||||||||||||
3543 | QQuickTransform *t = p->transforms.at(ii); | - | ||||||||||||||||||||||||
3544 | QQuickTransformPrivate *tp = QQuickTransformPrivate::get(t); | - | ||||||||||||||||||||||||
3545 | tp->items.removeOne(that); | - | ||||||||||||||||||||||||
3546 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3547 | - | |||||||||||||||||||||||||
3548 | p->transforms.clear(); | - | ||||||||||||||||||||||||
3549 | - | |||||||||||||||||||||||||
3550 | p->dirty(QQuickItemPrivate::Transform); | - | ||||||||||||||||||||||||
3551 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
3552 | - | |||||||||||||||||||||||||
3553 | void QQuickItemPrivate::_q_resourceObjectDeleted(QObject *object) | - | ||||||||||||||||||||||||
3554 | { | - | ||||||||||||||||||||||||
3555 | if (extra.isAllocated() && extra->resourcesList.contains(object))
| 0-14 | ||||||||||||||||||||||||
3556 | extra->resourcesList.removeAll(object); executed 14 times by 6 tests: extra->resourcesList.removeAll(object); Executed by:
| 14 | ||||||||||||||||||||||||
3557 | } executed 14 times by 6 tests: end of block Executed by:
| 14 | ||||||||||||||||||||||||
3558 | - | |||||||||||||||||||||||||
3559 | /*! | - | ||||||||||||||||||||||||
3560 | \qmlpropertygroup QtQuick::Item::anchors | - | ||||||||||||||||||||||||
3561 | \qmlproperty AnchorLine QtQuick::Item::anchors.top | - | ||||||||||||||||||||||||
3562 | \qmlproperty AnchorLine QtQuick::Item::anchors.bottom | - | ||||||||||||||||||||||||
3563 | \qmlproperty AnchorLine QtQuick::Item::anchors.left | - | ||||||||||||||||||||||||
3564 | \qmlproperty AnchorLine QtQuick::Item::anchors.right | - | ||||||||||||||||||||||||
3565 | \qmlproperty AnchorLine QtQuick::Item::anchors.horizontalCenter | - | ||||||||||||||||||||||||
3566 | \qmlproperty AnchorLine QtQuick::Item::anchors.verticalCenter | - | ||||||||||||||||||||||||
3567 | \qmlproperty AnchorLine QtQuick::Item::anchors.baseline | - | ||||||||||||||||||||||||
3568 | - | |||||||||||||||||||||||||
3569 | \qmlproperty Item QtQuick::Item::anchors.fill | - | ||||||||||||||||||||||||
3570 | \qmlproperty Item QtQuick::Item::anchors.centerIn | - | ||||||||||||||||||||||||
3571 | - | |||||||||||||||||||||||||
3572 | \qmlproperty real QtQuick::Item::anchors.margins | - | ||||||||||||||||||||||||
3573 | \qmlproperty real QtQuick::Item::anchors.topMargin | - | ||||||||||||||||||||||||
3574 | \qmlproperty real QtQuick::Item::anchors.bottomMargin | - | ||||||||||||||||||||||||
3575 | \qmlproperty real QtQuick::Item::anchors.leftMargin | - | ||||||||||||||||||||||||
3576 | \qmlproperty real QtQuick::Item::anchors.rightMargin | - | ||||||||||||||||||||||||
3577 | \qmlproperty real QtQuick::Item::anchors.horizontalCenterOffset | - | ||||||||||||||||||||||||
3578 | \qmlproperty real QtQuick::Item::anchors.verticalCenterOffset | - | ||||||||||||||||||||||||
3579 | \qmlproperty real QtQuick::Item::anchors.baselineOffset | - | ||||||||||||||||||||||||
3580 | - | |||||||||||||||||||||||||
3581 | \qmlproperty bool QtQuick::Item::anchors.alignWhenCentered | - | ||||||||||||||||||||||||
3582 | - | |||||||||||||||||||||||||
3583 | Anchors provide a way to position an item by specifying its | - | ||||||||||||||||||||||||
3584 | relationship with other items. | - | ||||||||||||||||||||||||
3585 | - | |||||||||||||||||||||||||
3586 | Margins apply to top, bottom, left, right, and fill anchors. | - | ||||||||||||||||||||||||
3587 | The \l anchors.margins property can be used to set all of the various margins at once, to the same value. | - | ||||||||||||||||||||||||
3588 | It will not override a specific margin that has been previously set; to clear an explicit margin | - | ||||||||||||||||||||||||
3589 | set its value to \c undefined. | - | ||||||||||||||||||||||||
3590 | Note that margins are anchor-specific and are not applied if an item does not | - | ||||||||||||||||||||||||
3591 | use anchors. | - | ||||||||||||||||||||||||
3592 | - | |||||||||||||||||||||||||
3593 | Offsets apply for horizontal center, vertical center, and baseline anchors. | - | ||||||||||||||||||||||||
3594 | - | |||||||||||||||||||||||||
3595 | \table | - | ||||||||||||||||||||||||
3596 | \row | - | ||||||||||||||||||||||||
3597 | \li \image declarative-anchors_example.png | - | ||||||||||||||||||||||||
3598 | \li Text anchored to Image, horizontally centered and vertically below, with a margin. | - | ||||||||||||||||||||||||
3599 | \qml | - | ||||||||||||||||||||||||
3600 | Item { | - | ||||||||||||||||||||||||
3601 | Image { | - | ||||||||||||||||||||||||
3602 | id: pic | - | ||||||||||||||||||||||||
3603 | // ... | - | ||||||||||||||||||||||||
3604 | } | - | ||||||||||||||||||||||||
3605 | Text { | - | ||||||||||||||||||||||||
3606 | id: label | - | ||||||||||||||||||||||||
3607 | anchors.horizontalCenter: pic.horizontalCenter | - | ||||||||||||||||||||||||
3608 | anchors.top: pic.bottom | - | ||||||||||||||||||||||||
3609 | anchors.topMargin: 5 | - | ||||||||||||||||||||||||
3610 | // ... | - | ||||||||||||||||||||||||
3611 | } | - | ||||||||||||||||||||||||
3612 | } | - | ||||||||||||||||||||||||
3613 | \endqml | - | ||||||||||||||||||||||||
3614 | \row | - | ||||||||||||||||||||||||
3615 | \li \image declarative-anchors_example2.png | - | ||||||||||||||||||||||||
3616 | \li | - | ||||||||||||||||||||||||
3617 | Left of Text anchored to right of Image, with a margin. The y | - | ||||||||||||||||||||||||
3618 | property of both defaults to 0. | - | ||||||||||||||||||||||||
3619 | - | |||||||||||||||||||||||||
3620 | \qml | - | ||||||||||||||||||||||||
3621 | Item { | - | ||||||||||||||||||||||||
3622 | Image { | - | ||||||||||||||||||||||||
3623 | id: pic | - | ||||||||||||||||||||||||
3624 | // ... | - | ||||||||||||||||||||||||
3625 | } | - | ||||||||||||||||||||||||
3626 | Text { | - | ||||||||||||||||||||||||
3627 | id: label | - | ||||||||||||||||||||||||
3628 | anchors.left: pic.right | - | ||||||||||||||||||||||||
3629 | anchors.leftMargin: 5 | - | ||||||||||||||||||||||||
3630 | // ... | - | ||||||||||||||||||||||||
3631 | } | - | ||||||||||||||||||||||||
3632 | } | - | ||||||||||||||||||||||||
3633 | \endqml | - | ||||||||||||||||||||||||
3634 | \endtable | - | ||||||||||||||||||||||||
3635 | - | |||||||||||||||||||||||||
3636 | \l anchors.fill provides a convenient way for one item to have the | - | ||||||||||||||||||||||||
3637 | same geometry as another item, and is equivalent to connecting all | - | ||||||||||||||||||||||||
3638 | four directional anchors. | - | ||||||||||||||||||||||||
3639 | - | |||||||||||||||||||||||||
3640 | To clear an anchor value, set it to \c undefined. | - | ||||||||||||||||||||||||
3641 | - | |||||||||||||||||||||||||
3642 | \l anchors.alignWhenCentered (default \c true) forces centered anchors to align to a | - | ||||||||||||||||||||||||
3643 | whole pixel; if the item being centered has an odd \l width or \l height, the item | - | ||||||||||||||||||||||||
3644 | will be positioned on a whole pixel rather than being placed on a half-pixel. | - | ||||||||||||||||||||||||
3645 | This ensures the item is painted crisply. There are cases where this is not | - | ||||||||||||||||||||||||
3646 | desirable, for example when rotating the item jitters may be apparent as the | - | ||||||||||||||||||||||||
3647 | center is rounded. | - | ||||||||||||||||||||||||
3648 | - | |||||||||||||||||||||||||
3649 | \note You can only anchor an item to siblings or a parent. | - | ||||||||||||||||||||||||
3650 | - | |||||||||||||||||||||||||
3651 | For more information see \l {anchor-layout}{Anchor Layouts}. | - | ||||||||||||||||||||||||
3652 | */ | - | ||||||||||||||||||||||||
3653 | QQuickAnchors *QQuickItemPrivate::anchors() const | - | ||||||||||||||||||||||||
3654 | { | - | ||||||||||||||||||||||||
3655 | if (!_anchors) {
| 1794-12520 | ||||||||||||||||||||||||
3656 | Q_Q(const QQuickItem); | - | ||||||||||||||||||||||||
3657 | _anchors = new QQuickAnchors(const_cast<QQuickItem *>(q)); | - | ||||||||||||||||||||||||
3658 | if (!componentComplete)
| 102-12418 | ||||||||||||||||||||||||
3659 | _anchors->classBegin(); executed 12418 times by 77 tests: _anchors->classBegin(); Executed by:
| 12418 | ||||||||||||||||||||||||
3660 | } executed 12520 times by 83 tests: end of block Executed by:
| 12520 | ||||||||||||||||||||||||
3661 | return _anchors; executed 14314 times by 83 tests: return _anchors; Executed by:
| 14314 | ||||||||||||||||||||||||
3662 | } | - | ||||||||||||||||||||||||
3663 | - | |||||||||||||||||||||||||
3664 | void QQuickItemPrivate::siblingOrderChanged() | - | ||||||||||||||||||||||||
3665 | { | - | ||||||||||||||||||||||||
3666 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
3667 | if (!changeListeners.isEmpty()) {
| 3598-19082 | ||||||||||||||||||||||||
3668 | const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732) | - | ||||||||||||||||||||||||
3669 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { | - | ||||||||||||||||||||||||
3670 | if (change.types & QQuickItemPrivate::SiblingOrder) {
| 1364-3108 | ||||||||||||||||||||||||
3671 | change.listener->itemSiblingOrderChanged(q); | - | ||||||||||||||||||||||||
3672 | } executed 3108 times by 6 tests: end of block Executed by:
| 3108 | ||||||||||||||||||||||||
3673 | } executed 4472 times by 7 tests: end of block Executed by:
| 4472 | ||||||||||||||||||||||||
3674 | } executed 3598 times by 7 tests: end of block Executed by:
| 3598 | ||||||||||||||||||||||||
3675 | } executed 22680 times by 18 tests: end of block Executed by:
| 22680 | ||||||||||||||||||||||||
3676 | - | |||||||||||||||||||||||||
3677 | QQmlListProperty<QObject> QQuickItemPrivate::data() | - | ||||||||||||||||||||||||
3678 | { | - | ||||||||||||||||||||||||
3679 | return QQmlListProperty<QObject>(q_func(), nullptr, QQuickItemPrivate::data_append, executed 102465 times by 113 tests: return QQmlListProperty<QObject>(q_func(), nullptr, QQuickItemPrivate::data_append, QQuickItemPrivate::data_count, QQuickItemPrivate::data_at, QQuickItemPrivate::data_clear); Executed by:
| 102465 | ||||||||||||||||||||||||
3680 | QQuickItemPrivate::data_count, executed 102465 times by 113 tests: return QQmlListProperty<QObject>(q_func(), nullptr, QQuickItemPrivate::data_append, QQuickItemPrivate::data_count, QQuickItemPrivate::data_at, QQuickItemPrivate::data_clear); Executed by:
| 102465 | ||||||||||||||||||||||||
3681 | QQuickItemPrivate::data_at, executed 102465 times by 113 tests: return QQmlListProperty<QObject>(q_func(), nullptr, QQuickItemPrivate::data_append, QQuickItemPrivate::data_count, QQuickItemPrivate::data_at, QQuickItemPrivate::data_clear); Executed by:
| 102465 | ||||||||||||||||||||||||
3682 | QQuickItemPrivate::data_clear); executed 102465 times by 113 tests: return QQmlListProperty<QObject>(q_func(), nullptr, QQuickItemPrivate::data_append, QQuickItemPrivate::data_count, QQuickItemPrivate::data_at, QQuickItemPrivate::data_clear); Executed by:
| 102465 | ||||||||||||||||||||||||
3683 | } | - | ||||||||||||||||||||||||
3684 | - | |||||||||||||||||||||||||
3685 | /*! | - | ||||||||||||||||||||||||
3686 | \qmlpropertygroup QtQuick::Item::childrenRect | - | ||||||||||||||||||||||||
3687 | \qmlproperty real QtQuick::Item::childrenRect.x | - | ||||||||||||||||||||||||
3688 | \qmlproperty real QtQuick::Item::childrenRect.y | - | ||||||||||||||||||||||||
3689 | \qmlproperty real QtQuick::Item::childrenRect.width | - | ||||||||||||||||||||||||
3690 | \qmlproperty real QtQuick::Item::childrenRect.height | - | ||||||||||||||||||||||||
3691 | \readonly | - | ||||||||||||||||||||||||
3692 | - | |||||||||||||||||||||||||
3693 | This read-only property holds the collective position and size of the item's | - | ||||||||||||||||||||||||
3694 | children. | - | ||||||||||||||||||||||||
3695 | - | |||||||||||||||||||||||||
3696 | This property is useful if you need to access the collective geometry | - | ||||||||||||||||||||||||
3697 | of an item's children in order to correctly size the item. | - | ||||||||||||||||||||||||
3698 | */ | - | ||||||||||||||||||||||||
3699 | /*! | - | ||||||||||||||||||||||||
3700 | \property QQuickItem::childrenRect | - | ||||||||||||||||||||||||
3701 | - | |||||||||||||||||||||||||
3702 | This property holds the collective position and size of the item's | - | ||||||||||||||||||||||||
3703 | children. | - | ||||||||||||||||||||||||
3704 | - | |||||||||||||||||||||||||
3705 | This property is useful if you need to access the collective geometry | - | ||||||||||||||||||||||||
3706 | of an item's children in order to correctly size the item. | - | ||||||||||||||||||||||||
3707 | */ | - | ||||||||||||||||||||||||
3708 | QRectF QQuickItem::childrenRect() | - | ||||||||||||||||||||||||
3709 | { | - | ||||||||||||||||||||||||
3710 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
3711 | if (!d->extra.isAllocated() || !d->extra->contents) {
| 18-506 | ||||||||||||||||||||||||
3712 | d->extra.value().contents = new QQuickContents(this); | - | ||||||||||||||||||||||||
3713 | if (d->componentComplete)
| 22-72 | ||||||||||||||||||||||||
3714 | d->extra->contents->complete(); executed 22 times by 4 tests: d->extra->contents->complete(); Executed by:
| 22 | ||||||||||||||||||||||||
3715 | } executed 94 times by 5 tests: end of block Executed by:
| 94 | ||||||||||||||||||||||||
3716 | return d->extra->contents->rectF(); executed 524 times by 5 tests: return d->extra->contents->rectF(); Executed by:
| 524 | ||||||||||||||||||||||||
3717 | } | - | ||||||||||||||||||||||||
3718 | - | |||||||||||||||||||||||||
3719 | /*! | - | ||||||||||||||||||||||||
3720 | Returns the children of this item. | - | ||||||||||||||||||||||||
3721 | */ | - | ||||||||||||||||||||||||
3722 | QList<QQuickItem *> QQuickItem::childItems() const | - | ||||||||||||||||||||||||
3723 | { | - | ||||||||||||||||||||||||
3724 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
3725 | return d->childItems; executed 15292006 times by 83 tests: return d->childItems; Executed by:
| 15292006 | ||||||||||||||||||||||||
3726 | } | - | ||||||||||||||||||||||||
3727 | - | |||||||||||||||||||||||||
3728 | /*! | - | ||||||||||||||||||||||||
3729 | \qmlproperty bool QtQuick::Item::clip | - | ||||||||||||||||||||||||
3730 | This property holds whether clipping is enabled. The default clip value is \c false. | - | ||||||||||||||||||||||||
3731 | - | |||||||||||||||||||||||||
3732 | If clipping is enabled, an item will clip its own painting, as well | - | ||||||||||||||||||||||||
3733 | as the painting of its children, to its bounding rectangle. | - | ||||||||||||||||||||||||
3734 | */ | - | ||||||||||||||||||||||||
3735 | /*! | - | ||||||||||||||||||||||||
3736 | \property QQuickItem::clip | - | ||||||||||||||||||||||||
3737 | This property holds whether clipping is enabled. The default clip value is \c false. | - | ||||||||||||||||||||||||
3738 | - | |||||||||||||||||||||||||
3739 | If clipping is enabled, an item will clip its own painting, as well | - | ||||||||||||||||||||||||
3740 | as the painting of its children, to its bounding rectangle. If you set | - | ||||||||||||||||||||||||
3741 | clipping during an item's paint operation, remember to re-set it to | - | ||||||||||||||||||||||||
3742 | prevent clipping the rest of your scene. | - | ||||||||||||||||||||||||
3743 | */ | - | ||||||||||||||||||||||||
3744 | bool QQuickItem::clip() const | - | ||||||||||||||||||||||||
3745 | { | - | ||||||||||||||||||||||||
3746 | return flags() & ItemClipsChildrenToShape; executed 321636 times by 82 tests: return flags() & ItemClipsChildrenToShape; Executed by:
| 321636 | ||||||||||||||||||||||||
3747 | } | - | ||||||||||||||||||||||||
3748 | - | |||||||||||||||||||||||||
3749 | void QQuickItem::setClip(bool c) | - | ||||||||||||||||||||||||
3750 | { | - | ||||||||||||||||||||||||
3751 | if (clip() == c)
| 10-272 | ||||||||||||||||||||||||
3752 | return; executed 10 times by 2 tests: return; Executed by:
| 10 | ||||||||||||||||||||||||
3753 | - | |||||||||||||||||||||||||
3754 | setFlag(ItemClipsChildrenToShape, c); | - | ||||||||||||||||||||||||
3755 | - | |||||||||||||||||||||||||
3756 | emit clipChanged(c); | - | ||||||||||||||||||||||||
3757 | } executed 272 times by 11 tests: end of block Executed by:
| 272 | ||||||||||||||||||||||||
3758 | - | |||||||||||||||||||||||||
3759 | - | |||||||||||||||||||||||||
3760 | /*! | - | ||||||||||||||||||||||||
3761 | This function is called to handle this item's changes in | - | ||||||||||||||||||||||||
3762 | geometry from \a oldGeometry to \a newGeometry. If the two | - | ||||||||||||||||||||||||
3763 | geometries are the same, it doesn't do anything. | - | ||||||||||||||||||||||||
3764 | - | |||||||||||||||||||||||||
3765 | Derived classes must call the base class method within their implementation. | - | ||||||||||||||||||||||||
3766 | */ | - | ||||||||||||||||||||||||
3767 | void QQuickItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | - | ||||||||||||||||||||||||
3768 | { | - | ||||||||||||||||||||||||
3769 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
3770 | - | |||||||||||||||||||||||||
3771 | if (d->_anchors)
| 41916-1166123 | ||||||||||||||||||||||||
3772 | QQuickAnchorsPrivate::get(d->_anchors)->updateMe(); executed 41916 times by 75 tests: QQuickAnchorsPrivate::get(d->_anchors)->updateMe(); Executed by:
| 41916 | ||||||||||||||||||||||||
3773 | - | |||||||||||||||||||||||||
3774 | QQuickGeometryChange change; | - | ||||||||||||||||||||||||
3775 | change.setXChange(newGeometry.x() != oldGeometry.x()); | - | ||||||||||||||||||||||||
3776 | change.setYChange(newGeometry.y() != oldGeometry.y()); | - | ||||||||||||||||||||||||
3777 | change.setWidthChange(newGeometry.width() != oldGeometry.width()); | - | ||||||||||||||||||||||||
3778 | change.setHeightChange(newGeometry.height() != oldGeometry.height()); | - | ||||||||||||||||||||||||
3779 | - | |||||||||||||||||||||||||
3780 | if (!d->changeListeners.isEmpty()) {
| 383677-824362 | ||||||||||||||||||||||||
3781 | const auto listeners = d->changeListeners; // NOTE: intentional copy (QTBUG-54732) | - | ||||||||||||||||||||||||
3782 | for (const QQuickItemPrivate::ChangeListener &listener : listeners) { | - | ||||||||||||||||||||||||
3783 | if (listener.types & QQuickItemPrivate::Geometry) {
| 1516-399921 | ||||||||||||||||||||||||
3784 | if (change.matches(listener.gTypes))
| 11600-388321 | ||||||||||||||||||||||||
3785 | listener.listener->itemGeometryChanged(this, change, oldGeometry); executed 388321 times by 47 tests: listener.listener->itemGeometryChanged(this, change, oldGeometry); Executed by:
| 388321 | ||||||||||||||||||||||||
3786 | } executed 399921 times by 49 tests: end of block Executed by:
| 399921 | ||||||||||||||||||||||||
3787 | } executed 401437 times by 51 tests: end of block Executed by:
| 401437 | ||||||||||||||||||||||||
3788 | } executed 383677 times by 51 tests: end of block Executed by:
| 383677 | ||||||||||||||||||||||||
3789 | - | |||||||||||||||||||||||||
3790 | if (change.xChange())
| 283863-924176 | ||||||||||||||||||||||||
3791 | emit xChanged(); executed 283863 times by 51 tests: xChanged(); Executed by:
| 283863 | ||||||||||||||||||||||||
3792 | if (change.yChange())
| 285264-922775 | ||||||||||||||||||||||||
3793 | emit yChanged(); executed 285264 times by 56 tests: yChanged(); Executed by:
| 285264 | ||||||||||||||||||||||||
3794 | if (change.widthChange())
| 511619-696420 | ||||||||||||||||||||||||
3795 | emit widthChanged(); executed 511619 times by 100 tests: widthChanged(); Executed by:
| 511619 | ||||||||||||||||||||||||
3796 | if (change.heightChange())
| 419729-788310 | ||||||||||||||||||||||||
3797 | emit heightChanged(); executed 419729 times by 100 tests: heightChanged(); Executed by:
| 419729 | ||||||||||||||||||||||||
3798 | } executed 1208039 times by 102 tests: end of block Executed by:
| 1208039 | ||||||||||||||||||||||||
3799 | - | |||||||||||||||||||||||||
3800 | /*! | - | ||||||||||||||||||||||||
3801 | Called on the render thread when it is time to sync the state | - | ||||||||||||||||||||||||
3802 | of the item with the scene graph. | - | ||||||||||||||||||||||||
3803 | - | |||||||||||||||||||||||||
3804 | The function is called as a result of QQuickItem::update(), if | - | ||||||||||||||||||||||||
3805 | the user has set the QQuickItem::ItemHasContents flag on the item. | - | ||||||||||||||||||||||||
3806 | - | |||||||||||||||||||||||||
3807 | The function should return the root of the scene graph subtree for | - | ||||||||||||||||||||||||
3808 | this item. Most implementations will return a single | - | ||||||||||||||||||||||||
3809 | QSGGeometryNode containing the visual representation of this item. | - | ||||||||||||||||||||||||
3810 | \a oldNode is the node that was returned the last time the | - | ||||||||||||||||||||||||
3811 | function was called. \a updatePaintNodeData provides a pointer to | - | ||||||||||||||||||||||||
3812 | the QSGTransformNode associated with this QQuickItem. | - | ||||||||||||||||||||||||
3813 | - | |||||||||||||||||||||||||
3814 | \code | - | ||||||||||||||||||||||||
3815 | QSGNode *MyItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *) | - | ||||||||||||||||||||||||
3816 | { | - | ||||||||||||||||||||||||
3817 | QSGSimpleRectNode *n = static_cast<QSGSimpleRectNode *>(node); | - | ||||||||||||||||||||||||
3818 | if (!n) { | - | ||||||||||||||||||||||||
3819 | n = new QSGSimpleRectNode(); | - | ||||||||||||||||||||||||
3820 | n->setColor(Qt::red); | - | ||||||||||||||||||||||||
3821 | } | - | ||||||||||||||||||||||||
3822 | n->setRect(boundingRect()); | - | ||||||||||||||||||||||||
3823 | return n; | - | ||||||||||||||||||||||||
3824 | } | - | ||||||||||||||||||||||||
3825 | \endcode | - | ||||||||||||||||||||||||
3826 | - | |||||||||||||||||||||||||
3827 | The main thread is blocked while this function is executed so it is safe to read | - | ||||||||||||||||||||||||
3828 | values from the QQuickItem instance and other objects in the main thread. | - | ||||||||||||||||||||||||
3829 | - | |||||||||||||||||||||||||
3830 | If no call to QQuickItem::updatePaintNode() result in actual scene graph | - | ||||||||||||||||||||||||
3831 | changes, like QSGNode::markDirty() or adding and removing nodes, then | - | ||||||||||||||||||||||||
3832 | the underlying implementation may decide to not render the scene again as | - | ||||||||||||||||||||||||
3833 | the visual outcome is identical. | - | ||||||||||||||||||||||||
3834 | - | |||||||||||||||||||||||||
3835 | \warning It is crucial that OpenGL operations and interaction with | - | ||||||||||||||||||||||||
3836 | the scene graph happens exclusively on the render thread, | - | ||||||||||||||||||||||||
3837 | primarily during the QQuickItem::updatePaintNode() call. The best | - | ||||||||||||||||||||||||
3838 | rule of thumb is to only use classes with the "QSG" prefix inside | - | ||||||||||||||||||||||||
3839 | the QQuickItem::updatePaintNode() function. | - | ||||||||||||||||||||||||
3840 | - | |||||||||||||||||||||||||
3841 | \warning This function is called on the render thread. This means any | - | ||||||||||||||||||||||||
3842 | QObjects or thread local storage that is created will have affinity to the | - | ||||||||||||||||||||||||
3843 | render thread, so apply caution when doing anything other than rendering | - | ||||||||||||||||||||||||
3844 | in this function. Similarly for signals, these will be emitted on the render | - | ||||||||||||||||||||||||
3845 | thread and will thus often be delivered via queued connections. | - | ||||||||||||||||||||||||
3846 | - | |||||||||||||||||||||||||
3847 | \note All classes with QSG prefix should be used solely on the scene graph's | - | ||||||||||||||||||||||||
3848 | rendering thread. See \l {Scene Graph and Rendering} for more information. | - | ||||||||||||||||||||||||
3849 | - | |||||||||||||||||||||||||
3850 | \sa QSGMaterial, QSGSimpleMaterial, QSGGeometryNode, QSGGeometry, | - | ||||||||||||||||||||||||
3851 | QSGFlatColorMaterial, QSGTextureMaterial, QSGNode::markDirty(), {Graphics Resource Handling} | - | ||||||||||||||||||||||||
3852 | */ | - | ||||||||||||||||||||||||
3853 | - | |||||||||||||||||||||||||
3854 | QSGNode *QQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) | - | ||||||||||||||||||||||||
3855 | { | - | ||||||||||||||||||||||||
3856 | Q_UNUSED(updatePaintNodeData) | - | ||||||||||||||||||||||||
3857 | delete oldNode; | - | ||||||||||||||||||||||||
3858 | return nullptr; executed 354 times by 2 tests: return nullptr; Executed by:
| 354 | ||||||||||||||||||||||||
3859 | } | - | ||||||||||||||||||||||||
3860 | - | |||||||||||||||||||||||||
3861 | QQuickItem::UpdatePaintNodeData::UpdatePaintNodeData() | - | ||||||||||||||||||||||||
3862 | : transformNode(nullptr) | - | ||||||||||||||||||||||||
3863 | { | - | ||||||||||||||||||||||||
3864 | } executed 5366 times by 90 tests: end of block Executed by:
| 5366 | ||||||||||||||||||||||||
3865 | - | |||||||||||||||||||||||||
3866 | /*! | - | ||||||||||||||||||||||||
3867 | This function is called when an item should release graphics | - | ||||||||||||||||||||||||
3868 | resources which are not already managed by the nodes returned from | - | ||||||||||||||||||||||||
3869 | QQuickItem::updatePaintNode(). | - | ||||||||||||||||||||||||
3870 | - | |||||||||||||||||||||||||
3871 | This happens when the item is about to be removed from the window it | - | ||||||||||||||||||||||||
3872 | was previously rendering to. The item is guaranteed to have a | - | ||||||||||||||||||||||||
3873 | \l {QQuickItem::window()}{window} when the function is called. | - | ||||||||||||||||||||||||
3874 | - | |||||||||||||||||||||||||
3875 | The function is called on the GUI thread and the state of the | - | ||||||||||||||||||||||||
3876 | rendering thread, when it is used, is unknown. Objects should | - | ||||||||||||||||||||||||
3877 | not be deleted directly, but instead scheduled for cleanup | - | ||||||||||||||||||||||||
3878 | using QQuickWindow::scheduleRenderJob(). | - | ||||||||||||||||||||||||
3879 | - | |||||||||||||||||||||||||
3880 | \sa {Graphics Resource Handling} | - | ||||||||||||||||||||||||
3881 | */ | - | ||||||||||||||||||||||||
3882 | - | |||||||||||||||||||||||||
3883 | void QQuickItem::releaseResources() | - | ||||||||||||||||||||||||
3884 | { | - | ||||||||||||||||||||||||
3885 | } | - | ||||||||||||||||||||||||
3886 | - | |||||||||||||||||||||||||
3887 | QSGTransformNode *QQuickItemPrivate::createTransformNode() | - | ||||||||||||||||||||||||
3888 | { | - | ||||||||||||||||||||||||
3889 | return new QSGTransformNode; executed 323650 times by 76 tests: return new QSGTransformNode; Executed by:
| 323650 | ||||||||||||||||||||||||
3890 | } | - | ||||||||||||||||||||||||
3891 | - | |||||||||||||||||||||||||
3892 | /*! | - | ||||||||||||||||||||||||
3893 | This function should perform any layout as required for this item. | - | ||||||||||||||||||||||||
3894 | - | |||||||||||||||||||||||||
3895 | When polish() is called, the scene graph schedules a polish event for this | - | ||||||||||||||||||||||||
3896 | item. When the scene graph is ready to render this item, it calls | - | ||||||||||||||||||||||||
3897 | updatePolish() to do any item layout as required before it renders the | - | ||||||||||||||||||||||||
3898 | next frame. | - | ||||||||||||||||||||||||
3899 | */ | - | ||||||||||||||||||||||||
3900 | void QQuickItem::updatePolish() | - | ||||||||||||||||||||||||
3901 | { | - | ||||||||||||||||||||||||
3902 | } | - | ||||||||||||||||||||||||
3903 | - | |||||||||||||||||||||||||
3904 | void QQuickItemPrivate::addItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types) | - | ||||||||||||||||||||||||
3905 | { | - | ||||||||||||||||||||||||
3906 | changeListeners.append(ChangeListener(listener, types)); | - | ||||||||||||||||||||||||
3907 | } executed 141531 times by 93 tests: end of block Executed by:
| 141531 | ||||||||||||||||||||||||
3908 | - | |||||||||||||||||||||||||
3909 | void QQuickItemPrivate::removeItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types) | - | ||||||||||||||||||||||||
3910 | { | - | ||||||||||||||||||||||||
3911 | ChangeListener change(listener, types); | - | ||||||||||||||||||||||||
3912 | changeListeners.removeOne(change); | - | ||||||||||||||||||||||||
3913 | } executed 128957 times by 38 tests: end of block Executed by:
| 128957 | ||||||||||||||||||||||||
3914 | - | |||||||||||||||||||||||||
3915 | void QQuickItemPrivate::updateOrAddGeometryChangeListener(QQuickItemChangeListener *listener, | - | ||||||||||||||||||||||||
3916 | QQuickGeometryChange types) | - | ||||||||||||||||||||||||
3917 | { | - | ||||||||||||||||||||||||
3918 | ChangeListener change(listener, types); | - | ||||||||||||||||||||||||
3919 | int index = changeListeners.indexOf(change); | - | ||||||||||||||||||||||||
3920 | if (index > -1)
| 44-12658 | ||||||||||||||||||||||||
3921 | changeListeners[index].gTypes = change.gTypes; //we may have different GeometryChangeTypes executed 44 times by 4 tests: changeListeners[index].gTypes = change.gTypes; Executed by:
| 44 | ||||||||||||||||||||||||
3922 | else | - | ||||||||||||||||||||||||
3923 | changeListeners.append(change); executed 12658 times by 75 tests: changeListeners.append(change); Executed by:
| 12658 | ||||||||||||||||||||||||
3924 | } | - | ||||||||||||||||||||||||
3925 | - | |||||||||||||||||||||||||
3926 | void QQuickItemPrivate::updateOrRemoveGeometryChangeListener(QQuickItemChangeListener *listener, | - | ||||||||||||||||||||||||
3927 | QQuickGeometryChange types) | - | ||||||||||||||||||||||||
3928 | { | - | ||||||||||||||||||||||||
3929 | ChangeListener change(listener, types); | - | ||||||||||||||||||||||||
3930 | if (types.noChange()) {
| 50-722 | ||||||||||||||||||||||||
3931 | changeListeners.removeOne(change); | - | ||||||||||||||||||||||||
3932 | } else { executed 722 times by 18 tests: end of block Executed by:
| 722 | ||||||||||||||||||||||||
3933 | int index = changeListeners.indexOf(change); | - | ||||||||||||||||||||||||
3934 | if (index > -1)
| 0-50 | ||||||||||||||||||||||||
3935 | changeListeners[index].gTypes = change.gTypes; //we may have different GeometryChangeTypes executed 50 times by 4 tests: changeListeners[index].gTypes = change.gTypes; Executed by:
| 50 | ||||||||||||||||||||||||
3936 | } executed 50 times by 4 tests: end of block Executed by:
| 50 | ||||||||||||||||||||||||
3937 | } | - | ||||||||||||||||||||||||
3938 | - | |||||||||||||||||||||||||
3939 | /*! | - | ||||||||||||||||||||||||
3940 | This event handler can be reimplemented in a subclass to receive key | - | ||||||||||||||||||||||||
3941 | press events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
3942 | \a event parameter. | - | ||||||||||||||||||||||||
3943 | */ | - | ||||||||||||||||||||||||
3944 | void QQuickItem::keyPressEvent(QKeyEvent *event) | - | ||||||||||||||||||||||||
3945 | { | - | ||||||||||||||||||||||||
3946 | event->ignore(); | - | ||||||||||||||||||||||||
3947 | } executed 1654 times by 7 tests: end of block Executed by:
| 1654 | ||||||||||||||||||||||||
3948 | - | |||||||||||||||||||||||||
3949 | /*! | - | ||||||||||||||||||||||||
3950 | This event handler can be reimplemented in a subclass to receive key | - | ||||||||||||||||||||||||
3951 | release events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
3952 | \a event parameter. | - | ||||||||||||||||||||||||
3953 | */ | - | ||||||||||||||||||||||||
3954 | void QQuickItem::keyReleaseEvent(QKeyEvent *event) | - | ||||||||||||||||||||||||
3955 | { | - | ||||||||||||||||||||||||
3956 | event->ignore(); | - | ||||||||||||||||||||||||
3957 | } executed 4850 times by 7 tests: end of block Executed by:
| 4850 | ||||||||||||||||||||||||
3958 | - | |||||||||||||||||||||||||
3959 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
3960 | /*! | - | ||||||||||||||||||||||||
3961 | This event handler can be reimplemented in a subclass to receive input | - | ||||||||||||||||||||||||
3962 | method events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
3963 | \a event parameter. | - | ||||||||||||||||||||||||
3964 | */ | - | ||||||||||||||||||||||||
3965 | void QQuickItem::inputMethodEvent(QInputMethodEvent *event) | - | ||||||||||||||||||||||||
3966 | { | - | ||||||||||||||||||||||||
3967 | event->ignore(); | - | ||||||||||||||||||||||||
3968 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3969 | #endif // im | - | ||||||||||||||||||||||||
3970 | - | |||||||||||||||||||||||||
3971 | /*! | - | ||||||||||||||||||||||||
3972 | This event handler can be reimplemented in a subclass to receive focus-in | - | ||||||||||||||||||||||||
3973 | events for an item. The event information is provided by the \c event | - | ||||||||||||||||||||||||
3974 | parameter. | - | ||||||||||||||||||||||||
3975 | */ | - | ||||||||||||||||||||||||
3976 | void QQuickItem::focusInEvent(QFocusEvent * /*event*/) | - | ||||||||||||||||||||||||
3977 | { | - | ||||||||||||||||||||||||
3978 | #if QT_CONFIG(accessibility) | - | ||||||||||||||||||||||||
3979 | if (QAccessible::isActive()) {
| 4-2104 | ||||||||||||||||||||||||
3980 | if (QObject *acc = QQuickAccessibleAttached::findAccessible(this)) {
| 2 | ||||||||||||||||||||||||
3981 | QAccessibleEvent ev(acc, QAccessible::Focus); | - | ||||||||||||||||||||||||
3982 | QAccessible::updateAccessibility(&ev); | - | ||||||||||||||||||||||||
3983 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3984 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
3985 | #endif | - | ||||||||||||||||||||||||
3986 | } executed 2108 times by 18 tests: end of block Executed by:
| 2108 | ||||||||||||||||||||||||
3987 | - | |||||||||||||||||||||||||
3988 | /*! | - | ||||||||||||||||||||||||
3989 | This event handler can be reimplemented in a subclass to receive focus-out | - | ||||||||||||||||||||||||
3990 | events for an item. The event information is provided by the \c event | - | ||||||||||||||||||||||||
3991 | parameter. | - | ||||||||||||||||||||||||
3992 | */ | - | ||||||||||||||||||||||||
3993 | void QQuickItem::focusOutEvent(QFocusEvent * /*event*/) | - | ||||||||||||||||||||||||
3994 | { | - | ||||||||||||||||||||||||
3995 | } | - | ||||||||||||||||||||||||
3996 | - | |||||||||||||||||||||||||
3997 | /*! | - | ||||||||||||||||||||||||
3998 | This event handler can be reimplemented in a subclass to receive mouse | - | ||||||||||||||||||||||||
3999 | press events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
4000 | \a event parameter. | - | ||||||||||||||||||||||||
4001 | */ | - | ||||||||||||||||||||||||
4002 | void QQuickItem::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
4003 | { | - | ||||||||||||||||||||||||
4004 | event->ignore(); | - | ||||||||||||||||||||||||
4005 | } executed 406 times by 10 tests: end of block Executed by:
| 406 | ||||||||||||||||||||||||
4006 | - | |||||||||||||||||||||||||
4007 | /*! | - | ||||||||||||||||||||||||
4008 | This event handler can be reimplemented in a subclass to receive mouse | - | ||||||||||||||||||||||||
4009 | move events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
4010 | \a event parameter. | - | ||||||||||||||||||||||||
4011 | */ | - | ||||||||||||||||||||||||
4012 | void QQuickItem::mouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
4013 | { | - | ||||||||||||||||||||||||
4014 | event->ignore(); | - | ||||||||||||||||||||||||
4015 | } executed 20 times by 2 tests: end of block Executed by:
| 20 | ||||||||||||||||||||||||
4016 | - | |||||||||||||||||||||||||
4017 | /*! | - | ||||||||||||||||||||||||
4018 | This event handler can be reimplemented in a subclass to receive mouse | - | ||||||||||||||||||||||||
4019 | release events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
4020 | \a event parameter. | - | ||||||||||||||||||||||||
4021 | */ | - | ||||||||||||||||||||||||
4022 | void QQuickItem::mouseReleaseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
4023 | { | - | ||||||||||||||||||||||||
4024 | event->ignore(); | - | ||||||||||||||||||||||||
4025 | } executed 20 times by 3 tests: end of block Executed by:
| 20 | ||||||||||||||||||||||||
4026 | - | |||||||||||||||||||||||||
4027 | /*! | - | ||||||||||||||||||||||||
4028 | This event handler can be reimplemented in a subclass to receive mouse | - | ||||||||||||||||||||||||
4029 | double-click events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
4030 | \a event parameter. | - | ||||||||||||||||||||||||
4031 | */ | - | ||||||||||||||||||||||||
4032 | void QQuickItem::mouseDoubleClickEvent(QMouseEvent *) | - | ||||||||||||||||||||||||
4033 | { | - | ||||||||||||||||||||||||
4034 | } | - | ||||||||||||||||||||||||
4035 | - | |||||||||||||||||||||||||
4036 | /*! | - | ||||||||||||||||||||||||
4037 | This event handler can be reimplemented in a subclass to be notified | - | ||||||||||||||||||||||||
4038 | when a mouse ungrab event has occurred on this item. | - | ||||||||||||||||||||||||
4039 | - | |||||||||||||||||||||||||
4040 | \sa ungrabMouse() | - | ||||||||||||||||||||||||
4041 | */ | - | ||||||||||||||||||||||||
4042 | void QQuickItem::mouseUngrabEvent() | - | ||||||||||||||||||||||||
4043 | { | - | ||||||||||||||||||||||||
4044 | // XXX todo | - | ||||||||||||||||||||||||
4045 | } | - | ||||||||||||||||||||||||
4046 | - | |||||||||||||||||||||||||
4047 | /*! | - | ||||||||||||||||||||||||
4048 | This event handler can be reimplemented in a subclass to be notified | - | ||||||||||||||||||||||||
4049 | when a touch ungrab event has occurred on this item. | - | ||||||||||||||||||||||||
4050 | */ | - | ||||||||||||||||||||||||
4051 | void QQuickItem::touchUngrabEvent() | - | ||||||||||||||||||||||||
4052 | { | - | ||||||||||||||||||||||||
4053 | // XXX todo | - | ||||||||||||||||||||||||
4054 | } | - | ||||||||||||||||||||||||
4055 | - | |||||||||||||||||||||||||
4056 | #if QT_CONFIG(wheelevent) | - | ||||||||||||||||||||||||
4057 | /*! | - | ||||||||||||||||||||||||
4058 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||
4059 | wheel events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
4060 | \a event parameter. | - | ||||||||||||||||||||||||
4061 | */ | - | ||||||||||||||||||||||||
4062 | void QQuickItem::wheelEvent(QWheelEvent *event) | - | ||||||||||||||||||||||||
4063 | { | - | ||||||||||||||||||||||||
4064 | event->ignore(); | - | ||||||||||||||||||||||||
4065 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
4066 | #endif | - | ||||||||||||||||||||||||
4067 | - | |||||||||||||||||||||||||
4068 | /*! | - | ||||||||||||||||||||||||
4069 | This event handler can be reimplemented in a subclass to receive touch | - | ||||||||||||||||||||||||
4070 | events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
4071 | \a event parameter. | - | ||||||||||||||||||||||||
4072 | */ | - | ||||||||||||||||||||||||
4073 | void QQuickItem::touchEvent(QTouchEvent *event) | - | ||||||||||||||||||||||||
4074 | { | - | ||||||||||||||||||||||||
4075 | event->ignore(); | - | ||||||||||||||||||||||||
4076 | } executed 249 times by 10 tests: end of block Executed by:
| 249 | ||||||||||||||||||||||||
4077 | - | |||||||||||||||||||||||||
4078 | /*! | - | ||||||||||||||||||||||||
4079 | This event handler can be reimplemented in a subclass to receive hover-enter | - | ||||||||||||||||||||||||
4080 | events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
4081 | \a event parameter. | - | ||||||||||||||||||||||||
4082 | - | |||||||||||||||||||||||||
4083 | Hover events are only provided if acceptHoverEvents() is true. | - | ||||||||||||||||||||||||
4084 | */ | - | ||||||||||||||||||||||||
4085 | void QQuickItem::hoverEnterEvent(QHoverEvent *event) | - | ||||||||||||||||||||||||
4086 | { | - | ||||||||||||||||||||||||
4087 | Q_UNUSED(event); | - | ||||||||||||||||||||||||
4088 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4089 | - | |||||||||||||||||||||||||
4090 | /*! | - | ||||||||||||||||||||||||
4091 | This event handler can be reimplemented in a subclass to receive hover-move | - | ||||||||||||||||||||||||
4092 | events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
4093 | \a event parameter. | - | ||||||||||||||||||||||||
4094 | - | |||||||||||||||||||||||||
4095 | Hover events are only provided if acceptHoverEvents() is true. | - | ||||||||||||||||||||||||
4096 | */ | - | ||||||||||||||||||||||||
4097 | void QQuickItem::hoverMoveEvent(QHoverEvent *event) | - | ||||||||||||||||||||||||
4098 | { | - | ||||||||||||||||||||||||
4099 | Q_UNUSED(event); | - | ||||||||||||||||||||||||
4100 | } executed 28 times by 1 test: end of block Executed by:
| 28 | ||||||||||||||||||||||||
4101 | - | |||||||||||||||||||||||||
4102 | /*! | - | ||||||||||||||||||||||||
4103 | This event handler can be reimplemented in a subclass to receive hover-leave | - | ||||||||||||||||||||||||
4104 | events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
4105 | \a event parameter. | - | ||||||||||||||||||||||||
4106 | - | |||||||||||||||||||||||||
4107 | Hover events are only provided if acceptHoverEvents() is true. | - | ||||||||||||||||||||||||
4108 | */ | - | ||||||||||||||||||||||||
4109 | void QQuickItem::hoverLeaveEvent(QHoverEvent *event) | - | ||||||||||||||||||||||||
4110 | { | - | ||||||||||||||||||||||||
4111 | Q_UNUSED(event); | - | ||||||||||||||||||||||||
4112 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4113 | - | |||||||||||||||||||||||||
4114 | #if QT_CONFIG(draganddrop) | - | ||||||||||||||||||||||||
4115 | /*! | - | ||||||||||||||||||||||||
4116 | This event handler can be reimplemented in a subclass to receive drag-enter | - | ||||||||||||||||||||||||
4117 | events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
4118 | \a event parameter. | - | ||||||||||||||||||||||||
4119 | - | |||||||||||||||||||||||||
4120 | Drag and drop events are only provided if the ItemAcceptsDrops flag | - | ||||||||||||||||||||||||
4121 | has been set for this item. | - | ||||||||||||||||||||||||
4122 | - | |||||||||||||||||||||||||
4123 | \sa Drag, {Drag and Drop} | - | ||||||||||||||||||||||||
4124 | */ | - | ||||||||||||||||||||||||
4125 | void QQuickItem::dragEnterEvent(QDragEnterEvent *event) | - | ||||||||||||||||||||||||
4126 | { | - | ||||||||||||||||||||||||
4127 | Q_UNUSED(event); | - | ||||||||||||||||||||||||
4128 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4129 | - | |||||||||||||||||||||||||
4130 | /*! | - | ||||||||||||||||||||||||
4131 | This event handler can be reimplemented in a subclass to receive drag-move | - | ||||||||||||||||||||||||
4132 | events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
4133 | \a event parameter. | - | ||||||||||||||||||||||||
4134 | - | |||||||||||||||||||||||||
4135 | Drag and drop events are only provided if the ItemAcceptsDrops flag | - | ||||||||||||||||||||||||
4136 | has been set for this item. | - | ||||||||||||||||||||||||
4137 | - | |||||||||||||||||||||||||
4138 | \sa Drag, {Drag and Drop} | - | ||||||||||||||||||||||||
4139 | */ | - | ||||||||||||||||||||||||
4140 | void QQuickItem::dragMoveEvent(QDragMoveEvent *event) | - | ||||||||||||||||||||||||
4141 | { | - | ||||||||||||||||||||||||
4142 | Q_UNUSED(event); | - | ||||||||||||||||||||||||
4143 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4144 | - | |||||||||||||||||||||||||
4145 | /*! | - | ||||||||||||||||||||||||
4146 | This event handler can be reimplemented in a subclass to receive drag-leave | - | ||||||||||||||||||||||||
4147 | events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
4148 | \a event parameter. | - | ||||||||||||||||||||||||
4149 | - | |||||||||||||||||||||||||
4150 | Drag and drop events are only provided if the ItemAcceptsDrops flag | - | ||||||||||||||||||||||||
4151 | has been set for this item. | - | ||||||||||||||||||||||||
4152 | - | |||||||||||||||||||||||||
4153 | \sa Drag, {Drag and Drop} | - | ||||||||||||||||||||||||
4154 | */ | - | ||||||||||||||||||||||||
4155 | void QQuickItem::dragLeaveEvent(QDragLeaveEvent *event) | - | ||||||||||||||||||||||||
4156 | { | - | ||||||||||||||||||||||||
4157 | Q_UNUSED(event); | - | ||||||||||||||||||||||||
4158 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4159 | - | |||||||||||||||||||||||||
4160 | /*! | - | ||||||||||||||||||||||||
4161 | This event handler can be reimplemented in a subclass to receive drop | - | ||||||||||||||||||||||||
4162 | events for an item. The event information is provided by the | - | ||||||||||||||||||||||||
4163 | \a event parameter. | - | ||||||||||||||||||||||||
4164 | - | |||||||||||||||||||||||||
4165 | Drag and drop events are only provided if the ItemAcceptsDrops flag | - | ||||||||||||||||||||||||
4166 | has been set for this item. | - | ||||||||||||||||||||||||
4167 | - | |||||||||||||||||||||||||
4168 | \sa Drag, {Drag and Drop} | - | ||||||||||||||||||||||||
4169 | */ | - | ||||||||||||||||||||||||
4170 | void QQuickItem::dropEvent(QDropEvent *event) | - | ||||||||||||||||||||||||
4171 | { | - | ||||||||||||||||||||||||
4172 | Q_UNUSED(event); | - | ||||||||||||||||||||||||
4173 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4174 | #endif // draganddrop | - | ||||||||||||||||||||||||
4175 | - | |||||||||||||||||||||||||
4176 | /*! | - | ||||||||||||||||||||||||
4177 | Reimplement this method to filter the mouse events that are received by | - | ||||||||||||||||||||||||
4178 | this item's children. | - | ||||||||||||||||||||||||
4179 | - | |||||||||||||||||||||||||
4180 | This method will only be called if filtersChildMouseEvents() is true. | - | ||||||||||||||||||||||||
4181 | - | |||||||||||||||||||||||||
4182 | Return true if the specified \a event should not be passed onto the | - | ||||||||||||||||||||||||
4183 | specified child \a item, and false otherwise. | - | ||||||||||||||||||||||||
4184 | - | |||||||||||||||||||||||||
4185 | \sa setFiltersChildMouseEvents() | - | ||||||||||||||||||||||||
4186 | */ | - | ||||||||||||||||||||||||
4187 | bool QQuickItem::childMouseEventFilter(QQuickItem *item, QEvent *event) | - | ||||||||||||||||||||||||
4188 | { | - | ||||||||||||||||||||||||
4189 | Q_UNUSED(item); | - | ||||||||||||||||||||||||
4190 | Q_UNUSED(event); | - | ||||||||||||||||||||||||
4191 | return false; executed 644 times by 6 tests: return false; Executed by:
| 644 | ||||||||||||||||||||||||
4192 | } | - | ||||||||||||||||||||||||
4193 | - | |||||||||||||||||||||||||
4194 | /*! | - | ||||||||||||||||||||||||
4195 | \internal | - | ||||||||||||||||||||||||
4196 | */ | - | ||||||||||||||||||||||||
4197 | void QQuickItem::windowDeactivateEvent() | - | ||||||||||||||||||||||||
4198 | { | - | ||||||||||||||||||||||||
4199 | const auto children = childItems(); | - | ||||||||||||||||||||||||
4200 | for (QQuickItem* item : children) { | - | ||||||||||||||||||||||||
4201 | item->windowDeactivateEvent(); | - | ||||||||||||||||||||||||
4202 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
4203 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
4204 | - | |||||||||||||||||||||||||
4205 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
4206 | /*! | - | ||||||||||||||||||||||||
4207 | This method is only relevant for input items. | - | ||||||||||||||||||||||||
4208 | - | |||||||||||||||||||||||||
4209 | If this item is an input item, this method should be reimplemented to | - | ||||||||||||||||||||||||
4210 | return the relevant input method flags for the given \a query. | - | ||||||||||||||||||||||||
4211 | - | |||||||||||||||||||||||||
4212 | \sa QWidget::inputMethodQuery() | - | ||||||||||||||||||||||||
4213 | */ | - | ||||||||||||||||||||||||
4214 | QVariant QQuickItem::inputMethodQuery(Qt::InputMethodQuery query) const | - | ||||||||||||||||||||||||
4215 | { | - | ||||||||||||||||||||||||
4216 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
4217 | QVariant v; | - | ||||||||||||||||||||||||
4218 | - | |||||||||||||||||||||||||
4219 | switch (query) { | - | ||||||||||||||||||||||||
4220 | case Qt::ImEnabled: executed 7677 times by 17 tests: case Qt::ImEnabled: Executed by:
| 7677 | ||||||||||||||||||||||||
4221 | v = (bool)(flags() & ItemAcceptsInputMethod); | - | ||||||||||||||||||||||||
4222 | break; executed 7677 times by 17 tests: break; Executed by:
| 7677 | ||||||||||||||||||||||||
4223 | case Qt::ImHints: executed 1428 times by 17 tests: case Qt::ImHints: Executed by:
| 1428 | ||||||||||||||||||||||||
4224 | case Qt::ImAnchorRectangle: never executed: case Qt::ImAnchorRectangle: | 0 | ||||||||||||||||||||||||
4225 | case Qt::ImCursorRectangle: never executed: case Qt::ImCursorRectangle: | 0 | ||||||||||||||||||||||||
4226 | case Qt::ImFont: never executed: case Qt::ImFont: | 0 | ||||||||||||||||||||||||
4227 | case Qt::ImCursorPosition: never executed: case Qt::ImCursorPosition: | 0 | ||||||||||||||||||||||||
4228 | case Qt::ImSurroundingText: never executed: case Qt::ImSurroundingText: | 0 | ||||||||||||||||||||||||
4229 | case Qt::ImCurrentSelection: never executed: case Qt::ImCurrentSelection: | 0 | ||||||||||||||||||||||||
4230 | case Qt::ImMaximumTextLength: never executed: case Qt::ImMaximumTextLength: | 0 | ||||||||||||||||||||||||
4231 | case Qt::ImAnchorPosition: never executed: case Qt::ImAnchorPosition: | 0 | ||||||||||||||||||||||||
4232 | case Qt::ImPreferredLanguage: never executed: case Qt::ImPreferredLanguage: | 0 | ||||||||||||||||||||||||
4233 | if (d->extra.isAllocated() && d->extra->keyHandler)
| 146-1216 | ||||||||||||||||||||||||
4234 | v = d->extra->keyHandler->inputMethodQuery(query); executed 146 times by 5 tests: v = d->extra->keyHandler->inputMethodQuery(query); Executed by:
| 146 | ||||||||||||||||||||||||
4235 | break; executed 1428 times by 17 tests: break; Executed by:
| 1428 | ||||||||||||||||||||||||
4236 | case Qt::ImEnterKeyType: never executed: case Qt::ImEnterKeyType: | 0 | ||||||||||||||||||||||||
4237 | if (d->extra.isAllocated() && d->extra->enterKeyAttached)
| 0 | ||||||||||||||||||||||||
4238 | v = d->extra->enterKeyAttached->type(); never executed: v = d->extra->enterKeyAttached->type(); | 0 | ||||||||||||||||||||||||
4239 | break; never executed: break; | 0 | ||||||||||||||||||||||||
4240 | case Qt::ImInputItemClipRectangle: never executed: case Qt::ImInputItemClipRectangle: | 0 | ||||||||||||||||||||||||
4241 | if (!(!window() ||!isVisible() || qFuzzyIsNull(opacity()))) {
| 0 | ||||||||||||||||||||||||
4242 | QRectF rect = QRectF(0,0, width(), height()); | - | ||||||||||||||||||||||||
4243 | const QQuickItem *par = this; | - | ||||||||||||||||||||||||
4244 | while (QQuickItem *parpar = par->parentItem()) {
| 0 | ||||||||||||||||||||||||
4245 | rect = parpar->mapRectFromItem(par, rect); | - | ||||||||||||||||||||||||
4246 | if (parpar->clip())
| 0 | ||||||||||||||||||||||||
4247 | rect = rect.intersected(parpar->clipRect()); never executed: rect = rect.intersected(parpar->clipRect()); | 0 | ||||||||||||||||||||||||
4248 | par = parpar; | - | ||||||||||||||||||||||||
4249 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4250 | rect = par->mapRectToScene(rect); | - | ||||||||||||||||||||||||
4251 | // once we have the rect in scene coordinates, clip to window | - | ||||||||||||||||||||||||
4252 | rect = rect.intersected(QRectF(QPoint(0,0), window()->size())); | - | ||||||||||||||||||||||||
4253 | // map it back to local coordinates | - | ||||||||||||||||||||||||
4254 | v = mapRectFromScene(rect); | - | ||||||||||||||||||||||||
4255 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4256 | break; never executed: break; | 0 | ||||||||||||||||||||||||
4257 | default: never executed: default: | 0 | ||||||||||||||||||||||||
4258 | break; never executed: break; | 0 | ||||||||||||||||||||||||
4259 | } | - | ||||||||||||||||||||||||
4260 | - | |||||||||||||||||||||||||
4261 | return v; executed 9105 times by 17 tests: return v; Executed by:
| 9105 | ||||||||||||||||||||||||
4262 | } | - | ||||||||||||||||||||||||
4263 | #endif // im | - | ||||||||||||||||||||||||
4264 | - | |||||||||||||||||||||||||
4265 | QQuickAnchorLine QQuickItemPrivate::left() const | - | ||||||||||||||||||||||||
4266 | { | - | ||||||||||||||||||||||||
4267 | Q_Q(const QQuickItem); | - | ||||||||||||||||||||||||
4268 | return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::LeftAnchor); executed 548 times by 21 tests: return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::LeftAnchor); Executed by:
| 548 | ||||||||||||||||||||||||
4269 | } | - | ||||||||||||||||||||||||
4270 | - | |||||||||||||||||||||||||
4271 | QQuickAnchorLine QQuickItemPrivate::right() const | - | ||||||||||||||||||||||||
4272 | { | - | ||||||||||||||||||||||||
4273 | Q_Q(const QQuickItem); | - | ||||||||||||||||||||||||
4274 | return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::RightAnchor); executed 806 times by 18 tests: return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::RightAnchor); Executed by:
| 806 | ||||||||||||||||||||||||
4275 | } | - | ||||||||||||||||||||||||
4276 | - | |||||||||||||||||||||||||
4277 | QQuickAnchorLine QQuickItemPrivate::horizontalCenter() const | - | ||||||||||||||||||||||||
4278 | { | - | ||||||||||||||||||||||||
4279 | Q_Q(const QQuickItem); | - | ||||||||||||||||||||||||
4280 | return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::HCenterAnchor); executed 1452 times by 16 tests: return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::HCenterAnchor); Executed by:
| 1452 | ||||||||||||||||||||||||
4281 | } | - | ||||||||||||||||||||||||
4282 | - | |||||||||||||||||||||||||
4283 | QQuickAnchorLine QQuickItemPrivate::top() const | - | ||||||||||||||||||||||||
4284 | { | - | ||||||||||||||||||||||||
4285 | Q_Q(const QQuickItem); | - | ||||||||||||||||||||||||
4286 | return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::TopAnchor); executed 938 times by 22 tests: return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::TopAnchor); Executed by:
| 938 | ||||||||||||||||||||||||
4287 | } | - | ||||||||||||||||||||||||
4288 | - | |||||||||||||||||||||||||
4289 | QQuickAnchorLine QQuickItemPrivate::bottom() const | - | ||||||||||||||||||||||||
4290 | { | - | ||||||||||||||||||||||||
4291 | Q_Q(const QQuickItem); | - | ||||||||||||||||||||||||
4292 | return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::BottomAnchor); executed 1280 times by 23 tests: return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::BottomAnchor); Executed by:
| 1280 | ||||||||||||||||||||||||
4293 | } | - | ||||||||||||||||||||||||
4294 | - | |||||||||||||||||||||||||
4295 | QQuickAnchorLine QQuickItemPrivate::verticalCenter() const | - | ||||||||||||||||||||||||
4296 | { | - | ||||||||||||||||||||||||
4297 | Q_Q(const QQuickItem); | - | ||||||||||||||||||||||||
4298 | return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::VCenterAnchor); executed 980 times by 13 tests: return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::VCenterAnchor); Executed by:
| 980 | ||||||||||||||||||||||||
4299 | } | - | ||||||||||||||||||||||||
4300 | - | |||||||||||||||||||||||||
4301 | QQuickAnchorLine QQuickItemPrivate::baseline() const | - | ||||||||||||||||||||||||
4302 | { | - | ||||||||||||||||||||||||
4303 | Q_Q(const QQuickItem); | - | ||||||||||||||||||||||||
4304 | return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::BaselineAnchor); executed 52 times by 7 tests: return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::BaselineAnchor); Executed by:
| 52 | ||||||||||||||||||||||||
4305 | } | - | ||||||||||||||||||||||||
4306 | - | |||||||||||||||||||||||||
4307 | /*! | - | ||||||||||||||||||||||||
4308 | \qmlproperty int QtQuick::Item::baselineOffset | - | ||||||||||||||||||||||||
4309 | - | |||||||||||||||||||||||||
4310 | Specifies the position of the item's baseline in local coordinates. | - | ||||||||||||||||||||||||
4311 | - | |||||||||||||||||||||||||
4312 | The baseline of a \l Text item is the imaginary line on which the text | - | ||||||||||||||||||||||||
4313 | sits. Controls containing text usually set their baseline to the | - | ||||||||||||||||||||||||
4314 | baseline of their text. | - | ||||||||||||||||||||||||
4315 | - | |||||||||||||||||||||||||
4316 | For non-text items, a default baseline offset of 0 is used. | - | ||||||||||||||||||||||||
4317 | */ | - | ||||||||||||||||||||||||
4318 | /*! | - | ||||||||||||||||||||||||
4319 | \property QQuickItem::baselineOffset | - | ||||||||||||||||||||||||
4320 | - | |||||||||||||||||||||||||
4321 | Specifies the position of the item's baseline in local coordinates. | - | ||||||||||||||||||||||||
4322 | - | |||||||||||||||||||||||||
4323 | The baseline of a \l Text item is the imaginary line on which the text | - | ||||||||||||||||||||||||
4324 | sits. Controls containing text usually set their baseline to the | - | ||||||||||||||||||||||||
4325 | baseline of their text. | - | ||||||||||||||||||||||||
4326 | - | |||||||||||||||||||||||||
4327 | For non-text items, a default baseline offset of 0 is used. | - | ||||||||||||||||||||||||
4328 | */ | - | ||||||||||||||||||||||||
4329 | qreal QQuickItem::baselineOffset() const | - | ||||||||||||||||||||||||
4330 | { | - | ||||||||||||||||||||||||
4331 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
4332 | return d->baselineOffset; executed 2690 times by 12 tests: return d->baselineOffset; Executed by:
| 2690 | ||||||||||||||||||||||||
4333 | } | - | ||||||||||||||||||||||||
4334 | - | |||||||||||||||||||||||||
4335 | void QQuickItem::setBaselineOffset(qreal offset) | - | ||||||||||||||||||||||||
4336 | { | - | ||||||||||||||||||||||||
4337 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
4338 | if (offset == d->baselineOffset)
| 214747-269628 | ||||||||||||||||||||||||
4339 | return; executed 214747 times by 25 tests: return; Executed by:
| 214747 | ||||||||||||||||||||||||
4340 | - | |||||||||||||||||||||||||
4341 | d->baselineOffset = offset; | - | ||||||||||||||||||||||||
4342 | - | |||||||||||||||||||||||||
4343 | if (!d->changeListeners.isEmpty()) {
| 498-269130 | ||||||||||||||||||||||||
4344 | const auto listeners = d->changeListeners; // NOTE: intentional copy (QTBUG-54732) | - | ||||||||||||||||||||||||
4345 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { | - | ||||||||||||||||||||||||
4346 | if (change.types & QQuickItemPrivate::Geometry) {
| 18-730 | ||||||||||||||||||||||||
4347 | QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate(); | - | ||||||||||||||||||||||||
4348 | if (anchor)
| 34-696 | ||||||||||||||||||||||||
4349 | anchor->updateVerticalAnchors(); executed 696 times by 8 tests: anchor->updateVerticalAnchors(); Executed by:
| 696 | ||||||||||||||||||||||||
4350 | } executed 730 times by 9 tests: end of block Executed by:
| 730 | ||||||||||||||||||||||||
4351 | } executed 748 times by 10 tests: end of block Executed by:
| 748 | ||||||||||||||||||||||||
4352 | } executed 498 times by 10 tests: end of block Executed by:
| 498 | ||||||||||||||||||||||||
4353 | - | |||||||||||||||||||||||||
4354 | if (d->_anchors && (d->_anchors->usedAnchors() & QQuickAnchors::BaselineAnchor))
| 3907-265721 | ||||||||||||||||||||||||
4355 | QQuickAnchorsPrivate::get(d->_anchors)->updateVerticalAnchors(); executed 10 times by 1 test: QQuickAnchorsPrivate::get(d->_anchors)->updateVerticalAnchors(); Executed by:
| 10 | ||||||||||||||||||||||||
4356 | - | |||||||||||||||||||||||||
4357 | emit baselineOffsetChanged(offset); | - | ||||||||||||||||||||||||
4358 | } executed 269628 times by 39 tests: end of block Executed by:
| 269628 | ||||||||||||||||||||||||
4359 | - | |||||||||||||||||||||||||
4360 | - | |||||||||||||||||||||||||
4361 | /*! | - | ||||||||||||||||||||||||
4362 | * Schedules a call to updatePaintNode() for this item. | - | ||||||||||||||||||||||||
4363 | * | - | ||||||||||||||||||||||||
4364 | * The call to QQuickItem::updatePaintNode() will always happen if the | - | ||||||||||||||||||||||||
4365 | * item is showing in a QQuickWindow. | - | ||||||||||||||||||||||||
4366 | * | - | ||||||||||||||||||||||||
4367 | * Only items which specify QQuickItem::ItemHasContents are allowed | - | ||||||||||||||||||||||||
4368 | * to call QQuickItem::update(). | - | ||||||||||||||||||||||||
4369 | */ | - | ||||||||||||||||||||||||
4370 | void QQuickItem::update() | - | ||||||||||||||||||||||||
4371 | { | - | ||||||||||||||||||||||||
4372 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
4373 | if (!(flags() & ItemHasContents)) {
| 2-663579 | ||||||||||||||||||||||||
4374 | #ifndef QT_NO_DEBUG | - | ||||||||||||||||||||||||
4375 | qWarning() << metaObject()->className() << ": Update called for a item without content"; | - | ||||||||||||||||||||||||
4376 | #endif | - | ||||||||||||||||||||||||
4377 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
4378 | } | - | ||||||||||||||||||||||||
4379 | d->dirty(QQuickItemPrivate::Content); | - | ||||||||||||||||||||||||
4380 | } executed 663579 times by 94 tests: end of block Executed by:
| 663579 | ||||||||||||||||||||||||
4381 | - | |||||||||||||||||||||||||
4382 | /*! | - | ||||||||||||||||||||||||
4383 | Schedules a polish event for this item. | - | ||||||||||||||||||||||||
4384 | - | |||||||||||||||||||||||||
4385 | When the scene graph processes the request, it will call updatePolish() | - | ||||||||||||||||||||||||
4386 | on this item. | - | ||||||||||||||||||||||||
4387 | */ | - | ||||||||||||||||||||||||
4388 | void QQuickItem::polish() | - | ||||||||||||||||||||||||
4389 | { | - | ||||||||||||||||||||||||
4390 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
4391 | if (!d->polishScheduled) {
| 165142-407363 | ||||||||||||||||||||||||
4392 | d->polishScheduled = true; | - | ||||||||||||||||||||||||
4393 | if (d->window) {
| 179863-227500 | ||||||||||||||||||||||||
4394 | QQuickWindowPrivate *p = QQuickWindowPrivate::get(d->window); | - | ||||||||||||||||||||||||
4395 | bool maybeupdate = p->itemsToPolish.isEmpty(); | - | ||||||||||||||||||||||||
4396 | p->itemsToPolish.append(this); | - | ||||||||||||||||||||||||
4397 | if (maybeupdate) d->window->maybeUpdate(); executed 19291 times by 20 tests: d->window->maybeUpdate(); Executed by:
| 19291-208209 | ||||||||||||||||||||||||
4398 | } executed 227500 times by 22 tests: end of block Executed by:
| 227500 | ||||||||||||||||||||||||
4399 | } executed 407363 times by 52 tests: end of block Executed by:
| 407363 | ||||||||||||||||||||||||
4400 | } executed 572505 times by 52 tests: end of block Executed by:
| 572505 | ||||||||||||||||||||||||
4401 | - | |||||||||||||||||||||||||
4402 | /*! | - | ||||||||||||||||||||||||
4403 | \qmlmethod object QtQuick::Item::mapFromItem(Item item, real x, real y) | - | ||||||||||||||||||||||||
4404 | \qmlmethod object QtQuick::Item::mapFromItem(Item item, real x, real y, real width, real height) | - | ||||||||||||||||||||||||
4405 | - | |||||||||||||||||||||||||
4406 | Maps the point (\a x, \a y) or rect (\a x, \a y, \a width, \a height), which is in \a | - | ||||||||||||||||||||||||
4407 | item's coordinate system, to this item's coordinate system, and returns a \l point or \l rect | - | ||||||||||||||||||||||||
4408 | matching the mapped coordinate. | - | ||||||||||||||||||||||||
4409 | - | |||||||||||||||||||||||||
4410 | If \a item is a \c null value, this maps the point or rect from the coordinate system of | - | ||||||||||||||||||||||||
4411 | the root QML view. | - | ||||||||||||||||||||||||
4412 | */ | - | ||||||||||||||||||||||||
4413 | /*! | - | ||||||||||||||||||||||||
4414 | \internal | - | ||||||||||||||||||||||||
4415 | */ | - | ||||||||||||||||||||||||
4416 | void QQuickItem::mapFromItem(QQmlV4Function *args) const | - | ||||||||||||||||||||||||
4417 | { | - | ||||||||||||||||||||||||
4418 | QV4::ExecutionEngine *v4 = args->v4engine(); | - | ||||||||||||||||||||||||
4419 | if (args->length() != 3 && args->length() != 5) {
| 0-54 | ||||||||||||||||||||||||
4420 | v4->throwTypeError(); | - | ||||||||||||||||||||||||
4421 | return; never executed: return; | 0 | ||||||||||||||||||||||||
4422 | } | - | ||||||||||||||||||||||||
4423 | - | |||||||||||||||||||||||||
4424 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
4425 | QV4::ScopedValue item(scope, (*args)[0]); | - | ||||||||||||||||||||||||
4426 | - | |||||||||||||||||||||||||
4427 | QQuickItem *itemObj = nullptr; | - | ||||||||||||||||||||||||
4428 | if (!item->isNull()) {
| 28-68 | ||||||||||||||||||||||||
4429 | QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, item->as<QV4::QObjectWrapper>()); | - | ||||||||||||||||||||||||
4430 | if (qobjectWrapper)
| 28-40 | ||||||||||||||||||||||||
4431 | itemObj = qobject_cast<QQuickItem*>(qobjectWrapper->object()); executed 40 times by 2 tests: itemObj = qobject_cast<QQuickItem*>(qobjectWrapper->object()); Executed by:
| 40 | ||||||||||||||||||||||||
4432 | } executed 68 times by 2 tests: end of block Executed by:
| 68 | ||||||||||||||||||||||||
4433 | - | |||||||||||||||||||||||||
4434 | if (!itemObj && !item->isNull()) {
| 28-56 | ||||||||||||||||||||||||
4435 | qmlWarning(this) << "mapFromItem() given argument \"" << item->toQStringNoThrow() | - | ||||||||||||||||||||||||
4436 | << "\" which is neither null nor an Item"; | - | ||||||||||||||||||||||||
4437 | v4->throwTypeError(); | - | ||||||||||||||||||||||||
4438 | return; executed 28 times by 1 test: return; Executed by:
| 28 | ||||||||||||||||||||||||
4439 | } | - | ||||||||||||||||||||||||
4440 | - | |||||||||||||||||||||||||
4441 | QV4::ScopedValue vx(scope, (*args)[1]); | - | ||||||||||||||||||||||||
4442 | QV4::ScopedValue vy(scope, (*args)[2]); | - | ||||||||||||||||||||||||
4443 | - | |||||||||||||||||||||||||
4444 | if (!vx->isNumber() || !vy->isNumber()) {
| 0-68 | ||||||||||||||||||||||||
4445 | v4->throwTypeError(); | - | ||||||||||||||||||||||||
4446 | return; never executed: return; | 0 | ||||||||||||||||||||||||
4447 | } | - | ||||||||||||||||||||||||
4448 | - | |||||||||||||||||||||||||
4449 | qreal x = vx->asDouble(); | - | ||||||||||||||||||||||||
4450 | qreal y = vy->asDouble(); | - | ||||||||||||||||||||||||
4451 | - | |||||||||||||||||||||||||
4452 | QVariant result; | - | ||||||||||||||||||||||||
4453 | - | |||||||||||||||||||||||||
4454 | if (args->length() > 3) {
| 32-36 | ||||||||||||||||||||||||
4455 | QV4::ScopedValue vw(scope, (*args)[3]); | - | ||||||||||||||||||||||||
4456 | QV4::ScopedValue vh(scope, (*args)[4]); | - | ||||||||||||||||||||||||
4457 | if (!vw->isNumber() || !vh->isNumber()) {
| 0-36 | ||||||||||||||||||||||||
4458 | v4->throwTypeError(); | - | ||||||||||||||||||||||||
4459 | return; never executed: return; | 0 | ||||||||||||||||||||||||
4460 | } | - | ||||||||||||||||||||||||
4461 | qreal w = vw->asDouble(); | - | ||||||||||||||||||||||||
4462 | qreal h = vh->asDouble(); | - | ||||||||||||||||||||||||
4463 | - | |||||||||||||||||||||||||
4464 | result = mapRectFromItem(itemObj, QRectF(x, y, w, h)); | - | ||||||||||||||||||||||||
4465 | } else { executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||||||||||||||
4466 | result = mapFromItem(itemObj, QPointF(x, y)); | - | ||||||||||||||||||||||||
4467 | } executed 32 times by 2 tests: end of block Executed by:
| 32 | ||||||||||||||||||||||||
4468 | - | |||||||||||||||||||||||||
4469 | QV4::ScopedObject rv(scope, v4->fromVariant(result)); | - | ||||||||||||||||||||||||
4470 | args->setReturnValue(rv.asReturnedValue()); | - | ||||||||||||||||||||||||
4471 | } executed 68 times by 2 tests: end of block Executed by:
| 68 | ||||||||||||||||||||||||
4472 | - | |||||||||||||||||||||||||
4473 | /*! | - | ||||||||||||||||||||||||
4474 | \internal | - | ||||||||||||||||||||||||
4475 | */ | - | ||||||||||||||||||||||||
4476 | QTransform QQuickItem::itemTransform(QQuickItem *other, bool *ok) const | - | ||||||||||||||||||||||||
4477 | { | - | ||||||||||||||||||||||||
4478 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
4479 | - | |||||||||||||||||||||||||
4480 | // XXX todo - we need to be able to handle common parents better and detect | - | ||||||||||||||||||||||||
4481 | // invalid cases | - | ||||||||||||||||||||||||
4482 | if (ok) *ok = true; executed 52918 times by 27 tests: *ok = true; Executed by:
| 10-52918 | ||||||||||||||||||||||||
4483 | - | |||||||||||||||||||||||||
4484 | QTransform t = d->itemToWindowTransform(); | - | ||||||||||||||||||||||||
4485 | if (other) t *= QQuickItemPrivate::get(other)->windowToItemTransform(); executed 52918 times by 27 tests: t *= QQuickItemPrivate::get(other)->windowToItemTransform(); Executed by:
| 10-52918 | ||||||||||||||||||||||||
4486 | - | |||||||||||||||||||||||||
4487 | return t; executed 52928 times by 28 tests: return t; Executed by:
| 52928 | ||||||||||||||||||||||||
4488 | } | - | ||||||||||||||||||||||||
4489 | - | |||||||||||||||||||||||||
4490 | /*! | - | ||||||||||||||||||||||||
4491 | \qmlmethod object QtQuick::Item::mapToItem(Item item, real x, real y) | - | ||||||||||||||||||||||||
4492 | \qmlmethod object QtQuick::Item::mapToItem(Item item, real x, real y, real width, real height) | - | ||||||||||||||||||||||||
4493 | - | |||||||||||||||||||||||||
4494 | Maps the point (\a x, \a y) or rect (\a x, \a y, \a width, \a height), which is in this | - | ||||||||||||||||||||||||
4495 | item's coordinate system, to \a item's coordinate system, and returns a \l point or \l rect | - | ||||||||||||||||||||||||
4496 | matching the mapped coordinate. | - | ||||||||||||||||||||||||
4497 | - | |||||||||||||||||||||||||
4498 | If \a item is a \c null value, this maps the point or rect to the coordinate system of the | - | ||||||||||||||||||||||||
4499 | root QML view. | - | ||||||||||||||||||||||||
4500 | */ | - | ||||||||||||||||||||||||
4501 | /*! | - | ||||||||||||||||||||||||
4502 | \internal | - | ||||||||||||||||||||||||
4503 | */ | - | ||||||||||||||||||||||||
4504 | void QQuickItem::mapToItem(QQmlV4Function *args) const | - | ||||||||||||||||||||||||
4505 | { | - | ||||||||||||||||||||||||
4506 | QV4::ExecutionEngine *v4 = args->v4engine(); | - | ||||||||||||||||||||||||
4507 | if (args->length() != 3 && args->length() != 5) {
| 0-54 | ||||||||||||||||||||||||
4508 | v4->throwTypeError(); | - | ||||||||||||||||||||||||
4509 | return; never executed: return; | 0 | ||||||||||||||||||||||||
4510 | } | - | ||||||||||||||||||||||||
4511 | - | |||||||||||||||||||||||||
4512 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
4513 | QV4::ScopedValue item(scope, (*args)[0]); | - | ||||||||||||||||||||||||
4514 | - | |||||||||||||||||||||||||
4515 | QQuickItem *itemObj = nullptr; | - | ||||||||||||||||||||||||
4516 | if (!item->isNull()) {
| 28-68 | ||||||||||||||||||||||||
4517 | QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, item->as<QV4::QObjectWrapper>()); | - | ||||||||||||||||||||||||
4518 | if (qobjectWrapper)
| 28-40 | ||||||||||||||||||||||||
4519 | itemObj = qobject_cast<QQuickItem*>(qobjectWrapper->object()); executed 40 times by 2 tests: itemObj = qobject_cast<QQuickItem*>(qobjectWrapper->object()); Executed by:
| 40 | ||||||||||||||||||||||||
4520 | } executed 68 times by 2 tests: end of block Executed by:
| 68 | ||||||||||||||||||||||||
4521 | - | |||||||||||||||||||||||||
4522 | if (!itemObj && !item->isNull()) {
| 28-56 | ||||||||||||||||||||||||
4523 | qmlWarning(this) << "mapToItem() given argument \"" << item->toQStringNoThrow() | - | ||||||||||||||||||||||||
4524 | << "\" which is neither null nor an Item"; | - | ||||||||||||||||||||||||
4525 | v4->throwTypeError(); | - | ||||||||||||||||||||||||
4526 | return; executed 28 times by 1 test: return; Executed by:
| 28 | ||||||||||||||||||||||||
4527 | } | - | ||||||||||||||||||||||||
4528 | - | |||||||||||||||||||||||||
4529 | QV4::ScopedValue vx(scope, (*args)[1]); | - | ||||||||||||||||||||||||
4530 | QV4::ScopedValue vy(scope, (*args)[2]); | - | ||||||||||||||||||||||||
4531 | - | |||||||||||||||||||||||||
4532 | if (!vx->isNumber() || !vy->isNumber()) {
| 0-68 | ||||||||||||||||||||||||
4533 | v4->throwTypeError(); | - | ||||||||||||||||||||||||
4534 | return; never executed: return; | 0 | ||||||||||||||||||||||||
4535 | } | - | ||||||||||||||||||||||||
4536 | - | |||||||||||||||||||||||||
4537 | qreal x = vx->asDouble(); | - | ||||||||||||||||||||||||
4538 | qreal y = vy->asDouble(); | - | ||||||||||||||||||||||||
4539 | - | |||||||||||||||||||||||||
4540 | QVariant result; | - | ||||||||||||||||||||||||
4541 | - | |||||||||||||||||||||||||
4542 | if (args->length() > 3) {
| 32-36 | ||||||||||||||||||||||||
4543 | QV4::ScopedValue vw(scope, (*args)[3]); | - | ||||||||||||||||||||||||
4544 | QV4::ScopedValue vh(scope, (*args)[4]); | - | ||||||||||||||||||||||||
4545 | if (!vw->isNumber() || !vh->isNumber()) {
| 0-36 | ||||||||||||||||||||||||
4546 | v4->throwTypeError(); | - | ||||||||||||||||||||||||
4547 | return; never executed: return; | 0 | ||||||||||||||||||||||||
4548 | } | - | ||||||||||||||||||||||||
4549 | qreal w = vw->asDouble(); | - | ||||||||||||||||||||||||
4550 | qreal h = vh->asDouble(); | - | ||||||||||||||||||||||||
4551 | - | |||||||||||||||||||||||||
4552 | result = mapRectToItem(itemObj, QRectF(x, y, w, h)); | - | ||||||||||||||||||||||||
4553 | } else { executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||||||||||||||
4554 | result = mapToItem(itemObj, QPointF(x, y)); | - | ||||||||||||||||||||||||
4555 | } executed 32 times by 2 tests: end of block Executed by:
| 32 | ||||||||||||||||||||||||
4556 | - | |||||||||||||||||||||||||
4557 | QV4::ScopedObject rv(scope, v4->fromVariant(result)); | - | ||||||||||||||||||||||||
4558 | args->setReturnValue(rv.asReturnedValue()); | - | ||||||||||||||||||||||||
4559 | } executed 68 times by 2 tests: end of block Executed by:
| 68 | ||||||||||||||||||||||||
4560 | - | |||||||||||||||||||||||||
4561 | /*! | - | ||||||||||||||||||||||||
4562 | \since 5.7 | - | ||||||||||||||||||||||||
4563 | \qmlmethod object QtQuick::Item::mapFromGlobal(real x, real y) | - | ||||||||||||||||||||||||
4564 | - | |||||||||||||||||||||||||
4565 | Maps the point (\a x, \a y), which is in the global coordinate system, to the | - | ||||||||||||||||||||||||
4566 | item's coordinate system, and returns a \l point matching the mapped coordinate. | - | ||||||||||||||||||||||||
4567 | */ | - | ||||||||||||||||||||||||
4568 | /*! | - | ||||||||||||||||||||||||
4569 | \internal | - | ||||||||||||||||||||||||
4570 | */ | - | ||||||||||||||||||||||||
4571 | void QQuickItem::mapFromGlobal(QQmlV4Function *args) const | - | ||||||||||||||||||||||||
4572 | { | - | ||||||||||||||||||||||||
4573 | QV4::ExecutionEngine *v4 = args->v4engine(); | - | ||||||||||||||||||||||||
4574 | if (args->length() != 2) {
| 0-20 | ||||||||||||||||||||||||
4575 | v4->throwTypeError(); | - | ||||||||||||||||||||||||
4576 | return; never executed: return; | 0 | ||||||||||||||||||||||||
4577 | } | - | ||||||||||||||||||||||||
4578 | - | |||||||||||||||||||||||||
4579 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
4580 | QV4::ScopedValue vx(scope, (*args)[0]); | - | ||||||||||||||||||||||||
4581 | QV4::ScopedValue vy(scope, (*args)[1]); | - | ||||||||||||||||||||||||
4582 | - | |||||||||||||||||||||||||
4583 | if (!vx->isNumber() || !vy->isNumber()) {
| 0-20 | ||||||||||||||||||||||||
4584 | v4->throwTypeError(); | - | ||||||||||||||||||||||||
4585 | return; never executed: return; | 0 | ||||||||||||||||||||||||
4586 | } | - | ||||||||||||||||||||||||
4587 | - | |||||||||||||||||||||||||
4588 | qreal x = vx->asDouble(); | - | ||||||||||||||||||||||||
4589 | qreal y = vy->asDouble(); | - | ||||||||||||||||||||||||
4590 | QVariant result = mapFromGlobal(QPointF(x, y)); | - | ||||||||||||||||||||||||
4591 | - | |||||||||||||||||||||||||
4592 | QV4::ScopedObject rv(scope, v4->fromVariant(result)); | - | ||||||||||||||||||||||||
4593 | args->setReturnValue(rv.asReturnedValue()); | - | ||||||||||||||||||||||||
4594 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||
4595 | - | |||||||||||||||||||||||||
4596 | /*! | - | ||||||||||||||||||||||||
4597 | \since 5.7 | - | ||||||||||||||||||||||||
4598 | \qmlmethod object QtQuick::Item::mapToGlobal(real x, real y) | - | ||||||||||||||||||||||||
4599 | - | |||||||||||||||||||||||||
4600 | Maps the point (\a x, \a y), which is in this item's coordinate system, to the | - | ||||||||||||||||||||||||
4601 | global coordinate system, and returns a \l point matching the mapped coordinate. | - | ||||||||||||||||||||||||
4602 | */ | - | ||||||||||||||||||||||||
4603 | /*! | - | ||||||||||||||||||||||||
4604 | \internal | - | ||||||||||||||||||||||||
4605 | */ | - | ||||||||||||||||||||||||
4606 | void QQuickItem::mapToGlobal(QQmlV4Function *args) const | - | ||||||||||||||||||||||||
4607 | { | - | ||||||||||||||||||||||||
4608 | QV4::ExecutionEngine *v4 = args->v4engine(); | - | ||||||||||||||||||||||||
4609 | if (args->length() != 2) {
| 0-20 | ||||||||||||||||||||||||
4610 | v4->throwTypeError(); | - | ||||||||||||||||||||||||
4611 | return; never executed: return; | 0 | ||||||||||||||||||||||||
4612 | } | - | ||||||||||||||||||||||||
4613 | - | |||||||||||||||||||||||||
4614 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
4615 | QV4::ScopedValue vx(scope, (*args)[0]); | - | ||||||||||||||||||||||||
4616 | QV4::ScopedValue vy(scope, (*args)[1]); | - | ||||||||||||||||||||||||
4617 | - | |||||||||||||||||||||||||
4618 | if (!vx->isNumber() || !vy->isNumber()) {
| 0-20 | ||||||||||||||||||||||||
4619 | v4->throwTypeError(); | - | ||||||||||||||||||||||||
4620 | return; never executed: return; | 0 | ||||||||||||||||||||||||
4621 | } | - | ||||||||||||||||||||||||
4622 | - | |||||||||||||||||||||||||
4623 | qreal x = vx->asDouble(); | - | ||||||||||||||||||||||||
4624 | qreal y = vy->asDouble(); | - | ||||||||||||||||||||||||
4625 | QVariant result = mapToGlobal(QPointF(x, y)); | - | ||||||||||||||||||||||||
4626 | - | |||||||||||||||||||||||||
4627 | QV4::ScopedObject rv(scope, v4->fromVariant(result)); | - | ||||||||||||||||||||||||
4628 | args->setReturnValue(rv.asReturnedValue()); | - | ||||||||||||||||||||||||
4629 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||
4630 | - | |||||||||||||||||||||||||
4631 | /*! | - | ||||||||||||||||||||||||
4632 | \qmlmethod QtQuick::Item::forceActiveFocus() | - | ||||||||||||||||||||||||
4633 | - | |||||||||||||||||||||||||
4634 | Forces active focus on the item. | - | ||||||||||||||||||||||||
4635 | - | |||||||||||||||||||||||||
4636 | This method sets focus on the item and ensures that all ancestor | - | ||||||||||||||||||||||||
4637 | FocusScope objects in the object hierarchy are also given \l focus. | - | ||||||||||||||||||||||||
4638 | - | |||||||||||||||||||||||||
4639 | The reason for the focus change will be \l [CPP] Qt::OtherFocusReason. Use | - | ||||||||||||||||||||||||
4640 | the overloaded method to specify the focus reason to enable better | - | ||||||||||||||||||||||||
4641 | handling of the focus change. | - | ||||||||||||||||||||||||
4642 | - | |||||||||||||||||||||||||
4643 | \sa activeFocus | - | ||||||||||||||||||||||||
4644 | */ | - | ||||||||||||||||||||||||
4645 | /*! | - | ||||||||||||||||||||||||
4646 | Forces active focus on the item. | - | ||||||||||||||||||||||||
4647 | - | |||||||||||||||||||||||||
4648 | This method sets focus on the item and ensures that all ancestor | - | ||||||||||||||||||||||||
4649 | FocusScope objects in the object hierarchy are also given \l focus. | - | ||||||||||||||||||||||||
4650 | - | |||||||||||||||||||||||||
4651 | The reason for the focus change will be \l [CPP] Qt::OtherFocusReason. Use | - | ||||||||||||||||||||||||
4652 | the overloaded method to specify the focus reason to enable better | - | ||||||||||||||||||||||||
4653 | handling of the focus change. | - | ||||||||||||||||||||||||
4654 | - | |||||||||||||||||||||||||
4655 | \sa activeFocus | - | ||||||||||||||||||||||||
4656 | */ | - | ||||||||||||||||||||||||
4657 | void QQuickItem::forceActiveFocus() | - | ||||||||||||||||||||||||
4658 | { | - | ||||||||||||||||||||||||
4659 | forceActiveFocus(Qt::OtherFocusReason); | - | ||||||||||||||||||||||||
4660 | } executed 120 times by 6 tests: end of block Executed by:
| 120 | ||||||||||||||||||||||||
4661 | - | |||||||||||||||||||||||||
4662 | /*! | - | ||||||||||||||||||||||||
4663 | \qmlmethod QtQuick::Item::forceActiveFocus(Qt::FocusReason reason) | - | ||||||||||||||||||||||||
4664 | \overload | - | ||||||||||||||||||||||||
4665 | - | |||||||||||||||||||||||||
4666 | Forces active focus on the item with the given \a reason. | - | ||||||||||||||||||||||||
4667 | - | |||||||||||||||||||||||||
4668 | This method sets focus on the item and ensures that all ancestor | - | ||||||||||||||||||||||||
4669 | FocusScope objects in the object hierarchy are also given \l focus. | - | ||||||||||||||||||||||||
4670 | - | |||||||||||||||||||||||||
4671 | \since 5.1 | - | ||||||||||||||||||||||||
4672 | - | |||||||||||||||||||||||||
4673 | \sa activeFocus, Qt::FocusReason | - | ||||||||||||||||||||||||
4674 | */ | - | ||||||||||||||||||||||||
4675 | /*! | - | ||||||||||||||||||||||||
4676 | \overload | - | ||||||||||||||||||||||||
4677 | Forces active focus on the item with the given \a reason. | - | ||||||||||||||||||||||||
4678 | - | |||||||||||||||||||||||||
4679 | This method sets focus on the item and ensures that all ancestor | - | ||||||||||||||||||||||||
4680 | FocusScope objects in the object hierarchy are also given \l focus. | - | ||||||||||||||||||||||||
4681 | - | |||||||||||||||||||||||||
4682 | \since 5.1 | - | ||||||||||||||||||||||||
4683 | - | |||||||||||||||||||||||||
4684 | \sa activeFocus, Qt::FocusReason | - | ||||||||||||||||||||||||
4685 | */ | - | ||||||||||||||||||||||||
4686 | - | |||||||||||||||||||||||||
4687 | void QQuickItem::forceActiveFocus(Qt::FocusReason reason) | - | ||||||||||||||||||||||||
4688 | { | - | ||||||||||||||||||||||||
4689 | setFocus(true, reason); | - | ||||||||||||||||||||||||
4690 | QQuickItem *parent = parentItem(); | - | ||||||||||||||||||||||||
4691 | while (parent) {
| 934-1594 | ||||||||||||||||||||||||
4692 | if (parent->flags() & QQuickItem::ItemIsFocusScope) {
| 582-1012 | ||||||||||||||||||||||||
4693 | parent->setFocus(true, reason); | - | ||||||||||||||||||||||||
4694 | } executed 1012 times by 6 tests: end of block Executed by:
| 1012 | ||||||||||||||||||||||||
4695 | parent = parent->parentItem(); | - | ||||||||||||||||||||||||
4696 | } executed 1594 times by 6 tests: end of block Executed by:
| 1594 | ||||||||||||||||||||||||
4697 | } executed 934 times by 7 tests: end of block Executed by:
| 934 | ||||||||||||||||||||||||
4698 | - | |||||||||||||||||||||||||
4699 | /*! | - | ||||||||||||||||||||||||
4700 | \qmlmethod QtQuick::Item::nextItemInFocusChain(bool forward) | - | ||||||||||||||||||||||||
4701 | - | |||||||||||||||||||||||||
4702 | \since 5.1 | - | ||||||||||||||||||||||||
4703 | - | |||||||||||||||||||||||||
4704 | Returns the item in the focus chain which is next to this item. | - | ||||||||||||||||||||||||
4705 | If \a forward is \c true, or not supplied, it is the next item in | - | ||||||||||||||||||||||||
4706 | the forwards direction. If \a forward is \c false, it is the next | - | ||||||||||||||||||||||||
4707 | item in the backwards direction. | - | ||||||||||||||||||||||||
4708 | */ | - | ||||||||||||||||||||||||
4709 | /*! | - | ||||||||||||||||||||||||
4710 | Returns the item in the focus chain which is next to this item. | - | ||||||||||||||||||||||||
4711 | If \a forward is \c true, or not supplied, it is the next item in | - | ||||||||||||||||||||||||
4712 | the forwards direction. If \a forward is \c false, it is the next | - | ||||||||||||||||||||||||
4713 | item in the backwards direction. | - | ||||||||||||||||||||||||
4714 | */ | - | ||||||||||||||||||||||||
4715 | - | |||||||||||||||||||||||||
4716 | QQuickItem *QQuickItem::nextItemInFocusChain(bool forward) | - | ||||||||||||||||||||||||
4717 | { | - | ||||||||||||||||||||||||
4718 | return QQuickItemPrivate::nextPrevItemInTabFocusChain(this, forward); executed 54 times by 1 test: return QQuickItemPrivate::nextPrevItemInTabFocusChain(this, forward); Executed by:
| 54 | ||||||||||||||||||||||||
4719 | } | - | ||||||||||||||||||||||||
4720 | - | |||||||||||||||||||||||||
4721 | /*! | - | ||||||||||||||||||||||||
4722 | \qmlmethod QtQuick::Item::childAt(real x, real y) | - | ||||||||||||||||||||||||
4723 | - | |||||||||||||||||||||||||
4724 | Returns the first visible child item found at point (\a x, \a y) within | - | ||||||||||||||||||||||||
4725 | the coordinate system of this item. | - | ||||||||||||||||||||||||
4726 | - | |||||||||||||||||||||||||
4727 | Returns \c null if there is no such item. | - | ||||||||||||||||||||||||
4728 | */ | - | ||||||||||||||||||||||||
4729 | /*! | - | ||||||||||||||||||||||||
4730 | Returns the first visible child item found at point (\a x, \a y) within | - | ||||||||||||||||||||||||
4731 | the coordinate system of this item. | - | ||||||||||||||||||||||||
4732 | - | |||||||||||||||||||||||||
4733 | Returns 0 if there is no such item. | - | ||||||||||||||||||||||||
4734 | */ | - | ||||||||||||||||||||||||
4735 | QQuickItem *QQuickItem::childAt(qreal x, qreal y) const | - | ||||||||||||||||||||||||
4736 | { | - | ||||||||||||||||||||||||
4737 | const QList<QQuickItem *> children = childItems(); | - | ||||||||||||||||||||||||
4738 | for (int i = children.count()-1; i >= 0; --i) {
| 38-354 | ||||||||||||||||||||||||
4739 | QQuickItem *child = children.at(i); | - | ||||||||||||||||||||||||
4740 | // Map coordinates to the child element's coordinate space | - | ||||||||||||||||||||||||
4741 | QPointF point = mapToItem(child, QPointF(x, y)); | - | ||||||||||||||||||||||||
4742 | if (child->isVisible() && point.x() >= 0
| 0-354 | ||||||||||||||||||||||||
4743 | && child->width() > point.x()
| 54-128 | ||||||||||||||||||||||||
4744 | && point.y() >= 0
| 12-116 | ||||||||||||||||||||||||
4745 | && child->height() > point.y())
| 32-84 | ||||||||||||||||||||||||
4746 | return child; executed 84 times by 2 tests: return child; Executed by:
| 84 | ||||||||||||||||||||||||
4747 | } executed 270 times by 2 tests: end of block Executed by:
| 270 | ||||||||||||||||||||||||
4748 | return nullptr; executed 38 times by 2 tests: return nullptr; Executed by:
| 38 | ||||||||||||||||||||||||
4749 | } | - | ||||||||||||||||||||||||
4750 | - | |||||||||||||||||||||||||
4751 | QQmlListProperty<QObject> QQuickItemPrivate::resources() | - | ||||||||||||||||||||||||
4752 | { | - | ||||||||||||||||||||||||
4753 | return QQmlListProperty<QObject>(q_func(), nullptr, QQuickItemPrivate::resources_append, executed 1112 times by 15 tests: return QQmlListProperty<QObject>(q_func(), nullptr, QQuickItemPrivate::resources_append, QQuickItemPrivate::resources_count, QQuickItemPrivate::resources_at, QQuickItemPrivate::resources_clear); Executed by:
| 1112 | ||||||||||||||||||||||||
4754 | QQuickItemPrivate::resources_count, executed 1112 times by 15 tests: return QQmlListProperty<QObject>(q_func(), nullptr, QQuickItemPrivate::resources_append, QQuickItemPrivate::resources_count, QQuickItemPrivate::resources_at, QQuickItemPrivate::resources_clear); Executed by:
| 1112 | ||||||||||||||||||||||||
4755 | QQuickItemPrivate::resources_at, executed 1112 times by 15 tests: return QQmlListProperty<QObject>(q_func(), nullptr, QQuickItemPrivate::resources_append, QQuickItemPrivate::resources_count, QQuickItemPrivate::resources_at, QQuickItemPrivate::resources_clear); Executed by:
| 1112 | ||||||||||||||||||||||||
4756 | QQuickItemPrivate::resources_clear); executed 1112 times by 15 tests: return QQmlListProperty<QObject>(q_func(), nullptr, QQuickItemPrivate::resources_append, QQuickItemPrivate::resources_count, QQuickItemPrivate::resources_at, QQuickItemPrivate::resources_clear); Executed by:
| 1112 | ||||||||||||||||||||||||
4757 | } | - | ||||||||||||||||||||||||
4758 | - | |||||||||||||||||||||||||
4759 | /*! | - | ||||||||||||||||||||||||
4760 | \qmlproperty list<Item> QtQuick::Item::children | - | ||||||||||||||||||||||||
4761 | \qmlproperty list<Object> QtQuick::Item::resources | - | ||||||||||||||||||||||||
4762 | - | |||||||||||||||||||||||||
4763 | The children property contains the list of visual children of this item. | - | ||||||||||||||||||||||||
4764 | The resources property contains non-visual resources that you want to | - | ||||||||||||||||||||||||
4765 | reference by name. | - | ||||||||||||||||||||||||
4766 | - | |||||||||||||||||||||||||
4767 | It is not generally necessary to refer to these properties when adding | - | ||||||||||||||||||||||||
4768 | child items or resources, as the default \l data property will | - | ||||||||||||||||||||||||
4769 | automatically assign child objects to the \c children and \c resources | - | ||||||||||||||||||||||||
4770 | properties as appropriate. See the \l data documentation for details. | - | ||||||||||||||||||||||||
4771 | */ | - | ||||||||||||||||||||||||
4772 | /*! | - | ||||||||||||||||||||||||
4773 | \property QQuickItem::children | - | ||||||||||||||||||||||||
4774 | \internal | - | ||||||||||||||||||||||||
4775 | */ | - | ||||||||||||||||||||||||
4776 | QQmlListProperty<QQuickItem> QQuickItemPrivate::children() | - | ||||||||||||||||||||||||
4777 | { | - | ||||||||||||||||||||||||
4778 | return QQmlListProperty<QQuickItem>(q_func(), nullptr, QQuickItemPrivate::children_append, executed 6460 times by 19 tests: return QQmlListProperty<QQuickItem>(q_func(), nullptr, QQuickItemPrivate::children_append, QQuickItemPrivate::children_count, QQuickItemPrivate::children_at, QQuickItemPrivate::children_clear); Executed by:
| 6460 | ||||||||||||||||||||||||
4779 | QQuickItemPrivate::children_count, executed 6460 times by 19 tests: return QQmlListProperty<QQuickItem>(q_func(), nullptr, QQuickItemPrivate::children_append, QQuickItemPrivate::children_count, QQuickItemPrivate::children_at, QQuickItemPrivate::children_clear); Executed by:
| 6460 | ||||||||||||||||||||||||
4780 | QQuickItemPrivate::children_at, executed 6460 times by 19 tests: return QQmlListProperty<QQuickItem>(q_func(), nullptr, QQuickItemPrivate::children_append, QQuickItemPrivate::children_count, QQuickItemPrivate::children_at, QQuickItemPrivate::children_clear); Executed by:
| 6460 | ||||||||||||||||||||||||
4781 | QQuickItemPrivate::children_clear); executed 6460 times by 19 tests: return QQmlListProperty<QQuickItem>(q_func(), nullptr, QQuickItemPrivate::children_append, QQuickItemPrivate::children_count, QQuickItemPrivate::children_at, QQuickItemPrivate::children_clear); Executed by:
| 6460 | ||||||||||||||||||||||||
4782 | - | |||||||||||||||||||||||||
4783 | } | - | ||||||||||||||||||||||||
4784 | - | |||||||||||||||||||||||||
4785 | /*! | - | ||||||||||||||||||||||||
4786 | \qmlproperty list<Item> QtQuick::Item::visibleChildren | - | ||||||||||||||||||||||||
4787 | This read-only property lists all of the item's children that are currently visible. | - | ||||||||||||||||||||||||
4788 | Note that a child's visibility may have changed explicitly, or because the visibility | - | ||||||||||||||||||||||||
4789 | of this (it's parent) item or another grandparent changed. | - | ||||||||||||||||||||||||
4790 | */ | - | ||||||||||||||||||||||||
4791 | /*! | - | ||||||||||||||||||||||||
4792 | \property QQuickItem::visibleChildren | - | ||||||||||||||||||||||||
4793 | \internal | - | ||||||||||||||||||||||||
4794 | */ | - | ||||||||||||||||||||||||
4795 | QQmlListProperty<QQuickItem> QQuickItemPrivate::visibleChildren() | - | ||||||||||||||||||||||||
4796 | { | - | ||||||||||||||||||||||||
4797 | return QQmlListProperty<QQuickItem>(q_func(), executed 324 times by 8 tests: return QQmlListProperty<QQuickItem>(q_func(), nullptr, QQuickItemPrivate::visibleChildren_count, QQuickItemPrivate::visibleChildren_at); Executed by:
| 324 | ||||||||||||||||||||||||
4798 | nullptr, executed 324 times by 8 tests: return QQmlListProperty<QQuickItem>(q_func(), nullptr, QQuickItemPrivate::visibleChildren_count, QQuickItemPrivate::visibleChildren_at); Executed by:
| 324 | ||||||||||||||||||||||||
4799 | QQuickItemPrivate::visibleChildren_count, executed 324 times by 8 tests: return QQmlListProperty<QQuickItem>(q_func(), nullptr, QQuickItemPrivate::visibleChildren_count, QQuickItemPrivate::visibleChildren_at); Executed by:
| 324 | ||||||||||||||||||||||||
4800 | QQuickItemPrivate::visibleChildren_at); executed 324 times by 8 tests: return QQmlListProperty<QQuickItem>(q_func(), nullptr, QQuickItemPrivate::visibleChildren_count, QQuickItemPrivate::visibleChildren_at); Executed by:
| 324 | ||||||||||||||||||||||||
4801 | - | |||||||||||||||||||||||||
4802 | } | - | ||||||||||||||||||||||||
4803 | - | |||||||||||||||||||||||||
4804 | /*! | - | ||||||||||||||||||||||||
4805 | \qmlproperty list<State> QtQuick::Item::states | - | ||||||||||||||||||||||||
4806 | - | |||||||||||||||||||||||||
4807 | This property holds the list of possible states for this item. To change | - | ||||||||||||||||||||||||
4808 | the state of this item, set the \l state property to one of these states, | - | ||||||||||||||||||||||||
4809 | or set the \l state property to an empty string to revert the item to its | - | ||||||||||||||||||||||||
4810 | default state. | - | ||||||||||||||||||||||||
4811 | - | |||||||||||||||||||||||||
4812 | This property is specified as a list of \l State objects. For example, | - | ||||||||||||||||||||||||
4813 | below is an item with "red_color" and "blue_color" states: | - | ||||||||||||||||||||||||
4814 | - | |||||||||||||||||||||||||
4815 | \qml | - | ||||||||||||||||||||||||
4816 | import QtQuick 2.0 | - | ||||||||||||||||||||||||
4817 | - | |||||||||||||||||||||||||
4818 | Rectangle { | - | ||||||||||||||||||||||||
4819 | id: root | - | ||||||||||||||||||||||||
4820 | width: 100; height: 100 | - | ||||||||||||||||||||||||
4821 | - | |||||||||||||||||||||||||
4822 | states: [ | - | ||||||||||||||||||||||||
4823 | State { | - | ||||||||||||||||||||||||
4824 | name: "red_color" | - | ||||||||||||||||||||||||
4825 | PropertyChanges { target: root; color: "red" } | - | ||||||||||||||||||||||||
4826 | }, | - | ||||||||||||||||||||||||
4827 | State { | - | ||||||||||||||||||||||||
4828 | name: "blue_color" | - | ||||||||||||||||||||||||
4829 | PropertyChanges { target: root; color: "blue" } | - | ||||||||||||||||||||||||
4830 | } | - | ||||||||||||||||||||||||
4831 | ] | - | ||||||||||||||||||||||||
4832 | } | - | ||||||||||||||||||||||||
4833 | \endqml | - | ||||||||||||||||||||||||
4834 | - | |||||||||||||||||||||||||
4835 | See \l{Qt Quick States} and \l{Animation and Transitions in Qt Quick} for | - | ||||||||||||||||||||||||
4836 | more details on using states and transitions. | - | ||||||||||||||||||||||||
4837 | - | |||||||||||||||||||||||||
4838 | \sa transitions | - | ||||||||||||||||||||||||
4839 | */ | - | ||||||||||||||||||||||||
4840 | /*! | - | ||||||||||||||||||||||||
4841 | \property QQuickItem::states | - | ||||||||||||||||||||||||
4842 | \internal | - | ||||||||||||||||||||||||
4843 | */ | - | ||||||||||||||||||||||||
4844 | QQmlListProperty<QQuickState> QQuickItemPrivate::states() | - | ||||||||||||||||||||||||
4845 | { | - | ||||||||||||||||||||||||
4846 | return _states()->statesProperty(); executed 1202 times by 23 tests: return _states()->statesProperty(); Executed by:
| 1202 | ||||||||||||||||||||||||
4847 | } | - | ||||||||||||||||||||||||
4848 | - | |||||||||||||||||||||||||
4849 | /*! | - | ||||||||||||||||||||||||
4850 | \qmlproperty list<Transition> QtQuick::Item::transitions | - | ||||||||||||||||||||||||
4851 | - | |||||||||||||||||||||||||
4852 | This property holds the list of transitions for this item. These define the | - | ||||||||||||||||||||||||
4853 | transitions to be applied to the item whenever it changes its \l state. | - | ||||||||||||||||||||||||
4854 | - | |||||||||||||||||||||||||
4855 | This property is specified as a list of \l Transition objects. For example: | - | ||||||||||||||||||||||||
4856 | - | |||||||||||||||||||||||||
4857 | \qml | - | ||||||||||||||||||||||||
4858 | import QtQuick 2.0 | - | ||||||||||||||||||||||||
4859 | - | |||||||||||||||||||||||||
4860 | Item { | - | ||||||||||||||||||||||||
4861 | transitions: [ | - | ||||||||||||||||||||||||
4862 | Transition { | - | ||||||||||||||||||||||||
4863 | //... | - | ||||||||||||||||||||||||
4864 | }, | - | ||||||||||||||||||||||||
4865 | Transition { | - | ||||||||||||||||||||||||
4866 | //... | - | ||||||||||||||||||||||||
4867 | } | - | ||||||||||||||||||||||||
4868 | ] | - | ||||||||||||||||||||||||
4869 | } | - | ||||||||||||||||||||||||
4870 | \endqml | - | ||||||||||||||||||||||||
4871 | - | |||||||||||||||||||||||||
4872 | See \l{Qt Quick States} and \l{Animation and Transitions in Qt Quick} for | - | ||||||||||||||||||||||||
4873 | more details on using states and transitions. | - | ||||||||||||||||||||||||
4874 | - | |||||||||||||||||||||||||
4875 | \sa states | - | ||||||||||||||||||||||||
4876 | */ | - | ||||||||||||||||||||||||
4877 | /*! | - | ||||||||||||||||||||||||
4878 | \property QQuickItem::transitions | - | ||||||||||||||||||||||||
4879 | \internal | - | ||||||||||||||||||||||||
4880 | */ | - | ||||||||||||||||||||||||
4881 | QQmlListProperty<QQuickTransition> QQuickItemPrivate::transitions() | - | ||||||||||||||||||||||||
4882 | { | - | ||||||||||||||||||||||||
4883 | return _states()->transitionsProperty(); executed 598 times by 10 tests: return _states()->transitionsProperty(); Executed by:
| 598 | ||||||||||||||||||||||||
4884 | } | - | ||||||||||||||||||||||||
4885 | - | |||||||||||||||||||||||||
4886 | QString QQuickItemPrivate::state() const | - | ||||||||||||||||||||||||
4887 | { | - | ||||||||||||||||||||||||
4888 | if (!_stateGroup)
| 4-278 | ||||||||||||||||||||||||
4889 | return QString(); executed 4 times by 2 tests: return QString(); Executed by:
| 4 | ||||||||||||||||||||||||
4890 | else | - | ||||||||||||||||||||||||
4891 | return _stateGroup->state(); executed 278 times by 14 tests: return _stateGroup->state(); Executed by:
| 278 | ||||||||||||||||||||||||
4892 | } | - | ||||||||||||||||||||||||
4893 | - | |||||||||||||||||||||||||
4894 | void QQuickItemPrivate::setState(const QString &state) | - | ||||||||||||||||||||||||
4895 | { | - | ||||||||||||||||||||||||
4896 | _states()->setState(state); | - | ||||||||||||||||||||||||
4897 | } executed 508 times by 14 tests: end of block Executed by:
| 508 | ||||||||||||||||||||||||
4898 | - | |||||||||||||||||||||||||
4899 | /*! | - | ||||||||||||||||||||||||
4900 | \qmlproperty string QtQuick::Item::state | - | ||||||||||||||||||||||||
4901 | - | |||||||||||||||||||||||||
4902 | This property holds the name of the current state of the item. | - | ||||||||||||||||||||||||
4903 | - | |||||||||||||||||||||||||
4904 | If the item is in its default state, that is, no explicit state has been | - | ||||||||||||||||||||||||
4905 | set, then this property holds an empty string. Likewise, you can return | - | ||||||||||||||||||||||||
4906 | an item to its default state by setting this property to an empty string. | - | ||||||||||||||||||||||||
4907 | - | |||||||||||||||||||||||||
4908 | \sa {Qt Quick States} | - | ||||||||||||||||||||||||
4909 | */ | - | ||||||||||||||||||||||||
4910 | /*! | - | ||||||||||||||||||||||||
4911 | \property QQuickItem::state | - | ||||||||||||||||||||||||
4912 | - | |||||||||||||||||||||||||
4913 | This property holds the name of the current state of the item. | - | ||||||||||||||||||||||||
4914 | - | |||||||||||||||||||||||||
4915 | If the item is in its default state, that is, no explicit state has been | - | ||||||||||||||||||||||||
4916 | set, then this property holds an empty string. Likewise, you can return | - | ||||||||||||||||||||||||
4917 | an item to its default state by setting this property to an empty string. | - | ||||||||||||||||||||||||
4918 | - | |||||||||||||||||||||||||
4919 | \sa {Qt Quick States} | - | ||||||||||||||||||||||||
4920 | */ | - | ||||||||||||||||||||||||
4921 | QString QQuickItem::state() const | - | ||||||||||||||||||||||||
4922 | { | - | ||||||||||||||||||||||||
4923 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
4924 | return d->state(); executed 252 times by 14 tests: return d->state(); Executed by:
| 252 | ||||||||||||||||||||||||
4925 | } | - | ||||||||||||||||||||||||
4926 | - | |||||||||||||||||||||||||
4927 | void QQuickItem::setState(const QString &state) | - | ||||||||||||||||||||||||
4928 | { | - | ||||||||||||||||||||||||
4929 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
4930 | d->setState(state); | - | ||||||||||||||||||||||||
4931 | } executed 218 times by 13 tests: end of block Executed by:
| 218 | ||||||||||||||||||||||||
4932 | - | |||||||||||||||||||||||||
4933 | /*! | - | ||||||||||||||||||||||||
4934 | \qmlproperty list<Transform> QtQuick::Item::transform | - | ||||||||||||||||||||||||
4935 | This property holds the list of transformations to apply. | - | ||||||||||||||||||||||||
4936 | - | |||||||||||||||||||||||||
4937 | For more information see \l Transform. | - | ||||||||||||||||||||||||
4938 | */ | - | ||||||||||||||||||||||||
4939 | /*! | - | ||||||||||||||||||||||||
4940 | \property QQuickItem::transform | - | ||||||||||||||||||||||||
4941 | \internal | - | ||||||||||||||||||||||||
4942 | */ | - | ||||||||||||||||||||||||
4943 | /*! | - | ||||||||||||||||||||||||
4944 | \internal | - | ||||||||||||||||||||||||
4945 | */ | - | ||||||||||||||||||||||||
4946 | QQmlListProperty<QQuickTransform> QQuickItem::transform() | - | ||||||||||||||||||||||||
4947 | { | - | ||||||||||||||||||||||||
4948 | return QQmlListProperty<QQuickTransform>(this, nullptr, QQuickItemPrivate::transform_append, executed 1036 times by 13 tests: return QQmlListProperty<QQuickTransform>(this, nullptr, QQuickItemPrivate::transform_append, QQuickItemPrivate::transform_count, QQuickItemPrivate::transform_at, QQuickItemPrivate::transform_clear); Executed by:
| 1036 | ||||||||||||||||||||||||
4949 | QQuickItemPrivate::transform_count, executed 1036 times by 13 tests: return QQmlListProperty<QQuickTransform>(this, nullptr, QQuickItemPrivate::transform_append, QQuickItemPrivate::transform_count, QQuickItemPrivate::transform_at, QQuickItemPrivate::transform_clear); Executed by:
| 1036 | ||||||||||||||||||||||||
4950 | QQuickItemPrivate::transform_at, executed 1036 times by 13 tests: return QQmlListProperty<QQuickTransform>(this, nullptr, QQuickItemPrivate::transform_append, QQuickItemPrivate::transform_count, QQuickItemPrivate::transform_at, QQuickItemPrivate::transform_clear); Executed by:
| 1036 | ||||||||||||||||||||||||
4951 | QQuickItemPrivate::transform_clear); executed 1036 times by 13 tests: return QQmlListProperty<QQuickTransform>(this, nullptr, QQuickItemPrivate::transform_append, QQuickItemPrivate::transform_count, QQuickItemPrivate::transform_at, QQuickItemPrivate::transform_clear); Executed by:
| 1036 | ||||||||||||||||||||||||
4952 | } | - | ||||||||||||||||||||||||
4953 | - | |||||||||||||||||||||||||
4954 | /*! | - | ||||||||||||||||||||||||
4955 | \reimp | - | ||||||||||||||||||||||||
4956 | Derived classes should call the base class method before adding their own action to | - | ||||||||||||||||||||||||
4957 | perform at classBegin. | - | ||||||||||||||||||||||||
4958 | */ | - | ||||||||||||||||||||||||
4959 | void QQuickItem::classBegin() | - | ||||||||||||||||||||||||
4960 | { | - | ||||||||||||||||||||||||
4961 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
4962 | d->componentComplete = false; | - | ||||||||||||||||||||||||
4963 | if (d->_stateGroup)
| 0-445978 | ||||||||||||||||||||||||
4964 | d->_stateGroup->classBegin(); never executed: d->_stateGroup->classBegin(); | 0 | ||||||||||||||||||||||||
4965 | if (d->_anchors)
| 0-445978 | ||||||||||||||||||||||||
4966 | d->_anchors->classBegin(); never executed: d->_anchors->classBegin(); | 0 | ||||||||||||||||||||||||
4967 | #if QT_CONFIG(quick_shadereffect) | - | ||||||||||||||||||||||||
4968 | if (d->extra.isAllocated() && d->extra->layer)
| 0-438300 | ||||||||||||||||||||||||
4969 | d->extra->layer->classBegin(); never executed: d->extra->layer->classBegin(); | 0 | ||||||||||||||||||||||||
4970 | #endif | - | ||||||||||||||||||||||||
4971 | } executed 445978 times by 126 tests: end of block Executed by:
| 445978 | ||||||||||||||||||||||||
4972 | - | |||||||||||||||||||||||||
4973 | /*! | - | ||||||||||||||||||||||||
4974 | \reimp | - | ||||||||||||||||||||||||
4975 | Derived classes should call the base class method before adding their own actions to | - | ||||||||||||||||||||||||
4976 | perform at componentComplete. | - | ||||||||||||||||||||||||
4977 | */ | - | ||||||||||||||||||||||||
4978 | void QQuickItem::componentComplete() | - | ||||||||||||||||||||||||
4979 | { | - | ||||||||||||||||||||||||
4980 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
4981 | d->componentComplete = true; | - | ||||||||||||||||||||||||
4982 | if (d->_stateGroup)
| 1008-444970 | ||||||||||||||||||||||||
4983 | d->_stateGroup->componentComplete(); executed 1008 times by 17 tests: d->_stateGroup->componentComplete(); Executed by:
| 1008 | ||||||||||||||||||||||||
4984 | if (d->_anchors) {
| 12418-433560 | ||||||||||||||||||||||||
4985 | d->_anchors->componentComplete(); | - | ||||||||||||||||||||||||
4986 | QQuickAnchorsPrivate::get(d->_anchors)->updateOnComplete(); | - | ||||||||||||||||||||||||
4987 | } executed 12418 times by 77 tests: end of block Executed by:
| 12418 | ||||||||||||||||||||||||
4988 | - | |||||||||||||||||||||||||
4989 | if (d->extra.isAllocated()) {
| 120714-325264 | ||||||||||||||||||||||||
4990 | #if QT_CONFIG(quick_shadereffect) | - | ||||||||||||||||||||||||
4991 | if (d->extra->layer)
| 82-120632 | ||||||||||||||||||||||||
4992 | d->extra->layer->componentComplete(); executed 82 times by 2 tests: d->extra->layer->componentComplete(); Executed by:
| 82 | ||||||||||||||||||||||||
4993 | #endif | - | ||||||||||||||||||||||||
4994 | - | |||||||||||||||||||||||||
4995 | if (d->extra->keyHandler)
| 440-120274 | ||||||||||||||||||||||||
4996 | d->extra->keyHandler->componentComplete(); executed 440 times by 9 tests: d->extra->keyHandler->componentComplete(); Executed by:
| 440 | ||||||||||||||||||||||||
4997 | - | |||||||||||||||||||||||||
4998 | if (d->extra->contents)
| 72-120642 | ||||||||||||||||||||||||
4999 | d->extra->contents->complete(); executed 72 times by 2 tests: d->extra->contents->complete(); Executed by:
| 72 | ||||||||||||||||||||||||
5000 | } executed 120714 times by 115 tests: end of block Executed by:
| 120714 | ||||||||||||||||||||||||
5001 | - | |||||||||||||||||||||||||
5002 | if (d->window && d->dirtyAttributes) {
| 0-291141 | ||||||||||||||||||||||||
5003 | d->addToDirtyList(); | - | ||||||||||||||||||||||||
5004 | QQuickWindowPrivate::get(d->window)->dirtyItem(this); | - | ||||||||||||||||||||||||
5005 | } executed 154837 times by 18 tests: end of block Executed by:
| 154837 | ||||||||||||||||||||||||
5006 | } executed 445978 times by 126 tests: end of block Executed by:
| 445978 | ||||||||||||||||||||||||
5007 | - | |||||||||||||||||||||||||
5008 | QQuickStateGroup *QQuickItemPrivate::_states() | - | ||||||||||||||||||||||||
5009 | { | - | ||||||||||||||||||||||||
5010 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
5011 | if (!_stateGroup) {
| 1064-1250 | ||||||||||||||||||||||||
5012 | _stateGroup = new QQuickStateGroup; | - | ||||||||||||||||||||||||
5013 | if (!componentComplete)
| 54-1010 | ||||||||||||||||||||||||
5014 | _stateGroup->classBegin(); executed 1010 times by 17 tests: _stateGroup->classBegin(); Executed by:
| 1010 | ||||||||||||||||||||||||
5015 | qmlobject_connect(_stateGroup, QQuickStateGroup, SIGNAL(stateChanged(QString)), executed 56 times by 24 tests: end of block Executed by:
never executed: methodIdx = QQuickItem::staticMetaObject.indexOfSlot(method+1); executed 56 times by 24 tests: methodIdx = QQuickItem::staticMetaObject.indexOfSignal(method+1); Executed by:
| 0-1008 | ||||||||||||||||||||||||
5016 | q, QQuickItem, SIGNAL(stateChanged(QString))) | - | ||||||||||||||||||||||||
5017 | } executed 1064 times by 24 tests: end of block Executed by:
| 1064 | ||||||||||||||||||||||||
5018 | - | |||||||||||||||||||||||||
5019 | return _stateGroup; executed 2314 times by 24 tests: return _stateGroup; Executed by:
| 2314 | ||||||||||||||||||||||||
5020 | } | - | ||||||||||||||||||||||||
5021 | - | |||||||||||||||||||||||||
5022 | QPointF QQuickItemPrivate::computeTransformOrigin() const | - | ||||||||||||||||||||||||
5023 | { | - | ||||||||||||||||||||||||
5024 | switch (origin()) { | - | ||||||||||||||||||||||||
5025 | default: never executed: default: | 0 | ||||||||||||||||||||||||
5026 | case QQuickItem::TopLeft: executed 24 times by 2 tests: case QQuickItem::TopLeft: Executed by:
| 24 | ||||||||||||||||||||||||
5027 | return QPointF(0, 0); executed 24 times by 2 tests: return QPointF(0, 0); Executed by:
| 24 | ||||||||||||||||||||||||
5028 | case QQuickItem::Top: never executed: case QQuickItem::Top: | 0 | ||||||||||||||||||||||||
5029 | return QPointF(width / 2., 0); never executed: return QPointF(width / 2., 0); | 0 | ||||||||||||||||||||||||
5030 | case QQuickItem::TopRight: never executed: case QQuickItem::TopRight: | 0 | ||||||||||||||||||||||||
5031 | return QPointF(width, 0); never executed: return QPointF(width, 0); | 0 | ||||||||||||||||||||||||
5032 | case QQuickItem::Left: never executed: case QQuickItem::Left: | 0 | ||||||||||||||||||||||||
5033 | return QPointF(0, height / 2.); never executed: return QPointF(0, height / 2.); | 0 | ||||||||||||||||||||||||
5034 | case QQuickItem::Center: executed 7794 times by 21 tests: case QQuickItem::Center: Executed by:
| 7794 | ||||||||||||||||||||||||
5035 | return QPointF(width / 2., height / 2.); executed 7794 times by 21 tests: return QPointF(width / 2., height / 2.); Executed by:
| 7794 | ||||||||||||||||||||||||
5036 | case QQuickItem::Right: never executed: case QQuickItem::Right: | 0 | ||||||||||||||||||||||||
5037 | return QPointF(width, height / 2.); never executed: return QPointF(width, height / 2.); | 0 | ||||||||||||||||||||||||
5038 | case QQuickItem::BottomLeft: executed 8 times by 1 test: case QQuickItem::BottomLeft: Executed by:
| 8 | ||||||||||||||||||||||||
5039 | return QPointF(0, height); executed 8 times by 1 test: return QPointF(0, height); Executed by:
| 8 | ||||||||||||||||||||||||
5040 | case QQuickItem::Bottom: never executed: case QQuickItem::Bottom: | 0 | ||||||||||||||||||||||||
5041 | return QPointF(width / 2., height); never executed: return QPointF(width / 2., height); | 0 | ||||||||||||||||||||||||
5042 | case QQuickItem::BottomRight: never executed: case QQuickItem::BottomRight: | 0 | ||||||||||||||||||||||||
5043 | return QPointF(width, height); never executed: return QPointF(width, height); | 0 | ||||||||||||||||||||||||
5044 | } | - | ||||||||||||||||||||||||
5045 | } | - | ||||||||||||||||||||||||
5046 | - | |||||||||||||||||||||||||
5047 | void QQuickItemPrivate::transformChanged() | - | ||||||||||||||||||||||||
5048 | { | - | ||||||||||||||||||||||||
5049 | #if QT_CONFIG(quick_shadereffect) | - | ||||||||||||||||||||||||
5050 | if (extra.isAllocated() && extra->layer)
| 112-845798 | ||||||||||||||||||||||||
5051 | extra->layer->updateMatrix(); executed 112 times by 4 tests: extra->layer->updateMatrix(); Executed by:
| 112 | ||||||||||||||||||||||||
5052 | #endif | - | ||||||||||||||||||||||||
5053 | } executed 1212383 times by 102 tests: end of block Executed by:
| 1212383 | ||||||||||||||||||||||||
5054 | - | |||||||||||||||||||||||||
5055 | bool QQuickItemPrivate::filterKeyEvent(QKeyEvent *e, bool post) | - | ||||||||||||||||||||||||
5056 | { | - | ||||||||||||||||||||||||
5057 | if (!extra.isAllocated() || !extra->keyHandler)
| 184-16544 | ||||||||||||||||||||||||
5058 | return false; executed 16126 times by 8 tests: return false; Executed by:
| 16126 | ||||||||||||||||||||||||
5059 | - | |||||||||||||||||||||||||
5060 | if (post)
| 252-350 | ||||||||||||||||||||||||
5061 | e->accept(); executed 252 times by 4 tests: e->accept(); Executed by:
| 252 | ||||||||||||||||||||||||
5062 | - | |||||||||||||||||||||||||
5063 | if (e->type() == QEvent::KeyPress)
| 208-394 | ||||||||||||||||||||||||
5064 | extra->keyHandler->keyPressed(e, post); executed 394 times by 5 tests: extra->keyHandler->keyPressed(e, post); Executed by:
| 394 | ||||||||||||||||||||||||
5065 | else | - | ||||||||||||||||||||||||
5066 | extra->keyHandler->keyReleased(e, post); executed 208 times by 4 tests: extra->keyHandler->keyReleased(e, post); Executed by:
| 208 | ||||||||||||||||||||||||
5067 | - | |||||||||||||||||||||||||
5068 | return e->isAccepted(); executed 602 times by 5 tests: return e->isAccepted(); Executed by:
| 602 | ||||||||||||||||||||||||
5069 | } | - | ||||||||||||||||||||||||
5070 | - | |||||||||||||||||||||||||
5071 | void QQuickItemPrivate::deliverKeyEvent(QKeyEvent *e) | - | ||||||||||||||||||||||||
5072 | { | - | ||||||||||||||||||||||||
5073 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
5074 | - | |||||||||||||||||||||||||
5075 | Q_ASSERT(e->isAccepted()); | - | ||||||||||||||||||||||||
5076 | if (filterKeyEvent(e, false))
| 40-10182 | ||||||||||||||||||||||||
5077 | return; executed 40 times by 3 tests: return; Executed by:
| 40 | ||||||||||||||||||||||||
5078 | else | - | ||||||||||||||||||||||||
5079 | e->accept(); executed 10182 times by 8 tests: e->accept(); Executed by:
| 10182 | ||||||||||||||||||||||||
5080 | - | |||||||||||||||||||||||||
5081 | if (e->type() == QEvent::KeyPress)
| 4318-5864 | ||||||||||||||||||||||||
5082 | q->keyPressEvent(e); executed 4318 times by 7 tests: q->keyPressEvent(e); Executed by:
| 4318 | ||||||||||||||||||||||||
5083 | else | - | ||||||||||||||||||||||||
5084 | q->keyReleaseEvent(e); executed 5864 times by 7 tests: q->keyReleaseEvent(e); Executed by:
| 5864 | ||||||||||||||||||||||||
5085 | - | |||||||||||||||||||||||||
5086 | if (e->isAccepted())
| 3676-6506 | ||||||||||||||||||||||||
5087 | return; executed 3676 times by 6 tests: return; Executed by:
| 3676 | ||||||||||||||||||||||||
5088 | - | |||||||||||||||||||||||||
5089 | if (filterKeyEvent(e, true) || !q->window())
| 0-6370 | ||||||||||||||||||||||||
5090 | return; executed 136 times by 4 tests: return; Executed by:
| 136 | ||||||||||||||||||||||||
5091 | - | |||||||||||||||||||||||||
5092 | //only care about KeyPress now | - | ||||||||||||||||||||||||
5093 | if (e->type() == QEvent::KeyPress &&
| 1534-4836 | ||||||||||||||||||||||||
5094 | (q == q->window()->contentItem() || q->activeFocusOnTab())) {
| 194-1040 | ||||||||||||||||||||||||
5095 | bool res = false; | - | ||||||||||||||||||||||||
5096 | if (!(e->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
| 154-534 | ||||||||||||||||||||||||
5097 | if (e->key() == Qt::Key_Backtab
| 0-534 | ||||||||||||||||||||||||
5098 | || (e->key() == Qt::Key_Tab && (e->modifiers() & Qt::ShiftModifier)))
| 198-336 | ||||||||||||||||||||||||
5099 | res = QQuickItemPrivate::focusNextPrev(q, false); executed 104 times by 2 tests: res = QQuickItemPrivate::focusNextPrev(q, false); Executed by:
| 104 | ||||||||||||||||||||||||
5100 | else if (e->key() == Qt::Key_Tab)
| 94-336 | ||||||||||||||||||||||||
5101 | res = QQuickItemPrivate::focusNextPrev(q, true); executed 94 times by 1 test: res = QQuickItemPrivate::focusNextPrev(q, true); Executed by:
| 94 | ||||||||||||||||||||||||
5102 | if (res)
| 198-336 | ||||||||||||||||||||||||
5103 | e->setAccepted(true); executed 198 times by 2 tests: e->setAccepted(true); Executed by:
| 198 | ||||||||||||||||||||||||
5104 | } executed 534 times by 7 tests: end of block Executed by:
| 534 | ||||||||||||||||||||||||
5105 | } executed 688 times by 7 tests: end of block Executed by:
| 688 | ||||||||||||||||||||||||
5106 | } executed 6370 times by 8 tests: end of block Executed by:
| 6370 | ||||||||||||||||||||||||
5107 | - | |||||||||||||||||||||||||
5108 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
5109 | void QQuickItemPrivate::deliverInputMethodEvent(QInputMethodEvent *e) | - | ||||||||||||||||||||||||
5110 | { | - | ||||||||||||||||||||||||
5111 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
5112 | - | |||||||||||||||||||||||||
5113 | Q_ASSERT(e->isAccepted()); | - | ||||||||||||||||||||||||
5114 | if (extra.isAllocated() && extra->keyHandler) {
| 0 | ||||||||||||||||||||||||
5115 | extra->keyHandler->inputMethodEvent(e, false); | - | ||||||||||||||||||||||||
5116 | - | |||||||||||||||||||||||||
5117 | if (e->isAccepted())
| 0 | ||||||||||||||||||||||||
5118 | return; never executed: return; | 0 | ||||||||||||||||||||||||
5119 | else | - | ||||||||||||||||||||||||
5120 | e->accept(); never executed: e->accept(); | 0 | ||||||||||||||||||||||||
5121 | } | - | ||||||||||||||||||||||||
5122 | - | |||||||||||||||||||||||||
5123 | q->inputMethodEvent(e); | - | ||||||||||||||||||||||||
5124 | - | |||||||||||||||||||||||||
5125 | if (e->isAccepted())
| 0 | ||||||||||||||||||||||||
5126 | return; never executed: return; | 0 | ||||||||||||||||||||||||
5127 | - | |||||||||||||||||||||||||
5128 | if (extra.isAllocated() && extra->keyHandler) {
| 0 | ||||||||||||||||||||||||
5129 | e->accept(); | - | ||||||||||||||||||||||||
5130 | - | |||||||||||||||||||||||||
5131 | extra->keyHandler->inputMethodEvent(e, true); | - | ||||||||||||||||||||||||
5132 | } never executed: end of block | 0 | ||||||||||||||||||||||||
5133 | } never executed: end of block | 0 | ||||||||||||||||||||||||
5134 | #endif // im | - | ||||||||||||||||||||||||
5135 | - | |||||||||||||||||||||||||
5136 | void QQuickItemPrivate::deliverShortcutOverrideEvent(QKeyEvent *event) | - | ||||||||||||||||||||||||
5137 | { | - | ||||||||||||||||||||||||
5138 | if (extra.isAllocated() && extra->keyHandler) {
| 0-350 | ||||||||||||||||||||||||
5139 | extra->keyHandler->shortcutOverride(event); | - | ||||||||||||||||||||||||
5140 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||
5141 | } executed 350 times by 6 tests: end of block Executed by:
| 350 | ||||||||||||||||||||||||
5142 | - | |||||||||||||||||||||||||
5143 | bool QQuickItemPrivate::anyPointerHandlerWants(QQuickEventPoint *point) const | - | ||||||||||||||||||||||||
5144 | { | - | ||||||||||||||||||||||||
5145 | if (!hasPointerHandlers())
| 0-4968 | ||||||||||||||||||||||||
5146 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
5147 | for (QQuickPointerHandler *handler : extra->pointerHandlers) { | - | ||||||||||||||||||||||||
5148 | if (handler->wantsEventPoint(point))
| 952-5192 | ||||||||||||||||||||||||
5149 | return true; executed 952 times by 2 tests: return true; Executed by:
| 952 | ||||||||||||||||||||||||
5150 | } executed 5192 times by 4 tests: end of block Executed by:
| 5192 | ||||||||||||||||||||||||
5151 | return false; executed 4016 times by 4 tests: return false; Executed by:
| 4016 | ||||||||||||||||||||||||
5152 | } | - | ||||||||||||||||||||||||
5153 | - | |||||||||||||||||||||||||
5154 | /*! | - | ||||||||||||||||||||||||
5155 | \internal | - | ||||||||||||||||||||||||
5156 | Deliver the \a event to all PointerHandlers which are in the pre-determined | - | ||||||||||||||||||||||||
5157 | eventDeliveryTargets() vector. If \a avoidExclusiveGrabber is true, it skips | - | ||||||||||||||||||||||||
5158 | delivery to any handler which is the exclusive grabber of any point within this event | - | ||||||||||||||||||||||||
5159 | (because delivery to exclusive grabbers is handled separately). | - | ||||||||||||||||||||||||
5160 | */ | - | ||||||||||||||||||||||||
5161 | bool QQuickItemPrivate::handlePointerEvent(QQuickPointerEvent *event, bool avoidExclusiveGrabber) | - | ||||||||||||||||||||||||
5162 | { | - | ||||||||||||||||||||||||
5163 | bool delivered = false; | - | ||||||||||||||||||||||||
5164 | QVector<QQuickPointerHandler *> &eventDeliveryTargets = event->device()->eventDeliveryTargets(); | - | ||||||||||||||||||||||||
5165 | if (extra.isAllocated()) {
| 1047-6482 | ||||||||||||||||||||||||
5166 | for (QQuickPointerHandler *handler : extra->pointerHandlers) { | - | ||||||||||||||||||||||||
5167 | if ((!avoidExclusiveGrabber || !event->hasExclusiveGrabber(handler)) && !eventDeliveryTargets.contains(handler)) {
| 58-1643 | ||||||||||||||||||||||||
5168 | handler->handlePointerEvent(event); | - | ||||||||||||||||||||||||
5169 | delivered = true; | - | ||||||||||||||||||||||||
5170 | } executed 1643 times by 5 tests: end of block Executed by:
| 1643 | ||||||||||||||||||||||||
5171 | } executed 2842 times by 5 tests: end of block Executed by:
| 2842 | ||||||||||||||||||||||||
5172 | } executed 6482 times by 15 tests: end of block Executed by:
| 6482 | ||||||||||||||||||||||||
5173 | return delivered; executed 7529 times by 16 tests: return delivered; Executed by:
| 7529 | ||||||||||||||||||||||||
5174 | } | - | ||||||||||||||||||||||||
5175 | - | |||||||||||||||||||||||||
5176 | /*! | - | ||||||||||||||||||||||||
5177 | Called when \a change occurs for this item. | - | ||||||||||||||||||||||||
5178 | - | |||||||||||||||||||||||||
5179 | \a value contains extra information relating to the change, when | - | ||||||||||||||||||||||||
5180 | applicable. | - | ||||||||||||||||||||||||
5181 | - | |||||||||||||||||||||||||
5182 | If you re-implement this method in a subclass, be sure to call | - | ||||||||||||||||||||||||
5183 | \code | - | ||||||||||||||||||||||||
5184 | QQuickItem::itemChange(change, value); | - | ||||||||||||||||||||||||
5185 | \endcode | - | ||||||||||||||||||||||||
5186 | typically at the end of your implementation, to ensure the | - | ||||||||||||||||||||||||
5187 | \l windowChanged() signal will be emitted. | - | ||||||||||||||||||||||||
5188 | */ | - | ||||||||||||||||||||||||
5189 | void QQuickItem::itemChange(ItemChange change, const ItemChangeData &value) | - | ||||||||||||||||||||||||
5190 | { | - | ||||||||||||||||||||||||
5191 | if (change == ItemSceneChange)
| 806842-1679101 | ||||||||||||||||||||||||
5192 | emit windowChanged(value.window); executed 806842 times by 90 tests: windowChanged(value.window); Executed by:
| 806842 | ||||||||||||||||||||||||
5193 | } executed 2485943 times by 106 tests: end of block Executed by:
| 2485943 | ||||||||||||||||||||||||
5194 | - | |||||||||||||||||||||||||
5195 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
5196 | /*! | - | ||||||||||||||||||||||||
5197 | Notify input method on updated query values if needed. \a queries indicates | - | ||||||||||||||||||||||||
5198 | the changed attributes. | - | ||||||||||||||||||||||||
5199 | */ | - | ||||||||||||||||||||||||
5200 | void QQuickItem::updateInputMethod(Qt::InputMethodQueries queries) | - | ||||||||||||||||||||||||
5201 | { | - | ||||||||||||||||||||||||
5202 | if (hasActiveFocus())
| 10807-14303 | ||||||||||||||||||||||||
5203 | QGuiApplication::inputMethod()->update(queries); executed 14303 times by 17 tests: QGuiApplication::inputMethod()->update(queries); Executed by:
| 14303 | ||||||||||||||||||||||||
5204 | } executed 25110 times by 19 tests: end of block Executed by:
| 25110 | ||||||||||||||||||||||||
5205 | #endif // im | - | ||||||||||||||||||||||||
5206 | - | |||||||||||||||||||||||||
5207 | // XXX todo - do we want/need this anymore? | - | ||||||||||||||||||||||||
5208 | /*! \internal */ | - | ||||||||||||||||||||||||
5209 | QRectF QQuickItem::boundingRect() const | - | ||||||||||||||||||||||||
5210 | { | - | ||||||||||||||||||||||||
5211 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
5212 | return QRectF(0, 0, d->width, d->height); executed 150 times by 1 test: return QRectF(0, 0, d->width, d->height); Executed by:
| 150 | ||||||||||||||||||||||||
5213 | } | - | ||||||||||||||||||||||||
5214 | - | |||||||||||||||||||||||||
5215 | /*! \internal */ | - | ||||||||||||||||||||||||
5216 | QRectF QQuickItem::clipRect() const | - | ||||||||||||||||||||||||
5217 | { | - | ||||||||||||||||||||||||
5218 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
5219 | return QRectF(0, 0, d->width, d->height); executed 1048 times by 16 tests: return QRectF(0, 0, d->width, d->height); Executed by:
| 1048 | ||||||||||||||||||||||||
5220 | } | - | ||||||||||||||||||||||||
5221 | - | |||||||||||||||||||||||||
5222 | /*! | - | ||||||||||||||||||||||||
5223 | \qmlproperty enumeration QtQuick::Item::transformOrigin | - | ||||||||||||||||||||||||
5224 | This property holds the origin point around which scale and rotation transform. | - | ||||||||||||||||||||||||
5225 | - | |||||||||||||||||||||||||
5226 | Nine transform origins are available, as shown in the image below. | - | ||||||||||||||||||||||||
5227 | The default transform origin is \c Item.Center. | - | ||||||||||||||||||||||||
5228 | - | |||||||||||||||||||||||||
5229 | \image declarative-transformorigin.png | - | ||||||||||||||||||||||||
5230 | - | |||||||||||||||||||||||||
5231 | This example rotates an image around its bottom-right corner. | - | ||||||||||||||||||||||||
5232 | \qml | - | ||||||||||||||||||||||||
5233 | Image { | - | ||||||||||||||||||||||||
5234 | source: "myimage.png" | - | ||||||||||||||||||||||||
5235 | transformOrigin: Item.BottomRight | - | ||||||||||||||||||||||||
5236 | rotation: 45 | - | ||||||||||||||||||||||||
5237 | } | - | ||||||||||||||||||||||||
5238 | \endqml | - | ||||||||||||||||||||||||
5239 | - | |||||||||||||||||||||||||
5240 | To set an arbitrary transform origin point use the \l Scale or \l Rotation | - | ||||||||||||||||||||||||
5241 | transform types with \l transform. | - | ||||||||||||||||||||||||
5242 | */ | - | ||||||||||||||||||||||||
5243 | /*! | - | ||||||||||||||||||||||||
5244 | \property QQuickItem::transformOrigin | - | ||||||||||||||||||||||||
5245 | This property holds the origin point around which scale and rotation transform. | - | ||||||||||||||||||||||||
5246 | - | |||||||||||||||||||||||||
5247 | Nine transform origins are available, as shown in the image below. | - | ||||||||||||||||||||||||
5248 | The default transform origin is \c Item.Center. | - | ||||||||||||||||||||||||
5249 | - | |||||||||||||||||||||||||
5250 | \image declarative-transformorigin.png | - | ||||||||||||||||||||||||
5251 | */ | - | ||||||||||||||||||||||||
5252 | QQuickItem::TransformOrigin QQuickItem::transformOrigin() const | - | ||||||||||||||||||||||||
5253 | { | - | ||||||||||||||||||||||||
5254 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
5255 | return d->origin(); executed 304 times by 11 tests: return d->origin(); Executed by:
| 304 | ||||||||||||||||||||||||
5256 | } | - | ||||||||||||||||||||||||
5257 | - | |||||||||||||||||||||||||
5258 | void QQuickItem::setTransformOrigin(TransformOrigin origin) | - | ||||||||||||||||||||||||
5259 | { | - | ||||||||||||||||||||||||
5260 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
5261 | if (origin == d->origin())
| 30-198 | ||||||||||||||||||||||||
5262 | return; executed 198 times by 4 tests: return; Executed by:
| 198 | ||||||||||||||||||||||||
5263 | - | |||||||||||||||||||||||||
5264 | d->extra.value().origin = origin; | - | ||||||||||||||||||||||||
5265 | d->dirty(QQuickItemPrivate::TransformOrigin); | - | ||||||||||||||||||||||||
5266 | - | |||||||||||||||||||||||||
5267 | emit transformOriginChanged(d->origin()); | - | ||||||||||||||||||||||||
5268 | } executed 30 times by 4 tests: end of block Executed by:
| 30 | ||||||||||||||||||||||||
5269 | - | |||||||||||||||||||||||||
5270 | /*! | - | ||||||||||||||||||||||||
5271 | \property QQuickItem::transformOriginPoint | - | ||||||||||||||||||||||||
5272 | \internal | - | ||||||||||||||||||||||||
5273 | */ | - | ||||||||||||||||||||||||
5274 | /*! | - | ||||||||||||||||||||||||
5275 | \internal | - | ||||||||||||||||||||||||
5276 | */ | - | ||||||||||||||||||||||||
5277 | QPointF QQuickItem::transformOriginPoint() const | - | ||||||||||||||||||||||||
5278 | { | - | ||||||||||||||||||||||||
5279 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
5280 | if (d->extra.isAllocated() && !d->extra->userTransformOriginPoint.isNull())
| 0-1625 | ||||||||||||||||||||||||
5281 | return d->extra->userTransformOriginPoint; never executed: return d->extra->userTransformOriginPoint; | 0 | ||||||||||||||||||||||||
5282 | return d->computeTransformOrigin(); executed 1673 times by 21 tests: return d->computeTransformOrigin(); Executed by:
| 1673 | ||||||||||||||||||||||||
5283 | } | - | ||||||||||||||||||||||||
5284 | - | |||||||||||||||||||||||||
5285 | /*! | - | ||||||||||||||||||||||||
5286 | \internal | - | ||||||||||||||||||||||||
5287 | */ | - | ||||||||||||||||||||||||
5288 | void QQuickItem::setTransformOriginPoint(const QPointF &point) | - | ||||||||||||||||||||||||
5289 | { | - | ||||||||||||||||||||||||
5290 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
5291 | if (d->extra.value().userTransformOriginPoint == point)
| 0 | ||||||||||||||||||||||||
5292 | return; never executed: return; | 0 | ||||||||||||||||||||||||
5293 | - | |||||||||||||||||||||||||
5294 | d->extra->userTransformOriginPoint = point; | - | ||||||||||||||||||||||||
5295 | d->dirty(QQuickItemPrivate::TransformOrigin); | - | ||||||||||||||||||||||||
5296 | } never executed: end of block | 0 | ||||||||||||||||||||||||
5297 | - | |||||||||||||||||||||||||
5298 | /*! | - | ||||||||||||||||||||||||
5299 | \qmlproperty real QtQuick::Item::z | - | ||||||||||||||||||||||||
5300 | - | |||||||||||||||||||||||||
5301 | Sets the stacking order of sibling items. By default the stacking order is 0. | - | ||||||||||||||||||||||||
5302 | - | |||||||||||||||||||||||||
5303 | Items with a higher stacking value are drawn on top of siblings with a | - | ||||||||||||||||||||||||
5304 | lower stacking order. Items with the same stacking value are drawn | - | ||||||||||||||||||||||||
5305 | bottom up in the order they appear. Items with a negative stacking | - | ||||||||||||||||||||||||
5306 | value are drawn under their parent's content. | - | ||||||||||||||||||||||||
5307 | - | |||||||||||||||||||||||||
5308 | The following example shows the various effects of stacking order. | - | ||||||||||||||||||||||||
5309 | - | |||||||||||||||||||||||||
5310 | \table | - | ||||||||||||||||||||||||
5311 | \row | - | ||||||||||||||||||||||||
5312 | \li \image declarative-item_stacking1.png | - | ||||||||||||||||||||||||
5313 | \li Same \c z - later children above earlier children: | - | ||||||||||||||||||||||||
5314 | \qml | - | ||||||||||||||||||||||||
5315 | Item { | - | ||||||||||||||||||||||||
5316 | Rectangle { | - | ||||||||||||||||||||||||
5317 | color: "red" | - | ||||||||||||||||||||||||
5318 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5319 | } | - | ||||||||||||||||||||||||
5320 | Rectangle { | - | ||||||||||||||||||||||||
5321 | color: "blue" | - | ||||||||||||||||||||||||
5322 | x: 50; y: 50; width: 100; height: 100 | - | ||||||||||||||||||||||||
5323 | } | - | ||||||||||||||||||||||||
5324 | } | - | ||||||||||||||||||||||||
5325 | \endqml | - | ||||||||||||||||||||||||
5326 | \row | - | ||||||||||||||||||||||||
5327 | \li \image declarative-item_stacking2.png | - | ||||||||||||||||||||||||
5328 | \li Higher \c z on top: | - | ||||||||||||||||||||||||
5329 | \qml | - | ||||||||||||||||||||||||
5330 | Item { | - | ||||||||||||||||||||||||
5331 | Rectangle { | - | ||||||||||||||||||||||||
5332 | z: 1 | - | ||||||||||||||||||||||||
5333 | color: "red" | - | ||||||||||||||||||||||||
5334 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5335 | } | - | ||||||||||||||||||||||||
5336 | Rectangle { | - | ||||||||||||||||||||||||
5337 | color: "blue" | - | ||||||||||||||||||||||||
5338 | x: 50; y: 50; width: 100; height: 100 | - | ||||||||||||||||||||||||
5339 | } | - | ||||||||||||||||||||||||
5340 | } | - | ||||||||||||||||||||||||
5341 | \endqml | - | ||||||||||||||||||||||||
5342 | \row | - | ||||||||||||||||||||||||
5343 | \li \image declarative-item_stacking3.png | - | ||||||||||||||||||||||||
5344 | \li Same \c z - children above parents: | - | ||||||||||||||||||||||||
5345 | \qml | - | ||||||||||||||||||||||||
5346 | Item { | - | ||||||||||||||||||||||||
5347 | Rectangle { | - | ||||||||||||||||||||||||
5348 | color: "red" | - | ||||||||||||||||||||||||
5349 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5350 | Rectangle { | - | ||||||||||||||||||||||||
5351 | color: "blue" | - | ||||||||||||||||||||||||
5352 | x: 50; y: 50; width: 100; height: 100 | - | ||||||||||||||||||||||||
5353 | } | - | ||||||||||||||||||||||||
5354 | } | - | ||||||||||||||||||||||||
5355 | } | - | ||||||||||||||||||||||||
5356 | \endqml | - | ||||||||||||||||||||||||
5357 | \row | - | ||||||||||||||||||||||||
5358 | \li \image declarative-item_stacking4.png | - | ||||||||||||||||||||||||
5359 | \li Lower \c z below: | - | ||||||||||||||||||||||||
5360 | \qml | - | ||||||||||||||||||||||||
5361 | Item { | - | ||||||||||||||||||||||||
5362 | Rectangle { | - | ||||||||||||||||||||||||
5363 | color: "red" | - | ||||||||||||||||||||||||
5364 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5365 | Rectangle { | - | ||||||||||||||||||||||||
5366 | z: -1 | - | ||||||||||||||||||||||||
5367 | color: "blue" | - | ||||||||||||||||||||||||
5368 | x: 50; y: 50; width: 100; height: 100 | - | ||||||||||||||||||||||||
5369 | } | - | ||||||||||||||||||||||||
5370 | } | - | ||||||||||||||||||||||||
5371 | } | - | ||||||||||||||||||||||||
5372 | \endqml | - | ||||||||||||||||||||||||
5373 | \endtable | - | ||||||||||||||||||||||||
5374 | */ | - | ||||||||||||||||||||||||
5375 | /*! | - | ||||||||||||||||||||||||
5376 | \property QQuickItem::z | - | ||||||||||||||||||||||||
5377 | - | |||||||||||||||||||||||||
5378 | Sets the stacking order of sibling items. By default the stacking order is 0. | - | ||||||||||||||||||||||||
5379 | - | |||||||||||||||||||||||||
5380 | Items with a higher stacking value are drawn on top of siblings with a | - | ||||||||||||||||||||||||
5381 | lower stacking order. Items with the same stacking value are drawn | - | ||||||||||||||||||||||||
5382 | bottom up in the order they appear. Items with a negative stacking | - | ||||||||||||||||||||||||
5383 | value are drawn under their parent's content. | - | ||||||||||||||||||||||||
5384 | - | |||||||||||||||||||||||||
5385 | The following example shows the various effects of stacking order. | - | ||||||||||||||||||||||||
5386 | - | |||||||||||||||||||||||||
5387 | \table | - | ||||||||||||||||||||||||
5388 | \row | - | ||||||||||||||||||||||||
5389 | \li \image declarative-item_stacking1.png | - | ||||||||||||||||||||||||
5390 | \li Same \c z - later children above earlier children: | - | ||||||||||||||||||||||||
5391 | \qml | - | ||||||||||||||||||||||||
5392 | Item { | - | ||||||||||||||||||||||||
5393 | Rectangle { | - | ||||||||||||||||||||||||
5394 | color: "red" | - | ||||||||||||||||||||||||
5395 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5396 | } | - | ||||||||||||||||||||||||
5397 | Rectangle { | - | ||||||||||||||||||||||||
5398 | color: "blue" | - | ||||||||||||||||||||||||
5399 | x: 50; y: 50; width: 100; height: 100 | - | ||||||||||||||||||||||||
5400 | } | - | ||||||||||||||||||||||||
5401 | } | - | ||||||||||||||||||||||||
5402 | \endqml | - | ||||||||||||||||||||||||
5403 | \row | - | ||||||||||||||||||||||||
5404 | \li \image declarative-item_stacking2.png | - | ||||||||||||||||||||||||
5405 | \li Higher \c z on top: | - | ||||||||||||||||||||||||
5406 | \qml | - | ||||||||||||||||||||||||
5407 | Item { | - | ||||||||||||||||||||||||
5408 | Rectangle { | - | ||||||||||||||||||||||||
5409 | z: 1 | - | ||||||||||||||||||||||||
5410 | color: "red" | - | ||||||||||||||||||||||||
5411 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5412 | } | - | ||||||||||||||||||||||||
5413 | Rectangle { | - | ||||||||||||||||||||||||
5414 | color: "blue" | - | ||||||||||||||||||||||||
5415 | x: 50; y: 50; width: 100; height: 100 | - | ||||||||||||||||||||||||
5416 | } | - | ||||||||||||||||||||||||
5417 | } | - | ||||||||||||||||||||||||
5418 | \endqml | - | ||||||||||||||||||||||||
5419 | \row | - | ||||||||||||||||||||||||
5420 | \li \image declarative-item_stacking3.png | - | ||||||||||||||||||||||||
5421 | \li Same \c z - children above parents: | - | ||||||||||||||||||||||||
5422 | \qml | - | ||||||||||||||||||||||||
5423 | Item { | - | ||||||||||||||||||||||||
5424 | Rectangle { | - | ||||||||||||||||||||||||
5425 | color: "red" | - | ||||||||||||||||||||||||
5426 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5427 | Rectangle { | - | ||||||||||||||||||||||||
5428 | color: "blue" | - | ||||||||||||||||||||||||
5429 | x: 50; y: 50; width: 100; height: 100 | - | ||||||||||||||||||||||||
5430 | } | - | ||||||||||||||||||||||||
5431 | } | - | ||||||||||||||||||||||||
5432 | } | - | ||||||||||||||||||||||||
5433 | \endqml | - | ||||||||||||||||||||||||
5434 | \row | - | ||||||||||||||||||||||||
5435 | \li \image declarative-item_stacking4.png | - | ||||||||||||||||||||||||
5436 | \li Lower \c z below: | - | ||||||||||||||||||||||||
5437 | \qml | - | ||||||||||||||||||||||||
5438 | Item { | - | ||||||||||||||||||||||||
5439 | Rectangle { | - | ||||||||||||||||||||||||
5440 | color: "red" | - | ||||||||||||||||||||||||
5441 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5442 | Rectangle { | - | ||||||||||||||||||||||||
5443 | z: -1 | - | ||||||||||||||||||||||||
5444 | color: "blue" | - | ||||||||||||||||||||||||
5445 | x: 50; y: 50; width: 100; height: 100 | - | ||||||||||||||||||||||||
5446 | } | - | ||||||||||||||||||||||||
5447 | } | - | ||||||||||||||||||||||||
5448 | } | - | ||||||||||||||||||||||||
5449 | \endqml | - | ||||||||||||||||||||||||
5450 | \endtable | - | ||||||||||||||||||||||||
5451 | */ | - | ||||||||||||||||||||||||
5452 | qreal QQuickItem::z() const | - | ||||||||||||||||||||||||
5453 | { | - | ||||||||||||||||||||||||
5454 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
5455 | return d->z(); executed 2075645 times by 106 tests: return d->z(); Executed by:
| 2075645 | ||||||||||||||||||||||||
5456 | } | - | ||||||||||||||||||||||||
5457 | - | |||||||||||||||||||||||||
5458 | void QQuickItem::setZ(qreal v) | - | ||||||||||||||||||||||||
5459 | { | - | ||||||||||||||||||||||||
5460 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
5461 | if (d->z() == v)
| 4308-80357 | ||||||||||||||||||||||||
5462 | return; executed 4308 times by 13 tests: return; Executed by:
| 4308 | ||||||||||||||||||||||||
5463 | - | |||||||||||||||||||||||||
5464 | d->extra.value().z = v; | - | ||||||||||||||||||||||||
5465 | - | |||||||||||||||||||||||||
5466 | d->dirty(QQuickItemPrivate::ZValue); | - | ||||||||||||||||||||||||
5467 | if (d->parentItem) {
| 3268-77089 | ||||||||||||||||||||||||
5468 | QQuickItemPrivate::get(d->parentItem)->dirty(QQuickItemPrivate::ChildrenStackingChanged); | - | ||||||||||||||||||||||||
5469 | QQuickItemPrivate::get(d->parentItem)->markSortedChildrenDirty(this); | - | ||||||||||||||||||||||||
5470 | } executed 3268 times by 8 tests: end of block Executed by:
| 3268 | ||||||||||||||||||||||||
5471 | - | |||||||||||||||||||||||||
5472 | emit zChanged(); | - | ||||||||||||||||||||||||
5473 | - | |||||||||||||||||||||||||
5474 | #if QT_CONFIG(quick_shadereffect) | - | ||||||||||||||||||||||||
5475 | if (d->extra.isAllocated() && d->extra->layer)
| 0-80357 | ||||||||||||||||||||||||
5476 | d->extra->layer->updateZ(); executed 6 times by 1 test: d->extra->layer->updateZ(); Executed by:
| 6 | ||||||||||||||||||||||||
5477 | #endif | - | ||||||||||||||||||||||||
5478 | } executed 80357 times by 16 tests: end of block Executed by:
| 80357 | ||||||||||||||||||||||||
5479 | - | |||||||||||||||||||||||||
5480 | /*! | - | ||||||||||||||||||||||||
5481 | \qmlproperty real QtQuick::Item::rotation | - | ||||||||||||||||||||||||
5482 | This property holds the rotation of the item in degrees clockwise around | - | ||||||||||||||||||||||||
5483 | its transformOrigin. | - | ||||||||||||||||||||||||
5484 | - | |||||||||||||||||||||||||
5485 | The default value is 0 degrees (that is, no rotation). | - | ||||||||||||||||||||||||
5486 | - | |||||||||||||||||||||||||
5487 | \table | - | ||||||||||||||||||||||||
5488 | \row | - | ||||||||||||||||||||||||
5489 | \li \image declarative-rotation.png | - | ||||||||||||||||||||||||
5490 | \li | - | ||||||||||||||||||||||||
5491 | \qml | - | ||||||||||||||||||||||||
5492 | Rectangle { | - | ||||||||||||||||||||||||
5493 | color: "blue" | - | ||||||||||||||||||||||||
5494 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5495 | Rectangle { | - | ||||||||||||||||||||||||
5496 | color: "red" | - | ||||||||||||||||||||||||
5497 | x: 25; y: 25; width: 50; height: 50 | - | ||||||||||||||||||||||||
5498 | rotation: 30 | - | ||||||||||||||||||||||||
5499 | } | - | ||||||||||||||||||||||||
5500 | } | - | ||||||||||||||||||||||||
5501 | \endqml | - | ||||||||||||||||||||||||
5502 | \endtable | - | ||||||||||||||||||||||||
5503 | - | |||||||||||||||||||||||||
5504 | \sa Transform, Rotation | - | ||||||||||||||||||||||||
5505 | */ | - | ||||||||||||||||||||||||
5506 | /*! | - | ||||||||||||||||||||||||
5507 | \property QQuickItem::rotation | - | ||||||||||||||||||||||||
5508 | This property holds the rotation of the item in degrees clockwise around | - | ||||||||||||||||||||||||
5509 | its transformOrigin. | - | ||||||||||||||||||||||||
5510 | - | |||||||||||||||||||||||||
5511 | The default value is 0 degrees (that is, no rotation). | - | ||||||||||||||||||||||||
5512 | - | |||||||||||||||||||||||||
5513 | \table | - | ||||||||||||||||||||||||
5514 | \row | - | ||||||||||||||||||||||||
5515 | \li \image declarative-rotation.png | - | ||||||||||||||||||||||||
5516 | \li | - | ||||||||||||||||||||||||
5517 | \qml | - | ||||||||||||||||||||||||
5518 | Rectangle { | - | ||||||||||||||||||||||||
5519 | color: "blue" | - | ||||||||||||||||||||||||
5520 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5521 | Rectangle { | - | ||||||||||||||||||||||||
5522 | color: "red" | - | ||||||||||||||||||||||||
5523 | x: 25; y: 25; width: 50; height: 50 | - | ||||||||||||||||||||||||
5524 | rotation: 30 | - | ||||||||||||||||||||||||
5525 | } | - | ||||||||||||||||||||||||
5526 | } | - | ||||||||||||||||||||||||
5527 | \endqml | - | ||||||||||||||||||||||||
5528 | \endtable | - | ||||||||||||||||||||||||
5529 | - | |||||||||||||||||||||||||
5530 | \sa Transform, Rotation | - | ||||||||||||||||||||||||
5531 | */ | - | ||||||||||||||||||||||||
5532 | qreal QQuickItem::rotation() const | - | ||||||||||||||||||||||||
5533 | { | - | ||||||||||||||||||||||||
5534 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
5535 | return d->rotation(); executed 560 times by 15 tests: return d->rotation(); Executed by:
| 560 | ||||||||||||||||||||||||
5536 | } | - | ||||||||||||||||||||||||
5537 | - | |||||||||||||||||||||||||
5538 | void QQuickItem::setRotation(qreal r) | - | ||||||||||||||||||||||||
5539 | { | - | ||||||||||||||||||||||||
5540 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
5541 | if (d->rotation() == r)
| 300-1299 | ||||||||||||||||||||||||
5542 | return; executed 300 times by 8 tests: return; Executed by:
| 300 | ||||||||||||||||||||||||
5543 | - | |||||||||||||||||||||||||
5544 | d->extra.value().rotation = r; | - | ||||||||||||||||||||||||
5545 | - | |||||||||||||||||||||||||
5546 | d->dirty(QQuickItemPrivate::BasicTransform); | - | ||||||||||||||||||||||||
5547 | - | |||||||||||||||||||||||||
5548 | d->itemChange(ItemRotationHasChanged, r); | - | ||||||||||||||||||||||||
5549 | - | |||||||||||||||||||||||||
5550 | emit rotationChanged(); | - | ||||||||||||||||||||||||
5551 | } executed 1299 times by 13 tests: end of block Executed by:
| 1299 | ||||||||||||||||||||||||
5552 | - | |||||||||||||||||||||||||
5553 | /*! | - | ||||||||||||||||||||||||
5554 | \qmlproperty real QtQuick::Item::scale | - | ||||||||||||||||||||||||
5555 | This property holds the scale factor for this item. | - | ||||||||||||||||||||||||
5556 | - | |||||||||||||||||||||||||
5557 | A scale of less than 1.0 causes the item to be rendered at a smaller | - | ||||||||||||||||||||||||
5558 | size, and a scale greater than 1.0 renders the item at a larger size. | - | ||||||||||||||||||||||||
5559 | A negative scale causes the item to be mirrored when rendered. | - | ||||||||||||||||||||||||
5560 | - | |||||||||||||||||||||||||
5561 | The default value is 1.0. | - | ||||||||||||||||||||||||
5562 | - | |||||||||||||||||||||||||
5563 | Scaling is applied from the transformOrigin. | - | ||||||||||||||||||||||||
5564 | - | |||||||||||||||||||||||||
5565 | \table | - | ||||||||||||||||||||||||
5566 | \row | - | ||||||||||||||||||||||||
5567 | \li \image declarative-scale.png | - | ||||||||||||||||||||||||
5568 | \li | - | ||||||||||||||||||||||||
5569 | \qml | - | ||||||||||||||||||||||||
5570 | import QtQuick 2.0 | - | ||||||||||||||||||||||||
5571 | - | |||||||||||||||||||||||||
5572 | Rectangle { | - | ||||||||||||||||||||||||
5573 | color: "blue" | - | ||||||||||||||||||||||||
5574 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5575 | - | |||||||||||||||||||||||||
5576 | Rectangle { | - | ||||||||||||||||||||||||
5577 | color: "green" | - | ||||||||||||||||||||||||
5578 | width: 25; height: 25 | - | ||||||||||||||||||||||||
5579 | } | - | ||||||||||||||||||||||||
5580 | - | |||||||||||||||||||||||||
5581 | Rectangle { | - | ||||||||||||||||||||||||
5582 | color: "red" | - | ||||||||||||||||||||||||
5583 | x: 25; y: 25; width: 50; height: 50 | - | ||||||||||||||||||||||||
5584 | scale: 1.4 | - | ||||||||||||||||||||||||
5585 | } | - | ||||||||||||||||||||||||
5586 | } | - | ||||||||||||||||||||||||
5587 | \endqml | - | ||||||||||||||||||||||||
5588 | \endtable | - | ||||||||||||||||||||||||
5589 | - | |||||||||||||||||||||||||
5590 | \sa Transform, Scale | - | ||||||||||||||||||||||||
5591 | */ | - | ||||||||||||||||||||||||
5592 | /*! | - | ||||||||||||||||||||||||
5593 | \property QQuickItem::scale | - | ||||||||||||||||||||||||
5594 | This property holds the scale factor for this item. | - | ||||||||||||||||||||||||
5595 | - | |||||||||||||||||||||||||
5596 | A scale of less than 1.0 causes the item to be rendered at a smaller | - | ||||||||||||||||||||||||
5597 | size, and a scale greater than 1.0 renders the item at a larger size. | - | ||||||||||||||||||||||||
5598 | A negative scale causes the item to be mirrored when rendered. | - | ||||||||||||||||||||||||
5599 | - | |||||||||||||||||||||||||
5600 | The default value is 1.0. | - | ||||||||||||||||||||||||
5601 | - | |||||||||||||||||||||||||
5602 | Scaling is applied from the transformOrigin. | - | ||||||||||||||||||||||||
5603 | - | |||||||||||||||||||||||||
5604 | \table | - | ||||||||||||||||||||||||
5605 | \row | - | ||||||||||||||||||||||||
5606 | \li \image declarative-scale.png | - | ||||||||||||||||||||||||
5607 | \li | - | ||||||||||||||||||||||||
5608 | \qml | - | ||||||||||||||||||||||||
5609 | import QtQuick 2.0 | - | ||||||||||||||||||||||||
5610 | - | |||||||||||||||||||||||||
5611 | Rectangle { | - | ||||||||||||||||||||||||
5612 | color: "blue" | - | ||||||||||||||||||||||||
5613 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5614 | - | |||||||||||||||||||||||||
5615 | Rectangle { | - | ||||||||||||||||||||||||
5616 | color: "green" | - | ||||||||||||||||||||||||
5617 | width: 25; height: 25 | - | ||||||||||||||||||||||||
5618 | } | - | ||||||||||||||||||||||||
5619 | - | |||||||||||||||||||||||||
5620 | Rectangle { | - | ||||||||||||||||||||||||
5621 | color: "red" | - | ||||||||||||||||||||||||
5622 | x: 25; y: 25; width: 50; height: 50 | - | ||||||||||||||||||||||||
5623 | scale: 1.4 | - | ||||||||||||||||||||||||
5624 | } | - | ||||||||||||||||||||||||
5625 | } | - | ||||||||||||||||||||||||
5626 | \endqml | - | ||||||||||||||||||||||||
5627 | \endtable | - | ||||||||||||||||||||||||
5628 | - | |||||||||||||||||||||||||
5629 | \sa Transform, Scale | - | ||||||||||||||||||||||||
5630 | */ | - | ||||||||||||||||||||||||
5631 | qreal QQuickItem::scale() const | - | ||||||||||||||||||||||||
5632 | { | - | ||||||||||||||||||||||||
5633 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
5634 | return d->scale(); executed 558 times by 16 tests: return d->scale(); Executed by:
| 558 | ||||||||||||||||||||||||
5635 | } | - | ||||||||||||||||||||||||
5636 | - | |||||||||||||||||||||||||
5637 | void QQuickItem::setScale(qreal s) | - | ||||||||||||||||||||||||
5638 | { | - | ||||||||||||||||||||||||
5639 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
5640 | if (d->scale() == s)
| 297-1634 | ||||||||||||||||||||||||
5641 | return; executed 1634 times by 10 tests: return; Executed by:
| 1634 | ||||||||||||||||||||||||
5642 | - | |||||||||||||||||||||||||
5643 | d->extra.value().scale = s; | - | ||||||||||||||||||||||||
5644 | - | |||||||||||||||||||||||||
5645 | d->dirty(QQuickItemPrivate::BasicTransform); | - | ||||||||||||||||||||||||
5646 | - | |||||||||||||||||||||||||
5647 | emit scaleChanged(); | - | ||||||||||||||||||||||||
5648 | } executed 297 times by 14 tests: end of block Executed by:
| 297 | ||||||||||||||||||||||||
5649 | - | |||||||||||||||||||||||||
5650 | /*! | - | ||||||||||||||||||||||||
5651 | \qmlproperty real QtQuick::Item::opacity | - | ||||||||||||||||||||||||
5652 | - | |||||||||||||||||||||||||
5653 | This property holds the opacity of the item. Opacity is specified as a | - | ||||||||||||||||||||||||
5654 | number between 0.0 (fully transparent) and 1.0 (fully opaque). The default | - | ||||||||||||||||||||||||
5655 | value is 1.0. | - | ||||||||||||||||||||||||
5656 | - | |||||||||||||||||||||||||
5657 | When this property is set, the specified opacity is also applied | - | ||||||||||||||||||||||||
5658 | individually to child items. This may have an unintended effect in some | - | ||||||||||||||||||||||||
5659 | circumstances. For example in the second set of rectangles below, the red | - | ||||||||||||||||||||||||
5660 | rectangle has specified an opacity of 0.5, which affects the opacity of | - | ||||||||||||||||||||||||
5661 | its blue child rectangle even though the child has not specified an opacity. | - | ||||||||||||||||||||||||
5662 | - | |||||||||||||||||||||||||
5663 | \table | - | ||||||||||||||||||||||||
5664 | \row | - | ||||||||||||||||||||||||
5665 | \li \image declarative-item_opacity1.png | - | ||||||||||||||||||||||||
5666 | \li | - | ||||||||||||||||||||||||
5667 | \qml | - | ||||||||||||||||||||||||
5668 | Item { | - | ||||||||||||||||||||||||
5669 | Rectangle { | - | ||||||||||||||||||||||||
5670 | color: "red" | - | ||||||||||||||||||||||||
5671 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5672 | Rectangle { | - | ||||||||||||||||||||||||
5673 | color: "blue" | - | ||||||||||||||||||||||||
5674 | x: 50; y: 50; width: 100; height: 100 | - | ||||||||||||||||||||||||
5675 | } | - | ||||||||||||||||||||||||
5676 | } | - | ||||||||||||||||||||||||
5677 | } | - | ||||||||||||||||||||||||
5678 | \endqml | - | ||||||||||||||||||||||||
5679 | \row | - | ||||||||||||||||||||||||
5680 | \li \image declarative-item_opacity2.png | - | ||||||||||||||||||||||||
5681 | \li | - | ||||||||||||||||||||||||
5682 | \qml | - | ||||||||||||||||||||||||
5683 | Item { | - | ||||||||||||||||||||||||
5684 | Rectangle { | - | ||||||||||||||||||||||||
5685 | opacity: 0.5 | - | ||||||||||||||||||||||||
5686 | color: "red" | - | ||||||||||||||||||||||||
5687 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5688 | Rectangle { | - | ||||||||||||||||||||||||
5689 | color: "blue" | - | ||||||||||||||||||||||||
5690 | x: 50; y: 50; width: 100; height: 100 | - | ||||||||||||||||||||||||
5691 | } | - | ||||||||||||||||||||||||
5692 | } | - | ||||||||||||||||||||||||
5693 | } | - | ||||||||||||||||||||||||
5694 | \endqml | - | ||||||||||||||||||||||||
5695 | \endtable | - | ||||||||||||||||||||||||
5696 | - | |||||||||||||||||||||||||
5697 | Changing an item's opacity does not affect whether the item receives user | - | ||||||||||||||||||||||||
5698 | input events. (In contrast, setting \l visible property to \c false stops | - | ||||||||||||||||||||||||
5699 | mouse events, and setting the \l enabled property to \c false stops mouse | - | ||||||||||||||||||||||||
5700 | and keyboard events, and also removes active focus from the item.) | - | ||||||||||||||||||||||||
5701 | - | |||||||||||||||||||||||||
5702 | \sa visible | - | ||||||||||||||||||||||||
5703 | */ | - | ||||||||||||||||||||||||
5704 | /*! | - | ||||||||||||||||||||||||
5705 | \property QQuickItem::opacity | - | ||||||||||||||||||||||||
5706 | - | |||||||||||||||||||||||||
5707 | This property holds the opacity of the item. Opacity is specified as a | - | ||||||||||||||||||||||||
5708 | number between 0.0 (fully transparent) and 1.0 (fully opaque). The default | - | ||||||||||||||||||||||||
5709 | value is 1.0. | - | ||||||||||||||||||||||||
5710 | - | |||||||||||||||||||||||||
5711 | When this property is set, the specified opacity is also applied | - | ||||||||||||||||||||||||
5712 | individually to child items. This may have an unintended effect in some | - | ||||||||||||||||||||||||
5713 | circumstances. For example in the second set of rectangles below, the red | - | ||||||||||||||||||||||||
5714 | rectangle has specified an opacity of 0.5, which affects the opacity of | - | ||||||||||||||||||||||||
5715 | its blue child rectangle even though the child has not specified an opacity. | - | ||||||||||||||||||||||||
5716 | - | |||||||||||||||||||||||||
5717 | Values outside the range of 0 to 1 will be clamped. | - | ||||||||||||||||||||||||
5718 | - | |||||||||||||||||||||||||
5719 | \table | - | ||||||||||||||||||||||||
5720 | \row | - | ||||||||||||||||||||||||
5721 | \li \image declarative-item_opacity1.png | - | ||||||||||||||||||||||||
5722 | \li | - | ||||||||||||||||||||||||
5723 | \qml | - | ||||||||||||||||||||||||
5724 | Item { | - | ||||||||||||||||||||||||
5725 | Rectangle { | - | ||||||||||||||||||||||||
5726 | color: "red" | - | ||||||||||||||||||||||||
5727 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5728 | Rectangle { | - | ||||||||||||||||||||||||
5729 | color: "blue" | - | ||||||||||||||||||||||||
5730 | x: 50; y: 50; width: 100; height: 100 | - | ||||||||||||||||||||||||
5731 | } | - | ||||||||||||||||||||||||
5732 | } | - | ||||||||||||||||||||||||
5733 | } | - | ||||||||||||||||||||||||
5734 | \endqml | - | ||||||||||||||||||||||||
5735 | \row | - | ||||||||||||||||||||||||
5736 | \li \image declarative-item_opacity2.png | - | ||||||||||||||||||||||||
5737 | \li | - | ||||||||||||||||||||||||
5738 | \qml | - | ||||||||||||||||||||||||
5739 | Item { | - | ||||||||||||||||||||||||
5740 | Rectangle { | - | ||||||||||||||||||||||||
5741 | opacity: 0.5 | - | ||||||||||||||||||||||||
5742 | color: "red" | - | ||||||||||||||||||||||||
5743 | width: 100; height: 100 | - | ||||||||||||||||||||||||
5744 | Rectangle { | - | ||||||||||||||||||||||||
5745 | color: "blue" | - | ||||||||||||||||||||||||
5746 | x: 50; y: 50; width: 100; height: 100 | - | ||||||||||||||||||||||||
5747 | } | - | ||||||||||||||||||||||||
5748 | } | - | ||||||||||||||||||||||||
5749 | } | - | ||||||||||||||||||||||||
5750 | \endqml | - | ||||||||||||||||||||||||
5751 | \endtable | - | ||||||||||||||||||||||||
5752 | - | |||||||||||||||||||||||||
5753 | Changing an item's opacity does not affect whether the item receives user | - | ||||||||||||||||||||||||
5754 | input events. (In contrast, setting \l visible property to \c false stops | - | ||||||||||||||||||||||||
5755 | mouse events, and setting the \l enabled property to \c false stops mouse | - | ||||||||||||||||||||||||
5756 | and keyboard events, and also removes active focus from the item.) | - | ||||||||||||||||||||||||
5757 | - | |||||||||||||||||||||||||
5758 | \sa visible | - | ||||||||||||||||||||||||
5759 | */ | - | ||||||||||||||||||||||||
5760 | qreal QQuickItem::opacity() const | - | ||||||||||||||||||||||||
5761 | { | - | ||||||||||||||||||||||||
5762 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
5763 | return d->opacity(); executed 778 times by 14 tests: return d->opacity(); Executed by:
| 778 | ||||||||||||||||||||||||
5764 | } | - | ||||||||||||||||||||||||
5765 | - | |||||||||||||||||||||||||
5766 | void QQuickItem::setOpacity(qreal newOpacity) | - | ||||||||||||||||||||||||
5767 | { | - | ||||||||||||||||||||||||
5768 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
5769 | qreal o = qBound<qreal>(0, newOpacity, 1); | - | ||||||||||||||||||||||||
5770 | if (d->opacity() == o)
| 24584-38611 | ||||||||||||||||||||||||
5771 | return; executed 38611 times by 8 tests: return; Executed by:
| 38611 | ||||||||||||||||||||||||
5772 | - | |||||||||||||||||||||||||
5773 | d->extra.value().opacity = o; | - | ||||||||||||||||||||||||
5774 | - | |||||||||||||||||||||||||
5775 | d->dirty(QQuickItemPrivate::OpacityValue); | - | ||||||||||||||||||||||||
5776 | - | |||||||||||||||||||||||||
5777 | d->itemChange(ItemOpacityHasChanged, o); | - | ||||||||||||||||||||||||
5778 | - | |||||||||||||||||||||||||
5779 | emit opacityChanged(); | - | ||||||||||||||||||||||||
5780 | } executed 24584 times by 19 tests: end of block Executed by:
| 24584 | ||||||||||||||||||||||||
5781 | - | |||||||||||||||||||||||||
5782 | /*! | - | ||||||||||||||||||||||||
5783 | \qmlproperty bool QtQuick::Item::visible | - | ||||||||||||||||||||||||
5784 | - | |||||||||||||||||||||||||
5785 | This property holds whether the item is visible. By default this is true. | - | ||||||||||||||||||||||||
5786 | - | |||||||||||||||||||||||||
5787 | Setting this property directly affects the \c visible value of child | - | ||||||||||||||||||||||||
5788 | items. When set to \c false, the \c visible values of all child items also | - | ||||||||||||||||||||||||
5789 | become \c false. When set to \c true, the \c visible values of child items | - | ||||||||||||||||||||||||
5790 | are returned to \c true, unless they have explicitly been set to \c false. | - | ||||||||||||||||||||||||
5791 | - | |||||||||||||||||||||||||
5792 | (Because of this flow-on behavior, using the \c visible property may not | - | ||||||||||||||||||||||||
5793 | have the intended effect if a property binding should only respond to | - | ||||||||||||||||||||||||
5794 | explicit property changes. In such cases it may be better to use the | - | ||||||||||||||||||||||||
5795 | \l opacity property instead.) | - | ||||||||||||||||||||||||
5796 | - | |||||||||||||||||||||||||
5797 | If this property is set to \c false, the item will no longer receive mouse | - | ||||||||||||||||||||||||
5798 | events, but will continue to receive key events and will retain the keyboard | - | ||||||||||||||||||||||||
5799 | \l focus if it has been set. (In contrast, setting the \l enabled property | - | ||||||||||||||||||||||||
5800 | to \c false stops both mouse and keyboard events, and also removes focus | - | ||||||||||||||||||||||||
5801 | from the item.) | - | ||||||||||||||||||||||||
5802 | - | |||||||||||||||||||||||||
5803 | \note This property's value is only affected by changes to this property or | - | ||||||||||||||||||||||||
5804 | the parent's \c visible property. It does not change, for example, if this | - | ||||||||||||||||||||||||
5805 | item moves off-screen, or if the \l opacity changes to 0. | - | ||||||||||||||||||||||||
5806 | - | |||||||||||||||||||||||||
5807 | \sa opacity, enabled | - | ||||||||||||||||||||||||
5808 | */ | - | ||||||||||||||||||||||||
5809 | /*! | - | ||||||||||||||||||||||||
5810 | \property QQuickItem::visible | - | ||||||||||||||||||||||||
5811 | - | |||||||||||||||||||||||||
5812 | This property holds whether the item is visible. By default this is true. | - | ||||||||||||||||||||||||
5813 | - | |||||||||||||||||||||||||
5814 | Setting this property directly affects the \c visible value of child | - | ||||||||||||||||||||||||
5815 | items. When set to \c false, the \c visible values of all child items also | - | ||||||||||||||||||||||||
5816 | become \c false. When set to \c true, the \c visible values of child items | - | ||||||||||||||||||||||||
5817 | are returned to \c true, unless they have explicitly been set to \c false. | - | ||||||||||||||||||||||||
5818 | - | |||||||||||||||||||||||||
5819 | (Because of this flow-on behavior, using the \c visible property may not | - | ||||||||||||||||||||||||
5820 | have the intended effect if a property binding should only respond to | - | ||||||||||||||||||||||||
5821 | explicit property changes. In such cases it may be better to use the | - | ||||||||||||||||||||||||
5822 | \l opacity property instead.) | - | ||||||||||||||||||||||||
5823 | - | |||||||||||||||||||||||||
5824 | If this property is set to \c false, the item will no longer receive mouse | - | ||||||||||||||||||||||||
5825 | events, but will continue to receive key events and will retain the keyboard | - | ||||||||||||||||||||||||
5826 | \l focus if it has been set. (In contrast, setting the \l enabled property | - | ||||||||||||||||||||||||
5827 | to \c false stops both mouse and keyboard events, and also removes focus | - | ||||||||||||||||||||||||
5828 | from the item.) | - | ||||||||||||||||||||||||
5829 | - | |||||||||||||||||||||||||
5830 | \note This property's value is only affected by changes to this property or | - | ||||||||||||||||||||||||
5831 | the parent's \c visible property. It does not change, for example, if this | - | ||||||||||||||||||||||||
5832 | item moves off-screen, or if the \l opacity changes to 0. | - | ||||||||||||||||||||||||
5833 | - | |||||||||||||||||||||||||
5834 | \sa opacity, enabled | - | ||||||||||||||||||||||||
5835 | */ | - | ||||||||||||||||||||||||
5836 | bool QQuickItem::isVisible() const | - | ||||||||||||||||||||||||
5837 | { | - | ||||||||||||||||||||||||
5838 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
5839 | return d->effectiveVisible; executed 1527890 times by 107 tests: return d->effectiveVisible; Executed by:
| 1527890 | ||||||||||||||||||||||||
5840 | } | - | ||||||||||||||||||||||||
5841 | - | |||||||||||||||||||||||||
5842 | void QQuickItemPrivate::setVisible(bool visible) | - | ||||||||||||||||||||||||
5843 | { | - | ||||||||||||||||||||||||
5844 | if (visible == explicitVisible)
| 8766-55369 | ||||||||||||||||||||||||
5845 | return; executed 55369 times by 13 tests: return; Executed by:
| 55369 | ||||||||||||||||||||||||
5846 | - | |||||||||||||||||||||||||
5847 | explicitVisible = visible; | - | ||||||||||||||||||||||||
5848 | if (!visible)
| 3307-5459 | ||||||||||||||||||||||||
5849 | dirty(QQuickItemPrivate::Visible); executed 5459 times by 33 tests: dirty(QQuickItemPrivate::Visible); Executed by:
| 5459 | ||||||||||||||||||||||||
5850 | - | |||||||||||||||||||||||||
5851 | const bool childVisibilityChanged = setEffectiveVisibleRecur(calcEffectiveVisible()); | - | ||||||||||||||||||||||||
5852 | if (childVisibilityChanged && parentItem)
| 6-8760 | ||||||||||||||||||||||||
5853 | emit parentItem->visibleChildrenChanged(); // signal the parent, not this! executed 8262 times by 18 tests: parentItem->visibleChildrenChanged(); Executed by:
| 8262 | ||||||||||||||||||||||||
5854 | } executed 8766 times by 33 tests: end of block Executed by:
| 8766 | ||||||||||||||||||||||||
5855 | - | |||||||||||||||||||||||||
5856 | void QQuickItem::setVisible(bool v) | - | ||||||||||||||||||||||||
5857 | { | - | ||||||||||||||||||||||||
5858 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
5859 | d->setVisible(v); | - | ||||||||||||||||||||||||
5860 | } executed 64135 times by 34 tests: end of block Executed by:
| 64135 | ||||||||||||||||||||||||
5861 | - | |||||||||||||||||||||||||
5862 | /*! | - | ||||||||||||||||||||||||
5863 | \qmlproperty bool QtQuick::Item::enabled | - | ||||||||||||||||||||||||
5864 | - | |||||||||||||||||||||||||
5865 | This property holds whether the item receives mouse and keyboard events. | - | ||||||||||||||||||||||||
5866 | By default this is true. | - | ||||||||||||||||||||||||
5867 | - | |||||||||||||||||||||||||
5868 | Setting this property directly affects the \c enabled value of child | - | ||||||||||||||||||||||||
5869 | items. When set to \c false, the \c enabled values of all child items also | - | ||||||||||||||||||||||||
5870 | become \c false. When set to \c true, the \c enabled values of child items | - | ||||||||||||||||||||||||
5871 | are returned to \c true, unless they have explicitly been set to \c false. | - | ||||||||||||||||||||||||
5872 | - | |||||||||||||||||||||||||
5873 | Setting this property to \c false automatically causes \l activeFocus to be | - | ||||||||||||||||||||||||
5874 | set to \c false, and this item will no longer receive keyboard events. | - | ||||||||||||||||||||||||
5875 | - | |||||||||||||||||||||||||
5876 | \sa visible | - | ||||||||||||||||||||||||
5877 | */ | - | ||||||||||||||||||||||||
5878 | /*! | - | ||||||||||||||||||||||||
5879 | \property QQuickItem::enabled | - | ||||||||||||||||||||||||
5880 | - | |||||||||||||||||||||||||
5881 | This property holds whether the item receives mouse and keyboard events. | - | ||||||||||||||||||||||||
5882 | By default this is true. | - | ||||||||||||||||||||||||
5883 | - | |||||||||||||||||||||||||
5884 | Setting this property directly affects the \c enabled value of child | - | ||||||||||||||||||||||||
5885 | items. When set to \c false, the \c enabled values of all child items also | - | ||||||||||||||||||||||||
5886 | become \c false. When set to \c true, the \c enabled values of child items | - | ||||||||||||||||||||||||
5887 | are returned to \c true, unless they have explicitly been set to \c false. | - | ||||||||||||||||||||||||
5888 | - | |||||||||||||||||||||||||
5889 | Setting this property to \c false automatically causes \l activeFocus to be | - | ||||||||||||||||||||||||
5890 | set to \c false, and this item will longer receive keyboard events. | - | ||||||||||||||||||||||||
5891 | - | |||||||||||||||||||||||||
5892 | \sa visible | - | ||||||||||||||||||||||||
5893 | */ | - | ||||||||||||||||||||||||
5894 | bool QQuickItem::isEnabled() const | - | ||||||||||||||||||||||||
5895 | { | - | ||||||||||||||||||||||||
5896 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
5897 | return d->effectiveEnable; executed 64589 times by 34 tests: return d->effectiveEnable; Executed by:
| 64589 | ||||||||||||||||||||||||
5898 | } | - | ||||||||||||||||||||||||
5899 | - | |||||||||||||||||||||||||
5900 | void QQuickItem::setEnabled(bool e) | - | ||||||||||||||||||||||||
5901 | { | - | ||||||||||||||||||||||||
5902 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
5903 | if (e == d->explicitEnable)
| 16-298 | ||||||||||||||||||||||||
5904 | return; executed 16 times by 3 tests: return; Executed by:
| 16 | ||||||||||||||||||||||||
5905 | - | |||||||||||||||||||||||||
5906 | d->explicitEnable = e; | - | ||||||||||||||||||||||||
5907 | - | |||||||||||||||||||||||||
5908 | QQuickItem *scope = parentItem(); | - | ||||||||||||||||||||||||
5909 | while (scope && !scope->isFocusScope())
| 46-252 | ||||||||||||||||||||||||
5910 | scope = scope->parentItem(); executed 54 times by 3 tests: scope = scope->parentItem(); Executed by:
| 54 | ||||||||||||||||||||||||
5911 | - | |||||||||||||||||||||||||
5912 | d->setEffectiveEnableRecur(scope, d->calcEffectiveEnable()); | - | ||||||||||||||||||||||||
5913 | } executed 298 times by 9 tests: end of block Executed by:
| 298 | ||||||||||||||||||||||||
5914 | - | |||||||||||||||||||||||||
5915 | bool QQuickItemPrivate::calcEffectiveVisible() const | - | ||||||||||||||||||||||||
5916 | { | - | ||||||||||||||||||||||||
5917 | // XXX todo - Should the effective visible of an element with no parent just be the current | - | ||||||||||||||||||||||||
5918 | // effective visible? This would prevent pointless re-processing in the case of an element | - | ||||||||||||||||||||||||
5919 | // moving to/from a no-parent situation, but it is different from what graphics view does. | - | ||||||||||||||||||||||||
5920 | return explicitVisible && (!parentItem || QQuickItemPrivate::get(parentItem)->effectiveVisible); executed 825796 times by 106 tests: return explicitVisible && (!parentItem || QQuickItemPrivate::get(parentItem)->effectiveVisible); Executed by:
| 825796 | ||||||||||||||||||||||||
5921 | } | - | ||||||||||||||||||||||||
5922 | - | |||||||||||||||||||||||||
5923 | bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible) | - | ||||||||||||||||||||||||
5924 | { | - | ||||||||||||||||||||||||
5925 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
5926 | - | |||||||||||||||||||||||||
5927 | if (newEffectiveVisible && !explicitVisible) {
| 12-819466 | ||||||||||||||||||||||||
5928 | // This item locally overrides visibility | - | ||||||||||||||||||||||||
5929 | return false; // effective visibility didn't change executed 12 times by 2 tests: return false; Executed by:
| 12 | ||||||||||||||||||||||||
5930 | } | - | ||||||||||||||||||||||||
5931 | - | |||||||||||||||||||||||||
5932 | if (newEffectiveVisible == effectiveVisible) {
| 12722-816483 | ||||||||||||||||||||||||
5933 | // No change necessary | - | ||||||||||||||||||||||||
5934 | return false; // effective visibility didn't change executed 816483 times by 106 tests: return false; Executed by:
| 816483 | ||||||||||||||||||||||||
5935 | } | - | ||||||||||||||||||||||||
5936 | - | |||||||||||||||||||||||||
5937 | effectiveVisible = newEffectiveVisible; | - | ||||||||||||||||||||||||
5938 | dirty(Visible); | - | ||||||||||||||||||||||||
5939 | if (parentItem) QQuickItemPrivate::get(parentItem)->dirty(ChildrenStackingChanged); executed 11693 times by 24 tests: QQuickItemPrivate::get(parentItem)->dirty(ChildrenStackingChanged); Executed by:
| 1029-11693 | ||||||||||||||||||||||||
5940 | - | |||||||||||||||||||||||||
5941 | if (window) {
| 4448-8274 | ||||||||||||||||||||||||
5942 | QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window); | - | ||||||||||||||||||||||||
5943 | windowPriv->removeGrabber(q); | - | ||||||||||||||||||||||||
5944 | } executed 8274 times by 17 tests: end of block Executed by:
| 8274 | ||||||||||||||||||||||||
5945 | - | |||||||||||||||||||||||||
5946 | bool childVisibilityChanged = false; | - | ||||||||||||||||||||||||
5947 | for (int ii = 0; ii < childItems.count(); ++ii)
| 3421-12722 | ||||||||||||||||||||||||
5948 | childVisibilityChanged |= QQuickItemPrivate::get(childItems.at(ii))->setEffectiveVisibleRecur(newEffectiveVisible); executed 3421 times by 16 tests: childVisibilityChanged |= QQuickItemPrivate::get(childItems.at(ii))->setEffectiveVisibleRecur(newEffectiveVisible); Executed by:
| 3421 | ||||||||||||||||||||||||
5949 | - | |||||||||||||||||||||||||
5950 | itemChange(QQuickItem::ItemVisibleHasChanged, effectiveVisible); | - | ||||||||||||||||||||||||
5951 | #if QT_CONFIG(accessibility) | - | ||||||||||||||||||||||||
5952 | if (isAccessible) {
| 0-12722 | ||||||||||||||||||||||||
5953 | QAccessibleEvent ev(q, effectiveVisible ? QAccessible::ObjectShow : QAccessible::ObjectHide); | - | ||||||||||||||||||||||||
5954 | QAccessible::updateAccessibility(&ev); | - | ||||||||||||||||||||||||
5955 | } never executed: end of block | 0 | ||||||||||||||||||||||||
5956 | #endif | - | ||||||||||||||||||||||||
5957 | emit q->visibleChanged(); | - | ||||||||||||||||||||||||
5958 | if (childVisibilityChanged)
| 977-11745 | ||||||||||||||||||||||||
5959 | emit q->visibleChildrenChanged(); executed 977 times by 16 tests: q->visibleChildrenChanged(); Executed by:
| 977 | ||||||||||||||||||||||||
5960 | - | |||||||||||||||||||||||||
5961 | return true; // effective visibility DID change executed 12722 times by 33 tests: return true; Executed by:
| 12722 | ||||||||||||||||||||||||
5962 | } | - | ||||||||||||||||||||||||
5963 | - | |||||||||||||||||||||||||
5964 | bool QQuickItemPrivate::calcEffectiveEnable() const | - | ||||||||||||||||||||||||
5965 | { | - | ||||||||||||||||||||||||
5966 | // XXX todo - Should the effective enable of an element with no parent just be the current | - | ||||||||||||||||||||||||
5967 | // effective enable? This would prevent pointless re-processing in the case of an element | - | ||||||||||||||||||||||||
5968 | // moving to/from a no-parent situation, but it is different from what graphics view does. | - | ||||||||||||||||||||||||
5969 | return explicitEnable && (!parentItem || QQuickItemPrivate::get(parentItem)->effectiveEnable); executed 817328 times by 106 tests: return explicitEnable && (!parentItem || QQuickItemPrivate::get(parentItem)->effectiveEnable); Executed by:
| 817328 | ||||||||||||||||||||||||
5970 | } | - | ||||||||||||||||||||||||
5971 | - | |||||||||||||||||||||||||
5972 | void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffectiveEnable) | - | ||||||||||||||||||||||||
5973 | { | - | ||||||||||||||||||||||||
5974 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
5975 | - | |||||||||||||||||||||||||
5976 | if (newEffectiveEnable && !explicitEnable) {
| 2-816600 | ||||||||||||||||||||||||
5977 | // This item locally overrides enable | - | ||||||||||||||||||||||||
5978 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
5979 | } | - | ||||||||||||||||||||||||
5980 | - | |||||||||||||||||||||||||
5981 | if (newEffectiveEnable == effectiveEnable) {
| 390-816998 | ||||||||||||||||||||||||
5982 | // No change necessary | - | ||||||||||||||||||||||||
5983 | return; executed 816998 times by 106 tests: return; Executed by:
| 816998 | ||||||||||||||||||||||||
5984 | } | - | ||||||||||||||||||||||||
5985 | - | |||||||||||||||||||||||||
5986 | effectiveEnable = newEffectiveEnable; | - | ||||||||||||||||||||||||
5987 | - | |||||||||||||||||||||||||
5988 | if (window) {
| 62-328 | ||||||||||||||||||||||||
5989 | QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window); | - | ||||||||||||||||||||||||
5990 | windowPriv->removeGrabber(q); | - | ||||||||||||||||||||||||
5991 | if (scope && !effectiveEnable && activeFocus) {
| 0-62 | ||||||||||||||||||||||||
5992 | windowPriv->clearFocusInScope( | - | ||||||||||||||||||||||||
5993 | scope, q, Qt::OtherFocusReason, QQuickWindowPrivate::DontChangeFocusProperty | QQuickWindowPrivate::DontChangeSubFocusItem); | - | ||||||||||||||||||||||||
5994 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
5995 | } executed 62 times by 4 tests: end of block Executed by:
| 62 | ||||||||||||||||||||||||
5996 | - | |||||||||||||||||||||||||
5997 | for (int ii = 0; ii < childItems.count(); ++ii) {
| 62-390 | ||||||||||||||||||||||||
5998 | QQuickItemPrivate::get(childItems.at(ii))->setEffectiveEnableRecur( | - | ||||||||||||||||||||||||
5999 | (flags & QQuickItem::ItemIsFocusScope) && scope ? q : scope, newEffectiveEnable); | - | ||||||||||||||||||||||||
6000 | } executed 62 times by 4 tests: end of block Executed by:
| 62 | ||||||||||||||||||||||||
6001 | - | |||||||||||||||||||||||||
6002 | if (window && scope && effectiveEnable && focus) {
| 0-328 | ||||||||||||||||||||||||
6003 | QQuickWindowPrivate::get(window)->setFocusInScope( | - | ||||||||||||||||||||||||
6004 | scope, q, Qt::OtherFocusReason, QQuickWindowPrivate::DontChangeFocusProperty | QQuickWindowPrivate::DontChangeSubFocusItem); | - | ||||||||||||||||||||||||
6005 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
6006 | - | |||||||||||||||||||||||||
6007 | itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable); | - | ||||||||||||||||||||||||
6008 | emit q->enabledChanged(); | - | ||||||||||||||||||||||||
6009 | } executed 390 times by 9 tests: end of block Executed by:
| 390 | ||||||||||||||||||||||||
6010 | - | |||||||||||||||||||||||||
6011 | bool QQuickItemPrivate::isTransparentForPositioner() const | - | ||||||||||||||||||||||||
6012 | { | - | ||||||||||||||||||||||||
6013 | return extra.isAllocated() && extra.value().transparentForPositioner; executed 122585 times by 23 tests: return extra.isAllocated() && extra.value().transparentForPositioner; Executed by:
| 122585 | ||||||||||||||||||||||||
6014 | } | - | ||||||||||||||||||||||||
6015 | - | |||||||||||||||||||||||||
6016 | void QQuickItemPrivate::setTransparentForPositioner(bool transparent) | - | ||||||||||||||||||||||||
6017 | { | - | ||||||||||||||||||||||||
6018 | extra.value().transparentForPositioner = transparent; | - | ||||||||||||||||||||||||
6019 | } executed 1634 times by 17 tests: end of block Executed by:
| 1634 | ||||||||||||||||||||||||
6020 | - | |||||||||||||||||||||||||
6021 | - | |||||||||||||||||||||||||
6022 | QString QQuickItemPrivate::dirtyToString() const | - | ||||||||||||||||||||||||
6023 | { | - | ||||||||||||||||||||||||
6024 | #define DIRTY_TO_STRING(value) if (dirtyAttributes & value) { \ | - | ||||||||||||||||||||||||
6025 | if (!rv.isEmpty()) \ | - | ||||||||||||||||||||||||
6026 | rv.append(QLatin1Char('|')); \ | - | ||||||||||||||||||||||||
6027 | rv.append(QLatin1String(#value)); \ | - | ||||||||||||||||||||||||
6028 | } | - | ||||||||||||||||||||||||
6029 | - | |||||||||||||||||||||||||
6030 | // QString rv = QLatin1String("0x") + QString::number(dirtyAttributes, 16); | - | ||||||||||||||||||||||||
6031 | QString rv; | - | ||||||||||||||||||||||||
6032 | - | |||||||||||||||||||||||||
6033 | DIRTY_TO_STRING(TransformOrigin); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6034 | DIRTY_TO_STRING(Transform); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6035 | DIRTY_TO_STRING(BasicTransform); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6036 | DIRTY_TO_STRING(Position); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6037 | DIRTY_TO_STRING(Size); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6038 | DIRTY_TO_STRING(ZValue); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6039 | DIRTY_TO_STRING(Content); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6040 | DIRTY_TO_STRING(Smooth); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6041 | DIRTY_TO_STRING(OpacityValue); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6042 | DIRTY_TO_STRING(ChildrenChanged); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6043 | DIRTY_TO_STRING(ChildrenStackingChanged); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6044 | DIRTY_TO_STRING(ParentChanged); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6045 | DIRTY_TO_STRING(Clip); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6046 | DIRTY_TO_STRING(Window); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6047 | DIRTY_TO_STRING(EffectReference); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6048 | DIRTY_TO_STRING(Visible); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6049 | DIRTY_TO_STRING(HideReference); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6050 | DIRTY_TO_STRING(Antialiasing); never executed: rv.append(QLatin1Char('|')); never executed: end of block
| 0 | ||||||||||||||||||||||||
6051 | - | |||||||||||||||||||||||||
6052 | return rv; never executed: return rv; | 0 | ||||||||||||||||||||||||
6053 | } | - | ||||||||||||||||||||||||
6054 | - | |||||||||||||||||||||||||
6055 | void QQuickItemPrivate::dirty(DirtyType type) | - | ||||||||||||||||||||||||
6056 | { | - | ||||||||||||||||||||||||
6057 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
6058 | if (type & (TransformOrigin | Transform | BasicTransform | Position | Size))
| 1212383-3533792 | ||||||||||||||||||||||||
6059 | transformChanged(); executed 1212383 times by 102 tests: transformChanged(); Executed by:
| 1212383 | ||||||||||||||||||||||||
6060 | - | |||||||||||||||||||||||||
6061 | if (!(dirtyAttributes & type) || (window && !prevDirtyItem)) {
| 11896-3241727 | ||||||||||||||||||||||||
6062 | dirtyAttributes |= type; | - | ||||||||||||||||||||||||
6063 | if (window && componentComplete) {
| 255234-2119366 | ||||||||||||||||||||||||
6064 | addToDirtyList(); | - | ||||||||||||||||||||||||
6065 | QQuickWindowPrivate::get(window)->dirtyItem(q); | - | ||||||||||||||||||||||||
6066 | } executed 879023 times by 90 tests: end of block Executed by:
| 879023 | ||||||||||||||||||||||||
6067 | } executed 3253623 times by 112 tests: end of block Executed by:
| 3253623 | ||||||||||||||||||||||||
6068 | } executed 4746175 times by 112 tests: end of block Executed by:
| 4746175 | ||||||||||||||||||||||||
6069 | - | |||||||||||||||||||||||||
6070 | void QQuickItemPrivate::addToDirtyList() | - | ||||||||||||||||||||||||
6071 | { | - | ||||||||||||||||||||||||
6072 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
6073 | - | |||||||||||||||||||||||||
6074 | Q_ASSERT(window); | - | ||||||||||||||||||||||||
6075 | if (!prevDirtyItem) {
| 362691-671169 | ||||||||||||||||||||||||
6076 | Q_ASSERT(!nextDirtyItem); | - | ||||||||||||||||||||||||
6077 | - | |||||||||||||||||||||||||
6078 | QQuickWindowPrivate *p = QQuickWindowPrivate::get(window); | - | ||||||||||||||||||||||||
6079 | nextDirtyItem = p->dirtyItemList; | - | ||||||||||||||||||||||||
6080 | if (nextDirtyItem) QQuickItemPrivate::get(nextDirtyItem)->prevDirtyItem = &nextDirtyItem; executed 623091 times by 90 tests: QQuickItemPrivate::get(nextDirtyItem)->prevDirtyItem = &nextDirtyItem; Executed by:
| 48078-623091 | ||||||||||||||||||||||||
6081 | prevDirtyItem = &p->dirtyItemList; | - | ||||||||||||||||||||||||
6082 | p->dirtyItemList = q; | - | ||||||||||||||||||||||||
6083 | p->dirtyItem(q); | - | ||||||||||||||||||||||||
6084 | } executed 671169 times by 90 tests: end of block Executed by:
| 671169 | ||||||||||||||||||||||||
6085 | Q_ASSERT(prevDirtyItem); | - | ||||||||||||||||||||||||
6086 | } executed 1033860 times by 90 tests: end of block Executed by:
| 1033860 | ||||||||||||||||||||||||
6087 | - | |||||||||||||||||||||||||
6088 | void QQuickItemPrivate::removeFromDirtyList() | - | ||||||||||||||||||||||||
6089 | { | - | ||||||||||||||||||||||||
6090 | if (prevDirtyItem) {
| 671021-1100696 | ||||||||||||||||||||||||
6091 | if (nextDirtyItem) QQuickItemPrivate::get(nextDirtyItem)->prevDirtyItem = prevDirtyItem; executed 596872 times by 84 tests: QQuickItemPrivate::get(nextDirtyItem)->prevDirtyItem = prevDirtyItem; Executed by:
| 74149-596872 | ||||||||||||||||||||||||
6092 | *prevDirtyItem = nextDirtyItem; | - | ||||||||||||||||||||||||
6093 | prevDirtyItem = nullptr; | - | ||||||||||||||||||||||||
6094 | nextDirtyItem = nullptr; | - | ||||||||||||||||||||||||
6095 | } executed 671021 times by 90 tests: end of block Executed by:
| 671021 | ||||||||||||||||||||||||
6096 | Q_ASSERT(!prevDirtyItem); | - | ||||||||||||||||||||||||
6097 | Q_ASSERT(!nextDirtyItem); | - | ||||||||||||||||||||||||
6098 | } executed 1771717 times by 106 tests: end of block Executed by:
| 1771717 | ||||||||||||||||||||||||
6099 | - | |||||||||||||||||||||||||
6100 | void QQuickItemPrivate::refFromEffectItem(bool hide) | - | ||||||||||||||||||||||||
6101 | { | - | ||||||||||||||||||||||||
6102 | ++extra.value().effectRefCount; | - | ||||||||||||||||||||||||
6103 | if (extra->effectRefCount == 1) {
| 94-112 | ||||||||||||||||||||||||
6104 | dirty(EffectReference); | - | ||||||||||||||||||||||||
6105 | if (parentItem)
| 14-98 | ||||||||||||||||||||||||
6106 | QQuickItemPrivate::get(parentItem)->dirty(ChildrenStackingChanged); executed 98 times by 4 tests: QQuickItemPrivate::get(parentItem)->dirty(ChildrenStackingChanged); Executed by:
| 98 | ||||||||||||||||||||||||
6107 | } executed 112 times by 6 tests: end of block Executed by:
| 112 | ||||||||||||||||||||||||
6108 | if (hide) {
| 96-110 | ||||||||||||||||||||||||
6109 | if (++extra->hideRefCount == 1)
| 0-96 | ||||||||||||||||||||||||
6110 | dirty(HideReference); executed 96 times by 4 tests: dirty(HideReference); Executed by:
| 96 | ||||||||||||||||||||||||
6111 | } executed 96 times by 4 tests: end of block Executed by:
| 96 | ||||||||||||||||||||||||
6112 | recursiveRefFromEffectItem(1); | - | ||||||||||||||||||||||||
6113 | } executed 206 times by 6 tests: end of block Executed by:
| 206 | ||||||||||||||||||||||||
6114 | - | |||||||||||||||||||||||||
6115 | void QQuickItemPrivate::recursiveRefFromEffectItem(int refs) | - | ||||||||||||||||||||||||
6116 | { | - | ||||||||||||||||||||||||
6117 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
6118 | if (!refs)
| 4130-816976 | ||||||||||||||||||||||||
6119 | return; executed 816976 times by 106 tests: return; Executed by:
| 816976 | ||||||||||||||||||||||||
6120 | extra.value().recursiveEffectRefCount += refs; | - | ||||||||||||||||||||||||
6121 | for (int ii = 0; ii < childItems.count(); ++ii) {
| 3182-4130 | ||||||||||||||||||||||||
6122 | QQuickItem *child = childItems.at(ii); | - | ||||||||||||||||||||||||
6123 | QQuickItemPrivate::get(child)->recursiveRefFromEffectItem(refs); | - | ||||||||||||||||||||||||
6124 | } executed 3182 times by 4 tests: end of block Executed by:
| 3182 | ||||||||||||||||||||||||
6125 | // Polish may rely on the effect ref count so trigger one, if item is not visible | - | ||||||||||||||||||||||||
6126 | // (if visible, it will be triggered automatically). | - | ||||||||||||||||||||||||
6127 | if (!effectiveVisible && refs > 0 && extra.value().recursiveEffectRefCount == 1) // it wasn't referenced, now it's referenced
| 6-4082 | ||||||||||||||||||||||||
6128 | q->polish(); executed 6 times by 2 tests: q->polish(); Executed by:
| 6 | ||||||||||||||||||||||||
6129 | } executed 4130 times by 6 tests: end of block Executed by:
| 4130 | ||||||||||||||||||||||||
6130 | - | |||||||||||||||||||||||||
6131 | void QQuickItemPrivate::derefFromEffectItem(bool unhide) | - | ||||||||||||||||||||||||
6132 | { | - | ||||||||||||||||||||||||
6133 | Q_ASSERT(extra->effectRefCount); | - | ||||||||||||||||||||||||
6134 | --extra->effectRefCount; | - | ||||||||||||||||||||||||
6135 | if (extra->effectRefCount == 0) {
| 90-98 | ||||||||||||||||||||||||
6136 | dirty(EffectReference); | - | ||||||||||||||||||||||||
6137 | if (parentItem)
| 4-94 | ||||||||||||||||||||||||
6138 | QQuickItemPrivate::get(parentItem)->dirty(ChildrenStackingChanged); executed 4 times by 1 test: QQuickItemPrivate::get(parentItem)->dirty(ChildrenStackingChanged); Executed by:
| 4 | ||||||||||||||||||||||||
6139 | } executed 98 times by 4 tests: end of block Executed by:
| 98 | ||||||||||||||||||||||||
6140 | if (unhide) {
| 94 | ||||||||||||||||||||||||
6141 | if (--extra->hideRefCount == 0)
| 0-94 | ||||||||||||||||||||||||
6142 | dirty(HideReference); executed 94 times by 4 tests: dirty(HideReference); Executed by:
| 94 | ||||||||||||||||||||||||
6143 | } executed 94 times by 4 tests: end of block Executed by:
| 94 | ||||||||||||||||||||||||
6144 | recursiveRefFromEffectItem(-1); | - | ||||||||||||||||||||||||
6145 | } executed 188 times by 4 tests: end of block Executed by:
| 188 | ||||||||||||||||||||||||
6146 | - | |||||||||||||||||||||||||
6147 | void QQuickItemPrivate::setCulled(bool cull) | - | ||||||||||||||||||||||||
6148 | { | - | ||||||||||||||||||||||||
6149 | if (cull == culled)
| 218914-396679 | ||||||||||||||||||||||||
6150 | return; executed 396679 times by 11 tests: return; Executed by:
| 396679 | ||||||||||||||||||||||||
6151 | - | |||||||||||||||||||||||||
6152 | culled = cull; | - | ||||||||||||||||||||||||
6153 | if ((cull && ++extra.value().hideRefCount == 1) || (!cull && --extra.value().hideRefCount == 0))
| 0-138291 | ||||||||||||||||||||||||
6154 | dirty(HideReference); executed 218914 times by 12 tests: dirty(HideReference); Executed by:
| 218914 | ||||||||||||||||||||||||
6155 | } executed 218914 times by 12 tests: end of block Executed by:
| 218914 | ||||||||||||||||||||||||
6156 | - | |||||||||||||||||||||||||
6157 | void QQuickItemPrivate::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) | - | ||||||||||||||||||||||||
6158 | { | - | ||||||||||||||||||||||||
6159 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
6160 | switch (change) { | - | ||||||||||||||||||||||||
6161 | case QQuickItem::ItemChildAddedChange: { executed 408954 times by 106 tests: case QQuickItem::ItemChildAddedChange: Executed by:
| 408954 | ||||||||||||||||||||||||
6162 | q->itemChange(change, data); | - | ||||||||||||||||||||||||
6163 | if (!changeListeners.isEmpty()) {
| 86632-322322 | ||||||||||||||||||||||||
6164 | const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732) | - | ||||||||||||||||||||||||
6165 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { | - | ||||||||||||||||||||||||
6166 | if (change.types & QQuickItemPrivate::Children) {
| 26-89688 | ||||||||||||||||||||||||
6167 | change.listener->itemChildAdded(q, data.item); | - | ||||||||||||||||||||||||
6168 | } executed 26 times by 1 test: end of block Executed by:
| 26 | ||||||||||||||||||||||||
6169 | } executed 89714 times by 30 tests: end of block Executed by:
| 89714 | ||||||||||||||||||||||||
6170 | } executed 86632 times by 30 tests: end of block Executed by:
| 86632 | ||||||||||||||||||||||||
6171 | break; executed 408954 times by 106 tests: break; Executed by:
| 408954 | ||||||||||||||||||||||||
6172 | } | - | ||||||||||||||||||||||||
6173 | case QQuickItem::ItemChildRemovedChange: { executed 408576 times by 106 tests: case QQuickItem::ItemChildRemovedChange: Executed by:
| 408576 | ||||||||||||||||||||||||
6174 | q->itemChange(change, data); | - | ||||||||||||||||||||||||
6175 | if (!changeListeners.isEmpty()) {
| 115361-293215 | ||||||||||||||||||||||||
6176 | const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732) | - | ||||||||||||||||||||||||
6177 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { | - | ||||||||||||||||||||||||
6178 | if (change.types & QQuickItemPrivate::Children) {
| 114-134721 | ||||||||||||||||||||||||
6179 | change.listener->itemChildRemoved(q, data.item); | - | ||||||||||||||||||||||||
6180 | } executed 114 times by 3 tests: end of block Executed by:
| 114 | ||||||||||||||||||||||||
6181 | } executed 134835 times by 83 tests: end of block Executed by:
| 134835 | ||||||||||||||||||||||||
6182 | } executed 115361 times by 83 tests: end of block Executed by:
| 115361 | ||||||||||||||||||||||||
6183 | break; executed 408576 times by 106 tests: break; Executed by:
| 408576 | ||||||||||||||||||||||||
6184 | } | - | ||||||||||||||||||||||||
6185 | case QQuickItem::ItemSceneChange: executed 806842 times by 90 tests: case QQuickItem::ItemSceneChange: Executed by:
| 806842 | ||||||||||||||||||||||||
6186 | q->itemChange(change, data); | - | ||||||||||||||||||||||||
6187 | break; executed 806842 times by 90 tests: break; Executed by:
| 806842 | ||||||||||||||||||||||||
6188 | case QQuickItem::ItemVisibleHasChanged: { executed 12722 times by 33 tests: case QQuickItem::ItemVisibleHasChanged: Executed by:
| 12722 | ||||||||||||||||||||||||
6189 | q->itemChange(change, data); | - | ||||||||||||||||||||||||
6190 | if (!changeListeners.isEmpty()) {
| 590-12132 | ||||||||||||||||||||||||
6191 | const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732) | - | ||||||||||||||||||||||||
6192 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { | - | ||||||||||||||||||||||||
6193 | if (change.types & QQuickItemPrivate::Visibility) {
| 178-666 | ||||||||||||||||||||||||
6194 | change.listener->itemVisibilityChanged(q); | - | ||||||||||||||||||||||||
6195 | } executed 178 times by 7 tests: end of block Executed by:
| 178 | ||||||||||||||||||||||||
6196 | } executed 844 times by 15 tests: end of block Executed by:
| 844 | ||||||||||||||||||||||||
6197 | } executed 590 times by 15 tests: end of block Executed by:
| 590 | ||||||||||||||||||||||||
6198 | break; executed 12722 times by 33 tests: break; Executed by:
| 12722 | ||||||||||||||||||||||||
6199 | } | - | ||||||||||||||||||||||||
6200 | case QQuickItem::ItemEnabledHasChanged: { executed 390 times by 9 tests: case QQuickItem::ItemEnabledHasChanged: Executed by:
| 390 | ||||||||||||||||||||||||
6201 | q->itemChange(change, data); | - | ||||||||||||||||||||||||
6202 | if (!changeListeners.isEmpty()) {
| 20-370 | ||||||||||||||||||||||||
6203 | const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732) | - | ||||||||||||||||||||||||
6204 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { | - | ||||||||||||||||||||||||
6205 | if (change.types & QQuickItemPrivate::Enabled) {
| 0-32 | ||||||||||||||||||||||||
6206 | change.listener->itemEnabledChanged(q); | - | ||||||||||||||||||||||||
6207 | } never executed: end of block | 0 | ||||||||||||||||||||||||
6208 | } executed 32 times by 4 tests: end of block Executed by:
| 32 | ||||||||||||||||||||||||
6209 | } executed 20 times by 4 tests: end of block Executed by:
| 20 | ||||||||||||||||||||||||
6210 | break; executed 390 times by 9 tests: break; Executed by:
| 390 | ||||||||||||||||||||||||
6211 | } | - | ||||||||||||||||||||||||
6212 | case QQuickItem::ItemParentHasChanged: { executed 817030 times by 106 tests: case QQuickItem::ItemParentHasChanged: Executed by:
| 817030 | ||||||||||||||||||||||||
6213 | q->itemChange(change, data); | - | ||||||||||||||||||||||||
6214 | if (!changeListeners.isEmpty()) {
| 22178-794852 | ||||||||||||||||||||||||
6215 | const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732) | - | ||||||||||||||||||||||||
6216 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { | - | ||||||||||||||||||||||||
6217 | if (change.types & QQuickItemPrivate::Parent) {
| 212-27750 | ||||||||||||||||||||||||
6218 | change.listener->itemParentChanged(q, data.item); | - | ||||||||||||||||||||||||
6219 | } executed 212 times by 6 tests: end of block Executed by:
| 212 | ||||||||||||||||||||||||
6220 | } executed 27962 times by 89 tests: end of block Executed by:
| 27962 | ||||||||||||||||||||||||
6221 | } executed 22178 times by 89 tests: end of block Executed by:
| 22178 | ||||||||||||||||||||||||
6222 | break; executed 817030 times by 106 tests: break; Executed by:
| 817030 | ||||||||||||||||||||||||
6223 | } | - | ||||||||||||||||||||||||
6224 | case QQuickItem::ItemOpacityHasChanged: { executed 24584 times by 19 tests: case QQuickItem::ItemOpacityHasChanged: Executed by:
| 24584 | ||||||||||||||||||||||||
6225 | q->itemChange(change, data); | - | ||||||||||||||||||||||||
6226 | if (!changeListeners.isEmpty()) {
| 510-24074 | ||||||||||||||||||||||||
6227 | const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732) | - | ||||||||||||||||||||||||
6228 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { | - | ||||||||||||||||||||||||
6229 | if (change.types & QQuickItemPrivate::Opacity) {
| 28-554 | ||||||||||||||||||||||||
6230 | change.listener->itemOpacityChanged(q); | - | ||||||||||||||||||||||||
6231 | } executed 28 times by 2 tests: end of block Executed by:
| 28 | ||||||||||||||||||||||||
6232 | } executed 582 times by 6 tests: end of block Executed by:
| 582 | ||||||||||||||||||||||||
6233 | } executed 510 times by 6 tests: end of block Executed by:
| 510 | ||||||||||||||||||||||||
6234 | break; executed 24584 times by 19 tests: break; Executed by:
| 24584 | ||||||||||||||||||||||||
6235 | } | - | ||||||||||||||||||||||||
6236 | case QQuickItem::ItemActiveFocusHasChanged: executed 3418 times by 18 tests: case QQuickItem::ItemActiveFocusHasChanged: Executed by:
| 3418 | ||||||||||||||||||||||||
6237 | q->itemChange(change, data); | - | ||||||||||||||||||||||||
6238 | break; executed 3418 times by 18 tests: break; Executed by:
| 3418 | ||||||||||||||||||||||||
6239 | case QQuickItem::ItemRotationHasChanged: { executed 1299 times by 13 tests: case QQuickItem::ItemRotationHasChanged: Executed by:
| 1299 | ||||||||||||||||||||||||
6240 | q->itemChange(change, data); | - | ||||||||||||||||||||||||
6241 | if (!changeListeners.isEmpty()) {
| 535-764 | ||||||||||||||||||||||||
6242 | const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732) | - | ||||||||||||||||||||||||
6243 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { | - | ||||||||||||||||||||||||
6244 | if (change.types & QQuickItemPrivate::Rotation) {
| 12-556 | ||||||||||||||||||||||||
6245 | change.listener->itemRotationChanged(q); | - | ||||||||||||||||||||||||
6246 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
6247 | } executed 568 times by 4 tests: end of block Executed by:
| 568 | ||||||||||||||||||||||||
6248 | } executed 535 times by 4 tests: end of block Executed by:
| 535 | ||||||||||||||||||||||||
6249 | break; executed 1299 times by 13 tests: break; Executed by:
| 1299 | ||||||||||||||||||||||||
6250 | } | - | ||||||||||||||||||||||||
6251 | case QQuickItem::ItemAntialiasingHasChanged: executed 2128 times by 8 tests: case QQuickItem::ItemAntialiasingHasChanged: Executed by:
| 2128 | ||||||||||||||||||||||||
6252 | // fall through | - | ||||||||||||||||||||||||
6253 | case QQuickItem::ItemDevicePixelRatioHasChanged: never executed: case QQuickItem::ItemDevicePixelRatioHasChanged: | 0 | ||||||||||||||||||||||||
6254 | q->itemChange(change, data); | - | ||||||||||||||||||||||||
6255 | break; executed 2128 times by 8 tests: break; Executed by:
| 2128 | ||||||||||||||||||||||||
6256 | } | - | ||||||||||||||||||||||||
6257 | } executed 2485943 times by 106 tests: end of block Executed by:
| 2485943 | ||||||||||||||||||||||||
6258 | - | |||||||||||||||||||||||||
6259 | /*! | - | ||||||||||||||||||||||||
6260 | \qmlproperty bool QtQuick::Item::smooth | - | ||||||||||||||||||||||||
6261 | - | |||||||||||||||||||||||||
6262 | Primarily used in image based items to decide if the item should use smooth | - | ||||||||||||||||||||||||
6263 | sampling or not. Smooth sampling is performed using linear interpolation, while | - | ||||||||||||||||||||||||
6264 | non-smooth is performed using nearest neighbor. | - | ||||||||||||||||||||||||
6265 | - | |||||||||||||||||||||||||
6266 | In Qt Quick 2.0, this property has minimal impact on performance. | - | ||||||||||||||||||||||||
6267 | - | |||||||||||||||||||||||||
6268 | By default, this property is set to \c true. | - | ||||||||||||||||||||||||
6269 | */ | - | ||||||||||||||||||||||||
6270 | /*! | - | ||||||||||||||||||||||||
6271 | \property QQuickItem::smooth | - | ||||||||||||||||||||||||
6272 | \brief Specifies whether the item is smoothed or not | - | ||||||||||||||||||||||||
6273 | - | |||||||||||||||||||||||||
6274 | Primarily used in image based items to decide if the item should use smooth | - | ||||||||||||||||||||||||
6275 | sampling or not. Smooth sampling is performed using linear interpolation, while | - | ||||||||||||||||||||||||
6276 | non-smooth is performed using nearest neighbor. | - | ||||||||||||||||||||||||
6277 | - | |||||||||||||||||||||||||
6278 | In Qt Quick 2.0, this property has minimal impact on performance. | - | ||||||||||||||||||||||||
6279 | - | |||||||||||||||||||||||||
6280 | By default, this property is set to \c true. | - | ||||||||||||||||||||||||
6281 | */ | - | ||||||||||||||||||||||||
6282 | bool QQuickItem::smooth() const | - | ||||||||||||||||||||||||
6283 | { | - | ||||||||||||||||||||||||
6284 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6285 | return d->smooth; executed 2364 times by 16 tests: return d->smooth; Executed by:
| 2364 | ||||||||||||||||||||||||
6286 | } | - | ||||||||||||||||||||||||
6287 | void QQuickItem::setSmooth(bool smooth) | - | ||||||||||||||||||||||||
6288 | { | - | ||||||||||||||||||||||||
6289 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6290 | if (d->smooth == smooth)
| 108-266 | ||||||||||||||||||||||||
6291 | return; executed 266 times by 10 tests: return; Executed by:
| 266 | ||||||||||||||||||||||||
6292 | - | |||||||||||||||||||||||||
6293 | d->smooth = smooth; | - | ||||||||||||||||||||||||
6294 | d->dirty(QQuickItemPrivate::Smooth); | - | ||||||||||||||||||||||||
6295 | - | |||||||||||||||||||||||||
6296 | emit smoothChanged(smooth); | - | ||||||||||||||||||||||||
6297 | } executed 108 times by 6 tests: end of block Executed by:
| 108 | ||||||||||||||||||||||||
6298 | - | |||||||||||||||||||||||||
6299 | /*! | - | ||||||||||||||||||||||||
6300 | \qmlproperty bool QtQuick::Item::activeFocusOnTab | - | ||||||||||||||||||||||||
6301 | - | |||||||||||||||||||||||||
6302 | This property holds whether the item wants to be in the tab focus | - | ||||||||||||||||||||||||
6303 | chain. By default, this is set to \c false. | - | ||||||||||||||||||||||||
6304 | - | |||||||||||||||||||||||||
6305 | The tab focus chain traverses elements by first visiting the | - | ||||||||||||||||||||||||
6306 | parent, and then its children in the order they occur in the | - | ||||||||||||||||||||||||
6307 | children property. Pressing the tab key on an item in the tab | - | ||||||||||||||||||||||||
6308 | focus chain will move keyboard focus to the next item in the | - | ||||||||||||||||||||||||
6309 | chain. Pressing BackTab (normally Shift+Tab) will move focus | - | ||||||||||||||||||||||||
6310 | to the previous item. | - | ||||||||||||||||||||||||
6311 | - | |||||||||||||||||||||||||
6312 | To set up a manual tab focus chain, see \l KeyNavigation. Tab | - | ||||||||||||||||||||||||
6313 | key events used by Keys or KeyNavigation have precedence over | - | ||||||||||||||||||||||||
6314 | focus chain behavior; ignore the events in other key handlers | - | ||||||||||||||||||||||||
6315 | to allow it to propagate. | - | ||||||||||||||||||||||||
6316 | */ | - | ||||||||||||||||||||||||
6317 | /*! | - | ||||||||||||||||||||||||
6318 | \property QQuickItem::activeFocusOnTab | - | ||||||||||||||||||||||||
6319 | - | |||||||||||||||||||||||||
6320 | This property holds whether the item wants to be in the tab focus | - | ||||||||||||||||||||||||
6321 | chain. By default, this is set to \c false. | - | ||||||||||||||||||||||||
6322 | */ | - | ||||||||||||||||||||||||
6323 | bool QQuickItem::activeFocusOnTab() const | - | ||||||||||||||||||||||||
6324 | { | - | ||||||||||||||||||||||||
6325 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6326 | return d->activeFocusOnTab; executed 1828 times by 14 tests: return d->activeFocusOnTab; Executed by:
| 1828 | ||||||||||||||||||||||||
6327 | } | - | ||||||||||||||||||||||||
6328 | void QQuickItem::setActiveFocusOnTab(bool activeFocusOnTab) | - | ||||||||||||||||||||||||
6329 | { | - | ||||||||||||||||||||||||
6330 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6331 | if (d->activeFocusOnTab == activeFocusOnTab)
| 50-168 | ||||||||||||||||||||||||
6332 | return; executed 50 times by 2 tests: return; Executed by:
| 50 | ||||||||||||||||||||||||
6333 | - | |||||||||||||||||||||||||
6334 | if (window()) {
| 4-164 | ||||||||||||||||||||||||
6335 | if ((this == window()->activeFocusItem()) && this != window()->contentItem() && !activeFocusOnTab) {
| 0-2 | ||||||||||||||||||||||||
6336 | qWarning("QQuickItem: Cannot set activeFocusOnTab to false once item is the active focus item."); | - | ||||||||||||||||||||||||
6337 | return; never executed: return; | 0 | ||||||||||||||||||||||||
6338 | } | - | ||||||||||||||||||||||||
6339 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
6340 | - | |||||||||||||||||||||||||
6341 | d->activeFocusOnTab = activeFocusOnTab; | - | ||||||||||||||||||||||||
6342 | - | |||||||||||||||||||||||||
6343 | emit activeFocusOnTabChanged(activeFocusOnTab); | - | ||||||||||||||||||||||||
6344 | } executed 168 times by 5 tests: end of block Executed by:
| 168 | ||||||||||||||||||||||||
6345 | - | |||||||||||||||||||||||||
6346 | /*! | - | ||||||||||||||||||||||||
6347 | \qmlproperty bool QtQuick::Item::antialiasing | - | ||||||||||||||||||||||||
6348 | - | |||||||||||||||||||||||||
6349 | Used by visual elements to decide if the item should use antialiasing or not. | - | ||||||||||||||||||||||||
6350 | In some cases items with antialiasing require more memory and are potentially | - | ||||||||||||||||||||||||
6351 | slower to render (see \l {Antialiasing} for more details). | - | ||||||||||||||||||||||||
6352 | - | |||||||||||||||||||||||||
6353 | The default is false, but may be overridden by derived elements. | - | ||||||||||||||||||||||||
6354 | */ | - | ||||||||||||||||||||||||
6355 | /*! | - | ||||||||||||||||||||||||
6356 | \property QQuickItem::antialiasing | - | ||||||||||||||||||||||||
6357 | \brief Specifies whether the item is antialiased or not | - | ||||||||||||||||||||||||
6358 | - | |||||||||||||||||||||||||
6359 | Used by visual elements to decide if the item should use antialiasing or not. | - | ||||||||||||||||||||||||
6360 | In some cases items with antialiasing require more memory and are potentially | - | ||||||||||||||||||||||||
6361 | slower to render (see \l {Antialiasing} for more details). | - | ||||||||||||||||||||||||
6362 | - | |||||||||||||||||||||||||
6363 | The default is false, but may be overridden by derived elements. | - | ||||||||||||||||||||||||
6364 | */ | - | ||||||||||||||||||||||||
6365 | bool QQuickItem::antialiasing() const | - | ||||||||||||||||||||||||
6366 | { | - | ||||||||||||||||||||||||
6367 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6368 | return d->antialiasingValid ? d->antialiasing : d->implicitAntialiasing; executed 122272 times by 77 tests: return d->antialiasingValid ? d->antialiasing : d->implicitAntialiasing; Executed by:
| 122272 | ||||||||||||||||||||||||
6369 | } | - | ||||||||||||||||||||||||
6370 | - | |||||||||||||||||||||||||
6371 | void QQuickItem::setAntialiasing(bool aa) | - | ||||||||||||||||||||||||
6372 | { | - | ||||||||||||||||||||||||
6373 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6374 | - | |||||||||||||||||||||||||
6375 | if (!d->antialiasingValid) {
| 12-2320 | ||||||||||||||||||||||||
6376 | d->antialiasingValid = true; | - | ||||||||||||||||||||||||
6377 | d->antialiasing = d->implicitAntialiasing; | - | ||||||||||||||||||||||||
6378 | } executed 2320 times by 8 tests: end of block Executed by:
| 2320 | ||||||||||||||||||||||||
6379 | - | |||||||||||||||||||||||||
6380 | if (aa == d->antialiasing)
| 204-2128 | ||||||||||||||||||||||||
6381 | return; executed 204 times by 4 tests: return; Executed by:
| 204 | ||||||||||||||||||||||||
6382 | - | |||||||||||||||||||||||||
6383 | d->antialiasing = aa; | - | ||||||||||||||||||||||||
6384 | d->dirty(QQuickItemPrivate::Antialiasing); | - | ||||||||||||||||||||||||
6385 | - | |||||||||||||||||||||||||
6386 | d->itemChange(ItemAntialiasingHasChanged, d->antialiasing); | - | ||||||||||||||||||||||||
6387 | - | |||||||||||||||||||||||||
6388 | emit antialiasingChanged(antialiasing()); | - | ||||||||||||||||||||||||
6389 | } executed 2128 times by 8 tests: end of block Executed by:
| 2128 | ||||||||||||||||||||||||
6390 | - | |||||||||||||||||||||||||
6391 | void QQuickItem::resetAntialiasing() | - | ||||||||||||||||||||||||
6392 | { | - | ||||||||||||||||||||||||
6393 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6394 | if (!d->antialiasingValid)
| 6 | ||||||||||||||||||||||||
6395 | return; executed 6 times by 1 test: return; Executed by:
| 6 | ||||||||||||||||||||||||
6396 | - | |||||||||||||||||||||||||
6397 | d->antialiasingValid = false; | - | ||||||||||||||||||||||||
6398 | - | |||||||||||||||||||||||||
6399 | if (d->implicitAntialiasing != d->antialiasing)
| 0-6 | ||||||||||||||||||||||||
6400 | emit antialiasingChanged(antialiasing()); executed 6 times by 2 tests: antialiasingChanged(antialiasing()); Executed by:
| 6 | ||||||||||||||||||||||||
6401 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||
6402 | - | |||||||||||||||||||||||||
6403 | void QQuickItemPrivate::setImplicitAntialiasing(bool antialiasing) | - | ||||||||||||||||||||||||
6404 | { | - | ||||||||||||||||||||||||
6405 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
6406 | bool prev = q->antialiasing(); | - | ||||||||||||||||||||||||
6407 | implicitAntialiasing = antialiasing; | - | ||||||||||||||||||||||||
6408 | if (componentComplete && (q->antialiasing() != prev))
| 77-2202 | ||||||||||||||||||||||||
6409 | emit q->antialiasingChanged(q->antialiasing()); executed 77 times by 4 tests: q->antialiasingChanged(q->antialiasing()); Executed by:
| 77 | ||||||||||||||||||||||||
6410 | } executed 2830 times by 13 tests: end of block Executed by:
| 2830 | ||||||||||||||||||||||||
6411 | - | |||||||||||||||||||||||||
6412 | /*! | - | ||||||||||||||||||||||||
6413 | Returns the item flags for this item. | - | ||||||||||||||||||||||||
6414 | - | |||||||||||||||||||||||||
6415 | \sa setFlag() | - | ||||||||||||||||||||||||
6416 | */ | - | ||||||||||||||||||||||||
6417 | QQuickItem::Flags QQuickItem::flags() const | - | ||||||||||||||||||||||||
6418 | { | - | ||||||||||||||||||||||||
6419 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6420 | return (QQuickItem::Flags)d->flags; executed 1902248 times by 112 tests: return (QQuickItem::Flags)d->flags; Executed by:
| 1902248 | ||||||||||||||||||||||||
6421 | } | - | ||||||||||||||||||||||||
6422 | - | |||||||||||||||||||||||||
6423 | /*! | - | ||||||||||||||||||||||||
6424 | Enables the specified \a flag for this item if \a enabled is true; | - | ||||||||||||||||||||||||
6425 | if \a enabled is false, the flag is disabled. | - | ||||||||||||||||||||||||
6426 | - | |||||||||||||||||||||||||
6427 | These provide various hints for the item; for example, the | - | ||||||||||||||||||||||||
6428 | ItemClipsChildrenToShape flag indicates that all children of this | - | ||||||||||||||||||||||||
6429 | item should be clipped to fit within the item area. | - | ||||||||||||||||||||||||
6430 | */ | - | ||||||||||||||||||||||||
6431 | void QQuickItem::setFlag(Flag flag, bool enabled) | - | ||||||||||||||||||||||||
6432 | { | - | ||||||||||||||||||||||||
6433 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6434 | if (enabled)
| 70-374752 | ||||||||||||||||||||||||
6435 | setFlags((Flags)(d->flags | (quint32)flag)); executed 374752 times by 100 tests: setFlags((Flags)(d->flags | (quint32)flag)); Executed by:
| 374752 | ||||||||||||||||||||||||
6436 | else | - | ||||||||||||||||||||||||
6437 | setFlags((Flags)(d->flags & ~(quint32)flag)); executed 70 times by 3 tests: setFlags((Flags)(d->flags & ~(quint32)flag)); Executed by:
| 70 | ||||||||||||||||||||||||
6438 | } | - | ||||||||||||||||||||||||
6439 | - | |||||||||||||||||||||||||
6440 | /*! | - | ||||||||||||||||||||||||
6441 | Enables the specified \a flags for this item. | - | ||||||||||||||||||||||||
6442 | - | |||||||||||||||||||||||||
6443 | \sa setFlag() | - | ||||||||||||||||||||||||
6444 | */ | - | ||||||||||||||||||||||||
6445 | void QQuickItem::setFlags(Flags flags) | - | ||||||||||||||||||||||||
6446 | { | - | ||||||||||||||||||||||||
6447 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6448 | - | |||||||||||||||||||||||||
6449 | if (int(flags & ItemIsFocusScope) != int(d->flags & ItemIsFocusScope)) {
| 4430-370700 | ||||||||||||||||||||||||
6450 | if (flags & ItemIsFocusScope && !d->childItems.isEmpty() && d->window) {
| 0-3702 | ||||||||||||||||||||||||
6451 | qWarning("QQuickItem: Cannot set FocusScope once item has children and is in a window."); | - | ||||||||||||||||||||||||
6452 | flags &= ~ItemIsFocusScope; | - | ||||||||||||||||||||||||
6453 | } else if (d->flags & ItemIsFocusScope) { never executed: end of block
| 0-4430 | ||||||||||||||||||||||||
6454 | qWarning("QQuickItem: Cannot unset FocusScope flag."); | - | ||||||||||||||||||||||||
6455 | flags |= ItemIsFocusScope; | - | ||||||||||||||||||||||||
6456 | } never executed: end of block | 0 | ||||||||||||||||||||||||
6457 | } executed 4430 times by 21 tests: end of block Executed by:
| 4430 | ||||||||||||||||||||||||
6458 | - | |||||||||||||||||||||||||
6459 | if (int(flags & ItemClipsChildrenToShape) != int(d->flags & ItemClipsChildrenToShape))
| 272-374858 | ||||||||||||||||||||||||
6460 | d->dirty(QQuickItemPrivate::Clip); executed 272 times by 11 tests: d->dirty(QQuickItemPrivate::Clip); Executed by:
| 272 | ||||||||||||||||||||||||
6461 | - | |||||||||||||||||||||||||
6462 | d->flags = flags; | - | ||||||||||||||||||||||||
6463 | } executed 375130 times by 102 tests: end of block Executed by:
| 375130 | ||||||||||||||||||||||||
6464 | - | |||||||||||||||||||||||||
6465 | /*! | - | ||||||||||||||||||||||||
6466 | \qmlproperty real QtQuick::Item::x | - | ||||||||||||||||||||||||
6467 | \qmlproperty real QtQuick::Item::y | - | ||||||||||||||||||||||||
6468 | \qmlproperty real QtQuick::Item::width | - | ||||||||||||||||||||||||
6469 | \qmlproperty real QtQuick::Item::height | - | ||||||||||||||||||||||||
6470 | - | |||||||||||||||||||||||||
6471 | Defines the item's position and size. | - | ||||||||||||||||||||||||
6472 | The default value is \c 0. | - | ||||||||||||||||||||||||
6473 | - | |||||||||||||||||||||||||
6474 | The (x,y) position is relative to the \l parent. | - | ||||||||||||||||||||||||
6475 | - | |||||||||||||||||||||||||
6476 | \qml | - | ||||||||||||||||||||||||
6477 | Item { x: 100; y: 100; width: 100; height: 100 } | - | ||||||||||||||||||||||||
6478 | \endqml | - | ||||||||||||||||||||||||
6479 | */ | - | ||||||||||||||||||||||||
6480 | /*! | - | ||||||||||||||||||||||||
6481 | \property QQuickItem::x | - | ||||||||||||||||||||||||
6482 | - | |||||||||||||||||||||||||
6483 | Defines the item's x position relative to its parent. | - | ||||||||||||||||||||||||
6484 | */ | - | ||||||||||||||||||||||||
6485 | /*! | - | ||||||||||||||||||||||||
6486 | \property QQuickItem::y | - | ||||||||||||||||||||||||
6487 | - | |||||||||||||||||||||||||
6488 | Defines the item's y position relative to its parent. | - | ||||||||||||||||||||||||
6489 | */ | - | ||||||||||||||||||||||||
6490 | qreal QQuickItem::x() const | - | ||||||||||||||||||||||||
6491 | { | - | ||||||||||||||||||||||||
6492 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6493 | return d->x; executed 1328055 times by 64 tests: return d->x; Executed by:
| 1328055 | ||||||||||||||||||||||||
6494 | } | - | ||||||||||||||||||||||||
6495 | - | |||||||||||||||||||||||||
6496 | qreal QQuickItem::y() const | - | ||||||||||||||||||||||||
6497 | { | - | ||||||||||||||||||||||||
6498 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6499 | return d->y; executed 1714104 times by 63 tests: return d->y; Executed by:
| 1714104 | ||||||||||||||||||||||||
6500 | } | - | ||||||||||||||||||||||||
6501 | - | |||||||||||||||||||||||||
6502 | /*! | - | ||||||||||||||||||||||||
6503 | \internal | - | ||||||||||||||||||||||||
6504 | */ | - | ||||||||||||||||||||||||
6505 | QPointF QQuickItem::position() const | - | ||||||||||||||||||||||||
6506 | { | - | ||||||||||||||||||||||||
6507 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6508 | return QPointF(d->x, d->y); executed 34723 times by 17 tests: return QPointF(d->x, d->y); Executed by:
| 34723 | ||||||||||||||||||||||||
6509 | } | - | ||||||||||||||||||||||||
6510 | - | |||||||||||||||||||||||||
6511 | void QQuickItem::setX(qreal v) | - | ||||||||||||||||||||||||
6512 | { | - | ||||||||||||||||||||||||
6513 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6514 | if (qt_is_nan(v))
| 12-285736 | ||||||||||||||||||||||||
6515 | return; executed 12 times by 1 test: return; Executed by:
| 12 | ||||||||||||||||||||||||
6516 | if (d->x == v)
| 71975-213761 | ||||||||||||||||||||||||
6517 | return; executed 71975 times by 32 tests: return; Executed by:
| 71975 | ||||||||||||||||||||||||
6518 | - | |||||||||||||||||||||||||
6519 | qreal oldx = d->x; | - | ||||||||||||||||||||||||
6520 | d->x = v; | - | ||||||||||||||||||||||||
6521 | - | |||||||||||||||||||||||||
6522 | d->dirty(QQuickItemPrivate::Position); | - | ||||||||||||||||||||||||
6523 | - | |||||||||||||||||||||||||
6524 | geometryChanged(QRectF(d->x, d->y, d->width, d->height), | - | ||||||||||||||||||||||||
6525 | QRectF(oldx, d->y, d->width, d->height)); | - | ||||||||||||||||||||||||
6526 | } executed 213761 times by 47 tests: end of block Executed by:
| 213761 | ||||||||||||||||||||||||
6527 | - | |||||||||||||||||||||||||
6528 | void QQuickItem::setY(qreal v) | - | ||||||||||||||||||||||||
6529 | { | - | ||||||||||||||||||||||||
6530 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6531 | if (qt_is_nan(v))
| 16-270903 | ||||||||||||||||||||||||
6532 | return; executed 16 times by 1 test: return; Executed by:
| 16 | ||||||||||||||||||||||||
6533 | if (d->y == v)
| 113024-157879 | ||||||||||||||||||||||||
6534 | return; executed 113024 times by 35 tests: return; Executed by:
| 113024 | ||||||||||||||||||||||||
6535 | - | |||||||||||||||||||||||||
6536 | qreal oldy = d->y; | - | ||||||||||||||||||||||||
6537 | d->y = v; | - | ||||||||||||||||||||||||
6538 | - | |||||||||||||||||||||||||
6539 | d->dirty(QQuickItemPrivate::Position); | - | ||||||||||||||||||||||||
6540 | - | |||||||||||||||||||||||||
6541 | geometryChanged(QRectF(d->x, d->y, d->width, d->height), | - | ||||||||||||||||||||||||
6542 | QRectF(d->x, oldy, d->width, d->height)); | - | ||||||||||||||||||||||||
6543 | } executed 157879 times by 47 tests: end of block Executed by:
| 157879 | ||||||||||||||||||||||||
6544 | - | |||||||||||||||||||||||||
6545 | /*! | - | ||||||||||||||||||||||||
6546 | \internal | - | ||||||||||||||||||||||||
6547 | */ | - | ||||||||||||||||||||||||
6548 | void QQuickItem::setPosition(const QPointF &pos) | - | ||||||||||||||||||||||||
6549 | { | - | ||||||||||||||||||||||||
6550 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6551 | if (QPointF(d->x, d->y) == pos)
| 93174-149552 | ||||||||||||||||||||||||
6552 | return; executed 93174 times by 71 tests: return; Executed by:
| 93174 | ||||||||||||||||||||||||
6553 | - | |||||||||||||||||||||||||
6554 | qreal oldx = d->x; | - | ||||||||||||||||||||||||
6555 | qreal oldy = d->y; | - | ||||||||||||||||||||||||
6556 | - | |||||||||||||||||||||||||
6557 | d->x = pos.x(); | - | ||||||||||||||||||||||||
6558 | d->y = pos.y(); | - | ||||||||||||||||||||||||
6559 | - | |||||||||||||||||||||||||
6560 | d->dirty(QQuickItemPrivate::Position); | - | ||||||||||||||||||||||||
6561 | - | |||||||||||||||||||||||||
6562 | geometryChanged(QRectF(d->x, d->y, d->width, d->height), | - | ||||||||||||||||||||||||
6563 | QRectF(oldx, oldy, d->width, d->height)); | - | ||||||||||||||||||||||||
6564 | } executed 149552 times by 44 tests: end of block Executed by:
| 149552 | ||||||||||||||||||||||||
6565 | - | |||||||||||||||||||||||||
6566 | /*! | - | ||||||||||||||||||||||||
6567 | \property QQuickItem::width | - | ||||||||||||||||||||||||
6568 | - | |||||||||||||||||||||||||
6569 | This property holds the width of this item. | - | ||||||||||||||||||||||||
6570 | */ | - | ||||||||||||||||||||||||
6571 | qreal QQuickItem::width() const | - | ||||||||||||||||||||||||
6572 | { | - | ||||||||||||||||||||||||
6573 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6574 | return d->width; executed 2672108 times by 103 tests: return d->width; Executed by:
| 2672108 | ||||||||||||||||||||||||
6575 | } | - | ||||||||||||||||||||||||
6576 | - | |||||||||||||||||||||||||
6577 | void QQuickItem::setWidth(qreal w) | - | ||||||||||||||||||||||||
6578 | { | - | ||||||||||||||||||||||||
6579 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6580 | if (qt_is_nan(w))
| 24-201742 | ||||||||||||||||||||||||
6581 | return; executed 24 times by 1 test: return; Executed by:
| 24 | ||||||||||||||||||||||||
6582 | - | |||||||||||||||||||||||||
6583 | d->widthValid = true; | - | ||||||||||||||||||||||||
6584 | if (d->width == w)
| 81705-120037 | ||||||||||||||||||||||||
6585 | return; executed 81705 times by 29 tests: return; Executed by:
| 81705 | ||||||||||||||||||||||||
6586 | - | |||||||||||||||||||||||||
6587 | qreal oldWidth = d->width; | - | ||||||||||||||||||||||||
6588 | d->width = w; | - | ||||||||||||||||||||||||
6589 | - | |||||||||||||||||||||||||
6590 | d->dirty(QQuickItemPrivate::Size); | - | ||||||||||||||||||||||||
6591 | - | |||||||||||||||||||||||||
6592 | geometryChanged(QRectF(d->x, d->y, d->width, d->height), | - | ||||||||||||||||||||||||
6593 | QRectF(d->x, d->y, oldWidth, d->height)); | - | ||||||||||||||||||||||||
6594 | } executed 120037 times by 93 tests: end of block Executed by:
| 120037 | ||||||||||||||||||||||||
6595 | - | |||||||||||||||||||||||||
6596 | void QQuickItem::resetWidth() | - | ||||||||||||||||||||||||
6597 | { | - | ||||||||||||||||||||||||
6598 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6599 | d->widthValid = false; | - | ||||||||||||||||||||||||
6600 | setImplicitWidth(implicitWidth()); | - | ||||||||||||||||||||||||
6601 | } executed 128 times by 9 tests: end of block Executed by:
| 128 | ||||||||||||||||||||||||
6602 | - | |||||||||||||||||||||||||
6603 | void QQuickItemPrivate::implicitWidthChanged() | - | ||||||||||||||||||||||||
6604 | { | - | ||||||||||||||||||||||||
6605 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
6606 | if (!changeListeners.isEmpty()) {
| 104033-754158 | ||||||||||||||||||||||||
6607 | const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732) | - | ||||||||||||||||||||||||
6608 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { | - | ||||||||||||||||||||||||
6609 | if (change.types & QQuickItemPrivate::ImplicitWidth) {
| 228-104341 | ||||||||||||||||||||||||
6610 | change.listener->itemImplicitWidthChanged(q); | - | ||||||||||||||||||||||||
6611 | } executed 228 times by 5 tests: end of block Executed by:
| 228 | ||||||||||||||||||||||||
6612 | } executed 104569 times by 23 tests: end of block Executed by:
| 104569 | ||||||||||||||||||||||||
6613 | } executed 104033 times by 23 tests: end of block Executed by:
| 104033 | ||||||||||||||||||||||||
6614 | emit q->implicitWidthChanged(); | - | ||||||||||||||||||||||||
6615 | } executed 858191 times by 53 tests: end of block Executed by:
| 858191 | ||||||||||||||||||||||||
6616 | - | |||||||||||||||||||||||||
6617 | qreal QQuickItemPrivate::getImplicitWidth() const | - | ||||||||||||||||||||||||
6618 | { | - | ||||||||||||||||||||||||
6619 | return implicitWidth; executed 4028 times by 21 tests: return implicitWidth; Executed by:
| 4028 | ||||||||||||||||||||||||
6620 | } | - | ||||||||||||||||||||||||
6621 | /*! | - | ||||||||||||||||||||||||
6622 | Returns the width of the item that is implied by other properties that determine the content. | - | ||||||||||||||||||||||||
6623 | */ | - | ||||||||||||||||||||||||
6624 | qreal QQuickItem::implicitWidth() const | - | ||||||||||||||||||||||||
6625 | { | - | ||||||||||||||||||||||||
6626 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6627 | return d->getImplicitWidth(); executed 5356 times by 24 tests: return d->getImplicitWidth(); Executed by:
| 5356 | ||||||||||||||||||||||||
6628 | } | - | ||||||||||||||||||||||||
6629 | - | |||||||||||||||||||||||||
6630 | /*! | - | ||||||||||||||||||||||||
6631 | \qmlproperty real QtQuick::Item::implicitWidth | - | ||||||||||||||||||||||||
6632 | \qmlproperty real QtQuick::Item::implicitHeight | - | ||||||||||||||||||||||||
6633 | - | |||||||||||||||||||||||||
6634 | Defines the natural width or height of the Item if no \l width or \l height is specified. | - | ||||||||||||||||||||||||
6635 | - | |||||||||||||||||||||||||
6636 | The default implicit size for most items is 0x0, however some items have an inherent | - | ||||||||||||||||||||||||
6637 | implicit size which cannot be overridden, for example, \l [QML] Image and \l [QML] Text. | - | ||||||||||||||||||||||||
6638 | - | |||||||||||||||||||||||||
6639 | Setting the implicit size is useful for defining components that have a preferred size | - | ||||||||||||||||||||||||
6640 | based on their content, for example: | - | ||||||||||||||||||||||||
6641 | - | |||||||||||||||||||||||||
6642 | \qml | - | ||||||||||||||||||||||||
6643 | // Label.qml | - | ||||||||||||||||||||||||
6644 | import QtQuick 2.0 | - | ||||||||||||||||||||||||
6645 | - | |||||||||||||||||||||||||
6646 | Item { | - | ||||||||||||||||||||||||
6647 | property alias icon: image.source | - | ||||||||||||||||||||||||
6648 | property alias label: text.text | - | ||||||||||||||||||||||||
6649 | implicitWidth: text.implicitWidth + image.implicitWidth | - | ||||||||||||||||||||||||
6650 | implicitHeight: Math.max(text.implicitHeight, image.implicitHeight) | - | ||||||||||||||||||||||||
6651 | Image { id: image } | - | ||||||||||||||||||||||||
6652 | Text { | - | ||||||||||||||||||||||||
6653 | id: text | - | ||||||||||||||||||||||||
6654 | wrapMode: Text.Wrap | - | ||||||||||||||||||||||||
6655 | anchors.left: image.right; anchors.right: parent.right | - | ||||||||||||||||||||||||
6656 | anchors.verticalCenter: parent.verticalCenter | - | ||||||||||||||||||||||||
6657 | } | - | ||||||||||||||||||||||||
6658 | } | - | ||||||||||||||||||||||||
6659 | \endqml | - | ||||||||||||||||||||||||
6660 | - | |||||||||||||||||||||||||
6661 | \note Using implicitWidth of \l [QML] Text or \l [QML] TextEdit and setting the width explicitly | - | ||||||||||||||||||||||||
6662 | incurs a performance penalty as the text must be laid out twice. | - | ||||||||||||||||||||||||
6663 | */ | - | ||||||||||||||||||||||||
6664 | /*! | - | ||||||||||||||||||||||||
6665 | \property QQuickItem::implicitWidth | - | ||||||||||||||||||||||||
6666 | \property QQuickItem::implicitHeight | - | ||||||||||||||||||||||||
6667 | - | |||||||||||||||||||||||||
6668 | Defines the natural width or height of the Item if no \l width or \l height is specified. | - | ||||||||||||||||||||||||
6669 | - | |||||||||||||||||||||||||
6670 | The default implicit size for most items is 0x0, however some items have an inherent | - | ||||||||||||||||||||||||
6671 | implicit size which cannot be overridden, for example, \l [QML] Image and \l [QML] Text. | - | ||||||||||||||||||||||||
6672 | - | |||||||||||||||||||||||||
6673 | Setting the implicit size is useful for defining components that have a preferred size | - | ||||||||||||||||||||||||
6674 | based on their content, for example: | - | ||||||||||||||||||||||||
6675 | - | |||||||||||||||||||||||||
6676 | \qml | - | ||||||||||||||||||||||||
6677 | // Label.qml | - | ||||||||||||||||||||||||
6678 | import QtQuick 2.0 | - | ||||||||||||||||||||||||
6679 | - | |||||||||||||||||||||||||
6680 | Item { | - | ||||||||||||||||||||||||
6681 | property alias icon: image.source | - | ||||||||||||||||||||||||
6682 | property alias label: text.text | - | ||||||||||||||||||||||||
6683 | implicitWidth: text.implicitWidth + image.implicitWidth | - | ||||||||||||||||||||||||
6684 | implicitHeight: Math.max(text.implicitHeight, image.implicitHeight) | - | ||||||||||||||||||||||||
6685 | Image { id: image } | - | ||||||||||||||||||||||||
6686 | Text { | - | ||||||||||||||||||||||||
6687 | id: text | - | ||||||||||||||||||||||||
6688 | wrapMode: Text.Wrap | - | ||||||||||||||||||||||||
6689 | anchors.left: image.right; anchors.right: parent.right | - | ||||||||||||||||||||||||
6690 | anchors.verticalCenter: parent.verticalCenter | - | ||||||||||||||||||||||||
6691 | } | - | ||||||||||||||||||||||||
6692 | } | - | ||||||||||||||||||||||||
6693 | \endqml | - | ||||||||||||||||||||||||
6694 | - | |||||||||||||||||||||||||
6695 | \note Using implicitWidth of \l [QML] Text or \l [QML] TextEdit and setting the width explicitly | - | ||||||||||||||||||||||||
6696 | incurs a performance penalty as the text must be laid out twice. | - | ||||||||||||||||||||||||
6697 | */ | - | ||||||||||||||||||||||||
6698 | void QQuickItem::setImplicitWidth(qreal w) | - | ||||||||||||||||||||||||
6699 | { | - | ||||||||||||||||||||||||
6700 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6701 | bool changed = w != d->implicitWidth; | - | ||||||||||||||||||||||||
6702 | d->implicitWidth = w; | - | ||||||||||||||||||||||||
6703 | if (d->width == w || widthValid()) {
| 148-498 | ||||||||||||||||||||||||
6704 | if (changed)
| 162-168 | ||||||||||||||||||||||||
6705 | d->implicitWidthChanged(); executed 162 times by 8 tests: d->implicitWidthChanged(); Executed by:
| 162 | ||||||||||||||||||||||||
6706 | if (d->width == w || widthValid())
| 0-186 | ||||||||||||||||||||||||
6707 | return; executed 330 times by 9 tests: return; Executed by:
| 330 | ||||||||||||||||||||||||
6708 | changed = false; | - | ||||||||||||||||||||||||
6709 | } never executed: end of block | 0 | ||||||||||||||||||||||||
6710 | - | |||||||||||||||||||||||||
6711 | qreal oldWidth = d->width; | - | ||||||||||||||||||||||||
6712 | d->width = w; | - | ||||||||||||||||||||||||
6713 | - | |||||||||||||||||||||||||
6714 | d->dirty(QQuickItemPrivate::Size); | - | ||||||||||||||||||||||||
6715 | - | |||||||||||||||||||||||||
6716 | geometryChanged(QRectF(d->x, d->y, d->width, d->height), | - | ||||||||||||||||||||||||
6717 | QRectF(d->x, d->y, oldWidth, d->height)); | - | ||||||||||||||||||||||||
6718 | - | |||||||||||||||||||||||||
6719 | if (changed)
| 58-258 | ||||||||||||||||||||||||
6720 | d->implicitWidthChanged(); executed 258 times by 7 tests: d->implicitWidthChanged(); Executed by:
| 258 | ||||||||||||||||||||||||
6721 | } executed 316 times by 12 tests: end of block Executed by:
| 316 | ||||||||||||||||||||||||
6722 | - | |||||||||||||||||||||||||
6723 | /*! | - | ||||||||||||||||||||||||
6724 | Returns whether the width property has been set explicitly. | - | ||||||||||||||||||||||||
6725 | */ | - | ||||||||||||||||||||||||
6726 | bool QQuickItem::widthValid() const | - | ||||||||||||||||||||||||
6727 | { | - | ||||||||||||||||||||||||
6728 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6729 | return d->widthValid; executed 1699202 times by 52 tests: return d->widthValid; Executed by:
| 1699202 | ||||||||||||||||||||||||
6730 | } | - | ||||||||||||||||||||||||
6731 | - | |||||||||||||||||||||||||
6732 | /*! | - | ||||||||||||||||||||||||
6733 | \property QQuickItem::height | - | ||||||||||||||||||||||||
6734 | - | |||||||||||||||||||||||||
6735 | This property holds the height of this item. | - | ||||||||||||||||||||||||
6736 | */ | - | ||||||||||||||||||||||||
6737 | qreal QQuickItem::height() const | - | ||||||||||||||||||||||||
6738 | { | - | ||||||||||||||||||||||||
6739 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6740 | return d->height; executed 3223356 times by 102 tests: return d->height; Executed by:
| 3223356 | ||||||||||||||||||||||||
6741 | } | - | ||||||||||||||||||||||||
6742 | - | |||||||||||||||||||||||||
6743 | void QQuickItem::setHeight(qreal h) | - | ||||||||||||||||||||||||
6744 | { | - | ||||||||||||||||||||||||
6745 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6746 | if (qt_is_nan(h))
| 16-130525 | ||||||||||||||||||||||||
6747 | return; executed 16 times by 1 test: return; Executed by:
| 16 | ||||||||||||||||||||||||
6748 | - | |||||||||||||||||||||||||
6749 | d->heightValid = true; | - | ||||||||||||||||||||||||
6750 | if (d->height == h)
| 5798-124727 | ||||||||||||||||||||||||
6751 | return; executed 5798 times by 25 tests: return; Executed by:
| 5798 | ||||||||||||||||||||||||
6752 | - | |||||||||||||||||||||||||
6753 | qreal oldHeight = d->height; | - | ||||||||||||||||||||||||
6754 | d->height = h; | - | ||||||||||||||||||||||||
6755 | - | |||||||||||||||||||||||||
6756 | d->dirty(QQuickItemPrivate::Size); | - | ||||||||||||||||||||||||
6757 | - | |||||||||||||||||||||||||
6758 | geometryChanged(QRectF(d->x, d->y, d->width, d->height), | - | ||||||||||||||||||||||||
6759 | QRectF(d->x, d->y, d->width, oldHeight)); | - | ||||||||||||||||||||||||
6760 | } executed 124727 times by 91 tests: end of block Executed by:
| 124727 | ||||||||||||||||||||||||
6761 | - | |||||||||||||||||||||||||
6762 | void QQuickItem::resetHeight() | - | ||||||||||||||||||||||||
6763 | { | - | ||||||||||||||||||||||||
6764 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6765 | d->heightValid = false; | - | ||||||||||||||||||||||||
6766 | setImplicitHeight(implicitHeight()); | - | ||||||||||||||||||||||||
6767 | } executed 54 times by 5 tests: end of block Executed by:
| 54 | ||||||||||||||||||||||||
6768 | - | |||||||||||||||||||||||||
6769 | void QQuickItemPrivate::implicitHeightChanged() | - | ||||||||||||||||||||||||
6770 | { | - | ||||||||||||||||||||||||
6771 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
6772 | if (!changeListeners.isEmpty()) {
| 62182-699259 | ||||||||||||||||||||||||
6773 | const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732) | - | ||||||||||||||||||||||||
6774 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { | - | ||||||||||||||||||||||||
6775 | if (change.types & QQuickItemPrivate::ImplicitHeight) {
| 112-62788 | ||||||||||||||||||||||||
6776 | change.listener->itemImplicitHeightChanged(q); | - | ||||||||||||||||||||||||
6777 | } executed 112 times by 6 tests: end of block Executed by:
| 112 | ||||||||||||||||||||||||
6778 | } executed 62900 times by 23 tests: end of block Executed by:
| 62900 | ||||||||||||||||||||||||
6779 | } executed 62182 times by 23 tests: end of block Executed by:
| 62182 | ||||||||||||||||||||||||
6780 | emit q->implicitHeightChanged(); | - | ||||||||||||||||||||||||
6781 | } executed 761441 times by 52 tests: end of block Executed by:
| 761441 | ||||||||||||||||||||||||
6782 | - | |||||||||||||||||||||||||
6783 | qreal QQuickItemPrivate::getImplicitHeight() const | - | ||||||||||||||||||||||||
6784 | { | - | ||||||||||||||||||||||||
6785 | return implicitHeight; executed 4640 times by 22 tests: return implicitHeight; Executed by:
| 4640 | ||||||||||||||||||||||||
6786 | } | - | ||||||||||||||||||||||||
6787 | - | |||||||||||||||||||||||||
6788 | qreal QQuickItem::implicitHeight() const | - | ||||||||||||||||||||||||
6789 | { | - | ||||||||||||||||||||||||
6790 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6791 | return d->getImplicitHeight(); executed 5596 times by 23 tests: return d->getImplicitHeight(); Executed by:
| 5596 | ||||||||||||||||||||||||
6792 | } | - | ||||||||||||||||||||||||
6793 | - | |||||||||||||||||||||||||
6794 | void QQuickItem::setImplicitHeight(qreal h) | - | ||||||||||||||||||||||||
6795 | { | - | ||||||||||||||||||||||||
6796 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6797 | bool changed = h != d->implicitHeight; | - | ||||||||||||||||||||||||
6798 | d->implicitHeight = h; | - | ||||||||||||||||||||||||
6799 | if (d->height == h || heightValid()) {
| 462-1866 | ||||||||||||||||||||||||
6800 | if (changed)
| 234-1826 | ||||||||||||||||||||||||
6801 | d->implicitHeightChanged(); executed 234 times by 8 tests: d->implicitHeightChanged(); Executed by:
| 234 | ||||||||||||||||||||||||
6802 | if (d->height == h || heightValid())
| 0-1386 | ||||||||||||||||||||||||
6803 | return; executed 2060 times by 10 tests: return; Executed by:
| 2060 | ||||||||||||||||||||||||
6804 | changed = false; | - | ||||||||||||||||||||||||
6805 | } never executed: end of block | 0 | ||||||||||||||||||||||||
6806 | - | |||||||||||||||||||||||||
6807 | qreal oldHeight = d->height; | - | ||||||||||||||||||||||||
6808 | d->height = h; | - | ||||||||||||||||||||||||
6809 | - | |||||||||||||||||||||||||
6810 | d->dirty(QQuickItemPrivate::Size); | - | ||||||||||||||||||||||||
6811 | - | |||||||||||||||||||||||||
6812 | geometryChanged(QRectF(d->x, d->y, d->width, d->height), | - | ||||||||||||||||||||||||
6813 | QRectF(d->x, d->y, d->width, oldHeight)); | - | ||||||||||||||||||||||||
6814 | - | |||||||||||||||||||||||||
6815 | if (changed)
| 6-456 | ||||||||||||||||||||||||
6816 | d->implicitHeightChanged(); executed 456 times by 8 tests: d->implicitHeightChanged(); Executed by:
| 456 | ||||||||||||||||||||||||
6817 | } executed 462 times by 8 tests: end of block Executed by:
| 462 | ||||||||||||||||||||||||
6818 | - | |||||||||||||||||||||||||
6819 | /*! | - | ||||||||||||||||||||||||
6820 | \internal | - | ||||||||||||||||||||||||
6821 | */ | - | ||||||||||||||||||||||||
6822 | void QQuickItem::setImplicitSize(qreal w, qreal h) | - | ||||||||||||||||||||||||
6823 | { | - | ||||||||||||||||||||||||
6824 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6825 | bool wChanged = w != d->implicitWidth; | - | ||||||||||||||||||||||||
6826 | bool hChanged = h != d->implicitHeight; | - | ||||||||||||||||||||||||
6827 | - | |||||||||||||||||||||||||
6828 | d->implicitWidth = w; | - | ||||||||||||||||||||||||
6829 | d->implicitHeight = h; | - | ||||||||||||||||||||||||
6830 | - | |||||||||||||||||||||||||
6831 | bool wDone = false; | - | ||||||||||||||||||||||||
6832 | bool hDone = false; | - | ||||||||||||||||||||||||
6833 | if (d->width == w || widthValid()) {
| 6080-385358 | ||||||||||||||||||||||||
6834 | if (wChanged)
| 5992-144153 | ||||||||||||||||||||||||
6835 | d->implicitWidthChanged(); executed 5992 times by 23 tests: d->implicitWidthChanged(); Executed by:
| 5992 | ||||||||||||||||||||||||
6836 | wDone = d->width == w || widthValid();
| 0-144119 | ||||||||||||||||||||||||
6837 | wChanged = false; | - | ||||||||||||||||||||||||
6838 | } executed 150145 times by 44 tests: end of block Executed by:
| 150145 | ||||||||||||||||||||||||
6839 | if (d->height == h || heightValid()) {
| 6116-289015 | ||||||||||||||||||||||||
6840 | if (hChanged)
| 5351-241173 | ||||||||||||||||||||||||
6841 | d->implicitHeightChanged(); executed 5351 times by 24 tests: d->implicitHeightChanged(); Executed by:
| 5351 | ||||||||||||||||||||||||
6842 | hDone = d->height == h || heightValid();
| 0-240506 | ||||||||||||||||||||||||
6843 | hChanged = false; | - | ||||||||||||||||||||||||
6844 | } executed 246524 times by 43 tests: end of block Executed by:
| 246524 | ||||||||||||||||||||||||
6845 | if (wDone && hDone)
| 49165-379278 | ||||||||||||||||||||||||
6846 | return; executed 100980 times by 39 tests: return; Executed by:
| 100980 | ||||||||||||||||||||||||
6847 | - | |||||||||||||||||||||||||
6848 | qreal oldWidth = d->width; | - | ||||||||||||||||||||||||
6849 | qreal oldHeight = d->height; | - | ||||||||||||||||||||||||
6850 | if (!wDone)
| 49165-379278 | ||||||||||||||||||||||||
6851 | d->width = w; executed 379278 times by 48 tests: d->width = w; Executed by:
| 379278 | ||||||||||||||||||||||||
6852 | if (!hDone)
| 145544-282899 | ||||||||||||||||||||||||
6853 | d->height = h; executed 282899 times by 49 tests: d->height = h; Executed by:
| 282899 | ||||||||||||||||||||||||
6854 | - | |||||||||||||||||||||||||
6855 | d->dirty(QQuickItemPrivate::Size); | - | ||||||||||||||||||||||||
6856 | - | |||||||||||||||||||||||||
6857 | geometryChanged(QRectF(d->x, d->y, d->width, d->height), | - | ||||||||||||||||||||||||
6858 | QRectF(d->x, d->y, oldWidth, oldHeight)); | - | ||||||||||||||||||||||||
6859 | - | |||||||||||||||||||||||||
6860 | if (!wDone && wChanged)
| 0-379278 | ||||||||||||||||||||||||
6861 | d->implicitWidthChanged(); executed 379278 times by 48 tests: d->implicitWidthChanged(); Executed by:
| 379278 | ||||||||||||||||||||||||
6862 | if (!hDone && hChanged)
| 0-282899 | ||||||||||||||||||||||||
6863 | d->implicitHeightChanged(); executed 282899 times by 49 tests: d->implicitHeightChanged(); Executed by:
| 282899 | ||||||||||||||||||||||||
6864 | } executed 428443 times by 50 tests: end of block Executed by:
| 428443 | ||||||||||||||||||||||||
6865 | - | |||||||||||||||||||||||||
6866 | /*! | - | ||||||||||||||||||||||||
6867 | Returns whether the height property has been set explicitly. | - | ||||||||||||||||||||||||
6868 | */ | - | ||||||||||||||||||||||||
6869 | bool QQuickItem::heightValid() const | - | ||||||||||||||||||||||||
6870 | { | - | ||||||||||||||||||||||||
6871 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6872 | return d->heightValid; executed 1629752 times by 53 tests: return d->heightValid; Executed by:
| 1629752 | ||||||||||||||||||||||||
6873 | } | - | ||||||||||||||||||||||||
6874 | - | |||||||||||||||||||||||||
6875 | /*! | - | ||||||||||||||||||||||||
6876 | \since 5.10 | - | ||||||||||||||||||||||||
6877 | - | |||||||||||||||||||||||||
6878 | Returns the size of the item. | - | ||||||||||||||||||||||||
6879 | - | |||||||||||||||||||||||||
6880 | \sa setSize, width, height | - | ||||||||||||||||||||||||
6881 | */ | - | ||||||||||||||||||||||||
6882 | - | |||||||||||||||||||||||||
6883 | QSizeF QQuickItem::size() const | - | ||||||||||||||||||||||||
6884 | { | - | ||||||||||||||||||||||||
6885 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6886 | return QSizeF(d->width, d->height); executed 8978 times by 4 tests: return QSizeF(d->width, d->height); Executed by:
| 8978 | ||||||||||||||||||||||||
6887 | } | - | ||||||||||||||||||||||||
6888 | - | |||||||||||||||||||||||||
6889 | - | |||||||||||||||||||||||||
6890 | /*! | - | ||||||||||||||||||||||||
6891 | \since 5.10 | - | ||||||||||||||||||||||||
6892 | - | |||||||||||||||||||||||||
6893 | Sets the size of the item to \a size. | - | ||||||||||||||||||||||||
6894 | - | |||||||||||||||||||||||||
6895 | \sa size, setWidth, setHeight | - | ||||||||||||||||||||||||
6896 | */ | - | ||||||||||||||||||||||||
6897 | void QQuickItem::setSize(const QSizeF &size) | - | ||||||||||||||||||||||||
6898 | { | - | ||||||||||||||||||||||||
6899 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
6900 | d->heightValid = true; | - | ||||||||||||||||||||||||
6901 | d->widthValid = true; | - | ||||||||||||||||||||||||
6902 | - | |||||||||||||||||||||||||
6903 | if (d->width == size.width() && d->height == size.height())
| 882-15106 | ||||||||||||||||||||||||
6904 | return; executed 14224 times by 92 tests: return; Executed by:
| 14224 | ||||||||||||||||||||||||
6905 | - | |||||||||||||||||||||||||
6906 | qreal oldHeight = d->height; | - | ||||||||||||||||||||||||
6907 | qreal oldWidth = d->width; | - | ||||||||||||||||||||||||
6908 | d->height = size.height(); | - | ||||||||||||||||||||||||
6909 | d->width = size.width(); | - | ||||||||||||||||||||||||
6910 | - | |||||||||||||||||||||||||
6911 | d->dirty(QQuickItemPrivate::Size); | - | ||||||||||||||||||||||||
6912 | - | |||||||||||||||||||||||||
6913 | geometryChanged(QRectF(d->x, d->y, d->width, d->height), | - | ||||||||||||||||||||||||
6914 | QRectF(d->x, d->y, oldWidth, oldHeight)); | - | ||||||||||||||||||||||||
6915 | } executed 12878 times by 82 tests: end of block Executed by:
| 12878 | ||||||||||||||||||||||||
6916 | - | |||||||||||||||||||||||||
6917 | /*! | - | ||||||||||||||||||||||||
6918 | \qmlproperty bool QtQuick::Item::activeFocus | - | ||||||||||||||||||||||||
6919 | - | |||||||||||||||||||||||||
6920 | This read-only property indicates whether the item has active focus. | - | ||||||||||||||||||||||||
6921 | - | |||||||||||||||||||||||||
6922 | If activeFocus is true, either this item is the one that currently | - | ||||||||||||||||||||||||
6923 | receives keyboard input, or it is a FocusScope ancestor of the item | - | ||||||||||||||||||||||||
6924 | that currently receives keyboard input. | - | ||||||||||||||||||||||||
6925 | - | |||||||||||||||||||||||||
6926 | Usually, activeFocus is gained by setting \l focus on an item and its | - | ||||||||||||||||||||||||
6927 | enclosing FocusScope objects. In the following example, the \c input | - | ||||||||||||||||||||||||
6928 | and \c focusScope objects will have active focus, while the root | - | ||||||||||||||||||||||||
6929 | rectangle object will not. | - | ||||||||||||||||||||||||
6930 | - | |||||||||||||||||||||||||
6931 | \qml | - | ||||||||||||||||||||||||
6932 | import QtQuick 2.0 | - | ||||||||||||||||||||||||
6933 | - | |||||||||||||||||||||||||
6934 | Rectangle { | - | ||||||||||||||||||||||||
6935 | width: 100; height: 100 | - | ||||||||||||||||||||||||
6936 | - | |||||||||||||||||||||||||
6937 | FocusScope { | - | ||||||||||||||||||||||||
6938 | id: focusScope | - | ||||||||||||||||||||||||
6939 | focus: true | - | ||||||||||||||||||||||||
6940 | - | |||||||||||||||||||||||||
6941 | TextInput { | - | ||||||||||||||||||||||||
6942 | id: input | - | ||||||||||||||||||||||||
6943 | focus: true | - | ||||||||||||||||||||||||
6944 | } | - | ||||||||||||||||||||||||
6945 | } | - | ||||||||||||||||||||||||
6946 | } | - | ||||||||||||||||||||||||
6947 | \endqml | - | ||||||||||||||||||||||||
6948 | - | |||||||||||||||||||||||||
6949 | \sa focus, {Keyboard Focus in Qt Quick} | - | ||||||||||||||||||||||||
6950 | */ | - | ||||||||||||||||||||||||
6951 | /*! | - | ||||||||||||||||||||||||
6952 | \property QQuickItem::activeFocus | - | ||||||||||||||||||||||||
6953 | - | |||||||||||||||||||||||||
6954 | This read-only property indicates whether the item has active focus. | - | ||||||||||||||||||||||||
6955 | - | |||||||||||||||||||||||||
6956 | If activeFocus is true, either this item is the one that currently | - | ||||||||||||||||||||||||
6957 | receives keyboard input, or it is a FocusScope ancestor of the item | - | ||||||||||||||||||||||||
6958 | that currently receives keyboard input. | - | ||||||||||||||||||||||||
6959 | - | |||||||||||||||||||||||||
6960 | Usually, activeFocus is gained by setting \l focus on an item and its | - | ||||||||||||||||||||||||
6961 | enclosing FocusScope objects. In the following example, the \c input | - | ||||||||||||||||||||||||
6962 | and \c focusScope objects will have active focus, while the root | - | ||||||||||||||||||||||||
6963 | rectangle object will not. | - | ||||||||||||||||||||||||
6964 | - | |||||||||||||||||||||||||
6965 | \qml | - | ||||||||||||||||||||||||
6966 | import QtQuick 2.0 | - | ||||||||||||||||||||||||
6967 | - | |||||||||||||||||||||||||
6968 | Rectangle { | - | ||||||||||||||||||||||||
6969 | width: 100; height: 100 | - | ||||||||||||||||||||||||
6970 | - | |||||||||||||||||||||||||
6971 | FocusScope { | - | ||||||||||||||||||||||||
6972 | focus: true | - | ||||||||||||||||||||||||
6973 | - | |||||||||||||||||||||||||
6974 | TextInput { | - | ||||||||||||||||||||||||
6975 | id: input | - | ||||||||||||||||||||||||
6976 | focus: true | - | ||||||||||||||||||||||||
6977 | } | - | ||||||||||||||||||||||||
6978 | } | - | ||||||||||||||||||||||||
6979 | } | - | ||||||||||||||||||||||||
6980 | \endqml | - | ||||||||||||||||||||||||
6981 | - | |||||||||||||||||||||||||
6982 | \sa focus, {Keyboard Focus in Qt Quick} | - | ||||||||||||||||||||||||
6983 | */ | - | ||||||||||||||||||||||||
6984 | bool QQuickItem::hasActiveFocus() const | - | ||||||||||||||||||||||||
6985 | { | - | ||||||||||||||||||||||||
6986 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
6987 | return d->activeFocus; executed 29194 times by 25 tests: return d->activeFocus; Executed by:
| 29194 | ||||||||||||||||||||||||
6988 | } | - | ||||||||||||||||||||||||
6989 | - | |||||||||||||||||||||||||
6990 | /*! | - | ||||||||||||||||||||||||
6991 | \qmlproperty bool QtQuick::Item::focus | - | ||||||||||||||||||||||||
6992 | - | |||||||||||||||||||||||||
6993 | This property holds whether the item has focus within the enclosing | - | ||||||||||||||||||||||||
6994 | FocusScope. If true, this item will gain active focus when the | - | ||||||||||||||||||||||||
6995 | enclosing FocusScope gains active focus. | - | ||||||||||||||||||||||||
6996 | - | |||||||||||||||||||||||||
6997 | In the following example, \c input will be given active focus when | - | ||||||||||||||||||||||||
6998 | \c scope gains active focus: | - | ||||||||||||||||||||||||
6999 | - | |||||||||||||||||||||||||
7000 | \qml | - | ||||||||||||||||||||||||
7001 | import QtQuick 2.0 | - | ||||||||||||||||||||||||
7002 | - | |||||||||||||||||||||||||
7003 | Rectangle { | - | ||||||||||||||||||||||||
7004 | width: 100; height: 100 | - | ||||||||||||||||||||||||
7005 | - | |||||||||||||||||||||||||
7006 | FocusScope { | - | ||||||||||||||||||||||||
7007 | id: scope | - | ||||||||||||||||||||||||
7008 | - | |||||||||||||||||||||||||
7009 | TextInput { | - | ||||||||||||||||||||||||
7010 | id: input | - | ||||||||||||||||||||||||
7011 | focus: true | - | ||||||||||||||||||||||||
7012 | } | - | ||||||||||||||||||||||||
7013 | } | - | ||||||||||||||||||||||||
7014 | } | - | ||||||||||||||||||||||||
7015 | \endqml | - | ||||||||||||||||||||||||
7016 | - | |||||||||||||||||||||||||
7017 | For the purposes of this property, the scene as a whole is assumed | - | ||||||||||||||||||||||||
7018 | to act like a focus scope. On a practical level, that means the | - | ||||||||||||||||||||||||
7019 | following QML will give active focus to \c input on startup. | - | ||||||||||||||||||||||||
7020 | - | |||||||||||||||||||||||||
7021 | \qml | - | ||||||||||||||||||||||||
7022 | Rectangle { | - | ||||||||||||||||||||||||
7023 | width: 100; height: 100 | - | ||||||||||||||||||||||||
7024 | - | |||||||||||||||||||||||||
7025 | TextInput { | - | ||||||||||||||||||||||||
7026 | id: input | - | ||||||||||||||||||||||||
7027 | focus: true | - | ||||||||||||||||||||||||
7028 | } | - | ||||||||||||||||||||||||
7029 | } | - | ||||||||||||||||||||||||
7030 | \endqml | - | ||||||||||||||||||||||||
7031 | - | |||||||||||||||||||||||||
7032 | \sa activeFocus, {Keyboard Focus in Qt Quick} | - | ||||||||||||||||||||||||
7033 | */ | - | ||||||||||||||||||||||||
7034 | /*! | - | ||||||||||||||||||||||||
7035 | \property QQuickItem::focus | - | ||||||||||||||||||||||||
7036 | - | |||||||||||||||||||||||||
7037 | This property holds whether the item has focus within the enclosing | - | ||||||||||||||||||||||||
7038 | FocusScope. If true, this item will gain active focus when the | - | ||||||||||||||||||||||||
7039 | enclosing FocusScope gains active focus. | - | ||||||||||||||||||||||||
7040 | - | |||||||||||||||||||||||||
7041 | In the following example, \c input will be given active focus when | - | ||||||||||||||||||||||||
7042 | \c scope gains active focus: | - | ||||||||||||||||||||||||
7043 | - | |||||||||||||||||||||||||
7044 | \qml | - | ||||||||||||||||||||||||
7045 | import QtQuick 2.0 | - | ||||||||||||||||||||||||
7046 | - | |||||||||||||||||||||||||
7047 | Rectangle { | - | ||||||||||||||||||||||||
7048 | width: 100; height: 100 | - | ||||||||||||||||||||||||
7049 | - | |||||||||||||||||||||||||
7050 | FocusScope { | - | ||||||||||||||||||||||||
7051 | id: scope | - | ||||||||||||||||||||||||
7052 | - | |||||||||||||||||||||||||
7053 | TextInput { | - | ||||||||||||||||||||||||
7054 | id: input | - | ||||||||||||||||||||||||
7055 | focus: true | - | ||||||||||||||||||||||||
7056 | } | - | ||||||||||||||||||||||||
7057 | } | - | ||||||||||||||||||||||||
7058 | } | - | ||||||||||||||||||||||||
7059 | \endqml | - | ||||||||||||||||||||||||
7060 | - | |||||||||||||||||||||||||
7061 | For the purposes of this property, the scene as a whole is assumed | - | ||||||||||||||||||||||||
7062 | to act like a focus scope. On a practical level, that means the | - | ||||||||||||||||||||||||
7063 | following QML will give active focus to \c input on startup. | - | ||||||||||||||||||||||||
7064 | - | |||||||||||||||||||||||||
7065 | \qml | - | ||||||||||||||||||||||||
7066 | Rectangle { | - | ||||||||||||||||||||||||
7067 | width: 100; height: 100 | - | ||||||||||||||||||||||||
7068 | - | |||||||||||||||||||||||||
7069 | TextInput { | - | ||||||||||||||||||||||||
7070 | id: input | - | ||||||||||||||||||||||||
7071 | focus: true | - | ||||||||||||||||||||||||
7072 | } | - | ||||||||||||||||||||||||
7073 | } | - | ||||||||||||||||||||||||
7074 | \endqml | - | ||||||||||||||||||||||||
7075 | - | |||||||||||||||||||||||||
7076 | \sa activeFocus, {Keyboard Focus in Qt Quick} | - | ||||||||||||||||||||||||
7077 | */ | - | ||||||||||||||||||||||||
7078 | bool QQuickItem::hasFocus() const | - | ||||||||||||||||||||||||
7079 | { | - | ||||||||||||||||||||||||
7080 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7081 | return d->focus; executed 821692 times by 106 tests: return d->focus; Executed by:
| 821692 | ||||||||||||||||||||||||
7082 | } | - | ||||||||||||||||||||||||
7083 | - | |||||||||||||||||||||||||
7084 | void QQuickItem::setFocus(bool focus) | - | ||||||||||||||||||||||||
7085 | { | - | ||||||||||||||||||||||||
7086 | setFocus(focus, Qt::OtherFocusReason); | - | ||||||||||||||||||||||||
7087 | } executed 9981 times by 19 tests: end of block Executed by:
| 9981 | ||||||||||||||||||||||||
7088 | - | |||||||||||||||||||||||||
7089 | void QQuickItem::setFocus(bool focus, Qt::FocusReason reason) | - | ||||||||||||||||||||||||
7090 | { | - | ||||||||||||||||||||||||
7091 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7092 | if (d->focus == focus)
| 2486-10551 | ||||||||||||||||||||||||
7093 | return; executed 2486 times by 10 tests: return; Executed by:
| 2486 | ||||||||||||||||||||||||
7094 | - | |||||||||||||||||||||||||
7095 | if (d->window || d->parentItem) {
| 1986-5686 | ||||||||||||||||||||||||
7096 | // Need to find our nearest focus scope | - | ||||||||||||||||||||||||
7097 | QQuickItem *scope = parentItem(); | - | ||||||||||||||||||||||||
7098 | while (scope && !scope->isFocusScope() && scope->parentItem())
| 36-13925 | ||||||||||||||||||||||||
7099 | scope = scope->parentItem(); executed 6458 times by 17 tests: scope = scope->parentItem(); Executed by:
| 6458 | ||||||||||||||||||||||||
7100 | if (d->window) {
| 3700-4865 | ||||||||||||||||||||||||
7101 | if (reason != Qt::PopupFocusReason) {
| 4-4861 | ||||||||||||||||||||||||
7102 | if (focus)
| 90-4771 | ||||||||||||||||||||||||
7103 | QQuickWindowPrivate::get(d->window)->setFocusInScope(scope, this, reason); executed 4771 times by 20 tests: QQuickWindowPrivate::get(d->window)->setFocusInScope(scope, this, reason); Executed by:
| 4771 | ||||||||||||||||||||||||
7104 | else | - | ||||||||||||||||||||||||
7105 | QQuickWindowPrivate::get(d->window)->clearFocusInScope(scope, this, reason); executed 90 times by 6 tests: QQuickWindowPrivate::get(d->window)->clearFocusInScope(scope, this, reason); Executed by:
| 90 | ||||||||||||||||||||||||
7106 | } | - | ||||||||||||||||||||||||
7107 | } else { executed 4865 times by 20 tests: end of block Executed by:
| 4865 | ||||||||||||||||||||||||
7108 | // do the focus changes from setFocusInScope/clearFocusInScope that are | - | ||||||||||||||||||||||||
7109 | // unrelated to a window | - | ||||||||||||||||||||||||
7110 | QVarLengthArray<QQuickItem *, 20> changed; | - | ||||||||||||||||||||||||
7111 | QQuickItem *oldSubFocusItem = QQuickItemPrivate::get(scope)->subFocusItem; | - | ||||||||||||||||||||||||
7112 | if (oldSubFocusItem) {
| 132-3568 | ||||||||||||||||||||||||
7113 | QQuickItemPrivate::get(oldSubFocusItem)->updateSubFocusItem(scope, false); | - | ||||||||||||||||||||||||
7114 | QQuickItemPrivate::get(oldSubFocusItem)->focus = false; | - | ||||||||||||||||||||||||
7115 | changed << oldSubFocusItem; | - | ||||||||||||||||||||||||
7116 | } else if (!scope->isFocusScope() && scope->hasFocus()) { executed 132 times by 4 tests: end of block Executed by:
| 10-3542 | ||||||||||||||||||||||||
7117 | QQuickItemPrivate::get(scope)->focus = false; | - | ||||||||||||||||||||||||
7118 | changed << scope; | - | ||||||||||||||||||||||||
7119 | } executed 16 times by 2 tests: end of block Executed by:
| 16 | ||||||||||||||||||||||||
7120 | d->updateSubFocusItem(scope, focus); | - | ||||||||||||||||||||||||
7121 | - | |||||||||||||||||||||||||
7122 | d->focus = focus; | - | ||||||||||||||||||||||||
7123 | changed << this; | - | ||||||||||||||||||||||||
7124 | emit focusChanged(focus); | - | ||||||||||||||||||||||||
7125 | - | |||||||||||||||||||||||||
7126 | QQuickWindowPrivate::notifyFocusChangesRecur(changed.data(), changed.count() - 1); | - | ||||||||||||||||||||||||
7127 | } executed 3700 times by 14 tests: end of block Executed by:
| 3700 | ||||||||||||||||||||||||
7128 | } else { | - | ||||||||||||||||||||||||
7129 | QVarLengthArray<QQuickItem *, 20> changed; | - | ||||||||||||||||||||||||
7130 | QQuickItem *oldSubFocusItem = d->subFocusItem; | - | ||||||||||||||||||||||||
7131 | if (!isFocusScope() && oldSubFocusItem) {
| 2-1186 | ||||||||||||||||||||||||
7132 | QQuickItemPrivate::get(oldSubFocusItem)->updateSubFocusItem(this, false); | - | ||||||||||||||||||||||||
7133 | QQuickItemPrivate::get(oldSubFocusItem)->focus = false; | - | ||||||||||||||||||||||||
7134 | changed << oldSubFocusItem; | - | ||||||||||||||||||||||||
7135 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
7136 | - | |||||||||||||||||||||||||
7137 | d->focus = focus; | - | ||||||||||||||||||||||||
7138 | changed << this; | - | ||||||||||||||||||||||||
7139 | emit focusChanged(focus); | - | ||||||||||||||||||||||||
7140 | - | |||||||||||||||||||||||||
7141 | QQuickWindowPrivate::notifyFocusChangesRecur(changed.data(), changed.count() - 1); | - | ||||||||||||||||||||||||
7142 | } executed 1986 times by 13 tests: end of block Executed by:
| 1986 | ||||||||||||||||||||||||
7143 | } | - | ||||||||||||||||||||||||
7144 | - | |||||||||||||||||||||||||
7145 | /*! | - | ||||||||||||||||||||||||
7146 | Returns true if this item is a focus scope, and false otherwise. | - | ||||||||||||||||||||||||
7147 | */ | - | ||||||||||||||||||||||||
7148 | bool QQuickItem::isFocusScope() const | - | ||||||||||||||||||||||||
7149 | { | - | ||||||||||||||||||||||||
7150 | return flags() & ItemIsFocusScope; executed 854245 times by 106 tests: return flags() & ItemIsFocusScope; Executed by:
| 854245 | ||||||||||||||||||||||||
7151 | } | - | ||||||||||||||||||||||||
7152 | - | |||||||||||||||||||||||||
7153 | /*! | - | ||||||||||||||||||||||||
7154 | If this item is a focus scope, this returns the item in its focus chain | - | ||||||||||||||||||||||||
7155 | that currently has focus. | - | ||||||||||||||||||||||||
7156 | - | |||||||||||||||||||||||||
7157 | Returns 0 if this item is not a focus scope. | - | ||||||||||||||||||||||||
7158 | */ | - | ||||||||||||||||||||||||
7159 | QQuickItem *QQuickItem::scopedFocusItem() const | - | ||||||||||||||||||||||||
7160 | { | - | ||||||||||||||||||||||||
7161 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7162 | if (!isFocusScope())
| 0-2608 | ||||||||||||||||||||||||
7163 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
7164 | else | - | ||||||||||||||||||||||||
7165 | return d->subFocusItem; executed 2608 times by 18 tests: return d->subFocusItem; Executed by:
| 2608 | ||||||||||||||||||||||||
7166 | } | - | ||||||||||||||||||||||||
7167 | - | |||||||||||||||||||||||||
7168 | /*! | - | ||||||||||||||||||||||||
7169 | Returns \c true if this item is an ancestor of \a child (i.e., if this item | - | ||||||||||||||||||||||||
7170 | is \a child's parent, or one of \a child's parent's ancestors). | - | ||||||||||||||||||||||||
7171 | - | |||||||||||||||||||||||||
7172 | \since 5.7 | - | ||||||||||||||||||||||||
7173 | - | |||||||||||||||||||||||||
7174 | \sa parentItem() | - | ||||||||||||||||||||||||
7175 | */ | - | ||||||||||||||||||||||||
7176 | bool QQuickItem::isAncestorOf(const QQuickItem *child) const | - | ||||||||||||||||||||||||
7177 | { | - | ||||||||||||||||||||||||
7178 | if (!child || child == this)
| 0-32 | ||||||||||||||||||||||||
7179 | return false; executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||||||||||||||
7180 | const QQuickItem *ancestor = child; | - | ||||||||||||||||||||||||
7181 | while ((ancestor = ancestor->parentItem())) {
| 8-44 | ||||||||||||||||||||||||
7182 | if (ancestor == this)
| 20-24 | ||||||||||||||||||||||||
7183 | return true; executed 20 times by 1 test: return true; Executed by:
| 20 | ||||||||||||||||||||||||
7184 | } executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||||||||||||||||||||
7185 | return false; executed 8 times by 1 test: return false; Executed by:
| 8 | ||||||||||||||||||||||||
7186 | } | - | ||||||||||||||||||||||||
7187 | - | |||||||||||||||||||||||||
7188 | /*! | - | ||||||||||||||||||||||||
7189 | Returns the mouse buttons accepted by this item. | - | ||||||||||||||||||||||||
7190 | - | |||||||||||||||||||||||||
7191 | The default value is Qt::NoButton; that is, no mouse buttons are accepted. | - | ||||||||||||||||||||||||
7192 | - | |||||||||||||||||||||||||
7193 | If an item does not accept the mouse button for a particular mouse event, | - | ||||||||||||||||||||||||
7194 | the mouse event will not be delivered to the item and will be delivered | - | ||||||||||||||||||||||||
7195 | to the next item in the item hierarchy instead. | - | ||||||||||||||||||||||||
7196 | */ | - | ||||||||||||||||||||||||
7197 | Qt::MouseButtons QQuickItem::acceptedMouseButtons() const | - | ||||||||||||||||||||||||
7198 | { | - | ||||||||||||||||||||||||
7199 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7200 | return d->acceptedMouseButtons(); executed 19558 times by 19 tests: return d->acceptedMouseButtons(); Executed by:
| 19558 | ||||||||||||||||||||||||
7201 | } | - | ||||||||||||||||||||||||
7202 | - | |||||||||||||||||||||||||
7203 | /*! | - | ||||||||||||||||||||||||
7204 | Sets the mouse buttons accepted by this item to \a buttons. | - | ||||||||||||||||||||||||
7205 | */ | - | ||||||||||||||||||||||||
7206 | void QQuickItem::setAcceptedMouseButtons(Qt::MouseButtons buttons) | - | ||||||||||||||||||||||||
7207 | { | - | ||||||||||||||||||||||||
7208 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7209 | if (buttons & Qt::LeftButton)
| 74-274638 | ||||||||||||||||||||||||
7210 | d->extra.setFlag(); executed 274638 times by 53 tests: d->extra.setFlag(); Executed by:
| 274638 | ||||||||||||||||||||||||
7211 | else | - | ||||||||||||||||||||||||
7212 | d->extra.clearFlag(); executed 74 times by 3 tests: d->extra.clearFlag(); Executed by:
| 74 | ||||||||||||||||||||||||
7213 | - | |||||||||||||||||||||||||
7214 | buttons &= ~Qt::LeftButton; | - | ||||||||||||||||||||||||
7215 | if (buttons || d->extra.isAllocated())
| 4108-267412 | ||||||||||||||||||||||||
7216 | d->extra.value().acceptedMouseButtons = buttons; executed 7300 times by 28 tests: d->extra.value().acceptedMouseButtons = buttons; Executed by:
| 7300 | ||||||||||||||||||||||||
7217 | } executed 274712 times by 53 tests: end of block Executed by:
| 274712 | ||||||||||||||||||||||||
7218 | - | |||||||||||||||||||||||||
7219 | /*! | - | ||||||||||||||||||||||||
7220 | Returns whether mouse and touch events of this item's children should be filtered | - | ||||||||||||||||||||||||
7221 | through this item. | - | ||||||||||||||||||||||||
7222 | - | |||||||||||||||||||||||||
7223 | \sa setFiltersChildMouseEvents(), childMouseEventFilter() | - | ||||||||||||||||||||||||
7224 | */ | - | ||||||||||||||||||||||||
7225 | bool QQuickItem::filtersChildMouseEvents() const | - | ||||||||||||||||||||||||
7226 | { | - | ||||||||||||||||||||||||
7227 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7228 | return d->filtersChildMouseEvents; executed 24837 times by 16 tests: return d->filtersChildMouseEvents; Executed by:
| 24837 | ||||||||||||||||||||||||
7229 | } | - | ||||||||||||||||||||||||
7230 | - | |||||||||||||||||||||||||
7231 | /*! | - | ||||||||||||||||||||||||
7232 | Sets whether mouse and touch events of this item's children should be filtered | - | ||||||||||||||||||||||||
7233 | through this item. | - | ||||||||||||||||||||||||
7234 | - | |||||||||||||||||||||||||
7235 | If \a filter is true, childMouseEventFilter() will be called when | - | ||||||||||||||||||||||||
7236 | a mouse event is triggered for a child item. | - | ||||||||||||||||||||||||
7237 | - | |||||||||||||||||||||||||
7238 | \sa filtersChildMouseEvents() | - | ||||||||||||||||||||||||
7239 | */ | - | ||||||||||||||||||||||||
7240 | void QQuickItem::setFiltersChildMouseEvents(bool filter) | - | ||||||||||||||||||||||||
7241 | { | - | ||||||||||||||||||||||||
7242 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7243 | d->filtersChildMouseEvents = filter; | - | ||||||||||||||||||||||||
7244 | } executed 6488 times by 32 tests: end of block Executed by:
| 6488 | ||||||||||||||||||||||||
7245 | - | |||||||||||||||||||||||||
7246 | /*! | - | ||||||||||||||||||||||||
7247 | \internal | - | ||||||||||||||||||||||||
7248 | */ | - | ||||||||||||||||||||||||
7249 | bool QQuickItem::isUnderMouse() const | - | ||||||||||||||||||||||||
7250 | { | - | ||||||||||||||||||||||||
7251 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7252 | if (!d->window)
| 0-40 | ||||||||||||||||||||||||
7253 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
7254 | - | |||||||||||||||||||||||||
7255 | QPointF cursorPos = QGuiApplicationPrivate::lastCursorPosition; | - | ||||||||||||||||||||||||
7256 | return contains(mapFromScene(d->window->mapFromGlobal(cursorPos.toPoint()))); executed 40 times by 3 tests: return contains(mapFromScene(d->window->mapFromGlobal(cursorPos.toPoint()))); Executed by:
| 40 | ||||||||||||||||||||||||
7257 | } | - | ||||||||||||||||||||||||
7258 | - | |||||||||||||||||||||||||
7259 | /*! | - | ||||||||||||||||||||||||
7260 | Returns whether hover events are accepted by this item. | - | ||||||||||||||||||||||||
7261 | - | |||||||||||||||||||||||||
7262 | The default value is false. | - | ||||||||||||||||||||||||
7263 | - | |||||||||||||||||||||||||
7264 | If this is false, then the item will not receive any hover events through | - | ||||||||||||||||||||||||
7265 | the hoverEnterEvent(), hoverMoveEvent() and hoverLeaveEvent() functions. | - | ||||||||||||||||||||||||
7266 | */ | - | ||||||||||||||||||||||||
7267 | bool QQuickItem::acceptHoverEvents() const | - | ||||||||||||||||||||||||
7268 | { | - | ||||||||||||||||||||||||
7269 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7270 | return d->hoverEnabled; executed 508 times by 14 tests: return d->hoverEnabled; Executed by:
| 508 | ||||||||||||||||||||||||
7271 | } | - | ||||||||||||||||||||||||
7272 | - | |||||||||||||||||||||||||
7273 | /*! | - | ||||||||||||||||||||||||
7274 | If \a enabled is true, this sets the item to accept hover events; | - | ||||||||||||||||||||||||
7275 | otherwise, hover events are not accepted by this item. | - | ||||||||||||||||||||||||
7276 | - | |||||||||||||||||||||||||
7277 | \sa acceptHoverEvents() | - | ||||||||||||||||||||||||
7278 | */ | - | ||||||||||||||||||||||||
7279 | void QQuickItem::setAcceptHoverEvents(bool enabled) | - | ||||||||||||||||||||||||
7280 | { | - | ||||||||||||||||||||||||
7281 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7282 | d->hoverEnabled = enabled; | - | ||||||||||||||||||||||||
7283 | d->setHasHoverInChild(enabled); | - | ||||||||||||||||||||||||
7284 | } executed 423030 times by 38 tests: end of block Executed by:
| 423030 | ||||||||||||||||||||||||
7285 | - | |||||||||||||||||||||||||
7286 | /*! | - | ||||||||||||||||||||||||
7287 | Returns whether touch events are accepted by this item. | - | ||||||||||||||||||||||||
7288 | - | |||||||||||||||||||||||||
7289 | The default value is false. | - | ||||||||||||||||||||||||
7290 | - | |||||||||||||||||||||||||
7291 | If this is false, then the item will not receive any touch events through | - | ||||||||||||||||||||||||
7292 | the touchEvent() function. | - | ||||||||||||||||||||||||
7293 | - | |||||||||||||||||||||||||
7294 | \since 5.10 | - | ||||||||||||||||||||||||
7295 | */ | - | ||||||||||||||||||||||||
7296 | bool QQuickItem::acceptTouchEvents() const | - | ||||||||||||||||||||||||
7297 | { | - | ||||||||||||||||||||||||
7298 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7299 | return d->touchEnabled; executed 3224 times by 10 tests: return d->touchEnabled; Executed by:
| 3224 | ||||||||||||||||||||||||
7300 | } | - | ||||||||||||||||||||||||
7301 | - | |||||||||||||||||||||||||
7302 | /*! | - | ||||||||||||||||||||||||
7303 | If \a enabled is true, this sets the item to accept touch events; | - | ||||||||||||||||||||||||
7304 | otherwise, touch events are not accepted by this item. | - | ||||||||||||||||||||||||
7305 | - | |||||||||||||||||||||||||
7306 | \since 5.10 | - | ||||||||||||||||||||||||
7307 | - | |||||||||||||||||||||||||
7308 | \sa acceptTouchEvents() | - | ||||||||||||||||||||||||
7309 | */ | - | ||||||||||||||||||||||||
7310 | void QQuickItem::setAcceptTouchEvents(bool enabled) | - | ||||||||||||||||||||||||
7311 | { | - | ||||||||||||||||||||||||
7312 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7313 | d->touchEnabled = enabled; | - | ||||||||||||||||||||||||
7314 | } executed 101012 times by 87 tests: end of block Executed by:
| 101012 | ||||||||||||||||||||||||
7315 | - | |||||||||||||||||||||||||
7316 | void QQuickItemPrivate::setHasCursorInChild(bool hasCursor) | - | ||||||||||||||||||||||||
7317 | { | - | ||||||||||||||||||||||||
7318 | #if QT_CONFIG(cursor) | - | ||||||||||||||||||||||||
7319 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
7320 | - | |||||||||||||||||||||||||
7321 | // if we're asked to turn it off (because of an unsetcursor call, or a node | - | ||||||||||||||||||||||||
7322 | // removal) then we should make sure it's really ok to turn it off. | - | ||||||||||||||||||||||||
7323 | if (!hasCursor && subtreeCursorEnabled) {
| 0-5338 | ||||||||||||||||||||||||
7324 | if (hasCursor)
| 0-4630 | ||||||||||||||||||||||||
7325 | return; // nope! sorry, I have a cursor myself never executed: return; | 0 | ||||||||||||||||||||||||
7326 | for (QQuickItem *otherChild : qAsConst(childItems)) { | - | ||||||||||||||||||||||||
7327 | QQuickItemPrivate *otherChildPrivate = QQuickItemPrivate::get(otherChild); | - | ||||||||||||||||||||||||
7328 | if (otherChildPrivate->subtreeCursorEnabled || otherChildPrivate->hasCursor)
| 0-2726 | ||||||||||||||||||||||||
7329 | return; // nope! sorry, something else wants it kept on. executed 1340 times by 8 tests: return; Executed by:
| 1340 | ||||||||||||||||||||||||
7330 | } executed 2726 times by 12 tests: end of block Executed by:
| 2726 | ||||||||||||||||||||||||
7331 | } executed 3290 times by 21 tests: end of block Executed by:
| 3290 | ||||||||||||||||||||||||
7332 | - | |||||||||||||||||||||||||
7333 | subtreeCursorEnabled = hasCursor; | - | ||||||||||||||||||||||||
7334 | QQuickItem *parent = q->parentItem(); | - | ||||||||||||||||||||||||
7335 | if (parent) {
| 456-8172 | ||||||||||||||||||||||||
7336 | QQuickItemPrivate *parentPrivate = QQuickItemPrivate::get(parent); | - | ||||||||||||||||||||||||
7337 | parentPrivate->setHasCursorInChild(hasCursor); | - | ||||||||||||||||||||||||
7338 | } executed 456 times by 8 tests: end of block Executed by:
| 456 | ||||||||||||||||||||||||
7339 | #else | - | ||||||||||||||||||||||||
7340 | Q_UNUSED(hasCursor); | - | ||||||||||||||||||||||||
7341 | #endif | - | ||||||||||||||||||||||||
7342 | } executed 8628 times by 23 tests: end of block Executed by:
| 8628 | ||||||||||||||||||||||||
7343 | - | |||||||||||||||||||||||||
7344 | void QQuickItemPrivate::setHasHoverInChild(bool hasHover) | - | ||||||||||||||||||||||||
7345 | { | - | ||||||||||||||||||||||||
7346 | Q_Q(QQuickItem); | - | ||||||||||||||||||||||||
7347 | - | |||||||||||||||||||||||||
7348 | // if we're asked to turn it off (because of a setAcceptHoverEvents call, or a node | - | ||||||||||||||||||||||||
7349 | // removal) then we should make sure it's really ok to turn it off. | - | ||||||||||||||||||||||||
7350 | if (!hasHover && subtreeHoverEnabled) {
| 2656-2343131 | ||||||||||||||||||||||||
7351 | if (hoverEnabled)
| 214-2442 | ||||||||||||||||||||||||
7352 | return; // nope! sorry, I need hover myself executed 214 times by 4 tests: return; Executed by:
| 214 | ||||||||||||||||||||||||
7353 | for (QQuickItem *otherChild : qAsConst(childItems)) { | - | ||||||||||||||||||||||||
7354 | QQuickItemPrivate *otherChildPrivate = QQuickItemPrivate::get(otherChild); | - | ||||||||||||||||||||||||
7355 | if (otherChildPrivate->subtreeHoverEnabled || otherChildPrivate->hoverEnabled)
| 0-814 | ||||||||||||||||||||||||
7356 | return; // nope! sorry, something else wants it kept on. executed 814 times by 10 tests: return; Executed by:
| 814 | ||||||||||||||||||||||||
7357 | if (otherChildPrivate->hasHoverHandlers())
| 0-662 | ||||||||||||||||||||||||
7358 | return; // nope! sorry, we have pointer handlers which are interested. never executed: return; | 0 | ||||||||||||||||||||||||
7359 | } executed 662 times by 7 tests: end of block Executed by:
| 662 | ||||||||||||||||||||||||
7360 | } executed 1628 times by 13 tests: end of block Executed by:
| 1628 | ||||||||||||||||||||||||
7361 | - | |||||||||||||||||||||||||
7362 | qCDebug(DBG_HOVER_TRACE) << q << subtreeHoverEnabled << "->" << hasHover; never executed: QMessageLogger(__FILE__, 7362, __PRETTY_FUNCTION__, DBG_HOVER_TRACE().categoryName()).debug() << q << subtreeHoverEnabled << "->" << hasHover;
| 0-2348173 | ||||||||||||||||||||||||
7363 | subtreeHoverEnabled = hasHover; | - | ||||||||||||||||||||||||
7364 | QQuickItem *parent = q->parentItem(); | - | ||||||||||||||||||||||||
7365 | if (parent) {
| 425014-1923159 | ||||||||||||||||||||||||
7366 | QQuickItemPrivate *parentPrivate = QQuickItemPrivate::get(parent); | - | ||||||||||||||||||||||||
7367 | parentPrivate->setHasHoverInChild(hasHover); | - | ||||||||||||||||||||||||
7368 | } executed 1923159 times by 24 tests: end of block Executed by:
| 1923159 | ||||||||||||||||||||||||
7369 | } executed 2348173 times by 38 tests: end of block Executed by:
| 2348173 | ||||||||||||||||||||||||
7370 | - | |||||||||||||||||||||||||
7371 | #if QT_CONFIG(cursor) | - | ||||||||||||||||||||||||
7372 | - | |||||||||||||||||||||||||
7373 | /*! | - | ||||||||||||||||||||||||
7374 | Returns the cursor shape for this item. | - | ||||||||||||||||||||||||
7375 | - | |||||||||||||||||||||||||
7376 | The mouse cursor will assume this shape when it is over this | - | ||||||||||||||||||||||||
7377 | item, unless an override cursor is set. | - | ||||||||||||||||||||||||
7378 | See the \l{Qt::CursorShape}{list of predefined cursor objects} for a | - | ||||||||||||||||||||||||
7379 | range of useful shapes. | - | ||||||||||||||||||||||||
7380 | - | |||||||||||||||||||||||||
7381 | If no cursor shape has been set this returns a cursor with the Qt::ArrowCursor shape, however | - | ||||||||||||||||||||||||
7382 | another cursor shape may be displayed if an overlapping item has a valid cursor. | - | ||||||||||||||||||||||||
7383 | - | |||||||||||||||||||||||||
7384 | \sa setCursor(), unsetCursor() | - | ||||||||||||||||||||||||
7385 | */ | - | ||||||||||||||||||||||||
7386 | - | |||||||||||||||||||||||||
7387 | QCursor QQuickItem::cursor() const | - | ||||||||||||||||||||||||
7388 | { | - | ||||||||||||||||||||||||
7389 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7390 | return d->extra.isAllocated() executed 202 times by 9 tests: return d->extra.isAllocated() ? d->extra->cursor : QCursor(); Executed by:
| 202 | ||||||||||||||||||||||||
7391 | ? d->extra->cursor executed 202 times by 9 tests: return d->extra.isAllocated() ? d->extra->cursor : QCursor(); Executed by:
| 202 | ||||||||||||||||||||||||
7392 | : QCursor(); executed 202 times by 9 tests: return d->extra.isAllocated() ? d->extra->cursor : QCursor(); Executed by:
| 202 | ||||||||||||||||||||||||
7393 | } | - | ||||||||||||||||||||||||
7394 | - | |||||||||||||||||||||||||
7395 | /*! | - | ||||||||||||||||||||||||
7396 | Sets the \a cursor shape for this item. | - | ||||||||||||||||||||||||
7397 | - | |||||||||||||||||||||||||
7398 | \sa cursor(), unsetCursor() | - | ||||||||||||||||||||||||
7399 | */ | - | ||||||||||||||||||||||||
7400 | - | |||||||||||||||||||||||||
7401 | void QQuickItem::setCursor(const QCursor &cursor) | - | ||||||||||||||||||||||||
7402 | { | - | ||||||||||||||||||||||||
7403 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7404 | - | |||||||||||||||||||||||||
7405 | Qt::CursorShape oldShape = d->extra.isAllocated() ? d->extra->cursor.shape() : Qt::ArrowCursor;
| 2-2014 | ||||||||||||||||||||||||
7406 | - | |||||||||||||||||||||||||
7407 | if (oldShape != cursor.shape() || oldShape >= Qt::LastCursor || cursor.shape() >= Qt::LastCursor) {
| 0-2012 | ||||||||||||||||||||||||
7408 | d->extra.value().cursor = cursor; | - | ||||||||||||||||||||||||
7409 | if (d->window) {
| 0-4 | ||||||||||||||||||||||||
7410 | QWindow *renderWindow = QQuickRenderControl::renderWindowFor(d->window); | - | ||||||||||||||||||||||||
7411 | QWindow *window = renderWindow ? renderWindow : d->window; // this may not be a QQuickWindow
| 0 | ||||||||||||||||||||||||
7412 | if (QQuickWindowPrivate::get(d->window)->cursorItem == this)
| 0 | ||||||||||||||||||||||||
7413 | window->setCursor(cursor); never executed: window->setCursor(cursor); | 0 | ||||||||||||||||||||||||
7414 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7415 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
7416 | - | |||||||||||||||||||||||||
7417 | if (!d->hasCursor) {
| 4-2012 | ||||||||||||||||||||||||
7418 | d->setHasCursorInChild(true); | - | ||||||||||||||||||||||||
7419 | d->hasCursor = true; | - | ||||||||||||||||||||||||
7420 | if (d->window) {
| 2-2010 | ||||||||||||||||||||||||
7421 | QWindow *renderWindow = QQuickRenderControl::renderWindowFor(d->window); | - | ||||||||||||||||||||||||
7422 | QWindow *window = renderWindow ? renderWindow : d->window;
| 0-2 | ||||||||||||||||||||||||
7423 | QPointF pos = window->mapFromGlobal(QGuiApplicationPrivate::lastCursorPosition.toPoint()); | - | ||||||||||||||||||||||||
7424 | if (contains(mapFromScene(pos)))
| 0-2 | ||||||||||||||||||||||||
7425 | QQuickWindowPrivate::get(d->window)->updateCursor(pos); never executed: QQuickWindowPrivate::get(d->window)->updateCursor(pos); | 0 | ||||||||||||||||||||||||
7426 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
7427 | } executed 2012 times by 23 tests: end of block Executed by:
| 2012 | ||||||||||||||||||||||||
7428 | } executed 2016 times by 23 tests: end of block Executed by:
| 2016 | ||||||||||||||||||||||||
7429 | - | |||||||||||||||||||||||||
7430 | /*! | - | ||||||||||||||||||||||||
7431 | Clears the cursor shape for this item. | - | ||||||||||||||||||||||||
7432 | - | |||||||||||||||||||||||||
7433 | \sa cursor(), setCursor() | - | ||||||||||||||||||||||||
7434 | */ | - | ||||||||||||||||||||||||
7435 | - | |||||||||||||||||||||||||
7436 | void QQuickItem::unsetCursor() | - | ||||||||||||||||||||||||
7437 | { | - | ||||||||||||||||||||||||
7438 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7439 | if (!d->hasCursor)
| 0 | ||||||||||||||||||||||||
7440 | return; never executed: return; | 0 | ||||||||||||||||||||||||
7441 | d->setHasCursorInChild(false); | - | ||||||||||||||||||||||||
7442 | d->hasCursor = false; | - | ||||||||||||||||||||||||
7443 | if (d->extra.isAllocated())
| 0 | ||||||||||||||||||||||||
7444 | d->extra->cursor = QCursor(); never executed: d->extra->cursor = QCursor(); | 0 | ||||||||||||||||||||||||
7445 | - | |||||||||||||||||||||||||
7446 | if (d->window) {
| 0 | ||||||||||||||||||||||||
7447 | QQuickWindowPrivate *windowPrivate = QQuickWindowPrivate::get(d->window); | - | ||||||||||||||||||||||||
7448 | if (windowPrivate->cursorItem == this) {
| 0 | ||||||||||||||||||||||||
7449 | QPointF pos = d->window->mapFromGlobal(QGuiApplicationPrivate::lastCursorPosition.toPoint()); | - | ||||||||||||||||||||||||
7450 | windowPrivate->updateCursor(pos); | - | ||||||||||||||||||||||||
7451 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7452 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7453 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7454 | - | |||||||||||||||||||||||||
7455 | #endif | - | ||||||||||||||||||||||||
7456 | - | |||||||||||||||||||||||||
7457 | /*! | - | ||||||||||||||||||||||||
7458 | Grabs the mouse input. | - | ||||||||||||||||||||||||
7459 | - | |||||||||||||||||||||||||
7460 | This item will receive all mouse events until ungrabMouse() is called. | - | ||||||||||||||||||||||||
7461 | Usually this function should not be called, since accepting for example | - | ||||||||||||||||||||||||
7462 | a mouse press event makes sure that the following events are delivered | - | ||||||||||||||||||||||||
7463 | to the item. | - | ||||||||||||||||||||||||
7464 | If an item wants to take over mouse events from the current receiver, | - | ||||||||||||||||||||||||
7465 | it needs to call this function. | - | ||||||||||||||||||||||||
7466 | - | |||||||||||||||||||||||||
7467 | \warning This function should be used with caution. | - | ||||||||||||||||||||||||
7468 | */ | - | ||||||||||||||||||||||||
7469 | void QQuickItem::grabMouse() | - | ||||||||||||||||||||||||
7470 | { | - | ||||||||||||||||||||||||
7471 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7472 | if (!d->window || d->window->mouseGrabberItem() == this)
| 0-1788 | ||||||||||||||||||||||||
7473 | return; executed 30 times by 2 tests: return; Executed by:
| 30 | ||||||||||||||||||||||||
7474 | QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(d->window); | - | ||||||||||||||||||||||||
7475 | bool fromTouch = windowPriv->isDeliveringTouchAsMouse(); | - | ||||||||||||||||||||||||
7476 | auto point = fromTouch ?
| 36-1722 | ||||||||||||||||||||||||
7477 | windowPriv->pointerEventInstance(windowPriv->touchMouseDevice)->pointById(windowPriv->touchMouseId) : | - | ||||||||||||||||||||||||
7478 | windowPriv->pointerEventInstance(QQuickPointerDevice::genericMouseDevice())->point(0); | - | ||||||||||||||||||||||||
7479 | if (point)
| 0-1758 | ||||||||||||||||||||||||
7480 | point->setGrabberItem(this); executed 1758 times by 13 tests: point->setGrabberItem(this); Executed by:
| 1758 | ||||||||||||||||||||||||
7481 | } executed 1758 times by 13 tests: end of block Executed by:
| 1758 | ||||||||||||||||||||||||
7482 | - | |||||||||||||||||||||||||
7483 | /*! | - | ||||||||||||||||||||||||
7484 | Releases the mouse grab following a call to grabMouse(). | - | ||||||||||||||||||||||||
7485 | - | |||||||||||||||||||||||||
7486 | Note that this function should only be called when the item wants | - | ||||||||||||||||||||||||
7487 | to stop handling further events. There is no need to call this function | - | ||||||||||||||||||||||||
7488 | after a release or cancel event since no future events will be received | - | ||||||||||||||||||||||||
7489 | in any case. No move or release events will be delivered after this | - | ||||||||||||||||||||||||
7490 | function was called. | - | ||||||||||||||||||||||||
7491 | */ | - | ||||||||||||||||||||||||
7492 | void QQuickItem::ungrabMouse() | - | ||||||||||||||||||||||||
7493 | { | - | ||||||||||||||||||||||||
7494 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7495 | if (!d->window)
| 0-92 | ||||||||||||||||||||||||
7496 | return; never executed: return; | 0 | ||||||||||||||||||||||||
7497 | QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(d->window); | - | ||||||||||||||||||||||||
7498 | windowPriv->removeGrabber(this, true, windowPriv->isDeliveringTouchAsMouse()); | - | ||||||||||||||||||||||||
7499 | } executed 92 times by 7 tests: end of block Executed by:
| 92 | ||||||||||||||||||||||||
7500 | - | |||||||||||||||||||||||||
7501 | - | |||||||||||||||||||||||||
7502 | /*! | - | ||||||||||||||||||||||||
7503 | Returns whether mouse input should exclusively remain with this item. | - | ||||||||||||||||||||||||
7504 | - | |||||||||||||||||||||||||
7505 | \sa setKeepMouseGrab() | - | ||||||||||||||||||||||||
7506 | */ | - | ||||||||||||||||||||||||
7507 | bool QQuickItem::keepMouseGrab() const | - | ||||||||||||||||||||||||
7508 | { | - | ||||||||||||||||||||||||
7509 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7510 | return d->keepMouse; executed 2497 times by 8 tests: return d->keepMouse; Executed by:
| 2497 | ||||||||||||||||||||||||
7511 | } | - | ||||||||||||||||||||||||
7512 | - | |||||||||||||||||||||||||
7513 | /*! | - | ||||||||||||||||||||||||
7514 | Sets whether the mouse input should remain exclusively with this item. | - | ||||||||||||||||||||||||
7515 | - | |||||||||||||||||||||||||
7516 | This is useful for items that wish to grab and keep mouse | - | ||||||||||||||||||||||||
7517 | interaction following a predefined gesture. For example, | - | ||||||||||||||||||||||||
7518 | an item that is interested in horizontal mouse movement | - | ||||||||||||||||||||||||
7519 | may set keepMouseGrab to true once a threshold has been | - | ||||||||||||||||||||||||
7520 | exceeded. Once keepMouseGrab has been set to true, filtering | - | ||||||||||||||||||||||||
7521 | items will not react to mouse events. | - | ||||||||||||||||||||||||
7522 | - | |||||||||||||||||||||||||
7523 | If \a keep is false, a filtering item may steal the grab. For example, | - | ||||||||||||||||||||||||
7524 | \l Flickable may attempt to steal a mouse grab if it detects that the | - | ||||||||||||||||||||||||
7525 | user has begun to move the viewport. | - | ||||||||||||||||||||||||
7526 | - | |||||||||||||||||||||||||
7527 | \sa keepMouseGrab() | - | ||||||||||||||||||||||||
7528 | */ | - | ||||||||||||||||||||||||
7529 | void QQuickItem::setKeepMouseGrab(bool keep) | - | ||||||||||||||||||||||||
7530 | { | - | ||||||||||||||||||||||||
7531 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7532 | d->keepMouse = keep; | - | ||||||||||||||||||||||||
7533 | } executed 7474 times by 15 tests: end of block Executed by:
| 7474 | ||||||||||||||||||||||||
7534 | - | |||||||||||||||||||||||||
7535 | /*! | - | ||||||||||||||||||||||||
7536 | Grabs the touch points specified by \a ids. | - | ||||||||||||||||||||||||
7537 | - | |||||||||||||||||||||||||
7538 | These touch points will be owned by the item until | - | ||||||||||||||||||||||||
7539 | they are released. Alternatively, the grab can be stolen | - | ||||||||||||||||||||||||
7540 | by a filtering item like Flickable. Use setKeepTouchGrab() | - | ||||||||||||||||||||||||
7541 | to prevent the grab from being stolen. | - | ||||||||||||||||||||||||
7542 | - | |||||||||||||||||||||||||
7543 | \sa ungrabTouchPoints(), setKeepTouchGrab() | - | ||||||||||||||||||||||||
7544 | */ | - | ||||||||||||||||||||||||
7545 | void QQuickItem::grabTouchPoints(const QVector<int> &ids) | - | ||||||||||||||||||||||||
7546 | { | - | ||||||||||||||||||||||||
7547 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7548 | if (!d->window)
| 0-22 | ||||||||||||||||||||||||
7549 | return; never executed: return; | 0 | ||||||||||||||||||||||||
7550 | QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(d->window); | - | ||||||||||||||||||||||||
7551 | windowPriv->grabTouchPoints(this, ids); | - | ||||||||||||||||||||||||
7552 | } executed 22 times by 2 tests: end of block Executed by:
| 22 | ||||||||||||||||||||||||
7553 | - | |||||||||||||||||||||||||
7554 | /*! | - | ||||||||||||||||||||||||
7555 | Ungrabs the touch points owned by this item. | - | ||||||||||||||||||||||||
7556 | - | |||||||||||||||||||||||||
7557 | \note there is hardly any reason to call this function. It should only be | - | ||||||||||||||||||||||||
7558 | called when an item does not want to receive any further events, so no | - | ||||||||||||||||||||||||
7559 | move or release events will be delivered after calling this function. | - | ||||||||||||||||||||||||
7560 | - | |||||||||||||||||||||||||
7561 | \sa grabTouchPoints() | - | ||||||||||||||||||||||||
7562 | */ | - | ||||||||||||||||||||||||
7563 | void QQuickItem::ungrabTouchPoints() | - | ||||||||||||||||||||||||
7564 | { | - | ||||||||||||||||||||||||
7565 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7566 | if (!d->window)
| 0-132 | ||||||||||||||||||||||||
7567 | return; never executed: return; | 0 | ||||||||||||||||||||||||
7568 | QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(d->window); | - | ||||||||||||||||||||||||
7569 | windowPriv->removeGrabber(this, false, true); | - | ||||||||||||||||||||||||
7570 | } executed 132 times by 2 tests: end of block Executed by:
| 132 | ||||||||||||||||||||||||
7571 | - | |||||||||||||||||||||||||
7572 | /*! | - | ||||||||||||||||||||||||
7573 | Returns whether the touch points grabbed by this item should exclusively | - | ||||||||||||||||||||||||
7574 | remain with this item. | - | ||||||||||||||||||||||||
7575 | - | |||||||||||||||||||||||||
7576 | \sa setKeepTouchGrab(), keepMouseGrab() | - | ||||||||||||||||||||||||
7577 | */ | - | ||||||||||||||||||||||||
7578 | bool QQuickItem::keepTouchGrab() const | - | ||||||||||||||||||||||||
7579 | { | - | ||||||||||||||||||||||||
7580 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7581 | return d->keepTouch; executed 1277 times by 8 tests: return d->keepTouch; Executed by:
| 1277 | ||||||||||||||||||||||||
7582 | } | - | ||||||||||||||||||||||||
7583 | - | |||||||||||||||||||||||||
7584 | /*! | - | ||||||||||||||||||||||||
7585 | Sets whether the touch points grabbed by this item should remain | - | ||||||||||||||||||||||||
7586 | exclusively with this item. | - | ||||||||||||||||||||||||
7587 | - | |||||||||||||||||||||||||
7588 | This is useful for items that wish to grab and keep specific touch | - | ||||||||||||||||||||||||
7589 | points following a predefined gesture. For example, | - | ||||||||||||||||||||||||
7590 | an item that is interested in horizontal touch point movement | - | ||||||||||||||||||||||||
7591 | may set setKeepTouchGrab to true once a threshold has been | - | ||||||||||||||||||||||||
7592 | exceeded. Once setKeepTouchGrab has been set to true, filtering | - | ||||||||||||||||||||||||
7593 | items will not react to the relevant touch points. | - | ||||||||||||||||||||||||
7594 | - | |||||||||||||||||||||||||
7595 | If \a keep is false, a filtering item may steal the grab. For example, | - | ||||||||||||||||||||||||
7596 | \l Flickable may attempt to steal a touch point grab if it detects that the | - | ||||||||||||||||||||||||
7597 | user has begun to move the viewport. | - | ||||||||||||||||||||||||
7598 | - | |||||||||||||||||||||||||
7599 | \sa keepTouchGrab(), setKeepMouseGrab() | - | ||||||||||||||||||||||||
7600 | */ | - | ||||||||||||||||||||||||
7601 | void QQuickItem::setKeepTouchGrab(bool keep) | - | ||||||||||||||||||||||||
7602 | { | - | ||||||||||||||||||||||||
7603 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7604 | d->keepTouch = keep; | - | ||||||||||||||||||||||||
7605 | } executed 364 times by 5 tests: end of block Executed by:
| 364 | ||||||||||||||||||||||||
7606 | - | |||||||||||||||||||||||||
7607 | /*! | - | ||||||||||||||||||||||||
7608 | \qmlmethod bool QtQuick::Item::contains(point point) | - | ||||||||||||||||||||||||
7609 | - | |||||||||||||||||||||||||
7610 | Returns true if this item contains \a point, which is in local coordinates; | - | ||||||||||||||||||||||||
7611 | returns false otherwise. | - | ||||||||||||||||||||||||
7612 | */ | - | ||||||||||||||||||||||||
7613 | /*! | - | ||||||||||||||||||||||||
7614 | Returns true if this item contains \a point, which is in local coordinates; | - | ||||||||||||||||||||||||
7615 | returns false otherwise. | - | ||||||||||||||||||||||||
7616 | - | |||||||||||||||||||||||||
7617 | This function can be overwritten in order to handle point collisions in items | - | ||||||||||||||||||||||||
7618 | with custom shapes. The default implementation checks if the point is inside | - | ||||||||||||||||||||||||
7619 | the item's bounding rect. | - | ||||||||||||||||||||||||
7620 | - | |||||||||||||||||||||||||
7621 | Note that this method is generally used to check whether the item is under the mouse cursor, | - | ||||||||||||||||||||||||
7622 | and for that reason, the implementation of this function should be as light-weight | - | ||||||||||||||||||||||||
7623 | as possible. | - | ||||||||||||||||||||||||
7624 | */ | - | ||||||||||||||||||||||||
7625 | bool QQuickItem::contains(const QPointF &point) const | - | ||||||||||||||||||||||||
7626 | { | - | ||||||||||||||||||||||||
7627 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7628 | if (d->mask) {
| 8-62104 | ||||||||||||||||||||||||
7629 | bool res = false; | - | ||||||||||||||||||||||||
7630 | d->extra->maskContains.invoke(d->mask, | - | ||||||||||||||||||||||||
7631 | Qt::DirectConnection, | - | ||||||||||||||||||||||||
7632 | Q_RETURN_ARG(bool, res), | - | ||||||||||||||||||||||||
7633 | Q_ARG(QPointF, point)); | - | ||||||||||||||||||||||||
7634 | return res; executed 8 times by 1 test: return res; Executed by:
| 8 | ||||||||||||||||||||||||
7635 | } else { | - | ||||||||||||||||||||||||
7636 | qreal x = point.x(); | - | ||||||||||||||||||||||||
7637 | qreal y = point.y(); | - | ||||||||||||||||||||||||
7638 | return x >= 0 && y >= 0 && x <= d->width && y <= d->height; executed 62104 times by 20 tests: return x >= 0 && y >= 0 && x <= d->width && y <= d->height; Executed by:
| 62104 | ||||||||||||||||||||||||
7639 | } | - | ||||||||||||||||||||||||
7640 | } | - | ||||||||||||||||||||||||
7641 | - | |||||||||||||||||||||||||
7642 | /*! | - | ||||||||||||||||||||||||
7643 | \qmlproperty QObject* QtQuick::Item::containmentMask | - | ||||||||||||||||||||||||
7644 | \since 5.11 | - | ||||||||||||||||||||||||
7645 | This property holds an optional mask for the Item to be used in the | - | ||||||||||||||||||||||||
7646 | QtQuick::Item::contains method. | - | ||||||||||||||||||||||||
7647 | QtQuick::Item::contains main use is currently to determine whether | - | ||||||||||||||||||||||||
7648 | an input event has landed into the item or not. | - | ||||||||||||||||||||||||
7649 | - | |||||||||||||||||||||||||
7650 | By default the \l contains method will return true for any point | - | ||||||||||||||||||||||||
7651 | within the Item's bounding box. \c containmentMask allows for a | - | ||||||||||||||||||||||||
7652 | more fine-grained control. For example, the developer could | - | ||||||||||||||||||||||||
7653 | define and use an AnotherItem element as containmentMask, | - | ||||||||||||||||||||||||
7654 | which has a specialized contains method, like: | - | ||||||||||||||||||||||||
7655 | - | |||||||||||||||||||||||||
7656 | \code | - | ||||||||||||||||||||||||
7657 | Item { id: item; containmentMask: AnotherItem { id: anotherItem } } | - | ||||||||||||||||||||||||
7658 | \endcode | - | ||||||||||||||||||||||||
7659 | - | |||||||||||||||||||||||||
7660 | \e{item}'s contains method would then return true only if | - | ||||||||||||||||||||||||
7661 | \e{anotherItem}'s contains implementation returns true. | - | ||||||||||||||||||||||||
7662 | */ | - | ||||||||||||||||||||||||
7663 | QObject *QQuickItem::containmentMask() const | - | ||||||||||||||||||||||||
7664 | { | - | ||||||||||||||||||||||||
7665 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7666 | return d->mask.data(); executed 204 times by 7 tests: return d->mask.data(); Executed by:
| 204 | ||||||||||||||||||||||||
7667 | } | - | ||||||||||||||||||||||||
7668 | - | |||||||||||||||||||||||||
7669 | void QQuickItem::setContainmentMask(QObject *mask) | - | ||||||||||||||||||||||||
7670 | { | - | ||||||||||||||||||||||||
7671 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7672 | // an Item can't mask itself (to prevent infinite loop in contains()) | - | ||||||||||||||||||||||||
7673 | if (d->mask.data() == mask || mask == static_cast<QObject *>(this))
| 0-6 | ||||||||||||||||||||||||
7674 | return; never executed: return; | 0 | ||||||||||||||||||||||||
7675 | - | |||||||||||||||||||||||||
7676 | QQuickItem *quickMask = qobject_cast<QQuickItem *>(d->mask); | - | ||||||||||||||||||||||||
7677 | if (quickMask) {
| 0-6 | ||||||||||||||||||||||||
7678 | QQuickItemPrivate *maskPrivate = QQuickItemPrivate::get(quickMask); | - | ||||||||||||||||||||||||
7679 | maskPrivate->registerAsContainmentMask(this, false); // removed from use as my mask | - | ||||||||||||||||||||||||
7680 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7681 | - | |||||||||||||||||||||||||
7682 | if (mask) {
| 0-6 | ||||||||||||||||||||||||
7683 | int methodIndex = mask->metaObject()->indexOfMethod(QByteArrayLiteral("contains(QPointF)")); executed 6 times by 2 tests: return ba; Executed by:
| 6 | ||||||||||||||||||||||||
7684 | if (methodIndex < 0) {
| 0-6 | ||||||||||||||||||||||||
7685 | qmlWarning(this) << QStringLiteral("QQuickItem: Object set as mask does not have an invokable contains method, ignoring it."); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||||||||
7686 | return; never executed: return; | 0 | ||||||||||||||||||||||||
7687 | } | - | ||||||||||||||||||||||||
7688 | d->extra.value().maskContains = mask->metaObject()->method(methodIndex); | - | ||||||||||||||||||||||||
7689 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||
7690 | d->mask = mask; | - | ||||||||||||||||||||||||
7691 | quickMask = qobject_cast<QQuickItem *>(mask); | - | ||||||||||||||||||||||||
7692 | if (quickMask) {
| 2-4 | ||||||||||||||||||||||||
7693 | QQuickItemPrivate *maskPrivate = QQuickItemPrivate::get(quickMask); | - | ||||||||||||||||||||||||
7694 | maskPrivate->registerAsContainmentMask(this, true); // telling maskPrivate that "this" is using it as mask | - | ||||||||||||||||||||||||
7695 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
7696 | emit containmentMaskChanged(); | - | ||||||||||||||||||||||||
7697 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||
7698 | - | |||||||||||||||||||||||||
7699 | /*! | - | ||||||||||||||||||||||||
7700 | Maps the given \a point in this item's coordinate system to the equivalent | - | ||||||||||||||||||||||||
7701 | point within \a item's coordinate system, and returns the mapped | - | ||||||||||||||||||||||||
7702 | coordinate. | - | ||||||||||||||||||||||||
7703 | - | |||||||||||||||||||||||||
7704 | If \a item is 0, this maps \a point to the coordinate system of the | - | ||||||||||||||||||||||||
7705 | scene. | - | ||||||||||||||||||||||||
7706 | - | |||||||||||||||||||||||||
7707 | \sa {Concepts - Visual Coordinates in Qt Quick} | - | ||||||||||||||||||||||||
7708 | */ | - | ||||||||||||||||||||||||
7709 | QPointF QQuickItem::mapToItem(const QQuickItem *item, const QPointF &point) const | - | ||||||||||||||||||||||||
7710 | { | - | ||||||||||||||||||||||||
7711 | QPointF p = mapToScene(point); | - | ||||||||||||||||||||||||
7712 | if (item)
| 10-596 | ||||||||||||||||||||||||
7713 | p = item->mapFromScene(p); executed 596 times by 4 tests: p = item->mapFromScene(p); Executed by:
| 596 | ||||||||||||||||||||||||
7714 | return p; executed 606 times by 4 tests: return p; Executed by:
| 606 | ||||||||||||||||||||||||
7715 | } | - | ||||||||||||||||||||||||
7716 | - | |||||||||||||||||||||||||
7717 | /*! | - | ||||||||||||||||||||||||
7718 | Maps the given \a point in this item's coordinate system to the equivalent | - | ||||||||||||||||||||||||
7719 | point within the scene's coordinate system, and returns the mapped | - | ||||||||||||||||||||||||
7720 | coordinate. | - | ||||||||||||||||||||||||
7721 | - | |||||||||||||||||||||||||
7722 | \sa {Concepts - Visual Coordinates in Qt Quick} | - | ||||||||||||||||||||||||
7723 | */ | - | ||||||||||||||||||||||||
7724 | QPointF QQuickItem::mapToScene(const QPointF &point) const | - | ||||||||||||||||||||||||
7725 | { | - | ||||||||||||||||||||||||
7726 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7727 | return d->itemToWindowTransform().map(point); executed 11436 times by 50 tests: return d->itemToWindowTransform().map(point); Executed by:
| 11436 | ||||||||||||||||||||||||
7728 | } | - | ||||||||||||||||||||||||
7729 | - | |||||||||||||||||||||||||
7730 | /*! | - | ||||||||||||||||||||||||
7731 | Maps the given \a point in this item's coordinate system to the equivalent | - | ||||||||||||||||||||||||
7732 | point within global screen coordinate system, and returns the mapped | - | ||||||||||||||||||||||||
7733 | coordinate. | - | ||||||||||||||||||||||||
7734 | - | |||||||||||||||||||||||||
7735 | For example, this may be helpful to add a popup to a Qt Quick component. | - | ||||||||||||||||||||||||
7736 | - | |||||||||||||||||||||||||
7737 | \note Window positioning is done by the window manager and this value is | - | ||||||||||||||||||||||||
7738 | treated only as a hint. So, the resulting window position may differ from | - | ||||||||||||||||||||||||
7739 | what is expected. | - | ||||||||||||||||||||||||
7740 | - | |||||||||||||||||||||||||
7741 | \since 5.7 | - | ||||||||||||||||||||||||
7742 | - | |||||||||||||||||||||||||
7743 | \sa {Concepts - Visual Coordinates in Qt Quick} | - | ||||||||||||||||||||||||
7744 | */ | - | ||||||||||||||||||||||||
7745 | QPointF QQuickItem::mapToGlobal(const QPointF &point) const | - | ||||||||||||||||||||||||
7746 | { | - | ||||||||||||||||||||||||
7747 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7748 | return d->windowToGlobalTransform().map(mapToScene(point)); executed 30 times by 1 test: return d->windowToGlobalTransform().map(mapToScene(point)); Executed by:
| 30 | ||||||||||||||||||||||||
7749 | } | - | ||||||||||||||||||||||||
7750 | - | |||||||||||||||||||||||||
7751 | /*! | - | ||||||||||||||||||||||||
7752 | Maps the given \a rect in this item's coordinate system to the equivalent | - | ||||||||||||||||||||||||
7753 | rectangular area within \a item's coordinate system, and returns the mapped | - | ||||||||||||||||||||||||
7754 | rectangle value. | - | ||||||||||||||||||||||||
7755 | - | |||||||||||||||||||||||||
7756 | If \a item is 0, this maps \a rect to the coordinate system of the | - | ||||||||||||||||||||||||
7757 | scene. | - | ||||||||||||||||||||||||
7758 | - | |||||||||||||||||||||||||
7759 | \sa {Concepts - Visual Coordinates in Qt Quick} | - | ||||||||||||||||||||||||
7760 | */ | - | ||||||||||||||||||||||||
7761 | QRectF QQuickItem::mapRectToItem(const QQuickItem *item, const QRectF &rect) const | - | ||||||||||||||||||||||||
7762 | { | - | ||||||||||||||||||||||||
7763 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7764 | QTransform t = d->itemToWindowTransform(); | - | ||||||||||||||||||||||||
7765 | if (item)
| 18-36 | ||||||||||||||||||||||||
7766 | t *= QQuickItemPrivate::get(item)->windowToItemTransform(); executed 36 times by 1 test: t *= QQuickItemPrivate::get(item)->windowToItemTransform(); Executed by:
| 36 | ||||||||||||||||||||||||
7767 | return t.mapRect(rect); executed 54 times by 1 test: return t.mapRect(rect); Executed by:
| 54 | ||||||||||||||||||||||||
7768 | } | - | ||||||||||||||||||||||||
7769 | - | |||||||||||||||||||||||||
7770 | /*! | - | ||||||||||||||||||||||||
7771 | Maps the given \a rect in this item's coordinate system to the equivalent | - | ||||||||||||||||||||||||
7772 | rectangular area within the scene's coordinate system, and returns the mapped | - | ||||||||||||||||||||||||
7773 | rectangle value. | - | ||||||||||||||||||||||||
7774 | - | |||||||||||||||||||||||||
7775 | \sa {Concepts - Visual Coordinates in Qt Quick} | - | ||||||||||||||||||||||||
7776 | */ | - | ||||||||||||||||||||||||
7777 | QRectF QQuickItem::mapRectToScene(const QRectF &rect) const | - | ||||||||||||||||||||||||
7778 | { | - | ||||||||||||||||||||||||
7779 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7780 | return d->itemToWindowTransform().mapRect(rect); executed 18 times by 1 test: return d->itemToWindowTransform().mapRect(rect); Executed by:
| 18 | ||||||||||||||||||||||||
7781 | } | - | ||||||||||||||||||||||||
7782 | - | |||||||||||||||||||||||||
7783 | /*! | - | ||||||||||||||||||||||||
7784 | Maps the given \a point in \a item's coordinate system to the equivalent | - | ||||||||||||||||||||||||
7785 | point within this item's coordinate system, and returns the mapped | - | ||||||||||||||||||||||||
7786 | coordinate. | - | ||||||||||||||||||||||||
7787 | - | |||||||||||||||||||||||||
7788 | If \a item is 0, this maps \a point from the coordinate system of the | - | ||||||||||||||||||||||||
7789 | scene. | - | ||||||||||||||||||||||||
7790 | - | |||||||||||||||||||||||||
7791 | \sa {Concepts - Visual Coordinates in Qt Quick} | - | ||||||||||||||||||||||||
7792 | */ | - | ||||||||||||||||||||||||
7793 | QPointF QQuickItem::mapFromItem(const QQuickItem *item, const QPointF &point) const | - | ||||||||||||||||||||||||
7794 | { | - | ||||||||||||||||||||||||
7795 | QPointF p = item?item->mapToScene(point):point;
| 10-7842 | ||||||||||||||||||||||||
7796 | return mapFromScene(p); executed 7852 times by 31 tests: return mapFromScene(p); Executed by:
| 7852 | ||||||||||||||||||||||||
7797 | } | - | ||||||||||||||||||||||||
7798 | - | |||||||||||||||||||||||||
7799 | /*! | - | ||||||||||||||||||||||||
7800 | Maps the given \a point in the scene's coordinate system to the equivalent | - | ||||||||||||||||||||||||
7801 | point within this item's coordinate system, and returns the mapped | - | ||||||||||||||||||||||||
7802 | coordinate. | - | ||||||||||||||||||||||||
7803 | - | |||||||||||||||||||||||||
7804 | \sa {Concepts - Visual Coordinates in Qt Quick} | - | ||||||||||||||||||||||||
7805 | */ | - | ||||||||||||||||||||||||
7806 | QPointF QQuickItem::mapFromScene(const QPointF &point) const | - | ||||||||||||||||||||||||
7807 | { | - | ||||||||||||||||||||||||
7808 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7809 | return d->windowToItemTransform().map(point); executed 101551 times by 44 tests: return d->windowToItemTransform().map(point); Executed by:
| 101551 | ||||||||||||||||||||||||
7810 | } | - | ||||||||||||||||||||||||
7811 | - | |||||||||||||||||||||||||
7812 | /*! | - | ||||||||||||||||||||||||
7813 | Maps the given \a point in the global screen coordinate system to the | - | ||||||||||||||||||||||||
7814 | equivalent point within this item's coordinate system, and returns the | - | ||||||||||||||||||||||||
7815 | mapped coordinate. | - | ||||||||||||||||||||||||
7816 | - | |||||||||||||||||||||||||
7817 | For example, this may be helpful to add a popup to a Qt Quick component. | - | ||||||||||||||||||||||||
7818 | - | |||||||||||||||||||||||||
7819 | \note Window positioning is done by the window manager and this value is | - | ||||||||||||||||||||||||
7820 | treated only as a hint. So, the resulting window position may differ from | - | ||||||||||||||||||||||||
7821 | what is expected. | - | ||||||||||||||||||||||||
7822 | - | |||||||||||||||||||||||||
7823 | \since 5.7 | - | ||||||||||||||||||||||||
7824 | - | |||||||||||||||||||||||||
7825 | \sa {Concepts - Visual Coordinates in Qt Quick} | - | ||||||||||||||||||||||||
7826 | */ | - | ||||||||||||||||||||||||
7827 | QPointF QQuickItem::mapFromGlobal(const QPointF &point) const | - | ||||||||||||||||||||||||
7828 | { | - | ||||||||||||||||||||||||
7829 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7830 | return mapFromScene(d->globalToWindowTransform().map(point)); executed 30 times by 1 test: return mapFromScene(d->globalToWindowTransform().map(point)); Executed by:
| 30 | ||||||||||||||||||||||||
7831 | } | - | ||||||||||||||||||||||||
7832 | - | |||||||||||||||||||||||||
7833 | /*! | - | ||||||||||||||||||||||||
7834 | Maps the given \a rect in \a item's coordinate system to the equivalent | - | ||||||||||||||||||||||||
7835 | rectangular area within this item's coordinate system, and returns the mapped | - | ||||||||||||||||||||||||
7836 | rectangle value. | - | ||||||||||||||||||||||||
7837 | - | |||||||||||||||||||||||||
7838 | If \a item is 0, this maps \a rect from the coordinate system of the | - | ||||||||||||||||||||||||
7839 | scene. | - | ||||||||||||||||||||||||
7840 | - | |||||||||||||||||||||||||
7841 | \sa {Concepts - Visual Coordinates in Qt Quick} | - | ||||||||||||||||||||||||
7842 | */ | - | ||||||||||||||||||||||||
7843 | QRectF QQuickItem::mapRectFromItem(const QQuickItem *item, const QRectF &rect) const | - | ||||||||||||||||||||||||
7844 | { | - | ||||||||||||||||||||||||
7845 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7846 | QTransform t = item?QQuickItemPrivate::get(item)->itemToWindowTransform():QTransform();
| 18-36 | ||||||||||||||||||||||||
7847 | t *= d->windowToItemTransform(); | - | ||||||||||||||||||||||||
7848 | return t.mapRect(rect); executed 54 times by 1 test: return t.mapRect(rect); Executed by:
| 54 | ||||||||||||||||||||||||
7849 | } | - | ||||||||||||||||||||||||
7850 | - | |||||||||||||||||||||||||
7851 | /*! | - | ||||||||||||||||||||||||
7852 | Maps the given \a rect in the scene's coordinate system to the equivalent | - | ||||||||||||||||||||||||
7853 | rectangular area within this item's coordinate system, and returns the mapped | - | ||||||||||||||||||||||||
7854 | rectangle value. | - | ||||||||||||||||||||||||
7855 | - | |||||||||||||||||||||||||
7856 | \sa {Concepts - Visual Coordinates in Qt Quick} | - | ||||||||||||||||||||||||
7857 | */ | - | ||||||||||||||||||||||||
7858 | QRectF QQuickItem::mapRectFromScene(const QRectF &rect) const | - | ||||||||||||||||||||||||
7859 | { | - | ||||||||||||||||||||||||
7860 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
7861 | return d->windowToItemTransform().mapRect(rect); executed 1740 times by 11 tests: return d->windowToItemTransform().mapRect(rect); Executed by:
| 1740 | ||||||||||||||||||||||||
7862 | } | - | ||||||||||||||||||||||||
7863 | - | |||||||||||||||||||||||||
7864 | /*! | - | ||||||||||||||||||||||||
7865 | \property QQuickItem::anchors | - | ||||||||||||||||||||||||
7866 | \internal | - | ||||||||||||||||||||||||
7867 | */ | - | ||||||||||||||||||||||||
7868 | - | |||||||||||||||||||||||||
7869 | /*! | - | ||||||||||||||||||||||||
7870 | \property QQuickItem::left | - | ||||||||||||||||||||||||
7871 | \internal | - | ||||||||||||||||||||||||
7872 | */ | - | ||||||||||||||||||||||||
7873 | - | |||||||||||||||||||||||||
7874 | /*! | - | ||||||||||||||||||||||||
7875 | \property QQuickItem::right | - | ||||||||||||||||||||||||
7876 | \internal | - | ||||||||||||||||||||||||
7877 | */ | - | ||||||||||||||||||||||||
7878 | - | |||||||||||||||||||||||||
7879 | /*! | - | ||||||||||||||||||||||||
7880 | \property QQuickItem::horizontalCenter | - | ||||||||||||||||||||||||
7881 | \internal | - | ||||||||||||||||||||||||
7882 | */ | - | ||||||||||||||||||||||||
7883 | - | |||||||||||||||||||||||||
7884 | /*! | - | ||||||||||||||||||||||||
7885 | \property QQuickItem::top | - | ||||||||||||||||||||||||
7886 | \internal | - | ||||||||||||||||||||||||
7887 | */ | - | ||||||||||||||||||||||||
7888 | - | |||||||||||||||||||||||||
7889 | /*! | - | ||||||||||||||||||||||||
7890 | \property QQuickItem::bottom | - | ||||||||||||||||||||||||
7891 | \internal | - | ||||||||||||||||||||||||
7892 | */ | - | ||||||||||||||||||||||||
7893 | - | |||||||||||||||||||||||||
7894 | /*! | - | ||||||||||||||||||||||||
7895 | \property QQuickItem::verticalCenter | - | ||||||||||||||||||||||||
7896 | \internal | - | ||||||||||||||||||||||||
7897 | */ | - | ||||||||||||||||||||||||
7898 | - | |||||||||||||||||||||||||
7899 | /*! | - | ||||||||||||||||||||||||
7900 | \property QQuickItem::baseline | - | ||||||||||||||||||||||||
7901 | \internal | - | ||||||||||||||||||||||||
7902 | */ | - | ||||||||||||||||||||||||
7903 | - | |||||||||||||||||||||||||
7904 | /*! | - | ||||||||||||||||||||||||
7905 | \property QQuickItem::data | - | ||||||||||||||||||||||||
7906 | \internal | - | ||||||||||||||||||||||||
7907 | */ | - | ||||||||||||||||||||||||
7908 | - | |||||||||||||||||||||||||
7909 | /*! | - | ||||||||||||||||||||||||
7910 | \property QQuickItem::resources | - | ||||||||||||||||||||||||
7911 | \internal | - | ||||||||||||||||||||||||
7912 | */ | - | ||||||||||||||||||||||||
7913 | - | |||||||||||||||||||||||||
7914 | /*! | - | ||||||||||||||||||||||||
7915 | \reimp | - | ||||||||||||||||||||||||
7916 | */ | - | ||||||||||||||||||||||||
7917 | bool QQuickItem::event(QEvent *ev) | - | ||||||||||||||||||||||||
7918 | { | - | ||||||||||||||||||||||||
7919 | Q_D(QQuickItem); | - | ||||||||||||||||||||||||
7920 | - | |||||||||||||||||||||||||
7921 | switch (ev->type()) { | - | ||||||||||||||||||||||||
7922 | #if 0 | - | ||||||||||||||||||||||||
7923 | case QEvent::PolishRequest: | - | ||||||||||||||||||||||||
7924 | d->polishScheduled = false; | - | ||||||||||||||||||||||||
7925 | updatePolish(); | - | ||||||||||||||||||||||||
7926 | break; | - | ||||||||||||||||||||||||
7927 | #endif | - | ||||||||||||||||||||||||
7928 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
7929 | case QEvent::InputMethodQuery: { executed 2252 times by 17 tests: case QEvent::InputMethodQuery: Executed by:
| 2252 | ||||||||||||||||||||||||
7930 | QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(ev); | - | ||||||||||||||||||||||||
7931 | Qt::InputMethodQueries queries = query->queries(); | - | ||||||||||||||||||||||||
7932 | for (uint i = 0; i < 32; ++i) {
| 2252-72064 | ||||||||||||||||||||||||
7933 | Qt::InputMethodQuery q = (Qt::InputMethodQuery)(int)(queries & (1<<i)); | - | ||||||||||||||||||||||||
7934 | if (q) {
| 4404-67660 | ||||||||||||||||||||||||
7935 | QVariant v = inputMethodQuery(q); | - | ||||||||||||||||||||||||
7936 | query->setValue(q, v); | - | ||||||||||||||||||||||||
7937 | } executed 4404 times by 17 tests: end of block Executed by:
| 4404 | ||||||||||||||||||||||||
7938 | } executed 72064 times by 17 tests: end of block Executed by:
| 72064 | ||||||||||||||||||||||||
7939 | query->accept(); | - | ||||||||||||||||||||||||
7940 | break; executed 2252 times by 17 tests: break; Executed by:
| 2252 | ||||||||||||||||||||||||
7941 | } | - | ||||||||||||||||||||||||
7942 | case QEvent::InputMethod: executed 674 times by 3 tests: case QEvent::InputMethod: Executed by:
| 674 | ||||||||||||||||||||||||
7943 | inputMethodEvent(static_cast<QInputMethodEvent *>(ev)); | - | ||||||||||||||||||||||||
7944 | break; executed 674 times by 3 tests: break; Executed by:
| 674 | ||||||||||||||||||||||||
7945 | #endif // im | - | ||||||||||||||||||||||||
7946 | case QEvent::TouchBegin: executed 178 times by 9 tests: case QEvent::TouchBegin: Executed by:
| 178 | ||||||||||||||||||||||||
7947 | case QEvent::TouchUpdate: executed 299 times by 8 tests: case QEvent::TouchUpdate: Executed by:
| 299 | ||||||||||||||||||||||||
7948 | case QEvent::TouchEnd: executed 96 times by 9 tests: case QEvent::TouchEnd: Executed by:
| 96 | ||||||||||||||||||||||||
7949 | case QEvent::TouchCancel: executed 4 times by 1 test: case QEvent::TouchCancel: Executed by:
| 4 | ||||||||||||||||||||||||
7950 | touchEvent(static_cast<QTouchEvent*>(ev)); | - | ||||||||||||||||||||||||
7951 | break; executed 577 times by 10 tests: break; Executed by:
| 577 | ||||||||||||||||||||||||
7952 | case QEvent::StyleAnimationUpdate: never executed: case QEvent::StyleAnimationUpdate: | 0 | ||||||||||||||||||||||||
7953 | if (isVisible()) {
| 0 | ||||||||||||||||||||||||
7954 | ev->accept(); | - | ||||||||||||||||||||||||
7955 | update(); | - | ||||||||||||||||||||||||
7956 | } never executed: end of block | 0 | ||||||||||||||||||||||||
7957 | break; never executed: break; | 0 | ||||||||||||||||||||||||
7958 | case QEvent::HoverEnter: executed 158 times by 6 tests: case QEvent::HoverEnter: Executed by:
| 158 | ||||||||||||||||||||||||
7959 | hoverEnterEvent(static_cast<QHoverEvent*>(ev)); | - | ||||||||||||||||||||||||
7960 | break; executed 158 times by 6 tests: break; Executed by:
| 158 | ||||||||||||||||||||||||
7961 | case QEvent::HoverLeave: executed 18 times by 4 tests: case QEvent::HoverLeave: Executed by:
| 18 | ||||||||||||||||||||||||
7962 | hoverLeaveEvent(static_cast<QHoverEvent*>(ev)); | - | ||||||||||||||||||||||||
7963 | break; executed 18 times by 4 tests: break; Executed by:
| 18 | ||||||||||||||||||||||||
7964 | case QEvent::HoverMove: executed 356 times by 6 tests: case QEvent::HoverMove: Executed by:
| 356 | ||||||||||||||||||||||||
7965 | hoverMoveEvent(static_cast<QHoverEvent*>(ev)); | - | ||||||||||||||||||||||||
7966 | break; executed 356 times by 6 tests: break; Executed by:
| 356 | ||||||||||||||||||||||||
7967 | case QEvent::KeyPress: executed 4346 times by 8 tests: case QEvent::KeyPress: Executed by:
| 4346 | ||||||||||||||||||||||||
7968 | case QEvent::KeyRelease: executed 5876 times by 7 tests: case QEvent::KeyRelease: Executed by:
| 5876 | ||||||||||||||||||||||||
7969 | d->deliverKeyEvent(static_cast<QKeyEvent*>(ev)); | - | ||||||||||||||||||||||||
7970 | break; executed 10222 times by 8 tests: break; Executed by:
| 10222 | ||||||||||||||||||||||||
7971 | case QEvent::ShortcutOverride: executed 350 times by 6 tests: case QEvent::ShortcutOverride: Executed by:
| 350 | ||||||||||||||||||||||||
7972 | d->deliverShortcutOverrideEvent(static_cast<QKeyEvent*>(ev)); | - | ||||||||||||||||||||||||
7973 | break; executed 350 times by 6 tests: break; Executed by:
| 350 | ||||||||||||||||||||||||
7974 | case QEvent::FocusIn: executed 2160 times by 18 tests: case QEvent::FocusIn: Executed by:
| 2160 | ||||||||||||||||||||||||
7975 | focusInEvent(static_cast<QFocusEvent*>(ev)); | - | ||||||||||||||||||||||||
7976 | break; executed 2160 times by 18 tests: break; Executed by:
| 2160 | ||||||||||||||||||||||||
7977 | case QEvent::FocusOut: executed 1108 times by 10 tests: case QEvent::FocusOut: Executed by:
| 1108 | ||||||||||||||||||||||||
7978 | focusOutEvent(static_cast<QFocusEvent*>(ev)); | - | ||||||||||||||||||||||||
7979 | break; executed 1108 times by 10 tests: break; Executed by:
| 1108 | ||||||||||||||||||||||||
7980 | case QEvent::MouseMove: executed 4753 times by 10 tests: case QEvent::MouseMove: Executed by:
| 4753 | ||||||||||||||||||||||||
7981 | mouseMoveEvent(static_cast<QMouseEvent*>(ev)); | - | ||||||||||||||||||||||||
7982 | break; executed 4753 times by 10 tests: break; Executed by:
| 4753 | ||||||||||||||||||||||||
7983 | case QEvent::MouseButtonPress: executed 2033 times by 15 tests: case QEvent::MouseButtonPress: Executed by:
| 2033 | ||||||||||||||||||||||||
7984 | mousePressEvent(static_cast<QMouseEvent*>(ev)); | - | ||||||||||||||||||||||||
7985 | break; executed 2033 times by 15 tests: break; Executed by:
| 2033 | ||||||||||||||||||||||||
7986 | case QEvent::MouseButtonRelease: executed 1636 times by 12 tests: case QEvent::MouseButtonRelease: Executed by:
| 1636 | ||||||||||||||||||||||||
7987 | mouseReleaseEvent(static_cast<QMouseEvent*>(ev)); | - | ||||||||||||||||||||||||
7988 | break; executed 1636 times by 12 tests: break; Executed by:
| 1636 | ||||||||||||||||||||||||
7989 | case QEvent::MouseButtonDblClick: executed 148 times by 4 tests: case QEvent::MouseButtonDblClick: Executed by:
| 148 | ||||||||||||||||||||||||
7990 | mouseDoubleClickEvent(static_cast<QMouseEvent*>(ev)); | - | ||||||||||||||||||||||||
7991 | break; executed 148 times by 4 tests: break; Executed by:
| 148 | ||||||||||||||||||||||||
7992 | #if QT_CONFIG(wheelevent) | - | ||||||||||||||||||||||||
7993 | case QEvent::Wheel: executed 10 times by 2 tests: case QEvent::Wheel: Executed by:
| 10 | ||||||||||||||||||||||||
7994 | wheelEvent(static_cast<QWheelEvent*>(ev)); | - | ||||||||||||||||||||||||
7995 | break; executed 10 times by 2 tests: break; Executed by:
| 10 | ||||||||||||||||||||||||
7996 | #endif | - | ||||||||||||||||||||||||
7997 | #if QT_CONFIG(draganddrop) | - | ||||||||||||||||||||||||
7998 | case QEvent::DragEnter: executed 256 times by 3 tests: case QEvent::DragEnter: Executed by:
| 256 | ||||||||||||||||||||||||
7999 | dragEnterEvent(static_cast<QDragEnterEvent*>(ev)); | - | ||||||||||||||||||||||||
8000 | break; executed 256 times by 3 tests: break; Executed by:
| 256 | ||||||||||||||||||||||||
8001 | case QEvent::DragLeave: executed 150 times by 3 tests: case QEvent::DragLeave: Executed by:
| 150 | ||||||||||||||||||||||||
8002 | dragLeaveEvent(static_cast<QDragLeaveEvent*>(ev)); | - | ||||||||||||||||||||||||
8003 | break; executed 150 times by 3 tests: break; Executed by:
| 150 | ||||||||||||||||||||||||
8004 | case QEvent::DragMove: executed 216 times by 3 tests: case QEvent::DragMove: Executed by:
| 216 | ||||||||||||||||||||||||
8005 | dragMoveEvent(static_cast<QDragMoveEvent*>(ev)); | - | ||||||||||||||||||||||||
8006 | break; executed 216 times by 3 tests: break; Executed by:
| 216 | ||||||||||||||||||||||||
8007 | case QEvent::Drop: executed 50 times by 2 tests: case QEvent::Drop: Executed by:
| 50 | ||||||||||||||||||||||||
8008 | dropEvent(static_cast<QDropEvent*>(ev)); | - | ||||||||||||||||||||||||
8009 | break; executed 50 times by 2 tests: break; Executed by:
| 50 | ||||||||||||||||||||||||
8010 | #endif // draganddrop | - | ||||||||||||||||||||||||
8011 | #if QT_CONFIG(gestures) | - | ||||||||||||||||||||||||
8012 | case QEvent::NativeGesture: never executed: case QEvent::NativeGesture: | 0 | ||||||||||||||||||||||||
8013 | ev->ignore(); | - | ||||||||||||||||||||||||
8014 | break; never executed: break; | 0 | ||||||||||||||||||||||||
8015 | #endif // gestures | - | ||||||||||||||||||||||||
8016 | default: executed 148991 times by 111 tests: default: Executed by:
| 148991 | ||||||||||||||||||||||||
8017 | return QObject::event(ev); executed 148991 times by 111 tests: return QObject::event(ev); Executed by:
| 148991 | ||||||||||||||||||||||||
8018 | } | - | ||||||||||||||||||||||||
8019 | - | |||||||||||||||||||||||||
8020 | return true; executed 27127 times by 28 tests: return true; Executed by:
| 27127 | ||||||||||||||||||||||||
8021 | } | - | ||||||||||||||||||||||||
8022 | - | |||||||||||||||||||||||||
8023 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||||||||||||||
8024 | // FIXME: Qt 6: Make this QDebug operator<<(QDebug debug, const QQuickItem *item) | - | ||||||||||||||||||||||||
8025 | QDebug operator<<(QDebug debug, QQuickItem *item) | - | ||||||||||||||||||||||||
8026 | { | - | ||||||||||||||||||||||||
8027 | QDebugStateSaver saver(debug); | - | ||||||||||||||||||||||||
8028 | debug.nospace(); | - | ||||||||||||||||||||||||
8029 | if (!item) {
| 0-52 | ||||||||||||||||||||||||
8030 | debug << "QQuickItem(0)"; | - | ||||||||||||||||||||||||
8031 | return debug; never executed: return debug; | 0 | ||||||||||||||||||||||||
8032 | } | - | ||||||||||||||||||||||||
8033 | - | |||||||||||||||||||||||||
8034 | const QRectF rect(item->position(), QSizeF(item->width(), item->height())); | - | ||||||||||||||||||||||||
8035 | - | |||||||||||||||||||||||||
8036 | debug << item->metaObject()->className() << '(' << static_cast<void *>(item); | - | ||||||||||||||||||||||||
8037 | if (!item->objectName().isEmpty())
| 24-28 | ||||||||||||||||||||||||
8038 | debug << ", name=" << item->objectName(); executed 28 times by 2 tests: debug << ", name=" << item->objectName(); Executed by:
| 28 | ||||||||||||||||||||||||
8039 | debug << ", parent=" << static_cast<void *>(item->parentItem()) | - | ||||||||||||||||||||||||
8040 | << ", geometry="; | - | ||||||||||||||||||||||||
8041 | QtDebugUtils::formatQRect(debug, rect); | - | ||||||||||||||||||||||||
8042 | if (const qreal z = item->z())
| 0-52 | ||||||||||||||||||||||||
8043 | debug << ", z=" << z; never executed: debug << ", z=" << z; | 0 | ||||||||||||||||||||||||
8044 | debug << ')'; | - | ||||||||||||||||||||||||
8045 | return debug; executed 52 times by 2 tests: return debug; Executed by:
| 52 | ||||||||||||||||||||||||
8046 | } | - | ||||||||||||||||||||||||
8047 | #endif | - | ||||||||||||||||||||||||
8048 | - | |||||||||||||||||||||||||
8049 | /*! | - | ||||||||||||||||||||||||
8050 | \fn bool QQuickItem::isTextureProvider() const | - | ||||||||||||||||||||||||
8051 | - | |||||||||||||||||||||||||
8052 | Returns true if this item is a texture provider. The default | - | ||||||||||||||||||||||||
8053 | implementation returns false. | - | ||||||||||||||||||||||||
8054 | - | |||||||||||||||||||||||||
8055 | This function can be called from any thread. | - | ||||||||||||||||||||||||
8056 | */ | - | ||||||||||||||||||||||||
8057 | - | |||||||||||||||||||||||||
8058 | bool QQuickItem::isTextureProvider() const | - | ||||||||||||||||||||||||
8059 | { | - | ||||||||||||||||||||||||
8060 | #if QT_CONFIG(quick_shadereffect) | - | ||||||||||||||||||||||||
8061 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
8062 | return d->extra.isAllocated() && d->extra->layer && d->extra->layer->effectSource() ? executed 16 times by 4 tests: return d->extra.isAllocated() && d->extra->layer && d->extra->layer->effectSource() ? d->extra->layer->effectSource()->isTextureProvider() : false; Executed by:
| 16 | ||||||||||||||||||||||||
8063 | d->extra->layer->effectSource()->isTextureProvider() : false; executed 16 times by 4 tests: return d->extra.isAllocated() && d->extra->layer && d->extra->layer->effectSource() ? d->extra->layer->effectSource()->isTextureProvider() : false; Executed by:
| 16 | ||||||||||||||||||||||||
8064 | #else | - | ||||||||||||||||||||||||
8065 | return false; | - | ||||||||||||||||||||||||
8066 | #endif | - | ||||||||||||||||||||||||
8067 | } | - | ||||||||||||||||||||||||
8068 | - | |||||||||||||||||||||||||
8069 | /*! | - | ||||||||||||||||||||||||
8070 | \fn QSGTextureProvider *QQuickItem::textureProvider() const | - | ||||||||||||||||||||||||
8071 | - | |||||||||||||||||||||||||
8072 | Returns the texture provider for an item. The default implementation | - | ||||||||||||||||||||||||
8073 | returns 0. | - | ||||||||||||||||||||||||
8074 | - | |||||||||||||||||||||||||
8075 | This function may only be called on the rendering thread. | - | ||||||||||||||||||||||||
8076 | */ | - | ||||||||||||||||||||||||
8077 | - | |||||||||||||||||||||||||
8078 | QSGTextureProvider *QQuickItem::textureProvider() const | - | ||||||||||||||||||||||||
8079 | { | - | ||||||||||||||||||||||||
8080 | #if QT_CONFIG(quick_shadereffect) | - | ||||||||||||||||||||||||
8081 | Q_D(const QQuickItem); | - | ||||||||||||||||||||||||
8082 | return d->extra.isAllocated() && d->extra->layer && d->extra->layer->effectSource() ? executed 12 times by 2 tests: return d->extra.isAllocated() && d->extra->layer && d->extra->layer->effectSource() ? d->extra->layer->effectSource()->textureProvider() : nullptr; Executed by:
| 12 | ||||||||||||||||||||||||
8083 | d->extra->layer->effectSource()->textureProvider() : nullptr; executed 12 times by 2 tests: return d->extra.isAllocated() && d->extra->layer && d->extra->layer->effectSource() ? d->extra->layer->effectSource()->textureProvider() : nullptr; Executed by:
| 12 | ||||||||||||||||||||||||
8084 | #else | - | ||||||||||||||||||||||||
8085 | return 0; | - | ||||||||||||||||||||||||
8086 | #endif | - | ||||||||||||||||||||||||
8087 | } | - | ||||||||||||||||||||||||
8088 | - | |||||||||||||||||||||||||
8089 | /*! | - | ||||||||||||||||||||||||
8090 | \property QQuickItem::layer | - | ||||||||||||||||||||||||
8091 | \internal | - | ||||||||||||||||||||||||
8092 | */ | - | ||||||||||||||||||||||||
8093 | QQuickItemLayer *QQuickItemPrivate::layer() const | - | ||||||||||||||||||||||||
8094 | { | - | ||||||||||||||||||||||||
8095 | #if QT_CONFIG(quick_shadereffect) | - | ||||||||||||||||||||||||
8096 | if (!extra.isAllocated() || !extra->layer) {
| 14-318 | ||||||||||||||||||||||||
8097 | extra.value().layer = new QQuickItemLayer(const_cast<QQuickItem *>(q_func())); | - | ||||||||||||||||||||||||
8098 | if (!componentComplete)
| 54-82 | ||||||||||||||||||||||||
8099 | extra->layer->classBegin(); executed 82 times by 2 tests: extra->layer->classBegin(); Executed by:
| 82 | ||||||||||||||||||||||||
8100 | } executed 136 times by 9 tests: end of block Executed by:
| 136 | ||||||||||||||||||||||||
8101 | return extra->layer; executed 332 times by 9 tests: return extra->layer; Executed by:
| 332 | ||||||||||||||||||||||||
8102 | #else | - | ||||||||||||||||||||||||
8103 | return 0; | - | ||||||||||||||||||||||||
8104 | #endif | - | ||||||||||||||||||||||||
8105 | } | - | ||||||||||||||||||||||||
8106 | - | |||||||||||||||||||||||||
8107 | bool QQuickItemPrivate::hasPointerHandlers() const | - | ||||||||||||||||||||||||
8108 | { | - | ||||||||||||||||||||||||
8109 | return extra.isAllocated() && !extra->pointerHandlers.isEmpty(); executed 71875 times by 24 tests: return extra.isAllocated() && !extra->pointerHandlers.isEmpty(); Executed by:
| 71875 | ||||||||||||||||||||||||
8110 | } | - | ||||||||||||||||||||||||
8111 | - | |||||||||||||||||||||||||
8112 | bool QQuickItemPrivate::hasHoverHandlers() const | - | ||||||||||||||||||||||||
8113 | { | - | ||||||||||||||||||||||||
8114 | if (!hasPointerHandlers())
| 0-662 | ||||||||||||||||||||||||
8115 | return false; executed 662 times by 7 tests: return false; Executed by:
| 662 | ||||||||||||||||||||||||
8116 | for (QQuickPointerHandler *h : extra->pointerHandlers) | - | ||||||||||||||||||||||||
8117 | if (qmlobject_cast<QQuickHoverHandler *>(h))
| 0 | ||||||||||||||||||||||||
8118 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
8119 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
8120 | } | - | ||||||||||||||||||||||||
8121 | - | |||||||||||||||||||||||||
8122 | #if QT_CONFIG(quick_shadereffect) | - | ||||||||||||||||||||||||
8123 | QQuickItemLayer::QQuickItemLayer(QQuickItem *item) | - | ||||||||||||||||||||||||
8124 | : m_item(item) | - | ||||||||||||||||||||||||
8125 | , m_enabled(false) | - | ||||||||||||||||||||||||
8126 | , m_mipmap(false) | - | ||||||||||||||||||||||||
8127 | , m_smooth(false) | - | ||||||||||||||||||||||||
8128 | , m_componentComplete(true) | - | ||||||||||||||||||||||||
8129 | , m_wrapMode(QQuickShaderEffectSource::ClampToEdge) | - | ||||||||||||||||||||||||
8130 | , m_format(QQuickShaderEffectSource::RGBA) | - | ||||||||||||||||||||||||
8131 | , m_name("source") | - | ||||||||||||||||||||||||
8132 | , m_effectComponent(nullptr) | - | ||||||||||||||||||||||||
8133 | , m_effect(nullptr) | - | ||||||||||||||||||||||||
8134 | , m_effectSource(nullptr) | - | ||||||||||||||||||||||||
8135 | , m_textureMirroring(QQuickShaderEffectSource::MirrorVertically) | - | ||||||||||||||||||||||||
8136 | , m_samples(0) | - | ||||||||||||||||||||||||
8137 | { | - | ||||||||||||||||||||||||
8138 | } executed 136 times by 9 tests: end of block Executed by:
| 136 | ||||||||||||||||||||||||
8139 | - | |||||||||||||||||||||||||
8140 | QQuickItemLayer::~QQuickItemLayer() | - | ||||||||||||||||||||||||
8141 | { | - | ||||||||||||||||||||||||
8142 | delete m_effectSource; | - | ||||||||||||||||||||||||
8143 | delete m_effect; | - | ||||||||||||||||||||||||
8144 | } executed 134 times by 9 tests: end of block Executed by:
| 134 | ||||||||||||||||||||||||
8145 | - | |||||||||||||||||||||||||
8146 | /*! | - | ||||||||||||||||||||||||
8147 | \qmlproperty bool QtQuick::Item::layer.enabled | - | ||||||||||||||||||||||||
8148 | - | |||||||||||||||||||||||||
8149 | Holds whether the item is layered or not. Layering is disabled by default. | - | ||||||||||||||||||||||||
8150 | - | |||||||||||||||||||||||||
8151 | A layered item is rendered into an offscreen surface and cached until | - | ||||||||||||||||||||||||
8152 | it is changed. Enabling layering for complex QML item hierarchies can | - | ||||||||||||||||||||||||
8153 | sometimes be an optimization. | - | ||||||||||||||||||||||||
8154 | - | |||||||||||||||||||||||||
8155 | None of the other layer properties have any effect when the layer | - | ||||||||||||||||||||||||
8156 | is disabled. | - | ||||||||||||||||||||||||
8157 | - | |||||||||||||||||||||||||
8158 | \sa {Item Layers} | - | ||||||||||||||||||||||||
8159 | */ | - | ||||||||||||||||||||||||
8160 | void QQuickItemLayer::setEnabled(bool e) | - | ||||||||||||||||||||||||
8161 | { | - | ||||||||||||||||||||||||
8162 | if (e == m_enabled)
| 6-86 | ||||||||||||||||||||||||
8163 | return; executed 6 times by 1 test: return; Executed by:
| 6 | ||||||||||||||||||||||||
8164 | m_enabled = e; | - | ||||||||||||||||||||||||
8165 | if (m_componentComplete) {
| 10-76 | ||||||||||||||||||||||||
8166 | if (m_enabled)
| 4-6 | ||||||||||||||||||||||||
8167 | activate(); executed 6 times by 1 test: activate(); Executed by:
| 6 | ||||||||||||||||||||||||
8168 | else | - | ||||||||||||||||||||||||
8169 | deactivate(); executed 4 times by 1 test: deactivate(); Executed by:
| 4 | ||||||||||||||||||||||||
8170 | } | - | ||||||||||||||||||||||||
8171 | - | |||||||||||||||||||||||||
8172 | emit enabledChanged(e); | - | ||||||||||||||||||||||||
8173 | } executed 86 times by 2 tests: end of block Executed by:
| 86 | ||||||||||||||||||||||||
8174 | - | |||||||||||||||||||||||||
8175 | void QQuickItemLayer::classBegin() | - | ||||||||||||||||||||||||
8176 | { | - | ||||||||||||||||||||||||
8177 | Q_ASSERT(!m_effectSource); | - | ||||||||||||||||||||||||
8178 | Q_ASSERT(!m_effect); | - | ||||||||||||||||||||||||
8179 | m_componentComplete = false; | - | ||||||||||||||||||||||||
8180 | } executed 82 times by 2 tests: end of block Executed by:
| 82 | ||||||||||||||||||||||||
8181 | - | |||||||||||||||||||||||||
8182 | void QQuickItemLayer::componentComplete() | - | ||||||||||||||||||||||||
8183 | { | - | ||||||||||||||||||||||||
8184 | Q_ASSERT(!m_componentComplete); | - | ||||||||||||||||||||||||
8185 | m_componentComplete = true; | - | ||||||||||||||||||||||||
8186 | if (m_enabled)
| 6-76 | ||||||||||||||||||||||||
8187 | activate(); executed 76 times by 2 tests: activate(); Executed by:
| 76 | ||||||||||||||||||||||||
8188 | } executed 82 times by 2 tests: end of block Executed by:
| 82 | ||||||||||||||||||||||||
8189 | - | |||||||||||||||||||||||||
8190 | void QQuickItemLayer::activate() | - | ||||||||||||||||||||||||
8191 | { | - | ||||||||||||||||||||||||
8192 | Q_ASSERT(!m_effectSource); | - | ||||||||||||||||||||||||
8193 | m_effectSource = new QQuickShaderEffectSource(); | - | ||||||||||||||||||||||||
8194 | QQuickItemPrivate::get(m_effectSource)->setTransparentForPositioner(true); | - | ||||||||||||||||||||||||
8195 | - | |||||||||||||||||||||||||
8196 | QQuickItem *parentItem = m_item->parentItem(); | - | ||||||||||||||||||||||||
8197 | if (parentItem) {
| 2-80 | ||||||||||||||||||||||||
8198 | m_effectSource->setParentItem(parentItem); | - | ||||||||||||||||||||||||
8199 | m_effectSource->stackAfter(m_item); | - | ||||||||||||||||||||||||
8200 | } executed 80 times by 2 tests: end of block Executed by:
| 80 | ||||||||||||||||||||||||
8201 | - | |||||||||||||||||||||||||
8202 | m_effectSource->setSourceItem(m_item); | - | ||||||||||||||||||||||||
8203 | m_effectSource->setHideSource(true); | - | ||||||||||||||||||||||||
8204 | m_effectSource->setSmooth(m_smooth); | - | ||||||||||||||||||||||||
8205 | m_effectSource->setTextureSize(m_size); | - | ||||||||||||||||||||||||
8206 | m_effectSource->setSourceRect(m_sourceRect); | - | ||||||||||||||||||||||||
8207 | m_effectSource->setMipmap(m_mipmap); | - | ||||||||||||||||||||||||
8208 | m_effectSource->setWrapMode(m_wrapMode); | - | ||||||||||||||||||||||||
8209 | m_effectSource->setFormat(m_format); | - | ||||||||||||||||||||||||
8210 | m_effectSource->setTextureMirroring(m_textureMirroring); | - | ||||||||||||||||||||||||
8211 | m_effectSource->setSamples(m_samples); | - | ||||||||||||||||||||||||
8212 | - | |||||||||||||||||||||||||
8213 | if (m_effectComponent)
| 22-60 | ||||||||||||||||||||||||
8214 | activateEffect(); executed 22 times by 2 tests: activateEffect(); Executed by:
| 22 | ||||||||||||||||||||||||
8215 | - | |||||||||||||||||||||||||
8216 | m_effectSource->setVisible(m_item->isVisible() && !m_effect); | - | ||||||||||||||||||||||||
8217 | - | |||||||||||||||||||||||||
8218 | updateZ(); | - | ||||||||||||||||||||||||
8219 | updateGeometry(); | - | ||||||||||||||||||||||||
8220 | updateOpacity(); | - | ||||||||||||||||||||||||
8221 | updateMatrix(); | - | ||||||||||||||||||||||||
8222 | - | |||||||||||||||||||||||||
8223 | QQuickItemPrivate *id = QQuickItemPrivate::get(m_item); | - | ||||||||||||||||||||||||
8224 | id->addItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Opacity | QQuickItemPrivate::Parent | QQuickItemPrivate::Visibility | QQuickItemPrivate::SiblingOrder); | - | ||||||||||||||||||||||||
8225 | } executed 82 times by 2 tests: end of block Executed by:
| 82 | ||||||||||||||||||||||||
8226 | - | |||||||||||||||||||||||||
8227 | void QQuickItemLayer::deactivate() | - | ||||||||||||||||||||||||
8228 | { | - | ||||||||||||||||||||||||
8229 | Q_ASSERT(m_effectSource); | - | ||||||||||||||||||||||||
8230 | - | |||||||||||||||||||||||||
8231 | if (m_effectComponent)
| 2 | ||||||||||||||||||||||||
8232 | deactivateEffect(); executed 2 times by 1 test: deactivateEffect(); Executed by:
| 2 | ||||||||||||||||||||||||
8233 | - | |||||||||||||||||||||||||
8234 | delete m_effectSource; | - | ||||||||||||||||||||||||
8235 | m_effectSource = nullptr; | - | ||||||||||||||||||||||||
8236 | - | |||||||||||||||||||||||||
8237 | QQuickItemPrivate *id = QQuickItemPrivate::get(m_item); | - | ||||||||||||||||||||||||
8238 | id->removeItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Opacity | QQuickItemPrivate::Parent | QQuickItemPrivate::Visibility | QQuickItemPrivate::SiblingOrder); | - | ||||||||||||||||||||||||
8239 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
8240 | - | |||||||||||||||||||||||||
8241 | void QQuickItemLayer::activateEffect() | - | ||||||||||||||||||||||||
8242 | { | - | ||||||||||||||||||||||||
8243 | Q_ASSERT(m_effectSource); | - | ||||||||||||||||||||||||
8244 | Q_ASSERT(m_effectComponent); | - | ||||||||||||||||||||||||
8245 | Q_ASSERT(!m_effect); | - | ||||||||||||||||||||||||
8246 | - | |||||||||||||||||||||||||
8247 | QObject *created = m_effectComponent->beginCreate(m_effectComponent->creationContext()); | - | ||||||||||||||||||||||||
8248 | m_effect = qobject_cast<QQuickItem *>(created); | - | ||||||||||||||||||||||||
8249 | if (!m_effect) {
| 0-40 | ||||||||||||||||||||||||
8250 | qWarning("Item: layer.effect is not a QML Item."); | - | ||||||||||||||||||||||||
8251 | m_effectComponent->completeCreate(); | - | ||||||||||||||||||||||||
8252 | delete created; | - | ||||||||||||||||||||||||
8253 | return; never executed: return; | 0 | ||||||||||||||||||||||||
8254 | } | - | ||||||||||||||||||||||||
8255 | QQuickItem *parentItem = m_item->parentItem(); | - | ||||||||||||||||||||||||
8256 | if (parentItem) {
| 2-38 | ||||||||||||||||||||||||
8257 | m_effect->setParentItem(parentItem); | - | ||||||||||||||||||||||||
8258 | m_effect->stackAfter(m_effectSource); | - | ||||||||||||||||||||||||
8259 | } executed 38 times by 2 tests: end of block Executed by:
| 38 | ||||||||||||||||||||||||
8260 | m_effect->setVisible(m_item->isVisible()); | - | ||||||||||||||||||||||||
8261 | m_effect->setProperty(m_name, qVariantFromValue<QObject *>(m_effectSource)); | - | ||||||||||||||||||||||||
8262 | QQuickItemPrivate::get(m_effect)->setTransparentForPositioner(true); | - | ||||||||||||||||||||||||
8263 | m_effectComponent->completeCreate(); | - | ||||||||||||||||||||||||
8264 | } executed 40 times by 2 tests: end of block Executed by:
| 40 | ||||||||||||||||||||||||
8265 | - | |||||||||||||||||||||||||
8266 | void QQuickItemLayer::deactivateEffect() | - | ||||||||||||||||||||||||
8267 | { | - | ||||||||||||||||||||||||
8268 | Q_ASSERT(m_effectSource); | - | ||||||||||||||||||||||||
8269 | Q_ASSERT(m_effectComponent); | - | ||||||||||||||||||||||||
8270 | - | |||||||||||||||||||||||||
8271 | delete m_effect; | - | ||||||||||||||||||||||||
8272 | m_effect = nullptr; | - | ||||||||||||||||||||||||
8273 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
8274 | - | |||||||||||||||||||||||||
8275 | - | |||||||||||||||||||||||||
8276 | /*! | - | ||||||||||||||||||||||||
8277 | \qmlproperty Component QtQuick::Item::layer.effect | - | ||||||||||||||||||||||||
8278 | - | |||||||||||||||||||||||||
8279 | Holds the effect that is applied to this layer. | - | ||||||||||||||||||||||||
8280 | - | |||||||||||||||||||||||||
8281 | The effect is typically a \l ShaderEffect component, although any \l Item component can be | - | ||||||||||||||||||||||||
8282 | assigned. The effect should have a source texture property with a name matching \l layer.samplerName. | - | ||||||||||||||||||||||||
8283 | - | |||||||||||||||||||||||||
8284 | \sa layer.samplerName, {Item Layers} | - | ||||||||||||||||||||||||
8285 | */ | - | ||||||||||||||||||||||||
8286 | - | |||||||||||||||||||||||||
8287 | void QQuickItemLayer::setEffect(QQmlComponent *component) | - | ||||||||||||||||||||||||
8288 | { | - | ||||||||||||||||||||||||
8289 | if (component == m_effectComponent)
| 6-40 | ||||||||||||||||||||||||
8290 | return; executed 6 times by 1 test: return; Executed by:
| 6 | ||||||||||||||||||||||||
8291 | - | |||||||||||||||||||||||||
8292 | bool updateNeeded = false; | - | ||||||||||||||||||||||||
8293 | if (m_effectSource && m_effectComponent) {
| 0-22 | ||||||||||||||||||||||||
8294 | deactivateEffect(); | - | ||||||||||||||||||||||||
8295 | updateNeeded = true; | - | ||||||||||||||||||||||||
8296 | } never executed: end of block | 0 | ||||||||||||||||||||||||
8297 | - | |||||||||||||||||||||||||
8298 | m_effectComponent = component; | - | ||||||||||||||||||||||||
8299 | - | |||||||||||||||||||||||||
8300 | if (m_effectSource && m_effectComponent) {
| 0-22 | ||||||||||||||||||||||||
8301 | activateEffect(); | - | ||||||||||||||||||||||||
8302 | updateNeeded = true; | - | ||||||||||||||||||||||||
8303 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
8304 | - | |||||||||||||||||||||||||
8305 | if (updateNeeded) {
| 18-22 | ||||||||||||||||||||||||
8306 | updateZ(); | - | ||||||||||||||||||||||||
8307 | updateGeometry(); | - | ||||||||||||||||||||||||
8308 | updateOpacity(); | - | ||||||||||||||||||||||||
8309 | updateMatrix(); | - | ||||||||||||||||||||||||
8310 | m_effectSource->setVisible(m_item->isVisible() && !m_effect); | - | ||||||||||||||||||||||||
8311 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
8312 | - | |||||||||||||||||||||||||
8313 | emit effectChanged(component); | - | ||||||||||||||||||||||||
8314 | } executed 40 times by 2 tests: end of block Executed by:
| 40 | ||||||||||||||||||||||||
8315 | - | |||||||||||||||||||||||||
8316 | - | |||||||||||||||||||||||||
8317 | /*! | - | ||||||||||||||||||||||||
8318 | \qmlproperty bool QtQuick::Item::layer.mipmap | - | ||||||||||||||||||||||||
8319 | - | |||||||||||||||||||||||||
8320 | If this property is true, mipmaps are generated for the texture. | - | ||||||||||||||||||||||||
8321 | - | |||||||||||||||||||||||||
8322 | \note Some OpenGL ES 2 implementations do not support mipmapping of | - | ||||||||||||||||||||||||
8323 | non-power-of-two textures. | - | ||||||||||||||||||||||||
8324 | - | |||||||||||||||||||||||||
8325 | \sa {Item Layers} | - | ||||||||||||||||||||||||
8326 | */ | - | ||||||||||||||||||||||||
8327 | - | |||||||||||||||||||||||||
8328 | void QQuickItemLayer::setMipmap(bool mipmap) | - | ||||||||||||||||||||||||
8329 | { | - | ||||||||||||||||||||||||
8330 | if (mipmap == m_mipmap)
| 0-2 | ||||||||||||||||||||||||
8331 | return; never executed: return; | 0 | ||||||||||||||||||||||||
8332 | m_mipmap = mipmap; | - | ||||||||||||||||||||||||
8333 | - | |||||||||||||||||||||||||
8334 | if (m_effectSource)
| 0-2 | ||||||||||||||||||||||||
8335 | m_effectSource->setMipmap(m_mipmap); never executed: m_effectSource->setMipmap(m_mipmap); | 0 | ||||||||||||||||||||||||
8336 | - | |||||||||||||||||||||||||
8337 | emit mipmapChanged(mipmap); | - | ||||||||||||||||||||||||
8338 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
8339 | - | |||||||||||||||||||||||||
8340 | - | |||||||||||||||||||||||||
8341 | /*! | - | ||||||||||||||||||||||||
8342 | \qmlproperty enumeration QtQuick::Item::layer.format | - | ||||||||||||||||||||||||
8343 | - | |||||||||||||||||||||||||
8344 | This property defines the internal OpenGL format of the texture. | - | ||||||||||||||||||||||||
8345 | Modifying this property makes most sense when the \a layer.effect is also | - | ||||||||||||||||||||||||
8346 | specified. Depending on the OpenGL implementation, this property might | - | ||||||||||||||||||||||||
8347 | allow you to save some texture memory. | - | ||||||||||||||||||||||||
8348 | - | |||||||||||||||||||||||||
8349 | \list | - | ||||||||||||||||||||||||
8350 | \li ShaderEffectSource.Alpha - GL_ALPHA; | - | ||||||||||||||||||||||||
8351 | \li ShaderEffectSource.RGB - GL_RGB | - | ||||||||||||||||||||||||
8352 | \li ShaderEffectSource.RGBA - GL_RGBA | - | ||||||||||||||||||||||||
8353 | \endlist | - | ||||||||||||||||||||||||
8354 | - | |||||||||||||||||||||||||
8355 | \note ShaderEffectSource.RGB and ShaderEffectSource.Alpha should | - | ||||||||||||||||||||||||
8356 | be used with caution, as support for these formats in the underlying | - | ||||||||||||||||||||||||
8357 | hardare and driver is often not present. | - | ||||||||||||||||||||||||
8358 | - | |||||||||||||||||||||||||
8359 | \sa {Item Layers} | - | ||||||||||||||||||||||||
8360 | */ | - | ||||||||||||||||||||||||
8361 | - | |||||||||||||||||||||||||
8362 | void QQuickItemLayer::setFormat(QQuickShaderEffectSource::Format f) | - | ||||||||||||||||||||||||
8363 | { | - | ||||||||||||||||||||||||
8364 | if (f == m_format)
| 0 | ||||||||||||||||||||||||
8365 | return; never executed: return; | 0 | ||||||||||||||||||||||||
8366 | m_format = f; | - | ||||||||||||||||||||||||
8367 | - | |||||||||||||||||||||||||
8368 | if (m_effectSource)
| 0 | ||||||||||||||||||||||||
8369 | m_effectSource->setFormat(m_format); never executed: m_effectSource->setFormat(m_format); | 0 | ||||||||||||||||||||||||
8370 | - | |||||||||||||||||||||||||
8371 | emit formatChanged(m_format); | - | ||||||||||||||||||||||||
8372 | } never executed: end of block | 0 | ||||||||||||||||||||||||
8373 | - | |||||||||||||||||||||||||
8374 | - | |||||||||||||||||||||||||
8375 | /*! | - | ||||||||||||||||||||||||
8376 | \qmlproperty rect QtQuick::Item::layer.sourceRect | - | ||||||||||||||||||||||||
8377 | - | |||||||||||||||||||||||||
8378 | This property defines the rectangular area of the item that should be | - | ||||||||||||||||||||||||
8379 | rendered into the texture. The source rectangle can be larger than | - | ||||||||||||||||||||||||
8380 | the item itself. If the rectangle is null, which is the default, | - | ||||||||||||||||||||||||
8381 | then the whole item is rendered to the texture. | - | ||||||||||||||||||||||||
8382 | - | |||||||||||||||||||||||||
8383 | \sa {Item Layers} | - | ||||||||||||||||||||||||
8384 | */ | - | ||||||||||||||||||||||||
8385 | - | |||||||||||||||||||||||||
8386 | void QQuickItemLayer::setSourceRect(const QRectF &sourceRect) | - | ||||||||||||||||||||||||
8387 | { | - | ||||||||||||||||||||||||
8388 | if (sourceRect == m_sourceRect)
| 0-2 | ||||||||||||||||||||||||
8389 | return; never executed: return; | 0 | ||||||||||||||||||||||||
8390 | m_sourceRect = sourceRect; | - | ||||||||||||||||||||||||
8391 | - | |||||||||||||||||||||||||
8392 | if (m_effectSource)
| 0-2 | ||||||||||||||||||||||||
8393 | m_effectSource->setSourceRect(m_sourceRect); never executed: m_effectSource->setSourceRect(m_sourceRect); | 0 | ||||||||||||||||||||||||
8394 | - | |||||||||||||||||||||||||
8395 | emit sourceRectChanged(sourceRect); | - | ||||||||||||||||||||||||
8396 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
8397 | - | |||||||||||||||||||||||||
8398 | /*! | - | ||||||||||||||||||||||||
8399 | \qmlproperty bool QtQuick::Item::layer.smooth | - | ||||||||||||||||||||||||
8400 | - | |||||||||||||||||||||||||
8401 | Holds whether the layer is smoothly transformed. | - | ||||||||||||||||||||||||
8402 | - | |||||||||||||||||||||||||
8403 | \sa {Item Layers} | - | ||||||||||||||||||||||||
8404 | */ | - | ||||||||||||||||||||||||
8405 | - | |||||||||||||||||||||||||
8406 | void QQuickItemLayer::setSmooth(bool s) | - | ||||||||||||||||||||||||
8407 | { | - | ||||||||||||||||||||||||
8408 | if (m_smooth == s)
| 0-10 | ||||||||||||||||||||||||
8409 | return; never executed: return; | 0 | ||||||||||||||||||||||||
8410 | m_smooth = s; | - | ||||||||||||||||||||||||
8411 | - | |||||||||||||||||||||||||
8412 | if (m_effectSource)
| 0-10 | ||||||||||||||||||||||||
8413 | m_effectSource->setSmooth(m_smooth); never executed: m_effectSource->setSmooth(m_smooth); | 0 | ||||||||||||||||||||||||
8414 | - | |||||||||||||||||||||||||
8415 | emit smoothChanged(s); | - | ||||||||||||||||||||||||
8416 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||
8417 | - | |||||||||||||||||||||||||
8418 | /*! | - | ||||||||||||||||||||||||
8419 | \qmlproperty size QtQuick::Item::layer.textureSize | - | ||||||||||||||||||||||||
8420 | - | |||||||||||||||||||||||||
8421 | This property holds the requested pixel size of the layers texture. If it is empty, | - | ||||||||||||||||||||||||
8422 | which is the default, the size of the item is used. | - | ||||||||||||||||||||||||
8423 | - | |||||||||||||||||||||||||
8424 | \note Some platforms have a limit on how small framebuffer objects can be, | - | ||||||||||||||||||||||||
8425 | which means the actual texture size might be larger than the requested | - | ||||||||||||||||||||||||
8426 | size. | - | ||||||||||||||||||||||||
8427 | - | |||||||||||||||||||||||||
8428 | \sa {Item Layers} | - | ||||||||||||||||||||||||
8429 | */ | - | ||||||||||||||||||||||||
8430 | - | |||||||||||||||||||||||||
8431 | void QQuickItemLayer::setSize(const QSize &size) | - | ||||||||||||||||||||||||
8432 | { | - | ||||||||||||||||||||||||
8433 | if (size == m_size)
| 0-2 | ||||||||||||||||||||||||
8434 | return; never executed: return; | 0 | ||||||||||||||||||||||||
8435 | m_size = size; | - | ||||||||||||||||||||||||
8436 | - | |||||||||||||||||||||||||
8437 | if (m_effectSource)
| 0-2 | ||||||||||||||||||||||||
8438 | m_effectSource->setTextureSize(size); never executed: m_effectSource->setTextureSize(size); | 0 | ||||||||||||||||||||||||
8439 | - | |||||||||||||||||||||||||
8440 | emit sizeChanged(size); | - | ||||||||||||||||||||||||
8441 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
8442 | - | |||||||||||||||||||||||||
8443 | /*! | - | ||||||||||||||||||||||||
8444 | \qmlproperty enumeration QtQuick::Item::layer.wrapMode | - | ||||||||||||||||||||||||
8445 | - | |||||||||||||||||||||||||
8446 | This property defines the OpenGL wrap modes associated with the texture. | - | ||||||||||||||||||||||||
8447 | Modifying this property makes most sense when the \a layer.effect is | - | ||||||||||||||||||||||||
8448 | specified. | - | ||||||||||||||||||||||||
8449 | - | |||||||||||||||||||||||||
8450 | \list | - | ||||||||||||||||||||||||
8451 | \li ShaderEffectSource.ClampToEdge - GL_CLAMP_TO_EDGE both horizontally and vertically | - | ||||||||||||||||||||||||
8452 | \li ShaderEffectSource.RepeatHorizontally - GL_REPEAT horizontally, GL_CLAMP_TO_EDGE vertically | - | ||||||||||||||||||||||||
8453 | \li ShaderEffectSource.RepeatVertically - GL_CLAMP_TO_EDGE horizontally, GL_REPEAT vertically | - | ||||||||||||||||||||||||
8454 | \li ShaderEffectSource.Repeat - GL_REPEAT both horizontally and vertically | - | ||||||||||||||||||||||||
8455 | \endlist | - | ||||||||||||||||||||||||
8456 | - | |||||||||||||||||||||||||
8457 | \note Some OpenGL ES 2 implementations do not support the GL_REPEAT | - | ||||||||||||||||||||||||
8458 | wrap mode with non-power-of-two textures. | - | ||||||||||||||||||||||||
8459 | - | |||||||||||||||||||||||||
8460 | \sa {Item Layers} | - | ||||||||||||||||||||||||
8461 | */ | - | ||||||||||||||||||||||||
8462 | - | |||||||||||||||||||||||||
8463 | void QQuickItemLayer::setWrapMode(QQuickShaderEffectSource::WrapMode mode) | - | ||||||||||||||||||||||||
8464 | { | - | ||||||||||||||||||||||||
8465 | if (mode == m_wrapMode)
| 0 | ||||||||||||||||||||||||
8466 | return; never executed: return; | 0 | ||||||||||||||||||||||||
8467 | m_wrapMode = mode; | - | ||||||||||||||||||||||||
8468 | - | |||||||||||||||||||||||||
8469 | if (m_effectSource)
| 0 | ||||||||||||||||||||||||
8470 | m_effectSource->setWrapMode(m_wrapMode); never executed: m_effectSource->setWrapMode(m_wrapMode); | 0 | ||||||||||||||||||||||||
8471 | - | |||||||||||||||||||||||||
8472 | emit wrapModeChanged(mode); | - | ||||||||||||||||||||||||
8473 | } never executed: end of block | 0 | ||||||||||||||||||||||||
8474 | - | |||||||||||||||||||||||||
8475 | /*! | - | ||||||||||||||||||||||||
8476 | \qmlproperty enumeration QtQuick::Item::layer.textureMirroring | - | ||||||||||||||||||||||||
8477 | \since 5.6 | - | ||||||||||||||||||||||||
8478 | - | |||||||||||||||||||||||||
8479 | This property defines how the generated OpenGL texture should be mirrored. | - | ||||||||||||||||||||||||
8480 | The default value is \c{ShaderEffectSource.MirrorVertically}. | - | ||||||||||||||||||||||||
8481 | Custom mirroring can be useful if the generated texture is directly accessed by custom shaders, | - | ||||||||||||||||||||||||
8482 | such as those specified by ShaderEffect. If no effect is specified for the layered | - | ||||||||||||||||||||||||
8483 | item, mirroring has no effect on the UI representation of the item. | - | ||||||||||||||||||||||||
8484 | - | |||||||||||||||||||||||||
8485 | \list | - | ||||||||||||||||||||||||
8486 | \li ShaderEffectSource.NoMirroring - No mirroring | - | ||||||||||||||||||||||||
8487 | \li ShaderEffectSource.MirrorHorizontally - The generated texture is flipped along X-axis. | - | ||||||||||||||||||||||||
8488 | \li ShaderEffectSource.MirrorVertically - The generated texture is flipped along Y-axis. | - | ||||||||||||||||||||||||
8489 | \endlist | - | ||||||||||||||||||||||||
8490 | */ | - | ||||||||||||||||||||||||
8491 | - | |||||||||||||||||||||||||
8492 | void QQuickItemLayer::setTextureMirroring(QQuickShaderEffectSource::TextureMirroring mirroring) | - | ||||||||||||||||||||||||
8493 | { | - | ||||||||||||||||||||||||
8494 | if (mirroring == m_textureMirroring)
| 0-28 | ||||||||||||||||||||||||
8495 | return; never executed: return; | 0 | ||||||||||||||||||||||||
8496 | m_textureMirroring = mirroring; | - | ||||||||||||||||||||||||
8497 | - | |||||||||||||||||||||||||
8498 | if (m_effectSource)
| 12-16 | ||||||||||||||||||||||||
8499 | m_effectSource->setTextureMirroring(m_textureMirroring); executed 12 times by 1 test: m_effectSource->setTextureMirroring(m_textureMirroring); Executed by:
| 12 | ||||||||||||||||||||||||
8500 | - | |||||||||||||||||||||||||
8501 | emit textureMirroringChanged(mirroring); | - | ||||||||||||||||||||||||
8502 | } executed 28 times by 1 test: end of block Executed by:
| 28 | ||||||||||||||||||||||||
8503 | - | |||||||||||||||||||||||||
8504 | /*! | - | ||||||||||||||||||||||||
8505 | \qmlproperty enumeration QtQuick::Item::layer.samples | - | ||||||||||||||||||||||||
8506 | \since 5.10 | - | ||||||||||||||||||||||||
8507 | - | |||||||||||||||||||||||||
8508 | This property allows requesting multisampled rendering in the layer. | - | ||||||||||||||||||||||||
8509 | - | |||||||||||||||||||||||||
8510 | By default multisampling is enabled whenever multisampling is | - | ||||||||||||||||||||||||
8511 | enabled for the entire window, assuming the scenegraph renderer in | - | ||||||||||||||||||||||||
8512 | use and the underlying graphics API supports this. | - | ||||||||||||||||||||||||
8513 | - | |||||||||||||||||||||||||
8514 | By setting the value to 2, 4, etc. multisampled rendering can be requested | - | ||||||||||||||||||||||||
8515 | for a part of the scene without enabling multisampling for the entire | - | ||||||||||||||||||||||||
8516 | scene. This way multisampling is applied only to a given subtree, which can | - | ||||||||||||||||||||||||
8517 | lead to significant performance gains since multisampling is not applied to | - | ||||||||||||||||||||||||
8518 | other parts of the scene. | - | ||||||||||||||||||||||||
8519 | - | |||||||||||||||||||||||||
8520 | \note Enabling multisampling can be potentially expensive regardless of the | - | ||||||||||||||||||||||||
8521 | layer's size, as it incurs a hardware and driver dependent performance and | - | ||||||||||||||||||||||||
8522 | memory cost. | - | ||||||||||||||||||||||||
8523 | - | |||||||||||||||||||||||||
8524 | \note This property is only functional when support for multisample | - | ||||||||||||||||||||||||
8525 | renderbuffers and framebuffer blits is available. Otherwise the value is | - | ||||||||||||||||||||||||
8526 | silently ignored. | - | ||||||||||||||||||||||||
8527 | */ | - | ||||||||||||||||||||||||
8528 | - | |||||||||||||||||||||||||
8529 | void QQuickItemLayer::setSamples(int count) | - | ||||||||||||||||||||||||
8530 | { | - | ||||||||||||||||||||||||
8531 | if (m_samples == count)
| 0-2 | ||||||||||||||||||||||||
8532 | return; never executed: return; | 0 | ||||||||||||||||||||||||
8533 | - | |||||||||||||||||||||||||
8534 | m_samples = count; | - | ||||||||||||||||||||||||
8535 | - | |||||||||||||||||||||||||
8536 | if (m_effectSource)
| 0-2 | ||||||||||||||||||||||||
8537 | m_effectSource->setSamples(m_samples); never executed: m_effectSource->setSamples(m_samples); | 0 | ||||||||||||||||||||||||
8538 | - | |||||||||||||||||||||||||
8539 | emit samplesChanged(count); | - | ||||||||||||||||||||||||
8540 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
8541 | - | |||||||||||||||||||||||||
8542 | /*! | - | ||||||||||||||||||||||||
8543 | \qmlproperty string QtQuick::Item::layer.samplerName | - | ||||||||||||||||||||||||
8544 | - | |||||||||||||||||||||||||
8545 | Holds the name of the effect's source texture property. | - | ||||||||||||||||||||||||
8546 | - | |||||||||||||||||||||||||
8547 | This value must match the name of the effect's source texture property | - | ||||||||||||||||||||||||
8548 | so that the Item can pass the layer's offscreen surface to the effect correctly. | - | ||||||||||||||||||||||||
8549 | - | |||||||||||||||||||||||||
8550 | \sa layer.effect, ShaderEffect, {Item Layers} | - | ||||||||||||||||||||||||
8551 | */ | - | ||||||||||||||||||||||||
8552 | - | |||||||||||||||||||||||||
8553 | void QQuickItemLayer::setName(const QByteArray &name) { | - | ||||||||||||||||||||||||
8554 | if (m_name == name)
| 4-8 | ||||||||||||||||||||||||
8555 | return; executed 8 times by 1 test: return; Executed by:
| 8 | ||||||||||||||||||||||||
8556 | if (m_effect) {
| 2 | ||||||||||||||||||||||||
8557 | m_effect->setProperty(m_name, QVariant()); | - | ||||||||||||||||||||||||
8558 | m_effect->setProperty(name, qVariantFromValue<QObject *>(m_effectSource)); | - | ||||||||||||||||||||||||
8559 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
8560 | m_name = name; | - | ||||||||||||||||||||||||
8561 | emit nameChanged(name); | - | ||||||||||||||||||||||||
8562 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
8563 | - | |||||||||||||||||||||||||
8564 | void QQuickItemLayer::itemOpacityChanged(QQuickItem *item) | - | ||||||||||||||||||||||||
8565 | { | - | ||||||||||||||||||||||||
8566 | Q_UNUSED(item) | - | ||||||||||||||||||||||||
8567 | updateOpacity(); | - | ||||||||||||||||||||||||
8568 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||
8569 | - | |||||||||||||||||||||||||
8570 | void QQuickItemLayer::itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) | - | ||||||||||||||||||||||||
8571 | { | - | ||||||||||||||||||||||||
8572 | updateGeometry(); | - | ||||||||||||||||||||||||
8573 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
8574 | - | |||||||||||||||||||||||||
8575 | void QQuickItemLayer::itemParentChanged(QQuickItem *item, QQuickItem *parent) | - | ||||||||||||||||||||||||
8576 | { | - | ||||||||||||||||||||||||
8577 | Q_UNUSED(item) | - | ||||||||||||||||||||||||
8578 | Q_ASSERT(item == m_item); | - | ||||||||||||||||||||||||
8579 | Q_ASSERT(parent != m_effectSource); | - | ||||||||||||||||||||||||
8580 | Q_ASSERT(parent == nullptr || parent != m_effect); | - | ||||||||||||||||||||||||
8581 | - | |||||||||||||||||||||||||
8582 | m_effectSource->setParentItem(parent); | - | ||||||||||||||||||||||||
8583 | if (parent)
| 2-78 | ||||||||||||||||||||||||
8584 | m_effectSource->stackAfter(m_item); executed 2 times by 1 test: m_effectSource->stackAfter(m_item); Executed by:
| 2 | ||||||||||||||||||||||||
8585 | - | |||||||||||||||||||||||||
8586 | if (m_effect) {
| 40 | ||||||||||||||||||||||||
8587 | m_effect->setParentItem(parent); | - | ||||||||||||||||||||||||
8588 | if (parent)
| 2-38 | ||||||||||||||||||||||||
8589 | m_effect->stackAfter(m_effectSource); executed 2 times by 1 test: m_effect->stackAfter(m_effectSource); Executed by:
| 2 | ||||||||||||||||||||||||
8590 | } executed 40 times by 2 tests: end of block Executed by:
| 40 | ||||||||||||||||||||||||
8591 | } executed 80 times by 2 tests: end of block Executed by:
| 80 | ||||||||||||||||||||||||
8592 | - | |||||||||||||||||||||||||
8593 | void QQuickItemLayer::itemSiblingOrderChanged(QQuickItem *) | - | ||||||||||||||||||||||||
8594 | { | - | ||||||||||||||||||||||||
8595 | m_effectSource->stackAfter(m_item); | - | ||||||||||||||||||||||||
8596 | if (m_effect)
| 0-10 | ||||||||||||||||||||||||
8597 | m_effect->stackAfter(m_effectSource); executed 10 times by 2 tests: m_effect->stackAfter(m_effectSource); Executed by:
| 10 | ||||||||||||||||||||||||
8598 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||
8599 | - | |||||||||||||||||||||||||
8600 | void QQuickItemLayer::itemVisibilityChanged(QQuickItem *) | - | ||||||||||||||||||||||||
8601 | { | - | ||||||||||||||||||||||||
8602 | QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
| 0-12 | ||||||||||||||||||||||||
8603 | Q_ASSERT(l); | - | ||||||||||||||||||||||||
8604 | l->setVisible(m_item->isVisible()); | - | ||||||||||||||||||||||||
8605 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
8606 | - | |||||||||||||||||||||||||
8607 | void QQuickItemLayer::updateZ() | - | ||||||||||||||||||||||||
8608 | { | - | ||||||||||||||||||||||||
8609 | if (!m_componentComplete || !m_enabled)
| 0-106 | ||||||||||||||||||||||||
8610 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
8611 | QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
| 42-62 | ||||||||||||||||||||||||
8612 | Q_ASSERT(l); | - | ||||||||||||||||||||||||
8613 | l->setZ(m_item->z()); | - | ||||||||||||||||||||||||
8614 | } executed 104 times by 2 tests: end of block Executed by:
| 104 | ||||||||||||||||||||||||
8615 | - | |||||||||||||||||||||||||
8616 | void QQuickItemLayer::updateOpacity() | - | ||||||||||||||||||||||||
8617 | { | - | ||||||||||||||||||||||||
8618 | QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
| 48-68 | ||||||||||||||||||||||||
8619 | Q_ASSERT(l); | - | ||||||||||||||||||||||||
8620 | l->setOpacity(m_item->opacity()); | - | ||||||||||||||||||||||||
8621 | } executed 116 times by 2 tests: end of block Executed by:
| 116 | ||||||||||||||||||||||||
8622 | - | |||||||||||||||||||||||||
8623 | void QQuickItemLayer::updateGeometry() | - | ||||||||||||||||||||||||
8624 | { | - | ||||||||||||||||||||||||
8625 | QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
| 44-66 | ||||||||||||||||||||||||
8626 | Q_ASSERT(l); | - | ||||||||||||||||||||||||
8627 | QRectF bounds = m_item->clipRect(); | - | ||||||||||||||||||||||||
8628 | l->setSize(bounds.size()); | - | ||||||||||||||||||||||||
8629 | l->setPosition(bounds.topLeft() + m_item->position()); | - | ||||||||||||||||||||||||
8630 | } executed 110 times by 2 tests: end of block Executed by:
| 110 | ||||||||||||||||||||||||
8631 | - | |||||||||||||||||||||||||
8632 | void QQuickItemLayer::updateMatrix() | - | ||||||||||||||||||||||||
8633 | { | - | ||||||||||||||||||||||||
8634 | // Called directly from transformChanged(), so needs some extra | - | ||||||||||||||||||||||||
8635 | // checks. | - | ||||||||||||||||||||||||
8636 | if (!m_componentComplete || !m_enabled)
| 30-182 | ||||||||||||||||||||||||
8637 | return; executed 102 times by 4 tests: return; Executed by:
| 102 | ||||||||||||||||||||||||
8638 | QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
| 44-66 | ||||||||||||||||||||||||
8639 | Q_ASSERT(l); | - | ||||||||||||||||||||||||
8640 | QQuickItemPrivate *ld = QQuickItemPrivate::get(l); | - | ||||||||||||||||||||||||
8641 | l->setScale(m_item->scale()); | - | ||||||||||||||||||||||||
8642 | l->setRotation(m_item->rotation()); | - | ||||||||||||||||||||||||
8643 | ld->transforms = QQuickItemPrivate::get(m_item)->transforms; | - | ||||||||||||||||||||||||
8644 | if (ld->origin() != QQuickItemPrivate::get(m_item)->origin())
| 0-110 | ||||||||||||||||||||||||
8645 | ld->extra.value().origin = QQuickItemPrivate::get(m_item)->origin(); never executed: ld->extra.value().origin = QQuickItemPrivate::get(m_item)->origin(); | 0 | ||||||||||||||||||||||||
8646 | ld->dirty(QQuickItemPrivate::Transform); | - | ||||||||||||||||||||||||
8647 | } executed 110 times by 2 tests: end of block Executed by:
| 110 | ||||||||||||||||||||||||
8648 | #endif // quick_shadereffect | - | ||||||||||||||||||||||||
8649 | - | |||||||||||||||||||||||||
8650 | QQuickItemPrivate::ExtraData::ExtraData() | - | ||||||||||||||||||||||||
8651 | : z(0), scale(1), rotation(0), opacity(1), | - | ||||||||||||||||||||||||
8652 | contents(nullptr), screenAttached(nullptr), layoutDirectionAttached(nullptr), | - | ||||||||||||||||||||||||
8653 | enterKeyAttached(nullptr), | - | ||||||||||||||||||||||||
8654 | keyHandler(nullptr), | - | ||||||||||||||||||||||||
8655 | #if QT_CONFIG(quick_shadereffect) | - | ||||||||||||||||||||||||
8656 | layer(nullptr), | - | ||||||||||||||||||||||||
8657 | #endif | - | ||||||||||||||||||||||||
8658 | effectRefCount(0), hideRefCount(0), | - | ||||||||||||||||||||||||
8659 | recursiveEffectRefCount(0), | - | ||||||||||||||||||||||||
8660 | opacityNode(nullptr), clipNode(nullptr), rootNode(nullptr), | - | ||||||||||||||||||||||||
8661 | acceptedMouseButtons(nullptr), origin(QQuickItem::Center), | - | ||||||||||||||||||||||||
8662 | transparentForPositioner(false) | - | ||||||||||||||||||||||||
8663 | { | - | ||||||||||||||||||||||||
8664 | } executed 135339 times by 120 tests: end of block Executed by:
| 135339 | ||||||||||||||||||||||||
8665 | - | |||||||||||||||||||||||||
8666 | - | |||||||||||||||||||||||||
8667 | #if QT_CONFIG(accessibility) | - | ||||||||||||||||||||||||
8668 | QAccessible::Role QQuickItemPrivate::accessibleRole() const | - | ||||||||||||||||||||||||
8669 | { | - | ||||||||||||||||||||||||
8670 | Q_Q(const QQuickItem); | - | ||||||||||||||||||||||||
8671 | QQuickAccessibleAttached *accessibleAttached = qobject_cast<QQuickAccessibleAttached *>(qmlAttachedPropertiesObject<QQuickAccessibleAttached>(q, false)); | - | ||||||||||||||||||||||||
8672 | if (accessibleAttached)
| 0-236 | ||||||||||||||||||||||||
8673 | return accessibleAttached->role(); executed 236 times by 1 test: return accessibleAttached->role(); Executed by:
| 236 | ||||||||||||||||||||||||
8674 | - | |||||||||||||||||||||||||
8675 | return QAccessible::NoRole; never executed: return QAccessible::NoRole; | 0 | ||||||||||||||||||||||||
8676 | } | - | ||||||||||||||||||||||||
8677 | #endif | - | ||||||||||||||||||||||||
8678 | - | |||||||||||||||||||||||||
8679 | // helper code to let a visual parent mark its visual children for the garbage collector | - | ||||||||||||||||||||||||
8680 | - | |||||||||||||||||||||||||
8681 | namespace QV4 { | - | ||||||||||||||||||||||||
8682 | namespace Heap { | - | ||||||||||||||||||||||||
8683 | struct QQuickItemWrapper : public QObjectWrapper { | - | ||||||||||||||||||||||||
8684 | static void markObjects(QV4::Heap::Base *that, QV4::MarkStack *markStack); | - | ||||||||||||||||||||||||
8685 | }; | - | ||||||||||||||||||||||||
8686 | } | - | ||||||||||||||||||||||||
8687 | } | - | ||||||||||||||||||||||||
8688 | - | |||||||||||||||||||||||||
8689 | struct QQuickItemWrapper : public QV4::QObjectWrapper { | - | ||||||||||||||||||||||||
8690 | V4_OBJECT2(QQuickItemWrapper, QV4::QObjectWrapper) never executed: end of block never executed: end of block executed 1348668 times by 126 tests: return &static_vtbl; Executed by:
executed 899112 times by 126 tests: return static_cast<QV4::Heap::QQuickItemWrapper *>(m()); Executed by:
executed 449556 times by 126 tests: return dptr; Executed by:
| 0-1348668 | ||||||||||||||||||||||||
8691 | }; | - | ||||||||||||||||||||||||
8692 | - | |||||||||||||||||||||||||
8693 | DEFINE_OBJECT_VTABLE(QQuickItemWrapper); | - | ||||||||||||||||||||||||
8694 | - | |||||||||||||||||||||||||
8695 | void QV4::Heap::QQuickItemWrapper::markObjects(QV4::Heap::Base *that, QV4::MarkStack *markStack) | - | ||||||||||||||||||||||||
8696 | { | - | ||||||||||||||||||||||||
8697 | QObjectWrapper *This = static_cast<QObjectWrapper *>(that); | - | ||||||||||||||||||||||||
8698 | if (QQuickItem *item = static_cast<QQuickItem*>(This->object())) {
| 2-82515 | ||||||||||||||||||||||||
8699 | for (QQuickItem *child : qAsConst(QQuickItemPrivate::get(item)->childItems)) | - | ||||||||||||||||||||||||
8700 | QV4::QObjectWrapper::markWrapper(child, markStack); executed 27386 times by 14 tests: QV4::QObjectWrapper::markWrapper(child, markStack); Executed by:
| 27386 | ||||||||||||||||||||||||
8701 | } executed 82515 times by 21 tests: end of block Executed by:
| 82515 | ||||||||||||||||||||||||
8702 | QObjectWrapper::markObjects(that, markStack); | - | ||||||||||||||||||||||||
8703 | } executed 82517 times by 21 tests: end of block Executed by:
| 82517 | ||||||||||||||||||||||||
8704 | - | |||||||||||||||||||||||||
8705 | quint64 QQuickItemPrivate::_q_createJSWrapper(QV4::ExecutionEngine *engine) | - | ||||||||||||||||||||||||
8706 | { | - | ||||||||||||||||||||||||
8707 | return (engine->memoryManager->allocate<QQuickItemWrapper>(q_func()))->asReturnedValue(); executed 449556 times by 126 tests: return (engine->memoryManager->allocate<QQuickItemWrapper>(q_func()))->asReturnedValue(); Executed by:
| 449556 | ||||||||||||||||||||||||
8708 | } | - | ||||||||||||||||||||||||
8709 | - | |||||||||||||||||||||||||
8710 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
8711 | - | |||||||||||||||||||||||||
8712 | #include <moc_qquickitem.cpp> | - | ||||||||||||||||||||||||
8713 | - | |||||||||||||||||||||||||
8714 | #include "moc_qquickitem_p.cpp" | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |