]>
vaikene.ee Git - evaf/blob - src/apps/FileFinder/Engine/ifilefinder.h
2 * @file FileFinder/Engine/ifilefinder.h
3 * @brief Interface for the file finder engine
6 * Copyright (c) 2011 Enar Vaikene
8 * This file is part of the eVaf C++ cross-platform application development framework.
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
20 #ifndef __FILEFINDER_ENGINE_IFILEFINDER_H
21 # define __FILEFINDER_ENGINE_IFILEFINDER_H
27 namespace FileFinder
{
30 * File filter defining patterns for file names and contents.
32 * File name patterns are wildcards (QRegExp::WildcardUnix). Multiple patterns can be separated by comma like,
33 * for example, "*.cpp,*.h". To include a comma in the pattern, escape it with '\'.
35 * Content patterns are regular expressions (QRegExp::RegExp).
37 * A file matches the filter if:
38 * @li file name matches the includeNames pattern or the includeNames pattern is empty;
39 * @li and; file name does not match the excludeNames pattern or the excludeNames pattern is empty;
40 * @li and; file content matches the includeContent pattern or the includeContent pattern is empty;
41 * @li and; file content does not match the excludeContent pattern or the excludeContent patytern is empty.
48 Filter(QString
const & in
, QString
const & en
, QString
const & ic
, QString
const & ec
)
55 /// QRegExp expression specifying file names that are included in the search result
58 /// QRegExp expression specifying file names that are excluded from the search result
61 /// QRegExp expression specifying file content that is included in the search result
62 QString includeContent
;
64 /// QRegExp expression specifying file content that is excluded from the search result
65 QString excludeContent
;
69 * File finder interface.
71 * The iFileFinder interface is used to search for files using name and content filters.
73 class iFileFinder
: public QObject
79 /// Interface constructor
80 iFileFinder() : QObject() {}
82 /// Empty virtual destructor
83 virtual ~iFileFinder() {}
86 * Starts a file search in the directory dir using filter.
87 * @param dir Directory where to search
88 * @param recursive If True, searches also in sub-directories
89 * @param filter File name and content filter
91 * The search() function searches for files matching the given filter. The search is started
92 * in the directory dir and continues recursively into sub-directories if the recursive flag
95 * The function is non-blocking and returns immediately. Results of the search are reported
96 * with found() signals and the finished() signal indicates that the search is either finished
99 * If a new search is started before the current search is finished, then the current search is canceled.
101 virtual void search(QString
const & dir
, bool recursive
, Filter
const & filter
) = 0;
104 * Cancels an ongoing search.
106 virtual void cancel() = 0;
109 * Indicates that a search is ongoing
111 virtual bool busy() const = 0;
117 * Signal emitted for every file found during the search.
118 * @param fileName name of the file with a path relative to the search directory
119 * @param dir Search directory
121 void found(QString
const & fileName
, QString
const & dir
);
124 * Signal emitted when the search is finished
125 * @param canceled True if the search was canceled instead of finished
127 void finished(bool canceled
);
132 } // namespace eVaf::FileFinder
135 Q_DECLARE_INTERFACE(eVaf::FileFinder::iFileFinder
, "eVaf.FileFinder.iFileFinder/1.0")
137 #endif // ifilefinder.h