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