summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (show whitespace changes)
-rw-r--r--kabc/address.cpp27
-rw-r--r--kabc/address.h2
-rw-r--r--kabc/addressee.cpp25
-rw-r--r--kabc/addressee.h4
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
@@ -92,24 +92,51 @@ QStringList Address::asList()
92{ 92{
93 QStringList result; 93 QStringList result;
94 if ( ! mPostOfficeBox.isEmpty() )result.append(mPostOfficeBox); 94 if ( ! mPostOfficeBox.isEmpty() )result.append(mPostOfficeBox);
95 if ( ! mExtended.isEmpty())result.append(mExtended); 95 if ( ! mExtended.isEmpty())result.append(mExtended);
96 if ( ! mStreet.isEmpty())result.append(mStreet); 96 if ( ! mStreet.isEmpty())result.append(mStreet);
97 if ( ! mLocality.isEmpty() )result.append(mLocality); 97 if ( ! mLocality.isEmpty() )result.append(mLocality);
98 if ( ! mRegion.isEmpty())result.append(mRegion); 98 if ( ! mRegion.isEmpty())result.append(mRegion);
99 if ( ! mPostalCode.isEmpty())result.append(mPostalCode); 99 if ( ! mPostalCode.isEmpty())result.append(mPostalCode);
100 if ( ! mCountry.isEmpty())result.append(mCountry); 100 if ( ! mCountry.isEmpty())result.append(mCountry);
101 if ( ! mLabel.isEmpty() )result.append(mLabel); 101 if ( ! mLabel.isEmpty() )result.append(mLabel);
102 return result; 102 return result;
103} 103}
104
105bool 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
104void Address::clear() 131void Address::clear()
105{ 132{
106 *this = Address(); 133 *this = Address();
107} 134}
108 135
109void Address::setId( const QString &id ) 136void Address::setId( const QString &id )
110{ 137{
111 mEmpty = false; 138 mEmpty = false;
112 139
113 mId = id; 140 mId = id;
114} 141}
115 142
diff --git a/kabc/address.h b/kabc/address.h
index 37dd851..38ad20b 100644
--- a/kabc/address.h
+++ b/kabc/address.h
@@ -21,24 +21,25 @@
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_ADDRESS_H 28#ifndef KABC_ADDRESS_H
29#define KABC_ADDRESS_H 29#define KABC_ADDRESS_H
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
36// template tags for address formatting localization 37// template tags for address formatting localization
37#define KABC_FMTTAG_realname QString("%n") 38#define KABC_FMTTAG_realname QString("%n")
38#define KABC_FMTTAG_REALNAME QString("%N") 39#define KABC_FMTTAG_REALNAME QString("%N")
39#define KABC_FMTTAG_company QString("%cm") 40#define KABC_FMTTAG_company QString("%cm")
40#define KABC_FMTTAG_COMPANY QString("%CM") 41#define KABC_FMTTAG_COMPANY QString("%CM")
41#define KABC_FMTTAG_pobox QString("%p") 42#define KABC_FMTTAG_pobox QString("%p")
42#define KABC_FMTTAG_street QString("%s") 43#define KABC_FMTTAG_street QString("%s")
43#define KABC_FMTTAG_STREET QString("%S") 44#define KABC_FMTTAG_STREET QString("%S")
44#define KABC_FMTTAG_zipcode QString("%z") 45#define KABC_FMTTAG_zipcode QString("%z")
@@ -86,24 +87,25 @@ class Address
86 87
87 /** 88 /**
88 Constructor that creates an empty Address, which is initialized 89 Constructor that creates an empty Address, which is initialized
89 with a unique id (see @ref id()). 90 with a unique id (see @ref id()).
90 */ 91 */
91 Address(); 92 Address();
92 93
93 /** 94 /**
94 This is like @ref Address() just above, with the difference 95 This is like @ref Address() just above, with the difference
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;
101 103
102 /** 104 /**
103 Returns true, if the address is empty. 105 Returns true, if the address is empty.
104 */ 106 */
105 bool isEmpty() const; 107 bool isEmpty() const;
106 108
107 /** 109 /**
108 Clears all entries of the address. 110 Clears all entries of the address.
109 */ 111 */
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 155ce24..7e1e414 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -297,25 +297,50 @@ void Addressee::computeCsum(const QString &dev)
297 } 297 }
298 uint cs = getCsum4List(l); 298 uint cs = getCsum4List(l);
299 299
300#if 0 300#if 0
301 for ( iii = 0; iii < l.count(); ++iii) 301 for ( iii = 0; iii < l.count(); ++iii)
302 qDebug("%d***%s***",iii,l[iii].latin1()); 302 qDebug("%d***%s***",iii,l[iii].latin1());
303 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 303 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
304#endif 304#endif
305 305
306 306
307 setCsum( dev, QString::number (cs )); 307 setCsum( dev, QString::number (cs ));
308} 308}
309bool 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}
319bool 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}
310void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 335void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
311{ 336{
312 // merge all standard non-outlook fields. 337 // merge all standard non-outlook fields.
313 //if isSubSet (e.g. mobile phone sync) merge all fields 338 //if isSubSet (e.g. mobile phone sync) merge all fields
314 339
315 detach(); 340 detach();
316 if ( isSubSet ) { 341 if ( isSubSet ) {
317 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 342 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
318 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 343 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
319 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 344 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
320 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 345 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
321 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 346 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
diff --git a/kabc/addressee.h b/kabc/addressee.h
index a2fbcf5..d1c07cb 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -22,24 +22,25 @@
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#ifndef KABC_ADDRESSEE_H 29#ifndef KABC_ADDRESSEE_H
30#define KABC_ADDRESSEE_H 30#define KABC_ADDRESSEE_H
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
37#include <ksharedptr.h> 38#include <ksharedptr.h>
38#include <kurl.h> 39#include <kurl.h>
39 40
40#include "address.h" 41#include "address.h"
41#include "agent.h" 42#include "agent.h"
42#include "geo.h" 43#include "geo.h"
43#include "key.h" 44#include "key.h"
44#include "phonenumber.h" 45#include "phonenumber.h"
45#include "picture.h" 46#include "picture.h"
@@ -641,24 +642,27 @@ class Addressee
641 642
642 /** 643 /**
643 Remove phone number. If no phone number with the given id exists for this 644 Remove phone number. If no phone number with the given id exists for this
644 addresse nothing happens. 645 addresse nothing happens.
645 */ 646 */
646 void removePhoneNumber( const PhoneNumber &phoneNumber ); 647 void removePhoneNumber( const PhoneNumber &phoneNumber );
647 648
648 /** 649 /**
649 Return phone number, which matches the given type. 650 Return phone number, which matches the given type.
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 */
656 PhoneNumber::List phoneNumbers() const; 660 PhoneNumber::List phoneNumbers() const;
657 661
658 /** 662 /**
659 Return list of phone numbers with a special type. 663 Return list of phone numbers with a special type.
660 */ 664 */
661 PhoneNumber::List phoneNumbers( int type ) const; 665 PhoneNumber::List phoneNumbers( int type ) const;
662 666
663 /** 667 /**
664 Return phone number with the given id. 668 Return phone number with the given id.