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

#include <qresource_iterator_p.h>

Inheritance diagram for QResourceFileEngineIterator:
QAbstractFileEngineIterator

Public Functions

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...
 
 QResourceFileEngineIterator (QDir::Filters filters, const QStringList &filterNames)
 
 ~QResourceFileEngineIterator ()
 
- Public Functions inherited from QAbstractFileEngineIterator
virtual QFileInfo currentFileInfo () const
 The virtual function returns a QFileInfo for the current directory entry. More...
 
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...
 

Properties

QStringList entries
 
int index
 

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 62 of file qresource_iterator_p.h.

Constructors and Destructors

◆ QResourceFileEngineIterator()

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

Definition at line 49 of file qresource_iterator.cpp.

51  : QAbstractFileEngineIterator(filters, filterNames), index(-1)
52 {
53 }
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 ...

◆ ~QResourceFileEngineIterator()

QResourceFileEngineIterator::~QResourceFileEngineIterator ( )

Definition at line 55 of file qresource_iterator.cpp.

56 {
57 }

Functions

◆ currentFileName()

QString QResourceFileEngineIterator::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 83 of file qresource_iterator.cpp.

84 {
85  if (index <= 0 || index > entries.size())
86  return QString();
87  return entries.at(index - 1);
88 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ hasNext()

bool QResourceFileEngineIterator::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 67 of file qresource_iterator.cpp.

Referenced by next().

68 {
69  if (index == -1) {
70  // Lazy initialization of the iterator
71  QResource resource(path());
72  if (!resource.isValid())
73  return false;
74 
75  // Initialize and move to the next entry.
76  entries = resource.children();
77  index = 0;
78  }
79 
80  return index < entries.size();
81 }
QString path() const
Returns the path for this iterator.
The QResource class provides an interface for reading directly from resources.
Definition: qresource.h:58
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ next()

QString QResourceFileEngineIterator::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 59 of file qresource_iterator.cpp.

60 {
61  if (!hasNext())
62  return QString();
63  ++index;
64  return currentFilePath();
65 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString currentFilePath() const
Returns the path to the current directory entry.
bool hasNext() const
This pure virtual function returns true if there is at least one more entry in the current directory ...

Properties

◆ entries

QStringList QResourceFileEngineIterator::entries
mutableprivate

Definition at line 74 of file qresource_iterator_p.h.

Referenced by currentFileName(), and hasNext().

◆ index

int QResourceFileEngineIterator::index
mutableprivate

Definition at line 75 of file qresource_iterator_p.h.

Referenced by currentFileName(), hasNext(), and next().


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