summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index bfcfab5..18b4d58 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,1816 +1,1841 @@
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 //qDebug("csum: %d %d %d", i,k,cSum);
199 } 200 }
200 } 201 }
201 202
202 } 203 }
203 //QString dump = attList.join(","); 204 //QString dump = attList.join(",");
204 //qDebug("csum: %d %s", cSum,dump.latin1()); 205 //qDebug("csum: %d %s", cSum,dump.latin1());
205 206
206 return cSum; 207 return cSum;
207 208
208} 209}
209void Addressee::computeCsum(const QString &dev) 210void Addressee::computeCsum(const QString &dev)
210{ 211{
211 QStringList l; 212 QStringList l;
212 //if ( !mData->name.isEmpty() ) l.append(mData->name); 213 //if ( !mData->name.isEmpty() ) l.append(mData->name);
213 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 214 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 215 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 216 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
216 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); 217 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 218 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 219 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 220 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 221 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 222 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 223 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 224 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
224 if ( !mData->title .isEmpty() ) l.append( mData->title ); 225 if ( !mData->title .isEmpty() ) l.append( mData->title );
225 if ( !mData->role.isEmpty() ) l.append( mData->role ); 226 if ( !mData->role.isEmpty() ) l.append( mData->role );
226 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 227 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
227 if ( !mData->note.isEmpty() ) l.append( mData->note ); 228 if ( !mData->note.isEmpty() ) l.append( mData->note );
228 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 229 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 230 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 231 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
231 // if ( !mData->logo.isEmpty() ) l.append( ); 232 if ( !mData->logo.undefined() ) {
232 //if ( !mData->photo.isEmpty() ) l.append( ); 233 if ( !mData->logo.isIntern() )
233 //if ( !mData->sound.isEmpty() ) l.append( ); 234 l.append( mData->logo.url() );
235 else
236 l.append( QString::number(mData->logo.data().width()* mData->logo.data().height()));
237 } else {
238 l.append( "nologo");
239 }
240 if ( !mData->photo.undefined() ) {
241 if ( !mData->photo.isIntern() )
242 l.append( mData->photo.url() );
243 else
244 l.append( QString::number(mData->photo.data().width()* mData->photo.data().height()));
245 } else {
246 l.append( "nophoto");
247 }
248#if 0
249 if ( !mData->sound.undefined() ) {
250 if ( !mData->sound.isIntern() )
251 l.append( mData->sound.url() );
252 else
253 l.append( QString(mData->sound.data().with()* mData->sound.data().height()));
254 } else {
255 l.append( "nosound");
256 }
257#endif
234 //if ( !mData->agent.isEmpty() ) l.append( ); 258 //if ( !mData->agent.isEmpty() ) l.append( );
235 if ( mData->url.isValid() ) 259 if ( mData->url.isValid() )
236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 260 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
237 KABC::PhoneNumber::List phoneNumbers; 261 KABC::PhoneNumber::List phoneNumbers;
238 KABC::PhoneNumber::List::Iterator phoneIter; 262 KABC::PhoneNumber::List::Iterator phoneIter;
239 263
240 QStringList t; 264 QStringList t;
241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 265 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
242 ++phoneIter ) 266 ++phoneIter )
243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 267 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
244 t.sort(); 268 t.sort();
245 uint iii; 269 uint iii;
246 for ( iii = 0; iii < t.count(); ++iii) 270 for ( iii = 0; iii < t.count(); ++iii)
247 l.append( t[iii] ); 271 l.append( t[iii] );
248 t = mData->emails; 272 t = mData->emails;
249 t.sort(); 273 t.sort();
250 for ( iii = 0; iii < t.count(); ++iii) 274 for ( iii = 0; iii < t.count(); ++iii)
251 l.append( t[iii] ); 275 l.append( t[iii] );
252 t = mData->categories; 276 t = mData->categories;
253 t.sort(); 277 t.sort();
254 for ( iii = 0; iii < t.count(); ++iii) 278 for ( iii = 0; iii < t.count(); ++iii)
255 l.append( t[iii] ); 279 l.append( t[iii] );
256 t = mData->custom; 280 t = mData->custom;
257 t.sort(); 281 t.sort();
258 for ( iii = 0; iii < t.count(); ++iii) 282 for ( iii = 0; iii < t.count(); ++iii)
259 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { 283 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
260 int find = t[iii].find (':')+1; 284 int find = t[iii].find (':')+1;
261 //qDebug("lennnn %d %d ", find, t[iii].length()); 285 //qDebug("lennnn %d %d ", find, t[iii].length());
262 if ( find < t[iii].length()) 286 if ( find < t[iii].length())
263 l.append( t[iii] ); 287 l.append( t[iii] );
264 288
265 } 289 }
266 KABC::Address::List::Iterator addressIter; 290 KABC::Address::List::Iterator addressIter;
267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 291 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
268 ++addressIter ) { 292 ++addressIter ) {
269 t = (*addressIter).asList(); 293 t = (*addressIter).asList();
270 t.sort(); 294 t.sort();
271 for ( iii = 0; iii < t.count(); ++iii) 295 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 296 l.append( t[iii] );
273 } 297 }
274 uint cs = getCsum4List(l); 298 uint cs = getCsum4List(l);
275 299
276#if 0 300#if 0
277 for ( iii = 0; iii < l.count(); ++iii) 301 for ( iii = 0; iii < l.count(); ++iii)
278 qDebug("%d***%s***",iii,l[iii].latin1()); 302 qDebug("%d***%s***",iii,l[iii].latin1());
279 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 303 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
280#endif 304#endif
305
281 306
282 setCsum( dev, QString::number (cs )); 307 setCsum( dev, QString::number (cs ));
283} 308}
284 309
285void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 310void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
286{ 311{
287 // merge all standard non-outlook fields. 312 // merge all standard non-outlook fields.
288 //if isSubSet (e.g. mobile phone sync) merge all fields 313 //if isSubSet (e.g. mobile phone sync) merge all fields
289 314
290 detach(); 315 detach();
291 if ( isSubSet ) { 316 if ( isSubSet ) {
292 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 317 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
293 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 318 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
294 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 319 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
295 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 320 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
296 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 321 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
297 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 322 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
298 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 323 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
299 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 324 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
300 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 325 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
301 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 326 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
302 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 327 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
303 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 328 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 329 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 330 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
306 if ( !mData->birthday.isValid() ) 331 if ( !mData->birthday.isValid() )
307 if ( ad.mData->birthday.isValid()) 332 if ( ad.mData->birthday.isValid())
308 mData->birthday = ad.mData->birthday; 333 mData->birthday = ad.mData->birthday;
309 334
310 } 335 }
311 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 336 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
312 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 337 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
313 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 338 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
314 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 339 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
315 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 340 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
316 QStringList t; 341 QStringList t;
317 QStringList tAD; 342 QStringList tAD;
318 uint iii; 343 uint iii;
319 344
320 // ********** phone numbers 345 // ********** phone numbers
321 if ( isSubSet ) { 346 if ( isSubSet ) {
322 PhoneNumber::List phoneAD = ad.phoneNumbers(); 347 PhoneNumber::List phoneAD = ad.phoneNumbers();
323 PhoneNumber::List::Iterator phoneItAD; 348 PhoneNumber::List::Iterator phoneItAD;
324 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 349 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
325 bool found = false; 350 bool found = false;
326 PhoneNumber::List::Iterator it; 351 PhoneNumber::List::Iterator it;
327 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 352 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
328 if ( ( *phoneItAD ).contains( (*it) ) ) { 353 if ( ( *phoneItAD ).contains( (*it) ) ) {
329 found = true; 354 found = true;
330 (*it).setType( ( *phoneItAD ).type() ); 355 (*it).setType( ( *phoneItAD ).type() );
331 (*it).setNumber( ( *phoneItAD ).number() ); 356 (*it).setNumber( ( *phoneItAD ).number() );
332 break; 357 break;
333 } 358 }
334 } 359 }
335 // if ( isSubSet && ! found ) 360 // if ( isSubSet && ! found )
336 if ( ! found ) // LR try this one... 361 if ( ! found ) // LR try this one...
337 mData->phoneNumbers.append( *phoneItAD ); 362 mData->phoneNumbers.append( *phoneItAD );
338 } 363 }
339 } else { 364 } else {
340 PhoneNumber::List phoneAD = ad.phoneNumbers(); 365 PhoneNumber::List phoneAD = ad.phoneNumbers();
341 PhoneNumber::List::Iterator phoneItAD; 366 PhoneNumber::List::Iterator phoneItAD;
342 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 367 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
343 bool found = false; 368 bool found = false;
344 PhoneNumber::List::Iterator it; 369 PhoneNumber::List::Iterator it;
345 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 370 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
346 if ( ( *phoneItAD ).contains( (*it) ) ) { 371 if ( ( *phoneItAD ).contains( (*it) ) ) {
347 found = true; 372 found = true;
348 (*it).setType( ( *phoneItAD ).type() ); 373 (*it).setType( ( *phoneItAD ).type() );
349 (*it).setNumber( ( *phoneItAD ).number() ); 374 (*it).setNumber( ( *phoneItAD ).number() );
350 break; 375 break;
351 } 376 }
352 } 377 }
353 if ( ! found ) { // append numbers which do not have work or home type 378 if ( ! found ) { // append numbers which do not have work or home type
354 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) 379 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) )
355 mData->phoneNumbers.append( *phoneItAD ); 380 mData->phoneNumbers.append( *phoneItAD );
356 } 381 }
357 } 382 }
358 } 383 }
359 if ( isSubSet ) { 384 if ( isSubSet ) {
360 // ************* emails; 385 // ************* emails;
361 t = mData->emails; 386 t = mData->emails;
362 tAD = ad.mData->emails; 387 tAD = ad.mData->emails;
363 for ( iii = 0; iii < tAD.count(); ++iii) 388 for ( iii = 0; iii < tAD.count(); ++iii)
364 if ( !t.contains(tAD[iii] ) ) 389 if ( !t.contains(tAD[iii] ) )
365 mData->emails.append( tAD[iii] ); 390 mData->emails.append( tAD[iii] );
366 } 391 }
367 392
368 // ************* categories; 393 // ************* categories;
369 if ( isSubSet ) { 394 if ( isSubSet ) {
370 t = mData->categories; 395 t = mData->categories;
371 tAD = ad.mData->categories; 396 tAD = ad.mData->categories;
372 for ( iii = 0; iii < tAD.count(); ++iii) 397 for ( iii = 0; iii < tAD.count(); ++iii)
373 if ( !t.contains(tAD[iii] ) ) 398 if ( !t.contains(tAD[iii] ) )
374 mData->categories.append( tAD[iii] ); 399 mData->categories.append( tAD[iii] );
375 } 400 }
376 QStringList::ConstIterator it; 401 QStringList::ConstIterator it;
377 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 402 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
378 QString qualifiedName = (*it).left( (*it).find( ":" )); 403 QString qualifiedName = (*it).left( (*it).find( ":" ));
379 bool found = false; 404 bool found = false;
380 QStringList::ConstIterator itL; 405 QStringList::ConstIterator itL;
381 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 406 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
382 if ( (*itL).startsWith( qualifiedName ) ) { 407 if ( (*itL).startsWith( qualifiedName ) ) {
383 found = true; 408 found = true;
384 break; 409 break;
385 } 410 }
386 } 411 }
387 if ( ! found ) { 412 if ( ! found ) {
388 mData->custom.append( *it ); 413 mData->custom.append( *it );
389 } 414 }
390 } 415 }
391 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 416 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
392 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 417 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
393 if ( !mData->sound.isIntern() ) { 418 if ( !mData->sound.isIntern() ) {
394 if ( mData->sound.url().isEmpty() ) { 419 if ( mData->sound.url().isEmpty() ) {
395 mData->sound = ad.mData->sound; 420 mData->sound = ad.mData->sound;
396 } 421 }
397 } 422 }
398 if ( !mData->agent.isIntern() ) { 423 if ( !mData->agent.isIntern() ) {
399 if ( mData->agent.url().isEmpty() ) { 424 if ( mData->agent.url().isEmpty() ) {
400 mData->agent = ad.mData->agent; 425 mData->agent = ad.mData->agent;
401 } 426 }
402 } 427 }
403 { 428 {
404 Key::List::Iterator itA; 429 Key::List::Iterator itA;
405 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 430 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
406 bool found = false; 431 bool found = false;
407 Key::List::Iterator it; 432 Key::List::Iterator it;
408 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 433 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
409 if ( (*it) == (*itA)) { 434 if ( (*it) == (*itA)) {
410 found = true; 435 found = true;
411 break; 436 break;
412 437
413 } 438 }
414 } 439 }
415 if ( ! found ) { 440 if ( ! found ) {
416 mData->keys.append( *itA ); 441 mData->keys.append( *itA );
417 } 442 }
418 } 443 }
419 } 444 }
420 if ( isSubSet ) { 445 if ( isSubSet ) {
421 KABC::Address::List::Iterator addressIterA; 446 KABC::Address::List::Iterator addressIterA;
422 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 447 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
423 bool found = false; 448 bool found = false;
424 KABC::Address::List::Iterator addressIter; 449 KABC::Address::List::Iterator addressIter;
425 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 450 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
426 ++addressIter ) { 451 ++addressIter ) {
427 if ( (*addressIter) == (*addressIterA)) { 452 if ( (*addressIter) == (*addressIterA)) {
428 found = true; 453 found = true;
429 (*addressIter).setType( (*addressIterA).type() ); 454 (*addressIter).setType( (*addressIterA).type() );
430 break; 455 break;
431 } 456 }
432 457
433 } 458 }
434 if ( isSubSet && ! found ) { 459 if ( isSubSet && ! found ) {
435 mData->addresses.append( *addressIterA ); 460 mData->addresses.append( *addressIterA );
436 } 461 }
437 } 462 }
438 } 463 }
439 //qDebug("merge contact %s ", ad.uid().latin1()); 464 //qDebug("merge contact %s ", ad.uid().latin1());
440 setUid( ad.uid() ); 465 setUid( ad.uid() );
441 setRevision( ad.revision() ); 466 setRevision( ad.revision() );
442} 467}
443 468
444bool Addressee::removeVoice() 469bool Addressee::removeVoice()
445{ 470{
446 PhoneNumber::List phoneN = phoneNumbers(); 471 PhoneNumber::List phoneN = phoneNumbers();
447 PhoneNumber::List::Iterator phoneIt; 472 PhoneNumber::List::Iterator phoneIt;
448 bool found = false; 473 bool found = false;
449 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 474 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
450 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 475 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
451 if ((*phoneIt).type() - PhoneNumber::Voice ) { 476 if ((*phoneIt).type() - PhoneNumber::Voice ) {
452 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 477 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
453 insertPhoneNumber( (*phoneIt) ); 478 insertPhoneNumber( (*phoneIt) );
454 found = true; 479 found = true;
455 } 480 }
456 } 481 }
457 482
458 } 483 }
459 return found; 484 return found;
460} 485}
461 486
462bool Addressee::containsAdr(const Addressee& ad ) 487bool Addressee::containsAdr(const Addressee& ad )
463{ 488{
464 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 489 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
465 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 490 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
466 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 491 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
467 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 492 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
468 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 493 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
469 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 494 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
470 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 495 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
471 496
472 // compare phone numbers 497 // compare phone numbers
473 PhoneNumber::List phoneN = ad.phoneNumbers(); 498 PhoneNumber::List phoneN = ad.phoneNumbers();
474 PhoneNumber::List::Iterator phoneIt; 499 PhoneNumber::List::Iterator phoneIt;
475 bool found = false; 500 bool found = false;
476 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 501 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
477 bool found = false; 502 bool found = false;
478 PhoneNumber::List phoneL = ad.phoneNumbers(); 503 PhoneNumber::List phoneL = ad.phoneNumbers();
479 PhoneNumber::List::Iterator phoneItL; 504 PhoneNumber::List::Iterator phoneItL;
480 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 505 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
481 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 506 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
482 found = true; 507 found = true;
483 break; 508 break;
484 } 509 }
485 } 510 }
486 if ( ! found ) 511 if ( ! found )
487 return false; 512 return false;
488 } 513 }
489 return true; 514 return true;
490 515
491} 516}
492void Addressee::simplifyAddresses() 517void Addressee::simplifyAddresses()
493{ 518{
494 519
495 520
496 Address::List list; 521 Address::List list;
497 Address::List::Iterator it; 522 Address::List::Iterator it;
498 Address::List::Iterator it2; 523 Address::List::Iterator it2;
499 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 524 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
500 it2 = it; 525 it2 = it;
501 ++it2; 526 ++it2;
502 for( ; it2 != mData->addresses.end(); ++it2 ) { 527 for( ; it2 != mData->addresses.end(); ++it2 ) {
503 if ( (*it) == (*it2) ) { 528 if ( (*it) == (*it2) ) {
504 list.append( *it ); 529 list.append( *it );
505 break; 530 break;
506 } 531 }
507 } 532 }
508 } 533 }
509 for( it = list.begin(); it != list.end(); ++it ) { 534 for( it = list.begin(); it != list.end(); ++it ) {
510 removeAddress( (*it) ); 535 removeAddress( (*it) );
511 } 536 }
512 537
513 list.clear(); 538 list.clear();
514 int max = 2; 539 int max = 2;
515 if ( mData->url.isValid() ) 540 if ( mData->url.isValid() )
516 max = 1; 541 max = 1;
517 if ( mData->addresses.count() <= max ) return ; 542 if ( mData->addresses.count() <= max ) return ;
518 int count = 0; 543 int count = 0;
519 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 544 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
520 if ( count >= max ) 545 if ( count >= max )
521 list.append( *it ); 546 list.append( *it );
522 ++count; 547 ++count;
523 } 548 }
524 for( it = list.begin(); it != list.end(); ++it ) { 549 for( it = list.begin(); it != list.end(); ++it ) {
525 removeAddress( (*it) ); 550 removeAddress( (*it) );
526 } 551 }
527} 552}
528 553
529// removes all emails but the first 554// removes all emails but the first
530// needed by phone sync 555// needed by phone sync
531void Addressee::simplifyEmails() 556void Addressee::simplifyEmails()
532{ 557{
533 if ( mData->emails.count() == 0 ) return ; 558 if ( mData->emails.count() == 0 ) return ;
534 QString email = mData->emails.first(); 559 QString email = mData->emails.first();
535 detach(); 560 detach();
536 mData->emails.clear(); 561 mData->emails.clear();
537 mData->emails.append( email ); 562 mData->emails.append( email );
538} 563}
539 564
540void Addressee::simplifyPhoneNumbers() 565void Addressee::simplifyPhoneNumbers()
541{ 566{
542 int max = 4; 567 int max = 4;
543 int inList = mData->phoneNumbers.count(); 568 int inList = mData->phoneNumbers.count();
544 KABC::PhoneNumber::List removeNumbers; 569 KABC::PhoneNumber::List removeNumbers;
545 KABC::PhoneNumber::List::Iterator phoneIter; 570 KABC::PhoneNumber::List::Iterator phoneIter;
546 if ( inList > max ) { 571 if ( inList > max ) {
547 // delete non-preferred numbers 572 // delete non-preferred numbers
548 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 573 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
549 ++phoneIter ) { 574 ++phoneIter ) {
550 if ( inList > max ) { 575 if ( inList > max ) {
551 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 576 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
552 removeNumbers.append( ( *phoneIter ) ); 577 removeNumbers.append( ( *phoneIter ) );
553 --inList; 578 --inList;
554 } 579 }
555 } else 580 } else
556 break; 581 break;
557 } 582 }
558 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 583 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
559 ++phoneIter ) { 584 ++phoneIter ) {
560 removePhoneNumber(( *phoneIter )); 585 removePhoneNumber(( *phoneIter ));
561 } 586 }
562 // delete preferred numbers 587 // delete preferred numbers
563 if ( inList > max ) { 588 if ( inList > max ) {
564 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 589 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
565 ++phoneIter ) { 590 ++phoneIter ) {
566 if ( inList > max ) { 591 if ( inList > max ) {
567 removeNumbers.append( ( *phoneIter ) ); 592 removeNumbers.append( ( *phoneIter ) );
568 --inList; 593 --inList;
569 } else 594 } else
570 break; 595 break;
571 } 596 }
572 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 597 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
573 ++phoneIter ) { 598 ++phoneIter ) {
574 removePhoneNumber(( *phoneIter )); 599 removePhoneNumber(( *phoneIter ));
575 } 600 }
576 } 601 }
577 } 602 }
578 // remove non-numeric characters 603 // remove non-numeric characters
579 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 604 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
580 ++phoneIter ) { 605 ++phoneIter ) {
581 if ( ! ( *phoneIter ).simplifyNumber() ) 606 if ( ! ( *phoneIter ).simplifyNumber() )
582 removeNumbers.append( ( *phoneIter ) ); 607 removeNumbers.append( ( *phoneIter ) );
583 } 608 }
584 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 609 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
585 ++phoneIter ) { 610 ++phoneIter ) {
586 removePhoneNumber(( *phoneIter )); 611 removePhoneNumber(( *phoneIter ));
587 } 612 }
588} 613}
589void Addressee::simplifyPhoneNumberTypes() 614void Addressee::simplifyPhoneNumberTypes()
590{ 615{
591 KABC::PhoneNumber::List::Iterator phoneIter; 616 KABC::PhoneNumber::List::Iterator phoneIter;
592 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 617 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
593 ++phoneIter ) 618 ++phoneIter )
594 ( *phoneIter ).simplifyType(); 619 ( *phoneIter ).simplifyType();
595} 620}
596void Addressee::removeID(const QString &prof) 621void Addressee::removeID(const QString &prof)
597{ 622{
598 detach(); 623 detach();
599 if ( prof.isEmpty() ) 624 if ( prof.isEmpty() )
600 mData->mExternalId = ":"; 625 mData->mExternalId = ":";
601 else 626 else
602 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 627 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
603 628
604} 629}
605void Addressee::setID( const QString & prof , const QString & id ) 630void Addressee::setID( const QString & prof , const QString & id )
606{ 631{
607 detach(); 632 detach();
608 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 633 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
609 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 634 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
610} 635}
611void Addressee::setTempSyncStat( int id ) 636void Addressee::setTempSyncStat( int id )
612{ 637{
613 if ( mData->mTempSyncStat == id ) return; 638 if ( mData->mTempSyncStat == id ) return;
614 detach(); 639 detach();
615 mData->mTempSyncStat = id; 640 mData->mTempSyncStat = id;
616} 641}
617int Addressee::tempSyncStat() const 642int Addressee::tempSyncStat() const
618{ 643{
619 return mData->mTempSyncStat; 644 return mData->mTempSyncStat;
620} 645}
621 646
622const QString Addressee::getID( const QString & prof) const 647const QString Addressee::getID( const QString & prof) const
623{ 648{
624 return KIdManager::getId ( mData->mExternalId, prof ); 649 return KIdManager::getId ( mData->mExternalId, prof );
625} 650}
626 651
627void Addressee::setCsum( const QString & prof , const QString & id ) 652void Addressee::setCsum( const QString & prof , const QString & id )
628{ 653{
629 detach(); 654 detach();
630 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 655 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
631 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 656 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
632 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 657 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
633} 658}
634 659
635const QString Addressee::getCsum( const QString & prof) const 660const QString Addressee::getCsum( const QString & prof) const
636{ 661{
637 return KIdManager::getCsum ( mData->mExternalId, prof ); 662 return KIdManager::getCsum ( mData->mExternalId, prof );
638} 663}
639 664
640void Addressee::setIDStr( const QString & s ) 665void Addressee::setIDStr( const QString & s )
641{ 666{
642 detach(); 667 detach();
643 mData->mExternalId = s; 668 mData->mExternalId = s;
644} 669}
645 670
646const QString Addressee::IDStr() const 671const QString Addressee::IDStr() const
647{ 672{
648 return mData->mExternalId; 673 return mData->mExternalId;
649} 674}
650 675
651void Addressee::setExternalUID( const QString &id ) 676void Addressee::setExternalUID( const QString &id )
652{ 677{
653 if ( id == mData->externalUID ) return; 678 if ( id == mData->externalUID ) return;
654 detach(); 679 detach();
655 mData->empty = false; 680 mData->empty = false;
656 mData->externalUID = id; 681 mData->externalUID = id;
657} 682}
658 683
659const QString Addressee::externalUID() const 684const QString Addressee::externalUID() const
660{ 685{
661 return mData->externalUID; 686 return mData->externalUID;
662} 687}
663void Addressee::setOriginalExternalUID( const QString &id ) 688void Addressee::setOriginalExternalUID( const QString &id )
664{ 689{
665 if ( id == mData->originalExternalUID ) return; 690 if ( id == mData->originalExternalUID ) return;
666 detach(); 691 detach();
667 mData->empty = false; 692 mData->empty = false;
668 //qDebug("*******Set orig uid %s ", id.latin1()); 693 //qDebug("*******Set orig uid %s ", id.latin1());
669 mData->originalExternalUID = id; 694 mData->originalExternalUID = id;
670} 695}
671 696
672QString Addressee::originalExternalUID() const 697QString Addressee::originalExternalUID() const
673{ 698{
674 return mData->originalExternalUID; 699 return mData->originalExternalUID;
675} 700}
676 701
677void Addressee::setUid( const QString &id ) 702void Addressee::setUid( const QString &id )
678{ 703{
679 if ( id == mData->uid ) return; 704 if ( id == mData->uid ) return;
680 detach(); 705 detach();
681 //qDebug("****setuid %s ", id.latin1()); 706 //qDebug("****setuid %s ", id.latin1());
682 mData->empty = false; 707 mData->empty = false;
683 mData->uid = id; 708 mData->uid = id;
684} 709}
685 710
686const QString Addressee::uid() const 711const QString Addressee::uid() const
687{ 712{
688 if ( mData->uid.isEmpty() ) 713 if ( mData->uid.isEmpty() )
689 mData->uid = KApplication::randomString( 10 ); 714 mData->uid = KApplication::randomString( 10 );
690 715
691 return mData->uid; 716 return mData->uid;
692} 717}
693 718
694QString Addressee::uidLabel() 719QString Addressee::uidLabel()
695{ 720{
696 return i18n("Unique Identifier"); 721 return i18n("Unique Identifier");
697} 722}
698 723
699void Addressee::setName( const QString &name ) 724void Addressee::setName( const QString &name )
700{ 725{
701 if ( name == mData->name ) return; 726 if ( name == mData->name ) return;
702 detach(); 727 detach();
703 mData->empty = false; 728 mData->empty = false;
704 mData->name = name; 729 mData->name = name;
705} 730}
706 731
707QString Addressee::name() const 732QString Addressee::name() const
708{ 733{
709 return mData->name; 734 return mData->name;
710} 735}
711 736
712QString Addressee::nameLabel() 737QString Addressee::nameLabel()
713{ 738{
714 return i18n("Name"); 739 return i18n("Name");
715} 740}
716 741
717 742
718void Addressee::setFormattedName( const QString &formattedName ) 743void Addressee::setFormattedName( const QString &formattedName )
719{ 744{
720 if ( formattedName == mData->formattedName ) return; 745 if ( formattedName == mData->formattedName ) return;
721 detach(); 746 detach();
722 mData->empty = false; 747 mData->empty = false;
723 mData->formattedName = formattedName; 748 mData->formattedName = formattedName;
724} 749}
725 750
726QString Addressee::formattedName() const 751QString Addressee::formattedName() const
727{ 752{
728 return mData->formattedName; 753 return mData->formattedName;
729} 754}
730 755
731QString Addressee::formattedNameLabel() 756QString Addressee::formattedNameLabel()
732{ 757{
733 return i18n("Formatted Name"); 758 return i18n("Formatted Name");
734} 759}
735 760
736 761
737void Addressee::setFamilyName( const QString &familyName ) 762void Addressee::setFamilyName( const QString &familyName )
738{ 763{
739 if ( familyName == mData->familyName ) return; 764 if ( familyName == mData->familyName ) return;
740 detach(); 765 detach();
741 mData->empty = false; 766 mData->empty = false;
742 mData->familyName = familyName; 767 mData->familyName = familyName;
743} 768}
744 769
745QString Addressee::familyName() const 770QString Addressee::familyName() const
746{ 771{
747 return mData->familyName; 772 return mData->familyName;
748} 773}
749 774
750QString Addressee::familyNameLabel() 775QString Addressee::familyNameLabel()
751{ 776{
752 return i18n("Family Name"); 777 return i18n("Family Name");
753} 778}
754 779
755 780
756void Addressee::setGivenName( const QString &givenName ) 781void Addressee::setGivenName( const QString &givenName )
757{ 782{
758 if ( givenName == mData->givenName ) return; 783 if ( givenName == mData->givenName ) return;
759 detach(); 784 detach();
760 mData->empty = false; 785 mData->empty = false;
761 mData->givenName = givenName; 786 mData->givenName = givenName;
762} 787}
763 788
764QString Addressee::givenName() const 789QString Addressee::givenName() const
765{ 790{
766 return mData->givenName; 791 return mData->givenName;
767} 792}
768 793
769QString Addressee::givenNameLabel() 794QString Addressee::givenNameLabel()
770{ 795{
771 return i18n("Given Name"); 796 return i18n("Given Name");
772} 797}
773 798
774 799
775void Addressee::setAdditionalName( const QString &additionalName ) 800void Addressee::setAdditionalName( const QString &additionalName )
776{ 801{
777 if ( additionalName == mData->additionalName ) return; 802 if ( additionalName == mData->additionalName ) return;
778 detach(); 803 detach();
779 mData->empty = false; 804 mData->empty = false;
780 mData->additionalName = additionalName; 805 mData->additionalName = additionalName;
781} 806}
782 807
783QString Addressee::additionalName() const 808QString Addressee::additionalName() const
784{ 809{
785 return mData->additionalName; 810 return mData->additionalName;
786} 811}
787 812
788QString Addressee::additionalNameLabel() 813QString Addressee::additionalNameLabel()
789{ 814{
790 return i18n("Additional Names"); 815 return i18n("Additional Names");
791} 816}
792 817
793 818
794void Addressee::setPrefix( const QString &prefix ) 819void Addressee::setPrefix( const QString &prefix )
795{ 820{
796 if ( prefix == mData->prefix ) return; 821 if ( prefix == mData->prefix ) return;
797 detach(); 822 detach();
798 mData->empty = false; 823 mData->empty = false;
799 mData->prefix = prefix; 824 mData->prefix = prefix;
800} 825}
801 826
802QString Addressee::prefix() const 827QString Addressee::prefix() const
803{ 828{
804 return mData->prefix; 829 return mData->prefix;
805} 830}
806 831
807QString Addressee::prefixLabel() 832QString Addressee::prefixLabel()
808{ 833{
809 return i18n("Honorific Prefixes"); 834 return i18n("Honorific Prefixes");
810} 835}
811 836
812 837
813void Addressee::setSuffix( const QString &suffix ) 838void Addressee::setSuffix( const QString &suffix )
814{ 839{
815 if ( suffix == mData->suffix ) return; 840 if ( suffix == mData->suffix ) return;
816 detach(); 841 detach();
817 mData->empty = false; 842 mData->empty = false;
818 mData->suffix = suffix; 843 mData->suffix = suffix;
819} 844}
820 845
821QString Addressee::suffix() const 846QString Addressee::suffix() const
822{ 847{
823 return mData->suffix; 848 return mData->suffix;
824} 849}
825 850
826QString Addressee::suffixLabel() 851QString Addressee::suffixLabel()
827{ 852{
828 return i18n("Honorific Suffixes"); 853 return i18n("Honorific Suffixes");
829} 854}
830 855
831 856
832void Addressee::setNickName( const QString &nickName ) 857void Addressee::setNickName( const QString &nickName )
833{ 858{
834 if ( nickName == mData->nickName ) return; 859 if ( nickName == mData->nickName ) return;
835 detach(); 860 detach();
836 mData->empty = false; 861 mData->empty = false;
837 mData->nickName = nickName; 862 mData->nickName = nickName;
838} 863}
839 864
840QString Addressee::nickName() const 865QString Addressee::nickName() const
841{ 866{
842 return mData->nickName; 867 return mData->nickName;
843} 868}
844 869
845QString Addressee::nickNameLabel() 870QString Addressee::nickNameLabel()
846{ 871{
847 return i18n("Nick Name"); 872 return i18n("Nick Name");
848} 873}
849 874
850 875
851void Addressee::setBirthday( const QDateTime &birthday ) 876void Addressee::setBirthday( const QDateTime &birthday )
852{ 877{
853 if ( birthday == mData->birthday ) return; 878 if ( birthday == mData->birthday ) return;
854 detach(); 879 detach();
855 mData->empty = false; 880 mData->empty = false;
856 mData->birthday = birthday; 881 mData->birthday = birthday;
857} 882}
858 883
859QDateTime Addressee::birthday() const 884QDateTime Addressee::birthday() const
860{ 885{
861 return mData->birthday; 886 return mData->birthday;
862} 887}
863 888
864QString Addressee::birthdayLabel() 889QString Addressee::birthdayLabel()
865{ 890{
866 return i18n("Birthday"); 891 return i18n("Birthday");
867} 892}
868 893
869 894
870QString Addressee::homeAddressStreetLabel() 895QString Addressee::homeAddressStreetLabel()
871{ 896{
872 return i18n("Home Address Street"); 897 return i18n("Home Address Street");
873} 898}
874 899
875 900
876QString Addressee::homeAddressLocalityLabel() 901QString Addressee::homeAddressLocalityLabel()
877{ 902{
878 return i18n("Home Address Locality"); 903 return i18n("Home Address Locality");
879} 904}
880 905
881 906
882QString Addressee::homeAddressRegionLabel() 907QString Addressee::homeAddressRegionLabel()
883{ 908{
884 return i18n("Home Address Region"); 909 return i18n("Home Address Region");
885} 910}
886 911
887 912
888QString Addressee::homeAddressPostalCodeLabel() 913QString Addressee::homeAddressPostalCodeLabel()
889{ 914{
890 return i18n("Home Address Postal Code"); 915 return i18n("Home Address Postal Code");
891} 916}
892 917
893 918
894QString Addressee::homeAddressCountryLabel() 919QString Addressee::homeAddressCountryLabel()
895{ 920{
896 return i18n("Home Address Country"); 921 return i18n("Home Address Country");
897} 922}
898 923
899 924
900QString Addressee::homeAddressLabelLabel() 925QString Addressee::homeAddressLabelLabel()
901{ 926{
902 return i18n("Home Address Label"); 927 return i18n("Home Address Label");
903} 928}
904 929
905 930
906QString Addressee::businessAddressStreetLabel() 931QString Addressee::businessAddressStreetLabel()
907{ 932{
908 return i18n("Business Address Street"); 933 return i18n("Business Address Street");
909} 934}
910 935
911 936
912QString Addressee::businessAddressLocalityLabel() 937QString Addressee::businessAddressLocalityLabel()
913{ 938{
914 return i18n("Business Address Locality"); 939 return i18n("Business Address Locality");
915} 940}
916 941
917 942
918QString Addressee::businessAddressRegionLabel() 943QString Addressee::businessAddressRegionLabel()
919{ 944{
920 return i18n("Business Address Region"); 945 return i18n("Business Address Region");
921} 946}
922 947
923 948
924QString Addressee::businessAddressPostalCodeLabel() 949QString Addressee::businessAddressPostalCodeLabel()
925{ 950{
926 return i18n("Business Address Postal Code"); 951 return i18n("Business Address Postal Code");
927} 952}
928 953
929 954
930QString Addressee::businessAddressCountryLabel() 955QString Addressee::businessAddressCountryLabel()
931{ 956{
932 return i18n("Business Address Country"); 957 return i18n("Business Address Country");
933} 958}
934 959
935 960
936QString Addressee::businessAddressLabelLabel() 961QString Addressee::businessAddressLabelLabel()
937{ 962{
938 return i18n("Business Address Label"); 963 return i18n("Business Address Label");
939} 964}
940 965
941 966
942QString Addressee::homePhoneLabel() 967QString Addressee::homePhoneLabel()
943{ 968{
944 return i18n("Home Phone"); 969 return i18n("Home Phone");
945} 970}
946 971
947 972
948QString Addressee::businessPhoneLabel() 973QString Addressee::businessPhoneLabel()
949{ 974{
950 return i18n("Business Phone"); 975 return i18n("Business Phone");
951} 976}
952 977
953 978
954QString Addressee::mobilePhoneLabel() 979QString Addressee::mobilePhoneLabel()
955{ 980{
956 return i18n("Mobile Phone"); 981 return i18n("Mobile Phone");
957} 982}
958 983
959 984
960QString Addressee::homeFaxLabel() 985QString Addressee::homeFaxLabel()
961{ 986{
962 return i18n("Home Fax"); 987 return i18n("Home Fax");
963} 988}
964 989
965 990
966QString Addressee::businessFaxLabel() 991QString Addressee::businessFaxLabel()
967{ 992{
968 return i18n("Business Fax"); 993 return i18n("Business Fax");
969} 994}
970 995
971 996
972QString Addressee::carPhoneLabel() 997QString Addressee::carPhoneLabel()
973{ 998{
974 return i18n("Car Phone"); 999 return i18n("Car Phone");
975} 1000}
976 1001
977 1002
978QString Addressee::isdnLabel() 1003QString Addressee::isdnLabel()
979{ 1004{
980 return i18n("ISDN"); 1005 return i18n("ISDN");
981} 1006}
982 1007
983 1008
984QString Addressee::pagerLabel() 1009QString Addressee::pagerLabel()
985{ 1010{
986 return i18n("Pager"); 1011 return i18n("Pager");
987} 1012}
988 1013
989QString Addressee::sipLabel() 1014QString Addressee::sipLabel()
990{ 1015{
991 return i18n("SIP"); 1016 return i18n("SIP");
992} 1017}
993 1018
994QString Addressee::emailLabel() 1019QString Addressee::emailLabel()
995{ 1020{
996 return i18n("Email Address"); 1021 return i18n("Email Address");
997} 1022}
998 1023
999 1024
1000void Addressee::setMailer( const QString &mailer ) 1025void Addressee::setMailer( const QString &mailer )
1001{ 1026{
1002 if ( mailer == mData->mailer ) return; 1027 if ( mailer == mData->mailer ) return;
1003 detach(); 1028 detach();
1004 mData->empty = false; 1029 mData->empty = false;
1005 mData->mailer = mailer; 1030 mData->mailer = mailer;
1006} 1031}
1007 1032
1008QString Addressee::mailer() const 1033QString Addressee::mailer() const
1009{ 1034{
1010 return mData->mailer; 1035 return mData->mailer;
1011} 1036}
1012 1037
1013QString Addressee::mailerLabel() 1038QString Addressee::mailerLabel()
1014{ 1039{
1015 return i18n("Mail Client"); 1040 return i18n("Mail Client");
1016} 1041}
1017 1042
1018 1043
1019void Addressee::setTimeZone( const TimeZone &timeZone ) 1044void Addressee::setTimeZone( const TimeZone &timeZone )
1020{ 1045{
1021 if ( timeZone == mData->timeZone ) return; 1046 if ( timeZone == mData->timeZone ) return;
1022 detach(); 1047 detach();
1023 mData->empty = false; 1048 mData->empty = false;
1024 mData->timeZone = timeZone; 1049 mData->timeZone = timeZone;
1025} 1050}
1026 1051
1027TimeZone Addressee::timeZone() const 1052TimeZone Addressee::timeZone() const
1028{ 1053{
1029 return mData->timeZone; 1054 return mData->timeZone;
1030} 1055}
1031 1056
1032QString Addressee::timeZoneLabel() 1057QString Addressee::timeZoneLabel()
1033{ 1058{
1034 return i18n("Time Zone"); 1059 return i18n("Time Zone");
1035} 1060}
1036 1061
1037 1062
1038void Addressee::setGeo( const Geo &geo ) 1063void Addressee::setGeo( const Geo &geo )
1039{ 1064{
1040 if ( geo == mData->geo ) return; 1065 if ( geo == mData->geo ) return;
1041 detach(); 1066 detach();
1042 mData->empty = false; 1067 mData->empty = false;
1043 mData->geo = geo; 1068 mData->geo = geo;
1044} 1069}
1045 1070
1046Geo Addressee::geo() const 1071Geo Addressee::geo() const
1047{ 1072{
1048 return mData->geo; 1073 return mData->geo;
1049} 1074}
1050 1075
1051QString Addressee::geoLabel() 1076QString Addressee::geoLabel()
1052{ 1077{
1053 return i18n("Geographic Position"); 1078 return i18n("Geographic Position");
1054} 1079}
1055 1080
1056 1081
1057void Addressee::setTitle( const QString &title ) 1082void Addressee::setTitle( const QString &title )
1058{ 1083{
1059 if ( title == mData->title ) return; 1084 if ( title == mData->title ) return;
1060 detach(); 1085 detach();
1061 mData->empty = false; 1086 mData->empty = false;
1062 mData->title = title; 1087 mData->title = title;
1063} 1088}
1064 1089
1065QString Addressee::title() const 1090QString Addressee::title() const
1066{ 1091{
1067 return mData->title; 1092 return mData->title;
1068} 1093}
1069 1094
1070QString Addressee::titleLabel() 1095QString Addressee::titleLabel()
1071{ 1096{
1072 return i18n("Title"); 1097 return i18n("Title");
1073} 1098}
1074 1099
1075 1100
1076void Addressee::setRole( const QString &role ) 1101void Addressee::setRole( const QString &role )
1077{ 1102{
1078 if ( role == mData->role ) return; 1103 if ( role == mData->role ) return;
1079 detach(); 1104 detach();
1080 mData->empty = false; 1105 mData->empty = false;
1081 mData->role = role; 1106 mData->role = role;
1082} 1107}
1083 1108
1084QString Addressee::role() const 1109QString Addressee::role() const
1085{ 1110{
1086 return mData->role; 1111 return mData->role;
1087} 1112}
1088 1113
1089QString Addressee::roleLabel() 1114QString Addressee::roleLabel()
1090{ 1115{
1091 return i18n("Role"); 1116 return i18n("Role");
1092} 1117}
1093 1118
1094 1119
1095void Addressee::setOrganization( const QString &organization ) 1120void Addressee::setOrganization( const QString &organization )
1096{ 1121{
1097 if ( organization == mData->organization ) return; 1122 if ( organization == mData->organization ) return;
1098 detach(); 1123 detach();
1099 mData->empty = false; 1124 mData->empty = false;
1100 mData->organization = organization; 1125 mData->organization = organization;
1101} 1126}
1102 1127
1103QString Addressee::organization() const 1128QString Addressee::organization() const
1104{ 1129{
1105 return mData->organization; 1130 return mData->organization;
1106} 1131}
1107 1132
1108QString Addressee::organizationLabel() 1133QString Addressee::organizationLabel()
1109{ 1134{
1110 return i18n("Organization"); 1135 return i18n("Organization");
1111} 1136}
1112 1137
1113 1138
1114void Addressee::setNote( const QString &note ) 1139void Addressee::setNote( const QString &note )
1115{ 1140{
1116 if ( note == mData->note ) return; 1141 if ( note == mData->note ) return;
1117 detach(); 1142 detach();
1118 mData->empty = false; 1143 mData->empty = false;
1119 mData->note = note; 1144 mData->note = note;
1120} 1145}
1121 1146
1122QString Addressee::note() const 1147QString Addressee::note() const
1123{ 1148{
1124 return mData->note; 1149 return mData->note;
1125} 1150}
1126 1151
1127QString Addressee::noteLabel() 1152QString Addressee::noteLabel()
1128{ 1153{
1129 return i18n("Note"); 1154 return i18n("Note");
1130} 1155}
1131 1156
1132 1157
1133void Addressee::setProductId( const QString &productId ) 1158void Addressee::setProductId( const QString &productId )
1134{ 1159{
1135 if ( productId == mData->productId ) return; 1160 if ( productId == mData->productId ) return;
1136 detach(); 1161 detach();
1137 mData->empty = false; 1162 mData->empty = false;
1138 mData->productId = productId; 1163 mData->productId = productId;
1139} 1164}
1140 1165
1141QString Addressee::productId() const 1166QString Addressee::productId() const
1142{ 1167{
1143 return mData->productId; 1168 return mData->productId;
1144} 1169}
1145 1170
1146QString Addressee::productIdLabel() 1171QString Addressee::productIdLabel()
1147{ 1172{
1148 return i18n("Product Identifier"); 1173 return i18n("Product Identifier");
1149} 1174}
1150 1175
1151 1176
1152void Addressee::setRevision( const QDateTime &revision ) 1177void Addressee::setRevision( const QDateTime &revision )
1153{ 1178{
1154 if ( revision == mData->revision ) return; 1179 if ( revision == mData->revision ) return;
1155 detach(); 1180 detach();
1156 mData->empty = false; 1181 mData->empty = false;
1157 mData->revision = QDateTime( revision.date(), 1182 mData->revision = QDateTime( revision.date(),
1158 QTime (revision.time().hour(), 1183 QTime (revision.time().hour(),
1159 revision.time().minute(), 1184 revision.time().minute(),
1160 revision.time().second())); 1185 revision.time().second()));
1161} 1186}
1162 1187
1163QDateTime Addressee::revision() const 1188QDateTime Addressee::revision() const
1164{ 1189{
1165 return mData->revision; 1190 return mData->revision;
1166} 1191}
1167 1192
1168QString Addressee::revisionLabel() 1193QString Addressee::revisionLabel()
1169{ 1194{
1170 return i18n("Revision Date"); 1195 return i18n("Revision Date");
1171} 1196}
1172 1197
1173 1198
1174void Addressee::setSortString( const QString &sortString ) 1199void Addressee::setSortString( const QString &sortString )
1175{ 1200{
1176 if ( sortString == mData->sortString ) return; 1201 if ( sortString == mData->sortString ) return;
1177 detach(); 1202 detach();
1178 mData->empty = false; 1203 mData->empty = false;
1179 mData->sortString = sortString; 1204 mData->sortString = sortString;
1180} 1205}
1181 1206
1182QString Addressee::sortString() const 1207QString Addressee::sortString() const
1183{ 1208{
1184 return mData->sortString; 1209 return mData->sortString;
1185} 1210}
1186 1211
1187QString Addressee::sortStringLabel() 1212QString Addressee::sortStringLabel()
1188{ 1213{
1189 return i18n("Sort String"); 1214 return i18n("Sort String");
1190} 1215}
1191 1216
1192 1217
1193void Addressee::setUrl( const KURL &url ) 1218void Addressee::setUrl( const KURL &url )
1194{ 1219{
1195 if ( url == mData->url ) return; 1220 if ( url == mData->url ) return;
1196 detach(); 1221 detach();
1197 mData->empty = false; 1222 mData->empty = false;
1198 mData->url = url; 1223 mData->url = url;
1199} 1224}
1200 1225
1201KURL Addressee::url() const 1226KURL Addressee::url() const
1202{ 1227{
1203 return mData->url; 1228 return mData->url;
1204} 1229}
1205 1230
1206QString Addressee::urlLabel() 1231QString Addressee::urlLabel()
1207{ 1232{
1208 return i18n("URL"); 1233 return i18n("URL");
1209} 1234}
1210 1235
1211 1236
1212void Addressee::setSecrecy( const Secrecy &secrecy ) 1237void Addressee::setSecrecy( const Secrecy &secrecy )
1213{ 1238{
1214 if ( secrecy == mData->secrecy ) return; 1239 if ( secrecy == mData->secrecy ) return;
1215 detach(); 1240 detach();
1216 mData->empty = false; 1241 mData->empty = false;
1217 mData->secrecy = secrecy; 1242 mData->secrecy = secrecy;
1218} 1243}
1219 1244
1220Secrecy Addressee::secrecy() const 1245Secrecy Addressee::secrecy() const
1221{ 1246{
1222 return mData->secrecy; 1247 return mData->secrecy;
1223} 1248}
1224 1249
1225QString Addressee::secrecyLabel() 1250QString Addressee::secrecyLabel()
1226{ 1251{
1227 return i18n("Security Class"); 1252 return i18n("Security Class");
1228} 1253}
1229 1254
1230 1255
1231void Addressee::setLogo( const Picture &logo ) 1256void Addressee::setLogo( const Picture &logo )
1232{ 1257{
1233 if ( logo == mData->logo ) return; 1258 if ( logo == mData->logo ) return;
1234 detach(); 1259 detach();
1235 mData->empty = false; 1260 mData->empty = false;
1236 mData->logo = logo; 1261 mData->logo = logo;
1237} 1262}
1238 1263
1239Picture Addressee::logo() const 1264Picture Addressee::logo() const
1240{ 1265{
1241 return mData->logo; 1266 return mData->logo;
1242} 1267}
1243 1268
1244QString Addressee::logoLabel() 1269QString Addressee::logoLabel()
1245{ 1270{
1246 return i18n("Logo"); 1271 return i18n("Logo");
1247} 1272}
1248 1273
1249 1274
1250void Addressee::setPhoto( const Picture &photo ) 1275void Addressee::setPhoto( const Picture &photo )
1251{ 1276{
1252 if ( photo == mData->photo ) return; 1277 if ( photo == mData->photo ) return;
1253 detach(); 1278 detach();
1254 mData->empty = false; 1279 mData->empty = false;
1255 mData->photo = photo; 1280 mData->photo = photo;
1256} 1281}
1257 1282
1258Picture Addressee::photo() const 1283Picture Addressee::photo() const
1259{ 1284{
1260 return mData->photo; 1285 return mData->photo;
1261} 1286}
1262 1287
1263QString Addressee::photoLabel() 1288QString Addressee::photoLabel()
1264{ 1289{
1265 return i18n("Photo"); 1290 return i18n("Photo");
1266} 1291}
1267 1292
1268 1293
1269void Addressee::setSound( const Sound &sound ) 1294void Addressee::setSound( const Sound &sound )
1270{ 1295{
1271 if ( sound == mData->sound ) return; 1296 if ( sound == mData->sound ) return;
1272 detach(); 1297 detach();
1273 mData->empty = false; 1298 mData->empty = false;
1274 mData->sound = sound; 1299 mData->sound = sound;
1275} 1300}
1276 1301
1277Sound Addressee::sound() const 1302Sound Addressee::sound() const
1278{ 1303{
1279 return mData->sound; 1304 return mData->sound;
1280} 1305}
1281 1306
1282QString Addressee::soundLabel() 1307QString Addressee::soundLabel()
1283{ 1308{
1284 return i18n("Sound"); 1309 return i18n("Sound");
1285} 1310}
1286 1311
1287 1312
1288void Addressee::setAgent( const Agent &agent ) 1313void Addressee::setAgent( const Agent &agent )
1289{ 1314{
1290 if ( agent == mData->agent ) return; 1315 if ( agent == mData->agent ) return;
1291 detach(); 1316 detach();
1292 mData->empty = false; 1317 mData->empty = false;
1293 mData->agent = agent; 1318 mData->agent = agent;
1294} 1319}
1295 1320
1296Agent Addressee::agent() const 1321Agent Addressee::agent() const
1297{ 1322{
1298 return mData->agent; 1323 return mData->agent;
1299} 1324}
1300 1325
1301QString Addressee::agentLabel() 1326QString Addressee::agentLabel()
1302{ 1327{
1303 return i18n("Agent"); 1328 return i18n("Agent");
1304} 1329}
1305 1330
1306 1331
1307 1332
1308void Addressee::setNameFromString( const QString &str ) 1333void Addressee::setNameFromString( const QString &str )
1309{ 1334{
1310 setFormattedName( str ); 1335 setFormattedName( str );
1311 setName( str ); 1336 setName( str );
1312 1337
1313 static bool first = true; 1338 static bool first = true;
1314 static QStringList titles; 1339 static QStringList titles;
1315 static QStringList suffixes; 1340 static QStringList suffixes;
1316 static QStringList prefixes; 1341 static QStringList prefixes;
1317 1342
1318 if ( first ) { 1343 if ( first ) {
1319 first = false; 1344 first = false;
1320 titles += i18n( "Dr." ); 1345 titles += i18n( "Dr." );
1321 titles += i18n( "Miss" ); 1346 titles += i18n( "Miss" );
1322 titles += i18n( "Mr." ); 1347 titles += i18n( "Mr." );
1323 titles += i18n( "Mrs." ); 1348 titles += i18n( "Mrs." );
1324 titles += i18n( "Ms." ); 1349 titles += i18n( "Ms." );
1325 titles += i18n( "Prof." ); 1350 titles += i18n( "Prof." );
1326 1351
1327 suffixes += i18n( "I" ); 1352 suffixes += i18n( "I" );
1328 suffixes += i18n( "II" ); 1353 suffixes += i18n( "II" );
1329 suffixes += i18n( "III" ); 1354 suffixes += i18n( "III" );
1330 suffixes += i18n( "Jr." ); 1355 suffixes += i18n( "Jr." );
1331 suffixes += i18n( "Sr." ); 1356 suffixes += i18n( "Sr." );
1332 1357
1333 prefixes += "van"; 1358 prefixes += "van";
1334 prefixes += "von"; 1359 prefixes += "von";
1335 prefixes += "de"; 1360 prefixes += "de";
1336 1361
1337 KConfig config( locateLocal( "config", "kabcrc") ); 1362 KConfig config( locateLocal( "config", "kabcrc") );
1338 config.setGroup( "General" ); 1363 config.setGroup( "General" );
1339 titles += config.readListEntry( "Prefixes" ); 1364 titles += config.readListEntry( "Prefixes" );
1340 titles.remove( "" ); 1365 titles.remove( "" );
1341 prefixes += config.readListEntry( "Inclusions" ); 1366 prefixes += config.readListEntry( "Inclusions" );
1342 prefixes.remove( "" ); 1367 prefixes.remove( "" );
1343 suffixes += config.readListEntry( "Suffixes" ); 1368 suffixes += config.readListEntry( "Suffixes" );
1344 suffixes.remove( "" ); 1369 suffixes.remove( "" );
1345 } 1370 }
1346 1371
1347 // clear all name parts 1372 // clear all name parts
1348 setPrefix( "" ); 1373 setPrefix( "" );
1349 setGivenName( "" ); 1374 setGivenName( "" );
1350 setAdditionalName( "" ); 1375 setAdditionalName( "" );
1351 setFamilyName( "" ); 1376 setFamilyName( "" );
1352 setSuffix( "" ); 1377 setSuffix( "" );
1353 1378
1354 if ( str.isEmpty() ) 1379 if ( str.isEmpty() )
1355 return; 1380 return;
1356 1381
1357 int i = str.find(','); 1382 int i = str.find(',');
1358 if( i < 0 ) { 1383 if( i < 0 ) {
1359 QStringList parts = QStringList::split( " ", str ); 1384 QStringList parts = QStringList::split( " ", str );
1360 int leftOffset = 0; 1385 int leftOffset = 0;
1361 int rightOffset = parts.count() - 1; 1386 int rightOffset = parts.count() - 1;
1362 1387
1363 QString suffix; 1388 QString suffix;
1364 while ( rightOffset >= 0 ) { 1389 while ( rightOffset >= 0 ) {
1365 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1390 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1366 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1391 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1367 rightOffset--; 1392 rightOffset--;
1368 } else 1393 } else
1369 break; 1394 break;
1370 } 1395 }
1371 setSuffix( suffix ); 1396 setSuffix( suffix );
1372 1397
1373 if ( rightOffset < 0 ) 1398 if ( rightOffset < 0 )
1374 return; 1399 return;
1375 1400
1376 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1401 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1377 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1402 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1378 rightOffset--; 1403 rightOffset--;
1379 } else 1404 } else
1380 setFamilyName( parts[ rightOffset ] ); 1405 setFamilyName( parts[ rightOffset ] );
1381 1406
1382 QString prefix; 1407 QString prefix;
1383 while ( leftOffset < rightOffset ) { 1408 while ( leftOffset < rightOffset ) {
1384 if ( titles.contains( parts[ leftOffset ] ) ) { 1409 if ( titles.contains( parts[ leftOffset ] ) ) {
1385 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1410 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1386 leftOffset++; 1411 leftOffset++;
1387 } else 1412 } else
1388 break; 1413 break;
1389 } 1414 }
1390 setPrefix( prefix ); 1415 setPrefix( prefix );
1391 1416
1392 if ( leftOffset < rightOffset ) { 1417 if ( leftOffset < rightOffset ) {
1393 setGivenName( parts[ leftOffset ] ); 1418 setGivenName( parts[ leftOffset ] );
1394 leftOffset++; 1419 leftOffset++;
1395 } 1420 }
1396 1421
1397 QString additionalName; 1422 QString additionalName;
1398 while ( leftOffset < rightOffset ) { 1423 while ( leftOffset < rightOffset ) {
1399 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1424 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1400 leftOffset++; 1425 leftOffset++;
1401 } 1426 }
1402 setAdditionalName( additionalName ); 1427 setAdditionalName( additionalName );
1403 } else { 1428 } else {
1404 QString part1 = str.left( i ); 1429 QString part1 = str.left( i );
1405 QString part2 = str.mid( i + 1 ); 1430 QString part2 = str.mid( i + 1 );
1406 1431
1407 QStringList parts = QStringList::split( " ", part1 ); 1432 QStringList parts = QStringList::split( " ", part1 );
1408 int leftOffset = 0; 1433 int leftOffset = 0;
1409 int rightOffset = parts.count() - 1; 1434 int rightOffset = parts.count() - 1;
1410 1435
1411 QString suffix; 1436 QString suffix;
1412 while ( rightOffset >= 0 ) { 1437 while ( rightOffset >= 0 ) {
1413 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1438 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1414 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1439 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1415 rightOffset--; 1440 rightOffset--;
1416 } else 1441 } else
1417 break; 1442 break;
1418 } 1443 }
1419 setSuffix( suffix ); 1444 setSuffix( suffix );
1420 1445
1421 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1446 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1422 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1447 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1423 rightOffset--; 1448 rightOffset--;
1424 } else 1449 } else
1425 setFamilyName( parts[ rightOffset ] ); 1450 setFamilyName( parts[ rightOffset ] );
1426 1451
1427 QString prefix; 1452 QString prefix;
1428 while ( leftOffset < rightOffset ) { 1453 while ( leftOffset < rightOffset ) {
1429 if ( titles.contains( parts[ leftOffset ] ) ) { 1454 if ( titles.contains( parts[ leftOffset ] ) ) {
1430 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1455 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1431 leftOffset++; 1456 leftOffset++;
1432 } else 1457 } else
1433 break; 1458 break;
1434 } 1459 }
1435 1460
1436 parts = QStringList::split( " ", part2 ); 1461 parts = QStringList::split( " ", part2 );
1437 1462
1438 leftOffset = 0; 1463 leftOffset = 0;
1439 rightOffset = parts.count(); 1464 rightOffset = parts.count();
1440 1465
1441 while ( leftOffset < rightOffset ) { 1466 while ( leftOffset < rightOffset ) {
1442 if ( titles.contains( parts[ leftOffset ] ) ) { 1467 if ( titles.contains( parts[ leftOffset ] ) ) {
1443 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1468 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1444 leftOffset++; 1469 leftOffset++;
1445 } else 1470 } else
1446 break; 1471 break;
1447 } 1472 }
1448 setPrefix( prefix ); 1473 setPrefix( prefix );
1449 1474
1450 if ( leftOffset < rightOffset ) { 1475 if ( leftOffset < rightOffset ) {
1451 setGivenName( parts[ leftOffset ] ); 1476 setGivenName( parts[ leftOffset ] );
1452 leftOffset++; 1477 leftOffset++;
1453 } 1478 }
1454 1479
1455 QString additionalName; 1480 QString additionalName;
1456 while ( leftOffset < rightOffset ) { 1481 while ( leftOffset < rightOffset ) {
1457 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1482 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1458 leftOffset++; 1483 leftOffset++;
1459 } 1484 }
1460 setAdditionalName( additionalName ); 1485 setAdditionalName( additionalName );
1461 } 1486 }
1462} 1487}
1463 1488
1464QString Addressee::realName() const 1489QString Addressee::realName() const
1465{ 1490{
1466 if ( !formattedName().isEmpty() ) 1491 if ( !formattedName().isEmpty() )
1467 return formattedName(); 1492 return formattedName();
1468 1493
1469 QString n = assembledName(); 1494 QString n = assembledName();
1470 1495
1471 if ( n.isEmpty() ) 1496 if ( n.isEmpty() )
1472 n = name(); 1497 n = name();
1473 1498
1474 return n; 1499 return n;
1475} 1500}
1476 1501
1477QString Addressee::assembledName() const 1502QString Addressee::assembledName() const
1478{ 1503{
1479 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1504 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1480 familyName() + " " + suffix(); 1505 familyName() + " " + suffix();
1481 1506
1482 return name.simplifyWhiteSpace(); 1507 return name.simplifyWhiteSpace();
1483} 1508}
1484 1509
1485QString Addressee::fullEmail( const QString &email ) const 1510QString Addressee::fullEmail( const QString &email ) const
1486{ 1511{
1487 QString e; 1512 QString e;
1488 if ( email.isNull() ) { 1513 if ( email.isNull() ) {
1489 e = preferredEmail(); 1514 e = preferredEmail();
1490 } else { 1515 } else {
1491 e = email; 1516 e = email;
1492 } 1517 }
1493 if ( e.isEmpty() ) return QString::null; 1518 if ( e.isEmpty() ) return QString::null;
1494 1519
1495 QString text; 1520 QString text;
1496 if ( realName().isEmpty() ) 1521 if ( realName().isEmpty() )
1497 text = e; 1522 text = e;
1498 else 1523 else
1499 text = assembledName() + " <" + e + ">"; 1524 text = assembledName() + " <" + e + ">";
1500 1525
1501 return text; 1526 return text;
1502} 1527}
1503 1528
1504void Addressee::insertEmail( const QString &email, bool preferred ) 1529void Addressee::insertEmail( const QString &email, bool preferred )
1505{ 1530{
1506 detach(); 1531 detach();
1507 1532
1508 QStringList::Iterator it = mData->emails.find( email ); 1533 QStringList::Iterator it = mData->emails.find( email );
1509 1534
1510 if ( it != mData->emails.end() ) { 1535 if ( it != mData->emails.end() ) {
1511 if ( !preferred || it == mData->emails.begin() ) return; 1536 if ( !preferred || it == mData->emails.begin() ) return;
1512 mData->emails.remove( it ); 1537 mData->emails.remove( it );
1513 mData->emails.prepend( email ); 1538 mData->emails.prepend( email );
1514 } else { 1539 } else {
1515 if ( preferred ) { 1540 if ( preferred ) {
1516 mData->emails.prepend( email ); 1541 mData->emails.prepend( email );
1517 } else { 1542 } else {
1518 mData->emails.append( email ); 1543 mData->emails.append( email );
1519 } 1544 }
1520 } 1545 }
1521} 1546}
1522 1547
1523void Addressee::removeEmail( const QString &email ) 1548void Addressee::removeEmail( const QString &email )
1524{ 1549{
1525 detach(); 1550 detach();
1526 1551
1527 QStringList::Iterator it = mData->emails.find( email ); 1552 QStringList::Iterator it = mData->emails.find( email );
1528 if ( it == mData->emails.end() ) return; 1553 if ( it == mData->emails.end() ) return;
1529 1554
1530 mData->emails.remove( it ); 1555 mData->emails.remove( it );
1531} 1556}
1532 1557
1533QString Addressee::preferredEmail() const 1558QString Addressee::preferredEmail() const
1534{ 1559{
1535 if ( mData->emails.count() == 0 ) return QString::null; 1560 if ( mData->emails.count() == 0 ) return QString::null;
1536 else return mData->emails.first(); 1561 else return mData->emails.first();
1537} 1562}
1538 1563
1539QStringList Addressee::emails() const 1564QStringList Addressee::emails() const
1540{ 1565{
1541 return mData->emails; 1566 return mData->emails;
1542} 1567}
1543void Addressee::setEmails( const QStringList& emails ) { 1568void Addressee::setEmails( const QStringList& emails ) {
1544 detach(); 1569 detach();
1545 mData->emails = emails; 1570 mData->emails = emails;
1546} 1571}
1547void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1572void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1548{ 1573{
1549 detach(); 1574 detach();
1550 mData->empty = false; 1575 mData->empty = false;
1551 1576
1552 PhoneNumber::List::Iterator it; 1577 PhoneNumber::List::Iterator it;
1553 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1578 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1554 if ( (*it).id() == phoneNumber.id() ) { 1579 if ( (*it).id() == phoneNumber.id() ) {
1555 *it = phoneNumber; 1580 *it = phoneNumber;
1556 return; 1581 return;
1557 } 1582 }
1558 } 1583 }
1559 mData->phoneNumbers.append( phoneNumber ); 1584 mData->phoneNumbers.append( phoneNumber );
1560} 1585}
1561 1586
1562void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1587void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1563{ 1588{
1564 detach(); 1589 detach();
1565 1590
1566 PhoneNumber::List::Iterator it; 1591 PhoneNumber::List::Iterator it;
1567 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1592 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1568 if ( (*it).id() == phoneNumber.id() ) { 1593 if ( (*it).id() == phoneNumber.id() ) {
1569 mData->phoneNumbers.remove( it ); 1594 mData->phoneNumbers.remove( it );
1570 return; 1595 return;
1571 } 1596 }
1572 } 1597 }
1573} 1598}
1574 1599
1575PhoneNumber Addressee::phoneNumber( int type ) const 1600PhoneNumber Addressee::phoneNumber( int type ) const
1576{ 1601{
1577 PhoneNumber phoneNumber( "", type ); 1602 PhoneNumber phoneNumber( "", type );
1578 PhoneNumber::List::ConstIterator it; 1603 PhoneNumber::List::ConstIterator it;
1579 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1604 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1580 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1605 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1581 if ( (*it).type() & PhoneNumber::Pref ) 1606 if ( (*it).type() & PhoneNumber::Pref )
1582 return (*it); 1607 return (*it);
1583 else if ( phoneNumber.number().isEmpty() ) 1608 else if ( phoneNumber.number().isEmpty() )
1584 phoneNumber = (*it); 1609 phoneNumber = (*it);
1585 } 1610 }
1586 } 1611 }
1587 1612
1588 return phoneNumber; 1613 return phoneNumber;
1589} 1614}
1590 1615
1591PhoneNumber::List Addressee::phoneNumbers() const 1616PhoneNumber::List Addressee::phoneNumbers() const
1592{ 1617{
1593 return mData->phoneNumbers; 1618 return mData->phoneNumbers;
1594} 1619}
1595 1620
1596PhoneNumber::List Addressee::phoneNumbers( int type ) const 1621PhoneNumber::List Addressee::phoneNumbers( int type ) const
1597{ 1622{
1598 PhoneNumber::List list; 1623 PhoneNumber::List list;
1599 1624
1600 PhoneNumber::List::ConstIterator it; 1625 PhoneNumber::List::ConstIterator it;
1601 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1626 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1602 if ( matchBinaryPattern( (*it).type(), type ) ) { 1627 if ( matchBinaryPattern( (*it).type(), type ) ) {
1603 list.append( *it ); 1628 list.append( *it );
1604 } 1629 }
1605 } 1630 }
1606 return list; 1631 return list;
1607} 1632}
1608 1633
1609PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1634PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1610{ 1635{
1611 PhoneNumber::List::ConstIterator it; 1636 PhoneNumber::List::ConstIterator it;
1612 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1637 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1613 if ( (*it).id() == id ) { 1638 if ( (*it).id() == id ) {
1614 return *it; 1639 return *it;
1615 } 1640 }
1616 } 1641 }
1617 return PhoneNumber(); 1642 return PhoneNumber();
1618} 1643}
1619 1644
1620void Addressee::insertKey( const Key &key ) 1645void Addressee::insertKey( const Key &key )
1621{ 1646{
1622 detach(); 1647 detach();
1623 mData->empty = false; 1648 mData->empty = false;
1624 1649
1625 Key::List::Iterator it; 1650 Key::List::Iterator it;
1626 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1651 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1627 if ( (*it).id() == key.id() ) { 1652 if ( (*it).id() == key.id() ) {
1628 *it = key; 1653 *it = key;
1629 return; 1654 return;
1630 } 1655 }
1631 } 1656 }
1632 mData->keys.append( key ); 1657 mData->keys.append( key );
1633} 1658}
1634 1659
1635void Addressee::removeKey( const Key &key ) 1660void Addressee::removeKey( const Key &key )
1636{ 1661{
1637 detach(); 1662 detach();
1638 1663
1639 Key::List::Iterator it; 1664 Key::List::Iterator it;
1640 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1665 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1641 if ( (*it).id() == key.id() ) { 1666 if ( (*it).id() == key.id() ) {
1642 mData->keys.remove( key ); 1667 mData->keys.remove( key );
1643 return; 1668 return;
1644 } 1669 }
1645 } 1670 }
1646} 1671}
1647 1672
1648Key Addressee::key( int type, QString customTypeString ) const 1673Key Addressee::key( int type, QString customTypeString ) const
1649{ 1674{
1650 Key::List::ConstIterator it; 1675 Key::List::ConstIterator it;
1651 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1676 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1652 if ( (*it).type() == type ) { 1677 if ( (*it).type() == type ) {
1653 if ( type == Key::Custom ) { 1678 if ( type == Key::Custom ) {
1654 if ( customTypeString.isEmpty() ) { 1679 if ( customTypeString.isEmpty() ) {
1655 return *it; 1680 return *it;
1656 } else { 1681 } else {
1657 if ( (*it).customTypeString() == customTypeString ) 1682 if ( (*it).customTypeString() == customTypeString )
1658 return (*it); 1683 return (*it);
1659 } 1684 }
1660 } else { 1685 } else {
1661 return *it; 1686 return *it;
1662 } 1687 }
1663 } 1688 }
1664 } 1689 }
1665 return Key( QString(), type ); 1690 return Key( QString(), type );
1666} 1691}
1667void Addressee::setKeys( const Key::List& list ) { 1692void Addressee::setKeys( const Key::List& list ) {
1668 detach(); 1693 detach();
1669 mData->keys = list; 1694 mData->keys = list;
1670} 1695}
1671 1696
1672Key::List Addressee::keys() const 1697Key::List Addressee::keys() const
1673{ 1698{
1674 return mData->keys; 1699 return mData->keys;
1675} 1700}
1676 1701
1677Key::List Addressee::keys( int type, QString customTypeString ) const 1702Key::List Addressee::keys( int type, QString customTypeString ) const
1678{ 1703{
1679 Key::List list; 1704 Key::List list;
1680 1705
1681 Key::List::ConstIterator it; 1706 Key::List::ConstIterator it;
1682 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1707 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1683 if ( (*it).type() == type ) { 1708 if ( (*it).type() == type ) {
1684 if ( type == Key::Custom ) { 1709 if ( type == Key::Custom ) {
1685 if ( customTypeString.isEmpty() ) { 1710 if ( customTypeString.isEmpty() ) {
1686 list.append(*it); 1711 list.append(*it);
1687 } else { 1712 } else {
1688 if ( (*it).customTypeString() == customTypeString ) 1713 if ( (*it).customTypeString() == customTypeString )
1689 list.append(*it); 1714 list.append(*it);
1690 } 1715 }
1691 } else { 1716 } else {
1692 list.append(*it); 1717 list.append(*it);
1693 } 1718 }
1694 } 1719 }
1695 } 1720 }
1696 return list; 1721 return list;
1697} 1722}
1698 1723
1699Key Addressee::findKey( const QString &id ) const 1724Key Addressee::findKey( const QString &id ) const
1700{ 1725{
1701 Key::List::ConstIterator it; 1726 Key::List::ConstIterator it;
1702 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1727 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1703 if ( (*it).id() == id ) { 1728 if ( (*it).id() == id ) {
1704 return *it; 1729 return *it;
1705 } 1730 }
1706 } 1731 }
1707 return Key(); 1732 return Key();
1708} 1733}
1709 1734
1710QString Addressee::asString() const 1735QString Addressee::asString() const
1711{ 1736{
1712 return "Smith, agent Smith..."; 1737 return "Smith, agent Smith...";
1713} 1738}
1714 1739
1715void Addressee::dump() const 1740void Addressee::dump() const
1716{ 1741{
1717 return; 1742 return;
1718#if 0 1743#if 0
1719 kdDebug(5700) << "Addressee {" << endl; 1744 kdDebug(5700) << "Addressee {" << endl;
1720 1745
1721 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1746 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1722 1747
1723 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1748 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1724 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1749 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1725 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1750 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1726 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1751 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1727 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1752 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1728 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1753 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1729 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1754 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1730 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1755 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1731 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1756 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1732 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1757 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1733 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1758 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1734 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1759 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1735 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1760 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1736 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1761 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1737 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1762 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1738 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1763 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1739 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1764 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1740 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1765 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1741 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1766 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1742 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1767 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1743 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1768 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1744 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1769 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1745 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1770 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1746 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1771 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1747 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1772 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1748 1773
1749 kdDebug(5700) << " Emails {" << endl; 1774 kdDebug(5700) << " Emails {" << endl;
1750 QStringList e = emails(); 1775 QStringList e = emails();
1751 QStringList::ConstIterator it; 1776 QStringList::ConstIterator it;
1752 for( it = e.begin(); it != e.end(); ++it ) { 1777 for( it = e.begin(); it != e.end(); ++it ) {
1753 kdDebug(5700) << " " << (*it) << endl; 1778 kdDebug(5700) << " " << (*it) << endl;
1754 } 1779 }
1755 kdDebug(5700) << " }" << endl; 1780 kdDebug(5700) << " }" << endl;
1756 1781
1757 kdDebug(5700) << " PhoneNumbers {" << endl; 1782 kdDebug(5700) << " PhoneNumbers {" << endl;
1758 PhoneNumber::List p = phoneNumbers(); 1783 PhoneNumber::List p = phoneNumbers();
1759 PhoneNumber::List::ConstIterator it2; 1784 PhoneNumber::List::ConstIterator it2;
1760 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1785 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1761 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1786 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1762 } 1787 }
1763 kdDebug(5700) << " }" << endl; 1788 kdDebug(5700) << " }" << endl;
1764 1789
1765 Address::List a = addresses(); 1790 Address::List a = addresses();
1766 Address::List::ConstIterator it3; 1791 Address::List::ConstIterator it3;
1767 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1792 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1768 (*it3).dump(); 1793 (*it3).dump();
1769 } 1794 }
1770 1795
1771 kdDebug(5700) << " Keys {" << endl; 1796 kdDebug(5700) << " Keys {" << endl;
1772 Key::List k = keys(); 1797 Key::List k = keys();
1773 Key::List::ConstIterator it4; 1798 Key::List::ConstIterator it4;
1774 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1799 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1775 kdDebug(5700) << " Type: " << int((*it4).type()) << 1800 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1776 " Key: " << (*it4).textData() << 1801 " Key: " << (*it4).textData() <<
1777 " CustomString: " << (*it4).customTypeString() << endl; 1802 " CustomString: " << (*it4).customTypeString() << endl;
1778 } 1803 }
1779 kdDebug(5700) << " }" << endl; 1804 kdDebug(5700) << " }" << endl;
1780 1805
1781 kdDebug(5700) << "}" << endl; 1806 kdDebug(5700) << "}" << endl;
1782#endif 1807#endif
1783} 1808}
1784 1809
1785 1810
1786void Addressee::insertAddress( const Address &address ) 1811void Addressee::insertAddress( const Address &address )
1787{ 1812{
1788 detach(); 1813 detach();
1789 mData->empty = false; 1814 mData->empty = false;
1790 1815
1791 Address::List::Iterator it; 1816 Address::List::Iterator it;
1792 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1817 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1793 if ( (*it).id() == address.id() ) { 1818 if ( (*it).id() == address.id() ) {
1794 *it = address; 1819 *it = address;
1795 return; 1820 return;
1796 } 1821 }
1797 } 1822 }
1798 mData->addresses.append( address ); 1823 mData->addresses.append( address );
1799} 1824}
1800 1825
1801void Addressee::removeAddress( const Address &address ) 1826void Addressee::removeAddress( const Address &address )
1802{ 1827{
1803 detach(); 1828 detach();
1804 1829
1805 Address::List::Iterator it; 1830 Address::List::Iterator it;
1806 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1831 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1807 if ( (*it).id() == address.id() ) { 1832 if ( (*it).id() == address.id() ) {
1808 mData->addresses.remove( it ); 1833 mData->addresses.remove( it );
1809 return; 1834 return;
1810 } 1835 }
1811 } 1836 }
1812} 1837}
1813 1838
1814Address Addressee::address( int type ) const 1839Address Addressee::address( int type ) const
1815{ 1840{
1816 Address address( type ); 1841 Address address( type );