summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
authorzautrix <zautrix>2005-01-18 09:31:59 (UTC)
committer zautrix <zautrix>2005-01-18 09:31:59 (UTC)
commit2d6776d79732f6771885a549de5c37f9e75f7641 (patch) (unidiff)
tree5dc2abf48a99e2a35f8e1458f731b3ef9210ac7e /kabc/addressee.cpp
parent522486966ecf041a6e49913b6e420d58d4284837 (diff)
downloadkdepimpi-2d6776d79732f6771885a549de5c37f9e75f7641.zip
kdepimpi-2d6776d79732f6771885a549de5c37f9e75f7641.tar.gz
kdepimpi-2d6776d79732f6771885a549de5c37f9e75f7641.tar.bz2
fixed merging
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp111
1 files changed, 61 insertions, 50 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 3b238f5..82b4b9b 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,790 +1,801 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern ); 46static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern ); 47static bool matchBinaryPatternP( int value, int pattern );
48 48
49struct Addressee::AddresseeData : public KShared 49struct Addressee::AddresseeData : public KShared
50{ 50{
51 QString uid; 51 QString uid;
52 QString name; 52 QString name;
53 QString formattedName; 53 QString formattedName;
54 QString familyName; 54 QString familyName;
55 QString givenName; 55 QString givenName;
56 QString additionalName; 56 QString additionalName;
57 QString prefix; 57 QString prefix;
58 QString suffix; 58 QString suffix;
59 QString nickName; 59 QString nickName;
60 QDateTime birthday; 60 QDateTime birthday;
61 QString mailer; 61 QString mailer;
62 TimeZone timeZone; 62 TimeZone timeZone;
63 Geo geo; 63 Geo geo;
64 QString title; 64 QString title;
65 QString role; 65 QString role;
66 QString organization; 66 QString organization;
67 QString note; 67 QString note;
68 QString productId; 68 QString productId;
69 QDateTime revision; 69 QDateTime revision;
70 QString sortString; 70 QString sortString;
71 QString externalUID; 71 QString externalUID;
72 QString originalExternalUID; 72 QString originalExternalUID;
73 KURL url; 73 KURL url;
74 Secrecy secrecy; 74 Secrecy secrecy;
75 Picture logo; 75 Picture logo;
76 Picture photo; 76 Picture photo;
77 Sound sound; 77 Sound sound;
78 Agent agent; 78 Agent agent;
79 QString mExternalId; 79 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 81 Address::List addresses;
82 Key::List keys; 82 Key::List keys;
83 QStringList emails; 83 QStringList emails;
84 QStringList categories; 84 QStringList categories;
85 QStringList custom; 85 QStringList custom;
86 int mTempSyncStat; 86 int mTempSyncStat;
87 Resource *resource; 87 Resource *resource;
88 88
89 bool empty :1; 89 bool empty :1;
90 bool changed :1; 90 bool changed :1;
91 bool tagged :1; 91 bool tagged :1;
92}; 92};
93 93
94Addressee::Addressee() 94Addressee::Addressee()
95{ 95{
96 mData = new AddresseeData; 96 mData = new AddresseeData;
97 mData->empty = true; 97 mData->empty = true;
98 mData->changed = false; 98 mData->changed = false;
99 mData->resource = 0; 99 mData->resource = 0;
100 mData->mExternalId = ":"; 100 mData->mExternalId = ":";
101 mData->revision = QDateTime ( QDate( 2003,1,1)); 101 mData->revision = QDateTime ( QDate( 2003,1,1));
102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
103} 103}
104 104
105Addressee::~Addressee() 105Addressee::~Addressee()
106{ 106{
107} 107}
108 108
109Addressee::Addressee( const Addressee &a ) 109Addressee::Addressee( const Addressee &a )
110{ 110{
111 mData = a.mData; 111 mData = a.mData;
112} 112}
113 113
114Addressee &Addressee::operator=( const Addressee &a ) 114Addressee &Addressee::operator=( const Addressee &a )
115{ 115{
116 mData = a.mData; 116 mData = a.mData;
117 return (*this); 117 return (*this);
118} 118}
119 119
120Addressee Addressee::copy() 120Addressee Addressee::copy()
121{ 121{
122 Addressee a; 122 Addressee a;
123 *(a.mData) = *mData; 123 *(a.mData) = *mData;
124 return a; 124 return a;
125} 125}
126 126
127void Addressee::detach() 127void Addressee::detach()
128{ 128{
129 if ( mData.count() == 1 ) return; 129 if ( mData.count() == 1 ) return;
130 *this = copy(); 130 *this = copy();
131} 131}
132 132
133bool Addressee::operator==( const Addressee &a ) const 133bool Addressee::operator==( const Addressee &a ) const
134{ 134{
135 if ( uid() != a.uid() ) return false; 135 if ( uid() != a.uid() ) return false;
136 if ( mData->name != a.mData->name ) return false; 136 if ( mData->name != a.mData->name ) return false;
137 if ( mData->formattedName != a.mData->formattedName ) return false; 137 if ( mData->formattedName != a.mData->formattedName ) return false;
138 if ( mData->familyName != a.mData->familyName ) return false; 138 if ( mData->familyName != a.mData->familyName ) return false;
139 if ( mData->givenName != a.mData->givenName ) return false; 139 if ( mData->givenName != a.mData->givenName ) return false;
140 if ( mData->additionalName != a.mData->additionalName ) return false; 140 if ( mData->additionalName != a.mData->additionalName ) return false;
141 if ( mData->prefix != a.mData->prefix ) return false; 141 if ( mData->prefix != a.mData->prefix ) return false;
142 if ( mData->suffix != a.mData->suffix ) return false; 142 if ( mData->suffix != a.mData->suffix ) return false;
143 if ( mData->nickName != a.mData->nickName ) return false; 143 if ( mData->nickName != a.mData->nickName ) return false;
144 if ( mData->birthday != a.mData->birthday ) return false; 144 if ( mData->birthday != a.mData->birthday ) return false;
145 if ( mData->mailer != a.mData->mailer ) return false; 145 if ( mData->mailer != a.mData->mailer ) return false;
146 if ( mData->timeZone != a.mData->timeZone ) return false; 146 if ( mData->timeZone != a.mData->timeZone ) return false;
147 if ( mData->geo != a.mData->geo ) return false; 147 if ( mData->geo != a.mData->geo ) return false;
148 if ( mData->title != a.mData->title ) return false; 148 if ( mData->title != a.mData->title ) return false;
149 if ( mData->role != a.mData->role ) return false; 149 if ( mData->role != a.mData->role ) return false;
150 if ( mData->organization != a.mData->organization ) return false; 150 if ( mData->organization != a.mData->organization ) return false;
151 if ( mData->note != a.mData->note ) return false; 151 if ( mData->note != a.mData->note ) return false;
152 if ( mData->productId != a.mData->productId ) return false; 152 if ( mData->productId != a.mData->productId ) return false;
153 //if ( mData->revision != a.mData->revision ) return false; 153 //if ( mData->revision != a.mData->revision ) return false;
154 if ( mData->sortString != a.mData->sortString ) return false; 154 if ( mData->sortString != a.mData->sortString ) return false;
155 if ( mData->secrecy != a.mData->secrecy ) return false; 155 if ( mData->secrecy != a.mData->secrecy ) return false;
156 if ( mData->logo != a.mData->logo ) return false; 156 if ( mData->logo != a.mData->logo ) return false;
157 if ( mData->photo != a.mData->photo ) return false; 157 if ( mData->photo != a.mData->photo ) return false;
158 if ( mData->sound != a.mData->sound ) return false; 158 if ( mData->sound != a.mData->sound ) return false;
159 if ( mData->agent != a.mData->agent ) return false; 159 if ( mData->agent != a.mData->agent ) return false;
160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
161 ( mData->url != a.mData->url ) ) return false; 161 ( mData->url != a.mData->url ) ) return false;
162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
163 if ( mData->addresses != a.mData->addresses ) return false; 163 if ( mData->addresses != a.mData->addresses ) return false;
164 if ( mData->keys != a.mData->keys ) return false; 164 if ( mData->keys != a.mData->keys ) return false;
165 if ( mData->emails != a.mData->emails ) return false; 165 if ( mData->emails != a.mData->emails ) return false;
166 if ( mData->categories != a.mData->categories ) return false; 166 if ( mData->categories != a.mData->categories ) return false;
167 if ( mData->custom != a.mData->custom ) return false; 167 if ( mData->custom != a.mData->custom ) return false;
168 168
169 return true; 169 return true;
170} 170}
171 171
172bool Addressee::operator!=( const Addressee &a ) const 172bool Addressee::operator!=( const Addressee &a ) const
173{ 173{
174 return !( a == *this ); 174 return !( a == *this );
175} 175}
176 176
177bool Addressee::isEmpty() const 177bool Addressee::isEmpty() const
178{ 178{
179 return mData->empty; 179 return mData->empty;
180} 180}
181ulong Addressee::getCsum4List( const QStringList & attList) 181ulong Addressee::getCsum4List( const QStringList & attList)
182{ 182{
183 int max = attList.count(); 183 int max = attList.count();
184 ulong cSum = 0; 184 ulong cSum = 0;
185 int j,k,i; 185 int j,k,i;
186 int add; 186 int add;
187 for ( i = 0; i < max ; ++i ) { 187 for ( i = 0; i < max ; ++i ) {
188 QString s = attList[i]; 188 QString s = attList[i];
189 if ( ! s.isEmpty() ){ 189 if ( ! s.isEmpty() ){
190 j = s.length(); 190 j = s.length();
191 for ( k = 0; k < j; ++k ) { 191 for ( k = 0; k < j; ++k ) {
192 int mul = k +1; 192 int mul = k +1;
193 add = s[k].unicode (); 193 add = s[k].unicode ();
194 if ( k < 16 ) 194 if ( k < 16 )
195 mul = mul * mul; 195 mul = mul * mul;
196 int ii = i+1; 196 int ii = i+1;
197 add = add * mul *ii*ii*ii; 197 add = add * mul *ii*ii*ii;
198 cSum += add; 198 cSum += add;
199 } 199 }
200 } 200 }
201 201
202 } 202 }
203 //QString dump = attList.join(","); 203 //QString dump = attList.join(",");
204 //qDebug("csum: %d %s", cSum,dump.latin1()); 204 //qDebug("csum: %d %s", cSum,dump.latin1());
205 205
206 return cSum; 206 return cSum;
207 207
208} 208}
209void Addressee::computeCsum(const QString &dev) 209void Addressee::computeCsum(const QString &dev)
210{ 210{
211 QStringList l; 211 QStringList l;
212 //if ( !mData->name.isEmpty() ) l.append(mData->name); 212 //if ( !mData->name.isEmpty() ) l.append(mData->name);
213 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 213 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
216 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); 216 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
224 if ( !mData->title .isEmpty() ) l.append( mData->title ); 224 if ( !mData->title .isEmpty() ) l.append( mData->title );
225 if ( !mData->role.isEmpty() ) l.append( mData->role ); 225 if ( !mData->role.isEmpty() ) l.append( mData->role );
226 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 226 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
227 if ( !mData->note.isEmpty() ) l.append( mData->note ); 227 if ( !mData->note.isEmpty() ) l.append( mData->note );
228 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 228 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
231 // if ( !mData->logo.isEmpty() ) l.append( ); 231 // if ( !mData->logo.isEmpty() ) l.append( );
232 //if ( !mData->photo.isEmpty() ) l.append( ); 232 //if ( !mData->photo.isEmpty() ) l.append( );
233 //if ( !mData->sound.isEmpty() ) l.append( ); 233 //if ( !mData->sound.isEmpty() ) l.append( );
234 //if ( !mData->agent.isEmpty() ) l.append( ); 234 //if ( !mData->agent.isEmpty() ) l.append( );
235 if ( mData->url.isValid() ) 235 if ( mData->url.isValid() )
236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
237 KABC::PhoneNumber::List phoneNumbers; 237 KABC::PhoneNumber::List phoneNumbers;
238 KABC::PhoneNumber::List::Iterator phoneIter; 238 KABC::PhoneNumber::List::Iterator phoneIter;
239 239
240 QStringList t; 240 QStringList t;
241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
242 ++phoneIter ) 242 ++phoneIter )
243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
244 t.sort(); 244 t.sort();
245 uint iii; 245 uint iii;
246 for ( iii = 0; iii < t.count(); ++iii) 246 for ( iii = 0; iii < t.count(); ++iii)
247 l.append( t[iii] ); 247 l.append( t[iii] );
248 t = mData->emails; 248 t = mData->emails;
249 t.sort(); 249 t.sort();
250 for ( iii = 0; iii < t.count(); ++iii) 250 for ( iii = 0; iii < t.count(); ++iii)
251 l.append( t[iii] ); 251 l.append( t[iii] );
252 t = mData->categories; 252 t = mData->categories;
253 t.sort(); 253 t.sort();
254 for ( iii = 0; iii < t.count(); ++iii) 254 for ( iii = 0; iii < t.count(); ++iii)
255 l.append( t[iii] ); 255 l.append( t[iii] );
256 t = mData->custom; 256 t = mData->custom;
257 t.sort(); 257 t.sort();
258 for ( iii = 0; iii < t.count(); ++iii) 258 for ( iii = 0; iii < t.count(); ++iii)
259 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { 259 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
260 int find = t[iii].find (':')+1; 260 int find = t[iii].find (':')+1;
261 //qDebug("lennnn %d %d ", find, t[iii].length()); 261 //qDebug("lennnn %d %d ", find, t[iii].length());
262 if ( find < t[iii].length()) 262 if ( find < t[iii].length())
263 l.append( t[iii] ); 263 l.append( t[iii] );
264 264
265 } 265 }
266 KABC::Address::List::Iterator addressIter; 266 KABC::Address::List::Iterator addressIter;
267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
268 ++addressIter ) { 268 ++addressIter ) {
269 t = (*addressIter).asList(); 269 t = (*addressIter).asList();
270 t.sort(); 270 t.sort();
271 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 272 l.append( t[iii] );
273 } 273 }
274 uint cs = getCsum4List(l); 274 uint cs = getCsum4List(l);
275 275
276#if 0 276#if 0
277 for ( iii = 0; iii < l.count(); ++iii) 277 for ( iii = 0; iii < l.count(); ++iii)
278 qDebug("%d***%s***",iii,l[iii].latin1()); 278 qDebug("%d***%s***",iii,l[iii].latin1());
279 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 279 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
280#endif 280#endif
281 281
282 setCsum( dev, QString::number (cs )); 282 setCsum( dev, QString::number (cs ));
283} 283}
284 284
285void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 285void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
286{ 286{
287 // merge all standard non-outlook fields.
288 //if isSubSet (e.g. mobile phone sync) merge all fields
287 289
288 detach(); 290 detach();
289 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 291 if ( isSubSet ) {
290 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 292 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
291 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 293 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
292 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 294 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
293 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 295 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
294 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 296 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
295 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 297 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
296 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 298 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
297 if ( !mData->birthday.isValid() ) 299 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
298 if ( ad.mData->birthday.isValid()) 300 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
299 mData->birthday = ad.mData->birthday; 301 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
302 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
303 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
306 if ( !mData->birthday.isValid() )
307 if ( ad.mData->birthday.isValid())
308 mData->birthday = ad.mData->birthday;
309
310 }
300 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 311 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
301 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 312 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
302 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 313 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
303 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
304 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
305 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
306 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
307 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 314 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
308 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 315 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
309 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
310 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
311 QStringList t; 316 QStringList t;
312 QStringList tAD; 317 QStringList tAD;
313 uint iii; 318 uint iii;
314 319
315 // ********** phone numbers 320 // ********** phone numbers
316 PhoneNumber::List phoneAD = ad.phoneNumbers(); 321 if ( isSubSet ) {
317 PhoneNumber::List::Iterator phoneItAD; 322 PhoneNumber::List phoneAD = ad.phoneNumbers();
318 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 323 PhoneNumber::List::Iterator phoneItAD;
319 bool found = false; 324 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
320 PhoneNumber::List::Iterator it; 325 bool found = false;
321 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 326 PhoneNumber::List::Iterator it;
322 if ( ( *phoneItAD ).contains( (*it) ) ) { 327 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
323 found = true; 328 if ( ( *phoneItAD ).contains( (*it) ) ) {
324 (*it).setType( ( *phoneItAD ).type() ); 329 found = true;
325 (*it).setNumber( ( *phoneItAD ).number() ); 330 (*it).setType( ( *phoneItAD ).type() );
326 break; 331 (*it).setNumber( ( *phoneItAD ).number() );
332 break;
333 }
327 } 334 }
335 // if ( isSubSet && ! found )
336 if ( ! found ) // LR try this one...
337 mData->phoneNumbers.append( *phoneItAD );
328 } 338 }
329 // if ( isSubSet && ! found )
330 if ( ! found ) // LR try this one...
331 mData->phoneNumbers.append( *phoneItAD );
332 } 339 }
333 if ( isSubSet ) { 340 if ( isSubSet ) {
334 // ************* emails; 341 // ************* emails;
335 t = mData->emails; 342 t = mData->emails;
336 tAD = ad.mData->emails; 343 tAD = ad.mData->emails;
337 for ( iii = 0; iii < tAD.count(); ++iii) 344 for ( iii = 0; iii < tAD.count(); ++iii)
338 if ( !t.contains(tAD[iii] ) ) 345 if ( !t.contains(tAD[iii] ) )
339 mData->emails.append( tAD[iii] ); 346 mData->emails.append( tAD[iii] );
340 } 347 }
341 348
342 // ************* categories; 349 // ************* categories;
343 t = mData->categories; 350 if ( isSubSet ) {
344 tAD = ad.mData->categories; 351 t = mData->categories;
345 for ( iii = 0; iii < tAD.count(); ++iii) 352 tAD = ad.mData->categories;
346 if ( !t.contains(tAD[iii] ) ) 353 for ( iii = 0; iii < tAD.count(); ++iii)
347 mData->categories.append( tAD[iii] ); 354 if ( !t.contains(tAD[iii] ) )
355 mData->categories.append( tAD[iii] );
356 }
348 QStringList::ConstIterator it; 357 QStringList::ConstIterator it;
349 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 358 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
350 QString qualifiedName = (*it).left( (*it).find( ":" )); 359 QString qualifiedName = (*it).left( (*it).find( ":" ));
351 bool found = false; 360 bool found = false;
352 QStringList::ConstIterator itL; 361 QStringList::ConstIterator itL;
353 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 362 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
354 if ( (*itL).startsWith( qualifiedName ) ) { 363 if ( (*itL).startsWith( qualifiedName ) ) {
355 found = true; 364 found = true;
356 break; 365 break;
357 } 366 }
358 } 367 }
359 if ( ! found ) { 368 if ( ! found ) {
360 mData->custom.append( *it ); 369 mData->custom.append( *it );
361 } 370 }
362 } 371 }
363 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 372 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
364 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 373 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
365 if ( !mData->sound.isIntern() ) { 374 if ( !mData->sound.isIntern() ) {
366 if ( mData->sound.url().isEmpty() ) { 375 if ( mData->sound.url().isEmpty() ) {
367 mData->sound = ad.mData->sound; 376 mData->sound = ad.mData->sound;
368 } 377 }
369 } 378 }
370 if ( !mData->agent.isIntern() ) { 379 if ( !mData->agent.isIntern() ) {
371 if ( mData->agent.url().isEmpty() ) { 380 if ( mData->agent.url().isEmpty() ) {
372 mData->agent = ad.mData->agent; 381 mData->agent = ad.mData->agent;
373 } 382 }
374 } 383 }
375 { 384 {
376 Key::List::Iterator itA; 385 Key::List::Iterator itA;
377 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 386 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
378 bool found = false; 387 bool found = false;
379 Key::List::Iterator it; 388 Key::List::Iterator it;
380 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 389 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
381 if ( (*it) == (*itA)) { 390 if ( (*it) == (*itA)) {
382 found = true; 391 found = true;
383 break; 392 break;
384 393
385 } 394 }
386 } 395 }
387 if ( ! found ) { 396 if ( ! found ) {
388 mData->keys.append( *itA ); 397 mData->keys.append( *itA );
389 } 398 }
390 } 399 }
391 } 400 }
392 KABC::Address::List::Iterator addressIterA; 401 if ( isSubSet ) {
393 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 402 KABC::Address::List::Iterator addressIterA;
394 bool found = false; 403 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
395 KABC::Address::List::Iterator addressIter; 404 bool found = false;
396 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 405 KABC::Address::List::Iterator addressIter;
397 ++addressIter ) { 406 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
398 if ( (*addressIter) == (*addressIterA)) { 407 ++addressIter ) {
399 found = true; 408 if ( (*addressIter) == (*addressIterA)) {
400 (*addressIter).setType( (*addressIterA).type() ); 409 found = true;
401 break; 410 (*addressIter).setType( (*addressIterA).type() );
402 } 411 break;
412 }
403 413
404 } 414 }
405 if ( isSubSet && ! found ) { 415 if ( isSubSet && ! found ) {
406 mData->addresses.append( *addressIterA ); 416 mData->addresses.append( *addressIterA );
417 }
407 } 418 }
408 } 419 }
409 //qDebug("merge contact %s ", ad.uid().latin1()); 420 //qDebug("merge contact %s ", ad.uid().latin1());
410 setUid( ad.uid() ); 421 setUid( ad.uid() );
411 setRevision( ad.revision() ); 422 setRevision( ad.revision() );
412} 423}
413 424
414bool Addressee::removeVoice() 425bool Addressee::removeVoice()
415{ 426{
416 PhoneNumber::List phoneN = phoneNumbers(); 427 PhoneNumber::List phoneN = phoneNumbers();
417 PhoneNumber::List::Iterator phoneIt; 428 PhoneNumber::List::Iterator phoneIt;
418 bool found = false; 429 bool found = false;
419 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 430 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
420 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 431 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
421 if ((*phoneIt).type() - PhoneNumber::Voice ) { 432 if ((*phoneIt).type() - PhoneNumber::Voice ) {
422 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 433 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
423 insertPhoneNumber( (*phoneIt) ); 434 insertPhoneNumber( (*phoneIt) );
424 found = true; 435 found = true;
425 } 436 }
426 } 437 }
427 438
428 } 439 }
429 return found; 440 return found;
430} 441}
431 442
432bool Addressee::containsAdr(const Addressee& ad ) 443bool Addressee::containsAdr(const Addressee& ad )
433{ 444{
434 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 445 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
435 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 446 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
436 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 447 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
437 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 448 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
438 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 449 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
439 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 450 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
440 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 451 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
441 452
442 // compare phone numbers 453 // compare phone numbers
443 PhoneNumber::List phoneN = ad.phoneNumbers(); 454 PhoneNumber::List phoneN = ad.phoneNumbers();
444 PhoneNumber::List::Iterator phoneIt; 455 PhoneNumber::List::Iterator phoneIt;
445 bool found = false; 456 bool found = false;
446 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 457 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
447 bool found = false; 458 bool found = false;
448 PhoneNumber::List phoneL = ad.phoneNumbers(); 459 PhoneNumber::List phoneL = ad.phoneNumbers();
449 PhoneNumber::List::Iterator phoneItL; 460 PhoneNumber::List::Iterator phoneItL;
450 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 461 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
451 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 462 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
452 found = true; 463 found = true;
453 break; 464 break;
454 } 465 }
455 } 466 }
456 if ( ! found ) 467 if ( ! found )
457 return false; 468 return false;
458 } 469 }
459 return true; 470 return true;
460 471
461} 472}
462void Addressee::simplifyAddresses() 473void Addressee::simplifyAddresses()
463{ 474{
464 475
465 476
466 Address::List list; 477 Address::List list;
467 Address::List::Iterator it; 478 Address::List::Iterator it;
468 Address::List::Iterator it2; 479 Address::List::Iterator it2;
469 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 480 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
470 it2 = it; 481 it2 = it;
471 ++it2; 482 ++it2;
472 for( ; it2 != mData->addresses.end(); ++it2 ) { 483 for( ; it2 != mData->addresses.end(); ++it2 ) {
473 if ( (*it) == (*it2) ) { 484 if ( (*it) == (*it2) ) {
474 list.append( *it ); 485 list.append( *it );
475 break; 486 break;
476 } 487 }
477 } 488 }
478 } 489 }
479 for( it = list.begin(); it != list.end(); ++it ) { 490 for( it = list.begin(); it != list.end(); ++it ) {
480 removeAddress( (*it) ); 491 removeAddress( (*it) );
481 } 492 }
482 493
483 list.clear(); 494 list.clear();
484 int max = 2; 495 int max = 2;
485 if ( mData->url.isValid() ) 496 if ( mData->url.isValid() )
486 max = 1; 497 max = 1;
487 if ( mData->addresses.count() <= max ) return ; 498 if ( mData->addresses.count() <= max ) return ;
488 int count = 0; 499 int count = 0;
489 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 500 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
490 if ( count >= max ) 501 if ( count >= max )
491 list.append( *it ); 502 list.append( *it );
492 ++count; 503 ++count;
493 } 504 }
494 for( it = list.begin(); it != list.end(); ++it ) { 505 for( it = list.begin(); it != list.end(); ++it ) {
495 removeAddress( (*it) ); 506 removeAddress( (*it) );
496 } 507 }
497} 508}
498 509
499// removes all emails but the first 510// removes all emails but the first
500// needed by phone sync 511// needed by phone sync
501void Addressee::simplifyEmails() 512void Addressee::simplifyEmails()
502{ 513{
503 if ( mData->emails.count() == 0 ) return ; 514 if ( mData->emails.count() == 0 ) return ;
504 QString email = mData->emails.first(); 515 QString email = mData->emails.first();
505 detach(); 516 detach();
506 mData->emails.clear(); 517 mData->emails.clear();
507 mData->emails.append( email ); 518 mData->emails.append( email );
508} 519}
509 520
510void Addressee::simplifyPhoneNumbers() 521void Addressee::simplifyPhoneNumbers()
511{ 522{
512 int max = 4; 523 int max = 4;
513 int inList = mData->phoneNumbers.count(); 524 int inList = mData->phoneNumbers.count();
514 KABC::PhoneNumber::List removeNumbers; 525 KABC::PhoneNumber::List removeNumbers;
515 KABC::PhoneNumber::List::Iterator phoneIter; 526 KABC::PhoneNumber::List::Iterator phoneIter;
516 if ( inList > max ) { 527 if ( inList > max ) {
517 // delete non-preferred numbers 528 // delete non-preferred numbers
518 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 529 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
519 ++phoneIter ) { 530 ++phoneIter ) {
520 if ( inList > max ) { 531 if ( inList > max ) {
521 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 532 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
522 removeNumbers.append( ( *phoneIter ) ); 533 removeNumbers.append( ( *phoneIter ) );
523 --inList; 534 --inList;
524 } 535 }
525 } else 536 } else
526 break; 537 break;
527 } 538 }
528 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 539 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
529 ++phoneIter ) { 540 ++phoneIter ) {
530 removePhoneNumber(( *phoneIter )); 541 removePhoneNumber(( *phoneIter ));
531 } 542 }
532 // delete preferred numbers 543 // delete preferred numbers
533 if ( inList > max ) { 544 if ( inList > max ) {
534 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 545 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
535 ++phoneIter ) { 546 ++phoneIter ) {
536 if ( inList > max ) { 547 if ( inList > max ) {
537 removeNumbers.append( ( *phoneIter ) ); 548 removeNumbers.append( ( *phoneIter ) );
538 --inList; 549 --inList;
539 } else 550 } else
540 break; 551 break;
541 } 552 }
542 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 553 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
543 ++phoneIter ) { 554 ++phoneIter ) {
544 removePhoneNumber(( *phoneIter )); 555 removePhoneNumber(( *phoneIter ));
545 } 556 }
546 } 557 }
547 } 558 }
548 // remove non-numeric characters 559 // remove non-numeric characters
549 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 560 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
550 ++phoneIter ) { 561 ++phoneIter ) {
551 if ( ! ( *phoneIter ).simplifyNumber() ) 562 if ( ! ( *phoneIter ).simplifyNumber() )
552 removeNumbers.append( ( *phoneIter ) ); 563 removeNumbers.append( ( *phoneIter ) );
553 } 564 }
554 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 565 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
555 ++phoneIter ) { 566 ++phoneIter ) {
556 removePhoneNumber(( *phoneIter )); 567 removePhoneNumber(( *phoneIter ));
557 } 568 }
558} 569}
559void Addressee::simplifyPhoneNumberTypes() 570void Addressee::simplifyPhoneNumberTypes()
560{ 571{
561 KABC::PhoneNumber::List::Iterator phoneIter; 572 KABC::PhoneNumber::List::Iterator phoneIter;
562 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 573 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
563 ++phoneIter ) 574 ++phoneIter )
564 ( *phoneIter ).simplifyType(); 575 ( *phoneIter ).simplifyType();
565} 576}
566void Addressee::removeID(const QString &prof) 577void Addressee::removeID(const QString &prof)
567{ 578{
568 detach(); 579 detach();
569 if ( prof.isEmpty() ) 580 if ( prof.isEmpty() )
570 mData->mExternalId = ":"; 581 mData->mExternalId = ":";
571 else 582 else
572 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 583 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
573 584
574} 585}
575void Addressee::setID( const QString & prof , const QString & id ) 586void Addressee::setID( const QString & prof , const QString & id )
576{ 587{
577 detach(); 588 detach();
578 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 589 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
579 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 590 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
580} 591}
581void Addressee::setTempSyncStat( int id ) 592void Addressee::setTempSyncStat( int id )
582{ 593{
583 if ( mData->mTempSyncStat == id ) return; 594 if ( mData->mTempSyncStat == id ) return;
584 detach(); 595 detach();
585 mData->mTempSyncStat = id; 596 mData->mTempSyncStat = id;
586} 597}
587int Addressee::tempSyncStat() const 598int Addressee::tempSyncStat() const
588{ 599{
589 return mData->mTempSyncStat; 600 return mData->mTempSyncStat;
590} 601}
591 602
592const QString Addressee::getID( const QString & prof) const 603const QString Addressee::getID( const QString & prof) const
593{ 604{
594 return KIdManager::getId ( mData->mExternalId, prof ); 605 return KIdManager::getId ( mData->mExternalId, prof );
595} 606}
596 607
597void Addressee::setCsum( const QString & prof , const QString & id ) 608void Addressee::setCsum( const QString & prof , const QString & id )
598{ 609{
599 detach(); 610 detach();
600 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 611 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
601 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 612 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
602 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 613 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
603} 614}
604 615
605const QString Addressee::getCsum( const QString & prof) const 616const QString Addressee::getCsum( const QString & prof) const
606{ 617{
607 return KIdManager::getCsum ( mData->mExternalId, prof ); 618 return KIdManager::getCsum ( mData->mExternalId, prof );
608} 619}
609 620
610void Addressee::setIDStr( const QString & s ) 621void Addressee::setIDStr( const QString & s )
611{ 622{
612 detach(); 623 detach();
613 mData->mExternalId = s; 624 mData->mExternalId = s;
614} 625}
615 626
616const QString Addressee::IDStr() const 627const QString Addressee::IDStr() const
617{ 628{
618 return mData->mExternalId; 629 return mData->mExternalId;
619} 630}
620 631
621void Addressee::setExternalUID( const QString &id ) 632void Addressee::setExternalUID( const QString &id )
622{ 633{
623 if ( id == mData->externalUID ) return; 634 if ( id == mData->externalUID ) return;
624 detach(); 635 detach();
625 mData->empty = false; 636 mData->empty = false;
626 mData->externalUID = id; 637 mData->externalUID = id;
627} 638}
628 639
629const QString Addressee::externalUID() const 640const QString Addressee::externalUID() const
630{ 641{
631 return mData->externalUID; 642 return mData->externalUID;
632} 643}
633void Addressee::setOriginalExternalUID( const QString &id ) 644void Addressee::setOriginalExternalUID( const QString &id )
634{ 645{
635 if ( id == mData->originalExternalUID ) return; 646 if ( id == mData->originalExternalUID ) return;
636 detach(); 647 detach();
637 mData->empty = false; 648 mData->empty = false;
638 //qDebug("*******Set orig uid %s ", id.latin1()); 649 //qDebug("*******Set orig uid %s ", id.latin1());
639 mData->originalExternalUID = id; 650 mData->originalExternalUID = id;
640} 651}
641 652
642QString Addressee::originalExternalUID() const 653QString Addressee::originalExternalUID() const
643{ 654{
644 return mData->originalExternalUID; 655 return mData->originalExternalUID;
645} 656}
646 657
647void Addressee::setUid( const QString &id ) 658void Addressee::setUid( const QString &id )
648{ 659{
649 if ( id == mData->uid ) return; 660 if ( id == mData->uid ) return;
650 detach(); 661 detach();
651 //qDebug("****setuid %s ", id.latin1()); 662 //qDebug("****setuid %s ", id.latin1());
652 mData->empty = false; 663 mData->empty = false;
653 mData->uid = id; 664 mData->uid = id;
654} 665}
655 666
656const QString Addressee::uid() const 667const QString Addressee::uid() const
657{ 668{
658 if ( mData->uid.isEmpty() ) 669 if ( mData->uid.isEmpty() )
659 mData->uid = KApplication::randomString( 10 ); 670 mData->uid = KApplication::randomString( 10 );
660 671
661 return mData->uid; 672 return mData->uid;
662} 673}
663 674
664QString Addressee::uidLabel() 675QString Addressee::uidLabel()
665{ 676{
666 return i18n("Unique Identifier"); 677 return i18n("Unique Identifier");
667} 678}
668 679
669void Addressee::setName( const QString &name ) 680void Addressee::setName( const QString &name )
670{ 681{
671 if ( name == mData->name ) return; 682 if ( name == mData->name ) return;
672 detach(); 683 detach();
673 mData->empty = false; 684 mData->empty = false;
674 mData->name = name; 685 mData->name = name;
675} 686}
676 687
677QString Addressee::name() const 688QString Addressee::name() const
678{ 689{
679 return mData->name; 690 return mData->name;
680} 691}
681 692
682QString Addressee::nameLabel() 693QString Addressee::nameLabel()
683{ 694{
684 return i18n("Name"); 695 return i18n("Name");
685} 696}
686 697
687 698
688void Addressee::setFormattedName( const QString &formattedName ) 699void Addressee::setFormattedName( const QString &formattedName )
689{ 700{
690 if ( formattedName == mData->formattedName ) return; 701 if ( formattedName == mData->formattedName ) return;
691 detach(); 702 detach();
692 mData->empty = false; 703 mData->empty = false;
693 mData->formattedName = formattedName; 704 mData->formattedName = formattedName;
694} 705}
695 706
696QString Addressee::formattedName() const 707QString Addressee::formattedName() const
697{ 708{
698 return mData->formattedName; 709 return mData->formattedName;
699} 710}
700 711
701QString Addressee::formattedNameLabel() 712QString Addressee::formattedNameLabel()
702{ 713{
703 return i18n("Formatted Name"); 714 return i18n("Formatted Name");
704} 715}
705 716
706 717
707void Addressee::setFamilyName( const QString &familyName ) 718void Addressee::setFamilyName( const QString &familyName )
708{ 719{
709 if ( familyName == mData->familyName ) return; 720 if ( familyName == mData->familyName ) return;
710 detach(); 721 detach();
711 mData->empty = false; 722 mData->empty = false;
712 mData->familyName = familyName; 723 mData->familyName = familyName;
713} 724}
714 725
715QString Addressee::familyName() const 726QString Addressee::familyName() const
716{ 727{
717 return mData->familyName; 728 return mData->familyName;
718} 729}
719 730
720QString Addressee::familyNameLabel() 731QString Addressee::familyNameLabel()
721{ 732{
722 return i18n("Family Name"); 733 return i18n("Family Name");
723} 734}
724 735
725 736
726void Addressee::setGivenName( const QString &givenName ) 737void Addressee::setGivenName( const QString &givenName )
727{ 738{
728 if ( givenName == mData->givenName ) return; 739 if ( givenName == mData->givenName ) return;
729 detach(); 740 detach();
730 mData->empty = false; 741 mData->empty = false;
731 mData->givenName = givenName; 742 mData->givenName = givenName;
732} 743}
733 744
734QString Addressee::givenName() const 745QString Addressee::givenName() const
735{ 746{
736 return mData->givenName; 747 return mData->givenName;
737} 748}
738 749
739QString Addressee::givenNameLabel() 750QString Addressee::givenNameLabel()
740{ 751{
741 return i18n("Given Name"); 752 return i18n("Given Name");
742} 753}
743 754
744 755
745void Addressee::setAdditionalName( const QString &additionalName ) 756void Addressee::setAdditionalName( const QString &additionalName )
746{ 757{
747 if ( additionalName == mData->additionalName ) return; 758 if ( additionalName == mData->additionalName ) return;
748 detach(); 759 detach();
749 mData->empty = false; 760 mData->empty = false;
750 mData->additionalName = additionalName; 761 mData->additionalName = additionalName;
751} 762}
752 763
753QString Addressee::additionalName() const 764QString Addressee::additionalName() const
754{ 765{
755 return mData->additionalName; 766 return mData->additionalName;
756} 767}
757 768
758QString Addressee::additionalNameLabel() 769QString Addressee::additionalNameLabel()
759{ 770{
760 return i18n("Additional Names"); 771 return i18n("Additional Names");
761} 772}
762 773
763 774
764void Addressee::setPrefix( const QString &prefix ) 775void Addressee::setPrefix( const QString &prefix )
765{ 776{
766 if ( prefix == mData->prefix ) return; 777 if ( prefix == mData->prefix ) return;
767 detach(); 778 detach();
768 mData->empty = false; 779 mData->empty = false;
769 mData->prefix = prefix; 780 mData->prefix = prefix;
770} 781}
771 782
772QString Addressee::prefix() const 783QString Addressee::prefix() const
773{ 784{
774 return mData->prefix; 785 return mData->prefix;
775} 786}
776 787
777QString Addressee::prefixLabel() 788QString Addressee::prefixLabel()
778{ 789{
779 return i18n("Honorific Prefixes"); 790 return i18n("Honorific Prefixes");
780} 791}
781 792
782 793
783void Addressee::setSuffix( const QString &suffix ) 794void Addressee::setSuffix( const QString &suffix )
784{ 795{
785 if ( suffix == mData->suffix ) return; 796 if ( suffix == mData->suffix ) return;
786 detach(); 797 detach();
787 mData->empty = false; 798 mData->empty = false;
788 mData->suffix = suffix; 799 mData->suffix = suffix;
789} 800}
790 801