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
src_corelib_io_qabstractfileengine.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4using namespace Qt::StringLiterals;
5
8{
9public:
10 std::unique_ptr<QAbstractFileEngine> create(const QString &fileName) const override;
11};
12
13std::unique_ptr<QAbstractFileEngine> ZipEngineHandler::create(const QString &fileName) const
14{
15 // ZipEngineHandler returns a ZipEngine for all .zip files
16 if (fileName.toLower().endsWith(".zip"_L1))
17 return std::make_unique<ZipEngine>(fileName);
18 return {};
19}
20
21int main(int argc, char **argv)
22{
23 QApplication app(argc, argv);
24
26
28 window.show();
29
30 return app.exec();
31}
33
35std::unique_ptr<QAbstractFileEngine> ZipEngineHandler::create(const QString &fileName) const
36{
37 // ZipEngineHandler returns a ZipEngine for all .zip files
38 if (fileName.toLower().endsWith(".zip"_L1))
39 return std::make_unique<ZipEngine>(fileName);
40 else
41 return {};
42}
44
45
48CustomFileEngine::beginEntryList(const QString &path, QDir::Filters filters,
49 const QStringList &filterNames)
50{
51 return std::make_unique<CustomFileEngineIterator>(path, filters, filterNames);
52}
54
55
58{
59public:
60 CustomIterator(const QString &path, const QStringList &nameFilters, QDir::Filters filters)
62 {
63 // In a real iterator, these entries are fetched from the
64 // file system based on the value of path().
65 entries << "entry1" << "entry2" << "entry3";
66 }
67
68 bool advance() override
69 {
70 if (entries.isEmpty())
71 return false;
72 if (index < entries.size() - 1) {
73 ++index;
74 return true;
75 }
76 return false;
77 }
78
80 {
81 return entries.at(index);
82 }
83
84private:
85 QStringList entries;
86 int index;
87};
bool advance() override
This pure virtual function advances the iterator to the next directory entry; if the operation was su...
CustomIterator(const QString &path, const QStringList &nameFilters, QDir::Filters filters)
\inmodule QtCore \reentrant
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines.
std::unique_ptr< Iterator > IteratorUniquePtr
The QApplication class manages the GUI application's control flow and main settings.
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
Definition qstring.h:1226
std::unique_ptr< QAbstractFileEngine > create(const QString &fileName) const override
[0]
int main()
[0]
GLuint index
[2]
GLsizei const GLchar *const * path
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]
QApplication app(argc, argv)
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]
view create()
QJSEngine engine
[0]