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
qqmlnotifyingblob.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 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
5
7
8QQmlNotifyingBlob::Callback::~Callback() = default;
9
10void QQmlNotifyingBlob::Callback::ready(QQmlNotifyingBlob *) {}
11void QQmlNotifyingBlob::Callback::progress(QQmlNotifyingBlob *, qreal) {}
12
13void QQmlNotifyingBlob::registerCallback(Callback *callback)
14{
15 assertEngineThread();
16 Q_ASSERT(!m_callbacks.contains(callback));
17 m_callbacks.append(callback);
18}
19
20void QQmlNotifyingBlob::unregisterCallback(Callback *callback)
21{
22 assertEngineThreadIfRunning();
23 Q_ASSERT(m_callbacks.contains(callback));
24 m_callbacks.removeOne(callback);
25 Q_ASSERT(!m_callbacks.contains(callback));
26}
27
28void QQmlNotifyingBlob::completed()
29{
30 assertEngineThread();
31 // Notify callbacks
32 while (!m_callbacks.isEmpty()) {
33 Callback *callback = m_callbacks.takeFirst();
34 callback->ready(this);
35 }
36}
37
38void QQmlNotifyingBlob::downloadProgressChanged(qreal p)
39{
40 assertEngineThread();
41
42 for (Callback *callback : std::as_const(m_callbacks))
43 callback->progress(this, p);
44}
45
46QT_END_NAMESPACE