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
qqmldirdata_p.h
Go to the documentation of this file.
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#ifndef QQMLDIRDATA_P_H
5#define QQMLDIRDATA_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 <private/qqmltypeloader_p.h>
19
21
22class Q_AUTOTEST_EXPORT QQmlQmldirData : public QQmlTypeLoader::Blob
23{
24private:
25 friend class QQmlTypeLoader;
26
27public:
28 QQmlQmldirData(const QUrl &, QQmlTypeLoader *);
29
30 const QString &content() const;
31 QV4::CompiledData::Location importLocation(Blob *blob) const;
32
33 template<typename Callback>
34 bool processImports(Blob *blob, const Callback &callback) const
35 {
36 assertTypeLoaderThread();
37 bool result = true;
38 const auto range = m_imports.equal_range(blob);
39 for (auto it = range.first; it != range.second; ++it) {
40 // Do we need to resolve this import?
41 if ((it->import->priority == 0) || (it->import->priority > it->priority)) {
42 // This is the (current) best resolution for this import
43 if (!callback(it->import))
44 result = false;
45 it->import->priority = it->priority;
46 }
47 }
48 return result;
49 }
50
51 void setPriority(Blob *, const PendingImportPtr &, int);
52
53protected:
54 void dataReceived(const SourceCodeData &) override;
55 void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *) override;
56
57private:
58 struct PrioritizedImport {
59 PendingImportPtr import;
60 int priority = 0;
61 };
62
63 QString m_content;
64 QMultiHash<Blob *, PrioritizedImport> m_imports;
65};
66
67QT_END_NAMESPACE
68
69#endif // QQMLDIRDATA_P_H