QAbstractFileEngineIterator: general code cleanup
- This is private API, no point having the d-pointer indirection; store the members in QAbstractFileEngineIterator directly. In subsequent commits sub-classes can use m_fileInfo from the base class, saving some space in e.g. QFSFileEngineIterator - Make setPath() public, it's a setter called by some QAFEI sub-classes - Remove EntryInfoType enum, nothing uses it This is a step towards remodeling QAFEIterator, and its subclasses, after QFileSystemIterator, i.e. adding a `virtual bool advance()` method, and dropping next()/hasNext(). This also is more inline with the QDirListing class (which uses STL-style iterators). Change-Id: I8ad774b854231e3cdce4935f04c8bf24031001dd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
94dfcaac8a
commit
e9126fd3ab
@ -870,14 +870,6 @@ bool QAbstractFileEngine::cloneTo(QAbstractFileEngine *target)
|
||||
\sa QDirListing
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QAbstractFileEngineIterator::EntryInfoType
|
||||
\internal
|
||||
|
||||
This enum describes the different types of information that can be
|
||||
requested through the QAbstractFileEngineIterator::entryInfo() function.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typedef QAbstractFileEngine::Iterator
|
||||
\since 4.3
|
||||
@ -885,25 +877,15 @@ bool QAbstractFileEngine::cloneTo(QAbstractFileEngine *target)
|
||||
Synonym for QAbstractFileEngineIterator.
|
||||
*/
|
||||
|
||||
class QAbstractFileEngineIteratorPrivate
|
||||
{
|
||||
public:
|
||||
QString path;
|
||||
QDir::Filters filters;
|
||||
QStringList nameFilters;
|
||||
QFileInfo fileInfo;
|
||||
};
|
||||
|
||||
/*!
|
||||
Constructs a QAbstractFileEngineIterator, using the entry filters \a
|
||||
filters, and wildcard name filters \a nameFilters.
|
||||
*/
|
||||
QAbstractFileEngineIterator::QAbstractFileEngineIterator(QDir::Filters filters,
|
||||
const QStringList &nameFilters)
|
||||
: d(new QAbstractFileEngineIteratorPrivate)
|
||||
: m_filters(filters),
|
||||
m_nameFilters(nameFilters)
|
||||
{
|
||||
d->nameFilters = nameFilters;
|
||||
d->filters = filters;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -926,7 +908,7 @@ QAbstractFileEngineIterator::~QAbstractFileEngineIterator()
|
||||
*/
|
||||
QString QAbstractFileEngineIterator::path() const
|
||||
{
|
||||
return d->path;
|
||||
return m_path;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -937,7 +919,7 @@ QString QAbstractFileEngineIterator::path() const
|
||||
*/
|
||||
void QAbstractFileEngineIterator::setPath(const QString &path)
|
||||
{
|
||||
d->path = path;
|
||||
m_path = path;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -947,7 +929,7 @@ void QAbstractFileEngineIterator::setPath(const QString &path)
|
||||
*/
|
||||
QStringList QAbstractFileEngineIterator::nameFilters() const
|
||||
{
|
||||
return d->nameFilters;
|
||||
return m_nameFilters;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -957,7 +939,7 @@ QStringList QAbstractFileEngineIterator::nameFilters() const
|
||||
*/
|
||||
QDir::Filters QAbstractFileEngineIterator::filters() const
|
||||
{
|
||||
return d->filters;
|
||||
return m_filters;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1001,26 +983,11 @@ QString QAbstractFileEngineIterator::currentFilePath() const
|
||||
QFileInfo QAbstractFileEngineIterator::currentFileInfo() const
|
||||
{
|
||||
QString path = currentFilePath();
|
||||
if (d->fileInfo.filePath() != path)
|
||||
d->fileInfo.setFile(path);
|
||||
if (m_fileInfo.filePath() != path)
|
||||
m_fileInfo.setFile(path);
|
||||
|
||||
// return a shallow copy
|
||||
return d->fileInfo;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Returns the entry info \a type for this iterator's current directory entry
|
||||
as a QVariant. If \a type is undefined for this entry, a null QVariant is
|
||||
returned.
|
||||
|
||||
\sa QAbstractFileEngine::beginEntryList(), QDir::beginEntryList()
|
||||
*/
|
||||
QVariant QAbstractFileEngineIterator::entryInfo(EntryInfoType type) const
|
||||
{
|
||||
Q_UNUSED(type);
|
||||
return QVariant();
|
||||
return m_fileInfo;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -191,7 +191,6 @@ public:
|
||||
virtual QAbstractFileEngine *create(const QString &fileName) const = 0;
|
||||
};
|
||||
|
||||
class QAbstractFileEngineIteratorPrivate;
|
||||
class Q_CORE_EXPORT QAbstractFileEngineIterator
|
||||
{
|
||||
public:
|
||||
@ -201,6 +200,7 @@ public:
|
||||
virtual QString next() = 0;
|
||||
virtual bool hasNext() const = 0;
|
||||
|
||||
void setPath(const QString &path);
|
||||
QString path() const;
|
||||
QStringList nameFilters() const;
|
||||
QDir::Filters filters() const;
|
||||
@ -210,17 +210,17 @@ public:
|
||||
virtual QString currentFilePath() const;
|
||||
|
||||
protected:
|
||||
enum EntryInfoType {
|
||||
};
|
||||
virtual QVariant entryInfo(EntryInfoType type) const;
|
||||
mutable QFileInfo m_fileInfo;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(QAbstractFileEngineIterator)
|
||||
friend class QDirIterator;
|
||||
friend class QDirIteratorPrivate;
|
||||
friend class QDirListingPrivate;
|
||||
void setPath(const QString &path);
|
||||
QScopedPointer<QAbstractFileEngineIteratorPrivate> d;
|
||||
|
||||
QDir::Filters m_filters;
|
||||
QStringList m_nameFilters;
|
||||
QString m_path;
|
||||
};
|
||||
|
||||
class QAbstractFileEnginePrivate
|
||||
|
Loading…
x
Reference in New Issue
Block a user