summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
Unidiff
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index d6b70c4..c34f671 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,1332 +1,1331 @@
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 );
46 46
47struct Addressee::AddresseeData : public KShared 47struct Addressee::AddresseeData : public KShared
48{ 48{
49 QString uid; 49 QString uid;
50 QString name; 50 QString name;
51 QString formattedName; 51 QString formattedName;
52 QString familyName; 52 QString familyName;
53 QString givenName; 53 QString givenName;
54 QString additionalName; 54 QString additionalName;
55 QString prefix; 55 QString prefix;
56 QString suffix; 56 QString suffix;
57 QString nickName; 57 QString nickName;
58 QDateTime birthday; 58 QDateTime birthday;
59 QString mailer; 59 QString mailer;
60 TimeZone timeZone; 60 TimeZone timeZone;
61 Geo geo; 61 Geo geo;
62 QString title; 62 QString title;
63 QString role; 63 QString role;
64 QString organization; 64 QString organization;
65 QString note; 65 QString note;
66 QString productId; 66 QString productId;
67 QDateTime revision; 67 QDateTime revision;
68 QString sortString; 68 QString sortString;
69 KURL url; 69 KURL url;
70 Secrecy secrecy; 70 Secrecy secrecy;
71 Picture logo; 71 Picture logo;
72 Picture photo; 72 Picture photo;
73 Sound sound; 73 Sound sound;
74 Agent agent; 74 Agent agent;
75 QString mExternalId; 75 QString mExternalId;
76 PhoneNumber::List phoneNumbers; 76 PhoneNumber::List phoneNumbers;
77 Address::List addresses; 77 Address::List addresses;
78 Key::List keys; 78 Key::List keys;
79 QStringList emails; 79 QStringList emails;
80 QStringList categories; 80 QStringList categories;
81 QStringList custom; 81 QStringList custom;
82 int mTempSyncStat; 82 int mTempSyncStat;
83 Resource *resource; 83 Resource *resource;
84 84
85 bool empty :1; 85 bool empty :1;
86 bool changed :1; 86 bool changed :1;
87}; 87};
88 88
89Addressee::Addressee() 89Addressee::Addressee()
90{ 90{
91 mData = new AddresseeData; 91 mData = new AddresseeData;
92 mData->empty = true; 92 mData->empty = true;
93 mData->changed = false; 93 mData->changed = false;
94 mData->resource = 0; 94 mData->resource = 0;
95 mData->mExternalId = ":"; 95 mData->mExternalId = ":";
96 mData->revision = QDateTime ( QDate( 2004,1,1)); 96 mData->revision = QDateTime ( QDate( 2004,1,1));
97 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 97 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
98} 98}
99 99
100Addressee::~Addressee() 100Addressee::~Addressee()
101{ 101{
102} 102}
103 103
104Addressee::Addressee( const Addressee &a ) 104Addressee::Addressee( const Addressee &a )
105{ 105{
106 mData = a.mData; 106 mData = a.mData;
107} 107}
108 108
109Addressee &Addressee::operator=( const Addressee &a ) 109Addressee &Addressee::operator=( const Addressee &a )
110{ 110{
111 mData = a.mData; 111 mData = a.mData;
112 return (*this); 112 return (*this);
113} 113}
114 114
115Addressee Addressee::copy() 115Addressee Addressee::copy()
116{ 116{
117 Addressee a; 117 Addressee a;
118 *(a.mData) = *mData; 118 *(a.mData) = *mData;
119 return a; 119 return a;
120} 120}
121 121
122void Addressee::detach() 122void Addressee::detach()
123{ 123{
124 if ( mData.count() == 1 ) return; 124 if ( mData.count() == 1 ) return;
125 *this = copy(); 125 *this = copy();
126} 126}
127 127
128bool Addressee::operator==( const Addressee &a ) const 128bool Addressee::operator==( const Addressee &a ) const
129{ 129{
130 if ( uid() != a.uid() ) return false; 130 if ( uid() != a.uid() ) return false;
131 if ( mData->name != a.mData->name ) return false; 131 if ( mData->name != a.mData->name ) return false;
132 if ( mData->formattedName != a.mData->formattedName ) return false; 132 if ( mData->formattedName != a.mData->formattedName ) return false;
133 if ( mData->familyName != a.mData->familyName ) return false; 133 if ( mData->familyName != a.mData->familyName ) return false;
134 if ( mData->givenName != a.mData->givenName ) return false; 134 if ( mData->givenName != a.mData->givenName ) return false;
135 if ( mData->additionalName != a.mData->additionalName ) return false; 135 if ( mData->additionalName != a.mData->additionalName ) return false;
136 if ( mData->prefix != a.mData->prefix ) return false; 136 if ( mData->prefix != a.mData->prefix ) return false;
137 if ( mData->suffix != a.mData->suffix ) return false; 137 if ( mData->suffix != a.mData->suffix ) return false;
138 if ( mData->nickName != a.mData->nickName ) return false; 138 if ( mData->nickName != a.mData->nickName ) return false;
139 if ( mData->birthday != a.mData->birthday ) return false; 139 if ( mData->birthday != a.mData->birthday ) return false;
140 if ( mData->mailer != a.mData->mailer ) return false; 140 if ( mData->mailer != a.mData->mailer ) return false;
141 if ( mData->timeZone != a.mData->timeZone ) return false; 141 if ( mData->timeZone != a.mData->timeZone ) return false;
142 if ( mData->geo != a.mData->geo ) return false; 142 if ( mData->geo != a.mData->geo ) return false;
143 if ( mData->title != a.mData->title ) return false; 143 if ( mData->title != a.mData->title ) return false;
144 if ( mData->role != a.mData->role ) return false; 144 if ( mData->role != a.mData->role ) return false;
145 if ( mData->organization != a.mData->organization ) return false; 145 if ( mData->organization != a.mData->organization ) return false;
146 if ( mData->note != a.mData->note ) return false; 146 if ( mData->note != a.mData->note ) return false;
147 if ( mData->productId != a.mData->productId ) return false; 147 if ( mData->productId != a.mData->productId ) return false;
148 if ( mData->revision != a.mData->revision ) return false; 148 if ( mData->revision != a.mData->revision ) return false;
149 if ( mData->sortString != a.mData->sortString ) return false; 149 if ( mData->sortString != a.mData->sortString ) return false;
150 if ( mData->secrecy != a.mData->secrecy ) return false; 150 if ( mData->secrecy != a.mData->secrecy ) return false;
151 if ( mData->logo != a.mData->logo ) return false; 151 if ( mData->logo != a.mData->logo ) return false;
152 if ( mData->photo != a.mData->photo ) return false; 152 if ( mData->photo != a.mData->photo ) return false;
153 if ( mData->sound != a.mData->sound ) return false; 153 if ( mData->sound != a.mData->sound ) return false;
154 if ( mData->agent != a.mData->agent ) return false; 154 if ( mData->agent != a.mData->agent ) return false;
155 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 155 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
156 ( mData->url != a.mData->url ) ) return false; 156 ( mData->url != a.mData->url ) ) return false;
157 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 157 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
158 if ( mData->addresses != a.mData->addresses ) return false; 158 if ( mData->addresses != a.mData->addresses ) return false;
159 if ( mData->keys != a.mData->keys ) return false; 159 if ( mData->keys != a.mData->keys ) return false;
160 if ( mData->emails != a.mData->emails ) return false; 160 if ( mData->emails != a.mData->emails ) return false;
161 if ( mData->categories != a.mData->categories ) return false; 161 if ( mData->categories != a.mData->categories ) return false;
162 if ( mData->custom != a.mData->custom ) return false; 162 if ( mData->custom != a.mData->custom ) return false;
163 163
164 return true; 164 return true;
165} 165}
166 166
167bool Addressee::operator!=( const Addressee &a ) const 167bool Addressee::operator!=( const Addressee &a ) const
168{ 168{
169 return !( a == *this ); 169 return !( a == *this );
170} 170}
171 171
172bool Addressee::isEmpty() const 172bool Addressee::isEmpty() const
173{ 173{
174 return mData->empty; 174 return mData->empty;
175} 175}
176ulong Addressee::getCsum4List( const QStringList & attList) 176ulong Addressee::getCsum4List( const QStringList & attList)
177{ 177{
178 int max = attList.count(); 178 int max = attList.count();
179 ulong cSum = 0; 179 ulong cSum = 0;
180 int j,k,i; 180 int j,k,i;
181 int add; 181 int add;
182 for ( i = 0; i < max ; ++i ) { 182 for ( i = 0; i < max ; ++i ) {
183 QString s = attList[i]; 183 QString s = attList[i];
184 if ( ! s.isEmpty() ){ 184 if ( ! s.isEmpty() ){
185 j = s.length(); 185 j = s.length();
186 for ( k = 0; k < j; ++k ) { 186 for ( k = 0; k < j; ++k ) {
187 int mul = k +1; 187 int mul = k +1;
188 add = s[k].unicode (); 188 add = s[k].unicode ();
189 if ( k < 16 ) 189 if ( k < 16 )
190 mul = mul * mul; 190 mul = mul * mul;
191 int ii = i+1; 191 int ii = i+1;
192 add = add * mul *ii*ii*ii; 192 add = add * mul *ii*ii*ii;
193 cSum += add; 193 cSum += add;
194 } 194 }
195 } 195 }
196 196
197 } 197 }
198 //QString dump = attList.join(","); 198 //QString dump = attList.join(",");
199 //qDebug("csum: %d %s", cSum,dump.latin1()); 199 //qDebug("csum: %d %s", cSum,dump.latin1());
200 200
201 return cSum; 201 return cSum;
202 202
203} 203}
204void Addressee::computeCsum(const QString &dev) 204void Addressee::computeCsum(const QString &dev)
205{ 205{
206 QStringList l; 206 QStringList l;
207 if ( !mData->name.isEmpty() ) l.append(mData->name); 207 if ( !mData->name.isEmpty() ) l.append(mData->name);
208 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 208 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
209 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 209 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
210 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 210 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
211 if ( !mData->additionalName ) l.append( mData->additionalName ); 211 if ( !mData->additionalName ) l.append( mData->additionalName );
212 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 212 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
213 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 213 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
214 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 214 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
215 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 215 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
216 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 216 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
217 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 217 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
218 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 218 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
219 if ( !mData->title .isEmpty() ) l.append( mData->title ); 219 if ( !mData->title .isEmpty() ) l.append( mData->title );
220 if ( !mData->role.isEmpty() ) l.append( mData->role ); 220 if ( !mData->role.isEmpty() ) l.append( mData->role );
221 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 221 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
222 if ( !mData->note.isEmpty() ) l.append( mData->note ); 222 if ( !mData->note.isEmpty() ) l.append( mData->note );
223 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 223 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
224 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 224 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
225 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 225 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
226 // if ( !mData->logo.isEmpty() ) l.append( ); 226 // if ( !mData->logo.isEmpty() ) l.append( );
227 //if ( !mData->photo.isEmpty() ) l.append( ); 227 //if ( !mData->photo.isEmpty() ) l.append( );
228 //if ( !mData->sound.isEmpty() ) l.append( ); 228 //if ( !mData->sound.isEmpty() ) l.append( );
229 //if ( !mData->agent.isEmpty() ) l.append( ); 229 //if ( !mData->agent.isEmpty() ) l.append( );
230 //if ( mData->url.isValid() ) l.append( ); 230 //if ( mData->url.isValid() ) l.append( );
231#if 0 231#if 0
232 if ( !mData->phoneNumbers.isEmpty() ) l.append( ); 232 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
233 if ( !mData->addresses.isEmpty() ) l.append( ); 233 if ( !mData->addresses.isEmpty() ) l.append( );
234 //if ( !mData->keys.isEmpty() ) l.append( ); 234 //if ( !mData->keys.isEmpty() ) l.append( );
235 if ( !mData->emails.isEmpty() ) l.append( ); 235 if ( !mData->emails.isEmpty() ) l.append( );
236 if ( !mData->categories .isEmpty() ) l.append( ); 236 if ( !mData->categories .isEmpty() ) l.append( );
237 if ( !mData->custom.isEmpty() ) l.append( ); 237 if ( !mData->custom.isEmpty() ) l.append( );
238#endif 238#endif
239 KABC::PhoneNumber::List phoneNumbers; 239 KABC::PhoneNumber::List phoneNumbers;
240 KABC::PhoneNumber::List::Iterator phoneIter; 240 KABC::PhoneNumber::List::Iterator phoneIter;
241 241
242 QStringList t; 242 QStringList t;
243 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 243 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
244 ++phoneIter ) 244 ++phoneIter )
245 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 245 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
246 t.sort(); 246 t.sort();
247 uint iii; 247 uint iii;
248 for ( iii = 0; iii < t.count(); ++iii) 248 for ( iii = 0; iii < t.count(); ++iii)
249 l.append( t[iii] ); 249 l.append( t[iii] );
250 t = mData->emails; 250 t = mData->emails;
251 t.sort(); 251 t.sort();
252 for ( iii = 0; iii < t.count(); ++iii) 252 for ( iii = 0; iii < t.count(); ++iii)
253 l.append( t[iii] ); 253 l.append( t[iii] );
254 t = mData->categories; 254 t = mData->categories;
255 t.sort(); 255 t.sort();
256 for ( iii = 0; iii < t.count(); ++iii) 256 for ( iii = 0; iii < t.count(); ++iii)
257 l.append( t[iii] ); 257 l.append( t[iii] );
258 t = mData->custom; 258 t = mData->custom;
259 t.sort(); 259 t.sort();
260 for ( iii = 0; iii < t.count(); ++iii) 260 for ( iii = 0; iii < t.count(); ++iii)
261 l.append( t[iii] ); 261 l.append( t[iii] );
262 KABC::Address::List::Iterator addressIter; 262 KABC::Address::List::Iterator addressIter;
263 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 263 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
264 ++addressIter ) { 264 ++addressIter ) {
265 t = (*addressIter).asList(); 265 t = (*addressIter).asList();
266 t.sort(); 266 t.sort();
267 for ( iii = 0; iii < t.count(); ++iii) 267 for ( iii = 0; iii < t.count(); ++iii)
268 l.append( t[iii] ); 268 l.append( t[iii] );
269 } 269 }
270 uint cs = getCsum4List(l); 270 uint cs = getCsum4List(l);
271 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 271 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
272 setCsum( dev, QString::number (cs )); 272 setCsum( dev, QString::number (cs ));
273} 273}
274void Addressee::removeID(const QString &prof) 274void Addressee::removeID(const QString &prof)
275{ 275{
276 detach(); 276 detach();
277 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 277 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
278 278
279} 279}
280void Addressee::setID( const QString & prof , const QString & id ) 280void Addressee::setID( const QString & prof , const QString & id )
281{ 281{
282 detach(); 282 detach();
283 qDebug("setID1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
284 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 283 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
285 qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 284 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
286} 285}
287void Addressee::setTempSyncStat( int id ) 286void Addressee::setTempSyncStat( int id )
288{ 287{
289 if ( mData->mTempSyncStat == id ) return; 288 if ( mData->mTempSyncStat == id ) return;
290 detach(); 289 detach();
291 mData->mTempSyncStat = id; 290 mData->mTempSyncStat = id;
292} 291}
293int Addressee::tempSyncStat() const 292int Addressee::tempSyncStat() const
294{ 293{
295 return mData->mTempSyncStat; 294 return mData->mTempSyncStat;
296} 295}
297 296
298QString Addressee::getID( const QString & prof) 297QString Addressee::getID( const QString & prof)
299{ 298{
300 return KIdManager::getId ( mData->mExternalId, prof ); 299 return KIdManager::getId ( mData->mExternalId, prof );
301} 300}
302 301
303void Addressee::setCsum( const QString & prof , const QString & id ) 302void Addressee::setCsum( const QString & prof , const QString & id )
304{ 303{
305 detach(); 304 detach();
306 qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 305 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
307 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 306 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
308 qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 307 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
309} 308}
310 309
311QString Addressee::getCsum( const QString & prof) 310QString Addressee::getCsum( const QString & prof)
312{ 311{
313 return KIdManager::getCsum ( mData->mExternalId, prof ); 312 return KIdManager::getCsum ( mData->mExternalId, prof );
314} 313}
315 314
316void Addressee::setIDStr( const QString & s ) 315void Addressee::setIDStr( const QString & s )
317{ 316{
318 detach(); 317 detach();
319 mData->mExternalId = s; 318 mData->mExternalId = s;
320} 319}
321 320
322QString Addressee::IDStr() const 321QString Addressee::IDStr() const
323{ 322{
324 return mData->mExternalId; 323 return mData->mExternalId;
325} 324}
326 325
327 326
328void Addressee::setUid( const QString &id ) 327void Addressee::setUid( const QString &id )
329{ 328{
330 if ( id == mData->uid ) return; 329 if ( id == mData->uid ) return;
331 detach(); 330 detach();
332 mData->empty = false; 331 mData->empty = false;
333 mData->uid = id; 332 mData->uid = id;
334} 333}
335 334
336QString Addressee::uid() const 335QString Addressee::uid() const
337{ 336{
338 if ( mData->uid.isEmpty() ) 337 if ( mData->uid.isEmpty() )
339 mData->uid = KApplication::randomString( 10 ); 338 mData->uid = KApplication::randomString( 10 );
340 339
341 return mData->uid; 340 return mData->uid;
342} 341}
343 342
344QString Addressee::uidLabel() 343QString Addressee::uidLabel()
345{ 344{
346 return i18n("Unique Identifier"); 345 return i18n("Unique Identifier");
347} 346}
348 347
349void Addressee::setName( const QString &name ) 348void Addressee::setName( const QString &name )
350{ 349{
351 if ( name == mData->name ) return; 350 if ( name == mData->name ) return;
352 detach(); 351 detach();
353 mData->empty = false; 352 mData->empty = false;
354 mData->name = name; 353 mData->name = name;
355} 354}
356 355
357QString Addressee::name() const 356QString Addressee::name() const
358{ 357{
359 return mData->name; 358 return mData->name;
360} 359}
361 360
362QString Addressee::nameLabel() 361QString Addressee::nameLabel()
363{ 362{
364 return i18n("Name"); 363 return i18n("Name");
365} 364}
366 365
367 366
368void Addressee::setFormattedName( const QString &formattedName ) 367void Addressee::setFormattedName( const QString &formattedName )
369{ 368{
370 if ( formattedName == mData->formattedName ) return; 369 if ( formattedName == mData->formattedName ) return;
371 detach(); 370 detach();
372 mData->empty = false; 371 mData->empty = false;
373 mData->formattedName = formattedName; 372 mData->formattedName = formattedName;
374} 373}
375 374
376QString Addressee::formattedName() const 375QString Addressee::formattedName() const
377{ 376{
378 return mData->formattedName; 377 return mData->formattedName;
379} 378}
380 379
381QString Addressee::formattedNameLabel() 380QString Addressee::formattedNameLabel()
382{ 381{
383 return i18n("Formatted Name"); 382 return i18n("Formatted Name");
384} 383}
385 384
386 385
387void Addressee::setFamilyName( const QString &familyName ) 386void Addressee::setFamilyName( const QString &familyName )
388{ 387{
389 if ( familyName == mData->familyName ) return; 388 if ( familyName == mData->familyName ) return;
390 detach(); 389 detach();
391 mData->empty = false; 390 mData->empty = false;
392 mData->familyName = familyName; 391 mData->familyName = familyName;
393} 392}
394 393
395QString Addressee::familyName() const 394QString Addressee::familyName() const
396{ 395{
397 return mData->familyName; 396 return mData->familyName;
398} 397}
399 398
400QString Addressee::familyNameLabel() 399QString Addressee::familyNameLabel()
401{ 400{
402 return i18n("Family Name"); 401 return i18n("Family Name");
403} 402}
404 403
405 404
406void Addressee::setGivenName( const QString &givenName ) 405void Addressee::setGivenName( const QString &givenName )
407{ 406{
408 if ( givenName == mData->givenName ) return; 407 if ( givenName == mData->givenName ) return;
409 detach(); 408 detach();
410 mData->empty = false; 409 mData->empty = false;
411 mData->givenName = givenName; 410 mData->givenName = givenName;
412} 411}
413 412
414QString Addressee::givenName() const 413QString Addressee::givenName() const
415{ 414{
416 return mData->givenName; 415 return mData->givenName;
417} 416}
418 417
419QString Addressee::givenNameLabel() 418QString Addressee::givenNameLabel()
420{ 419{
421 return i18n("Given Name"); 420 return i18n("Given Name");
422} 421}
423 422
424 423
425void Addressee::setAdditionalName( const QString &additionalName ) 424void Addressee::setAdditionalName( const QString &additionalName )
426{ 425{
427 if ( additionalName == mData->additionalName ) return; 426 if ( additionalName == mData->additionalName ) return;
428 detach(); 427 detach();
429 mData->empty = false; 428 mData->empty = false;
430 mData->additionalName = additionalName; 429 mData->additionalName = additionalName;
431} 430}
432 431
433QString Addressee::additionalName() const 432QString Addressee::additionalName() const
434{ 433{
435 return mData->additionalName; 434 return mData->additionalName;
436} 435}
437 436
438QString Addressee::additionalNameLabel() 437QString Addressee::additionalNameLabel()
439{ 438{
440 return i18n("Additional Names"); 439 return i18n("Additional Names");
441} 440}
442 441
443 442
444void Addressee::setPrefix( const QString &prefix ) 443void Addressee::setPrefix( const QString &prefix )
445{ 444{
446 if ( prefix == mData->prefix ) return; 445 if ( prefix == mData->prefix ) return;
447 detach(); 446 detach();
448 mData->empty = false; 447 mData->empty = false;
449 mData->prefix = prefix; 448 mData->prefix = prefix;
450} 449}
451 450
452QString Addressee::prefix() const 451QString Addressee::prefix() const
453{ 452{
454 return mData->prefix; 453 return mData->prefix;
455} 454}
456 455
457QString Addressee::prefixLabel() 456QString Addressee::prefixLabel()
458{ 457{
459 return i18n("Honorific Prefixes"); 458 return i18n("Honorific Prefixes");
460} 459}
461 460
462 461
463void Addressee::setSuffix( const QString &suffix ) 462void Addressee::setSuffix( const QString &suffix )
464{ 463{
465 if ( suffix == mData->suffix ) return; 464 if ( suffix == mData->suffix ) return;
466 detach(); 465 detach();
467 mData->empty = false; 466 mData->empty = false;
468 mData->suffix = suffix; 467 mData->suffix = suffix;
469} 468}
470 469
471QString Addressee::suffix() const 470QString Addressee::suffix() const
472{ 471{
473 return mData->suffix; 472 return mData->suffix;
474} 473}
475 474
476QString Addressee::suffixLabel() 475QString Addressee::suffixLabel()
477{ 476{
478 return i18n("Honorific Suffixes"); 477 return i18n("Honorific Suffixes");
479} 478}
480 479
481 480
482void Addressee::setNickName( const QString &nickName ) 481void Addressee::setNickName( const QString &nickName )
483{ 482{
484 if ( nickName == mData->nickName ) return; 483 if ( nickName == mData->nickName ) return;
485 detach(); 484 detach();
486 mData->empty = false; 485 mData->empty = false;
487 mData->nickName = nickName; 486 mData->nickName = nickName;
488} 487}
489 488
490QString Addressee::nickName() const 489QString Addressee::nickName() const
491{ 490{
492 return mData->nickName; 491 return mData->nickName;
493} 492}
494 493
495QString Addressee::nickNameLabel() 494QString Addressee::nickNameLabel()
496{ 495{
497 return i18n("Nick Name"); 496 return i18n("Nick Name");
498} 497}
499 498
500 499
501void Addressee::setBirthday( const QDateTime &birthday ) 500void Addressee::setBirthday( const QDateTime &birthday )
502{ 501{
503 if ( birthday == mData->birthday ) return; 502 if ( birthday == mData->birthday ) return;
504 detach(); 503 detach();
505 mData->empty = false; 504 mData->empty = false;
506 mData->birthday = birthday; 505 mData->birthday = birthday;
507} 506}
508 507
509QDateTime Addressee::birthday() const 508QDateTime Addressee::birthday() const
510{ 509{
511 return mData->birthday; 510 return mData->birthday;
512} 511}
513 512
514QString Addressee::birthdayLabel() 513QString Addressee::birthdayLabel()
515{ 514{
516 return i18n("Birthday"); 515 return i18n("Birthday");
517} 516}
518 517
519 518
520QString Addressee::homeAddressStreetLabel() 519QString Addressee::homeAddressStreetLabel()
521{ 520{
522 return i18n("Home Address Street"); 521 return i18n("Home Address Street");
523} 522}
524 523
525 524
526QString Addressee::homeAddressLocalityLabel() 525QString Addressee::homeAddressLocalityLabel()
527{ 526{
528 return i18n("Home Address Locality"); 527 return i18n("Home Address Locality");
529} 528}
530 529
531 530
532QString Addressee::homeAddressRegionLabel() 531QString Addressee::homeAddressRegionLabel()
533{ 532{
534 return i18n("Home Address Region"); 533 return i18n("Home Address Region");
535} 534}
536 535
537 536
538QString Addressee::homeAddressPostalCodeLabel() 537QString Addressee::homeAddressPostalCodeLabel()
539{ 538{
540 return i18n("Home Address Postal Code"); 539 return i18n("Home Address Postal Code");
541} 540}
542 541
543 542
544QString Addressee::homeAddressCountryLabel() 543QString Addressee::homeAddressCountryLabel()
545{ 544{
546 return i18n("Home Address Country"); 545 return i18n("Home Address Country");
547} 546}
548 547
549 548
550QString Addressee::homeAddressLabelLabel() 549QString Addressee::homeAddressLabelLabel()
551{ 550{
552 return i18n("Home Address Label"); 551 return i18n("Home Address Label");
553} 552}
554 553
555 554
556QString Addressee::businessAddressStreetLabel() 555QString Addressee::businessAddressStreetLabel()
557{ 556{
558 return i18n("Business Address Street"); 557 return i18n("Business Address Street");
559} 558}
560 559
561 560
562QString Addressee::businessAddressLocalityLabel() 561QString Addressee::businessAddressLocalityLabel()
563{ 562{
564 return i18n("Business Address Locality"); 563 return i18n("Business Address Locality");
565} 564}
566 565
567 566
568QString Addressee::businessAddressRegionLabel() 567QString Addressee::businessAddressRegionLabel()
569{ 568{
570 return i18n("Business Address Region"); 569 return i18n("Business Address Region");
571} 570}
572 571
573 572
574QString Addressee::businessAddressPostalCodeLabel() 573QString Addressee::businessAddressPostalCodeLabel()
575{ 574{
576 return i18n("Business Address Postal Code"); 575 return i18n("Business Address Postal Code");
577} 576}
578 577
579 578
580QString Addressee::businessAddressCountryLabel() 579QString Addressee::businessAddressCountryLabel()
581{ 580{
582 return i18n("Business Address Country"); 581 return i18n("Business Address Country");
583} 582}
584 583
585 584
586QString Addressee::businessAddressLabelLabel() 585QString Addressee::businessAddressLabelLabel()
587{ 586{
588 return i18n("Business Address Label"); 587 return i18n("Business Address Label");
589} 588}
590 589
591 590
592QString Addressee::homePhoneLabel() 591QString Addressee::homePhoneLabel()
593{ 592{
594 return i18n("Home Phone"); 593 return i18n("Home Phone");
595} 594}
596 595
597 596
598QString Addressee::businessPhoneLabel() 597QString Addressee::businessPhoneLabel()
599{ 598{
600 return i18n("Business Phone"); 599 return i18n("Business Phone");
601} 600}
602 601
603 602
604QString Addressee::mobilePhoneLabel() 603QString Addressee::mobilePhoneLabel()
605{ 604{
606 return i18n("Mobile Phone"); 605 return i18n("Mobile Phone");
607} 606}
608 607
609 608
610QString Addressee::homeFaxLabel() 609QString Addressee::homeFaxLabel()
611{ 610{
612 return i18n("Home Fax"); 611 return i18n("Home Fax");
613} 612}
614 613
615 614
616QString Addressee::businessFaxLabel() 615QString Addressee::businessFaxLabel()
617{ 616{
618 return i18n("Business Fax"); 617 return i18n("Business Fax");
619} 618}
620 619
621 620
622QString Addressee::carPhoneLabel() 621QString Addressee::carPhoneLabel()
623{ 622{
624 return i18n("Car Phone"); 623 return i18n("Car Phone");
625} 624}
626 625
627 626
628QString Addressee::isdnLabel() 627QString Addressee::isdnLabel()
629{ 628{
630 return i18n("ISDN"); 629 return i18n("ISDN");
631} 630}
632 631
633 632
634QString Addressee::pagerLabel() 633QString Addressee::pagerLabel()
635{ 634{
636 return i18n("Pager"); 635 return i18n("Pager");
637} 636}
638 637
639QString Addressee::sipLabel() 638QString Addressee::sipLabel()
640{ 639{
641 return i18n("SIP"); 640 return i18n("SIP");
642} 641}
643 642
644QString Addressee::emailLabel() 643QString Addressee::emailLabel()
645{ 644{
646 return i18n("Email Address"); 645 return i18n("Email Address");
647} 646}
648 647
649 648
650void Addressee::setMailer( const QString &mailer ) 649void Addressee::setMailer( const QString &mailer )
651{ 650{
652 if ( mailer == mData->mailer ) return; 651 if ( mailer == mData->mailer ) return;
653 detach(); 652 detach();
654 mData->empty = false; 653 mData->empty = false;
655 mData->mailer = mailer; 654 mData->mailer = mailer;
656} 655}
657 656
658QString Addressee::mailer() const 657QString Addressee::mailer() const
659{ 658{
660 return mData->mailer; 659 return mData->mailer;
661} 660}
662 661
663QString Addressee::mailerLabel() 662QString Addressee::mailerLabel()
664{ 663{
665 return i18n("Mail Client"); 664 return i18n("Mail Client");
666} 665}
667 666
668 667
669void Addressee::setTimeZone( const TimeZone &timeZone ) 668void Addressee::setTimeZone( const TimeZone &timeZone )
670{ 669{
671 if ( timeZone == mData->timeZone ) return; 670 if ( timeZone == mData->timeZone ) return;
672 detach(); 671 detach();
673 mData->empty = false; 672 mData->empty = false;
674 mData->timeZone = timeZone; 673 mData->timeZone = timeZone;
675} 674}
676 675
677TimeZone Addressee::timeZone() const 676TimeZone Addressee::timeZone() const
678{ 677{
679 return mData->timeZone; 678 return mData->timeZone;
680} 679}
681 680
682QString Addressee::timeZoneLabel() 681QString Addressee::timeZoneLabel()
683{ 682{
684 return i18n("Time Zone"); 683 return i18n("Time Zone");
685} 684}
686 685
687 686
688void Addressee::setGeo( const Geo &geo ) 687void Addressee::setGeo( const Geo &geo )
689{ 688{
690 if ( geo == mData->geo ) return; 689 if ( geo == mData->geo ) return;
691 detach(); 690 detach();
692 mData->empty = false; 691 mData->empty = false;
693 mData->geo = geo; 692 mData->geo = geo;
694} 693}
695 694
696Geo Addressee::geo() const 695Geo Addressee::geo() const
697{ 696{
698 return mData->geo; 697 return mData->geo;
699} 698}
700 699
701QString Addressee::geoLabel() 700QString Addressee::geoLabel()
702{ 701{
703 return i18n("Geographic Position"); 702 return i18n("Geographic Position");
704} 703}
705 704
706 705
707void Addressee::setTitle( const QString &title ) 706void Addressee::setTitle( const QString &title )
708{ 707{
709 if ( title == mData->title ) return; 708 if ( title == mData->title ) return;
710 detach(); 709 detach();
711 mData->empty = false; 710 mData->empty = false;
712 mData->title = title; 711 mData->title = title;
713} 712}
714 713
715QString Addressee::title() const 714QString Addressee::title() const
716{ 715{
717 return mData->title; 716 return mData->title;
718} 717}
719 718
720QString Addressee::titleLabel() 719QString Addressee::titleLabel()
721{ 720{
722 return i18n("Title"); 721 return i18n("Title");
723} 722}
724 723
725 724
726void Addressee::setRole( const QString &role ) 725void Addressee::setRole( const QString &role )
727{ 726{
728 if ( role == mData->role ) return; 727 if ( role == mData->role ) return;
729 detach(); 728 detach();
730 mData->empty = false; 729 mData->empty = false;
731 mData->role = role; 730 mData->role = role;
732} 731}
733 732
734QString Addressee::role() const 733QString Addressee::role() const
735{ 734{
736 return mData->role; 735 return mData->role;
737} 736}
738 737
739QString Addressee::roleLabel() 738QString Addressee::roleLabel()
740{ 739{
741 return i18n("Role"); 740 return i18n("Role");
742} 741}
743 742
744 743
745void Addressee::setOrganization( const QString &organization ) 744void Addressee::setOrganization( const QString &organization )
746{ 745{
747 if ( organization == mData->organization ) return; 746 if ( organization == mData->organization ) return;
748 detach(); 747 detach();
749 mData->empty = false; 748 mData->empty = false;
750 mData->organization = organization; 749 mData->organization = organization;
751} 750}
752 751
753QString Addressee::organization() const 752QString Addressee::organization() const
754{ 753{
755 return mData->organization; 754 return mData->organization;
756} 755}
757 756
758QString Addressee::organizationLabel() 757QString Addressee::organizationLabel()
759{ 758{
760 return i18n("Organization"); 759 return i18n("Organization");
761} 760}
762 761
763 762
764void Addressee::setNote( const QString &note ) 763void Addressee::setNote( const QString &note )
765{ 764{
766 if ( note == mData->note ) return; 765 if ( note == mData->note ) return;
767 detach(); 766 detach();
768 mData->empty = false; 767 mData->empty = false;
769 mData->note = note; 768 mData->note = note;
770} 769}
771 770
772QString Addressee::note() const 771QString Addressee::note() const
773{ 772{
774 return mData->note; 773 return mData->note;
775} 774}
776 775
777QString Addressee::noteLabel() 776QString Addressee::noteLabel()
778{ 777{
779 return i18n("Note"); 778 return i18n("Note");
780} 779}
781 780
782 781
783void Addressee::setProductId( const QString &productId ) 782void Addressee::setProductId( const QString &productId )
784{ 783{
785 if ( productId == mData->productId ) return; 784 if ( productId == mData->productId ) return;
786 detach(); 785 detach();
787 mData->empty = false; 786 mData->empty = false;
788 mData->productId = productId; 787 mData->productId = productId;
789} 788}
790 789
791QString Addressee::productId() const 790QString Addressee::productId() const
792{ 791{
793 return mData->productId; 792 return mData->productId;
794} 793}
795 794
796QString Addressee::productIdLabel() 795QString Addressee::productIdLabel()
797{ 796{
798 return i18n("Product Identifier"); 797 return i18n("Product Identifier");
799} 798}
800 799
801 800
802void Addressee::setRevision( const QDateTime &revision ) 801void Addressee::setRevision( const QDateTime &revision )
803{ 802{
804 if ( revision == mData->revision ) return; 803 if ( revision == mData->revision ) return;
805 detach(); 804 detach();
806 mData->empty = false; 805 mData->empty = false;
807 mData->revision = revision; 806 mData->revision = revision;
808} 807}
809 808
810QDateTime Addressee::revision() const 809QDateTime Addressee::revision() const
811{ 810{
812 return mData->revision; 811 return mData->revision;
813} 812}
814 813
815QString Addressee::revisionLabel() 814QString Addressee::revisionLabel()
816{ 815{
817 return i18n("Revision Date"); 816 return i18n("Revision Date");
818} 817}
819 818
820 819
821void Addressee::setSortString( const QString &sortString ) 820void Addressee::setSortString( const QString &sortString )
822{ 821{
823 if ( sortString == mData->sortString ) return; 822 if ( sortString == mData->sortString ) return;
824 detach(); 823 detach();
825 mData->empty = false; 824 mData->empty = false;
826 mData->sortString = sortString; 825 mData->sortString = sortString;
827} 826}
828 827
829QString Addressee::sortString() const 828QString Addressee::sortString() const
830{ 829{
831 return mData->sortString; 830 return mData->sortString;
832} 831}
833 832
834QString Addressee::sortStringLabel() 833QString Addressee::sortStringLabel()
835{ 834{
836 return i18n("Sort String"); 835 return i18n("Sort String");
837} 836}
838 837
839 838
840void Addressee::setUrl( const KURL &url ) 839void Addressee::setUrl( const KURL &url )
841{ 840{
842 if ( url == mData->url ) return; 841 if ( url == mData->url ) return;
843 detach(); 842 detach();
844 mData->empty = false; 843 mData->empty = false;
845 mData->url = url; 844 mData->url = url;
846} 845}
847 846
848KURL Addressee::url() const 847KURL Addressee::url() const
849{ 848{
850 return mData->url; 849 return mData->url;
851} 850}
852 851
853QString Addressee::urlLabel() 852QString Addressee::urlLabel()
854{ 853{
855 return i18n("URL"); 854 return i18n("URL");
856} 855}
857 856
858 857
859void Addressee::setSecrecy( const Secrecy &secrecy ) 858void Addressee::setSecrecy( const Secrecy &secrecy )
860{ 859{
861 if ( secrecy == mData->secrecy ) return; 860 if ( secrecy == mData->secrecy ) return;
862 detach(); 861 detach();
863 mData->empty = false; 862 mData->empty = false;
864 mData->secrecy = secrecy; 863 mData->secrecy = secrecy;
865} 864}
866 865
867Secrecy Addressee::secrecy() const 866Secrecy Addressee::secrecy() const
868{ 867{
869 return mData->secrecy; 868 return mData->secrecy;
870} 869}
871 870
872QString Addressee::secrecyLabel() 871QString Addressee::secrecyLabel()
873{ 872{
874 return i18n("Security Class"); 873 return i18n("Security Class");
875} 874}
876 875
877 876
878void Addressee::setLogo( const Picture &logo ) 877void Addressee::setLogo( const Picture &logo )
879{ 878{
880 if ( logo == mData->logo ) return; 879 if ( logo == mData->logo ) return;
881 detach(); 880 detach();
882 mData->empty = false; 881 mData->empty = false;
883 mData->logo = logo; 882 mData->logo = logo;
884} 883}
885 884
886Picture Addressee::logo() const 885Picture Addressee::logo() const
887{ 886{
888 return mData->logo; 887 return mData->logo;
889} 888}
890 889
891QString Addressee::logoLabel() 890QString Addressee::logoLabel()
892{ 891{
893 return i18n("Logo"); 892 return i18n("Logo");
894} 893}
895 894
896 895
897void Addressee::setPhoto( const Picture &photo ) 896void Addressee::setPhoto( const Picture &photo )
898{ 897{
899 if ( photo == mData->photo ) return; 898 if ( photo == mData->photo ) return;
900 detach(); 899 detach();
901 mData->empty = false; 900 mData->empty = false;
902 mData->photo = photo; 901 mData->photo = photo;
903} 902}
904 903
905Picture Addressee::photo() const 904Picture Addressee::photo() const
906{ 905{
907 return mData->photo; 906 return mData->photo;
908} 907}
909 908
910QString Addressee::photoLabel() 909QString Addressee::photoLabel()
911{ 910{
912 return i18n("Photo"); 911 return i18n("Photo");
913} 912}
914 913
915 914
916void Addressee::setSound( const Sound &sound ) 915void Addressee::setSound( const Sound &sound )
917{ 916{
918 if ( sound == mData->sound ) return; 917 if ( sound == mData->sound ) return;
919 detach(); 918 detach();
920 mData->empty = false; 919 mData->empty = false;
921 mData->sound = sound; 920 mData->sound = sound;
922} 921}
923 922
924Sound Addressee::sound() const 923Sound Addressee::sound() const
925{ 924{
926 return mData->sound; 925 return mData->sound;
927} 926}
928 927
929QString Addressee::soundLabel() 928QString Addressee::soundLabel()
930{ 929{
931 return i18n("Sound"); 930 return i18n("Sound");
932} 931}
933 932
934 933
935void Addressee::setAgent( const Agent &agent ) 934void Addressee::setAgent( const Agent &agent )
936{ 935{
937 if ( agent == mData->agent ) return; 936 if ( agent == mData->agent ) return;
938 detach(); 937 detach();
939 mData->empty = false; 938 mData->empty = false;
940 mData->agent = agent; 939 mData->agent = agent;
941} 940}
942 941
943Agent Addressee::agent() const 942Agent Addressee::agent() const
944{ 943{
945 return mData->agent; 944 return mData->agent;
946} 945}
947 946
948QString Addressee::agentLabel() 947QString Addressee::agentLabel()
949{ 948{
950 return i18n("Agent"); 949 return i18n("Agent");
951} 950}
952 951
953 952
954 953
955void Addressee::setNameFromString( const QString &str ) 954void Addressee::setNameFromString( const QString &str )
956{ 955{
957 setFormattedName( str ); 956 setFormattedName( str );
958 setName( str ); 957 setName( str );
959 958
960 static bool first = true; 959 static bool first = true;
961 static QStringList titles; 960 static QStringList titles;
962 static QStringList suffixes; 961 static QStringList suffixes;
963 static QStringList prefixes; 962 static QStringList prefixes;
964 963
965 if ( first ) { 964 if ( first ) {
966 first = false; 965 first = false;
967 titles += i18n( "Dr." ); 966 titles += i18n( "Dr." );
968 titles += i18n( "Miss" ); 967 titles += i18n( "Miss" );
969 titles += i18n( "Mr." ); 968 titles += i18n( "Mr." );
970 titles += i18n( "Mrs." ); 969 titles += i18n( "Mrs." );
971 titles += i18n( "Ms." ); 970 titles += i18n( "Ms." );
972 titles += i18n( "Prof." ); 971 titles += i18n( "Prof." );
973 972
974 suffixes += i18n( "I" ); 973 suffixes += i18n( "I" );
975 suffixes += i18n( "II" ); 974 suffixes += i18n( "II" );
976 suffixes += i18n( "III" ); 975 suffixes += i18n( "III" );
977 suffixes += i18n( "Jr." ); 976 suffixes += i18n( "Jr." );
978 suffixes += i18n( "Sr." ); 977 suffixes += i18n( "Sr." );
979 978
980 prefixes += "van"; 979 prefixes += "van";
981 prefixes += "von"; 980 prefixes += "von";
982 prefixes += "de"; 981 prefixes += "de";
983 982
984 KConfig config( locateLocal( "config", "kabcrc") ); 983 KConfig config( locateLocal( "config", "kabcrc") );
985 config.setGroup( "General" ); 984 config.setGroup( "General" );
986 titles += config.readListEntry( "Prefixes" ); 985 titles += config.readListEntry( "Prefixes" );
987 titles.remove( "" ); 986 titles.remove( "" );
988 prefixes += config.readListEntry( "Inclusions" ); 987 prefixes += config.readListEntry( "Inclusions" );
989 prefixes.remove( "" ); 988 prefixes.remove( "" );
990 suffixes += config.readListEntry( "Suffixes" ); 989 suffixes += config.readListEntry( "Suffixes" );
991 suffixes.remove( "" ); 990 suffixes.remove( "" );
992 } 991 }
993 992
994 // clear all name parts 993 // clear all name parts
995 setPrefix( "" ); 994 setPrefix( "" );
996 setGivenName( "" ); 995 setGivenName( "" );
997 setAdditionalName( "" ); 996 setAdditionalName( "" );
998 setFamilyName( "" ); 997 setFamilyName( "" );
999 setSuffix( "" ); 998 setSuffix( "" );
1000 999
1001 if ( str.isEmpty() ) 1000 if ( str.isEmpty() )
1002 return; 1001 return;
1003 1002
1004 int i = str.find(','); 1003 int i = str.find(',');
1005 if( i < 0 ) { 1004 if( i < 0 ) {
1006 QStringList parts = QStringList::split( " ", str ); 1005 QStringList parts = QStringList::split( " ", str );
1007 int leftOffset = 0; 1006 int leftOffset = 0;
1008 int rightOffset = parts.count() - 1; 1007 int rightOffset = parts.count() - 1;
1009 1008
1010 QString suffix; 1009 QString suffix;
1011 while ( rightOffset >= 0 ) { 1010 while ( rightOffset >= 0 ) {
1012 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1011 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1013 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1012 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1014 rightOffset--; 1013 rightOffset--;
1015 } else 1014 } else
1016 break; 1015 break;
1017 } 1016 }
1018 setSuffix( suffix ); 1017 setSuffix( suffix );
1019 1018
1020 if ( rightOffset < 0 ) 1019 if ( rightOffset < 0 )
1021 return; 1020 return;
1022 1021
1023 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1022 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1024 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1023 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1025 rightOffset--; 1024 rightOffset--;
1026 } else 1025 } else
1027 setFamilyName( parts[ rightOffset ] ); 1026 setFamilyName( parts[ rightOffset ] );
1028 1027
1029 QString prefix; 1028 QString prefix;
1030 while ( leftOffset < rightOffset ) { 1029 while ( leftOffset < rightOffset ) {
1031 if ( titles.contains( parts[ leftOffset ] ) ) { 1030 if ( titles.contains( parts[ leftOffset ] ) ) {
1032 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1031 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1033 leftOffset++; 1032 leftOffset++;
1034 } else 1033 } else
1035 break; 1034 break;
1036 } 1035 }
1037 setPrefix( prefix ); 1036 setPrefix( prefix );
1038 1037
1039 if ( leftOffset < rightOffset ) { 1038 if ( leftOffset < rightOffset ) {
1040 setGivenName( parts[ leftOffset ] ); 1039 setGivenName( parts[ leftOffset ] );
1041 leftOffset++; 1040 leftOffset++;
1042 } 1041 }
1043 1042
1044 QString additionalName; 1043 QString additionalName;
1045 while ( leftOffset < rightOffset ) { 1044 while ( leftOffset < rightOffset ) {
1046 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1045 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1047 leftOffset++; 1046 leftOffset++;
1048 } 1047 }
1049 setAdditionalName( additionalName ); 1048 setAdditionalName( additionalName );
1050 } else { 1049 } else {
1051 QString part1 = str.left( i ); 1050 QString part1 = str.left( i );
1052 QString part2 = str.mid( i + 1 ); 1051 QString part2 = str.mid( i + 1 );
1053 1052
1054 QStringList parts = QStringList::split( " ", part1 ); 1053 QStringList parts = QStringList::split( " ", part1 );
1055 int leftOffset = 0; 1054 int leftOffset = 0;
1056 int rightOffset = parts.count() - 1; 1055 int rightOffset = parts.count() - 1;
1057 1056
1058 QString suffix; 1057 QString suffix;
1059 while ( rightOffset >= 0 ) { 1058 while ( rightOffset >= 0 ) {
1060 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1059 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1061 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1060 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1062 rightOffset--; 1061 rightOffset--;
1063 } else 1062 } else
1064 break; 1063 break;
1065 } 1064 }
1066 setSuffix( suffix ); 1065 setSuffix( suffix );
1067 1066
1068 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1067 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1069 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1068 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1070 rightOffset--; 1069 rightOffset--;
1071 } else 1070 } else
1072 setFamilyName( parts[ rightOffset ] ); 1071 setFamilyName( parts[ rightOffset ] );
1073 1072
1074 QString prefix; 1073 QString prefix;
1075 while ( leftOffset < rightOffset ) { 1074 while ( leftOffset < rightOffset ) {
1076 if ( titles.contains( parts[ leftOffset ] ) ) { 1075 if ( titles.contains( parts[ leftOffset ] ) ) {
1077 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1076 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1078 leftOffset++; 1077 leftOffset++;
1079 } else 1078 } else
1080 break; 1079 break;
1081 } 1080 }
1082 1081
1083 parts = QStringList::split( " ", part2 ); 1082 parts = QStringList::split( " ", part2 );
1084 1083
1085 leftOffset = 0; 1084 leftOffset = 0;
1086 rightOffset = parts.count(); 1085 rightOffset = parts.count();
1087 1086
1088 while ( leftOffset < rightOffset ) { 1087 while ( leftOffset < rightOffset ) {
1089 if ( titles.contains( parts[ leftOffset ] ) ) { 1088 if ( titles.contains( parts[ leftOffset ] ) ) {
1090 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1089 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1091 leftOffset++; 1090 leftOffset++;
1092 } else 1091 } else
1093 break; 1092 break;
1094 } 1093 }
1095 setPrefix( prefix ); 1094 setPrefix( prefix );
1096 1095
1097 if ( leftOffset < rightOffset ) { 1096 if ( leftOffset < rightOffset ) {
1098 setGivenName( parts[ leftOffset ] ); 1097 setGivenName( parts[ leftOffset ] );
1099 leftOffset++; 1098 leftOffset++;
1100 } 1099 }
1101 1100
1102 QString additionalName; 1101 QString additionalName;
1103 while ( leftOffset < rightOffset ) { 1102 while ( leftOffset < rightOffset ) {
1104 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1103 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1105 leftOffset++; 1104 leftOffset++;
1106 } 1105 }
1107 setAdditionalName( additionalName ); 1106 setAdditionalName( additionalName );
1108 } 1107 }
1109} 1108}
1110 1109
1111QString Addressee::realName() const 1110QString Addressee::realName() const
1112{ 1111{
1113 if ( !formattedName().isEmpty() ) 1112 if ( !formattedName().isEmpty() )
1114 return formattedName(); 1113 return formattedName();
1115 1114
1116 QString n = assembledName(); 1115 QString n = assembledName();
1117 1116
1118 if ( n.isEmpty() ) 1117 if ( n.isEmpty() )
1119 n = name(); 1118 n = name();
1120 1119
1121 return n; 1120 return n;
1122} 1121}
1123 1122
1124QString Addressee::assembledName() const 1123QString Addressee::assembledName() const
1125{ 1124{
1126 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1125 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1127 familyName() + " " + suffix(); 1126 familyName() + " " + suffix();
1128 1127
1129 return name.simplifyWhiteSpace(); 1128 return name.simplifyWhiteSpace();
1130} 1129}
1131 1130
1132QString Addressee::fullEmail( const QString &email ) const 1131QString Addressee::fullEmail( const QString &email ) const
1133{ 1132{
1134 QString e; 1133 QString e;
1135 if ( email.isNull() ) { 1134 if ( email.isNull() ) {
1136 e = preferredEmail(); 1135 e = preferredEmail();
1137 } else { 1136 } else {
1138 e = email; 1137 e = email;
1139 } 1138 }
1140 if ( e.isEmpty() ) return QString::null; 1139 if ( e.isEmpty() ) return QString::null;
1141 1140
1142 QString text; 1141 QString text;
1143 if ( realName().isEmpty() ) 1142 if ( realName().isEmpty() )
1144 text = e; 1143 text = e;
1145 else 1144 else
1146 text = assembledName() + " <" + e + ">"; 1145 text = assembledName() + " <" + e + ">";
1147 1146
1148 return text; 1147 return text;
1149} 1148}
1150 1149
1151void Addressee::insertEmail( const QString &email, bool preferred ) 1150void Addressee::insertEmail( const QString &email, bool preferred )
1152{ 1151{
1153 detach(); 1152 detach();
1154 1153
1155 QStringList::Iterator it = mData->emails.find( email ); 1154 QStringList::Iterator it = mData->emails.find( email );
1156 1155
1157 if ( it != mData->emails.end() ) { 1156 if ( it != mData->emails.end() ) {
1158 if ( !preferred || it == mData->emails.begin() ) return; 1157 if ( !preferred || it == mData->emails.begin() ) return;
1159 mData->emails.remove( it ); 1158 mData->emails.remove( it );
1160 mData->emails.prepend( email ); 1159 mData->emails.prepend( email );
1161 } else { 1160 } else {
1162 if ( preferred ) { 1161 if ( preferred ) {
1163 mData->emails.prepend( email ); 1162 mData->emails.prepend( email );
1164 } else { 1163 } else {
1165 mData->emails.append( email ); 1164 mData->emails.append( email );
1166 } 1165 }
1167 } 1166 }
1168} 1167}
1169 1168
1170void Addressee::removeEmail( const QString &email ) 1169void Addressee::removeEmail( const QString &email )
1171{ 1170{
1172 detach(); 1171 detach();
1173 1172
1174 QStringList::Iterator it = mData->emails.find( email ); 1173 QStringList::Iterator it = mData->emails.find( email );
1175 if ( it == mData->emails.end() ) return; 1174 if ( it == mData->emails.end() ) return;
1176 1175
1177 mData->emails.remove( it ); 1176 mData->emails.remove( it );
1178} 1177}
1179 1178
1180QString Addressee::preferredEmail() const 1179QString Addressee::preferredEmail() const
1181{ 1180{
1182 if ( mData->emails.count() == 0 ) return QString::null; 1181 if ( mData->emails.count() == 0 ) return QString::null;
1183 else return mData->emails.first(); 1182 else return mData->emails.first();
1184} 1183}
1185 1184
1186QStringList Addressee::emails() const 1185QStringList Addressee::emails() const
1187{ 1186{
1188 return mData->emails; 1187 return mData->emails;
1189} 1188}
1190void Addressee::setEmails( const QStringList& emails ) { 1189void Addressee::setEmails( const QStringList& emails ) {
1191 detach(); 1190 detach();
1192 mData->emails = emails; 1191 mData->emails = emails;
1193} 1192}
1194void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1193void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1195{ 1194{
1196 detach(); 1195 detach();
1197 mData->empty = false; 1196 mData->empty = false;
1198 1197
1199 PhoneNumber::List::Iterator it; 1198 PhoneNumber::List::Iterator it;
1200 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1199 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1201 if ( (*it).id() == phoneNumber.id() ) { 1200 if ( (*it).id() == phoneNumber.id() ) {
1202 *it = phoneNumber; 1201 *it = phoneNumber;
1203 return; 1202 return;
1204 } 1203 }
1205 } 1204 }
1206 mData->phoneNumbers.append( phoneNumber ); 1205 mData->phoneNumbers.append( phoneNumber );
1207} 1206}
1208 1207
1209void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1208void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1210{ 1209{
1211 detach(); 1210 detach();
1212 1211
1213 PhoneNumber::List::Iterator it; 1212 PhoneNumber::List::Iterator it;
1214 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1213 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1215 if ( (*it).id() == phoneNumber.id() ) { 1214 if ( (*it).id() == phoneNumber.id() ) {
1216 mData->phoneNumbers.remove( it ); 1215 mData->phoneNumbers.remove( it );
1217 return; 1216 return;
1218 } 1217 }
1219 } 1218 }
1220} 1219}
1221 1220
1222PhoneNumber Addressee::phoneNumber( int type ) const 1221PhoneNumber Addressee::phoneNumber( int type ) const
1223{ 1222{
1224 PhoneNumber phoneNumber( "", type ); 1223 PhoneNumber phoneNumber( "", type );
1225 PhoneNumber::List::ConstIterator it; 1224 PhoneNumber::List::ConstIterator it;
1226 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1225 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1227 if ( matchBinaryPattern( (*it).type(), type ) ) { 1226 if ( matchBinaryPattern( (*it).type(), type ) ) {
1228 if ( (*it).type() & PhoneNumber::Pref ) 1227 if ( (*it).type() & PhoneNumber::Pref )
1229 return (*it); 1228 return (*it);
1230 else if ( phoneNumber.number().isEmpty() ) 1229 else if ( phoneNumber.number().isEmpty() )
1231 phoneNumber = (*it); 1230 phoneNumber = (*it);
1232 } 1231 }
1233 } 1232 }
1234 1233
1235 return phoneNumber; 1234 return phoneNumber;
1236} 1235}
1237 1236
1238PhoneNumber::List Addressee::phoneNumbers() const 1237PhoneNumber::List Addressee::phoneNumbers() const
1239{ 1238{
1240 return mData->phoneNumbers; 1239 return mData->phoneNumbers;
1241} 1240}
1242 1241
1243PhoneNumber::List Addressee::phoneNumbers( int type ) const 1242PhoneNumber::List Addressee::phoneNumbers( int type ) const
1244{ 1243{
1245 PhoneNumber::List list; 1244 PhoneNumber::List list;
1246 1245
1247 PhoneNumber::List::ConstIterator it; 1246 PhoneNumber::List::ConstIterator it;
1248 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1247 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1249 if ( matchBinaryPattern( (*it).type(), type ) ) { 1248 if ( matchBinaryPattern( (*it).type(), type ) ) {
1250 list.append( *it ); 1249 list.append( *it );
1251 } 1250 }
1252 } 1251 }
1253 return list; 1252 return list;
1254} 1253}
1255 1254
1256PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1255PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1257{ 1256{
1258 PhoneNumber::List::ConstIterator it; 1257 PhoneNumber::List::ConstIterator it;
1259 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1258 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1260 if ( (*it).id() == id ) { 1259 if ( (*it).id() == id ) {
1261 return *it; 1260 return *it;
1262 } 1261 }
1263 } 1262 }
1264 return PhoneNumber(); 1263 return PhoneNumber();
1265} 1264}
1266 1265
1267void Addressee::insertKey( const Key &key ) 1266void Addressee::insertKey( const Key &key )
1268{ 1267{
1269 detach(); 1268 detach();
1270 mData->empty = false; 1269 mData->empty = false;
1271 1270
1272 Key::List::Iterator it; 1271 Key::List::Iterator it;
1273 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1272 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1274 if ( (*it).id() == key.id() ) { 1273 if ( (*it).id() == key.id() ) {
1275 *it = key; 1274 *it = key;
1276 return; 1275 return;
1277 } 1276 }
1278 } 1277 }
1279 mData->keys.append( key ); 1278 mData->keys.append( key );
1280} 1279}
1281 1280
1282void Addressee::removeKey( const Key &key ) 1281void Addressee::removeKey( const Key &key )
1283{ 1282{
1284 detach(); 1283 detach();
1285 1284
1286 Key::List::Iterator it; 1285 Key::List::Iterator it;
1287 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1286 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1288 if ( (*it).id() == key.id() ) { 1287 if ( (*it).id() == key.id() ) {
1289 mData->keys.remove( key ); 1288 mData->keys.remove( key );
1290 return; 1289 return;
1291 } 1290 }
1292 } 1291 }
1293} 1292}
1294 1293
1295Key Addressee::key( int type, QString customTypeString ) const 1294Key Addressee::key( int type, QString customTypeString ) const
1296{ 1295{
1297 Key::List::ConstIterator it; 1296 Key::List::ConstIterator it;
1298 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1297 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1299 if ( (*it).type() == type ) { 1298 if ( (*it).type() == type ) {
1300 if ( type == Key::Custom ) { 1299 if ( type == Key::Custom ) {
1301 if ( customTypeString.isEmpty() ) { 1300 if ( customTypeString.isEmpty() ) {
1302 return *it; 1301 return *it;
1303 } else { 1302 } else {
1304 if ( (*it).customTypeString() == customTypeString ) 1303 if ( (*it).customTypeString() == customTypeString )
1305 return (*it); 1304 return (*it);
1306 } 1305 }
1307 } else { 1306 } else {
1308 return *it; 1307 return *it;
1309 } 1308 }
1310 } 1309 }
1311 } 1310 }
1312 return Key( QString(), type ); 1311 return Key( QString(), type );
1313} 1312}
1314void Addressee::setKeys( const Key::List& list ) { 1313void Addressee::setKeys( const Key::List& list ) {
1315 detach(); 1314 detach();
1316 mData->keys = list; 1315 mData->keys = list;
1317} 1316}
1318 1317
1319Key::List Addressee::keys() const 1318Key::List Addressee::keys() const
1320{ 1319{
1321 return mData->keys; 1320 return mData->keys;
1322} 1321}
1323 1322
1324Key::List Addressee::keys( int type, QString customTypeString ) const 1323Key::List Addressee::keys( int type, QString customTypeString ) const
1325{ 1324{
1326 Key::List list; 1325 Key::List list;
1327 1326
1328 Key::List::ConstIterator it; 1327 Key::List::ConstIterator it;
1329 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1328 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1330 if ( (*it).type() == type ) { 1329 if ( (*it).type() == type ) {
1331 if ( type == Key::Custom ) { 1330 if ( type == Key::Custom ) {
1332 if ( customTypeString.isEmpty() ) { 1331 if ( customTypeString.isEmpty() ) {