1 | // Copyright (C) 2019 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 | #include <private/qqmldirdata_p.h> |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | QQmlQmldirData::QQmlQmldirData(const QUrl &url, QQmlTypeLoader *loader) |
9 | : QQmlTypeLoader::Blob(url, QmldirFile, loader) |
10 | { |
11 | } |
12 | |
13 | const QString &QQmlQmldirData::content() const |
14 | { |
15 | return m_content; |
16 | } |
17 | |
18 | QV4::CompiledData::Location QQmlQmldirData::importLocation(QQmlTypeLoader::Blob *blob) const |
19 | { |
20 | auto it = m_imports.constFind(key: blob); |
21 | if (it == m_imports.constEnd()) |
22 | return QV4::CompiledData::Location(); |
23 | return it->import->location; |
24 | } |
25 | |
26 | void QQmlQmldirData::setPriority(QQmlTypeLoader::Blob *blob, |
27 | QQmlTypeLoader::Blob::PendingImportPtr import, int priority) |
28 | { |
29 | m_imports.insert(key: blob, value: { .import: std::move(import), .priority: priority }); |
30 | } |
31 | |
32 | void QQmlQmldirData::dataReceived(const SourceCodeData &data) |
33 | { |
34 | QString error; |
35 | m_content = data.readAll(error: &error); |
36 | if (!error.isEmpty()) { |
37 | setError(error); |
38 | return; |
39 | } |
40 | } |
41 | |
42 | void QQmlQmldirData::initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *) |
43 | { |
44 | Q_UNIMPLEMENTED(); |
45 | } |
46 | |
47 | QT_END_NAMESPACE |
48 |