summaryrefslogtreecommitdiffabout
path: root/kaddressbook/filter.cpp
Unidiff
Diffstat (limited to 'kaddressbook/filter.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/filter.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp
index 39d2ae4..9cb4c2d 100644
--- a/kaddressbook/filter.cpp
+++ b/kaddressbook/filter.cpp
@@ -27,19 +27,22 @@
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 32
32Filter::Filter() 33Filter::Filter()
33 : mName( QString::null ), mMatchRule( Matching ), mEnabled( true ), 34 : mName( QString::null ), mMatchRule( Matching ), mEnabled( true ),
34 mInternal( false ) 35 mInternal( false )
35{ 36{
37 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
36} 38}
37 39
38Filter::Filter( const QString &name ) 40Filter::Filter( const QString &name )
39 : mName( name ), mMatchRule( Matching ), mEnabled( true ), 41 : mName( name ), mMatchRule( Matching ), mEnabled( true ),
40 mInternal( false ) 42 mInternal( false )
41{ 43{
44 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
42} 45}
43 46
44Filter::~Filter() 47Filter::~Filter()
45{ 48{
@@ -78,8 +81,25 @@ void Filter::apply( KABC::Addressee::List &addresseeList )
78} 81}
79 82
80bool Filter::filterAddressee( const KABC::Addressee &a ) 83bool Filter::filterAddressee( const KABC::Addressee &a )
81{ 84{
85 switch ( a.secrecy().type()) {
86 case KABC::Secrecy::Public:
87 if (! (mCriteria & ShowPublic ))
88 return false;
89 break;
90 case KABC::Secrecy::Private:
91 if (! (mCriteria & ShowPrivate ))
92 return false;
93 break;
94 case KABC::Secrecy::Confidential:
95 if (! (mCriteria & ShowConfidential ))
96 return false;
97 break;
98 default:
99 return false;
100 break;
101 }
82 QStringList::Iterator iter; 102 QStringList::Iterator iter;
83 iter = mCategoryList.begin(); 103 iter = mCategoryList.begin();
84 // empty filter always matches 104 // empty filter always matches
85 105
@@ -119,16 +139,18 @@ void Filter::save( KConfig *config )
119 config->writeEntry( "Name", mName ); 139 config->writeEntry( "Name", mName );
120 config->writeEntry( "Enabled", mEnabled ); 140 config->writeEntry( "Enabled", mEnabled );
121 config->writeEntry( "Categories", mCategoryList ); 141 config->writeEntry( "Categories", mCategoryList );
122 config->writeEntry( "MatchRule", (int)mMatchRule ); 142 config->writeEntry( "MatchRule", (int)mMatchRule );
143 config->writeEntry( "Criteria", (int)mCriteria );
123} 144}
124 145
125void Filter::restore( KConfig *config ) 146void Filter::restore( KConfig *config )
126{ 147{
127 mName = config->readEntry( "Name", "<internal error>" ); 148 mName = config->readEntry( "Name", "<internal error>" );
128 mEnabled = config->readBoolEntry( "Enabled", true ); 149 mEnabled = config->readBoolEntry( "Enabled", true );
129 mCategoryList = config->readListEntry( "Categories" ); 150 mCategoryList = config->readListEntry( "Categories" );
130 mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); 151 mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching );
152 mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential) );
131} 153}
132 154
133void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) 155void Filter::save( KConfig *config, QString baseGroup, Filter::List &list )
134{ 156{