3** Copyright (C) 2016 Research In Motion.
4** Contact: https://www.qt.io/licensing/
6** This file is part of the QtQml module of the Qt Toolkit.
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
41 \class QQmlAbstractUrlInterceptor
42 \inmodule QtQml
43 \brief allows you to control QML file loading.
45 QQmlAbstractUrlInterceptor is an interface which can be used to alter URLs
46 before they are used by the QML engine. This is primarily useful for altering
47 file urls into other file urls, such as selecting different graphical assets
48 for the current platform.
50 Relative URLs are intercepted after being resolved against the file path of the
51 current QML context. URL interception also occurs after setting the base path for
52 a loaded QML file. This means that the content loaded for that QML file uses the
53 intercepted URL, but inside the file the pre-intercepted URL is used for resolving
54 relative paths. This allows for interception of .qml file loading without needing
55 all paths (or local types) inside intercepted content to insert a different relative path.
57 Compared to setNetworkAccessManagerFactory, QQmlAbstractUrlInterceptor affects all URLs
58 and paths, including local files and embedded resource files. QQmlAbstractUrlInterceptor
59 is synchronous, and for asynchronous files must return a url with an asynchronous scheme
60 (such as http or a custom scheme handled by your own custom QNetworkAccessManager). You
61 can use a QQmlAbstractUrlInterceptor to change file URLs into networked URLs which are
62 handled by your own custom QNetworkAccessManager.
64 To implement support for a custom networked scheme, see setNetworkAccessManagerFactory.
68 \enum QQmlAbstractUrlInterceptor::DataType
70 Specifies where URL interception is taking place.
72 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
73 both leads to either complex URL replacement or double URL replacements for the same file.
75 \value QmldirFile The URL being intercepted is for a Qmldir file. Intercepting this, but not the QmlFile, allows for swapping out entire sub trees.
76 \value JavaScriptFile The URL being intercepted is an import for a Javascript file.
77 \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.
78 \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.
83 \fn QUrl QQmlAbstractUrlInterceptor::intercept(const QUrl& url, DataType type)
85 A pure virtual function where you can intercept the \a url. The returned value is taken as the
86 new value for the url. The type of url being intercepted is given by the \a type variable.
88 Your implementation of this function must be thread-safe, as it can be called from multiple threads
89 at the same time.
92 \fn QQmlAbstractUrlInterceptor::QQmlAbstractUrlInterceptor()
94 Constructor for QQmlAbstractUrlInterceptor.
97 \fn QQmlAbstractUrlInterceptor::~QQmlAbstractUrlInterceptor()
99 Destructor for QQmlAbstractUrlInterceptor.