OpenCoverage

qquickwindowmodule.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickwindowmodule.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the 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 "qquickwindowmodule_p.h"-
41#include "qquickwindowattached_p.h"-
42#include "qquickscreen_p.h"-
43#include "qquickview_p.h"-
44#include <QtQuick/QQuickWindow>-
45#include <QtCore/QCoreApplication>-
46#include <QtQml/QQmlEngine>-
47-
48#include <private/qguiapplication_p.h>-
49#include <private/qqmlengine_p.h>-
50#include <private/qv4qobjectwrapper_p.h>-
51#include <qpa/qplatformintegration.h>-
52-
53QT_BEGIN_NAMESPACE-
54-
55Q_DECLARE_LOGGING_CATEGORY(lcTransient)-
56-
57class QQuickWindowQmlImplPrivate : public QQuickWindowPrivate-
58{-
59public:-
60 QQuickWindowQmlImplPrivate()-
61 : complete(false)-
62 , visible(false)-
63 , visibility(QQuickWindow::AutomaticVisibility)-
64 {-
65 }
executed 150 times by 8 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickshortcut
  • tst_qquicktext
150
66-
67 bool complete;-
68 bool visible;-
69 QQuickWindow::Visibility visibility;-
70 QV4::PersistentValue rootItemMarker;-
71};-
72-
73QQuickWindowQmlImpl::QQuickWindowQmlImpl(QWindow *parent)-
74 : QQuickWindow(*(new QQuickWindowQmlImplPrivate), parent)-
75{-
76 connect(this, &QWindow::visibleChanged, this, &QQuickWindowQmlImpl::visibleChanged);-
77 connect(this, &QWindow::visibilityChanged, this, &QQuickWindowQmlImpl::visibilityChanged);-
78 connect(this, &QWindow::screenChanged, this, &QQuickWindowQmlImpl::screenChanged);-
79}
executed 150 times by 8 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickshortcut
  • tst_qquicktext
150
80-
81void QQuickWindowQmlImpl::setVisible(bool visible)-
82{-
83 Q_D(QQuickWindowQmlImpl);-
84 d->visible = visible;-
85 if (d->complete && (!transientParent() || transientParent()->isVisible()))
d->completeDescription
TRUEevaluated 148 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickshortcut
  • tst_qquicktext
FALSEevaluated 8 times by 3 tests
Evaluated by:
  • tst_qquickanimations
  • tst_qquicklistview
  • tst_qquickloader
!transientParent()Description
TRUEevaluated 144 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickshortcut
  • tst_qquicktext
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickloader
transientParent()->isVisible()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickloader
FALSEnever evaluated
0-148
86 QQuickWindow::setVisible(visible);
executed 148 times by 8 tests: QQuickWindow::setVisible(visible);
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickshortcut
  • tst_qquicktext
148
87}
executed 156 times by 8 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickshortcut
  • tst_qquicktext
