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