-rw-r--r-- | kaddressbook/filter.cpp | 24 | ||||
-rw-r--r-- | kaddressbook/filter.h | 1 |
2 files changed, 18 insertions, 7 deletions
diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp index 7a869fa..12ab1e3 100644 --- a/kaddressbook/filter.cpp +++ b/kaddressbook/filter.cpp | |||
@@ -1,228 +1,238 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 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 | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <kconfig.h> | 24 | #include <kconfig.h> |
25 | #include <kconfigbase.h> | 25 | #include <kconfigbase.h> |
26 | #include <kdebug.h> | 26 | #include <kdebug.h> |
27 | 27 | ||
28 | #include "kabprefs.h" | 28 | #include "kabprefs.h" |
29 | 29 | ||
30 | #include "filter.h" | 30 | #include "filter.h" |
31 | #include <secrecy.h> | 31 | #include <secrecy.h> |
32 | 32 | ||
33 | Filter::Filter() | 33 | Filter::Filter() |
34 | : mName( QString::null ), mMatchRule( Matching ), mEnabled( true ), | 34 | : mName( QString::null ), mMatchRule( NotMatching ), mEnabled( true ), |
35 | mInternal( false ) | 35 | mInternal( false ) |
36 | { | 36 | { |
37 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; | 37 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; |
38 | noName = true; | ||
38 | } | 39 | } |
39 | 40 | ||
40 | Filter::Filter( const QString &name ) | 41 | Filter::Filter( const QString &name ) |
41 | : mName( name ), mMatchRule( Matching ), mEnabled( true ), | 42 | : mName( name ), mMatchRule( NotMatching ), mEnabled( true ), |
42 | mInternal( false ) | 43 | mInternal( false ) |
43 | { | 44 | { |
44 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; | 45 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; |
46 | noName = false; | ||
45 | } | 47 | } |
46 | 48 | ||
47 | Filter::~Filter() | 49 | Filter::~Filter() |
48 | { | 50 | { |
49 | } | 51 | } |
50 | 52 | ||
51 | void Filter::setName( const QString &name ) | 53 | void Filter::setName( const QString &name ) |
52 | { | 54 | { |
53 | mName = name; | 55 | mName = name; |
56 | noName = false; | ||
54 | } | 57 | } |
55 | 58 | ||
56 | const QString &Filter::name() const | 59 | const QString &Filter::name() const |
57 | { | 60 | { |
58 | return mName; | 61 | return mName; |
59 | } | 62 | } |
60 | 63 | ||
61 | bool Filter::isInternal() const | 64 | bool Filter::isInternal() const |
62 | { | 65 | { |
63 | return mInternal; | 66 | return mInternal; |
64 | } | 67 | } |
65 | 68 | ||
66 | void Filter::apply( KABC::Addressee::List &addresseeList ) | 69 | void Filter::apply( KABC::Addressee::List &addresseeList ) |
67 | { | 70 | { |
71 | if ( noName ) | ||
72 | return; | ||
68 | KABC::Addressee::List::Iterator iter; | 73 | KABC::Addressee::List::Iterator iter; |
69 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ) { | 74 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ) { |
70 | if ( filterAddressee( *iter ) ) | 75 | if ( filterAddressee( *iter ) ) |
71 | ++iter; | 76 | ++iter; |
72 | else | 77 | else |
73 | { | 78 | { |
74 | #ifndef KAB_EMBEDDED | 79 | #ifndef KAB_EMBEDDED |
75 | iter = addresseeList.erase( iter ); | 80 | iter = addresseeList.erase( iter ); |
76 | #else //KAB_EMBEDDED | 81 | #else //KAB_EMBEDDED |
77 | iter = addresseeList.remove( iter ); | 82 | iter = addresseeList.remove( iter ); |
78 | #endif //KAB_EMBEDDED | 83 | #endif //KAB_EMBEDDED |
79 | } | 84 | } |
80 | } | 85 | } |
81 | } | 86 | } |
82 | 87 | ||
83 | bool Filter::filterAddressee( const KABC::Addressee &a ) | 88 | bool Filter::filterAddressee( const KABC::Addressee &a ) |
84 | { | 89 | { |
90 | |||
91 | if ( noName ) | ||
92 | return true; | ||
93 | //qDebug("Filter::filterAddressee %s",mName.latin1() ); | ||
85 | switch ( a.secrecy().type()) { | 94 | switch ( a.secrecy().type()) { |
86 | case KABC::Secrecy::Public: | 95 | case KABC::Secrecy::Public: |
87 | if (! (mCriteria & ShowPublic )) | 96 | if (! (mCriteria & ShowPublic )) |
88 | return false; | 97 | return false; |
89 | break; | 98 | break; |
90 | case KABC::Secrecy::Private: | 99 | case KABC::Secrecy::Private: |
91 | if (! (mCriteria & ShowPrivate )) | 100 | if (! (mCriteria & ShowPrivate )) |
92 | return false; | 101 | return false; |
93 | break; | 102 | break; |
94 | case KABC::Secrecy::Confidential: | 103 | case KABC::Secrecy::Confidential: |
95 | if (! (mCriteria & ShowConfidential )) | 104 | if (! (mCriteria & ShowConfidential )) |
96 | return false; | 105 | return false; |
97 | break; | 106 | break; |
98 | default: | 107 | default: |
99 | return false; | 108 | return false; |
100 | break; | 109 | break; |
101 | } | 110 | } |
102 | QStringList::Iterator iter; | 111 | QStringList::Iterator iter; |
103 | iter = mCategoryList.begin(); | 112 | iter = mCategoryList.begin(); |
104 | // empty filter always matches | ||
105 | 113 | ||
106 | if ( iter == mCategoryList.end() ) | 114 | if ( iter == mCategoryList.end() ) |
107 | return true; | 115 | return ( !(mMatchRule == Matching) ); |
108 | 116 | ||
109 | for ( ; iter != mCategoryList.end(); ++iter ) { | 117 | for ( ; iter != mCategoryList.end(); ++iter ) { |
110 | if ( a.hasCategory( *iter ) ) | 118 | if ( a.hasCategory( *iter ) ) |
111 | return ( mMatchRule == Matching ); | 119 | return ( mMatchRule == Matching ); |
112 | } | 120 | } |
113 | 121 | ||
114 | return !( mMatchRule == Matching ); | 122 | return !( mMatchRule == Matching ); |
115 | } | 123 | } |
116 | 124 | ||
117 | void Filter::setEnabled( bool on ) | 125 | void Filter::setEnabled( bool on ) |
118 | { | 126 | { |
119 | mEnabled = on; | 127 | mEnabled = on; |
120 | } | 128 | } |
121 | 129 | ||
122 | bool Filter::isEnabled() const | 130 | bool Filter::isEnabled() const |
123 | { | 131 | { |
124 | return mEnabled; | 132 | return mEnabled; |
125 | } | 133 | } |
126 | 134 | ||
127 | void Filter::setCategories( const QStringList &list ) | 135 | void Filter::setCategories( const QStringList &list ) |
128 | { | 136 | { |
129 | mCategoryList = list; | 137 | mCategoryList = list; |
130 | } | 138 | } |
131 | 139 | ||
132 | const QStringList &Filter::categories() const | 140 | const QStringList &Filter::categories() const |
133 | { | 141 | { |
134 | return mCategoryList; | 142 | return mCategoryList; |
135 | } | 143 | } |
136 | 144 | ||
137 | void Filter::save( KConfig *config ) | 145 | void Filter::save( KConfig *config ) |
138 | { | 146 | { |
139 | config->writeEntry( "Name", mName ); | 147 | config->writeEntry( "Name", mName ); |
140 | config->writeEntry( "Enabled", mEnabled ); | 148 | config->writeEntry( "Enabled", mEnabled ); |
141 | config->writeEntry( "Categories", mCategoryList ); | 149 | config->writeEntry( "Categories", mCategoryList ); |
142 | config->writeEntry( "MatchRule", (int)mMatchRule ); | 150 | config->writeEntry( "MatchRule", (int)mMatchRule ); |
143 | config->writeEntry( "Criteria", (int)mCriteria ); | 151 | config->writeEntry( "Criteria", (int)mCriteria ); |
144 | } | 152 | } |
145 | 153 | ||
146 | void Filter::restore( KConfig *config ) | 154 | void Filter::restore( KConfig *config ) |
147 | { | 155 | { |
156 | noName = false; | ||
148 | mName = config->readEntry( "Name", "<internal error>" ); | 157 | mName = config->readEntry( "Name", "<internal error>" ); |
149 | mEnabled = config->readBoolEntry( "Enabled", true ); | 158 | mEnabled = config->readBoolEntry( "Enabled", true ); |
150 | mCategoryList = config->readListEntry( "Categories" ); | 159 | mCategoryList = config->readListEntry( "Categories" ); |
151 | mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); | 160 | mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); |
152 | mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential ) ); | 161 | mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential ) ); |
153 | } | 162 | } |
154 | 163 | ||
155 | void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) | 164 | void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) |
156 | { | 165 | { |
157 | { | 166 | { |
158 | KConfigGroupSaver s( config, baseGroup ); | 167 | KConfigGroupSaver s( config, baseGroup ); |
159 | 168 | ||
160 | // remove the old filters | 169 | // remove the old filters |
161 | uint count = config->readNumEntry( "Count" ); | 170 | uint count = config->readNumEntry( "Count" ); |
162 | /* // memory access violation here | 171 | /* // memory access violation here |
163 | for ( uint i = 0; i < count; ++i ) | 172 | for ( uint i = 0; i < count; ++i ) |
164 | config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); | 173 | config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); |
165 | */ | 174 | */ |
166 | } | 175 | } |
167 | 176 | ||
168 | int index = 0; | 177 | int index = 0; |
169 | Filter::List::Iterator iter; | 178 | Filter::List::Iterator iter; |
170 | for ( iter = list.begin(); iter != list.end(); ++iter ) { | 179 | for ( iter = list.begin(); iter != list.end(); ++iter ) { |
171 | if ( !(*iter).mInternal ) { | 180 | if ( !(*iter).mInternal ) { |
172 | KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) ); | 181 | KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) ); |
173 | 182 | ||
174 | (*iter).save( config ); | 183 | (*iter).save( config ); |
175 | index++; | 184 | index++; |
176 | } | 185 | } |
177 | } | 186 | } |
178 | 187 | ||
179 | KConfigGroupSaver s( config, baseGroup ); | 188 | KConfigGroupSaver s( config, baseGroup ); |
180 | 189 | ||
181 | config->writeEntry( "Count", index ); | 190 | config->writeEntry( "Count", index ); |
182 | 191 | ||
183 | } | 192 | } |
184 | 193 | ||
185 | Filter::List Filter::restore( KConfig *config, QString baseGroup ) | 194 | Filter::List Filter::restore( KConfig *config, QString baseGroup ) |
186 | { | 195 | { |
187 | Filter::List list; | 196 | Filter::List list; |
188 | int count = 0; | 197 | int count = 0; |
189 | Filter f; | 198 | Filter f; |
190 | 199 | ||
191 | { | 200 | { |
192 | KConfigGroupSaver s( config, baseGroup ); | 201 | KConfigGroupSaver s( config, baseGroup ); |
193 | count = config->readNumEntry( "Count", 0 ); | 202 | count = config->readNumEntry( "Count", 0 ); |
194 | } | 203 | } |
195 | 204 | ||
196 | for ( int i = 0; i < count; i++ ) { | 205 | for ( int i = 0; i < count; i++ ) { |
197 | { | 206 | { |
198 | KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); | 207 | KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); |
199 | f.restore( config ); | 208 | f.restore( config ); |
200 | } | 209 | } |
201 | 210 | ||
202 | list.append( f ); | 211 | list.append( f ); |
203 | } | 212 | } |
204 | 213 | ||
205 | if ( list.isEmpty()) { | 214 | if ( list.isEmpty()) { |
206 | QStringList cats = KABPrefs::instance()->mCustomCategories; | 215 | QStringList cats = KABPrefs::instance()->mCustomCategories; |
207 | for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { | 216 | for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { |
208 | Filter filter; | 217 | Filter filter; |
218 | filter.noName = false; | ||
209 | filter.mName = *it; | 219 | filter.mName = *it; |
210 | filter.mEnabled = true; | 220 | filter.mEnabled = true; |
211 | filter.mCategoryList = *it; | 221 | filter.mCategoryList = *it; |
212 | filter.mMatchRule = Matching; | 222 | filter.mMatchRule = Matching; |
213 | filter.mInternal = true; | 223 | filter.mInternal = true; |
214 | list.append( filter ); | 224 | list.append( filter ); |
215 | } | 225 | } |
216 | } | 226 | } |
217 | return list; | 227 | return list; |
218 | } | 228 | } |
219 | 229 | ||
220 | void Filter::setMatchRule( MatchRule rule ) | 230 | void Filter::setMatchRule( MatchRule rule ) |
221 | { | 231 | { |
222 | mMatchRule = rule; | 232 | mMatchRule = rule; |
223 | } | 233 | } |
224 | 234 | ||
225 | Filter::MatchRule Filter::matchRule() const | 235 | Filter::MatchRule Filter::matchRule() const |
226 | { | 236 | { |
227 | return mMatchRule; | 237 | return mMatchRule; |
228 | } | 238 | } |
diff --git a/kaddressbook/filter.h b/kaddressbook/filter.h index 93f1352..f4ae123 100644 --- a/kaddressbook/filter.h +++ b/kaddressbook/filter.h | |||
@@ -1,157 +1,158 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 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 | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef FILTER_H | 24 | #ifndef FILTER_H |
25 | #define FILTER_H | 25 | #define FILTER_H |
26 | 26 | ||
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qvaluelist.h> | 29 | #include <qvaluelist.h> |
30 | 30 | ||
31 | #include <kabc/addressee.h> | 31 | #include <kabc/addressee.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | 33 | ||
34 | /** | 34 | /** |
35 | Filter for AddressBook related objects (Addressees) | 35 | Filter for AddressBook related objects (Addressees) |
36 | 36 | ||
37 | @todo This class should be switched to use shared data. | 37 | @todo This class should be switched to use shared data. |
38 | */ | 38 | */ |
39 | class Filter | 39 | class Filter |
40 | { | 40 | { |
41 | public: | 41 | public: |
42 | enum { ShowPublic = 1, ShowPrivate = 2, ShowConfidential = 4 }; | 42 | enum { ShowPublic = 1, ShowPrivate = 2, ShowConfidential = 4 }; |
43 | void setCriteria(int c) { mCriteria = c ;} | 43 | void setCriteria(int c) { mCriteria = c ;} |
44 | int criteria() const { return mCriteria;} | 44 | int criteria() const { return mCriteria;} |
45 | typedef QValueList<Filter> List; | 45 | typedef QValueList<Filter> List; |
46 | 46 | ||
47 | enum MatchRule { Matching = 0, NotMatching = 1 }; | 47 | enum MatchRule { Matching = 0, NotMatching = 1 }; |
48 | 48 | ||
49 | Filter(); | 49 | Filter(); |
50 | Filter( const QString& name ); | 50 | Filter( const QString& name ); |
51 | ~Filter(); | 51 | ~Filter(); |
52 | 52 | ||
53 | /** | 53 | /** |
54 | Set the name of the filter. | 54 | Set the name of the filter. |
55 | */ | 55 | */ |
56 | void setName( const QString &name ); | 56 | void setName( const QString &name ); |
57 | 57 | ||
58 | /** | 58 | /** |
59 | @return The name of the filter. | 59 | @return The name of the filter. |
60 | */ | 60 | */ |
61 | const QString &name() const; | 61 | const QString &name() const; |
62 | 62 | ||
63 | /** | 63 | /** |
64 | @return Whether the filter is an internal one. | 64 | @return Whether the filter is an internal one. |
65 | */ | 65 | */ |
66 | bool isInternal() const; | 66 | bool isInternal() const; |
67 | 67 | ||
68 | /** | 68 | /** |
69 | Apply the filter to the addressee list. All addressees not passing | 69 | Apply the filter to the addressee list. All addressees not passing |
70 | the filter criterias will be removed from the list. | 70 | the filter criterias will be removed from the list. |
71 | 71 | ||
72 | If the MatchRule is NotMatch, then all the addressees matching the | 72 | If the MatchRule is NotMatch, then all the addressees matching the |
73 | filter will be removed from the list. | 73 | filter will be removed from the list. |
74 | */ | 74 | */ |
75 | void apply( KABC::Addressee::List &addresseeList ); | 75 | void apply( KABC::Addressee::List &addresseeList ); |
76 | 76 | ||
77 | /** | 77 | /** |
78 | Apply the filter to the addressee. | 78 | Apply the filter to the addressee. |
79 | 79 | ||
80 | @return True if the addressee passes the criteria, false otherwise. | 80 | @return True if the addressee passes the criteria, false otherwise. |
81 | The return values are opposite if the MatchRule is NotMatch. | 81 | The return values are opposite if the MatchRule is NotMatch. |
82 | */ | 82 | */ |
83 | bool filterAddressee( const KABC::Addressee &a ); | 83 | bool filterAddressee( const KABC::Addressee &a ); |
84 | 84 | ||
85 | /** | 85 | /** |
86 | Enable or disable the filter | 86 | Enable or disable the filter |
87 | */ | 87 | */ |
88 | void setEnabled( bool on ); | 88 | void setEnabled( bool on ); |
89 | 89 | ||
90 | /** | 90 | /** |
91 | @return True if this filter is enabled, false otherwise. | 91 | @return True if this filter is enabled, false otherwise. |
92 | */ | 92 | */ |
93 | bool isEnabled() const; | 93 | bool isEnabled() const; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | Set the list of categories. This list is used to filter addressees. | 96 | Set the list of categories. This list is used to filter addressees. |
97 | */ | 97 | */ |
98 | void setCategories( const QStringList &list ); | 98 | void setCategories( const QStringList &list ); |
99 | 99 | ||
100 | /** | 100 | /** |
101 | @return The list of categories. | 101 | @return The list of categories. |
102 | */ | 102 | */ |
103 | const QStringList &categories() const; | 103 | const QStringList &categories() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Saves the filter to the config file. The group should already be set. | 106 | Saves the filter to the config file. The group should already be set. |
107 | */ | 107 | */ |
108 | void save( KConfig *config ); | 108 | void save( KConfig *config ); |
109 | 109 | ||
110 | /** | 110 | /** |
111 | Loads the filter from the config file. The group should already be set. | 111 | Loads the filter from the config file. The group should already be set. |
112 | */ | 112 | */ |
113 | void restore( KConfig *config ); | 113 | void restore( KConfig *config ); |
114 | 114 | ||
115 | /** | 115 | /** |
116 | Saves a list of filters to the config file. | 116 | Saves a list of filters to the config file. |
117 | 117 | ||
118 | @param config The config file to use | 118 | @param config The config file to use |
119 | @param baseGroup The base groupname to use. The number of filters | 119 | @param baseGroup The base groupname to use. The number of filters |
120 | will be written to this group, then a _1, _2, etc | 120 | will be written to this group, then a _1, _2, etc |
121 | will be append for each filter saved. | 121 | will be append for each filter saved. |
122 | @param list The list of filters to be saved. | 122 | @param list The list of filters to be saved. |
123 | */ | 123 | */ |
124 | static void save( KConfig *config, QString baseGroup, Filter::List &list ); | 124 | static void save( KConfig *config, QString baseGroup, Filter::List &list ); |
125 | 125 | ||
126 | /** | 126 | /** |
127 | Restores a list of filters from a config file. | 127 | Restores a list of filters from a config file. |
128 | 128 | ||
129 | @param config The config file to read from. | 129 | @param config The config file to read from. |
130 | @param baseGroup The base group name to be used to find the filters | 130 | @param baseGroup The base group name to be used to find the filters |
131 | 131 | ||
132 | @return The list of filters. | 132 | @return The list of filters. |
133 | */ | 133 | */ |
134 | static Filter::List restore( KConfig *config, QString baseGroup ); | 134 | static Filter::List restore( KConfig *config, QString baseGroup ); |
135 | 135 | ||
136 | /** | 136 | /** |
137 | Sets the filter rule. If the rule is Filter::Matching (default), | 137 | Sets the filter rule. If the rule is Filter::Matching (default), |
138 | then the filter will return true on items that match the filter. | 138 | then the filter will return true on items that match the filter. |
139 | If the rule is Filter::NotMatching, then the filter will return | 139 | If the rule is Filter::NotMatching, then the filter will return |
140 | true on items that do not match the filter. | 140 | true on items that do not match the filter. |
141 | */ | 141 | */ |
142 | void setMatchRule( MatchRule rule ); | 142 | void setMatchRule( MatchRule rule ); |
143 | 143 | ||
144 | /** @return The current match rule. | 144 | /** @return The current match rule. |
145 | */ | 145 | */ |
146 | MatchRule matchRule() const; | 146 | MatchRule matchRule() const; |
147 | 147 | ||
148 | private: | 148 | private: |
149 | bool noName; | ||
149 | int mCriteria; | 150 | int mCriteria; |
150 | QString mName; | 151 | QString mName; |
151 | QStringList mCategoryList; | 152 | QStringList mCategoryList; |
152 | MatchRule mMatchRule; | 153 | MatchRule mMatchRule; |
153 | bool mEnabled; | 154 | bool mEnabled; |
154 | bool mInternal; | 155 | bool mInternal; |
155 | }; | 156 | }; |
156 | 157 | ||
157 | #endif | 158 | #endif |