--- /dev/null
+/**
+ * @file FileFinder/Engine/ifilefinder.h
+ * @brief Interface for the file finder engine
+ * @author Enar Vaikene
+ *
+ * Copyright (c) 2011 Enar Vaikene
+ *
+ * This file is part of the eVaf C++ cross-platform application development framework.
+ *
+ * This file can be used under the terms of the GNU General Public License
+ * version 3.0 as published by the Free Software Foundation and appearing in
+ * the file LICENSE included in the packaging of this file. Please review the
+ * the following information to ensure the GNU General Public License version
+ * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * Alternatively, this file may be used in accordance with the Commercial License
+ * Agreement provided with the Software.
+ */
+
+#ifndef __FILEFINDER_ENGINE_IFILEFINDER_H
+# define __FILEFINDER_ENGINE_IFILEFINDER_H
+
+#include <QObject>
+#include <QString>
+
+namespace eVaf {
+namespace FileFinder {
+
+/**
+ * File filter defining patterns for file names and contents.
+ *
+ * File name patterns are wildcards (QRegExp::WildcardUnix). Multiple patterns can be separated by comma like,
+ * for example, "*.cpp,*.h". To include a comma in the pattern, escape it with '\'.
+ *
+ * Content patterns are regular expressions (QRegExp::RegExp).
+ *
+ * A file matches the filter if:
+ * @li file name matches the includeNames pattern or the includeNames pattern is empty;
+ * @li and; file name does not match the excludeNames pattern or the excludeNames pattern is empty;
+ * @li and; file content matches the includeContent pattern or the includeContent pattern is empty;
+ * @li and; file content does not match the excludeContent pattern or the excludeContent patytern is empty.
+ */
+struct Filter
+{
+ Filter()
+ {}
+
+ Filter(QString const & in, QString const & en, QString const & ic, QString const & ec)
+ : includeNames(in)
+ , excludeNames(en)
+ , includeContent(ic)
+ , excludeContent(ec)
+ {}
+
+ /// QRegExp expression specifying file names that are included in the search result
+ QString includeNames;
+
+ /// QRegExp expression specifying file names that are excluded from the search result
+ QString excludeNames;
+
+ /// QRegExp expression specifying file content that is included in the search result
+ QString includeContent;
+
+ /// QRegExp expression specifying file content that is excluded from the search result
+ QString excludeContent;
+};
+
+/**
+ * File finder interface.
+ *
+ * The iFileFinder interface is used to search for files using name and content filters.
+ */
+class iFileFinder : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ /// Interface constructor
+ iFileFinder() : QObject() {}
+
+ /// Empty virtual destructor
+ virtual ~iFileFinder() {}
+
+ /**
+ * Starts a file search in the directory dir using filter.
+ * @param dir Directory where to search
+ * @param recursive If True, searches also in sub-directories
+ * @param filter File name and content filter
+ *
+ * The search() function searches for files matching the given filter. The search is started
+ * in the directory dir and continues recursively into sub-directories if the recursive flag
+ * is set to true.
+ *
+ * The function is non-blocking and returns immediately. Results of the search are reported
+ * with found() signals and the finished() signal indicates that the search is either finished
+ * or canceled.
+ *
+ * If a new search is started before the current search is finished, then the current search is canceled.
+ */
+ virtual void search(QString const & dir, bool recursive, Filter const & filter) = 0;
+
+ /**
+ * Cancels an ongoing search.
+ */
+ virtual void cancel() = 0;
+
+ /**
+ * Indicates that a search is ongoing
+ */
+ virtual bool busy() const = 0;
+
+
+signals:
+
+ /**
+ * Signal emitted for every file found during the search.
+ * @param fileName name of the file with a path relative to the search directory
+ * @param dir Search directory
+ */
+ void found(QString const & fileName, QString const & dir);
+
+ /**
+ * Signal emitted when the search is finished
+ * @param canceled True if the search was canceled instead of finished
+ */
+ void finished(bool canceled);
+
+};
+
+
+} // namespace eVaf::FileFinder
+} // namespace eVaf
+
+Q_DECLARE_INTERFACE(eVaf::FileFinder::iFileFinder, "eVaf.FileFinder.iFileFinder/1.0")
+
+#endif // ifilefinder.h