Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QFSFileEngineIterator Class Reference

#include <qfsfileengine_iterator_p.h>

Inheritance diagram for QFSFileEngineIterator:
QAbstractFileEngineIterator

Public Functions

QFileInfo currentFileInfo () const
 The virtual function returns a QFileInfo for the current directory entry. More...
 
QString currentFileName () const
 This pure virtual function returns the name of the current directory entry, excluding the path. More...
 
bool hasNext () const
 This pure virtual function returns true if there is at least one more entry in the current directory (i. More...
 
QString next ()
 This pure virtual function advances the iterator to the next directory entry, and returns the file path to the current entry. More...
 
 QFSFileEngineIterator (QDir::Filters filters, const QStringList &filterNames)
 
 ~QFSFileEngineIterator ()
 
- Public Functions inherited from QAbstractFileEngineIterator
QString currentFilePath () const
 Returns the path to the current directory entry. More...
 
QDir::Filters filters () const
 Returns the entry filters for this iterator. More...
 
QStringList nameFilters () const
 Returns the name filters for this iterator. More...
 
QString path () const
 Returns the path for this iterator. More...
 
 QAbstractFileEngineIterator (QDir::Filters filters, const QStringList &nameFilters)
 Constructs a QAbstractFileEngineIterator, using the entry filters filters, and wildcard name filters nameFilters. More...
 
virtual ~QAbstractFileEngineIterator ()
 Destroys the QAbstractFileEngineIterator. More...
 

Private Functions

void advance () const
 

Properties

QFileInfo currentInfo
 
bool done
 
QScopedPointer< QFileSystemIteratornativeIterator
 
QFileInfo nextInfo
 

Additional Inherited Members

- Protected Types inherited from QAbstractFileEngineIterator
enum  EntryInfoType
 This enum describes the different types of information that can be requested through the QAbstractFileEngineIterator::entryInfo() function. More...
 
- Protected Functions inherited from QAbstractFileEngineIterator
virtual QVariant entryInfo (EntryInfoType type) const
 Returns the entry info type for this iterator's current directory entry as a QVariant. More...
 

Detailed Description

Definition at line 68 of file qfsfileengine_iterator_p.h.

Constructors and Destructors

◆ QFSFileEngineIterator()

QFSFileEngineIterator::QFSFileEngineIterator ( QDir::Filters  filters,
const QStringList filterNames 
)

Definition at line 51 of file qfsfileengine_iterator.cpp.

52  : QAbstractFileEngineIterator(filters, filterNames)
53  , done(false)
54 {
55 }
QDir::Filters filters() const
Returns the entry filters for this iterator.
QAbstractFileEngineIterator(QDir::Filters filters, const QStringList &nameFilters)
Constructs a QAbstractFileEngineIterator, using the entry filters filters, and wildcard name filters ...

◆ ~QFSFileEngineIterator()

QFSFileEngineIterator::~QFSFileEngineIterator ( )

Definition at line 57 of file qfsfileengine_iterator.cpp.

58 {
59 }

Functions

◆ advance()

void QFSFileEngineIterator::advance ( ) const
private

Definition at line 81 of file qfsfileengine_iterator.cpp.

Referenced by hasNext(), and next().

82 {
84 
85  QFileSystemEntry entry;
87  if (nativeIterator->advance(entry, data)) {
88  nextInfo = QFileInfo(new QFileInfoPrivate(entry, data));
89  } else {
90  done = true;
92  }
93 }
static const char * data(const QByteArray &arr)
bool advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData)
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
QScopedPointer< QFileSystemIterator > nativeIterator
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ currentFileInfo()

QFileInfo QFSFileEngineIterator::currentFileInfo ( ) const
virtual

The virtual function returns a QFileInfo for the current directory entry.

This function is provided for convenience. It can also be slightly faster than creating a QFileInfo object yourself, as the object returned by this function might contain cached information that QFileInfo otherwise would have to access through the file engine.

See also
currentFileName()

Reimplemented from QAbstractFileEngineIterator.

Definition at line 100 of file qfsfileengine_iterator.cpp.

101 {
102  return currentInfo;
103 }

◆ currentFileName()

QString QFSFileEngineIterator::currentFileName ( ) const
virtual

This pure virtual function returns the name of the current directory entry, excluding the path.

See also
currentFilePath()

Implements QAbstractFileEngineIterator.

Definition at line 95 of file qfsfileengine_iterator.cpp.

96 {
97  return currentInfo.fileName();
98 }
QString fileName() const
Returns the name of the file, excluding the path.
Definition: qfileinfo.cpp:726

◆ hasNext()

bool QFSFileEngineIterator::hasNext ( ) const
virtual

This pure virtual function returns true if there is at least one more entry in the current directory (i.

e., the iterator path is valid and accessible, and the iterator has not reached the end of the entry list).

See also
QDirIterator::hasNext()

Implements QAbstractFileEngineIterator.

Definition at line 61 of file qfsfileengine_iterator.cpp.

Referenced by next().

62 {
63  if (!done && !nativeIterator) {
65  filters(), nameFilters()));
66  advance();
67  }
68 
69  return !done;
70 }
QString path() const
Returns the path for this iterator.
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
QDir::Filters filters() const
Returns the entry filters for this iterator.
QStringList nameFilters() const
Returns the name filters for this iterator.
QScopedPointer< QFileSystemIterator > nativeIterator

◆ next()

QString QFSFileEngineIterator::next ( )
virtual

This pure virtual function advances the iterator to the next directory entry, and returns the file path to the current entry.

This function can optionally make use of nameFilters() and filters() to optimize its performance.

Reimplement this function in a subclass to advance the iterator.

See also
QDirIterator::next()

Implements QAbstractFileEngineIterator.

Definition at line 72 of file qfsfileengine_iterator.cpp.

73 {
74  if (!hasNext())
75  return QString();
76 
77  advance();
78  return currentFilePath();
79 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool hasNext() const
This pure virtual function returns true if there is at least one more entry in the current directory ...
QString currentFilePath() const
Returns the path to the current directory entry.

Properties

◆ currentInfo

QFileInfo QFSFileEngineIterator::currentInfo
mutableprivate

Definition at line 83 of file qfsfileengine_iterator_p.h.

Referenced by advance(), currentFileInfo(), and currentFileName().

◆ done

bool QFSFileEngineIterator::done
mutableprivate

Definition at line 85 of file qfsfileengine_iterator_p.h.

Referenced by advance(), and hasNext().

◆ nativeIterator

QScopedPointer<QFileSystemIterator> QFSFileEngineIterator::nativeIterator
mutableprivate

Definition at line 82 of file qfsfileengine_iterator_p.h.

Referenced by advance(), and hasNext().

◆ nextInfo

QFileInfo QFSFileEngineIterator::nextInfo
mutableprivate

Definition at line 84 of file qfsfileengine_iterator_p.h.

Referenced by advance().


The documentation for this class was generated from the following files: