Qt 4.8
Public Functions | Static Public Functions | Public Variables | List of all members
QDirPrivate Class Reference

#include <qdir_p.h>

Inheritance diagram for QDirPrivate:
QSharedData

Public Functions

void clearFileLists ()
 
bool exists () const
 
void initFileEngine ()
 
void initFileLists (const QDir &dir) const
 
 QDirPrivate (const QString &path, const QStringList &nameFilters_=QStringList(), QDir::SortFlags sort_=QDir::SortFlags(QDir::Name|QDir::IgnoreCase), QDir::Filters filters_=QDir::AllEntries)
 
 QDirPrivate (const QDirPrivate &copy)
 
void resolveAbsoluteEntry () const
 
void setPath (const QString &path)
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 

Static Public Functions

static QChar getFilterSepChar (const QString &nameFilter)
 
static void sortFileList (QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *)
 
static QStringList splitFilters (const QString &nameFilter, QChar sep=0)
 

Public Variables

QFileSystemEntry absoluteDirEntry
 
QFileSystemEntry dirEntry
 
QScopedPointer< QAbstractFileEnginefileEngine
 
QFileInfoList fileInfos
 
bool fileListsInitialized
 
QStringList files
 
QDir::Filters filters
 
QFileSystemMetaData metaData
 
QStringList nameFilters
 
QDir::SortFlags sort
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

Definition at line 50 of file qdir_p.h.

Constructors and Destructors

◆ QDirPrivate() [1/2]

QDirPrivate::QDirPrivate ( const QString path,
const QStringList nameFilters_ = QStringList(),
QDir::SortFlags  sort_ = QDir::SortFlags(QDir::Name | QDir::IgnoreCase),
QDir::Filters  filters_ = QDir::AllEntries 
)

Definition at line 89 of file qdir.cpp.

90  : QSharedData()
91  , nameFilters(nameFilters_)
92  , sort(sort_)
93  , filters(filters_)
94 #ifdef QT3_SUPPORT
95  , filterSepChar(0)
96  , matchAllDirs(false)
97 #endif
98  , fileListsInitialized(false)
99 {
100  setPath(path.isEmpty() ? QString::fromLatin1(".") : path);
101 
102  bool empty = nameFilters.isEmpty();
103  if (!empty) {
104  empty = true;
105  for (int i = 0; i < nameFilters.size(); ++i) {
106  if (!nameFilters.at(i).isEmpty()) {
107  empty = false;
108  break;
109  }
110  }
111  }
112  if (empty)
114 }
QSharedData()
Constructs a QSharedData object with a reference count of 0.
Definition: qshareddata.h:61
void setPath(const QString &path)
Definition: qdir.cpp:168
bool fileListsInitialized
Definition: qdir_p.h:87
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
QStringList nameFilters
Definition: qdir_p.h:76
QDir::SortFlags sort
Definition: qdir_p.h:77
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QDir::Filters filters
Definition: qdir_p.h:78

◆ QDirPrivate() [2/2]

QDirPrivate::QDirPrivate ( const QDirPrivate copy)

Definition at line 116 of file qdir.cpp.

117  : QSharedData(copy)
118  , nameFilters(copy.nameFilters)
119  , sort(copy.sort)
120  , filters(copy.filters)
121 #ifdef QT3_SUPPORT
122  , filterSepChar(copy.filterSepChar)
123  , matchAllDirs(copy.matchAllDirs)
124 #endif
125  , fileListsInitialized(false)
126  , dirEntry(copy.dirEntry)
127  , metaData(copy.metaData)
128 {
129 }
QSharedData()
Constructs a QSharedData object with a reference count of 0.
Definition: qshareddata.h:61
QFileSystemEntry dirEntry
Definition: qdir_p.h:91
bool fileListsInitialized
Definition: qdir_p.h:87
QStringList nameFilters
Definition: qdir_p.h:76
QDir::SortFlags sort
Definition: qdir_p.h:77
QDir::Filters filters
Definition: qdir_p.h:78
QFileSystemMetaData metaData
Definition: qdir_p.h:93

Functions

◆ clearFileLists()

void QDirPrivate::clearFileLists ( )
inline

Definition at line 187 of file qdir.cpp.

Referenced by QDir::nameFiltersFromString(), QDir::refresh(), QDir::setFilter(), QDir::setNameFilters(), setPath(), and QDir::setSorting().

188 {
189  fileListsInitialized = false;
190  files.clear();
191  fileInfos.clear();
192 }
QStringList files
Definition: qdir_p.h:88
bool fileListsInitialized
Definition: qdir_p.h:87
void clear()
Removes all items from the list.
Definition: qlist.h:764
QFileInfoList fileInfos
Definition: qdir_p.h:89

