7#include <QtCore/qurl.h>
8#include <QtCore/qcoreapplication.h>
9#include <QtCore/qloggingcategory.h>
10#include <QtCore/qset.h>
11#include <QtCore/qstringlist.h>
12#include <QtQml/qqmlengine.h>
13#include <QtQml/qqmlerror.h>
14#include <QtQml/qqmlfile.h>
15#include <private/qqmldirparser_p.h>
16#include <private/qqmltype_p.h>
17#include <private/qstringhash_p.h>
18#include <private/qfieldlist_p.h>
51 Lowest = std::numeric_limits<quint8>::max(),
79 const QString *
base =
nullptr,
bool *typeRecursionDetected =
nullptr,
82 QList<QQmlError> *errors =
nullptr)
const;
97 const QString *
base =
nullptr, QList<QQmlError> *errors =
nullptr,
99 bool *typeRecursionDeteced =
nullptr);
125 ImportIncomplete = 0x1,
142 QList<QQmlError> *errors =
nullptr,
144 bool *typeRecursionDetected =
nullptr)
const;
152 const ImportFlags
flags =
153 ImportFlags(!isLocal(
baseUrl()) ? ImportIncomplete : ImportNoFlag);
154 return addFileImport(
159 bool addInlineComponentImport(
165 QList<QQmlError> *errors);
170 ImportFlags
flags,
quint16 precedence, QList<QQmlError> *errors);
174 const QString &qmldirIdentifier,
const QString &qmldirUrl, QList<QQmlError> *errors);
185 QList<ScriptReference> resolvedScripts()
const;
194 QList<CompositeSingletonReference> resolvedCompositeSingletons()
const;
211 static QUrl urlFromLocalFileOrQrcOrUrl(
const QString &);
213 static void setDesignerSupportRequired(
bool b);
224 QQmlType *type_return, QList<QQmlError> *errors,
226 bool *typeRecursionDetected =
nullptr)
const;
240 bool getQmldirContent(
256 QFieldList<QQmlImportNamespace, &QQmlImportNamespace::nextNamespace> m_qualifiedSets;
294 template<
typename Callback>
297 const Callback &callback);
307 void clearDirCache();
317 QStringHash<QmldirCache *> qmldirCache;
323 QSet<QString> modulesForWhichPluginsHaveBeenLoaded;
324 QSet<QString> initializedPlugins;
328template<
typename Callback>
336 QmldirCache *cacheTail =
nullptr;
338 QmldirCache **cachePtr = qmldirCache.
value(uri);
339 QmldirCache *cacheHead = cachePtr ? *cachePtr :
nullptr;
341 cacheTail = cacheHead;
343 if (cacheTail->version == version) {
344 if (cacheTail->qmldirFilePath.isEmpty()) {
345 return cacheTail->qmldirPathUrl.
isEmpty()
349 if (callback(cacheTail->qmldirFilePath, cacheTail->qmldirPathUrl))
353 }
while (cacheTail->next && (cacheTail = cacheTail->next));
369 uri, localImportPaths, version);
371 QString qmldirAbsoluteFilePath;
372 for (
QString qmldirPath : qmlDirPaths) {
373 if (hasInterceptors) {
379 && qmldirPath.isEmpty()
385 qmldirAbsoluteFilePath = absoluteFilePath(qmldirPath);
386 if (!qmldirAbsoluteFilePath.isEmpty()) {
389 qmldirAbsoluteFilePath.lastIndexOf(u
'/') + 1);
403 QmldirCache *
cache =
new QmldirCache;
404 cache->version = version;
405 cache->qmldirFilePath = qmldirAbsoluteFilePath;
407 cache->next =
nullptr;
409 cacheTail->next =
cache;
423 QmldirCache *
cache =
new QmldirCache;
424 cache->version = version;
425 cache->next = cacheHead;
435 <<
"locateLocalQmldir:" <<
qPrintable(uri) <<
"module's qmldir file not found";
439 <<
"locateLocalQmldir:" <<
qPrintable(uri) <<
"module's qmldir found at"
440 << qmldirAbsoluteFilePath;
bool isEmpty() const noexcept
The QQmlEngine class provides an environment for instantiating QML components.
QList< QQmlAbstractUrlInterceptor * > urlInterceptors() const
Returns the list of currently active URL interceptors.
QUrl interceptUrl(const QUrl &url, QQmlAbstractUrlInterceptor::DataType type) const
Run the current URL interceptors on the given url of the given type and return the result.
static bool isLocalFile(const QString &url)
Returns true if url is a local file that can be opened with \l{QFile}.
static QString urlToLocalFileOrQrc(const QString &)
If url is a local file returns a path suitable for passing to \l{QFile}.
The QQmlImportDatabase class manages the QML imports for a QQmlEngine.
void addPluginPath(const QString &path)
QStringList dynamicPlugins() const
LocalQmldirSearchLocation
QStringList importPathList(PathType type=LocalOrRemote) const
bool removeDynamicPlugin(const QString &pluginId)
void setPluginPathList(const QStringList &paths)
void addImportPath(const QString &dir)
QStringList pluginPathList() const
static QTypeRevision lockModule(const QString &uri, const QString &typeNamespace, QTypeRevision version, QList< QQmlError > *errors)
QQmlImportDatabase(QQmlEngine *)
LocalQmldirResult locateLocalQmldir(const QString &uri, QTypeRevision version, LocalQmldirSearchLocation location, const Callback &callback)
@ QmldirInterceptedToRemote
void setImportPathList(const QStringList &paths)
bool needsSorting() const
QQmlImportNamespace * nextNamespace
QQmlImportInstance * findImport(const QString &uri) const
bool resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef &type, QTypeRevision *version_return, QQmlType *type_return, const QString *base=nullptr, QList< QQmlError > *errors=nullptr, QQmlType::RegistrationType registrationType=QQmlType::AnyRegistrationType, bool *typeRecursionDeteced=nullptr)
QList< QQmlImportInstance * > imports
void setNeedsSorting(bool needsSorting)
The QQmlImports class encapsulates one QML document's import statements.
static QUrl urlFromLocalFileOrQrcOrUrl(const QString &)
QTypeRevision addImplicitImport(QQmlTypeLoader *typeLoader, QString *localQmldir, QList< QQmlError > *errors)
static bool isLocal(const QString &url)
static QStringList completeQmldirPaths(const QString &uri, const QStringList &basePaths, QTypeRevision version)
Forms complete paths to a qmldir file, from a base URL, a module URI and version specification.
static bool isLocal(const QUrl &url)
The QQmlTypeLoader class abstracts loading files and their dependencies over the network.
void insert(const K &, const T &)
T * value(const K &) const
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
qDeleteAll(list.begin(), list.end())
QCache< int, Employee > cache
[0]
Combined button and popup list for selecting options.
#define Q_DECLARE_TR_FUNCTIONS(context)
#define Q_DECLARE_FLAGS(Flags, Enum)
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
#define qCDebug(category,...)
GLboolean GLboolean GLboolean b
GLsizei const GLuint * paths
GLsizei const GLchar *const * path
const QLoggingCategory & lcQmlImport()
void qmlClearEnginePlugins()
const QLoggingCategory & lcQmlImport()
static QString absolutePath(const QString &path)
static QUrl resolvedUrl(const QUrl &url, const QQmlRefPointer< QQmlContextData > &context)
#define qPrintable(string)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
static QString absoluteFilePath(const Options *options, const QString &relativeFileName)
QUrl url("example.com")
[constructor-url-reference]
char * toString(const MyType &t)
[31]
QQmlDirComponents qmlDirComponents
bool resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef &type, QTypeRevision *version_return, QQmlType *type_return, const QString *base=nullptr, bool *typeRecursionDetected=nullptr, QQmlType::RegistrationType=QQmlType::AnyRegistrationType, QQmlImport::RecursionRestriction recursionRestriction=QQmlImport::PreventRecursion, QList< QQmlError > *errors=nullptr) const
bool setQmldirContent(const QString &resolvedUrl, const QQmlTypeLoaderQmldirContent &qmldir, QQmlImportNamespace *nameSpace, QList< QQmlError > *errors)
QQmlDirScripts qmlDirScripts
static QQmlDirScripts getVersionedScripts(const QQmlDirScripts &qmldirscripts, QTypeRevision version)