Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qfsfileengine_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
5#include "qfileinfo_p.h"
6#include "qvariant.h"
7
8#ifndef QT_NO_FILESYSTEMITERATOR
9
11
14 , done(false)
15{
16}
17
19{
20}
21
23{
24 if (!done && !nativeIterator) {
25 nativeIterator.reset(new QFileSystemIterator(QFileSystemEntry(path()),
26 filters(), nameFilters()));
27 advance();
28 }
29
30 return !done;
31}
32
34{
35 if (!hasNext())
36 return QString();
37
38 advance();
39 return currentFilePath();
40}
41
42void QFSFileEngineIterator::advance() const
43{
44 currentInfo = nextInfo;
45
48 if (nativeIterator->advance(entry, data)) {
49 nextInfo = QFileInfo(new QFileInfoPrivate(entry, data));
50 } else {
51 done = true;
52 nativeIterator.reset();
53 }
54}
55
57{
58 return currentInfo.fileName();
59}
60
62{
63 return currentInfo;
64}
65
67
68#endif // QT_NO_FILESYSTEMITERATOR
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines.
QDir::Filters filters() const
Returns the entry filters for this iterator.
QString path() const
Returns the path for this iterator.
QStringList nameFilters() const
Returns the name filters for this iterator.
virtual QString currentFilePath() const
Returns the path to the current directory entry.
QFSFileEngineIterator(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.
QFileInfo currentFileInfo() const override
The virtual function returns a QFileInfo for the current directory entry.
bool hasNext() const override
This pure virtual function returns true if there is at least one more entry in the current directory ...
QString next() override
This pure virtual function advances the iterator to the next directory entry, and returns the file pa...
\inmodule QtCore \reentrant
Definition qfileinfo.h:22
QString fileName() const
Returns the name of the file, excluding the path.
bool advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData)
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
Combined button and popup list for selecting options.
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint entry
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]