Cppcheck
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Attributes
FileList Class Reference

A class for listing files and directories to check. More...

#include <filelist.h>

List of all members.

Public Member Functions

void AddFile (const QString &filepath)
 Add filename to the list.
void AddDirectory (const QString &directory, bool recursive=false)
 Add files in the directory to the list.
void AddPathList (const QStringList &paths)
 Add list of filenames and directories to the list.
QStringList GetFileList () const
 Return list of filenames (to check).
void AddExcludeList (const QStringList &paths)
 Add list of paths to exclusion list.

Protected Member Functions

QStringList ApplyExcludeList () const
 Get filtered list of paths.
bool Match (const QString &path) const
 Test if path matches any of the exclude filters.

Static Protected Member Functions

static QStringList GetDefaultFilters ()
 Return list of default filename extensions included.
static bool FilterMatches (const QFileInfo &inf)
 Test if filename matches the filename extensions filtering.

Private Attributes

QFileInfoList mFileList
QStringList mExcludedPaths

Detailed Description

A class for listing files and directories to check.

This class creates a list of files to check. If directory name is given then all files in the directory matching the filter will be added. The directory can be also added recursively when all files in subdirectories are added too. The filenames are matched against the filter and only those files whose filename extension is included in the filter list are added.

This class also handles filtering of paths against ignore filters given. If there is ignore filters then only paths not matching those filters are returned.

Definition at line 37 of file filelist.h.


Member Function Documentation

void FileList::AddDirectory ( const QString &  directory,
bool  recursive = false 
)

Add files in the directory to the list.

Parameters:
directoryFull pathname to directory to add.
recursiveIf true also files in subdirectories are added.

Definition at line 51 of file filelist.cpp.

References GetDefaultFilters(), and mFileList.

Referenced by AddPathList().

void FileList::AddExcludeList ( const QStringList &  paths)

Add list of paths to exclusion list.

Parameters:
pathsPaths to exclude.

Definition at line 104 of file filelist.cpp.

References mExcludedPaths.

Referenced by MainWindow::DoCheckFiles().

void FileList::AddFile ( const QString &  filepath)

Add filename to the list.

Parameters:
filepathFull path to the file.

Definition at line 44 of file filelist.cpp.

References FilterMatches(), and mFileList.

Referenced by AddPathList().

void FileList::AddPathList ( const QStringList &  paths)

Add list of filenames and directories to the list.

Parameters:
pathsList of paths to add.

Definition at line 78 of file filelist.cpp.

References AddDirectory(), and AddFile().

Referenced by MainWindow::DoCheckFiles().

QStringList FileList::ApplyExcludeList ( ) const [protected]

Get filtered list of paths.

This method takes the list of paths and applies the exclude lists to it. And then returns the list of paths that did not match the exclude filters.

Returns:
Filtered list of paths.

Definition at line 109 of file filelist.cpp.

References Match(), and mFileList.

Referenced by GetFileList().

bool FileList::FilterMatches ( const QFileInfo &  inf) [static, protected]

Test if filename matches the filename extensions filtering.

Returns:
true if filename matches filtering.

Definition at line 32 of file filelist.cpp.

References GetDefaultFilters().

Referenced by AddFile().

QStringList FileList::GetDefaultFilters ( ) [static, protected]

Return list of default filename extensions included.

Returns:
list of default filename extensions included.

Definition at line 25 of file filelist.cpp.

Referenced by AddDirectory(), and FilterMatches().

QStringList FileList::GetFileList ( ) const

Return list of filenames (to check).

Returns:
list of filenames to check.

Definition at line 90 of file filelist.cpp.

References ApplyExcludeList(), mExcludedPaths, and mFileList.

Referenced by MainWindow::DoCheckFiles().

bool FileList::Match ( const QString &  path) const [protected]

Test if path matches any of the exclude filters.

Parameters:
pathPath to test against exclude filters.
Returns:
true if any of the filters matches, false otherwise.

Definition at line 120 of file filelist.cpp.

References mExcludedPaths.

Referenced by ApplyExcludeList().


Member Data Documentation

QStringList FileList::mExcludedPaths [private]

Definition at line 103 of file filelist.h.

Referenced by AddExcludeList(), GetFileList(), and Match().

QFileInfoList FileList::mFileList [private]

Definition at line 102 of file filelist.h.

Referenced by AddDirectory(), AddFile(), ApplyExcludeList(), and GetFileList().


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