Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmlpreviewfileengine.h
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLPREVIEWFILEENGINE_H
5#define QQMLPREVIEWFILEENGINE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
19
20#include <QtCore/qpointer.h>
21#include <private/qabstractfileengine_p.h>
22#include <private/qfsfileengine_p.h>
23#include <QtCore/qbuffer.h>
24
25#include <memory>
26
28
30{
31public:
32 QQmlPreviewFileEngine(const QString &file, const QString &absolute,
33 QQmlPreviewFileLoader *loader);
34
35 void setFileName(const QString &file) override;
36
37 bool open(QIODevice::OpenMode flags, std::optional<QFile::Permissions> permissions) override;
38 bool close() override;
39 qint64 size() const override;
40 qint64 pos() const override;
41 bool seek(qint64) override;
42 qint64 read(char *data, qint64 maxlen) override;
43
44 FileFlags fileFlags(FileFlags type) const override;
46 uint ownerId(FileOwner) const override;
47
49 const QStringList &filterNames) override;
51
52 // Forwarding to fallback if exists
53 bool flush() override;
54 bool syncToDisk() override;
55 bool isSequential() const override;
56 bool remove() override;
57 bool copy(const QString &newName) override;
58 bool rename(const QString &newName) override;
59 bool renameOverwrite(const QString &newName) override;
60 bool link(const QString &newName) override;
61 bool mkdir(const QString &dirName, bool createParentDirectories,
62 std::optional<QFile::Permissions> permissions = std::nullopt) const override;
63 bool rmdir(const QString &dirName, bool recurseParentDirectories) const override;
64 bool setSize(qint64 size) override;
65 bool caseSensitive() const override;
66 bool isRelativePath() const override;
67 QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const override;
68 bool setPermissions(uint perms) override;
69 QByteArray id() const override;
70 QString owner(FileOwner) const override;
71 QDateTime fileTime(QFile::FileTime time) const override;
72 int handle() const override;
73 qint64 readLine(char *data, qint64 maxlen) override;
74 qint64 write(const char *data, qint64 len) override;
76 bool supportsExtension(Extension extension) const override;
77
78private:
79 void load() const;
80
81 QString m_name;
82 QString m_absolute;
83 QPointer<QQmlPreviewFileLoader> m_loader;
84
85 mutable QBuffer m_contents;
86 mutable QStringList m_entries;
87 mutable std::unique_ptr<QAbstractFileEngine> m_fallback;
89};
90
92{
93 Q_DISABLE_COPY_MOVE(QQmlPreviewFileEngineHandler)
94public:
96 std::unique_ptr<QAbstractFileEngine> create(const QString &fileName) const override;
97
98private:
99 QPointer<QQmlPreviewFileLoader> m_loader;
100};
101
102
103
105
106#endif // QQMLPREVIEWFILEENGINE_H
\inmodule QtCore \reentrant
\inmodule QtCore \reentrant
FileOwner
\value OwnerUser The user who owns the file.
std::unique_ptr< Iterator > IteratorUniquePtr
FileName
These values are used to request a file name in a particular format.
\inmodule QtCore \reentrant
Definition qbuffer.h:16
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore\reentrant
Definition qdatetime.h:283
QQmlPreviewFileEngineHandler(QQmlPreviewFileLoader *loader)
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.
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.
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 ...
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
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
void extension()
[6]
Definition dialogs.cpp:230
Combined button and popup list for selecting options.
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum type
GLbitfield flags
GLsizei const GLchar *const * path
GLuint GLenum option
GLenum GLsizei len
unsigned int uint
Definition qtypes.h:34
long long qint64
Definition qtypes.h:60
QT_BEGIN_NAMESPACE typedef uchar * output
QFile file
[0]
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]
view create()