summaryrefslogtreecommitdiffabout
path: root/kaddressbook/filter.cpp
Side-by-side diff
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
@@ -19,35 +19,38 @@
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <kconfig.h>
#include <kconfigbase.h>
#include <kdebug.h>
#include "kabprefs.h"
#include "filter.h"
+#include <secrecy.h>
Filter::Filter()
: mName( QString::null ), mMatchRule( Matching ), mEnabled( true ),
mInternal( false )
{
+ mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
}
Filter::Filter( const QString &name )
: mName( name ), mMatchRule( Matching ), mEnabled( true ),
mInternal( false )
{
+ mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
}
Filter::~Filter()
{
}
void Filter::setName( const QString &name )
{
mName = name;
}
const QString &Filter::name() const
@@ -70,24 +73,41 @@ void Filter::apply( KABC::Addressee::List &addresseeList )
{
#ifndef KAB_EMBEDDED
iter = addresseeList.erase( iter );
#else //KAB_EMBEDDED
iter = addresseeList.remove( iter );
#endif //KAB_EMBEDDED
}
}
}
bool Filter::filterAddressee( const KABC::Addressee &a )
{
+ switch ( a.secrecy().type()) {
+ case KABC::Secrecy::Public:
+ if (! (mCriteria & ShowPublic ))
+ return false;
+ break;
+ case KABC::Secrecy::Private:
+ if (! (mCriteria & ShowPrivate ))
+ return false;
+ break;
+ case KABC::Secrecy::Confidential:
+ if (! (mCriteria & ShowConfidential ))
+ return false;
+ break;
+ default:
+ return false;
+ break;
+ }
QStringList::Iterator iter;
iter = mCategoryList.begin();
// empty filter always matches
if ( iter == mCategoryList.end() )
return true;
for ( ; iter != mCategoryList.end(); ++iter ) {
if ( a.hasCategory( *iter ) )
return ( mMatchRule == Matching );
}
@@ -111,32 +131,34 @@ void Filter::setCategories( const QStringList &list )
const QStringList &Filter::categories() const
{
return mCategoryList;
}
void Filter::save( KConfig *config )
{
config->writeEntry( "Name", mName );
config->writeEntry( "Enabled", mEnabled );
config->writeEntry( "Categories", mCategoryList );
config->writeEntry( "MatchRule", (int)mMatchRule );
+ config->writeEntry( "Criteria", (int)mCriteria );
}
void Filter::restore( KConfig *config )
{
mName = config->readEntry( "Name", "<internal error>" );
mEnabled = config->readBoolEntry( "Enabled", true );
mCategoryList = config->readListEntry( "Categories" );
mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching );
+ mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential) );
}
void Filter::save( KConfig *config, QString baseGroup, Filter::List &list )
{
{
KConfigGroupSaver s( config, baseGroup );
// remove the old filters
uint count = config->readNumEntry( "Count" );
/* // memory access violation here
for ( uint i = 0; i < count; ++i )
config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) );