◆ exists()

bool QDirPrivate::exists ( ) const

Definition at line 131 of file qdir.cpp.

Referenced by QDir::cd(), and QDir::exists().

132 {
133  if (fileEngine.isNull()) {
136  return metaData.exists() && metaData.isDirectory();
137  }
138  const QAbstractFileEngine::FileFlags info =
143  return false;
144  return info & QAbstractFileEngine::ExistsFlag;
145 }
bool isNull() const
Returns true if this object is holding a pointer that is null.
static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
virtual FileFlags fileFlags(FileFlags type=FileInfoAll) const
This function should return the set of OR&#39;d flags that are true for the file engine&#39;s file...
static mach_timebase_info_data_t info
QFileSystemEntry dirEntry
Definition: qdir_p.h:91
QScopedPointer< QAbstractFileEngine > fileEngine
Definition: qdir_p.h:85
QFileSystemMetaData metaData
Definition: qdir_p.h:93

◆ getFilterSepChar()

QChar QDirPrivate::getFilterSepChar ( const QString nameFilter)
inlinestatic

Definition at line 148 of file qdir.cpp.

Referenced by QDir::nameFiltersFromString(), and splitFilters().

149 {
150  QChar sep(QLatin1Char(';'));
151  int i = nameFilter.indexOf(sep, 0);
152  if (i == -1 && nameFilter.indexOf(QLatin1Char(' '), 0) != -1)
153  sep = QChar(QLatin1Char(' '));
154  return sep;
155 }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ initFileEngine()

void QDirPrivate::initFileEngine ( )
inline

Definition at line 338 of file qdir.cpp.

Referenced by QDir::nameFiltersFromString(), QDir::refresh(), QDir::setFilter(), QDir::setNameFilters(), setPath(), and QDir::setSorting().

339 {
341 }
QFileSystemEntry dirEntry
Definition: qdir_p.h:91
QScopedPointer< QAbstractFileEngine > fileEngine
Definition: qdir_p.h:85
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
QFileSystemMetaData metaData
Definition: qdir_p.h:93
static QAbstractFileEngine * resolveEntryAndCreateLegacyEngine(QFileSystemEntry &entry, QFileSystemMetaData &data)
Resolves the entry (see QDir::searchPaths) and returns an engine for it, but never a QFSFileEngine...

◆ initFileLists()

void QDirPrivate::initFileLists ( const QDir dir) const
inline

Definition at line 324 of file qdir.cpp.

Referenced by QDir::count(), QDir::entryInfoList(), QDir::entryList(), and QDir::operator[]().

325 {
326  if (!fileListsInitialized) {
328  QDirIterator it(dir);
329  while (it.hasNext()) {
330  it.next();
331  l.append(it.fileInfo());
332  }
334  fileListsInitialized = true;
335  }
336 }
#define it(className, varName)
QStringList files
Definition: qdir_p.h:88
The QDirIterator class provides an iterator for directory entrylists.
Definition: qdiriterator.h:54
bool fileListsInitialized
Definition: qdir_p.h:87
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *)
Definition: qdir.cpp:294
QDir::SortFlags sort
Definition: qdir_p.h:77
QFactoryLoader * l
QFileInfoList fileInfos
Definition: qdir_p.h:89

◆ resolveAbsoluteEntry()

void QDirPrivate::resolveAbsoluteEntry ( ) const
inline

Definition at line 194 of file qdir.cpp.

Referenced by QDir::absoluteFilePath(), QDir::absolutePath(), QDir::makeAbsolute(), and QDir::operator==().

195 {
197  return;
198 
199  QString absoluteName;
200  if (fileEngine.isNull()) {
201  if (!dirEntry.isRelative() && dirEntry.isClean()) {
203  return;
204  }
205 
207  } else {
209  }
210 
212 }
bool isNull() const
Returns true if this object is holding a pointer that is null.
virtual QString fileName(FileName file=DefaultName) const
Return the file engine&#39;s current file name in the format specified by file.
QFileSystemEntry dirEntry
Definition: qdir_p.h:91
The QString class provides a Unicode character string.
Definition: qstring.h:83
QScopedPointer< QAbstractFileEngine > fileEngine
Definition: qdir_p.h:85
static QFileSystemEntry absoluteName(const QFileSystemEntry &entry)
static QString cleanPath(const QString &path)
Removes all multiple directory separators "/" and resolves any "."s or ".."s found in the path...
Definition: qdir.cpp:2082
QString filePath() const
bool isRelative() const
QFileSystemEntry absoluteDirEntry
Definition: qdir_p.h:92

◆ setPath()