156
88-
89void QQuickWindowQmlImpl::setVisibility(Visibility visibility)-
90{-
91 Q_D(QQuickWindowQmlImpl);-
92 d->visibility = visibility;-
93 if (d->complete)
d->completeDescription
TRUEnever evaluated
FALSEnever evaluated
0
94 QQuickWindow::setVisibility(visibility);
never executed: QQuickWindow::setVisibility(visibility);
0
95}
never executed: end of block
0
96-
97QQuickWindowAttached *QQuickWindowQmlImpl::qmlAttachedProperties(QObject *object)-
98{-
99 return new QQuickWindowAttached(object);
never executed: return new QQuickWindowAttached(object);
0
100}-
101-
102void QQuickWindowQmlImpl::classBegin()-
103{-
104 Q_D(QQuickWindowQmlImpl);-
105 QQmlEngine* e = qmlEngine(this);-
106-
107 QQmlEngine::setContextForObject(contentItem(), e->rootContext());-
108-
109 //Give QQuickView behavior when created from QML with QQmlApplicationEngine-
110 if (QCoreApplication::instance()->property("__qml_using_qqmlapplicationengine") == QVariant(true)) {
QCoreApplicati...QVariant(true)Description
TRUEevaluated 130 times by 1 test
Evaluated by:
  • tst_qquickshortcut
FALSEevaluated 20 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicktext
20-130
111 if (e && !e->incubationController())
eDescription
TRUEevaluated 130 times by 1 test
Evaluated by:
  • tst_qquickshortcut
FALSEnever evaluated
!e->incubationController()Description
TRUEevaluated 106 times by 1 test
Evaluated by:
  • tst_qquickshortcut
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshortcut
0-130
112 e->setIncubationController(incubationController());
executed 106 times by 1 test: e->setIncubationController(incubationController());
Executed by:
  • tst_qquickshortcut
106
113 }
executed 130 times by 1 test: end of block
Executed by:
  • tst_qquickshortcut
130
114 {-
115 // The content item has CppOwnership policy (set in QQuickWindow). Ensure the presence of a JS-
116 // wrapper so that the garbage collector can see the policy.-
117 QV4::ExecutionEngine *v4 = e->handle();-
118 QV4::QObjectWrapper::wrap(v4, d->contentItem);-
119 }-
120}
executed 150 times by 8 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickshortcut
  • tst_qquicktext
150
121-
122void QQuickWindowQmlImpl::componentComplete()-
123{-
124 Q_D(QQuickWindowQmlImpl);-
125 d->complete = true;-
126 QQuickItem *itemParent = qmlobject_cast<QQuickItem *>(QObject::parent());-
127 if (itemParent && !itemParent->window()) {
itemParentDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_qqmlcomponent
  • tst_qquickloader
FALSEevaluated 144 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickshortcut
  • tst_qquicktext
!itemParent->window()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickloader
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlcomponent
2-144
128 qCDebug(lcTransient) << "window" << title() << "has invisible Item parent" << itemParent << "transientParent"
never executed: QMessageLogger(__FILE__, 128, __PRETTY_FUNCTION__, lcTransient().categoryName()).debug() << "window" << title() << "has invisible Item parent" << itemParent << "transientParent" << transientParent() << "declared visibility" << d->visibility << "; delaying show";
qt_category_enabledDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickloader
0-4
129 << transientParent() << "declared visibility" << d->visibility << "; delaying show";
never executed: QMessageLogger(__FILE__, 128, __PRETTY_FUNCTION__, lcTransient().categoryName()).debug() << "window" << title() << "has invisible Item parent" << itemParent << "transientParent" << transientParent() << "declared visibility" << d->visibility << "; delaying show";
0
130 connect(itemParent, &QQuickItem::windowChanged, this,-
131 &QQuickWindowQmlImpl::setWindowVisibility, Qt::QueuedConnection);-
132 } else if (transientParent() && !transientParent()->isVisible()) {
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickloader
transientParent()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlcomponent
FALSEevaluated 144 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickshortcut
  • tst_qquicktext
!transientPare...)->isVisible()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlcomponent
FALSEnever evaluated
0-144
133 connect(transientParent(), &QQuickWindow::visibleChanged, this,-
134 &QQuickWindowQmlImpl::setWindowVisibility, Qt::QueuedConnection);-
135 } else {
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmlcomponent
2
136 setWindowVisibility();-
137 }
executed 144 times by 7 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickshortcut
  • tst_qquicktext
