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
androidcontentfileengine.h
Go to the documentation of this file.
1// Copyright (C) 2019 Volker Krause <vkrause@kde.org>
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 ANDROIDCONTENTFILEENGINE_H
5#define ANDROIDCONTENTFILEENGINE_H
6
7#include <private/qfsfileengine_p.h>
8
9#include <QtCore/qjniobject.h>
10#include <QtCore/qlist.h>
11
13
14using DocumentFilePtr = std::shared_ptr<class DocumentFile>;
15
17{
18public:
20 bool open(QIODevice::OpenMode openMode, std::optional<QFile::Permissions> permissions) override;
21 bool close() override;
22 qint64 size() const override;
23 bool remove() override;
24 bool rename(const QString &newName) override;
25 bool mkdir(const QString &dirName, bool createParentDirectories,
26 std::optional<QFile::Permissions> permissions = std::nullopt) const override;
27 bool rmdir(const QString &dirName, bool recurseParentDirectories) const override;
28 QByteArray id() const override;
29 bool caseSensitive() const override { return true; }
30 QDateTime fileTime(QFile::FileTime time) const override;
31 FileFlags fileFlags(FileFlags type = FileInfoAll) const override;
32 QString fileName(FileName file = DefaultName) const override;
34 const QStringList &filterNames) override;
35
36private:
37 void closeNativeFileDescriptor();
38
39 QString m_initialFile;
40 QJniObject m_pfd;
41 DocumentFilePtr m_documentFile;
42};
43
45{
46 Q_DISABLE_COPY_MOVE(AndroidContentFileEngineHandler)
47public:
50 std::unique_ptr<QAbstractFileEngine> create(const QString &fileName) const override;
51};
52
54{
55public:
57 const QStringList &filterNames);
59
60 bool advance() override;
61
62 QString currentFileName() const override;
63 QString currentFilePath() const override;
64private:
65 mutable QList<DocumentFilePtr> m_files;
66 mutable qsizetype m_index = -1;
67};
68
76class DocumentFile : public std::enable_shared_from_this<DocumentFile>
77{
78public:
79 static DocumentFilePtr parseFromAnyUri(const QString &filename);
81 static DocumentFilePtr fromTreeUri(const QJniObject &treeUri);
82
85 const QJniObject &uri() const;
86 const DocumentFilePtr &parent() const;
87 QString name() const;
88 QString id() const;
89 QString mimeType() const;
90 bool isDirectory() const;
91 bool isFile() const;
92 bool isVirtual() const;
93 QDateTime lastModified() const;
94 int64_t length() const;
95 bool canRead() const;
96 bool canWrite() const;
97 bool remove();
98 bool exists() const;
99 std::vector<DocumentFilePtr> listFiles();
100 bool rename(const QString &newName);
101
102protected:
103 DocumentFile(const QJniObject &uri, const std::shared_ptr<DocumentFile> &parent);
104
105protected:
108};
109
111
112#endif // ANDROIDCONTENTFILEENGINE_H
std::shared_ptr< class DocumentFile > DocumentFilePtr
bool advance() override
This pure virtual function advances the iterator to the next directory entry; if the operation was su...
QString currentFilePath() const override
Returns the path to the current directory entry.
AndroidContentFileEngineIterator(const QString &path, QDir::Filters filters, const QStringList &filterNames)
QString currentFileName() const override
This pure virtual function returns the name of the current directory entry, excluding the path.
QByteArray id() const override
qint64 size() const override
Returns the size of the 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 caseSensitive() const override
Should return true if the underlying file system is case-sensitive; otherwise return 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...
FileFlags fileFlags(FileFlags type=FileInfoAll) const override
This function should return the set of OR'd flags that are true for the file engine's file,...
QDateTime fileTime(QFile::FileTime time) const override
If time is BirthTime, return when the file was born (created).
bool rmdir(const QString &dirName, bool recurseParentDirectories) const override
Requests that the directory dirName is deleted from the file system.
bool close() override
Closes the file, returning true if successful; otherwise returns false.
AndroidContentFileEngine(const QString &fileName)
bool rename(const QString &newName) override
Requests that the file be renamed to newName in the file system.
bool open(QIODevice::OpenMode openMode, std::optional< QFile::Permissions > permissions) override
Opens the file in the specified mode.
bool remove() override
Requests that the file is deleted from the file system.
DocumentFile Api.
DocumentFilePtr m_parent
const DocumentFilePtr & parent() const
bool rename(const QString &newName)
const QJniObject & uri() const
DocumentFilePtr createFile(const QString &mimeType, const QString &displayName)
DocumentFilePtr createDirectory(const QString &displayName)
std::vector< DocumentFilePtr > listFiles()
static DocumentFilePtr fromTreeUri(const QJniObject &treeUri)
static DocumentFilePtr fromSingleUri(const QJniObject &uri)
static DocumentFilePtr parseFromAnyUri(const QString &filename)
DocumentFile(const QJniObject &uri, const std::shared_ptr< DocumentFile > &parent)
QDateTime lastModified() const
\inmodule QtCore \reentrant
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines.
QDir::Filters filters() const
Returns the entry filters for this iterator.
std::unique_ptr< Iterator > IteratorUniquePtr
FileName
These values are used to request a file name in a particular format.
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore\reentrant
Definition qdatetime.h:283
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
static QString displayName(CGDirectDisplayID displayID)
GLenum type
GLsizei const GLchar *const * path
ptrdiff_t qsizetype
Definition qtypes.h:165
long long qint64
Definition qtypes.h:60
QFile file
[0]
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]
view create()