author | zautrix <zautrix> | 2005-08-22 15:42:41 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-22 15:42:41 (UTC) |
commit | 1d82d044bbdedd407f6d08305522187ffd256552 (patch) (unidiff) | |
tree | 08f5651d72548b643ed012e5f6ad938b36d1ae3f /kabc | |
parent | f516a558e6d18982a54152b28ca3da78fe76e3fc (diff) | |
download | kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.zip kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.tar.gz kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.tar.bz2 |
kapi search fix
-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 | |||
@@ -101,6 +101,33 @@ QStringList Address::asList() | |||
101 | if ( ! mLabel.isEmpty() )result.append(mLabel); | 101 | if ( ! mLabel.isEmpty() )result.append(mLabel); |
102 | return result; | 102 | return result; |
103 | } | 103 | } |
104 | |||
105 | bool Address::matchAddress( QRegExp* re ) const | ||
106 | { | ||
107 | |||
108 | #if QT_VERSION >= 0x030000 | ||
109 | if (re->search( mPostOfficeBox ) == 0) return true; | ||
110 | if (re->search( mExtended ) == 0) return true; | ||
111 | if (re->search( mStreet ) == 0) return true; | ||
112 | if (re->search( mLocality ) == 0) return true; | ||
113 | if (re->search( mRegion ) == 0) return true; | ||
114 | if (re->search( mPostalCode ) == 0) return true; | ||
115 | if (re->search( mCountry ) == 0) return true; | ||
116 | if (re->search( mLabel ) == 0) return true; | ||
117 | #else | ||
118 | if (re->match( mPostOfficeBox ) == 0) return true; | ||
119 | if (re->match( mExtended ) == 0) return true; | ||
120 | if (re->match( mStreet ) == 0) return true; | ||
121 | if (re->match( mLocality ) == 0) return true; | ||
122 | if (re->match( mRegion ) == 0) return true; | ||
123 | if (re->match( mPostalCode ) == 0) return true; | ||
124 | if (re->match( mCountry ) == 0) return true; | ||
125 | if (re->match( mLabel ) == 0) return true; | ||
126 | #endif | ||
127 | |||
128 | return false; | ||
129 | } | ||
130 | |||
104 | void Address::clear() | 131 | void Address::clear() |
105 | { | 132 | { |
106 | *this = Address(); | 133 | *this = Address(); |
diff --git a/kabc/address.h b/kabc/address.h index 37dd851..38ad20b 100644 --- a/kabc/address.h +++ b/kabc/address.h | |||
@@ -30,6 +30,7 @@ $Id$ | |||
30 | 30 | ||
31 | #include <qmap.h> | 31 | #include <qmap.h> |
32 | #include <qstring.h> | 32 | #include <qstring.h> |
33 | #include <qregexp.h> | ||
33 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
34 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
35 | 36 | ||
@@ -95,6 +96,7 @@ class Address | |||
95 | that you can specify the type. | 96 | that you can specify the type. |
96 | */ | 97 | */ |
97 | Address( int ); | 98 | Address( int ); |
99 | bool matchAddress( QRegExp* searchExp ) const; | ||
98 | 100 | ||
99 | bool operator==( const Address & ) const; | 101 | bool operator==( const Address & ) const; |
100 | bool operator!=( const Address & ) const; | 102 | bool operator!=( const Address & ) const; |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 155ce24..7e1e414 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -306,7 +306,32 @@ void Addressee::computeCsum(const QString &dev) | |||
306 | 306 | ||
307 | setCsum( dev, QString::number (cs )); | 307 | setCsum( dev, QString::number (cs )); |
308 | } | 308 | } |
309 | bool Addressee::matchAddress( QRegExp* re ) const | ||
310 | { | ||
311 | KABC::Address::List::Iterator addressIter; | ||
312 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | ||
313 | ++addressIter ) { | ||
314 | if ( (*addressIter).matchAddress( re ) ) | ||
315 | return true; | ||
316 | } | ||
317 | return false; | ||
318 | } | ||
319 | bool Addressee::matchPhoneNumber( QRegExp* re ) const | ||
320 | { | ||
321 | KABC::PhoneNumber::List::Iterator phoneIter; | ||
322 | |||
323 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { | ||
324 | #if QT_VERSION >= 0x030000 | ||
325 | if (re->search( (*phoneIter).number() ) == 0) | ||
326 | #else | ||
327 | if (re->match( (*phoneIter).number() ) == 0) | ||
328 | #endif | ||
329 | return true; | ||
309 | 330 | ||
331 | } | ||
332 | return false; | ||
333 | |||
334 | } | ||
310 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 335 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
311 | { | 336 | { |
312 | // merge all standard non-outlook fields. | 337 | // merge all standard non-outlook fields. |
diff --git a/kabc/addressee.h b/kabc/addressee.h index a2fbcf5..d1c07cb 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -31,6 +31,7 @@ $Id$ | |||
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qregexp.h> | ||
34 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 36 | #include <qvaluelist.h> |
36 | 37 | ||
@@ -650,6 +651,9 @@ class Addressee | |||
650 | */ | 651 | */ |
651 | PhoneNumber phoneNumber( int type ) const; | 652 | PhoneNumber phoneNumber( int type ) const; |
652 | 653 | ||
654 | bool matchPhoneNumber( QRegExp* searchExp ) const; | ||
655 | bool matchAddress( QRegExp* searchExp ) const; | ||
656 | |||
653 | /** | 657 | /** |
654 | Return list of all phone numbers. | 658 | Return list of all phone numbers. |
655 | */ | 659 | */ |