summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/androidcontentfileengine.cpp
diff options
context:
space:
mode:
authorAhmad Samir <[email protected]>2023-12-17 21:10:18 +0200
committerAhmad Samir <[email protected]>2024-03-20 21:49:59 +0200
commitceeaf1b65787d3ef46dd0bdbd0e6810137163fea (patch)
tree7a3e10733a58f622b79c16d9e87ad3f1b7e17448 /src/plugins/platforms/android/androidcontentfileengine.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 <[email protected]> Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
Diffstat (limited to 'src/plugins/platforms/android/androidcontentfileengine.cpp')
-rw-r--r--src/plugins/platforms/android/androidcontentfileengine.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/plugins/platforms/android/androidcontentfileengine.cpp b/src/plugins/platforms/android/androidcontentfileengine.cpp
index 67221080b20..d0a22e35ab7 100644
--- a/src/plugins/platforms/android/androidcontentfileengine.cpp
+++ b/src/plugins/platforms/android/androidcontentfileengine.cpp
@@ -276,15 +276,7 @@ AndroidContentFileEngineIterator::~AndroidContentFileEngineIterator()
{
}
-QString AndroidContentFileEngineIterator::next()
-{
- if (!hasNext())
- return QString();
- ++m_index;
- return currentFilePath();
-}
-
-bool AndroidContentFileEngineIterator::hasNext() const
+bool AndroidContentFileEngineIterator::advance()
{
if (m_index == -1 && m_files.isEmpty()) {
const auto currentPath = path();
@@ -295,9 +287,18 @@ bool AndroidContentFileEngineIterator::hasNext() const
if (iterDoc->isDirectory())
for (const auto &doc : iterDoc->listFiles())
m_files.append(doc);
+ if (m_files.isEmpty())
+ return false;
+ m_index = 0;
+ return true;
}
- return m_index < (m_files.size() - 1);
+ if (m_index < m_files.size() - 1) {
+ ++m_index;
+ return true;
+ }
+
+ return false;
}
QString AndroidContentFileEngineIterator::currentFileName() const