kaddressbook

filter.h
1/*
2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of TQt, and distribute the resulting executable,
21 without including the source code for TQt in the source distribution.
22*/
23
24#ifndef FILTER_H
25#define FILTER_H
26
27#include <tqstring.h>
28#include <tqstringlist.h>
29#include <tqvaluelist.h>
30
31#include <tdeabc/addressee.h>
32#include <tdeconfig.h>
33
39class Filter
40{
41 public:
42 typedef TQValueList<Filter> List;
43
44 enum MatchRule { Matching = 0, NotMatching = 1 };
45
46 Filter();
47 Filter( const TQString& name );
48 ~Filter();
49
53 void setName( const TQString &name );
54
58 const TQString &name() const;
59
63 bool isInternal() const;
64
72 void apply( TDEABC::Addressee::List &addresseeList );
73
80 bool filterAddressee( const TDEABC::Addressee &a ) const;
81
85 void setEnabled( bool on );
86
90 bool isEnabled() const;
91
95 void setCategories( const TQStringList &list );
96
100 const TQStringList &categories() const;
101
105 void save( TDEConfig *config );
106
110 void restore( TDEConfig *config );
111
121 static void save( TDEConfig *config, const TQString &baseGroup, Filter::List &list );
122
131 static Filter::List restore( TDEConfig *config, const TQString &baseGroup );
132
139 void setMatchRule( MatchRule rule );
140
144 MatchRule matchRule() const;
145
149 bool isEmpty() const;
150
151 private:
152 TQString mName;
153 TQStringList mCategoryList;
154 MatchRule mMatchRule;
155 bool mEnabled;
156 bool mInternal;
157 bool mIsEmpty;
158};
159
160#endif
Filter for AddressBook related objects (Addressees)
Definition: filter.h:40
MatchRule matchRule() const
Definition: filter.cpp:211
bool isEnabled() const
Definition: filter.cpp:107
bool isEmpty() const
Definition: filter.cpp:216
void setName(const TQString &name)
Set the name of the filter.
Definition: filter.cpp:47
void restore(TDEConfig *config)
Loads the filter from the config file.
Definition: filter.cpp:132
void setEnabled(bool on)
Enable or disable the filter.
Definition: filter.cpp:100
const TQStringList & categories() const
Definition: filter.cpp:119
void setCategories(const TQStringList &list)
Set the list of categories.
Definition: filter.cpp:112
bool filterAddressee(const TDEABC::Addressee &a) const
Apply the filter to the addressee.
Definition: filter.cpp:75
void save(TDEConfig *config)
Saves the filter to the config file.
Definition: filter.cpp:124
const TQString & name() const
Definition: filter.cpp:54
void apply(TDEABC::Addressee::List &addresseeList)
Apply the filter to the addressee list.
Definition: filter.cpp:64
bool isInternal() const
Definition: filter.cpp:59
void setMatchRule(MatchRule rule)
Sets the filter rule.
Definition: filter.cpp:204