summaryrefslogtreecommitdiffabout
path: root/kaddressbook/filter.cpp
Unidiff
Diffstat (limited to 'kaddressbook/filter.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/filter.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp
index 12ab1e3..6462310 100644
--- a/kaddressbook/filter.cpp
+++ b/kaddressbook/filter.cpp
@@ -125,114 +125,114 @@ bool Filter::filterAddressee( const KABC::Addressee &a )
125void Filter::setEnabled( bool on ) 125void Filter::setEnabled( bool on )
126{ 126{
127 mEnabled = on; 127 mEnabled = on;
128} 128}
129 129
130bool Filter::isEnabled() const 130bool Filter::isEnabled() const
131{ 131{
132 return mEnabled; 132 return mEnabled;
133} 133}
134 134
135void Filter::setCategories( const QStringList &list ) 135void Filter::setCategories( const QStringList &list )
136{ 136{
137 mCategoryList = list; 137 mCategoryList = list;
138} 138}
139 139
140const QStringList &Filter::categories() const 140const QStringList &Filter::categories() const
141{ 141{
142 return mCategoryList; 142 return mCategoryList;
143} 143}
144 144
145void Filter::save( KConfig *config ) 145void Filter::save( KConfig *config )
146{ 146{
147 config->writeEntry( "Name", mName ); 147 config->writeEntry( "Name", mName );
148 config->writeEntry( "Enabled", mEnabled ); 148 config->writeEntry( "Enabled", mEnabled );
149 config->writeEntry( "Categories", mCategoryList ); 149 config->writeEntry( "Categories", mCategoryList );
150 config->writeEntry( "MatchRule", (int)mMatchRule ); 150 config->writeEntry( "MatchRule", (int)mMatchRule );
151 config->writeEntry( "Criteria", (int)mCriteria ); 151 config->writeEntry( "Criteria", (int)mCriteria );
152} 152}
153 153
154void Filter::restore( KConfig *config ) 154void Filter::restore( KConfig *config )
155{ 155{
156 noName = false; 156 noName = false;
157 mName = config->readEntry( "Name", "<internal error>" ); 157 mName = config->readEntry( "Name", "<internal error>" );
158 mEnabled = config->readBoolEntry( "Enabled", true ); 158 mEnabled = config->readBoolEntry( "Enabled", true );
159 mCategoryList = config->readListEntry( "Categories" ); 159 mCategoryList = config->readListEntry( "Categories" );
160 mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); 160 mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching );
161 mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential ) ); 161 mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential ) );
162} 162}
163 163
164void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) 164void Filter::save( KConfig *config, QString baseGroup, Filter::List &list )
165{ 165{
166 { 166 {
167 KConfigGroupSaver s( config, baseGroup ); 167 KConfigGroupSaver s( config, baseGroup );
168 168
169 // remove the old filters 169 // remove the old filters
170 uint count = config->readNumEntry( "Count" ); 170 uint count = config->readNumEntry( "Count" );
171 /* // memory access violation here 171 /* // memory access violation here
172 for ( uint i = 0; i < count; ++i ) 172 for ( uint i = 0; i < count; ++i )
173 config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); 173 config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) );
174 */ 174 */
175 } 175 }
176 176
177 int index = 0; 177 int index = 0;
178 Filter::List::Iterator iter; 178 Filter::List::Iterator iter;
179 for ( iter = list.begin(); iter != list.end(); ++iter ) { 179 for ( iter = list.begin(); iter != list.end(); ++iter ) {
180 if ( !(*iter).mInternal ) { 180 if ( !(*iter).mInternal ) {
181 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) ); 181 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) );
182 182
183 (*iter).save( config ); 183 (*iter).save( config );
184 index++; 184 index++;
185 } 185 }
186 } 186 }
187 187
188 KConfigGroupSaver s( config, baseGroup ); 188 KConfigGroupSaver s( config, baseGroup );
189 189
190 config->writeEntry( "Count", index ); 190 config->writeEntry( "Count", index );
191 191
192} 192}
193 193
194Filter::List Filter::restore( KConfig *config, QString baseGroup ) 194Filter::List Filter::restore( KConfig *config, QString baseGroup )
195{ 195{
196 Filter::List list; 196 Filter::List list;
197 int count = 0; 197 int count = 0;
198 Filter f; 198 Filter f;
199 199
200 { 200 {
201 KConfigGroupSaver s( config, baseGroup ); 201 KConfigGroupSaver s( config, baseGroup );
202 count = config->readNumEntry( "Count", 0 ); 202 count = config->readNumEntry( "Count", 0 );
203 } 203 }
204 204
205 for ( int i = 0; i < count; i++ ) { 205 for ( int i = 0; i < count; i++ ) {
206 { 206 {
207 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); 207 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) );
208 f.restore( config ); 208 f.restore( config );
209 } 209 }
210 210
211 list.append( f ); 211 list.append( f );
212 } 212 }
213 213
214 if ( list.isEmpty()) { 214 if ( list.isEmpty()) {
215 QStringList cats = KABPrefs::instance()->mCustomCategories; 215 QStringList cats = KABPrefs::instance()->mCustomCategories;
216 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { 216 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
217 Filter filter; 217 Filter filter;
218 filter.noName = false; 218 filter.noName = false;
219 filter.mName = *it; 219 filter.mName = *it;
220 filter.mEnabled = true; 220 filter.mEnabled = true;
221 filter.mCategoryList = *it; 221 filter.mCategoryList = QStringList(*it);
222 filter.mMatchRule = Matching; 222 filter.mMatchRule = Matching;
223 filter.mInternal = true; 223 filter.mInternal = true;
224 list.append( filter ); 224 list.append( filter );
225 } 225 }
226 } 226 }
227 return list; 227 return list;
228} 228}
229 229
230void Filter::setMatchRule( MatchRule rule ) 230void Filter::setMatchRule( MatchRule rule )
231{ 231{
232 mMatchRule = rule; 232 mMatchRule = rule;
233} 233}
234 234
235Filter::MatchRule Filter::matchRule() const 235Filter::MatchRule Filter::matchRule() const
236{ 236{
237 return mMatchRule; 237 return mMatchRule;
238} 238}