summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qabstractfileengine.cpp
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-12-17 21:10:18 +0200
committerAhmad Samir <a.samirh78@gmail.com>2024-03-20 21:49:59 +0200
commitceeaf1b65787d3ef46dd0bdbd0e6810137163fea (patch)
tree7a3e10733a58f622b79c16d9e87ad3f1b7e17448 /src/corelib/io/qabstractfileengine.cpp
parentcd5dd8b95bbda1e9531af52c251ea926f125c8ea (diff)
QAbstractFileEngineIterator: add `bool advance()` virtual method
And remove hasNext/next() methods. This remodels QAFEI to be like QFileSystemIterator. This better fits the logic in the newly added QDirListing class (which uses STL-style iterators). QFSFileEngineIterator: Initialize the internal nativeIterator in the constructor; also replace the advance() private method with an override for the advance() method inherited from the base class. QResourceFileEngineIterator: Override currentFileInfo(), with a QResouces the QFileInfo is created on demand if/when this method is called. This is the backend/private API, and QDirListing is the public API that can be used in a ranged-for to iterate over directory entries. Change-Id: I93eb7bdd64823ac01eea2dcaaa6bcc8ad868b2c4 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/io/qabstractfileengine.cpp')
-rw-r--r--src/corelib/io/qabstractfileengine.cpp22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp
index 2ad732cf3b..e7a3d10d01 100644
--- a/src/corelib/io/qabstractfileengine.cpp
+++ b/src/corelib/io/qabstractfileengine.cpp
@@ -862,10 +862,11 @@ bool QAbstractFileEngine::cloneTo(QAbstractFileEngine *target)
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 \c 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 advance(), as its name implies, advances the
+ iterator to the next entry in the current directory; if the operation
+ was successful this method returns \c true, otherwise it returns \c
+ false. You have to reimplement this function in your sub-class to work
+ with your file engine implementation.
The pure virtual function currentFileName() returns the name of the
current entry without advancing the iterator. The currentFilePath()
@@ -995,10 +996,11 @@ QFileInfo QAbstractFileEngineIterator::currentFileInfo() const
}
/*!
- \fn virtual QString QAbstractFileEngineIterator::next() = 0
+ \fn virtual bool QAbstractFileEngineIterator::advance() = 0
This pure virtual function advances the iterator to the next directory
- entry, and returns the file path to the current entry.
+ entry; if the operation was successful this method returns \c true,
+ otherwise it returs \c false.
This function can optionally make use of nameFilters() and filters() to
optimize its performance.
@@ -1007,14 +1009,6 @@ QFileInfo QAbstractFileEngineIterator::currentFileInfo() const
*/
/*!
- \fn virtual bool QAbstractFileEngineIterator::hasNext() const = 0
-
- This pure virtual function returns \c 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).
-*/
-
-/*!
Returns a QAbstractFileEngine::IteratorUniquePtr, that can be used
to iterate over the entries in \a path, using \a filters for entry
filtering and \a filterNames for name filtering. This function is called