⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdiriterator.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    if (!foundValidEntry)        done = true;}/*!    \internal    This convenience function implements the iterator's filtering logics and    applies then to the current directory entry.    It returns true if the current entry matches the filters (i.e., the    current entry will be returned as part of the directory iteration);    otherwise, false is returned.*/bool QDirIteratorPrivate::matchesFilters(const QAbstractFileEngineIterator *it) const{    const bool filterPermissions = ((filters & QDir::PermissionMask)                                    && (filters & QDir::PermissionMask) != QDir::PermissionMask);    const bool skipDirs     = !(filters & (QDir::Dirs | QDir::AllDirs));    const bool skipFiles    = !(filters & QDir::Files);    const bool skipSymlinks = (filters & QDir::NoSymLinks);    const bool doReadable   = !filterPermissions || (filters & QDir::Readable);    const bool doWritable   = !filterPermissions || (filters & QDir::Writable);    const bool doExecutable = !filterPermissions || (filters & QDir::Executable);    const bool includeHidden = (filters & QDir::Hidden);    const bool includeSystem = (filters & QDir::System);#ifndef QT_NO_REGEXP    // Prepare name filters    QList<QRegExp> regexps;    bool hasNameFilters = !nameFilters.isEmpty() && !(nameFilters.contains(QLatin1String("*")));    if (hasNameFilters) {        for (int i = 0; i < nameFilters.size(); ++i) {            regexps << QRegExp(nameFilters.at(i),                               (filters & QDir::CaseSensitive) ? Qt::CaseSensitive : Qt::CaseInsensitive,                               QRegExp::Wildcard);        }    }#endif    QString fileName = it->currentFileName();    if (fileName.isEmpty()) {        // invalid entry        return false;    }    QFileInfo fi = it->currentFileInfo();    QString filePath = it->currentFilePath();#ifndef QT_NO_REGEXP    // Pass all entries through name filters, except dirs if the AllDirs    // filter is passed.    if (hasNameFilters && !((filters & QDir::AllDirs) && fi.isDir())) {        bool matched = false;        for (int i = 0; i < regexps.size(); ++i) {            if (regexps.at(i).exactMatch(fileName)) {                matched = true;                break;            }        }        if (!matched)            return false;    }#endif        bool dotOrDotDot = (fileName == QLatin1String(".") || fileName == QLatin1String(".."));    if ((filters & QDir::NoDotAndDotDot) && dotOrDotDot)        return false;    bool isHidden = !dotOrDotDot && fi.isHidden();    if (!includeHidden && isHidden)        return false;    bool isSystem = (!fi.isFile() && !fi.isDir() && !fi.isSymLink())                    || (!fi.exists() && fi.isSymLink());    if (!includeSystem && isSystem)        return false;    bool alwaysShow = (filters & QDir::TypeMask) == 0        && ((isHidden && includeHidden)            || (includeSystem && isSystem));    // Skip files and directories    if ((filters & QDir::AllDirs) == 0 && skipDirs && fi.isDir()) {        if (!alwaysShow)            return false;    }    if ((skipFiles && (fi.isFile() || !fi.exists()))        || (skipSymlinks && fi.isSymLink())) {        if (!alwaysShow)            return false;    }    if (filterPermissions        && ((doReadable && !fi.isReadable())            || (doWritable && !fi.isWritable())            || (doExecutable && !fi.isExecutable()))) {        return false;    }    if (!includeSystem && !dotOrDotDot && ((fi.exists() && !fi.isFile() && !fi.isDir() && !fi.isSymLink())                                           || (!fi.exists() && fi.isSymLink()))) {        return false;    }        return true;}/*!    Constructs a QDirIterator that can iterate over \a dir's entrylist, using    \a dir's name filters and regular filters. You can pass options via \a    flags to decide how the directory should be iterated.    By default, \a flags is NoIteratorFlags, which provides the same behavior    as in QDir::entryList().    The sorting in \a dir is ignored.    \sa hasNext(), next(), IteratorFlags*/QDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags)    : d(new QDirIteratorPrivate(dir.path(), dir.nameFilters(), dir.filter(), flags)){    d->q = this;}/*!    Constructs a QDirIterator that can iterate over \a path, with no name    filtering and \a filters for entry filtering. You can pass options via \a    flags to decide how the directory should be iterated.    By default, \a filters is QDir::NoFilter, and \a flags is NoIteratorFlags,    which provides the same behavior as in QDir::entryList().    \sa hasNext(), next(), IteratorFlags*/QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorFlags flags)    : d(new QDirIteratorPrivate(path, QStringList(QLatin1String("*")), filters, flags)){    d->q = this;}/*!    Constructs a QDirIterator that can iterate over \a path. You can pass    options via \a flags to decide how the directory should be iterated.    By default, \a flags is NoIteratorFlags, which provides the same behavior    as in QDir::entryList().    \sa hasNext(), next(), IteratorFlags*/QDirIterator::QDirIterator(const QString &path, IteratorFlags flags)    : d(new QDirIteratorPrivate(path, QStringList(QLatin1String("*")), QDir::NoFilter, flags)){    d->q = this;}/*!    Constructs a QDirIterator that can iterate over \a path, using \a    nameFilters and \a filters. You can pass options via \a flags to decide    how the directory should be iterated.    By default, \a flags is NoIteratorFlags, which provides the same behavior    as QDir::entryList().    \sa hasNext(), next(), IteratorFlags*/QDirIterator::QDirIterator(const QString &path, const QStringList &nameFilters,                           QDir::Filters filters, IteratorFlags flags)    : d(new QDirIteratorPrivate(path, nameFilters, filters, flags)){    d->q = this;}/*!    Destroys the QDirIterator.*/QDirIterator::~QDirIterator(){    qDeleteAll(d->fileEngineIterators);    delete d;}/*!    Advances the iterator to the next entry, and returns the file path of this    new entry. If hasNext() returns false, this function does nothing, and    returns a null QString.    You can call fileName() or filePath() to get the current entry file name    or path, or fileInfo() to get a QFileInfo for the current entry.    \sa hasNext(), fileName(), filePath(), fileInfo()*/QString QDirIterator::next(){    if (!hasNext())        return QString();    d->advance();    return filePath();}/*!    Returns true if there is at least one more entry in the directory;    otherwise, false is returned.    \sa next(), fileName(), filePath(), fileInfo()*/bool QDirIterator::hasNext() const{    if (d->first) {        d->first = false;        d->advance();        if (!d->fileEngineIterators.isEmpty())            d->currentFilePath = d->fileEngineIterators.top()->currentFilePath();    }    return !d->done;}/*!    Returns the file name for the current directory entry, without the path    prepended. If the current entry is invalid (i.e., isValid() returns    false), a null QString is returned.    This function is provided for the convenience when iterating single    directories. For recursive iteration, you should call filePath() or    fileInfo() instead.        \sa filePath(), fileInfo()*/QString QDirIterator::fileName() const{    if (d->fileInfo.path() != d->currentFilePath)        d->fileInfo.setFile(d->currentFilePath);    return d->fileInfo.fileName();}/*!    Returns the full file path for the current directory entry. If the current    entry is invalid (i.e., isValid() returns false), a null QString is    returned.    \sa fileInfo(), fileName()*/QString QDirIterator::filePath() const{    return d->currentFilePath;}/*!    Returns a QFileInfo for the current directory entry. If the current entry    is invalid (i.e., isValid() returns false), a null QFileInfo is returned.    \sa filePath(), fileName()*/QFileInfo QDirIterator::fileInfo() const{    if (d->fileInfo.filePath() != d->currentFilePath)        d->fileInfo.setFile(d->currentFilePath);    return d->fileInfo;}/*!    Returns the base directory of the iterator.*/QString QDirIterator::path() const{    return d->path;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -