summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2010-08-25 13:16:51 (GMT)
committerJoão Abecasis <joao.abecasis@nokia.com>2010-08-25 14:35:31 (GMT)
commit72b00f0b6285aed47009067be4d92869d128856e (patch)
tree12edd5509ba31994e56b6ecf631c84d9f36f3701 /src/corelib
parent84373eb1c5f78874cf44b6e63cbffd4d49820f1d (diff)
downloadQt-72b00f0b6285aed47009067be4d92869d128856e.zip
Qt-72b00f0b6285aed47009067be4d92869d128856e.tar.gz
Qt-72b00f0b6285aed47009067be4d92869d128856e.tar.bz2
QDirPrivate refactoring
Some renaming to make intent clearer and improve consistency: listsDirty => listsInitialized (logic inverted) updateFileLists => initFileLists clear => clearFileLists Also note that initializing file lists shouldn't trigger detach, because no previous version of the cached data has been seen. Reviewed-by: Thomas Zander
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qdir.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 02f0e06..a88b284 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -98,7 +98,7 @@ public:
, matchAllDirs(false)
#endif
, fileEngine(0)
- , listsDirty(1)
+ , fileListsInitialized(false)
{
setPath(path.isEmpty() ? QString::fromLatin1(".") : path);
@@ -127,7 +127,7 @@ public:
, matchAllDirs(copy.matchAllDirs)
#endif
, fileEngine(0)
- , listsDirty(1)
+ , fileListsInitialized(false)
{
}
@@ -137,7 +137,7 @@ public:
}
void initFileEngine();
- void updateFileLists() const;
+ void initFileLists() const;
static void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *);
@@ -175,11 +175,11 @@ public:
// set the path to be the qt friendly version so then we can operate on it using just /
path = fileEngine->fileName(QAbstractFileEngine::DefaultName);
- clear();
+ clearFileLists();
}
- inline void clear() {
- listsDirty = 1;
+ inline void clearFileLists() {
+ fileListsInitialized = false;
files.clear();
fileInfos.clear();
}
@@ -196,7 +196,7 @@ public:
QAbstractFileEngine *fileEngine;
- mutable uint listsDirty : 1;
+ mutable bool fileListsInitialized;
mutable QStringList files;
mutable QFileInfoList fileInfos;
};
@@ -312,9 +312,9 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l,
}
}
-inline void QDirPrivate::updateFileLists() const
+inline void QDirPrivate::initFileLists() const
{
- if (listsDirty) {
+ if (!fileListsInitialized) {
QFileInfoList l;
QDirIterator it(path, nameFilters, filters);
while (it.hasNext()) {
@@ -322,7 +322,7 @@ inline void QDirPrivate::updateFileLists() const
l.append(it.fileInfo());
}
sortFileList(sort, l, &files, &fileInfos);
- listsDirty = 0;
+ fileListsInitialized = true;
}
}
@@ -948,7 +948,7 @@ void QDir::setNameFilters(const QStringList &nameFilters)
{
Q_D(QDir);
d->initFileEngine();
- d->clear();
+ d->clearFileLists();
d->nameFilters = nameFilters;
}
@@ -1137,7 +1137,7 @@ void QDir::setFilter(Filters filters)
{
Q_D(QDir);
d->initFileEngine();
- d->clear();
+ d->clearFileLists();
d->filters = filters;
}
@@ -1195,7 +1195,7 @@ void QDir::setSorting(SortFlags sort)
{
Q_D(QDir);
d->initFileEngine();
- d->clear();
+ d->clearFileLists();
d->sort = sort;
}
@@ -1210,7 +1210,7 @@ void QDir::setSorting(SortFlags sort)
uint QDir::count() const
{
Q_D(const QDir);
- d->updateFileLists();
+ d->initFileLists();
return d->files.count();
}
@@ -1224,7 +1224,7 @@ uint QDir::count() const
QString QDir::operator[](int pos) const
{
Q_D(const QDir);
- d->updateFileLists();
+ d->initFileLists();
return d->files[pos];
}
@@ -1307,7 +1307,7 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters,
sort = d->sort;
if (filters == d->filters && sort == d->sort && nameFilters == d->nameFilters) {
- d->updateFileLists();
+ d->initFileLists();
return d->files;
}
@@ -1353,7 +1353,7 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter
sort = d->sort;
if (filters == d->filters && sort == d->sort && nameFilters == d->nameFilters) {
- d->updateFileLists();
+ d->initFileLists();
return d->fileInfos;
}
@@ -1589,7 +1589,7 @@ bool QDir::makeAbsolute() // ### What do the return values signify?
d->path = absolutePath;
d->initFileEngine();
- d->clear();
+ d->clearFileLists();
if (!(d->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType))
return false;
@@ -2142,7 +2142,7 @@ void QDir::refresh() const
{
QDirPrivate *d = const_cast<QDir*>(this)->d_func();
d->initFileEngine();
- d->clear();
+ d->clearFileLists();
}
/*!
@@ -2232,7 +2232,7 @@ void QDir::setMatchAllDirs(bool on)
{
Q_D(QDir);
d->initFileEngine();
- d->clear();
+ d->clearFileLists();
d->matchAllDirs = on;
}