summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
Unidiff
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 295ee4f..2564894 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,2097 +1,2115 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
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#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern ); 46static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern ); 47static bool matchBinaryPatternP( int value, int pattern );
48 48
49struct Addressee::AddresseeData : public KShared 49struct Addressee::AddresseeData : public KShared
50{ 50{
51 QString uid; 51 QString uid;
52 QString name; 52 QString name;
53 QString formattedName; 53 QString formattedName;
54 QString familyName; 54 QString familyName;
55 QString givenName; 55 QString givenName;
56 QString additionalName; 56 QString additionalName;
57 QString prefix; 57 QString prefix;
58 QString suffix; 58 QString suffix;
59 QString nickName; 59 QString nickName;
60 QDateTime birthday; 60 QDateTime birthday;
61 QString mailer; 61 QString mailer;
62 TimeZone timeZone; 62 TimeZone timeZone;
63 Geo geo; 63 Geo geo;
64 QString title; 64 QString title;
65 QString role; 65 QString role;
66 QString organization; 66 QString organization;
67 QString note; 67 QString note;
68 QString productId; 68 QString productId;
69 QDateTime revision; 69 QDateTime revision;
70 QString sortString; 70 QString sortString;
71 QString externalUID; 71 QString externalUID;
72 QString originalExternalUID; 72 QString originalExternalUID;
73 KURL url; 73 KURL url;
74 Secrecy secrecy; 74 Secrecy secrecy;
75 Picture logo; 75 Picture logo;
76 Picture photo; 76 Picture photo;
77 Sound sound; 77 Sound sound;
78 Agent agent; 78 Agent agent;
79 QString mExternalId; 79 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 81 Address::List addresses;
82 Key::List keys; 82 Key::List keys;
83 QStringList emails; 83 QStringList emails;
84 QStringList categories; 84 QStringList categories;
85 QStringList custom; 85 QStringList custom;
86 int mTempSyncStat; 86 int mTempSyncStat;
87 Resource *resource; 87 Resource *resource;
88 88
89 bool empty :1; 89 bool empty :1;
90 bool changed :1; 90 bool changed :1;
91 bool tagged :1; 91 bool tagged :1;
92}; 92};
93 93
94Addressee::Addressee() 94Addressee::Addressee()
95{ 95{
96 mData = new AddresseeData; 96 mData = new AddresseeData;
97 mData->empty = true; 97 mData->empty = true;
98 mData->changed = false; 98 mData->changed = false;
99 mData->resource = 0; 99 mData->resource = 0;
100 mData->mExternalId = ":"; 100 mData->mExternalId = ":";
101 mData->revision = QDateTime ( QDate( 2003,1,1)); 101 mData->revision = QDateTime ( QDate( 2003,1,1));
102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
103} 103}
104 104
105Addressee::~Addressee() 105Addressee::~Addressee()
106{ 106{
107} 107}
108 108
109Addressee::Addressee( const Addressee &a ) 109Addressee::Addressee( const Addressee &a )
110{ 110{
111 mData = a.mData; 111 mData = a.mData;
112} 112}
113 113
114Addressee &Addressee::operator=( const Addressee &a ) 114Addressee &Addressee::operator=( const Addressee &a )
115{ 115{
116 mData = a.mData; 116 mData = a.mData;
117 return (*this); 117 return (*this);
118} 118}
119 119
120Addressee Addressee::copy() 120Addressee Addressee::copy()
121{ 121{
122 Addressee a; 122 Addressee a;
123 *(a.mData) = *mData; 123 *(a.mData) = *mData;
124 return a; 124 return a;
125} 125}
126 126
127void Addressee::detach() 127void Addressee::detach()
128{ 128{
129 if ( mData.count() == 1 ) return; 129 if ( mData.count() == 1 ) return;
130 *this = copy(); 130 *this = copy();
131} 131}
132 132
133bool Addressee::operator==( const Addressee &a ) const 133bool Addressee::operator==( const Addressee &a ) const
134{ 134{
135 if ( uid() != a.uid() ) return false; 135 if ( uid() != a.uid() ) return false;
136 if ( mData->name != a.mData->name ) return false; 136 if ( mData->name != a.mData->name ) return false;
137 if ( mData->formattedName != a.mData->formattedName ) return false; 137 if ( mData->formattedName != a.mData->formattedName ) return false;
138 if ( mData->familyName != a.mData->familyName ) return false; 138 if ( mData->familyName != a.mData->familyName ) return false;
139 if ( mData->givenName != a.mData->givenName ) return false; 139 if ( mData->givenName != a.mData->givenName ) return false;
140 if ( mData->additionalName != a.mData->additionalName ) return false; 140 if ( mData->additionalName != a.mData->additionalName ) return false;
141 if ( mData->prefix != a.mData->prefix ) return false; 141 if ( mData->prefix != a.mData->prefix ) return false;
142 if ( mData->suffix != a.mData->suffix ) return false; 142 if ( mData->suffix != a.mData->suffix ) return false;
143 if ( mData->nickName != a.mData->nickName ) return false; 143 if ( mData->nickName != a.mData->nickName ) return false;
144 if ( mData->birthday != a.mData->birthday ) return false; 144 if ( mData->birthday != a.mData->birthday ) return false;
145 if ( mData->mailer != a.mData->mailer ) return false; 145 if ( mData->mailer != a.mData->mailer ) return false;
146 if ( mData->timeZone != a.mData->timeZone ) return false; 146 if ( mData->timeZone != a.mData->timeZone ) return false;
147 if ( mData->geo != a.mData->geo ) return false; 147 if ( mData->geo != a.mData->geo ) return false;
148 if ( mData->title != a.mData->title ) return false; 148 if ( mData->title != a.mData->title ) return false;
149 if ( mData->role != a.mData->role ) return false; 149 if ( mData->role != a.mData->role ) return false;
150 if ( mData->organization != a.mData->organization ) return false; 150 if ( mData->organization != a.mData->organization ) return false;
151 if ( mData->note != a.mData->note ) return false; 151 if ( mData->note != a.mData->note ) return false;
152 if ( mData->productId != a.mData->productId ) return false; 152 if ( mData->productId != a.mData->productId ) return false;
153 //if ( mData->revision != a.mData->revision ) return false; 153 //if ( mData->revision != a.mData->revision ) return false;
154 if ( mData->sortString != a.mData->sortString ) return false; 154 if ( mData->sortString != a.mData->sortString ) return false;
155 if ( mData->secrecy != a.mData->secrecy ) return false; 155 if ( mData->secrecy != a.mData->secrecy ) return false;
156 if ( mData->logo != a.mData->logo ) return false; 156 if ( mData->logo != a.mData->logo ) return false;
157 if ( mData->photo != a.mData->photo ) return false; 157 if ( mData->photo != a.mData->photo ) return false;
158 if ( mData->sound != a.mData->sound ) return false; 158 if ( mData->sound != a.mData->sound ) return false;
159 if ( mData->agent != a.mData->agent ) return false; 159 if ( mData->agent != a.mData->agent ) return false;
160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
161 ( mData->url != a.mData->url ) ) return false; 161 ( mData->url != a.mData->url ) ) return false;
162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
163 if ( mData->addresses != a.mData->addresses ) return false; 163 if ( mData->addresses != a.mData->addresses ) return false;
164 if ( mData->keys != a.mData->keys ) return false; 164 if ( mData->keys != a.mData->keys ) return false;
165 if ( mData->emails != a.mData->emails ) return false; 165 if ( mData->emails != a.mData->emails ) return false;
166 if ( mData->categories != a.mData->categories ) return false; 166 if ( mData->categories != a.mData->categories ) return false;
167 if ( mData->custom != a.mData->custom ) return false; 167 if ( mData->custom != a.mData->custom ) return false;
168 168
169 return true; 169 return true;
170} 170}
171 171
172bool Addressee::operator!=( const Addressee &a ) const 172bool Addressee::operator!=( const Addressee &a ) const
173{ 173{
174 return !( a == *this ); 174 return !( a == *this );
175} 175}
176 176
177bool Addressee::isEmpty() const 177bool Addressee::isEmpty() const
178{ 178{
179 return mData->empty; 179 return mData->empty;
180} 180}
181ulong Addressee::getCsum4List( const QStringList & attList) 181ulong Addressee::getCsum4List( const QStringList & attList)
182{ 182{
183 int max = attList.count(); 183 int max = attList.count();
184 ulong cSum = 0; 184 ulong cSum = 0;
185 int j,k,i; 185 int j,k,i;
186 int add; 186 int add;
187 for ( i = 0; i < max ; ++i ) { 187 for ( i = 0; i < max ; ++i ) {
188 QString s = attList[i]; 188 QString s = attList[i];
189 if ( ! s.isEmpty() ){ 189 if ( ! s.isEmpty() ){
190 j = s.length(); 190 j = s.length();
191 for ( k = 0; k < j; ++k ) { 191 for ( k = 0; k < j; ++k ) {
192 int mul = k +1; 192 int mul = k +1;
193 add = s[k].unicode (); 193 add = s[k].unicode ();
194 if ( k < 16 ) 194 if ( k < 16 )
195 mul = mul * mul; 195 mul = mul * mul;
196 int ii = i+1; 196 int ii = i+1;
197 add = add * mul *ii*ii*ii; 197 add = add * mul *ii*ii*ii;
198 cSum += add; 198 cSum += add;
199 } 199 }
200 } 200 }
201 201
202 } 202 }
203 //QString dump = attList.join(","); 203 //QString dump = attList.join(",");
204 //qDebug("csum: %d %s", cSum,dump.latin1()); 204 //qDebug("csum: %d %s", cSum,dump.latin1());
205 205
206 return cSum; 206 return cSum;
207 207
208} 208}
209void Addressee::computeCsum(const QString &dev) 209void Addressee::computeCsum(const QString &dev)
210{ 210{
211 QStringList l; 211 QStringList l;
212 if ( !mData->name.isEmpty() ) l.append(mData->name); 212 if ( !mData->name.isEmpty() ) l.append(mData->name);
213 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 213 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
216 if ( !mData->additionalName ) l.append( mData->additionalName ); 216 if ( !mData->additionalName ) l.append( mData->additionalName );
217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
224 if ( !mData->title .isEmpty() ) l.append( mData->title ); 224 if ( !mData->title .isEmpty() ) l.append( mData->title );
225 if ( !mData->role.isEmpty() ) l.append( mData->role ); 225 if ( !mData->role.isEmpty() ) l.append( mData->role );
226 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 226 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
227 if ( !mData->note.isEmpty() ) l.append( mData->note ); 227 if ( !mData->note.isEmpty() ) l.append( mData->note );
228 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 228 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
231 // if ( !mData->logo.isEmpty() ) l.append( ); 231 // if ( !mData->logo.isEmpty() ) l.append( );
232 //if ( !mData->photo.isEmpty() ) l.append( ); 232 //if ( !mData->photo.isEmpty() ) l.append( );
233 //if ( !mData->sound.isEmpty() ) l.append( ); 233 //if ( !mData->sound.isEmpty() ) l.append( );
234 //if ( !mData->agent.isEmpty() ) l.append( ); 234 //if ( !mData->agent.isEmpty() ) l.append( );
235 if ( mData->url.isValid() ) 235 if ( mData->url.isValid() )
236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
237 KABC::PhoneNumber::List phoneNumbers; 237 KABC::PhoneNumber::List phoneNumbers;
238 KABC::PhoneNumber::List::Iterator phoneIter; 238 KABC::PhoneNumber::List::Iterator phoneIter;
239 239
240 QStringList t; 240 QStringList t;
241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
242 ++phoneIter ) 242 ++phoneIter )
243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
244 t.sort(); 244 t.sort();
245 uint iii; 245 uint iii;
246 for ( iii = 0; iii < t.count(); ++iii) 246 for ( iii = 0; iii < t.count(); ++iii)
247 l.append( t[iii] ); 247 l.append( t[iii] );
248 t = mData->emails; 248 t = mData->emails;
249 t.sort(); 249 t.sort();
250 for ( iii = 0; iii < t.count(); ++iii) 250 for ( iii = 0; iii < t.count(); ++iii)
251 l.append( t[iii] ); 251 l.append( t[iii] );
252 t = mData->categories; 252 t = mData->categories;
253 t.sort(); 253 t.sort();
254 for ( iii = 0; iii < t.count(); ++iii) 254 for ( iii = 0; iii < t.count(); ++iii)
255 l.append( t[iii] ); 255 l.append( t[iii] );
256 t = mData->custom; 256 t = mData->custom;
257 t.sort(); 257 t.sort();
258 for ( iii = 0; iii < t.count(); ++iii) 258 for ( iii = 0; iii < t.count(); ++iii)
259 l.append( t[iii] ); 259 l.append( t[iii] );
260 KABC::Address::List::Iterator addressIter; 260 KABC::Address::List::Iterator addressIter;
261 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 261 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
262 ++addressIter ) { 262 ++addressIter ) {
263 t = (*addressIter).asList(); 263 t = (*addressIter).asList();
264 t.sort(); 264 t.sort();
265 for ( iii = 0; iii < t.count(); ++iii) 265 for ( iii = 0; iii < t.count(); ++iii)
266 l.append( t[iii] ); 266 l.append( t[iii] );
267 } 267 }
268 uint cs = getCsum4List(l); 268 uint cs = getCsum4List(l);
269 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 269 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
270 setCsum( dev, QString::number (cs )); 270 setCsum( dev, QString::number (cs ));
271} 271}
272 272
273void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 273void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
274{ 274{
275 275
276 detach(); 276 detach();
277 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 277 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
278 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 278 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
279 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 279 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
280 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 280 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
281 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 281 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
282 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 282 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
283 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 283 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
284 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 284 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
285 if ( !mData->birthday.isValid() ) 285 if ( !mData->birthday.isValid() )
286 if ( ad.mData->birthday.isValid()) 286 if ( ad.mData->birthday.isValid())
287 mData->birthday = ad.mData->birthday; 287 mData->birthday = ad.mData->birthday;
288 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 288 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
289 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 289 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
290 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 290 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
291 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 291 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
292 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 292 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
293 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 293 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
294 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 294 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
295 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 295 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
296 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 296 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
297 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 297 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
298 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 298 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
299 QStringList t; 299 QStringList t;
300 QStringList tAD; 300 QStringList tAD;
301 uint iii; 301 uint iii;
302 302
303 // ********** phone numbers 303 // ********** phone numbers
304 PhoneNumber::List phoneAD = ad.phoneNumbers(); 304 PhoneNumber::List phoneAD = ad.phoneNumbers();
305 PhoneNumber::List::Iterator phoneItAD; 305 PhoneNumber::List::Iterator phoneItAD;
306 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 306 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
307 bool found = false; 307 bool found = false;
308 PhoneNumber::List::Iterator it; 308 PhoneNumber::List::Iterator it;
309 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 309 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
310 if ( ( *phoneItAD ).contains( (*it) ) ) { 310 if ( ( *phoneItAD ).contains( (*it) ) ) {
311 found = true; 311 found = true;
312 (*it).setType( ( *phoneItAD ).type() ); 312 (*it).setType( ( *phoneItAD ).type() );
313 break; 313 break;
314 } 314 }
315 } 315 }
316 if ( isSubSet && ! found ) 316 if ( isSubSet && ! found )
317 mData->phoneNumbers.append( *phoneItAD ); 317 mData->phoneNumbers.append( *phoneItAD );
318 } 318 }
319 if ( isSubSet ) { 319 if ( isSubSet ) {
320 // ************* emails; 320 // ************* emails;
321 t = mData->emails; 321 t = mData->emails;
322 tAD = ad.mData->emails; 322 tAD = ad.mData->emails;
323 for ( iii = 0; iii < tAD.count(); ++iii) 323 for ( iii = 0; iii < tAD.count(); ++iii)
324 if ( !t.contains(tAD[iii] ) ) 324 if ( !t.contains(tAD[iii] ) )
325 mData->emails.append( tAD[iii] ); 325 mData->emails.append( tAD[iii] );
326 } 326 }
327 327
328 // ************* categories; 328 // ************* categories;
329 t = mData->categories; 329 t = mData->categories;
330 tAD = ad.mData->categories; 330 tAD = ad.mData->categories;
331 for ( iii = 0; iii < tAD.count(); ++iii) 331 for ( iii = 0; iii < tAD.count(); ++iii)
332 if ( !t.contains(tAD[iii] ) ) 332 if ( !t.contains(tAD[iii] ) )
333 mData->categories.append( tAD[iii] ); 333 mData->categories.append( tAD[iii] );
334 QStringList::ConstIterator it; 334 QStringList::ConstIterator it;
335 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 335 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
336 QString qualifiedName = (*it).left( (*it).find( ":" )); 336 QString qualifiedName = (*it).left( (*it).find( ":" ));
337 bool found = false; 337 bool found = false;
338 QStringList::ConstIterator itL; 338 QStringList::ConstIterator itL;
339 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 339 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
340 if ( (*itL).startsWith( qualifiedName ) ) { 340 if ( (*itL).startsWith( qualifiedName ) ) {
341 found = true; 341 found = true;
342 break; 342 break;
343 } 343 }
344 } 344 }
345 if ( ! found ) { 345 if ( ! found ) {
346 mData->custom.append( *it ); 346 mData->custom.append( *it );
347 } 347 }
348 } 348 }
349 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 349 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
350 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 350 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
351 if ( !mData->sound.isIntern() ) { 351 if ( !mData->sound.isIntern() ) {
352 if ( mData->sound.url().isEmpty() ) { 352 if ( mData->sound.url().isEmpty() ) {
353 mData->sound = ad.mData->sound; 353 mData->sound = ad.mData->sound;
354 } 354 }
355 } 355 }
356 if ( !mData->agent.isIntern() ) { 356 if ( !mData->agent.isIntern() ) {
357 if ( mData->agent.url().isEmpty() ) { 357 if ( mData->agent.url().isEmpty() ) {
358 mData->agent = ad.mData->agent; 358 mData->agent = ad.mData->agent;
359 } 359 }
360 } 360 }
361 { 361 {
362 Key::List::Iterator itA; 362 Key::List::Iterator itA;
363 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 363 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
364 bool found = false; 364 bool found = false;
365 Key::List::Iterator it; 365 Key::List::Iterator it;
366 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 366 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
367 if ( (*it) == (*itA)) { 367 if ( (*it) == (*itA)) {
368 found = true; 368 found = true;
369 break; 369 break;
370 370
371 } 371 }
372 } 372 }
373 if ( ! found ) { 373 if ( ! found ) {
374 mData->keys.append( *itA ); 374 mData->keys.append( *itA );
375 } 375 }
376 } 376 }
377 } 377 }
378 KABC::Address::List::Iterator addressIterA; 378 KABC::Address::List::Iterator addressIterA;
379 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 379 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
380 bool found = false; 380 bool found = false;
381 KABC::Address::List::Iterator addressIter; 381 KABC::Address::List::Iterator addressIter;
382 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 382 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
383 ++addressIter ) { 383 ++addressIter ) {
384 if ( (*addressIter) == (*addressIterA)) { 384 if ( (*addressIter) == (*addressIterA)) {
385 found = true; 385 found = true;
386 (*addressIter).setType( (*addressIterA).type() ); 386 (*addressIter).setType( (*addressIterA).type() );
387 break; 387 break;
388 } 388 }
389 389
390 } 390 }
391 if ( isSubSet && ! found ) { 391 if ( isSubSet && ! found ) {
392 mData->addresses.append( *addressIterA ); 392 mData->addresses.append( *addressIterA );
393 } 393 }
394 } 394 }
395 //qDebug("merge contact %s ", ad.uid().latin1()); 395 //qDebug("merge contact %s ", ad.uid().latin1());
396 setUid( ad.uid() ); 396 setUid( ad.uid() );
397 setRevision( ad.revision() ); 397 setRevision( ad.revision() );
398} 398}
399 399
400bool Addressee::removeVoice() 400bool Addressee::removeVoice()
401{ 401{
402 PhoneNumber::List phoneN = phoneNumbers(); 402 PhoneNumber::List phoneN = phoneNumbers();
403 PhoneNumber::List::Iterator phoneIt; 403 PhoneNumber::List::Iterator phoneIt;
404 bool found = false; 404 bool found = false;
405 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 405 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
406 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 406 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
407 if ((*phoneIt).type() - PhoneNumber::Voice ) { 407 if ((*phoneIt).type() - PhoneNumber::Voice ) {
408 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 408 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
409 insertPhoneNumber( (*phoneIt) ); 409 insertPhoneNumber( (*phoneIt) );
410 found = true; 410 found = true;
411 } 411 }
412 } 412 }
413 413
414 } 414 }
415 return found; 415 return found;
416} 416}
417 417
418bool Addressee::containsAdr(const Addressee& ad ) 418bool Addressee::containsAdr(const Addressee& ad )
419{ 419{
420 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 420 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
421 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 421 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
422 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 422 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
423 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 423 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
424 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 424 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
425 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 425 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
426 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 426 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
427 427
428 // compare phone numbers 428 // compare phone numbers
429 PhoneNumber::List phoneN = ad.phoneNumbers(); 429 PhoneNumber::List phoneN = ad.phoneNumbers();
430 PhoneNumber::List::Iterator phoneIt; 430 PhoneNumber::List::Iterator phoneIt;
431 bool found = false; 431 bool found = false;
432 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 432 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
433 bool found = false; 433 bool found = false;
434 PhoneNumber::List phoneL = ad.phoneNumbers(); 434 PhoneNumber::List phoneL = ad.phoneNumbers();
435 PhoneNumber::List::Iterator phoneItL; 435 PhoneNumber::List::Iterator phoneItL;
436 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 436 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
437 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 437 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
438 found = true; 438 found = true;
439 break; 439 break;
440 } 440 }
441 } 441 }
442 if ( ! found ) 442 if ( ! found )
443 return false; 443 return false;
444 } 444 }
445 return true; 445 return true;
446 446
447} 447}
448void Addressee::simplifyAddresses() 448void Addressee::simplifyAddresses()
449{ 449{
450
451
452 Address::List list;
453 Address::List::Iterator it;
454 Address::List::Iterator it2;
455 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
456 it2 = it;
457 ++it2;
458 for( ; it2 != mData->addresses.end(); ++it2 ) {
459 if ( (*it) == (*it2) ) {
460 list.append( *it );
461 break;
462 }
463 }
464 }
465 for( it = list.begin(); it != list.end(); ++it ) {
466 removeAddress( (*it) );
467 }
468
469 list.clear();
450 int max = 2; 470 int max = 2;
451 if ( mData->url.isValid() ) 471 if ( mData->url.isValid() )
452 max = 1; 472 max = 1;
453 if ( mData->addresses.count() <= max ) return ; 473 if ( mData->addresses.count() <= max ) return ;
454 int count = 0; 474 int count = 0;
455 Address::List list;
456 Address::List::Iterator it;
457 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 475 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
458 if ( count >= max ) 476 if ( count >= max )
459 list.append( *it ); 477 list.append( *it );
460 ++count; 478 ++count;
461 } 479 }
462 for( it = list.begin(); it != list.end(); ++it ) { 480 for( it = list.begin(); it != list.end(); ++it ) {
463 removeAddress( (*it) ); 481 removeAddress( (*it) );
464 } 482 }
465} 483}
466 484
467// removes all emails but the first 485// removes all emails but the first
468// needed by phone sync 486// needed by phone sync
469void Addressee::simplifyEmails() 487void Addressee::simplifyEmails()
470{ 488{
471 if ( mData->emails.count() == 0 ) return ; 489 if ( mData->emails.count() == 0 ) return ;
472 QString email = mData->emails.first(); 490 QString email = mData->emails.first();
473 detach(); 491 detach();
474 mData->emails.clear(); 492 mData->emails.clear();
475 mData->emails.append( email ); 493 mData->emails.append( email );
476} 494}
477 495
478void Addressee::simplifyPhoneNumbers() 496void Addressee::simplifyPhoneNumbers()
479{ 497{
480 int max = 4; 498 int max = 4;
481 int inList = mData->phoneNumbers.count(); 499 int inList = mData->phoneNumbers.count();
482 KABC::PhoneNumber::List removeNumbers; 500 KABC::PhoneNumber::List removeNumbers;
483 KABC::PhoneNumber::List::Iterator phoneIter; 501 KABC::PhoneNumber::List::Iterator phoneIter;
484 if ( inList > max ) { 502 if ( inList > max ) {
485 // delete non-preferred numbers 503 // delete non-preferred numbers
486 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 504 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
487 ++phoneIter ) { 505 ++phoneIter ) {
488 if ( inList > max ) { 506 if ( inList > max ) {
489 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 507 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
490 removeNumbers.append( ( *phoneIter ) ); 508 removeNumbers.append( ( *phoneIter ) );
491 --inList; 509 --inList;
492 } 510 }
493 } else 511 } else
494 break; 512 break;
495 } 513 }
496 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 514 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
497 ++phoneIter ) { 515 ++phoneIter ) {
498 removePhoneNumber(( *phoneIter )); 516 removePhoneNumber(( *phoneIter ));
499 } 517 }
500 // delete preferred numbers 518 // delete preferred numbers
501 if ( inList > max ) { 519 if ( inList > max ) {
502 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 520 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
503 ++phoneIter ) { 521 ++phoneIter ) {
504 if ( inList > max ) { 522 if ( inList > max ) {
505 removeNumbers.append( ( *phoneIter ) ); 523 removeNumbers.append( ( *phoneIter ) );
506 --inList; 524 --inList;
507 } else 525 } else
508 break; 526 break;
509 } 527 }
510 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 528 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
511 ++phoneIter ) { 529 ++phoneIter ) {
512 removePhoneNumber(( *phoneIter )); 530 removePhoneNumber(( *phoneIter ));
513 } 531 }
514 } 532 }
515 } 533 }
516 // remove non-numeric characters 534 // remove non-numeric characters
517 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 535 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
518 ++phoneIter ) { 536 ++phoneIter ) {
519 if ( ! ( *phoneIter ).simplifyNumber() ) 537 if ( ! ( *phoneIter ).simplifyNumber() )
520 removeNumbers.append( ( *phoneIter ) ); 538 removeNumbers.append( ( *phoneIter ) );
521 } 539 }
522 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 540 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
523 ++phoneIter ) { 541 ++phoneIter ) {
524 removePhoneNumber(( *phoneIter )); 542 removePhoneNumber(( *phoneIter ));
525 } 543 }
526} 544}
527void Addressee::simplifyPhoneNumberTypes() 545void Addressee::simplifyPhoneNumberTypes()
528{ 546{
529 KABC::PhoneNumber::List::Iterator phoneIter; 547 KABC::PhoneNumber::List::Iterator phoneIter;
530 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 548 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
531 ++phoneIter ) 549 ++phoneIter )
532 ( *phoneIter ).simplifyType(); 550 ( *phoneIter ).simplifyType();
533} 551}
534void Addressee::removeID(const QString &prof) 552void Addressee::removeID(const QString &prof)
535{ 553{
536 detach(); 554 detach();
537 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 555 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
538 556
539} 557}
540void Addressee::setID( const QString & prof , const QString & id ) 558void Addressee::setID( const QString & prof , const QString & id )
541{ 559{
542 detach(); 560 detach();
543 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 561 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
544 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 562 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
545} 563}
546void Addressee::setTempSyncStat( int id ) 564void Addressee::setTempSyncStat( int id )
547{ 565{
548 if ( mData->mTempSyncStat == id ) return; 566 if ( mData->mTempSyncStat == id ) return;
549 detach(); 567 detach();
550 mData->mTempSyncStat = id; 568 mData->mTempSyncStat = id;
551} 569}
552int Addressee::tempSyncStat() const 570int Addressee::tempSyncStat() const
553{ 571{
554 return mData->mTempSyncStat; 572 return mData->mTempSyncStat;
555} 573}
556 574
557QString Addressee::getID( const QString & prof) 575QString Addressee::getID( const QString & prof)
558{ 576{
559 return KIdManager::getId ( mData->mExternalId, prof ); 577 return KIdManager::getId ( mData->mExternalId, prof );
560} 578}
561 579
562void Addressee::setCsum( const QString & prof , const QString & id ) 580void Addressee::setCsum( const QString & prof , const QString & id )
563{ 581{
564 detach(); 582 detach();
565 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 583 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
566 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 584 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
567 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 585 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
568} 586}
569 587
570QString Addressee::getCsum( const QString & prof) 588QString Addressee::getCsum( const QString & prof)
571{ 589{
572 return KIdManager::getCsum ( mData->mExternalId, prof ); 590 return KIdManager::getCsum ( mData->mExternalId, prof );
573} 591}
574 592
575void Addressee::setIDStr( const QString & s ) 593void Addressee::setIDStr( const QString & s )
576{ 594{
577 detach(); 595 detach();
578 mData->mExternalId = s; 596 mData->mExternalId = s;
579} 597}
580 598
581QString Addressee::IDStr() const 599QString Addressee::IDStr() const
582{ 600{
583 return mData->mExternalId; 601 return mData->mExternalId;
584} 602}
585 603
586void Addressee::setExternalUID( const QString &id ) 604void Addressee::setExternalUID( const QString &id )
587{ 605{
588 if ( id == mData->externalUID ) return; 606 if ( id == mData->externalUID ) return;
589 detach(); 607 detach();
590 mData->empty = false; 608 mData->empty = false;
591 mData->externalUID = id; 609 mData->externalUID = id;
592} 610}
593 611
594QString Addressee::externalUID() const 612QString Addressee::externalUID() const
595{ 613{
596 return mData->externalUID; 614 return mData->externalUID;
597} 615}
598void Addressee::setOriginalExternalUID( const QString &id ) 616void Addressee::setOriginalExternalUID( const QString &id )
599{ 617{
600 if ( id == mData->originalExternalUID ) return; 618 if ( id == mData->originalExternalUID ) return;
601 detach(); 619 detach();
602 mData->empty = false; 620 mData->empty = false;
603 //qDebug("*******Set orig uid %s ", id.latin1()); 621 //qDebug("*******Set orig uid %s ", id.latin1());
604 mData->originalExternalUID = id; 622 mData->originalExternalUID = id;
605} 623}
606 624
607QString Addressee::originalExternalUID() const 625QString Addressee::originalExternalUID() const
608{ 626{
609 return mData->originalExternalUID; 627 return mData->originalExternalUID;
610} 628}
611 629
612void Addressee::setUid( const QString &id ) 630void Addressee::setUid( const QString &id )
613{ 631{
614 if ( id == mData->uid ) return; 632 if ( id == mData->uid ) return;
615 detach(); 633 detach();
616 //qDebug("****setuid %s ", id.latin1()); 634 //qDebug("****setuid %s ", id.latin1());
617 mData->empty = false; 635 mData->empty = false;
618 mData->uid = id; 636 mData->uid = id;
619} 637}
620 638
621QString Addressee::uid() const 639QString Addressee::uid() const
622{ 640{
623 if ( mData->uid.isEmpty() ) 641 if ( mData->uid.isEmpty() )
624 mData->uid = KApplication::randomString( 10 ); 642 mData->uid = KApplication::randomString( 10 );
625 643
626 return mData->uid; 644 return mData->uid;
627} 645}
628 646
629QString Addressee::uidLabel() 647QString Addressee::uidLabel()
630{ 648{
631 return i18n("Unique Identifier"); 649 return i18n("Unique Identifier");
632} 650}
633 651
634void Addressee::setName( const QString &name ) 652void Addressee::setName( const QString &name )
635{ 653{
636 if ( name == mData->name ) return; 654 if ( name == mData->name ) return;
637 detach(); 655 detach();
638 mData->empty = false; 656 mData->empty = false;
639 mData->name = name; 657 mData->name = name;
640} 658}
641 659
642QString Addressee::name() const 660QString Addressee::name() const
643{ 661{
644 return mData->name; 662 return mData->name;
645} 663}
646 664
647QString Addressee::nameLabel() 665QString Addressee::nameLabel()
648{ 666{
649 return i18n("Name"); 667 return i18n("Name");
650} 668}
651 669
652 670
653void Addressee::setFormattedName( const QString &formattedName ) 671void Addressee::setFormattedName( const QString &formattedName )
654{ 672{
655 if ( formattedName == mData->formattedName ) return; 673 if ( formattedName == mData->formattedName ) return;
656 detach(); 674 detach();
657 mData->empty = false; 675 mData->empty = false;
658 mData->formattedName = formattedName; 676 mData->formattedName = formattedName;
659} 677}
660 678
661QString Addressee::formattedName() const 679QString Addressee::formattedName() const
662{ 680{
663 return mData->formattedName; 681 return mData->formattedName;
664} 682}
665 683
666QString Addressee::formattedNameLabel() 684QString Addressee::formattedNameLabel()
667{ 685{
668 return i18n("Formatted Name"); 686 return i18n("Formatted Name");
669} 687}
670 688
671 689
672void Addressee::setFamilyName( const QString &familyName ) 690void Addressee::setFamilyName( const QString &familyName )
673{ 691{
674 if ( familyName == mData->familyName ) return; 692 if ( familyName == mData->familyName ) return;
675 detach(); 693 detach();
676 mData->empty = false; 694 mData->empty = false;
677 mData->familyName = familyName; 695 mData->familyName = familyName;
678} 696}
679 697
680QString Addressee::familyName() const 698QString Addressee::familyName() const
681{ 699{
682 return mData->familyName; 700 return mData->familyName;
683} 701}
684 702
685QString Addressee::familyNameLabel() 703QString Addressee::familyNameLabel()
686{ 704{
687 return i18n("Family Name"); 705 return i18n("Family Name");
688} 706}
689 707
690 708
691void Addressee::setGivenName( const QString &givenName ) 709void Addressee::setGivenName( const QString &givenName )
692{ 710{
693 if ( givenName == mData->givenName ) return; 711 if ( givenName == mData->givenName ) return;
694 detach(); 712 detach();
695 mData->empty = false; 713 mData->empty = false;
696 mData->givenName = givenName; 714 mData->givenName = givenName;
697} 715}
698 716
699QString Addressee::givenName() const 717QString Addressee::givenName() const
700{ 718{
701 return mData->givenName; 719 return mData->givenName;
702} 720}
703 721
704QString Addressee::givenNameLabel() 722QString Addressee::givenNameLabel()
705{ 723{
706 return i18n("Given Name"); 724 return i18n("Given Name");
707} 725}
708 726
709 727
710void Addressee::setAdditionalName( const QString &additionalName ) 728void Addressee::setAdditionalName( const QString &additionalName )
711{ 729{
712 if ( additionalName == mData->additionalName ) return; 730 if ( additionalName == mData->additionalName ) return;
713 detach(); 731 detach();
714 mData->empty = false; 732 mData->empty = false;
715 mData->additionalName = additionalName; 733 mData->additionalName = additionalName;
716} 734}
717 735
718QString Addressee::additionalName() const 736QString Addressee::additionalName() const
719{ 737{
720 return mData->additionalName; 738 return mData->additionalName;
721} 739}
722 740
723QString Addressee::additionalNameLabel() 741QString Addressee::additionalNameLabel()
724{ 742{
725 return i18n("Additional Names"); 743 return i18n("Additional Names");
726} 744}
727 745
728 746
729void Addressee::setPrefix( const QString &prefix ) 747void Addressee::setPrefix( const QString &prefix )
730{ 748{
731 if ( prefix == mData->prefix ) return; 749 if ( prefix == mData->prefix ) return;
732 detach(); 750 detach();
733 mData->empty = false; 751 mData->empty = false;
734 mData->prefix = prefix; 752 mData->prefix = prefix;
735} 753}
736 754
737QString Addressee::prefix() const 755QString Addressee::prefix() const
738{ 756{
739 return mData->prefix; 757 return mData->prefix;
740} 758}
741 759
742QString Addressee::prefixLabel() 760QString Addressee::prefixLabel()
743{ 761{
744 return i18n("Honorific Prefixes"); 762 return i18n("Honorific Prefixes");
745} 763}
746 764
747 765
748void Addressee::setSuffix( const QString &suffix ) 766void Addressee::setSuffix( const QString &suffix )
749{ 767{
750 if ( suffix == mData->suffix ) return; 768 if ( suffix == mData->suffix ) return;
751 detach(); 769 detach();
752 mData->empty = false; 770 mData->empty = false;
753 mData->suffix = suffix; 771 mData->suffix = suffix;
754} 772}
755 773
756QString Addressee::suffix() const 774QString Addressee::suffix() const
757{ 775{
758 return mData->suffix; 776 return mData->suffix;
759} 777}
760 778
761QString Addressee::suffixLabel() 779QString Addressee::suffixLabel()
762{ 780{
763 return i18n("Honorific Suffixes"); 781 return i18n("Honorific Suffixes");
764} 782}
765 783
766 784
767void Addressee::setNickName( const QString &nickName ) 785void Addressee::setNickName( const QString &nickName )
768{ 786{
769 if ( nickName == mData->nickName ) return; 787 if ( nickName == mData->nickName ) return;
770 detach(); 788 detach();
771 mData->empty = false; 789 mData->empty = false;
772 mData->nickName = nickName; 790 mData->nickName = nickName;
773} 791}
774 792
775QString Addressee::nickName() const 793QString Addressee::nickName() const
776{ 794{
777 return mData->nickName; 795 return mData->nickName;
778} 796}
779 797
780QString Addressee::nickNameLabel() 798QString Addressee::nickNameLabel()
781{ 799{
782 return i18n("Nick Name"); 800 return i18n("Nick Name");
783} 801}
784 802
785 803
786void Addressee::setBirthday( const QDateTime &birthday ) 804void Addressee::setBirthday( const QDateTime &birthday )
787{ 805{
788 if ( birthday == mData->birthday ) return; 806 if ( birthday == mData->birthday ) return;
789 detach(); 807 detach();
790 mData->empty = false; 808 mData->empty = false;
791 mData->birthday = birthday; 809 mData->birthday = birthday;
792} 810}
793 811
794QDateTime Addressee::birthday() const 812QDateTime Addressee::birthday() const
795{ 813{
796 return mData->birthday; 814 return mData->birthday;
797} 815}
798 816
799QString Addressee::birthdayLabel() 817QString Addressee::birthdayLabel()
800{ 818{
801 return i18n("Birthday"); 819 return i18n("Birthday");
802} 820}
803 821
804 822
805QString Addressee::homeAddressStreetLabel() 823QString Addressee::homeAddressStreetLabel()
806{ 824{
807 return i18n("Home Address Street"); 825 return i18n("Home Address Street");
808} 826}
809 827
810 828
811QString Addressee::homeAddressLocalityLabel() 829QString Addressee::homeAddressLocalityLabel()
812{ 830{
813 return i18n("Home Address Locality"); 831 return i18n("Home Address Locality");
814} 832}
815 833
816 834
817QString Addressee::homeAddressRegionLabel() 835QString Addressee::homeAddressRegionLabel()
818{ 836{
819 return i18n("Home Address Region"); 837 return i18n("Home Address Region");
820} 838}
821 839
822 840
823QString Addressee::homeAddressPostalCodeLabel() 841QString Addressee::homeAddressPostalCodeLabel()
824{ 842{
825 return i18n("Home Address Postal Code"); 843 return i18n("Home Address Postal Code");
826} 844}
827 845
828 846
829QString Addressee::homeAddressCountryLabel() 847QString Addressee::homeAddressCountryLabel()
830{ 848{
831 return i18n("Home Address Country"); 849 return i18n("Home Address Country");
832} 850}
833 851
834 852
835QString Addressee::homeAddressLabelLabel() 853QString Addressee::homeAddressLabelLabel()
836{ 854{
837 return i18n("Home Address Label"); 855 return i18n("Home Address Label");
838} 856}
839 857
840 858
841QString Addressee::businessAddressStreetLabel() 859QString Addressee::businessAddressStreetLabel()
842{ 860{
843 return i18n("Business Address Street"); 861 return i18n("Business Address Street");
844} 862}
845 863
846 864
847QString Addressee::businessAddressLocalityLabel() 865QString Addressee::businessAddressLocalityLabel()
848{ 866{
849 return i18n("Business Address Locality"); 867 return i18n("Business Address Locality");
850} 868}
851 869
852 870
853QString Addressee::businessAddressRegionLabel() 871QString Addressee::businessAddressRegionLabel()
854{ 872{
855 return i18n("Business Address Region"); 873 return i18n("Business Address Region");
856} 874}
857 875
858 876
859QString Addressee::businessAddressPostalCodeLabel() 877QString Addressee::businessAddressPostalCodeLabel()
860{ 878{
861 return i18n("Business Address Postal Code"); 879 return i18n("Business Address Postal Code");
862} 880}
863 881
864 882
865QString Addressee::businessAddressCountryLabel() 883QString Addressee::businessAddressCountryLabel()
866{ 884{
867 return i18n("Business Address Country"); 885 return i18n("Business Address Country");
868} 886}
869 887
870 888
871QString Addressee::businessAddressLabelLabel() 889QString Addressee::businessAddressLabelLabel()
872{ 890{
873 return i18n("Business Address Label"); 891 return i18n("Business Address Label");
874} 892}
875 893
876 894
877QString Addressee::homePhoneLabel() 895QString Addressee::homePhoneLabel()
878{ 896{
879 return i18n("Home Phone"); 897 return i18n("Home Phone");
880} 898}
881 899
882 900
883QString Addressee::businessPhoneLabel() 901QString Addressee::businessPhoneLabel()
884{ 902{
885 return i18n("Business Phone"); 903 return i18n("Business Phone");
886} 904}
887 905
888 906
889QString Addressee::mobilePhoneLabel() 907QString Addressee::mobilePhoneLabel()
890{ 908{
891 return i18n("Mobile Phone"); 909 return i18n("Mobile Phone");
892} 910}
893 911
894 912
895QString Addressee::homeFaxLabel() 913QString Addressee::homeFaxLabel()
896{ 914{
897 return i18n("Home Fax"); 915 return i18n("Home Fax");
898} 916}
899 917
900 918
901QString Addressee::businessFaxLabel() 919QString Addressee::businessFaxLabel()
902{ 920{
903 return i18n("Business Fax"); 921 return i18n("Business Fax");
904} 922}
905 923
906 924
907QString Addressee::carPhoneLabel() 925QString Addressee::carPhoneLabel()
908{ 926{
909 return i18n("Car Phone"); 927 return i18n("Car Phone");
910} 928}
911 929
912 930
913QString Addressee::isdnLabel() 931QString Addressee::isdnLabel()
914{ 932{
915 return i18n("ISDN"); 933 return i18n("ISDN");
916} 934}
917 935
918 936
919QString Addressee::pagerLabel() 937QString Addressee::pagerLabel()
920{ 938{
921 return i18n("Pager"); 939 return i18n("Pager");
922} 940}
923 941
924QString Addressee::sipLabel() 942QString Addressee::sipLabel()
925{ 943{
926 return i18n("SIP"); 944 return i18n("SIP");
927} 945}
928 946
929QString Addressee::emailLabel() 947QString Addressee::emailLabel()
930{ 948{
931 return i18n("Email Address"); 949 return i18n("Email Address");
932} 950}
933 951
934 952
935void Addressee::setMailer( const QString &mailer ) 953void Addressee::setMailer( const QString &mailer )
936{ 954{
937 if ( mailer == mData->mailer ) return; 955 if ( mailer == mData->mailer ) return;
938 detach(); 956 detach();
939 mData->empty = false; 957 mData->empty = false;
940 mData->mailer = mailer; 958 mData->mailer = mailer;
941} 959}
942 960
943QString Addressee::mailer() const 961QString Addressee::mailer() const
944{ 962{
945 return mData->mailer; 963 return mData->mailer;
946} 964}
947 965
948QString Addressee::mailerLabel() 966QString Addressee::mailerLabel()
949{ 967{
950 return i18n("Mail Client"); 968 return i18n("Mail Client");
951} 969}
952 970
953 971
954void Addressee::setTimeZone( const TimeZone &timeZone ) 972void Addressee::setTimeZone( const TimeZone &timeZone )
955{ 973{
956 if ( timeZone == mData->timeZone ) return; 974 if ( timeZone == mData->timeZone ) return;
957 detach(); 975 detach();
958 mData->empty = false; 976 mData->empty = false;
959 mData->timeZone = timeZone; 977 mData->timeZone = timeZone;
960} 978}
961 979
962TimeZone Addressee::timeZone() const 980TimeZone Addressee::timeZone() const
963{ 981{
964 return mData->timeZone; 982 return mData->timeZone;
965} 983}
966 984
967QString Addressee::timeZoneLabel() 985QString Addressee::timeZoneLabel()
968{ 986{
969 return i18n("Time Zone"); 987 return i18n("Time Zone");
970} 988}
971 989
972 990
973void Addressee::setGeo( const Geo &geo ) 991void Addressee::setGeo( const Geo &geo )
974{ 992{
975 if ( geo == mData->geo ) return; 993 if ( geo == mData->geo ) return;
976 detach(); 994 detach();
977 mData->empty = false; 995 mData->empty = false;
978 mData->geo = geo; 996 mData->geo = geo;
979} 997}
980 998
981Geo Addressee::geo() const 999Geo Addressee::geo() const
982{ 1000{
983 return mData->geo; 1001 return mData->geo;
984} 1002}
985 1003
986QString Addressee::geoLabel() 1004QString Addressee::geoLabel()
987{ 1005{
988 return i18n("Geographic Position"); 1006 return i18n("Geographic Position");
989} 1007}
990 1008
991 1009
992void Addressee::setTitle( const QString &title ) 1010void Addressee::setTitle( const QString &title )
993{ 1011{
994 if ( title == mData->title ) return; 1012 if ( title == mData->title ) return;
995 detach(); 1013 detach();
996 mData->empty = false; 1014 mData->empty = false;
997 mData->title = title; 1015 mData->title = title;
998} 1016}
999 1017
1000QString Addressee::title() const 1018QString Addressee::title() const
1001{ 1019{
1002 return mData->title; 1020 return mData->title;
1003} 1021}
1004 1022
1005QString Addressee::titleLabel() 1023QString Addressee::titleLabel()
1006{ 1024{
1007 return i18n("Title"); 1025 return i18n("Title");
1008} 1026}
1009 1027
1010 1028
1011void Addressee::setRole( const QString &role ) 1029void Addressee::setRole( const QString &role )
1012{ 1030{
1013 if ( role == mData->role ) return; 1031 if ( role == mData->role ) return;
1014 detach(); 1032 detach();
1015 mData->empty = false; 1033 mData->empty = false;
1016 mData->role = role; 1034 mData->role = role;
1017} 1035}
1018 1036
1019QString Addressee::role() const 1037QString Addressee::role() const
1020{ 1038{
1021 return mData->role; 1039 return mData->role;
1022} 1040}
1023 1041
1024QString Addressee::roleLabel() 1042QString Addressee::roleLabel()
1025{ 1043{
1026 return i18n("Role"); 1044 return i18n("Role");
1027} 1045}
1028 1046
1029 1047
1030void Addressee::setOrganization( const QString &organization ) 1048void Addressee::setOrganization( const QString &organization )
1031{ 1049{
1032 if ( organization == mData->organization ) return; 1050 if ( organization == mData->organization ) return;
1033 detach(); 1051 detach();
1034 mData->empty = false; 1052 mData->empty = false;
1035 mData->organization = organization; 1053 mData->organization = organization;
1036} 1054}
1037 1055
1038QString Addressee::organization() const 1056QString Addressee::organization() const
1039{ 1057{
1040 return mData->organization; 1058 return mData->organization;
1041} 1059}
1042 1060
1043QString Addressee::organizationLabel() 1061QString Addressee::organizationLabel()
1044{ 1062{
1045 return i18n("Organization"); 1063 return i18n("Organization");
1046} 1064}
1047 1065
1048 1066
1049void Addressee::setNote( const QString &note ) 1067void Addressee::setNote( const QString &note )
1050{ 1068{
1051 if ( note == mData->note ) return; 1069 if ( note == mData->note ) return;
1052 detach(); 1070 detach();
1053 mData->empty = false; 1071 mData->empty = false;
1054 mData->note = note; 1072 mData->note = note;
1055} 1073}
1056 1074
1057QString Addressee::note() const 1075QString Addressee::note() const
1058{ 1076{
1059 return mData->note; 1077 return mData->note;
1060} 1078}
1061 1079
1062QString Addressee::noteLabel() 1080QString Addressee::noteLabel()
1063{ 1081{
1064 return i18n("Note"); 1082 return i18n("Note");
1065} 1083}
1066 1084
1067 1085
1068void Addressee::setProductId( const QString &productId ) 1086void Addressee::setProductId( const QString &productId )
1069{ 1087{
1070 if ( productId == mData->productId ) return; 1088 if ( productId == mData->productId ) return;
1071 detach(); 1089 detach();
1072 mData->empty = false; 1090 mData->empty = false;
1073 mData->productId = productId; 1091 mData->productId = productId;
1074} 1092}
1075 1093
1076QString Addressee::productId() const 1094QString Addressee::productId() const
1077{ 1095{
1078 return mData->productId; 1096 return mData->productId;
1079} 1097}
1080 1098
1081QString Addressee::productIdLabel() 1099QString Addressee::productIdLabel()
1082{ 1100{
1083 return i18n("Product Identifier"); 1101 return i18n("Product Identifier");
1084} 1102}
1085 1103
1086 1104
1087void Addressee::setRevision( const QDateTime &revision ) 1105void Addressee::setRevision( const QDateTime &revision )
1088{ 1106{
1089 if ( revision == mData->revision ) return; 1107 if ( revision == mData->revision ) return;
1090 detach(); 1108 detach();
1091 mData->empty = false; 1109 mData->empty = false;
1092 mData->revision = revision; 1110 mData->revision = revision;
1093} 1111}
1094 1112
1095QDateTime Addressee::revision() const 1113QDateTime Addressee::revision() const
1096{ 1114{
1097 return mData->revision; 1115 return mData->revision;
1098} 1116}
1099 1117
1100QString Addressee::revisionLabel() 1118QString Addressee::revisionLabel()
1101{ 1119{
1102 return i18n("Revision Date"); 1120 return i18n("Revision Date");
1103} 1121}
1104 1122
1105 1123
1106void Addressee::setSortString( const QString &sortString ) 1124void Addressee::setSortString( const QString &sortString )
1107{ 1125{
1108 if ( sortString == mData->sortString ) return; 1126 if ( sortString == mData->sortString ) return;
1109 detach(); 1127 detach();
1110 mData->empty = false; 1128 mData->empty = false;
1111 mData->sortString = sortString; 1129 mData->sortString = sortString;
1112} 1130}
1113 1131
1114QString Addressee::sortString() const 1132QString Addressee::sortString() const
1115{ 1133{
1116 return mData->sortString; 1134 return mData->sortString;
1117} 1135}
1118 1136
1119QString Addressee::sortStringLabel() 1137QString Addressee::sortStringLabel()
1120{ 1138{
1121 return i18n("Sort String"); 1139 return i18n("Sort String");
1122} 1140}
1123 1141
1124 1142
1125void Addressee::setUrl( const KURL &url ) 1143void Addressee::setUrl( const KURL &url )
1126{ 1144{
1127 if ( url == mData->url ) return; 1145 if ( url == mData->url ) return;
1128 detach(); 1146 detach();
1129 mData->empty = false; 1147 mData->empty = false;
1130 mData->url = url; 1148 mData->url = url;
1131} 1149}
1132 1150
1133KURL Addressee::url() const 1151KURL Addressee::url() const
1134{ 1152{
1135 return mData->url; 1153 return mData->url;
1136} 1154}
1137 1155
1138QString Addressee::urlLabel() 1156QString Addressee::urlLabel()
1139{ 1157{
1140 return i18n("URL"); 1158 return i18n("URL");
1141} 1159}
1142 1160
1143 1161
1144void Addressee::setSecrecy( const Secrecy &secrecy ) 1162void Addressee::setSecrecy( const Secrecy &secrecy )
1145{ 1163{
1146 if ( secrecy == mData->secrecy ) return; 1164 if ( secrecy == mData->secrecy ) return;
1147 detach(); 1165 detach();
1148 mData->empty = false; 1166 mData->empty = false;
1149 mData->secrecy = secrecy; 1167 mData->secrecy = secrecy;
1150} 1168}
1151 1169
1152Secrecy Addressee::secrecy() const 1170Secrecy Addressee::secrecy() const
1153{ 1171{
1154 return mData->secrecy; 1172 return mData->secrecy;
1155} 1173}
1156 1174
1157QString Addressee::secrecyLabel() 1175QString Addressee::secrecyLabel()
1158{ 1176{
1159 return i18n("Security Class"); 1177 return i18n("Security Class");
1160} 1178}
1161 1179
1162 1180
1163void Addressee::setLogo( const Picture &logo ) 1181void Addressee::setLogo( const Picture &logo )
1164{ 1182{
1165 if ( logo == mData->logo ) return; 1183 if ( logo == mData->logo ) return;
1166 detach(); 1184 detach();
1167 mData->empty = false; 1185 mData->empty = false;
1168 mData->logo = logo; 1186 mData->logo = logo;
1169} 1187}
1170 1188
1171Picture Addressee::logo() const 1189Picture Addressee::logo() const
1172{ 1190{
1173 return mData->logo; 1191 return mData->logo;
1174} 1192}
1175 1193
1176QString Addressee::logoLabel() 1194QString Addressee::logoLabel()
1177{ 1195{
1178 return i18n("Logo"); 1196 return i18n("Logo");
1179} 1197}
1180 1198
1181 1199
1182void Addressee::setPhoto( const Picture &photo ) 1200void Addressee::setPhoto( const Picture &photo )
1183{ 1201{
1184 if ( photo == mData->photo ) return; 1202 if ( photo == mData->photo ) return;
1185 detach(); 1203 detach();
1186 mData->empty = false; 1204 mData->empty = false;
1187 mData->photo = photo; 1205 mData->photo = photo;
1188} 1206}
1189 1207
1190Picture Addressee::photo() const 1208Picture Addressee::photo() const
1191{ 1209{
1192 return mData->photo; 1210 return mData->photo;
1193} 1211}
1194 1212
1195QString Addressee::photoLabel() 1213QString Addressee::photoLabel()
1196{ 1214{
1197 return i18n("Photo"); 1215 return i18n("Photo");
1198} 1216}
1199 1217
1200 1218
1201void Addressee::setSound( const Sound &sound ) 1219void Addressee::setSound( const Sound &sound )
1202{ 1220{
1203 if ( sound == mData->sound ) return; 1221 if ( sound == mData->sound ) return;
1204 detach(); 1222 detach();
1205 mData->empty = false; 1223 mData->empty = false;
1206 mData->sound = sound; 1224 mData->sound = sound;
1207} 1225}
1208 1226
1209Sound Addressee::sound() const 1227Sound Addressee::sound() const
1210{ 1228{
1211 return mData->sound; 1229 return mData->sound;
1212} 1230}
1213 1231
1214QString Addressee::soundLabel() 1232QString Addressee::soundLabel()
1215{ 1233{
1216 return i18n("Sound"); 1234 return i18n("Sound");
1217} 1235}
1218 1236
1219 1237
1220void Addressee::setAgent( const Agent &agent ) 1238void Addressee::setAgent( const Agent &agent )
1221{ 1239{
1222 if ( agent == mData->agent ) return; 1240 if ( agent == mData->agent ) return;
1223 detach(); 1241 detach();
1224 mData->empty = false; 1242 mData->empty = false;
1225 mData->agent = agent; 1243 mData->agent = agent;
1226} 1244}
1227 1245
1228Agent Addressee::agent() const 1246Agent Addressee::agent() const
1229{ 1247{
1230 return mData->agent; 1248 return mData->agent;
1231} 1249}
1232 1250
1233QString Addressee::agentLabel() 1251QString Addressee::agentLabel()
1234{ 1252{
1235 return i18n("Agent"); 1253 return i18n("Agent");
1236} 1254}
1237 1255
1238 1256
1239 1257
1240void Addressee::setNameFromString( const QString &str ) 1258void Addressee::setNameFromString( const QString &str )
1241{ 1259{
1242 setFormattedName( str ); 1260 setFormattedName( str );
1243 setName( str ); 1261 setName( str );
1244 1262
1245 static bool first = true; 1263 static bool first = true;
1246 static QStringList titles; 1264 static QStringList titles;
1247 static QStringList suffixes; 1265 static QStringList suffixes;
1248 static QStringList prefixes; 1266 static QStringList prefixes;
1249 1267
1250 if ( first ) { 1268 if ( first ) {
1251 first = false; 1269 first = false;
1252 titles += i18n( "Dr." ); 1270 titles += i18n( "Dr." );
1253 titles += i18n( "Miss" ); 1271 titles += i18n( "Miss" );
1254 titles += i18n( "Mr." ); 1272 titles += i18n( "Mr." );
1255 titles += i18n( "Mrs." ); 1273 titles += i18n( "Mrs." );
1256 titles += i18n( "Ms." ); 1274 titles += i18n( "Ms." );
1257 titles += i18n( "Prof." ); 1275 titles += i18n( "Prof." );
1258 1276
1259 suffixes += i18n( "I" ); 1277 suffixes += i18n( "I" );
1260 suffixes += i18n( "II" ); 1278 suffixes += i18n( "II" );
1261 suffixes += i18n( "III" ); 1279 suffixes += i18n( "III" );
1262 suffixes += i18n( "Jr." ); 1280 suffixes += i18n( "Jr." );
1263 suffixes += i18n( "Sr." ); 1281 suffixes += i18n( "Sr." );
1264 1282
1265 prefixes += "van"; 1283 prefixes += "van";
1266 prefixes += "von"; 1284 prefixes += "von";
1267 prefixes += "de"; 1285 prefixes += "de";
1268 1286
1269 KConfig config( locateLocal( "config", "kabcrc") ); 1287 KConfig config( locateLocal( "config", "kabcrc") );
1270 config.setGroup( "General" ); 1288 config.setGroup( "General" );
1271 titles += config.readListEntry( "Prefixes" ); 1289 titles += config.readListEntry( "Prefixes" );
1272 titles.remove( "" ); 1290 titles.remove( "" );
1273 prefixes += config.readListEntry( "Inclusions" ); 1291 prefixes += config.readListEntry( "Inclusions" );
1274 prefixes.remove( "" ); 1292 prefixes.remove( "" );
1275 suffixes += config.readListEntry( "Suffixes" ); 1293 suffixes += config.readListEntry( "Suffixes" );
1276 suffixes.remove( "" ); 1294 suffixes.remove( "" );
1277 } 1295 }
1278 1296
1279 // clear all name parts 1297 // clear all name parts
1280 setPrefix( "" ); 1298 setPrefix( "" );
1281 setGivenName( "" ); 1299 setGivenName( "" );
1282 setAdditionalName( "" ); 1300 setAdditionalName( "" );
1283 setFamilyName( "" ); 1301 setFamilyName( "" );
1284 setSuffix( "" ); 1302 setSuffix( "" );
1285 1303
1286 if ( str.isEmpty() ) 1304 if ( str.isEmpty() )
1287 return; 1305 return;
1288 1306
1289 int i = str.find(','); 1307 int i = str.find(',');
1290 if( i < 0 ) { 1308 if( i < 0 ) {
1291 QStringList parts = QStringList::split( " ", str ); 1309 QStringList parts = QStringList::split( " ", str );
1292 int leftOffset = 0; 1310 int leftOffset = 0;
1293 int rightOffset = parts.count() - 1; 1311 int rightOffset = parts.count() - 1;
1294 1312
1295 QString suffix; 1313 QString suffix;
1296 while ( rightOffset >= 0 ) { 1314 while ( rightOffset >= 0 ) {
1297 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1315 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1298 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1316 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1299 rightOffset--; 1317 rightOffset--;
1300 } else 1318 } else
1301 break; 1319 break;
1302 } 1320 }
1303 setSuffix( suffix ); 1321 setSuffix( suffix );
1304 1322
1305 if ( rightOffset < 0 ) 1323 if ( rightOffset < 0 )
1306 return; 1324 return;
1307 1325
1308 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1326 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1309 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1327 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1310 rightOffset--; 1328 rightOffset--;
1311 } else 1329 } else
1312 setFamilyName( parts[ rightOffset ] ); 1330 setFamilyName( parts[ rightOffset ] );
1313 1331
1314 QString prefix; 1332 QString prefix;
1315 while ( leftOffset < rightOffset ) { 1333 while ( leftOffset < rightOffset ) {
1316 if ( titles.contains( parts[ leftOffset ] ) ) { 1334 if ( titles.contains( parts[ leftOffset ] ) ) {
1317 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1335 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1318 leftOffset++; 1336 leftOffset++;
1319 } else 1337 } else
1320 break; 1338 break;
1321 } 1339 }
1322 setPrefix( prefix ); 1340 setPrefix( prefix );
1323 1341
1324 if ( leftOffset < rightOffset ) { 1342 if ( leftOffset < rightOffset ) {
1325 setGivenName( parts[ leftOffset ] ); 1343 setGivenName( parts[ leftOffset ] );
1326 leftOffset++; 1344 leftOffset++;
1327 } 1345 }
1328 1346
1329 QString additionalName; 1347 QString additionalName;
1330 while ( leftOffset < rightOffset ) { 1348 while ( leftOffset < rightOffset ) {
1331 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1349 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1332 leftOffset++; 1350 leftOffset++;
1333 } 1351 }
1334 setAdditionalName( additionalName ); 1352 setAdditionalName( additionalName );
1335 } else { 1353 } else {
1336 QString part1 = str.left( i ); 1354 QString part1 = str.left( i );
1337 QString part2 = str.mid( i + 1 ); 1355 QString part2 = str.mid( i + 1 );
1338 1356
1339 QStringList parts = QStringList::split( " ", part1 ); 1357 QStringList parts = QStringList::split( " ", part1 );
1340 int leftOffset = 0; 1358 int leftOffset = 0;
1341 int rightOffset = parts.count() - 1; 1359 int rightOffset = parts.count() - 1;
1342 1360
1343 QString suffix; 1361 QString suffix;
1344 while ( rightOffset >= 0 ) { 1362 while ( rightOffset >= 0 ) {
1345 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1363 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1346 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1364 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1347 rightOffset--; 1365 rightOffset--;
1348 } else 1366 } else
1349 break; 1367 break;
1350 } 1368 }
1351 setSuffix( suffix ); 1369 setSuffix( suffix );
1352 1370
1353 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1371 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1354 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1372 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1355 rightOffset--; 1373 rightOffset--;
1356 } else 1374 } else
1357 setFamilyName( parts[ rightOffset ] ); 1375 setFamilyName( parts[ rightOffset ] );
1358 1376
1359 QString prefix; 1377 QString prefix;
1360 while ( leftOffset < rightOffset ) { 1378 while ( leftOffset < rightOffset ) {
1361 if ( titles.contains( parts[ leftOffset ] ) ) { 1379 if ( titles.contains( parts[ leftOffset ] ) ) {
1362 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1380 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1363 leftOffset++; 1381 leftOffset++;
1364 } else 1382 } else
1365 break; 1383 break;
1366 } 1384 }
1367 1385
1368 parts = QStringList::split( " ", part2 ); 1386 parts = QStringList::split( " ", part2 );
1369 1387
1370 leftOffset = 0; 1388 leftOffset = 0;
1371 rightOffset = parts.count(); 1389 rightOffset = parts.count();
1372 1390
1373 while ( leftOffset < rightOffset ) { 1391 while ( leftOffset < rightOffset ) {
1374 if ( titles.contains( parts[ leftOffset ] ) ) { 1392 if ( titles.contains( parts[ leftOffset ] ) ) {
1375 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1393 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1376 leftOffset++; 1394 leftOffset++;
1377 } else 1395 } else
1378 break; 1396 break;
1379 } 1397 }
1380 setPrefix( prefix ); 1398 setPrefix( prefix );
1381 1399
1382 if ( leftOffset < rightOffset ) { 1400 if ( leftOffset < rightOffset ) {
1383 setGivenName( parts[ leftOffset ] ); 1401 setGivenName( parts[ leftOffset ] );
1384 leftOffset++; 1402 leftOffset++;
1385 } 1403 }
1386 1404
1387 QString additionalName; 1405 QString additionalName;
1388 while ( leftOffset < rightOffset ) { 1406 while ( leftOffset < rightOffset ) {
1389 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1407 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1390 leftOffset++; 1408 leftOffset++;
1391 } 1409 }
1392 setAdditionalName( additionalName ); 1410 setAdditionalName( additionalName );
1393 } 1411 }
1394} 1412}
1395 1413
1396QString Addressee::realName() const 1414QString Addressee::realName() const
1397{ 1415{
1398 if ( !formattedName().isEmpty() ) 1416 if ( !formattedName().isEmpty() )
1399 return formattedName(); 1417 return formattedName();
1400 1418
1401 QString n = assembledName(); 1419 QString n = assembledName();
1402 1420
1403 if ( n.isEmpty() ) 1421 if ( n.isEmpty() )
1404 n = name(); 1422 n = name();
1405 1423
1406 return n; 1424 return n;
1407} 1425}
1408 1426
1409QString Addressee::assembledName() const 1427QString Addressee::assembledName() const
1410{ 1428{
1411 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1429 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1412 familyName() + " " + suffix(); 1430 familyName() + " " + suffix();
1413 1431
1414 return name.simplifyWhiteSpace(); 1432 return name.simplifyWhiteSpace();
1415} 1433}
1416 1434
1417QString Addressee::fullEmail( const QString &email ) const 1435QString Addressee::fullEmail( const QString &email ) const
1418{ 1436{
1419 QString e; 1437 QString e;
1420 if ( email.isNull() ) { 1438 if ( email.isNull() ) {
1421 e = preferredEmail(); 1439 e = preferredEmail();
1422 } else { 1440 } else {
1423 e = email; 1441 e = email;
1424 } 1442 }
1425 if ( e.isEmpty() ) return QString::null; 1443 if ( e.isEmpty() ) return QString::null;
1426 1444
1427 QString text; 1445 QString text;
1428 if ( realName().isEmpty() ) 1446 if ( realName().isEmpty() )
1429 text = e; 1447 text = e;
1430 else 1448 else
1431 text = assembledName() + " <" + e + ">"; 1449 text = assembledName() + " <" + e + ">";
1432 1450
1433 return text; 1451 return text;
1434} 1452}
1435 1453
1436void Addressee::insertEmail( const QString &email, bool preferred ) 1454void Addressee::insertEmail( const QString &email, bool preferred )
1437{ 1455{
1438 detach(); 1456 detach();
1439 1457
1440 QStringList::Iterator it = mData->emails.find( email ); 1458 QStringList::Iterator it = mData->emails.find( email );
1441 1459
1442 if ( it != mData->emails.end() ) { 1460 if ( it != mData->emails.end() ) {
1443 if ( !preferred || it == mData->emails.begin() ) return; 1461 if ( !preferred || it == mData->emails.begin() ) return;
1444 mData->emails.remove( it ); 1462 mData->emails.remove( it );
1445 mData->emails.prepend( email ); 1463 mData->emails.prepend( email );
1446 } else { 1464 } else {
1447 if ( preferred ) { 1465 if ( preferred ) {
1448 mData->emails.prepend( email ); 1466 mData->emails.prepend( email );
1449 } else { 1467 } else {
1450 mData->emails.append( email ); 1468 mData->emails.append( email );
1451 } 1469 }
1452 } 1470 }
1453} 1471}
1454 1472
1455void Addressee::removeEmail( const QString &email ) 1473void Addressee::removeEmail( const QString &email )
1456{ 1474{
1457 detach(); 1475 detach();
1458 1476
1459 QStringList::Iterator it = mData->emails.find( email ); 1477 QStringList::Iterator it = mData->emails.find( email );
1460 if ( it == mData->emails.end() ) return; 1478 if ( it == mData->emails.end() ) return;
1461 1479
1462 mData->emails.remove( it ); 1480 mData->emails.remove( it );
1463} 1481}
1464 1482
1465QString Addressee::preferredEmail() const 1483QString Addressee::preferredEmail() const
1466{ 1484{
1467 if ( mData->emails.count() == 0 ) return QString::null; 1485 if ( mData->emails.count() == 0 ) return QString::null;
1468 else return mData->emails.first(); 1486 else return mData->emails.first();
1469} 1487}
1470 1488
1471QStringList Addressee::emails() const 1489QStringList Addressee::emails() const
1472{ 1490{
1473 return mData->emails; 1491 return mData->emails;
1474} 1492}
1475void Addressee::setEmails( const QStringList& emails ) { 1493void Addressee::setEmails( const QStringList& emails ) {
1476 detach(); 1494 detach();
1477 mData->emails = emails; 1495 mData->emails = emails;
1478} 1496}
1479void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1497void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1480{ 1498{
1481 detach(); 1499 detach();
1482 mData->empty = false; 1500 mData->empty = false;
1483 1501
1484 PhoneNumber::List::Iterator it; 1502 PhoneNumber::List::Iterator it;
1485 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1503 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1486 if ( (*it).id() == phoneNumber.id() ) { 1504 if ( (*it).id() == phoneNumber.id() ) {
1487 *it = phoneNumber; 1505 *it = phoneNumber;
1488 return; 1506 return;
1489 } 1507 }
1490 } 1508 }
1491 mData->phoneNumbers.append( phoneNumber ); 1509 mData->phoneNumbers.append( phoneNumber );
1492} 1510}
1493 1511
1494void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1512void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1495{ 1513{
1496 detach(); 1514 detach();
1497 1515
1498 PhoneNumber::List::Iterator it; 1516 PhoneNumber::List::Iterator it;
1499 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1517 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1500 if ( (*it).id() == phoneNumber.id() ) { 1518 if ( (*it).id() == phoneNumber.id() ) {
1501 mData->phoneNumbers.remove( it ); 1519 mData->phoneNumbers.remove( it );
1502 return; 1520 return;
1503 } 1521 }
1504 } 1522 }
1505} 1523}
1506 1524
1507PhoneNumber Addressee::phoneNumber( int type ) const 1525PhoneNumber Addressee::phoneNumber( int type ) const
1508{ 1526{
1509 PhoneNumber phoneNumber( "", type ); 1527 PhoneNumber phoneNumber( "", type );
1510 PhoneNumber::List::ConstIterator it; 1528 PhoneNumber::List::ConstIterator it;
1511 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1529 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1512 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1530 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1513 if ( (*it).type() & PhoneNumber::Pref ) 1531 if ( (*it).type() & PhoneNumber::Pref )
1514 return (*it); 1532 return (*it);
1515 else if ( phoneNumber.number().isEmpty() ) 1533 else if ( phoneNumber.number().isEmpty() )
1516 phoneNumber = (*it); 1534 phoneNumber = (*it);
1517 } 1535 }
1518 } 1536 }
1519 1537
1520 return phoneNumber; 1538 return phoneNumber;
1521} 1539}
1522 1540
1523PhoneNumber::List Addressee::phoneNumbers() const 1541PhoneNumber::List Addressee::phoneNumbers() const
1524{ 1542{
1525 return mData->phoneNumbers; 1543 return mData->phoneNumbers;
1526} 1544}
1527 1545
1528PhoneNumber::List Addressee::phoneNumbers( int type ) const 1546PhoneNumber::List Addressee::phoneNumbers( int type ) const
1529{ 1547{
1530 PhoneNumber::List list; 1548 PhoneNumber::List list;
1531 1549
1532 PhoneNumber::List::ConstIterator it; 1550 PhoneNumber::List::ConstIterator it;
1533 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1551 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1534 if ( matchBinaryPattern( (*it).type(), type ) ) { 1552 if ( matchBinaryPattern( (*it).type(), type ) ) {
1535 list.append( *it ); 1553 list.append( *it );
1536 } 1554 }
1537 } 1555 }
1538 return list; 1556 return list;
1539} 1557}
1540 1558
1541PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1559PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1542{ 1560{
1543 PhoneNumber::List::ConstIterator it; 1561 PhoneNumber::List::ConstIterator it;
1544 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1562 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1545 if ( (*it).id() == id ) { 1563 if ( (*it).id() == id ) {
1546 return *it; 1564 return *it;
1547 } 1565 }
1548 } 1566 }
1549 return PhoneNumber(); 1567 return PhoneNumber();
1550} 1568}
1551 1569
1552void Addressee::insertKey( const Key &key ) 1570void Addressee::insertKey( const Key &key )
1553{ 1571{
1554 detach(); 1572 detach();
1555 mData->empty = false; 1573 mData->empty = false;
1556 1574
1557 Key::List::Iterator it; 1575 Key::List::Iterator it;
1558 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1576 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1559 if ( (*it).id() == key.id() ) { 1577 if ( (*it).id() == key.id() ) {
1560 *it = key; 1578 *it = key;
1561 return; 1579 return;
1562 } 1580 }
1563 } 1581 }
1564 mData->keys.append( key ); 1582 mData->keys.append( key );
1565} 1583}
1566 1584
1567void Addressee::removeKey( const Key &key ) 1585void Addressee::removeKey( const Key &key )
1568{ 1586{
1569 detach(); 1587 detach();
1570 1588
1571 Key::List::Iterator it; 1589 Key::List::Iterator it;
1572 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1590 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1573 if ( (*it).id() == key.id() ) { 1591 if ( (*it).id() == key.id() ) {
1574 mData->keys.remove( key ); 1592 mData->keys.remove( key );
1575 return; 1593 return;
1576 } 1594 }
1577 } 1595 }
1578} 1596}
1579 1597
1580Key Addressee::key( int type, QString customTypeString ) const 1598Key Addressee::key( int type, QString customTypeString ) const
1581{ 1599{
1582 Key::List::ConstIterator it; 1600 Key::List::ConstIterator it;
1583 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1601 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1584 if ( (*it).type() == type ) { 1602 if ( (*it).type() == type ) {
1585 if ( type == Key::Custom ) { 1603 if ( type == Key::Custom ) {
1586 if ( customTypeString.isEmpty() ) { 1604 if ( customTypeString.isEmpty() ) {
1587 return *it; 1605 return *it;
1588 } else { 1606 } else {
1589 if ( (*it).customTypeString() == customTypeString ) 1607 if ( (*it).customTypeString() == customTypeString )
1590 return (*it); 1608 return (*it);
1591 } 1609 }
1592 } else { 1610 } else {
1593 return *it; 1611 return *it;
1594 } 1612 }
1595 } 1613 }
1596 } 1614 }
1597 return Key( QString(), type ); 1615 return Key( QString(), type );
1598} 1616}
1599void Addressee::setKeys( const Key::List& list ) { 1617void Addressee::setKeys( const Key::List& list ) {
1600 detach(); 1618 detach();
1601 mData->keys = list; 1619 mData->keys = list;
1602} 1620}
1603 1621
1604Key::List Addressee::keys() const 1622Key::List Addressee::keys() const
1605{ 1623{
1606 return mData->keys; 1624 return mData->keys;
1607} 1625}
1608 1626
1609Key::List Addressee::keys( int type, QString customTypeString ) const 1627Key::List Addressee::keys( int type, QString customTypeString ) const
1610{ 1628{
1611 Key::List list; 1629 Key::List list;
1612 1630
1613 Key::List::ConstIterator it; 1631 Key::List::ConstIterator it;
1614 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1632 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1615 if ( (*it).type() == type ) { 1633 if ( (*it).type() == type ) {
1616 if ( type == Key::Custom ) { 1634 if ( type == Key::Custom ) {
1617 if ( customTypeString.isEmpty() ) { 1635 if ( customTypeString.isEmpty() ) {
1618 list.append(*it); 1636 list.append(*it);
1619 } else { 1637 } else {
1620 if ( (*it).customTypeString() == customTypeString ) 1638 if ( (*it).customTypeString() == customTypeString )
1621 list.append(*it); 1639 list.append(*it);
1622 } 1640 }
1623 } else { 1641 } else {
1624 list.append(*it); 1642 list.append(*it);
1625 } 1643 }
1626 } 1644 }
1627 } 1645 }
1628 return list; 1646 return list;
1629} 1647}
1630 1648
1631Key Addressee::findKey( const QString &id ) const 1649Key Addressee::findKey( const QString &id ) const
1632{ 1650{
1633 Key::List::ConstIterator it; 1651 Key::List::ConstIterator it;
1634 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1652 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1635 if ( (*it).id() == id ) { 1653 if ( (*it).id() == id ) {
1636 return *it; 1654 return *it;
1637 } 1655 }
1638 } 1656 }
1639 return Key(); 1657 return Key();
1640} 1658}
1641 1659
1642QString Addressee::asString() const 1660QString Addressee::asString() const
1643{ 1661{
1644 return "Smith, agent Smith..."; 1662 return "Smith, agent Smith...";
1645} 1663}
1646 1664
1647void Addressee::dump() const 1665void Addressee::dump() const
1648{ 1666{
1649 return; 1667 return;
1650 kdDebug(5700) << "Addressee {" << endl; 1668 kdDebug(5700) << "Addressee {" << endl;
1651 1669
1652 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1670 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1653 1671
1654 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1672 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1655 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1673 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1656 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1674 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1657 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1675 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1658 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1676 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1659 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1677 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1660 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1678 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1661 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1679 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1662 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1680 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1663 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1681 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1664 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1682 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1665 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1683 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1666 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1684 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1667 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1685 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1668 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1686 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1669 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1687 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1670 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1688 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1671 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1689 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1672 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1690 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1673 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1691 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1674 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1692 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1675 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1693 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1676 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1694 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1677 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1695 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1678 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1696 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1679 1697
1680 kdDebug(5700) << " Emails {" << endl; 1698 kdDebug(5700) << " Emails {" << endl;
1681 QStringList e = emails(); 1699 QStringList e = emails();
1682 QStringList::ConstIterator it; 1700 QStringList::ConstIterator it;
1683 for( it = e.begin(); it != e.end(); ++it ) { 1701 for( it = e.begin(); it != e.end(); ++it ) {
1684 kdDebug(5700) << " " << (*it) << endl; 1702 kdDebug(5700) << " " << (*it) << endl;
1685 } 1703 }
1686 kdDebug(5700) << " }" << endl; 1704 kdDebug(5700) << " }" << endl;
1687 1705
1688 kdDebug(5700) << " PhoneNumbers {" << endl; 1706 kdDebug(5700) << " PhoneNumbers {" << endl;
1689 PhoneNumber::List p = phoneNumbers(); 1707 PhoneNumber::List p = phoneNumbers();
1690 PhoneNumber::List::ConstIterator it2; 1708 PhoneNumber::List::ConstIterator it2;
1691 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1709 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1692 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1710 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1693 } 1711 }
1694 kdDebug(5700) << " }" << endl; 1712 kdDebug(5700) << " }" << endl;
1695 1713
1696 Address::List a = addresses(); 1714 Address::List a = addresses();
1697 Address::List::ConstIterator it3; 1715 Address::List::ConstIterator it3;
1698 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1716 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1699 (*it3).dump(); 1717 (*it3).dump();
1700 } 1718 }
1701 1719
1702 kdDebug(5700) << " Keys {" << endl; 1720 kdDebug(5700) << " Keys {" << endl;
1703 Key::List k = keys(); 1721 Key::List k = keys();
1704 Key::List::ConstIterator it4; 1722 Key::List::ConstIterator it4;
1705 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1723 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1706 kdDebug(5700) << " Type: " << int((*it4).type()) << 1724 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1707 " Key: " << (*it4).textData() << 1725 " Key: " << (*it4).textData() <<
1708 " CustomString: " << (*it4).customTypeString() << endl; 1726 " CustomString: " << (*it4).customTypeString() << endl;
1709 } 1727 }
1710 kdDebug(5700) << " }" << endl; 1728 kdDebug(5700) << " }" << endl;
1711 1729
1712 kdDebug(5700) << "}" << endl; 1730 kdDebug(5700) << "}" << endl;
1713} 1731}
1714 1732
1715 1733
1716void Addressee::insertAddress( const Address &address ) 1734void Addressee::insertAddress( const Address &address )
1717{ 1735{
1718 detach(); 1736 detach();
1719 mData->empty = false; 1737 mData->empty = false;
1720 1738
1721 Address::List::Iterator it; 1739 Address::List::Iterator it;
1722 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1740 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1723 if ( (*it).id() == address.id() ) { 1741 if ( (*it).id() == address.id() ) {
1724 *it = address; 1742 *it = address;
1725 return; 1743 return;
1726 } 1744 }
1727 } 1745 }
1728 mData->addresses.append( address ); 1746 mData->addresses.append( address );
1729} 1747}
1730 1748
1731void Addressee::removeAddress( const Address &address ) 1749void Addressee::removeAddress( const Address &address )
1732{ 1750{
1733 detach(); 1751 detach();
1734 1752
1735 Address::List::Iterator it; 1753 Address::List::Iterator it;
1736 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1754 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1737 if ( (*it).id() == address.id() ) { 1755 if ( (*it).id() == address.id() ) {
1738 mData->addresses.remove( it ); 1756 mData->addresses.remove( it );
1739 return; 1757 return;
1740 } 1758 }
1741 } 1759 }
1742} 1760}
1743 1761
1744Address Addressee::address( int type ) const 1762Address Addressee::address( int type ) const
1745{ 1763{
1746 Address address( type ); 1764 Address address( type );
1747 Address::List::ConstIterator it; 1765 Address::List::ConstIterator it;
1748 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1766 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1749 if ( matchBinaryPatternA( (*it).type(), type ) ) { 1767 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1750 if ( (*it).type() & Address::Pref ) 1768 if ( (*it).type() & Address::Pref )
1751 return (*it); 1769 return (*it);
1752 else if ( address.isEmpty() ) 1770 else if ( address.isEmpty() )
1753 address = (*it); 1771 address = (*it);
1754 } 1772 }
1755 } 1773 }
1756 1774
1757 return address; 1775 return address;
1758} 1776}
1759 1777
1760Address::List Addressee::addresses() const 1778Address::List Addressee::addresses() const
1761{ 1779{
1762 return mData->addresses; 1780 return mData->addresses;
1763} 1781}
1764 1782
1765Address::List Addressee::addresses( int type ) const 1783Address::List Addressee::addresses( int type ) const
1766{ 1784{
1767 Address::List list; 1785 Address::List list;
1768 1786
1769 Address::List::ConstIterator it; 1787 Address::List::ConstIterator it;
1770 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1788 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1771 if ( matchBinaryPattern( (*it).type(), type ) ) { 1789 if ( matchBinaryPattern( (*it).type(), type ) ) {
1772 list.append( *it ); 1790 list.append( *it );
1773 } 1791 }
1774 } 1792 }
1775 1793
1776 return list; 1794 return list;
1777} 1795}
1778 1796
1779Address Addressee::findAddress( const QString &id ) const 1797Address Addressee::findAddress( const QString &id ) const
1780{ 1798{
1781 Address::List::ConstIterator it; 1799 Address::List::ConstIterator it;
1782 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1800 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1783 if ( (*it).id() == id ) { 1801 if ( (*it).id() == id ) {
1784 return *it; 1802 return *it;
1785 } 1803 }
1786 } 1804 }
1787 return Address(); 1805 return Address();
1788} 1806}
1789 1807
1790void Addressee::insertCategory( const QString &c ) 1808void Addressee::insertCategory( const QString &c )
1791{ 1809{
1792 detach(); 1810 detach();
1793 mData->empty = false; 1811 mData->empty = false;
1794 1812
1795 if ( mData->categories.contains( c ) ) return; 1813 if ( mData->categories.contains( c ) ) return;
1796 1814
1797 mData->categories.append( c ); 1815 mData->categories.append( c );
1798} 1816}
1799 1817
1800void Addressee::removeCategory( const QString &c ) 1818void Addressee::removeCategory( const QString &c )
1801{ 1819{
1802 detach(); 1820 detach();
1803 1821
1804 QStringList::Iterator it = mData->categories.find( c ); 1822 QStringList::Iterator it = mData->categories.find( c );
1805 if ( it == mData->categories.end() ) return; 1823 if ( it == mData->categories.end() ) return;
1806 1824
1807 mData->categories.remove( it ); 1825 mData->categories.remove( it );
1808} 1826}
1809 1827
1810bool Addressee::hasCategory( const QString &c ) const 1828bool Addressee::hasCategory( const QString &c ) const
1811{ 1829{
1812 return ( mData->categories.contains( c ) ); 1830 return ( mData->categories.contains( c ) );
1813} 1831}
1814 1832
1815void Addressee::setCategories( const QStringList &c ) 1833void Addressee::setCategories( const QStringList &c )
1816{ 1834{
1817 detach(); 1835 detach();
1818 mData->empty = false; 1836 mData->empty = false;
1819 1837
1820 mData->categories = c; 1838 mData->categories = c;
1821} 1839}
1822 1840
1823QStringList Addressee::categories() const 1841QStringList Addressee::categories() const
1824{ 1842{
1825 return mData->categories; 1843 return mData->categories;
1826} 1844}
1827 1845
1828void Addressee::insertCustom( const QString &app, const QString &name, 1846void Addressee::insertCustom( const QString &app, const QString &name,
1829 const QString &value ) 1847 const QString &value )
1830{ 1848{
1831 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 1849 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
1832 1850
1833 detach(); 1851 detach();
1834 mData->empty = false; 1852 mData->empty = false;
1835 1853
1836 QString qualifiedName = app + "-" + name + ":"; 1854 QString qualifiedName = app + "-" + name + ":";
1837 1855
1838 QStringList::Iterator it; 1856 QStringList::Iterator it;
1839 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1857 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1840 if ( (*it).startsWith( qualifiedName ) ) { 1858 if ( (*it).startsWith( qualifiedName ) ) {
1841 (*it) = qualifiedName + value; 1859 (*it) = qualifiedName + value;
1842 return; 1860 return;
1843 } 1861 }
1844 } 1862 }
1845 mData->custom.append( qualifiedName + value ); 1863 mData->custom.append( qualifiedName + value );
1846} 1864}
1847 1865
1848void Addressee::removeCustom( const QString &app, const QString &name) 1866void Addressee::removeCustom( const QString &app, const QString &name)
1849{ 1867{
1850 detach(); 1868 detach();
1851 1869
1852 QString qualifiedName = app + "-" + name + ":"; 1870 QString qualifiedName = app + "-" + name + ":";
1853 1871
1854 QStringList::Iterator it; 1872 QStringList::Iterator it;
1855 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1873 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1856 if ( (*it).startsWith( qualifiedName ) ) { 1874 if ( (*it).startsWith( qualifiedName ) ) {
1857 mData->custom.remove( it ); 1875 mData->custom.remove( it );
1858 return; 1876 return;
1859 } 1877 }
1860 } 1878 }
1861} 1879}
1862 1880
1863QString Addressee::custom( const QString &app, const QString &name ) const 1881QString Addressee::custom( const QString &app, const QString &name ) const
1864{ 1882{
1865 QString qualifiedName = app + "-" + name + ":"; 1883 QString qualifiedName = app + "-" + name + ":";
1866 QString value; 1884 QString value;
1867 1885
1868 QStringList::ConstIterator it; 1886 QStringList::ConstIterator it;
1869 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1887 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1870 if ( (*it).startsWith( qualifiedName ) ) { 1888 if ( (*it).startsWith( qualifiedName ) ) {
1871 value = (*it).mid( (*it).find( ":" ) + 1 ); 1889 value = (*it).mid( (*it).find( ":" ) + 1 );
1872 break; 1890 break;
1873 } 1891 }
1874 } 1892 }
1875 1893
1876 return value; 1894 return value;
1877} 1895}
1878 1896
1879void Addressee::setCustoms( const QStringList &l ) 1897void Addressee::setCustoms( const QStringList &l )
1880{ 1898{
1881 detach(); 1899 detach();
1882 mData->empty = false; 1900 mData->empty = false;
1883 1901
1884 mData->custom = l; 1902 mData->custom = l;
1885} 1903}
1886 1904
1887QStringList Addressee::customs() const 1905QStringList Addressee::customs() const
1888{ 1906{
1889 return mData->custom; 1907 return mData->custom;
1890} 1908}
1891 1909
1892void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, 1910void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1893 QString &email) 1911 QString &email)
1894{ 1912{
1895 int startPos, endPos, len; 1913 int startPos, endPos, len;
1896 QString partA, partB, result; 1914 QString partA, partB, result;
1897 char endCh = '>'; 1915 char endCh = '>';
1898 1916
1899 startPos = rawEmail.find('<'); 1917 startPos = rawEmail.find('<');
1900 if (startPos < 0) 1918 if (startPos < 0)
1901 { 1919 {
1902 startPos = rawEmail.find('('); 1920 startPos = rawEmail.find('(');
1903 endCh = ')'; 1921 endCh = ')';
1904 } 1922 }
1905 if (startPos < 0) 1923 if (startPos < 0)
1906 { 1924 {
1907 // We couldn't find any separators, so we assume the whole string 1925 // We couldn't find any separators, so we assume the whole string
1908 // is the email address 1926 // is the email address
1909 email = rawEmail; 1927 email = rawEmail;
1910 fullName = ""; 1928 fullName = "";
1911 } 1929 }
1912 else 1930 else
1913 { 1931 {
1914 // We have a start position, try to find an end 1932 // We have a start position, try to find an end
1915 endPos = rawEmail.find(endCh, startPos+1); 1933 endPos = rawEmail.find(endCh, startPos+1);
1916 1934
1917 if (endPos < 0) 1935 if (endPos < 0)
1918 { 1936 {
1919 // We couldn't find the end of the email address. We can only 1937 // We couldn't find the end of the email address. We can only
1920 // assume the entire string is the email address. 1938 // assume the entire string is the email address.
1921 email = rawEmail; 1939 email = rawEmail;
1922 fullName = ""; 1940 fullName = "";
1923 } 1941 }
1924 else 1942 else
1925 { 1943 {
1926 // We have a start and end to the email address 1944 // We have a start and end to the email address
1927 1945
1928 // Grab the name part 1946 // Grab the name part
1929 fullName = rawEmail.left(startPos).stripWhiteSpace(); 1947 fullName = rawEmail.left(startPos).stripWhiteSpace();
1930 1948
1931 // grab the email part 1949 // grab the email part
1932 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 1950 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
1933 1951
1934 // Check that we do not have any extra characters on the end of the 1952 // Check that we do not have any extra characters on the end of the
1935 // strings 1953 // strings
1936 len = fullName.length(); 1954 len = fullName.length();
1937 if (fullName[0]=='"' && fullName[len-1]=='"') 1955 if (fullName[0]=='"' && fullName[len-1]=='"')
1938 fullName = fullName.mid(1, len-2); 1956 fullName = fullName.mid(1, len-2);
1939 else if (fullName[0]=='<' && fullName[len-1]=='>') 1957 else if (fullName[0]=='<' && fullName[len-1]=='>')
1940 fullName = fullName.mid(1, len-2); 1958 fullName = fullName.mid(1, len-2);
1941 else if (fullName[0]=='(' && fullName[len-1]==')') 1959 else if (fullName[0]=='(' && fullName[len-1]==')')
1942 fullName = fullName.mid(1, len-2); 1960 fullName = fullName.mid(1, len-2);
1943 } 1961 }
1944 } 1962 }
1945} 1963}
1946 1964
1947void Addressee::setResource( Resource *resource ) 1965void Addressee::setResource( Resource *resource )
1948{ 1966{
1949 detach(); 1967 detach();
1950 mData->resource = resource; 1968 mData->resource = resource;
1951} 1969}
1952 1970
1953Resource *Addressee::resource() const 1971Resource *Addressee::resource() const
1954{ 1972{
1955 return mData->resource; 1973 return mData->resource;
1956} 1974}
1957 1975
1958//US 1976//US
1959QString Addressee::resourceLabel() 1977QString Addressee::resourceLabel()
1960{ 1978{
1961 return i18n("Resource"); 1979 return i18n("Resource");
1962} 1980}
1963 1981
1964void Addressee::setChanged( bool value ) 1982void Addressee::setChanged( bool value )
1965{ 1983{
1966 detach(); 1984 detach();
1967 mData->changed = value; 1985 mData->changed = value;
1968} 1986}
1969 1987
1970bool Addressee::changed() const 1988bool Addressee::changed() const
1971{ 1989{
1972 return mData->changed; 1990 return mData->changed;
1973} 1991}
1974 1992
1975void Addressee::setTagged( bool value ) 1993void Addressee::setTagged( bool value )
1976{ 1994{
1977 detach(); 1995 detach();
1978 mData->tagged = value; 1996 mData->tagged = value;
1979} 1997}
1980 1998
1981bool Addressee::tagged() const 1999bool Addressee::tagged() const
1982{ 2000{
1983 return mData->tagged; 2001 return mData->tagged;
1984} 2002}
1985 2003
1986QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 2004QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
1987{ 2005{
1988 if (!a.mData) return s; 2006 if (!a.mData) return s;
1989 2007
1990 s << a.uid(); 2008 s << a.uid();
1991 2009
1992 s << a.mData->name; 2010 s << a.mData->name;
1993 s << a.mData->formattedName; 2011 s << a.mData->formattedName;
1994 s << a.mData->familyName; 2012 s << a.mData->familyName;
1995 s << a.mData->givenName; 2013 s << a.mData->givenName;
1996 s << a.mData->additionalName; 2014 s << a.mData->additionalName;
1997 s << a.mData->prefix; 2015 s << a.mData->prefix;
1998 s << a.mData->suffix; 2016 s << a.mData->suffix;
1999 s << a.mData->nickName; 2017 s << a.mData->nickName;
2000 s << a.mData->birthday; 2018 s << a.mData->birthday;
2001 s << a.mData->mailer; 2019 s << a.mData->mailer;
2002 s << a.mData->timeZone; 2020 s << a.mData->timeZone;
2003 s << a.mData->geo; 2021 s << a.mData->geo;
2004 s << a.mData->title; 2022 s << a.mData->title;
2005 s << a.mData->role; 2023 s << a.mData->role;
2006 s << a.mData->organization; 2024 s << a.mData->organization;
2007 s << a.mData->note; 2025 s << a.mData->note;
2008 s << a.mData->productId; 2026 s << a.mData->productId;
2009 s << a.mData->revision; 2027 s << a.mData->revision;
2010 s << a.mData->sortString; 2028 s << a.mData->sortString;
2011 s << a.mData->url; 2029 s << a.mData->url;
2012 s << a.mData->secrecy; 2030 s << a.mData->secrecy;
2013 s << a.mData->logo; 2031 s << a.mData->logo;
2014 s << a.mData->photo; 2032 s << a.mData->photo;
2015 s << a.mData->sound; 2033 s << a.mData->sound;
2016 s << a.mData->agent; 2034 s << a.mData->agent;
2017 s << a.mData->phoneNumbers; 2035 s << a.mData->phoneNumbers;
2018 s << a.mData->addresses; 2036 s << a.mData->addresses;
2019 s << a.mData->emails; 2037 s << a.mData->emails;
2020 s << a.mData->categories; 2038 s << a.mData->categories;
2021 s << a.mData->custom; 2039 s << a.mData->custom;
2022 s << a.mData->keys; 2040 s << a.mData->keys;
2023 return s; 2041 return s;
2024} 2042}
2025 2043
2026QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 2044QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
2027{ 2045{
2028 if (!a.mData) return s; 2046 if (!a.mData) return s;
2029 2047
2030 s >> a.mData->uid; 2048 s >> a.mData->uid;
2031 2049
2032 s >> a.mData->name; 2050 s >> a.mData->name;
2033 s >> a.mData->formattedName; 2051 s >> a.mData->formattedName;
2034 s >> a.mData->familyName; 2052 s >> a.mData->familyName;
2035 s >> a.mData->givenName; 2053 s >> a.mData->givenName;
2036 s >> a.mData->additionalName; 2054 s >> a.mData->additionalName;
2037 s >> a.mData->prefix; 2055 s >> a.mData->prefix;
2038 s >> a.mData->suffix; 2056 s >> a.mData->suffix;
2039 s >> a.mData->nickName; 2057 s >> a.mData->nickName;
2040 s >> a.mData->birthday; 2058 s >> a.mData->birthday;
2041 s >> a.mData->mailer; 2059 s >> a.mData->mailer;
2042 s >> a.mData->timeZone; 2060 s >> a.mData->timeZone;
2043 s >> a.mData->geo; 2061 s >> a.mData->geo;
2044 s >> a.mData->title; 2062 s >> a.mData->title;
2045 s >> a.mData->role; 2063 s >> a.mData->role;
2046 s >> a.mData->organization; 2064 s >> a.mData->organization;
2047 s >> a.mData->note; 2065 s >> a.mData->note;
2048 s >> a.mData->productId; 2066 s >> a.mData->productId;
2049 s >> a.mData->revision; 2067 s >> a.mData->revision;
2050 s >> a.mData->sortString; 2068 s >> a.mData->sortString;
2051 s >> a.mData->url; 2069 s >> a.mData->url;
2052 s >> a.mData->secrecy; 2070 s >> a.mData->secrecy;
2053 s >> a.mData->logo; 2071 s >> a.mData->logo;
2054 s >> a.mData->photo; 2072 s >> a.mData->photo;
2055 s >> a.mData->sound; 2073 s >> a.mData->sound;
2056 s >> a.mData->agent; 2074 s >> a.mData->agent;
2057 s >> a.mData->phoneNumbers; 2075 s >> a.mData->phoneNumbers;
2058 s >> a.mData->addresses; 2076 s >> a.mData->addresses;
2059 s >> a.mData->emails; 2077 s >> a.mData->emails;
2060 s >> a.mData->categories; 2078 s >> a.mData->categories;
2061 s >> a.mData->custom; 2079 s >> a.mData->custom;
2062 s >> a.mData->keys; 2080 s >> a.mData->keys;
2063 2081
2064 a.mData->empty = false; 2082 a.mData->empty = false;
2065 2083
2066 return s; 2084 return s;
2067} 2085}
2068bool matchBinaryPattern( int value, int pattern ) 2086bool matchBinaryPattern( int value, int pattern )
2069{ 2087{
2070 /** 2088 /**
2071 We want to match all telephonnumbers/addresses which have the bits in the 2089 We want to match all telephonnumbers/addresses which have the bits in the
2072 pattern set. More are allowed. 2090 pattern set. More are allowed.
2073 if pattern == 0 we have a special handling, then we want only those with 2091 if pattern == 0 we have a special handling, then we want only those with
2074 exactly no bit set. 2092 exactly no bit set.
2075 */ 2093 */
2076 if ( pattern == 0 ) 2094 if ( pattern == 0 )
2077 return ( value == 0 ); 2095 return ( value == 0 );
2078 else 2096 else
2079 return ( pattern == ( pattern & value ) ); 2097 return ( pattern == ( pattern & value ) );
2080} 2098}
2081 2099
2082bool matchBinaryPatternP( int value, int pattern ) 2100bool matchBinaryPatternP( int value, int pattern )
2083{ 2101{
2084 2102
2085 if ( pattern == 0 ) 2103 if ( pattern == 0 )
2086 return ( value == 0 ); 2104 return ( value == 0 );
2087 else 2105 else
2088 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); 2106 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) );
2089} 2107}
2090bool matchBinaryPatternA( int value, int pattern ) 2108bool matchBinaryPatternA( int value, int pattern )
2091{ 2109{
2092 2110
2093 if ( pattern == 0 ) 2111 if ( pattern == 0 )
2094 return ( value == 0 ); 2112 return ( value == 0 );
2095 else 2113 else
2096 return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); 2114 return ( (pattern | Address::Pref) == ( value | Address::Pref ) );
2097} 2115}