From 630b7196d93786595546565329160ff26332704b Mon Sep 17 00:00:00 2001 From: tpearson Date: Fri, 12 Feb 2010 18:09:55 +0000 Subject: Added KDE3 version of kio-locate git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kio-locate@1089224 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/pattern.h | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 src/pattern.h (limited to 'src/pattern.h') diff --git a/src/pattern.h b/src/pattern.h new file mode 100644 index 0000000..8e17a69 --- /dev/null +++ b/src/pattern.h @@ -0,0 +1,114 @@ +/*************************************************************************** + * kio-locate: KDE I/O Slave for the locate command * + * * + * Copyright (C) 2005 by Tobi Vollebregt * + * tobivollebregt@gmail.com * + * * + * Thanks to Google's Summer Of Code Program! * + * * + * Copyright (C) 2004 by Armin Straub * + * linux@arminstraub.de * + * * + * This program was initially written by Michael Schuerig. * + * Although I have completely rewritten it, most ideas are adopted * + * from his original work. * + * * + * Copyright (C) 2002 by Michael Schuerig * + * michael@schuerig.de * + * * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#ifndef PATTERN_H +#define PATTERN_H + +#include +#include +#include + +/** + * Regular Expression adapted to the needs of kio-locate. + */ +class LocateRegExp +{ +public: + /** + * Constructor + * @param pattern the pattern to start with + * @param ignoreCase specifies, if the search should be case sensitive + */ + LocateRegExp(const QString& pattern, bool ignoreCase = false); + LocateRegExp(); + + virtual ~LocateRegExp(); + + /** + * Determines whether a file name is matching this regular expression. + * @param file the filename to match + */ + virtual bool isMatching(const QString& file) const; + + /** + * @return The position of the last match. + */ + virtual int getMatchPosition() const; + + /** + * @return The length of the last match. + */ + virtual int getMatchedLength() const; + + /** + * Set the pattern. + * @param pattern the pattern to search for. It may be prepended by an + * exclamation mark, to invert its meaning. + */ + virtual void setPattern(const QString& pattern); + + /** + * Get the pattern. + * @return search pattern + */ + virtual QString getPattern() const; + + private: + bool m_negated; + bool m_ignoreCase; + QRegExp m_regExp; + QString m_pattern; +}; + +/** + * List of regular expressions + */ +class LocateRegExpList: public QValueList +{ + public: + virtual ~LocateRegExpList(); + + /** + * Converts a stringlist into a regexplist. + * @param list the stringlist to convert + */ + LocateRegExpList& operator = (const QStringList& list); + + /** + * Determines whether a file name is matching at least one regular + * expression in the list. + * @param file the filename to match + */ + virtual bool isMatchingOne(const QString& file) const; + + /** + * Determines whether a file name is matching all regular expressions + * in the list. + * @param file the filename to match + */ + virtual bool isMatchingAll(const QString& file) const; +}; + +#endif -- cgit v1.2.1