summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/filter.cpp18
-rw-r--r--kaddressbook/filter.h1
2 files changed, 15 insertions, 4 deletions
diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp
index 7a869fa..12ab1e3 100644
--- a/kaddressbook/filter.cpp
+++ b/kaddressbook/filter.cpp
@@ -31,17 +31,19 @@
#include <secrecy.h>
Filter::Filter()
- : mName( QString::null ), mMatchRule( Matching ), mEnabled( true ),
+ : mName( QString::null ), mMatchRule( NotMatching ), mEnabled( true ),
mInternal( false )
{
mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
+ noName = true;
}
Filter::Filter( const QString &name )
- : mName( name ), mMatchRule( Matching ), mEnabled( true ),
+ : mName( name ), mMatchRule( NotMatching ), mEnabled( true ),
mInternal( false )
{
mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
+ noName = false;
}
Filter::~Filter()
@@ -51,6 +53,7 @@ Filter::~Filter()
void Filter::setName( const QString &name )
{
mName = name;
+ noName = false;
}
const QString &Filter::name() const
@@ -65,6 +68,8 @@ bool Filter::isInternal() const
void Filter::apply( KABC::Addressee::List &addresseeList )
{
+ if ( noName )
+ return;
KABC::Addressee::List::Iterator iter;
for ( iter = addresseeList.begin(); iter != addresseeList.end(); ) {
if ( filterAddressee( *iter ) )
@@ -82,6 +87,10 @@ void Filter::apply( KABC::Addressee::List &addresseeList )
bool Filter::filterAddressee( const KABC::Addressee &a )
{
+
+ if ( noName )
+ return true;
+ //qDebug("Filter::filterAddressee %s",mName.latin1() );
switch ( a.secrecy().type()) {
case KABC::Secrecy::Public:
if (! (mCriteria & ShowPublic ))
@@ -101,10 +110,9 @@ bool Filter::filterAddressee( const KABC::Addressee &a )
}
QStringList::Iterator iter;
iter = mCategoryList.begin();
- // empty filter always matches
if ( iter == mCategoryList.end() )
- return true;
+ return ( !(mMatchRule == Matching) );
for ( ; iter != mCategoryList.end(); ++iter ) {
if ( a.hasCategory( *iter ) )
@@ -145,6 +153,7 @@ void Filter::save( KConfig *config )
void Filter::restore( KConfig *config )
{
+ noName = false;
mName = config->readEntry( "Name", "<internal error>" );
mEnabled = config->readBoolEntry( "Enabled", true );
mCategoryList = config->readListEntry( "Categories" );
@@ -206,6 +215,7 @@ Filter::List Filter::restore( KConfig *config, QString baseGroup )
QStringList cats = KABPrefs::instance()->mCustomCategories;
for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
Filter filter;
+ filter.noName = false;
filter.mName = *it;
filter.mEnabled = true;
filter.mCategoryList = *it;
diff --git a/kaddressbook/filter.h b/kaddressbook/filter.h
index 93f1352..f4ae123 100644
--- a/kaddressbook/filter.h
+++ b/kaddressbook/filter.h
@@ -146,6 +146,7 @@ class Filter
MatchRule matchRule() const;
private:
+ bool noName;
int mCriteria;
QString mName;
QStringList mCategoryList;