144
138}-
139-
140void QQuickWindowQmlImpl::setWindowVisibility()-
141{-
142 Q_D(QQuickWindowQmlImpl);-
143 if (transientParent() && !transientParent()->isVisible())
transientParent()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickloader
FALSEevaluated 144 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickshortcut
  • tst_qquicktext
!transientPare...)->isVisible()Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickloader
0-144
144 return;
never executed: return;
0
145-
146 if (QQuickItem *senderItem = qmlobject_cast<QQuickItem *>(sender())) {
QQuickItem *se...m *>(sender())Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickloader
FALSEevaluated 144 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickshortcut
  • tst_qquicktext
4-144
147 disconnect(senderItem, &QQuickItem::windowChanged, this, &QQuickWindowQmlImpl::setWindowVisibility);-
148 } else if (sender()) {
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickloader
sender()Description
TRUEnever evaluated
FALSEevaluated 144 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickshortcut
  • tst_qquicktext
0-144
149 disconnect(transientParent(), &QWindow::visibleChanged, this, &QQuickWindowQmlImpl::setWindowVisibility);-
150 }
never executed: end of block
0
151-
152 // We have deferred window creation until we have the full picture of what-
153 // the user wanted in terms of window state, geometry, visibility, etc.-
154-
155 if ((d->visibility == Hidden && d->visible) || (d->visibility > AutomaticVisibility && !d->visible)) {
d->visibility == HiddenDescription
TRUEnever evaluated
FALSEevaluated 148 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickshortcut
  • tst_qquicktext
d->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
d->visibility ...aticVisibilityDescription
TRUEnever evaluated
FALSEevaluated 148 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickshortcut
  • tst_qquicktext
!d->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0-148
156 QQmlData *data = QQmlData::get(this);-
157 Q_ASSERT(data && data->context);-
158-
159 QQmlError error;-
160 error.setObject(this);-
161-
162 const QQmlContextData* urlContext = data->context;-
163 while (urlContext && urlContext->url().isEmpty())
urlContextDescription
TRUEnever evaluated
FALSEnever evaluated
urlContext->url().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
164 urlContext = urlContext->parent;
never executed: urlContext = urlContext->parent;
0
165 error.setUrl(urlContext ? urlContext->url() : QUrl());-
166-
167 QString objectId = data->context->findObjectId(this);-
168 if (!objectId.isEmpty())
!objectId.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
169 error.setDescription(QCoreApplication::translate("QQuickWindowQmlImpl",
never executed: error.setDescription(QCoreApplication::translate("QQuickWindowQmlImpl", "Conflicting properties 'visible' and 'visibility' for Window '%1'").arg(objectId));
0
170 "Conflicting properties 'visible' and 'visibility' for Window '%1'").arg(objectId));
never executed: error.setDescription(QCoreApplication::translate("QQuickWindowQmlImpl", "Conflicting properties 'visible' and 'visibility' for Window '%1'").arg(objectId));
0
171 else-
172 error.setDescription(QCoreApplication::translate("QQuickWindowQmlImpl",
never executed: error.setDescription(QCoreApplication::translate("QQuickWindowQmlImpl", "Conflicting properties 'visible' and 'visibility'"));
0
173 "Conflicting properties 'visible' and 'visibility'"));
never executed: error.setDescription(QCoreApplication::translate("QQuickWindowQmlImpl", "Conflicting properties 'visible' and 'visibility'"));
0
174-
175 QQmlEnginePrivate::get(data->context->engine)->warning(error);-
176 }
never executed: end of block
0
177-
178 if (d->visibility == AutomaticVisibility) {
d->visibility ...aticVisibilityDescription
TRUEevaluated 148 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickshortcut
  • tst_qquicktext
FALSEnever evaluated
0-148
179 setWindowState(QGuiApplicationPrivate::platformIntegration()->defaultWindowState(flags()));-
180 setVisible(d->visible);-
181 } else {
executed 148 times by 8 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickshortcut
  • tst_qquicktext
148
182 setVisibility(d->visibility);-
183 }
never executed: end of block
0
184}-
185-
186QObject *QQuickWindowQmlImpl::screen() const-
187{-
188 return new QQuickScreenInfo(const_cast<QQuickWindowQmlImpl *>(this), QWindow::screen());
never executed: return new QQuickScreenInfo(const_cast<QQuickWindowQmlImpl *>(this), QWindow::screen());
0
189}-
190-
191void QQuickWindowQmlImpl::setScreen(QObject *screen)-
192{-
193 QQuickScreenInfo *screenWrapper = qobject_cast<QQuickScreenInfo *>(screen);-
194 QWindow::setScreen(screenWrapper ? screenWrapper->wrappedScreen() : nullptr);-
195}
never executed: end of block
0
196-
197void QQuickWindowModule::defineModule()-
198{-
199 const char uri[] = "QtQuick.Window";-
200-
201 qmlRegisterType<QQuickWindow>(uri, 2, 0, "Window");-
202 qmlRegisterRevision<QWindow,1>(uri, 2, 1);-
203 qmlRegisterRevision<QWindow,2>(uri, 2, 2);-
204 qmlRegisterRevision<QQuickWindow,1>(uri, 2, 1);//Type moved to a subclass, but also has new members-
205 qmlRegisterRevision<QQuickWindow,2>(uri, 2, 2);-
206 qmlRegisterType<QQuickWindowQmlImpl>(uri, 2, 1, "Window");-
207 qmlRegisterType<QQuickWindowQmlImpl,1>(uri, 2, 2, "Window");-
208 qmlRegisterType<QQuickWindowQmlImpl,2>(uri, 2, 3, "Window");-
209 qmlRegisterUncreatableType<QQuickScreen>(uri, 2, 0, "Screen", QStringLiteral("Screen can only be used via the attached property."));
executed 54 times by 20 tests: return qstring_literal_temp;
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qqmlenginecleanup
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickmousearea
  • tst_qquickrepeater
  • tst_qquickscreen
  • tst_qquickshortcut
  • tst_qquicktableview
  • tst_qquicktext
  • tst_qquickview
  • tst_quicktestmainwithsetup
  • tst_scenegraph
  • tst_testfiltering
54
210 qmlRegisterUncreatableType<QQuickScreen,1>(uri, 2, 3, "Screen", QStringLiteral("Screen can only be used via the attached property."));
executed 54 times by 20 tests: return qstring_literal_temp;
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qqmlenginecleanup
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickmousearea
  • tst_qquickrepeater
  • tst_qquickscreen
  • tst_qquickshortcut
  • tst_qquicktableview
  • tst_qquicktext
  • tst_qquickview
  • tst_quicktestmainwithsetup
  • tst_scenegraph
  • tst_testfiltering
54
211 qmlRegisterUncreatableType<QQuickScreenInfo,2>(uri, 2, 3, "ScreenInfo", QStringLiteral("ScreenInfo can only be used via the attached property."));
executed 54 times by 20 tests: return qstring_literal_temp;
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qqmlenginecleanup
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickmousearea
  • tst_qquickrepeater
  • tst_qquickscreen
  • tst_qquickshortcut
  • tst_qquicktableview
  • tst_qquicktext
  • tst_qquickview
  • tst_quicktestmainwithsetup
  • tst_scenegraph
  • tst_testfiltering
54
212 qmlRegisterUncreatableType<QQuickScreenInfo,10>(uri, 2, 10, "ScreenInfo", QStringLiteral("ScreenInfo can only be used via the attached property."));
executed 54 times by 20 tests: return qstring_literal_temp;
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qqmlenginecleanup
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickmousearea
  • tst_qquickrepeater
  • tst_qquickscreen
  • tst_qquickshortcut
  • tst_qquicktableview
  • tst_qquicktext
  • tst_qquickview
  • tst_quicktestmainwithsetup
  • tst_scenegraph
  • tst_testfiltering
54
213}
executed 54 times by 20 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlcomponent
  • tst_qqmlenginecleanup
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickmousearea
  • tst_qquickrepeater
  • tst_qquickscreen
  • tst_qquickshortcut
  • tst_qquicktableview
  • tst_qquicktext
  • tst_qquickview
  • tst_quicktestmainwithsetup
  • tst_scenegraph
  • tst_testfiltering
54
214-
215QT_END_NAMESPACE-
216-
217#include "moc_qquickwindowmodule_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0