diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-01-27 01:04:16 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-01-27 01:04:16 -0600 |
commit | 5159cd2beb2e87806a5b54e9991b7895285c9d3e (patch) | |
tree | 9b70e8be47a390f8f4d56ead812ab0c9dad88709 /tdeio/tdeio/tdefilefilter.h | |
parent | c17cb900dcf52b8bd6dc300d4f103392900ec2b4 (diff) | |
download | tdelibs-5159cd2beb2e87806a5b54e9991b7895285c9d3e.tar.gz tdelibs-5159cd2beb2e87806a5b54e9991b7895285c9d3e.zip |
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdeio/tdeio/tdefilefilter.h')
-rw-r--r-- | tdeio/tdeio/tdefilefilter.h | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/tdeio/tdeio/tdefilefilter.h b/tdeio/tdeio/tdefilefilter.h new file mode 100644 index 000000000..2891e800e --- /dev/null +++ b/tdeio/tdeio/tdefilefilter.h @@ -0,0 +1,170 @@ +/* This file is part of the KDE libraries + + Copyright (c) 2001,2002 Carsten Pfeiffer <pfeiffer@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License (LGPL) as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KFILEFILTER_H +#define KFILEFILTER_H + +#include <tqptrlist.h> +#include <tqstringlist.h> + +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +#include <tdelibs_export.h> + +class TQRegExp; +class KFileItem; + +/** + * A KFileFilter is a simple base class for file filters. Just + * reimplement passesFilter(). + * @short Base class for file filters. + */ +class TDEIO_EXPORT KFileFilter +{ +public: + /** + * Checks the given @p item. + * @param item the item to filter + * @return true if the @p item passes the filter, false otherwise + */ + virtual bool passesFilter( const KFileItem *item ) const = 0; +protected: + virtual void virtual_hook( int id, void* data ); +}; + +/** + * A simple file filter that can filter hidden dot files, by name, + * by mime type and by mode. + * @short A simple file filter. + */ +class TDEIO_EXPORT KSimpleFileFilter : public KFileFilter +{ +public: + /** + * Creates a new filter. By default, it filters only hidden dot files + * and "." and "..". + */ + KSimpleFileFilter(); + virtual ~KSimpleFileFilter(); + + /** + * Enable or disable filtering hidden dot files. + * This option is enabled by default. + * @param filter true to enable filtering dot files, false to + * disable + * @see filterDotFiles + */ + virtual void setFilterDotFiles( bool filter ); + /** + * Checks whether filtering dot files is enabled. + * This option is enabled by default. + * @return true if filtering is enabled, false otherwise + * @see setFilterDotFiles + */ + bool filterDotFiles() const { return m_filterDotFiles; } + + /** + * Filters "." and "..", default is true. + * @param filter true to enable, false otherwise + */ + virtual void setFilterSpecials( bool filter ); + /** + * Checks whether it filters "." and "..", default is true. + * @return true if enabled, false otherwise + */ + bool filterSpecials() const { return m_filterSpecials; } + + // ### KDE4 make virtual and bool caseSensitive = false + /** + * Sets a list of regular expressions to filter by name. + * The file will only pass if its name matches one of the regular + * expressions. + * @param nameFilters a list of regular expressions, separated by + * the character @p separator + * @param caseSensitive if true, matches case sensitive. False + * otherwise + * @param separator the separator in the @p nameFilter + * @since 3.1 + */ + void setNameFilters( const TQString& nameFilters, bool caseSensitive, + const TQChar& separator = ' ' ); + /** + * Sets a list of regular expressions to filter by name. + * The file will only pass if its name matches one of the regular + * expressions. + * @param nameFilters a list of regular expressions, separated by + * space (' ') + */ + virtual void setNameFilters( const TQString& nameFilters ); + + /** + * Sets a list of mime filters. A file can only pass if its + * mime type is contained in this list. + * @param mimeFilters the list of mime types + * @see setMimeFilter + */ + virtual void setMimeFilters( const TQStringList& mimeFilters ); + /** + * Returns the list of mime types. + * @return the list of mime types + * @see mimeFilter + */ + TQStringList mimeFilters() const { return m_mimeFilters; } + + /** + * Sets the mode filter. If the @p mode is 0, the filter is + * disabled. + * When enabled, a file will only pass if the files mode + * ANDed with @p mode is not zero. + * @param mode the new mode. 0 to disable + * @see modeFilter + */ + virtual void setModeFilter( mode_t mode ); + /** + * Returns the mode filter, as set by setModeFilter(). + * @return the mode filter, 0 if disabled + * @see setModeFilter + */ + mode_t modeFilter() const { return m_modeFilter; } + + /** + * Checks the given @p item. + * @param item the item to filter + * @return true if the @p item passes the filter, false otherwise + */ + virtual bool passesFilter( const KFileItem *item ) const; + +protected: + TQPtrList<TQRegExp> m_nameFilters; + +private: + TQStringList m_mimeFilters; + bool m_filterDotFiles :1; + bool m_filterSpecials :1; + mode_t m_modeFilter; +protected: + virtual void virtual_hook( int id, void* data ); +private: + class KSimpleFileFilterPrivate* d; +}; + +#endif // KFILEFILTER_H |