![]() |
CopperSpice API
1.8.1
|
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 |
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.
|
pure virtual |
This pure virtual function returns 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 |
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).
QStringList QAbstractFileEngineIterator::nameFilters | ( | ) | const |
Returns the name filters for this iterator.
|
pure virtual |
This pure virtual function advances the iterator to the next directory entry, and returns the file path to the current entry. This method can optionally make use of nameFilters() and filters() to optimize its performance.
When reimplementing this method make sure to advance the iterator.
QString QAbstractFileEngineIterator::path | ( | ) | const |
Returns the path for this iterator.