8#include <QXmlStreamReader>
54 populateFromQrcFile(
f);
60 return qrcPathToFileSystemPath.isEmpty();
65 for (
const auto &
entry : qrcPathToFileSystemPath) {
66 if (
entry.resourcePath == resourcePath)
74 if (suffixes.isEmpty())
77 return suffixes.contains(suffix);
80template<
typename HandleMatch>
81void doFilter(
const QList<QQmlJSResourceFileMapper::Entry> &qrcPathToFileSystemPath,
83 const HandleMatch &handler)
89 for (
auto it = qrcPathToFileSystemPath.constBegin(),
90 end = qrcPathToFileSystemPath.constEnd();
it !=
end; ++
it) {
104 || !candidate.
mid(terminatedDirectory.size()).
contains(u
'/')) {
115 for (
auto it = qrcPathToFileSystemPath.constBegin(),
116 end = qrcPathToFileSystemPath.constEnd();
it !=
end; ++
it) {
118 if (
it->resourcePath ==
filter.path && handler(*
it))
120 }
else if (
it->filePath ==
filter.path && handler(*
it)) {
170void QQmlJSResourceFileMapper::populateFromQrcFile(
QFile &
file)
184 QXmlStreamAttributes currentFileAttributes;
188 switch (
reader.readNext()) {
189 case QXmlStreamReader::StartElement:
191 if (
state != InitialState)
199 QXmlStreamAttributes attributes =
reader.attributes();
208 if (
state != InResource)
211 currentFileAttributes =
reader.attributes();
216 case QXmlStreamReader::EndElement:
223 if (
state != InResource)
230 state = InitialState;
235 case QXmlStreamReader::Characters: {
236 if (
reader.isWhitespace())
247 currentFileName = currentFileAttributes.value(
QStringLiteral(
"alias")).toString();
251 currentFileName.
remove(0, 3);
253 const QString qrcPath = prefix + currentFileName;
255 qrcPathToFileSystemPath.append({qrcPath, fsPath});
static QString cleanPath(const QString &path)
Returns path with directory separators normalized (that is, platform-native separators converted to "...
QString suffix() const
Returns the suffix (extension) of the file.
QString canonicalFilePath() const
Returns the file system entry's canonical path, including the entry's name, that is,...
QDir absoluteDir() const
Returns a QDir object representing the absolute path of the parent directory of the file system entry...
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString text(const QString &key) const
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QString mid(qsizetype position, qsizetype n=-1) const &
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString & append(QChar c)
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
QString & prepend(QChar c)
QSet< QString >::iterator it
Combined button and popup list for selecting options.
QImageReader reader("image.png")
[1]
QList< QString > QStringList
Constructs a string list that contains the given string, str.
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
static bool hasSuffix(const QString &qrcPath, const QStringList &suffixes)
void doFilter(const QList< QQmlJSResourceFileMapper::Entry > &qrcPathToFileSystemPath, const QQmlJSResourceFileMapper::Filter &filter, const HandleMatch &handler)
#define QStringLiteral(str)
\inmodule QtCore \reentrant
Entry entry(const Filter &filter) const
static Filter resourceFileFilter(const QString &file)
static Filter resourceQmlDirectoryFilter(const QString &directory)
bool isFile(const QString &resourcePath) const
QList< Entry > filter(const Filter &filter) const
QStringList filePaths(const Filter &filter) const
static Filter localFileFilter(const QString &file)
QQmlJSResourceFileMapper(const QStringList &resourceFiles)
QStringList resourcePaths(const Filter &filter) const
static Filter allQmlJSFilter()