author | zautrix <zautrix> | 2005-01-16 14:10:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-16 14:10:42 (UTC) |
commit | de5f08d69c716f85cc92f20700cd24fb1ad41295 (patch) (unidiff) | |
tree | 0a4f5dbbdb4fc24215ab85fa4b5e073d0e8104ef /kaddressbook/filter.cpp | |
parent | 3f61f5a339e9c0c67c17b16214abded0d123f246 (diff) | |
download | kdepimpi-de5f08d69c716f85cc92f20700cd24fb1ad41295.zip kdepimpi-de5f08d69c716f85cc92f20700cd24fb1ad41295.tar.gz kdepimpi-de5f08d69c716f85cc92f20700cd24fb1ad41295.tar.bz2 |
added AB filter settings
-rw-r--r-- | kaddressbook/filter.cpp | 22 |
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 | |||
@@ -25,23 +25,26 @@ | |||
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 | 32 | ||
32 | Filter::Filter() | 33 | Filter::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 | ||
38 | Filter::Filter( const QString &name ) | 40 | Filter::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 | ||
44 | Filter::~Filter() | 47 | Filter::~Filter() |
45 | { | 48 | { |
46 | } | 49 | } |
47 | 50 | ||
@@ -76,12 +79,29 @@ void Filter::apply( KABC::Addressee::List &addresseeList ) | |||
76 | } | 79 | } |
77 | } | 80 | } |
78 | } | 81 | } |
79 | 82 | ||
80 | bool Filter::filterAddressee( const KABC::Addressee &a ) | 83 | bool 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 | ||
86 | if ( iter == mCategoryList.end() ) | 106 | if ( iter == mCategoryList.end() ) |
87 | return true; | 107 | return true; |
@@ -117,20 +137,22 @@ const QStringList &Filter::categories() const | |||
117 | void Filter::save( KConfig *config ) | 137 | void Filter::save( KConfig *config ) |
118 | { | 138 | { |
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 | ||
125 | void Filter::restore( KConfig *config ) | 146 | void 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 | ||
133 | void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) | 155 | void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) |
134 | { | 156 | { |
135 | { | 157 | { |
136 | KConfigGroupSaver s( config, baseGroup ); | 158 | KConfigGroupSaver s( config, baseGroup ); |