-rw-r--r-- | kabc/address.cpp | 27 | ||||
-rw-r--r-- | kabc/address.h | 2 | ||||
-rw-r--r-- | kabc/addressee.cpp | 25 | ||||
-rw-r--r-- | kabc/addressee.h | 4 |
4 files changed, 58 insertions, 0 deletions
diff --git a/kabc/address.cpp b/kabc/address.cpp index 5ffe511..6151f9e 100644 --- a/kabc/address.cpp +++ b/kabc/address.cpp @@ -103,2 +103,29 @@ QStringList Address::asList() } + +bool Address::matchAddress( QRegExp* re ) const +{ + +#if QT_VERSION >= 0x030000 + if (re->search( mPostOfficeBox ) == 0) return true; + if (re->search( mExtended ) == 0) return true; + if (re->search( mStreet ) == 0) return true; + if (re->search( mLocality ) == 0) return true; + if (re->search( mRegion ) == 0) return true; + if (re->search( mPostalCode ) == 0) return true; + if (re->search( mCountry ) == 0) return true; + if (re->search( mLabel ) == 0) return true; +#else + if (re->match( mPostOfficeBox ) == 0) return true; + if (re->match( mExtended ) == 0) return true; + if (re->match( mStreet ) == 0) return true; + if (re->match( mLocality ) == 0) return true; + if (re->match( mRegion ) == 0) return true; + if (re->match( mPostalCode ) == 0) return true; + if (re->match( mCountry ) == 0) return true; + if (re->match( mLabel ) == 0) return true; +#endif + + return false; +} + void Address::clear() diff --git a/kabc/address.h b/kabc/address.h index 37dd851..38ad20b 100644 --- a/kabc/address.h +++ b/kabc/address.h @@ -32,2 +32,3 @@ $Id$ #include <qstring.h> +#include <qregexp.h> #include <qstringlist.h> @@ -97,2 +98,3 @@ class Address Address( int ); + bool matchAddress( QRegExp* searchExp ) const; diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 155ce24..7e1e414 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -308,3 +308,28 @@ void Addressee::computeCsum(const QString &dev) } +bool Addressee::matchAddress( QRegExp* re ) const +{ + KABC::Address::List::Iterator addressIter; + for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); + ++addressIter ) { + if ( (*addressIter).matchAddress( re ) ) + return true; + } + return false; +} +bool Addressee::matchPhoneNumber( QRegExp* re ) const +{ + KABC::PhoneNumber::List::Iterator phoneIter; + + for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { +#if QT_VERSION >= 0x030000 + if (re->search( (*phoneIter).number() ) == 0) +#else + if (re->match( (*phoneIter).number() ) == 0) +#endif + return true; + } + return false; + +} void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) diff --git a/kabc/addressee.h b/kabc/addressee.h index a2fbcf5..d1c07cb 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h @@ -33,2 +33,3 @@ $Id$ #include <qstring.h> +#include <qregexp.h> #include <qstringlist.h> @@ -652,2 +653,5 @@ class Addressee + bool matchPhoneNumber( QRegExp* searchExp ) const; + bool matchAddress( QRegExp* searchExp ) const; + /** |