kfilefilter.h
00001 /* This file is part of the KDE libraries 00002 00003 Copyright (c) 2001,2002 Carsten Pfeiffer <pfeiffer@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License (LGPL) as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KFILEFILTER_H 00022 #define KFILEFILTER_H 00023 00024 #include <tqptrlist.h> 00025 #include <tqstringlist.h> 00026 00027 #include <sys/types.h> 00028 #include <sys/stat.h> 00029 #include <unistd.h> 00030 00031 #include <kdelibs_export.h> 00032 00033 class TQRegExp; 00034 class KFileItem; 00035 00041 class KIO_EXPORT KFileFilter 00042 { 00043 public: 00049 virtual bool passesFilter( const KFileItem *item ) const = 0; 00050 protected: 00051 virtual void virtual_hook( int id, void* data ); 00052 }; 00053 00059 class KIO_EXPORT KSimpleFileFilter : public KFileFilter 00060 { 00061 public: 00066 KSimpleFileFilter(); 00067 virtual ~KSimpleFileFilter(); 00068 00076 virtual void setFilterDotFiles( bool filter ); 00083 bool filterDotFiles() const { return m_filterDotFiles; } 00084 00089 virtual void setFilterSpecials( bool filter ); 00094 bool filterSpecials() const { return m_filterSpecials; } 00095 00096 // ### KDE4 make virtual and bool caseSensitive = false 00108 void setNameFilters( const TQString& nameFilters, bool caseSensitive, 00109 const TQChar& separator = ' ' ); 00117 virtual void setNameFilters( const TQString& nameFilters ); 00118 00125 virtual void setMimeFilters( const TQStringList& mimeFilters ); 00131 TQStringList mimeFilters() const { return m_mimeFilters; } 00132 00141 virtual void setModeFilter( mode_t mode ); 00147 mode_t modeFilter() const { return m_modeFilter; } 00148 00154 virtual bool passesFilter( const KFileItem *item ) const; 00155 00156 protected: 00157 TQPtrList<TQRegExp> m_nameFilters; 00158 00159 private: 00160 TQStringList m_mimeFilters; 00161 bool m_filterDotFiles :1; 00162 bool m_filterSpecials :1; 00163 mode_t m_modeFilter; 00164 protected: 00165 virtual void virtual_hook( int id, void* data ); 00166 private: 00167 class KSimpleFileFilterPrivate* d; 00168 }; 00169 00170 #endif // KFILEFILTER_H