author | zautrix <zautrix> | 2005-04-04 12:59:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-04 12:59:35 (UTC) |
commit | 919f1060a9ef41e6c865f28132cf9e82c3f67409 (patch) (side-by-side diff) | |
tree | 8e7c1283071ff2af2897ccf1c7e51e8b2b2bfadc /kaddressbook | |
parent | 23db4aa99cb7a5feb540b6be578efaee8ec6ef80 (diff) | |
download | kdepimpi-919f1060a9ef41e6c865f28132cf9e82c3f67409.zip kdepimpi-919f1060a9ef41e6c865f28132cf9e82c3f67409.tar.gz kdepimpi-919f1060a9ef41e6c865f28132cf9e82c3f67409.tar.bz2 |
kapi filter fixes
-rw-r--r-- | kaddressbook/filter.cpp | 24 | ||||
-rw-r--r-- | kaddressbook/filter.h | 1 |
2 files changed, 18 insertions, 7 deletions
diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp index 7a869fa..12ab1e3 100644 --- a/kaddressbook/filter.cpp +++ b/kaddressbook/filter.cpp @@ -30,19 +30,21 @@ #include "filter.h" #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() { @@ -50,8 +52,9 @@ Filter::~Filter() void Filter::setName( const QString &name ) { mName = name; + noName = false; } const QString &Filter::name() const { @@ -63,9 +66,11 @@ bool Filter::isInternal() const return mInternal; } 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 ) ) ++iter; @@ -81,8 +86,12 @@ 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 )) return false; @@ -100,12 +109,11 @@ bool Filter::filterAddressee( const KABC::Addressee &a ) break; } 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 ) ) return ( mMatchRule == Matching ); @@ -143,9 +151,10 @@ void Filter::save( KConfig *config ) config->writeEntry( "Criteria", (int)mCriteria ); } void Filter::restore( KConfig *config ) -{ +{ + noName = false; mName = config->readEntry( "Name", "<internal error>" ); mEnabled = config->readBoolEntry( "Enabled", true ); mCategoryList = config->readListEntry( "Categories" ); mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); @@ -204,9 +213,10 @@ Filter::List Filter::restore( KConfig *config, QString baseGroup ) if ( list.isEmpty()) { QStringList cats = KABPrefs::instance()->mCustomCategories; for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { - Filter filter; + Filter filter; + filter.noName = false; filter.mName = *it; filter.mEnabled = true; filter.mCategoryList = *it; filter.mMatchRule = Matching; diff --git a/kaddressbook/filter.h b/kaddressbook/filter.h index 93f1352..f4ae123 100644 --- a/kaddressbook/filter.h +++ b/kaddressbook/filter.h @@ -145,8 +145,9 @@ class Filter */ MatchRule matchRule() const; private: + bool noName; int mCriteria; QString mName; QStringList mCategoryList; MatchRule mMatchRule; |