1 | // Copyright (C) 2016 Research In Motion. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | /*! |
5 | \class QQmlAbstractUrlInterceptor |
6 | \inmodule QtQml |
7 | \brief allows you to control QML file loading. |
8 | |
9 | QQmlAbstractUrlInterceptor is an interface which can be used to alter URLs |
10 | before they are used by the QML engine. This is primarily useful for altering |
11 | file urls into other file urls, such as selecting different graphical assets |
12 | for the current platform. |
13 | |
14 | Relative URLs are intercepted after being resolved against the file path of the |
15 | current QML context. URL interception also occurs after setting the base path for |
16 | a loaded QML file. This means that the content loaded for that QML file uses the |
17 | intercepted URL, but inside the file the pre-intercepted URL is used for resolving |
18 | relative paths. This allows for interception of .qml file loading without needing |
19 | all paths (or local types) inside intercepted content to insert a different relative path. |
20 | |
21 | Compared to setNetworkAccessManagerFactory, QQmlAbstractUrlInterceptor affects all URLs |
22 | and paths, including local files and embedded resource files. QQmlAbstractUrlInterceptor |
23 | is synchronous, and for asynchronous files must return a url with an asynchronous scheme |
24 | (such as http or a custom scheme handled by your own custom QNetworkAccessManager). You |
25 | can use a QQmlAbstractUrlInterceptor to change file URLs into networked URLs which are |
26 | handled by your own custom QNetworkAccessManager. |
27 | |
28 | To implement support for a custom networked scheme, see setNetworkAccessManagerFactory. |
29 | */ |
30 | |
31 | /*! |
32 | \enum QQmlAbstractUrlInterceptor::DataType |
33 | |
34 | Specifies where URL interception is taking place. |
35 | |
36 | Because QML loads qmldir files for locating types, there are two URLs involved in loading a QML type. The URL of the (possibly implicit) qmldir used for locating the type and the URL of the file which defines the type. Intercepting |
37 | both leads to either complex URL replacement or double URL replacements for the same file. |
38 | |
39 | \value QmldirFile The URL being intercepted is for a Qmldir file. Intercepting this, but not the QmlFile, allows for swapping out entire sub trees. |
40 | \value JavaScriptFile The URL being intercepted is an import for a Javascript file. |
41 | \value QmlFile The URL being intercepted is for a Qml file. Intercepting this, but not the Qmldir file, leaves the base dir of a QML file untouched and acts like replacing the file with another file. |
42 | \value UrlString The URL being intercepted is a url property in a QML file, and not being used to load a file through the engine. |
43 | |
44 | */ |
45 | |
46 | /*! |
47 | \fn QUrl QQmlAbstractUrlInterceptor::intercept(const QUrl& url, DataType type) |
48 | |
49 | A pure virtual function where you can intercept the \a url. The returned value is taken as the |
50 | new value for the url. The type of url being intercepted is given by the \a type variable. |
51 | |
52 | Your implementation of this function must be thread-safe, as it can be called from multiple threads |
53 | at the same time. |
54 | */ |
55 | /*! |
56 | \fn QQmlAbstractUrlInterceptor::QQmlAbstractUrlInterceptor() |
57 | |
58 | Constructor for QQmlAbstractUrlInterceptor. |
59 | */ |
60 | /*! |
61 | \fn QQmlAbstractUrlInterceptor::~QQmlAbstractUrlInterceptor() |
62 | |
63 | Destructor for QQmlAbstractUrlInterceptor. |
64 | */ |
65 | |