7#include <QtCore/qlibraryinfo.h>
8#include <QtCore/qthread.h>
9#include <QtCore/qwaitcondition.h>
19 if (
path.at(0) ==
'/')
21 if (
path.at(0) ==
':' &&
path.size() >= 2 &&
path.at(1) ==
'/')
24 if (
path.length() >= 2 &&
path.at(1) ==
':')
69 if (m_index >= m_entries.size())
78 if (m_index == 0 || m_index > m_entries.size())
80 return m_entries.at(m_index - 1);
85 m_name(
file), m_absolute(absolute), m_loader(loader)
102 std::optional<QFile::Permissions> permissions)
110 return m_fallback->open(
flags, permissions);
112 Q_UNREACHABLE_RETURN(
false);
120 return m_fallback->close();
127 Q_UNREACHABLE_RETURN(
false);
133 return m_fallback ? m_fallback->size() : m_contents.
size();
138 return m_fallback ? m_fallback->pos() : m_contents.
pos();
143 return m_fallback? m_fallback->seek(newPos) : m_contents.
seek(newPos);
148 return m_fallback ? m_fallback->read(
data, maxlen) : m_contents.
read(
data, maxlen);
152 QAbstractFileEngine::FileFlags
type)
const
155 return m_fallback->fileFlags(
type);
157 QAbstractFileEngine::FileFlags
ret;
160 ret |= QAbstractFileEngine::FileFlags(
183 return m_fallback->fileName(
file);
189 return m_name.
mid(slashPos + 1);
195 else if (slashPos == 0)
197 return path.left(slashPos);
202 return m_absolute.
left(slashPos);
211 return m_fallback ? m_fallback->ownerId(
owner) :
static_cast<uint>(-2);
217 return m_fallback ? m_fallback->beginEntryList(
path,
filters, filterNames)
218 : std::make_unique<QQmlPreviewFileEngineIterator>(
224 return m_fallback ? m_fallback->endEntryList() :
nullptr;
229 return m_fallback ? m_fallback->flush() :
true;
234 return m_fallback ? m_fallback->syncToDisk() :
false;
239 return m_fallback ? m_fallback->isSequential() : m_contents.
isSequential();
244 return m_fallback ? m_fallback->remove() :
false;
249 return m_fallback ? m_fallback->copy(newName) :
false;
254 return m_fallback ? m_fallback->rename(newName) :
false;
259 return m_fallback ? m_fallback->renameOverwrite(newName) :
false;
264 return m_fallback ? m_fallback->link(newName) :
false;
268 std::optional<QFile::Permissions> permissions)
const
270 return m_fallback ? m_fallback->mkdir(dirName, createParentDirectories, permissions) :
false;
275 return m_fallback ? m_fallback->rmdir(dirName, recurseParentDirectories) :
false;
282 return m_fallback->setSize(
size);
284 if (size < 0 || size > std::numeric_limits<int>::max())
291 Q_UNREACHABLE_RETURN(
false);
297 return m_fallback ? m_fallback->caseSensitive() :
true;
302 return m_fallback ? m_fallback->isRelativePath() :
isRelative(m_name);
308 return m_fallback ? m_fallback->entryList(
filters, filterNames)
314 return m_fallback ? m_fallback->setPermissions(perms) :
false;
319 return m_fallback ? m_fallback->id() :
QByteArray();
324 return m_fallback ? m_fallback->owner(
owner) :
QString();
336 return m_fallback ? m_fallback->handle() : -1;
341 return m_fallback ? m_fallback->readLine(
data, maxlen) : m_contents.
readLine(
data, maxlen);
356 return m_fallback ? m_fallback->supportsExtension(
extension) :
false;
359void QQmlPreviewFileEngine::load()
const
369 m_result = m_loader->
load(m_absolute);
375 m_entries = m_loader->
entries();
403 if (relative.
isEmpty() || relative ==
":")
411 return std::make_unique<QQmlPreviewFileEngine>(relative, absolute, m_loader.
data());
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines.
QDir::Filters filters() const
Returns the entry filters for this iterator.
FileOwner
\value OwnerUser The user who owns the file.
static std::unique_ptr< QAbstractFileEngine > create(const QString &fileName)
Creates and returns a QAbstractFileEngine suitable for processing fileName.
virtual QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const
Requests that a list of all the files matching the filters list based on the filterNames in the file ...
std::unique_ptr< Iterator > IteratorUniquePtr
FileName
These values are used to request a file name in a particular format.
bool open(OpenMode openMode) override
\reimp
qint64 pos() const override
\reimp
void setData(const QByteArray &data)
Sets the contents of the internal buffer to be data.
void close() override
\reimp
qint64 size() const override
\reimp
bool seek(qint64 off) override
\reimp
QByteArray & buffer()
Returns a reference to the QBuffer's internal buffer.
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
\inmodule QtCore\reentrant
static QDateTime currentDateTime()
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString cleanPath(const QString &path)
Returns path with directory separators normalized (that is, platform-native separators converted to "...
static QString currentPath()
Returns the absolute path of the application's current directory.
static Q_CORE_EXPORT bool isRootPath(const QString &path)
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
qint64 readLine(char *data, qint64 maxlen)
This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes,...
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read.
T * data() const noexcept
std::unique_ptr< QAbstractFileEngine > create(const QString &fileName) const override
If this file handler can handle fileName, this method creates a file engine and returns it wrapped in...
QQmlPreviewFileEngineHandler(QQmlPreviewFileLoader *loader)
QString currentFileName() const override
This pure virtual function returns the name of the current directory entry, excluding the path.
~QQmlPreviewFileEngineIterator()
QQmlPreviewFileEngineIterator(const QString &path, QDir::Filters filters, const QStringList &filterNames, const QStringList &m_entries)
bool advance() override
This pure virtual function advances the iterator to the next directory entry; if the operation was su...
bool supportsExtension(Extension extension) const override
bool link(const QString &newName) override
Creates a link from the file currently specified by fileName() to newName.
QQmlPreviewFileEngine(const QString &file, const QString &absolute, QQmlPreviewFileLoader *loader)
QDateTime fileTime(QFile::FileTime time) const override
If time is BirthTime, return when the file was born (created).
uint ownerId(FileOwner) const override
If owner is OwnerUser return the ID of the user who owns the file.
bool setPermissions(uint perms) override
Requests that the file's permissions be set to perms.
bool caseSensitive() const override
Should return true if the underlying file system is case-sensitive; otherwise return false.
FileFlags fileFlags(FileFlags type) const override
This function should return the set of OR'd flags that are true for the file engine's file,...
bool seek(qint64) override
Sets the file position to the given offset.
void setFileName(const QString &file) override
Sets the file engine's file name to file.
bool mkdir(const QString &dirName, bool createParentDirectories, std::optional< QFile::Permissions > permissions=std::nullopt) const override
Requests that the directory dirName be created with the specified permissions.
bool extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) override
QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const override
Requests that a list of all the files matching the filters list based on the filterNames in the file ...
bool flush() override
Flushes the open file, returning true if successful; otherwise returns false.
IteratorUniquePtr beginEntryList(const QString &path, QDir::Filters filters, const QStringList &filterNames) override
Returns a QAbstractFileEngine::IteratorUniquePtr, that can be used to iterate over the entries in pat...
qint64 read(char *data, qint64 maxlen) override
Reads a number of characters from the file into data.
qint64 write(const char *data, qint64 len) override
Writes len bytes from data to the file.
bool open(QIODevice::OpenMode flags, std::optional< QFile::Permissions > permissions) override
Opens the file in the specified mode.
qint64 pos() const override
Returns the current file position.
qint64 readLine(char *data, qint64 maxlen) override
This function reads one line, terminated by a '\n' character, from the file info data.
bool syncToDisk() override
IteratorUniquePtr endEntryList() override
bool copy(const QString &newName) override
Copies the contents of this file to a file with the name newName.
bool setSize(qint64 size) override
Requests that the file be set to size size.
bool isRelativePath() const override
Return true if the file referred to by this file engine has a relative path; otherwise return false.
bool rmdir(const QString &dirName, bool recurseParentDirectories) const override
Requests that the directory dirName is deleted from the file system.
QString owner(FileOwner) const override
If owner is OwnerUser return the name of the user who owns the file.
bool renameOverwrite(const QString &newName) override
bool isSequential() const override
Returns true if the file is a sequential access device; returns false if the file is a direct access ...
QString fileName(QAbstractFileEngine::FileName file) const override
Return the file engine's current file name in the format specified by file.
int handle() const override
Returns the native file handle for this file engine.
bool rename(const QString &newName) override
Requests that the file be renamed to newName in the file system.
qint64 size() const override
Returns the size of the file.
bool remove() override
Requests that the file is deleted from the file system.
bool close() override
Closes the file, returning true if successful; otherwise returns false.
QByteArray id() const override
Result load(const QString &file)
bool isBlacklisted(const QString &file)
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString left(qsizetype n) const &
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
void chop(qsizetype n)
Removes n characters from the end of the string.
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.
Combined button and popup list for selecting options.
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei const GLchar *const * path
static QT_BEGIN_NAMESPACE bool isRelative(const QString &path)
static QString absolutePath(const QString &path)
bool isRootPath(const QString &path)
QT_BEGIN_NAMESPACE typedef uchar * output
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]