Qt 4.8
|
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines. More...
#include <qabstractfileengine.h>
Public Functions | |
virtual QFileInfo | currentFileInfo () const |
The virtual function returns a QFileInfo for the current directory entry. More... | |
virtual QString | currentFileName () const =0 |
This pure virtual function returns the name of the current directory entry, excluding the path. 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... | |
virtual bool | hasNext () const =0 |
This pure virtual function returns true if there is at least one more entry in the current directory (i. More... | |
QStringList | nameFilters () const |
Returns the name filters for this iterator. More... | |
virtual QString | next ()=0 |
This pure virtual function advances the iterator to the next directory entry, and returns the file path to the current entry. 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... | |
Protected Types | |
enum | EntryInfoType |
This enum describes the different types of information that can be requested through the QAbstractFileEngineIterator::entryInfo() function. More... | |
Protected Functions | |
virtual QVariant | entryInfo (EntryInfoType type) const |
Returns the entry info type for this iterator's current directory entry as a QVariant. More... | |
Private Functions | |
void | setPath (const QString &path) |
Sets the iterator path to path. More... | |
Properties | |
QScopedPointer< QAbstractFileEngineIteratorPrivate > | d |
Friends | |
class | QDirIterator |
class | QDirIteratorPrivate |
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines.
If all you want is to iterate over entries in a directory, see QDirIterator instead. This class is only for custom file engine authors.
QAbstractFileEngineIterator is a unidirectional single-use virtual iterator that plugs into QDirIterator, providing transparent proxy iteration for custom file engines.
You can subclass QAbstractFileEngineIterator to provide an iterator when writing your own file engine. To plug the iterator into your file system, you simply return an instance of this subclass from a reimplementation of QAbstractFileEngine::beginEntryList().
Example:
QAbstractFileEngineIterator is associated with a path, name filters, and entry filters. The path is the directory that the iterator lists entries in. The name filters and entry filters are provided for file engines that can optimize directory listing at the iterator level (e.g., network file systems that need to minimize network traffic), but they can also be ignored by the iterator subclass; QAbstractFileEngineIterator already provides the required filtering logics in the matchesFilters() function. You can call dirName() to get the directory name, nameFilters() to get a stringlist of name filters, and filters() to get the entry filters.
The pure virtual function hasNext() returns true if the current directory has at least one more entry (i.e., the directory name is valid and accessible, and we have not reached the end of the entry list), and false otherwise. Reimplement next() to seek to the next entry.
The pure virtual function currentFileName() returns the name of the current entry without advancing the iterator. The currentFilePath() function is provided for convenience; it returns the full path of the current entry.
Here is an example of how to implement an iterator that returns each of three fixed entries in sequence.
Note: QAbstractFileEngineIterator does not deal with QDir::IteratorFlags; it simply returns entries for a single directory.
Definition at line 214 of file qabstractfileengine.h.
|
protected |
This enum describes the different types of information that can be requested through the QAbstractFileEngineIterator::entryInfo() function.
Definition at line 232 of file qabstractfileengine.h.
QAbstractFileEngineIterator::QAbstractFileEngineIterator | ( | QDir::Filters | filters, |
const QStringList & | nameFilters | ||
) |
Constructs a QAbstractFileEngineIterator, using the entry filters filters, and wildcard name filters nameFilters.
Definition at line 926 of file qabstractfileengine.cpp.
|
virtual |
Destroys the QAbstractFileEngineIterator.
Definition at line 939 of file qabstractfileengine.cpp.
|
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.
Reimplemented in QFSFileEngineIterator.
Definition at line 1029 of file qabstractfileengine.cpp.
Referenced by QDirIteratorPrivate::advance().
|
pure virtual |
This pure virtual function returns the name of the current directory entry, excluding the path.
Implemented in QFSFileEngineIterator, and QResourceFileEngineIterator.
Referenced by QDirIteratorPrivate::advance(), and currentFilePath().
QString QAbstractFileEngineIterator::currentFilePath | ( | ) | const |
Returns the path to the current directory entry.
It's the same as prepending path() to the return value of currentFileName().
Definition at line 1006 of file qabstractfileengine.cpp.
Referenced by currentFileInfo(), QResourceFileEngineIterator::next(), and QFSFileEngineIterator::next().
|
protectedvirtual |
Returns the entry info type for this iterator's current directory entry as a QVariant.
If type is undefined for this entry, a null QVariant is returned.
Definition at line 1051 of file qabstractfileengine.cpp.
QDir::Filters QAbstractFileEngineIterator::filters | ( | ) | const |
Returns the entry filters for this iterator.
Definition at line 983 of file qabstractfileengine.cpp.
Referenced by QFSFileEngineIterator::hasNext(), and QAbstractFileEngineIterator().
|
pure 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).
Implemented in QFSFileEngineIterator, and QResourceFileEngineIterator.
Referenced by QDirIteratorPrivate::advance().
QStringList QAbstractFileEngineIterator::nameFilters | ( | ) | const |
Returns the name filters for this iterator.
Definition at line 973 of file qabstractfileengine.cpp.
Referenced by QFSFileEngineIterator::hasNext(), and QAbstractFileEngineIterator().
|
pure 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.
Implemented in QFSFileEngineIterator, and QResourceFileEngineIterator.
Referenced by QDirIteratorPrivate::advance().
QString QAbstractFileEngineIterator::path | ( | ) | const |
Returns the path for this iterator.
QDirIterator is responsible for assigning this path; it cannot change during the iterator's lifetime.
Definition at line 949 of file qabstractfileengine.cpp.
Referenced by currentFileInfo(), currentFilePath(), QResourceFileEngineIterator::hasNext(), QFSFileEngineIterator::hasNext(), and setPath().
|
private |
Sets the iterator path to path.
This function is called from within QDirIterator.
Definition at line 963 of file qabstractfileengine.cpp.
Referenced by QDirIteratorPrivate::pushDirectory().
|
friend |
Definition at line 238 of file qabstractfileengine.h.
|
friend |
Definition at line 239 of file qabstractfileengine.h.
|
private |
Definition at line 241 of file qabstractfileengine.h.
Referenced by currentFileInfo(), QAbstractFileEngine::error(), QAbstractFileEngine::errorString(), filters(), nameFilters(), path(), QAbstractFileEngineIterator(), QAbstractFileEngine::setError(), and setPath().