Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/qqmlparserstatus.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 QtQml 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 "qqmlparserstatus.h" | - | ||||||
41 | - | |||||||
42 | QT_BEGIN_NAMESPACE | - | ||||||
43 | - | |||||||
44 | /*! | - | ||||||
45 | \class QQmlParserStatus | - | ||||||
46 | \since 5.0 | - | ||||||
47 | \inmodule QtQml | - | ||||||
48 | \brief The QQmlParserStatus class provides updates on the QML parser state. | - | ||||||
49 | - | |||||||
50 | QQmlParserStatus provides a mechanism for classes instantiated by | - | ||||||
51 | a QQmlEngine to receive notification at key points in their creation. | - | ||||||
52 | - | |||||||
53 | This class is often used for optimization purposes, as it allows you to defer an | - | ||||||
54 | expensive operation until after all the properties have been set on an | - | ||||||
55 | object. For example, QML's \l {Text} element uses the parser status | - | ||||||
56 | to defer text layout until all of its properties have been set (we | - | ||||||
57 | don't want to layout when the \c text is assigned, and then relayout | - | ||||||
58 | when the \c font is assigned, and relayout again when the \c width is assigned, | - | ||||||
59 | and so on). | - | ||||||
60 | - | |||||||
61 | Be aware that QQmlParserStatus methods are only called when a class is instantiated | - | ||||||
62 | by a QQmlEngine. If you create the same class directly from C++, these methods will | - | ||||||
63 | not be called automatically. To avoid this problem, it is recommended that you start | - | ||||||
64 | deferring operations from classBegin instead of from the initial creation of your class. | - | ||||||
65 | This will still prevent multiple revaluations during initial binding assignment in QML, | - | ||||||
66 | but will not defer operations invoked from C++. | - | ||||||
67 | - | |||||||
68 | To use QQmlParserStatus, you must inherit both a QObject-derived class | - | ||||||
69 | and QQmlParserStatus, and use the Q_INTERFACES() macro. | - | ||||||
70 | - | |||||||
71 | \code | - | ||||||
72 | class MyObject : public QObject, public QQmlParserStatus | - | ||||||
73 | { | - | ||||||
74 | Q_OBJECT | - | ||||||
75 | Q_INTERFACES(QQmlParserStatus) | - | ||||||
76 | - | |||||||
77 | public: | - | ||||||
78 | MyObject(QObject *parent = 0); | - | ||||||
79 | ... | - | ||||||
80 | void classBegin(); | - | ||||||
81 | void componentComplete(); | - | ||||||
82 | } | - | ||||||
83 | \endcode | - | ||||||
84 | - | |||||||
85 | The \l {Qt Quick 1} version of this class is named QDeclarativeParserStatus. | - | ||||||
86 | */ | - | ||||||
87 | - | |||||||
88 | /*! \internal */ | - | ||||||
89 | QQmlParserStatus::QQmlParserStatus() | - | ||||||
90 | : d(nullptr) | - | ||||||
91 | { | - | ||||||
92 | } executed 500020 times by 133 tests: end of block Executed by:
| 500020 | ||||||
93 | - | |||||||
94 | /*! \internal */ | - | ||||||
95 | QQmlParserStatus::~QQmlParserStatus() | - | ||||||
96 | { | - | ||||||
97 | if(d)
| 16-456424 | ||||||
98 | (*d) = nullptr; executed 16 times by 3 tests: (*d) = nullptr; Executed by:
| 16 | ||||||
99 | } executed 456440 times by 128 tests: end of block Executed by:
| 456440 | ||||||
100 | - | |||||||
101 | /*! | - | ||||||
102 | \fn void QQmlParserStatus::classBegin() | - | ||||||
103 | - | |||||||
104 | Invoked after class creation, but before any properties have been set. | - | ||||||
105 | */ | - | ||||||
106 | - | |||||||
107 | /*! | - | ||||||
108 | \fn void QQmlParserStatus::componentComplete() | - | ||||||
109 | - | |||||||
110 | Invoked after the root component that caused this instantiation has | - | ||||||
111 | completed construction. At this point all static values and binding values | - | ||||||
112 | have been assigned to the class. | - | ||||||
113 | */ | - | ||||||
114 | - | |||||||
115 | QT_END_NAMESPACE | - | ||||||
Source code | Switch to Preprocessed file |