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
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
4#include "qresource.h"
6
7#include <QtCore/qvariant.h>
8
10
12 const QStringList &filterNames)
14 index(-1)
15{
16}
17
21
23{
24 if (index == -1) {
25 // Lazy initialization of the iterator
26 QResource resource(path());
27 if (!resource.isValid())
28 return false;
29
30 // Initialize and move to the first entry.
31 entries = resource.children();
32 if (entries.isEmpty())
33 return false;
34
35 index = 0;
36 return true;
37 }
38
39 if (index < entries.size() - 1) {
40 ++index;
41 return true;
42 }
43
44 return false;
45}
46
48{
49 if (index < 0 || index > entries.size())
50 return QString();
51 return entries.at(index);
52}
53
59
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines.
QString path() const
Returns the path for this iterator.
virtual QString currentFilePath() const
Returns the path to the current directory entry.
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:20
QStringList children() const
Returns a list of all resources in this directory, if the resource represents a file the list will be...
bool isValid() const
Returns true if the resource really exists in the resource hierarchy, false otherwise.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
GLuint index
[2]
GLsizei const GLchar *const * path
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]