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) ==
':')
77 return m_index < m_entries.size();
82 if (m_index == 0 || m_index > m_entries.size())
84 return m_entries.at(m_index - 1);
89 m_name(
file), m_absolute(absolute), m_loader(
loader)
106 std::optional<QFile::Permissions> permissions)
114 return m_fallback->
open(
flags, permissions);
116 Q_UNREACHABLE_RETURN(
false);
124 return m_fallback->
close();
131 Q_UNREACHABLE_RETURN(
false);
137 return m_fallback ? m_fallback->
size() : m_contents.
size();
142 return m_fallback ? m_fallback->
pos() : m_contents.
pos();
147 return m_fallback? m_fallback->
seek(newPos) : m_contents.
seek(newPos);
152 return m_fallback ? m_fallback->
read(
data, maxlen) : m_contents.
read(
data, maxlen);
156 QAbstractFileEngine::FileFlags
type)
const
161 QAbstractFileEngine::FileFlags
ret;
164 ret |= QAbstractFileEngine::FileFlags(
193 return m_name.
mid(slashPos + 1);
199 else if (slashPos == 0)
201 return path.left(slashPos);
206 return m_absolute.
left(slashPos);
227 return m_fallback ? m_fallback->
endEntryList() :
nullptr;
232 return m_fallback ? m_fallback->
flush() :
true;
237 return m_fallback ? m_fallback->
syncToDisk() :
false;
247 return m_fallback ? m_fallback->
remove() :
false;
252 return m_fallback ? m_fallback->
copy(newName) :
false;
257 return m_fallback ? m_fallback->
rename(newName) :
false;
267 return m_fallback ? m_fallback->
link(newName) :
false;
271 std::optional<QFile::Permissions> permissions)
const
273 return m_fallback ? m_fallback->
mkdir(dirName, createParentDirectories, permissions) :
false;
278 return m_fallback ? m_fallback->
rmdir(dirName, recurseParentDirectories) :
false;
287 if (size < 0 || size > std::numeric_limits<int>::max())
294 Q_UNREACHABLE_RETURN(
false);
339 return m_fallback ? m_fallback->
handle() : -1;
362void QQmlPreviewFileEngine::load()
const
372 m_result = m_loader->
load(m_absolute);
378 m_entries = m_loader->
entries();
405 if (relative.
isEmpty() || relative ==
":")
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines.
QDir::Filters filters() const
Returns the entry filters for this iterator.
virtual QString currentFilePath() const
Returns the path to the current directory entry.
\inmodule QtCore \reentrant
virtual bool remove()
Requests that the file is deleted from the file system.
virtual bool renameOverwrite(const QString &newName)
FileOwner
\value OwnerUser The user who owns the file.
virtual bool supportsExtension(Extension extension) const
virtual bool copy(const QString &newName)
Copies the contents of this file to a file with the name newName.
virtual bool setPermissions(uint perms)
Requests that the file's permissions be set to perms.
virtual bool isRelativePath() const
Return true if the file referred to by this file engine has a relative path; otherwise return false.
virtual bool rmdir(const QString &dirName, bool recurseParentDirectories) const
Requests that the directory dirName is deleted from the file system.
virtual bool close()
Closes the file, returning true if successful; otherwise returns false.
virtual qint64 write(const char *data, qint64 len)
Writes len bytes from data to the file.
virtual int handle() const
Returns the native file handle for this file engine.
virtual bool flush()
Flushes the open file, returning true if successful; otherwise returns false.
virtual Iterator * endEntryList()
virtual bool seek(qint64 pos)
Sets the file position to the given offset.
virtual bool mkdir(const QString &dirName, bool createParentDirectories, std::optional< QFile::Permissions > permissions=std::nullopt) const
Requests that the directory dirName be created with the specified permissions.
virtual qint64 readLine(char *data, qint64 maxlen)
This function reads one line, terminated by a '\n' character, from the file info data.
virtual qint64 read(char *data, qint64 maxlen)
Reads a number of characters from the file into data.
virtual bool rename(const QString &newName)
Requests that the file be renamed to newName in the file system.
virtual QDateTime fileTime(FileTime time) const
If time is BirthTime, return when the file was born (created).
virtual bool link(const QString &newName)
Creates a link from the file currently specified by fileName() to newName.
FileTime
These are used by the fileTime() function.
virtual qint64 size() const
Returns the size of the file.
virtual uint ownerId(FileOwner) const
If owner is OwnerUser return the ID of the user who owns the file.
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 ...
virtual QString fileName(FileName file=DefaultName) const
Return the file engine's current file name in the format specified by file.
virtual bool isSequential() const
Returns true if the file is a sequential access device; returns false if the file is a direct access ...
virtual QByteArray id() const
static QAbstractFileEngine * create(const QString &fileName)
Creates and returns a QAbstractFileEngine suitable for processing fileName.
virtual FileFlags fileFlags(FileFlags type=FileInfoAll) const
This function should return the set of OR'd flags that are true for the file engine's file,...
virtual Iterator * beginEntryList(QDir::Filters filters, const QStringList &filterNames)
Returns an instance of a QAbstractFileEngineIterator using filters for entry filtering and filterName...
FileName
These values are used to request a file name in a particular format.
virtual bool extension(Extension extension, const ExtensionOption *option=nullptr, ExtensionReturn *output=nullptr)
virtual qint64 pos() const
Returns the current file position.
virtual bool syncToDisk()
virtual QString owner(FileOwner) const
If owner is OwnerUser return the name of the user who owns the file.
virtual bool caseSensitive() const
Should return true if the underlying file system is case-sensitive; otherwise return false.
virtual bool setSize(qint64 size)
Requests that the file be set to size size.
virtual bool open(QIODevice::OpenMode openMode, std::optional< QFile::Permissions > permissions=std::nullopt)
Opens the file in the specified mode.
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.
QAbstractFileEngine * create(const QString &fileName) const override
Creates a file engine for file fileName.
QQmlPreviewFileEngineHandler(QQmlPreviewFileLoader *loader)
QString currentFileName() const override
This pure virtual function returns the name of the current directory entry, excluding the path.
bool hasNext() const override
This pure virtual function returns true if there is at least one more entry in the current directory ...
QString next() override
This pure virtual function advances the iterator to the next directory entry, and returns the file pa...
QQmlPreviewFileEngineIterator(QDir::Filters filters, const QStringList &filterNames, const QStringList &m_entries)
~QQmlPreviewFileEngineIterator()
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)
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.
Iterator * endEntryList() override
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.
QDateTime fileTime(FileTime time) const override
If time is BirthTime, return when the file was born (created).
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
Iterator * beginEntryList(QDir::Filters filters, const QStringList &filterNames) override
Returns an instance of a QAbstractFileEngineIterator using filters for entry filtering and filterName...
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.
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
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)
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
\macro QT_RESTRICTED_CAST_FROM_ASCII
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
Returns a string that contains n characters of this string, starting at the specified position index.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
Combined button and popup list for selecting options.
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]