void QDirPrivate::setPath ( const QString path)
inline

Definition at line 168 of file qdir.cpp.

Referenced by QDir::cd(), QDir::makeAbsolute(), QDir::operator=(), QDirPrivate(), and QDir::setPath().

169 {
171  if (p.endsWith(QLatin1Char('/'))
172  && p.length() > 1
173 #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
174  && (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter()))
175 #endif
176  ) {
177  p.truncate(p.length() - 1);
178  }
179 
181  metaData.clear();
182  initFileEngine();
183  clearFileLists();
185 }
bool isLetter() const
Returns true if the character is a letter (Letter_* categories); otherwise returns false...
Definition: qchar.cpp:653
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QFileSystemEntry dirEntry
Definition: qdir_p.h:91
The QString class provides a Unicode character string.
Definition: qstring.h:83
void initFileEngine()
Definition: qdir.cpp:338
void truncate(int pos)
Truncates the string at the given position index.
Definition: qstring.cpp:4603
void clearFileLists()
Definition: qdir.cpp:187
QFileSystemMetaData metaData
Definition: qdir_p.h:93
static QString fromNativeSeparators(const QString &pathName)
Returns pathName using &#39;/&#39; as file separator.
Definition: qdir.cpp:848
QFileSystemEntry absoluteDirEntry
Definition: qdir_p.h:92
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ sortFileList()

void QDirPrivate::sortFileList ( QDir::SortFlags  sort,
QFileInfoList l,
QStringList names,
QFileInfoList infos 
)
inlinestatic

Definition at line 294 of file qdir.cpp.

Referenced by QDir::entryInfoList(), QDir::entryList(), and initFileLists().

296 {
297  // names and infos are always empty lists or 0 here
298  int n = l.size();
299  if (n > 0) {
300  if (n == 1 || (sort & QDir::SortByMask) == QDir::Unsorted) {
301  if (infos)
302  *infos = l;
303  if (names) {
304  for (int i = 0; i < n; ++i)
305  names->append(l.at(i).fileName());
306  }
307  } else {
309  for (int i = 0; i < n; ++i)
310  si[i].item = l.at(i);
311  qSort(si.data(), si.data() + n, QDirSortItemComparator(sort));
312  // put them back in the list(s)
313  if (infos) {
314  for (int i = 0; i < n; ++i)
315  infos->append(si[i].item);
316  }
317  if (names) {
318  for (int i = 0; i < n; ++i)
319  names->append(si[i].item.fileName());
320  }
321  }
322  }
323 }
QString fileName() const
Returns the name of the file, excluding the path.
Definition: qfileinfo.cpp:726
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QScopedArrayPointer class stores a pointer to a dynamically allocated array of objects...
void qSort(RandomAccessIterator start, RandomAccessIterator end)
Definition: qalgorithms.h:177
QDir::SortFlags sort
Definition: qdir_p.h:77
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QFactoryLoader * l

◆ splitFilters()

QStringList QDirPrivate::splitFilters ( const QString nameFilter,
QChar  sep = 0 
)
inlinestatic

Definition at line 158 of file qdir.cpp.

Referenced by QDir::nameFiltersFromString().

159 {
160  if (sep == 0)
161  sep = getFilterSepChar(nameFilter);
162  QStringList ret = nameFilter.split(sep);
163  for (int i = 0; i < ret.count(); ++i)
164  ret[i] = ret[i].trimmed();
165  return ret;
166 }
static QChar getFilterSepChar(const QString &nameFilter)
Definition: qdir.cpp:148
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QString trimmed(QString source)
Definition: generator.cpp:233
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526

Properties

◆ absoluteDirEntry

QFileSystemEntry QDirPrivate::absoluteDirEntry
mutable

◆ dirEntry

QFileSystemEntry QDirPrivate::dirEntry

◆ fileEngine

QScopedPointer<QAbstractFileEngine> QDirPrivate::fileEngine

◆ fileInfos

QFileInfoList QDirPrivate::fileInfos
mutable

Definition at line 89 of file qdir_p.h.

Referenced by clearFileLists(), QDir::entryInfoList(), and initFileLists().

◆ fileListsInitialized

bool QDirPrivate::fileListsInitialized
mutable

Definition at line 87 of file qdir_p.h.

Referenced by clearFileLists(), and initFileLists().

◆ files

QStringList QDirPrivate::files
mutable

◆ filters

QDir::Filters QDirPrivate::filters

◆ metaData

QFileSystemMetaData QDirPrivate::metaData
mutable

◆ nameFilters

QStringList QDirPrivate::nameFilters

◆ sort

QDir::SortFlags QDirPrivate::sort

The documentation for this class was generated from the following files: