Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickworkerscript_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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// Qt-Security score:significant
4
5#ifndef QQUICKWORKERSCRIPT_P_H
6#define QQUICKWORKERSCRIPT_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <qqml.h>
20
21#include <QtQmlWorkerScript/private/qtqmlworkerscriptglobal_p.h>
22#include <QtQml/qqmlparserstatus.h>
23#include <QtCore/qthread.h>
24#include <QtQml/qjsvalue.h>
25#include <QtCore/qurl.h>
26
28
29
30class QQuickWorkerScript;
33{
35public:
38
39 int registerWorkerScript(QQuickWorkerScript *);
40 void removeWorkerScript(int);
41 void executeUrl(int, const QUrl &);
42 void sendMessage(int, const QByteArray &);
43
44protected:
45 void run() override;
46
47private:
49};
50
51class Q_QMLWORKERSCRIPT_EXPORT QQuickWorkerScript : public QObject, public QQmlParserStatus
52{
53 Q_OBJECT
54 Q_DISABLE_COPY_MOVE(QQuickWorkerScript)
55 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
56 Q_PROPERTY(bool ready READ ready NOTIFY readyChanged REVISION(2, 15))
57
58 QML_NAMED_ELEMENT(WorkerScript);
59 QML_ADDED_IN_VERSION(2, 0)
60
61 Q_INTERFACES(QQmlParserStatus)
62public:
63 QQuickWorkerScript(QObject *parent = nullptr);
64 ~QQuickWorkerScript();
65
66 QUrl source() const;
67 void setSource(const QUrl &);
68
69 bool ready() const;
70
71public Q_SLOTS:
72 void sendMessage(QQmlV4FunctionPtr);
73
74Q_SIGNALS:
75 void sourceChanged();
76 Q_REVISION(2, 15) void readyChanged();
77 void message(const QJSValue &messageObject);
78
79protected:
80 void classBegin() override;
81 void componentComplete() override;
82 bool event(QEvent *) override;
83
84private:
85 QQuickWorkerScriptEngine *engine();
86
87 QUrl m_source;
88 QQuickWorkerScriptEngine *m_engine = nullptr;
89 int m_scriptId = -1;
90 bool m_componentComplete = true;
91 bool m_ready = false;
92};
93
94QT_END_NAMESPACE
95
96#endif // QQUICKWORKERSCRIPT_P_H
bool event(QEvent *) override
This virtual function receives events to an object and should return true if the event e was recogniz...
static QV4::ReturnedValue method_sendMessage(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
void reportScriptException(WorkerScript *, const QQmlError &error)
QV4::ExecutionEngine * workerEngine(int id)
QHash< int, QBiPointer< QV4::ExecutionEngine, QQuickWorkerScript > > workers
void executeUrl(int, const QUrl &)
void sendMessage(int, const QByteArray &)
int registerWorkerScript(QQuickWorkerScript *)
QByteArray data() const
WorkerDataEvent(int workerId, const QByteArray &data)
WorkerErrorEvent(const QQmlError &error)
QQmlError error() const
WorkerIdEvent(int workerId, WorkerEventType type)
WorkerLoadEvent(int workerId, const QUrl &url)
WorkerRemoveEvent(int workerId)
V4_DEFINE_EXTENSION(WorkerScript, workerScriptExtension)
~WorkerScript()=default
void ready(QQmlNotifyingBlob *blob) final
WorkerScript(QV4::ExecutionEngine *engine)
QQuickWorkerScriptEnginePrivate * p
QQuickWorkerScript * owner
QV4::ExecutionEngine * engine