Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qresource_iterator.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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// Qt-Security score:significant reason:default
4
5#include "qresource.h"
7
8#include <QtCore/qvariant.h>
9
11
12QResourceFileEngineIterator::QResourceFileEngineIterator(const QString &path, QDir::Filters filters,
13 const QStringList &filterNames)
14 : QAbstractFileEngineIterator(path, filters, filterNames),
15 index(-1)
16{
17}
18
20 QDirListing::IteratorFlags filters,
21 const QStringList &filterNames)
23 index(-1)
24{
25}
26
30
32{
33 if (index == -1) {
34 // Lazy initialization of the iterator
35 QResource resource(path());
36 if (!resource.isValid())
37 return false;
38
39 // Initialize and move to the first entry.
40 entries = resource.children();
41 if (entries.isEmpty())
42 return false;
43
44 index = 0;
45 return true;
46 }
47
48 if (index < entries.size() - 1) {
49 ++index;
50 return true;
51 }
52
53 return false;
54}
55
57{
58 if (index < 0 || index > entries.size())
59 return QString();
60 return entries.at(index);
61}
62
64{
65 m_fileInfo = QFileInfo(currentFilePath());
66 return m_fileInfo;
67}
68
69QT_END_NAMESPACE
QResourceFileEngineIterator(const QString &path, QDir::Filters filters, const QStringList &filterNames)
bool advance() override
This pure virtual function advances the iterator to the next directory entry; if the operation was su...
QString currentFileName() const override
This pure virtual function returns the name of the current directory entry, excluding the path.
QFileInfo currentFileInfo() const override
The virtual function returns a QFileInfo for the current directory entry.
\inmodule QtCore
Definition qresource.h:21