1 | // Copyright (C) 2017 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QQUICKDEFERREDEXECUTE_P_P_H |
5 | #define QQUICKDEFERREDEXECUTE_P_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtCore/qglobal.h> |
19 | #include <QtQuickTemplates2/private/qquickdeferredpointer_p_p.h> |
20 | #include <QtQuickTemplates2/private/qtquicktemplates2global_p.h> |
21 | |
22 | #include <QtQml/private/qqmlvme_p.h> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QString; |
27 | class QObject; |
28 | |
29 | namespace QtQuickPrivate { |
30 | Q_QUICKTEMPLATES2_PRIVATE_EXPORT void beginDeferred(QObject *object, const QString &property, QQuickUntypedDeferredPointer *delegate, bool isOwnState); |
31 | Q_QUICKTEMPLATES2_PRIVATE_EXPORT void cancelDeferred(QObject *object, const QString &property); |
32 | Q_QUICKTEMPLATES2_PRIVATE_EXPORT void completeDeferred(QObject *object, const QString &property, QQuickUntypedDeferredPointer *delegate); |
33 | } |
34 | |
35 | template<typename T> |
36 | void quickBeginDeferred(QObject *object, const QString &property, QQuickDeferredPointer<T> &delegate) |
37 | { |
38 | if (!QQmlVME::componentCompleteEnabled()) |
39 | return; |
40 | |
41 | QtQuickPrivate::beginDeferred(object, property, delegate: &delegate, isOwnState: delegate.setExecuting(true)); |
42 | delegate.setExecuting(false); |
43 | } |
44 | |
45 | inline void quickCancelDeferred(QObject *object, const QString &property) |
46 | { |
47 | QtQuickPrivate::cancelDeferred(object, property); |
48 | } |
49 | |
50 | template<typename T> |
51 | void quickCompleteDeferred(QObject *object, const QString &property, QQuickDeferredPointer<T> &delegate) |
52 | { |
53 | Q_ASSERT(!delegate.wasExecuted()); |
54 | QtQuickPrivate::completeDeferred(object, property, delegate: &delegate); |
55 | delegate.setExecuted(); |
56 | } |
57 | |
58 | QT_END_NAMESPACE |
59 | |
60 | #endif // QQUICKDEFERREDEXECUTE_P_P_H |
61 | |