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

📄 filevisitor.h

📁 QT4的utils库源码包.解压后运行./configure配置,然后make.使用时在.pro文件中加入两行:LIBS+=-L$$(CPPLIBS)-lutils及INCLUDEPATH+=$$(C
💻 H
字号:
#ifndef _FileVisitor_H_#define _FileVisitor_H_//start#include <QDir>#include <QObject>#include <QStringList>#include "myexport.h"/** @short Visitor Pattern - visits files in a directory tree, recursively or non,    performing the same operation on each file.	@author Alan Ezust sae@mcs.suffolk.edu    @version $Id: filevisitor.h 932 2008-03-07 00:43:46Z sae $  */class UTILS_EXPORT FileVisitor : public QObject {    Q_OBJECT public:    /**       @param nameFilter unix glob-style fileName filter        e.g. *.html       @param recursive if true, also process subdirectores       @param symlinks if true, also process symbolic links.    */    FileVisitor(QString nameFilter="*",                bool recursive=true, bool symlinks=false);    FileVisitor(QStringList nameFilterList,            bool recursive=true, bool symlinks = false);     public slots:    /** @short Convenience method for processing a    list of file specs.    Useful for handling command line arguments.    Calls @ref processEntry() on each file item in list.     @param sl - stringlist of files or    directories to process  */    void processFileList(QStringList sl);        /** @short processes a single directory entry    Does not care if it is a directory or a file -    does all the proper checking before calling the    appropriate function, @ref processFile() on files,    or @ref processDir() on directories.    @param pathname location of a directory or a file    */    void processEntry(QString pathname);     signals:    /** @short emitted whenever a file is found        @param filename an absolute path    */    void foundFile(QString filename); protected:    /** @short override this to customize behavior        The operation which is performed on each file    (currently, it emits @ref foundFile() on each found file).        @param filename (absolute or relative) path     of file to be processed.    */    virtual void processFile(QString filename); /* override this    */    //end    /** @short @ref processEntry(QString) is a convenience function        which calls this method.    */    void processEntry(QFileInfo finfo);    /** @short Process a directory - calls processFile on each file in the directory     */    void processDir(QString pathname);    /** @short Process a directory - calls processFile on each file in the directory.     */    void processDir(QDir& directory);      /**@short override this method if you want to skip particular directories.        @return true if dir == (CVS | . | ..)    */    virtual bool skipDir(const QDir& dir); public:    /**       @param nf  a unix glob-style wildcard for specifying       filename filters. */         void addNameFilter(QString nf);      void setFilters(QStringList filters);        void setRecursive(bool r) {        m_Recursive = r;    }        void clearFilter() {        m_filterList.clear();    }        /** @short helper Function for reading all lines from a file        in one line */    static QStringList readLines(QFile &f);    /** @short helper function for reading all lines from a file        in one line */    static QStringList readLines(QString fn);    /** expands ~ only, not ~username.      @param path a location that may contain a ~ prefix.        @return an absolute path based on path.      */    static QString expandTilde(QString path);    //start protected:    QStringList m_filterList;    bool m_Recursive;    QDir::Filters m_DirFilter;};//end#endif

⌨️ 快捷键说明

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