CopperSpice API
1.9.2
|
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines. More...
Public Methods | |
QAbstractFileEngineIterator (QDir::Filters filters, const QStringList &nameFilters) | |
virtual | ~QAbstractFileEngineIterator () |
virtual QFileInfo | currentFileInfo () const |
virtual QString | currentFileName () const = 0 |
QString | currentFilePath () const |
QDir::Filters | filters () const |
virtual bool | hasNext () const = 0 |
QStringList | nameFilters () const |
virtual QString | next () = 0 |
QString | path () const |
Friends | |
class | QDirIterator |
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines. If your application only needs to iterate over entries in a directory then refer to QDirIterator. This class is used when implementing a custom file engine.
The following three steps are required to use this class.
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 methods hasNext() returns true if the current directory has at least one more entry and false otherwise. The method currentFileName() returns the name of the current entry without advancing the iterator. The currentFilePath() method returns the full path of the current entry.
The following example shows how to implement an iterator which returns each of three fixed entries in sequence.
QAbstractFileEngineIterator does not handle QDir::IteratorFlags it simply returns entries for a single directory.
QAbstractFileEngineIterator::QAbstractFileEngineIterator | ( | QDir::Filters | filters, |
const QStringList & | nameFilters | ||
) |
Constructs a QAbstractFileEngineIterator using the entry filters and wildcard nameFilters.
|
virtual |
Destroys the QAbstractFileEngineIterator.
|
virtual |
Returns a QFileInfo for the current directory entry. This method can be slightly faster than creating a QFileInfo object directly.
|
pure virtual |
Override this method to return the name of the current directory entry, excluding the path.
QString QAbstractFileEngineIterator::currentFilePath | ( | ) | const |
Returns the path to the current directory entry. This is the same as prepending path() to the return value of currentFileName().
QDir::Filters QAbstractFileEngineIterator::filters | ( | ) | const |
Returns the entry filters for this iterator.
|
pure virtual |
Override this method to return true if there is at least one more entry in the current directory.
QStringList QAbstractFileEngineIterator::nameFilters | ( | ) | const |
Returns the name filters for this iterator.
|
pure virtual |
When overriding this method advance the iterator to the next directory entry and return the file path to this entry. This method can optionally make use of nameFilters() and filters() to optimize performance.
QString QAbstractFileEngineIterator::path | ( | ) | const |
Returns the path for this iterator.