kaddressbook

filter.h

00001 /*
00002     This file is part of KAddressBook.
00003     Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program 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
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018 
00019     As a special exception, permission is given to link this program
00020     with any edition of Qt, and distribute the resulting executable,
00021     without including the source code for Qt in the source distribution.
00022 */
00023 
00024 #ifndef FILTER_H
00025 #define FILTER_H
00026 
00027 #include <qstring.h>
00028 #include <qstringlist.h>
00029 #include <qvaluelist.h>
00030 
00031 #include <kabc/addressee.h>
00032 #include <kconfig.h>
00033 
00039 class Filter
00040 {
00041   public:
00042     typedef QValueList<Filter> List;
00043 
00044     enum MatchRule { Matching = 0, NotMatching = 1 };
00045 
00046     Filter();
00047     Filter( const QString& name );
00048     ~Filter();
00049 
00053     void setName( const QString &name );
00054 
00058     const QString &name() const;
00059 
00063     bool isInternal() const;
00064 
00072     void apply( KABC::Addressee::List &addresseeList );
00073 
00080     bool filterAddressee( const KABC::Addressee &a ) const;
00081 
00085     void setEnabled( bool on );
00086 
00090     bool isEnabled() const;
00091 
00095     void setCategories( const QStringList &list );
00096 
00100     const QStringList &categories() const;
00101 
00105     void save( KConfig *config );
00106 
00110     void restore( KConfig *config );
00111 
00121     static void save( KConfig *config, const QString &baseGroup, Filter::List &list );
00122 
00131     static Filter::List restore( KConfig *config, const QString &baseGroup );
00132 
00139     void setMatchRule( MatchRule rule );
00140 
00144     MatchRule matchRule() const;
00145 
00149     bool isEmpty() const;
00150 
00151   private:
00152     QString mName;
00153     QStringList mCategoryList;
00154     MatchRule mMatchRule;
00155     bool mEnabled;
00156     bool mInternal;
00157     bool mIsEmpty;
00158 };
00159 
00160 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys