OpenCoverage

qquickstatechangescript.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/util/qquickstatechangescript.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 "qquickstatechangescript_p.h"-
41-
42#include <qqml.h>-
43#include <qqmlcontext.h>-
44#include <qqmlexpression.h>-
45#include <qqmlinfo.h>-
46#include <private/qqmlcontext_p.h>-
47#include <private/qqmlproperty_p.h>-
48#include <private/qqmlbinding_p.h>-
49#include "qquickstate_p_p.h"-
50-
51#include <QtCore/qdebug.h>-
52#include <QtCore/qmath.h>-
53-
54#include <private/qobject_p.h>-
55-
56QT_BEGIN_NAMESPACE-
57-
58class QQuickStateChangeScriptPrivate : public QQuickStateOperationPrivate-
59{-
60public:-
61 QQuickStateChangeScriptPrivate() {}-
62-
63 QQmlScriptString script;-
64 QString name;-
65};-
66-
67/*!-
68 \qmltype StateChangeScript-
69 \instantiates QQuickStateChangeScript-
70 \inqmlmodule QtQuick-
71 \ingroup qtquick-states-
72 \brief Specifies how to run a script in a state.-
73-
74 A StateChangeScript is run upon entering a state. You can optionally use-
75 ScriptAction to specify the point in the transition at which-
76 the StateChangeScript should be run.-
77-
78 \snippet qml/states/statechangescript.qml state and transition-
79-
80 \sa ScriptAction-
81*/-
82-
83QQuickStateChangeScript::QQuickStateChangeScript(QObject *parent)-
84: QQuickStateOperation(*(new QQuickStateChangeScriptPrivate), parent)-
85{-
86}
executed 8 times by 2 tests: end of block
Executed by:
  • tst_qquickanimations
  • tst_qquickstates
8
87-
88QQuickStateChangeScript::~QQuickStateChangeScript()-
89{-
90}-
91-
92/*!-
93 \qmlproperty script QtQuick::StateChangeScript::script-
94 This property holds the script to run when the state is current.-
95*/-
96QQmlScriptString QQuickStateChangeScript::script() const-
97{-
98 Q_D(const QQuickStateChangeScript);-
99 return d->script;
never executed: return d->script;
0
100}-
101-
102void QQuickStateChangeScript::setScript(const QQmlScriptString &s)-
103{-
104 Q_D(QQuickStateChangeScript);-
105 d->script = s;-
106}
executed 8 times by 2 tests: end of block
Executed by:
  • tst_qquickanimations
  • tst_qquickstates
8
107-
108/*!-
109 \qmlproperty string QtQuick::StateChangeScript::name-
110 This property holds the name of the script. This name can be used by a-
111 ScriptAction to target a specific script.-
112-
113 \sa ScriptAction::scriptName-
114*/-
115QString QQuickStateChangeScript::name() const-
116{-
117 Q_D(const QQuickStateChangeScript);-
118 return d->name;
never executed: return d->name;
0
119}-
120-
121void QQuickStateChangeScript::setName(const QString &n)-
122{-
123 Q_D(QQuickStateChangeScript);-
124 d->name = n;-
125}
never executed: end of block
0
126-
127void QQuickStateChangeScript::execute()-
128{-
129 Q_D(QQuickStateChangeScript);-
130 if (!d->script.isEmpty()) {
!d->script.isEmpty()Description
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_qquickanimations
  • tst_qquickstates
FALSEnever evaluated
0-8
131 QQmlExpression expr(d->script);-
132 expr.evaluate();-
133 if (expr.hasError())
expr.hasError()Description
TRUEnever evaluated
FALSEevaluated 8 times by 2 tests
Evaluated by:
  • tst_qquickanimations
  • tst_qquickstates
0-8
134 qmlWarning(this, expr.error());
never executed: qmlWarning(this, expr.error());
0
135 }
executed 8 times by 2 tests: end of block
Executed by:
  • tst_qquickanimations
  • tst_qquickstates
8
136}
executed 8 times by 2 tests: end of block
Executed by:
  • tst_qquickanimations
  • tst_qquickstates
8
137-
138QQuickStateChangeScript::ActionList QQuickStateChangeScript::actions()-
139{-
140 ActionList rv;-
141 QQuickStateAction a;-
142 a.event = this;-
143 rv << a;-
144 return rv;
executed 8 times by 2 tests: return rv;
Executed by:
  • tst_qquickanimations
  • tst_qquickstates
8
145}-
146-
147QQuickStateActionEvent::EventType QQuickStateChangeScript::type() const-
148{-
149 return Script;
never executed: return Script;
0
150}-
151-
152-
153#include <moc_qquickstatechangescript_p.cpp>-
154-
155QT_END_NAMESPACE-
156-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0