summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-13 07:02:20 (UTC)
committer zautrix <zautrix>2004-10-13 07:02:20 (UTC)
commitf22ee1ec902fe2fc610786f39049fb84542b8726 (patch) (unidiff)
tree22e8f0378410dd183dd8efc6cac418ec074321de
parentf08cf9044213a60c87e2bf299665d13a335feff5 (diff)
downloadkdepimpi-f22ee1ec902fe2fc610786f39049fb84542b8726.zip
kdepimpi-f22ee1ec902fe2fc610786f39049fb84542b8726.tar.gz
kdepimpi-f22ee1ec902fe2fc610786f39049fb84542b8726.tar.bz2
merging contacts
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp123
-rw-r--r--kabc/addressee.h2
2 files changed, 104 insertions, 21 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 548305a..cb10160 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,1987 +1,2070 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern ); 46static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern ); 47static bool matchBinaryPatternP( int value, int pattern );
48 48
49struct Addressee::AddresseeData : public KShared 49struct Addressee::AddresseeData : public KShared
50{ 50{
51 QString uid; 51 QString uid;
52 QString name; 52 QString name;
53 QString formattedName; 53 QString formattedName;
54 QString familyName; 54 QString familyName;
55 QString givenName; 55 QString givenName;
56 QString additionalName; 56 QString additionalName;
57 QString prefix; 57 QString prefix;
58 QString suffix; 58 QString suffix;
59 QString nickName; 59 QString nickName;
60 QDateTime birthday; 60 QDateTime birthday;
61 QString mailer; 61 QString mailer;
62 TimeZone timeZone; 62 TimeZone timeZone;
63 Geo geo; 63 Geo geo;
64 QString title; 64 QString title;
65 QString role; 65 QString role;
66 QString organization; 66 QString organization;
67 QString note; 67 QString note;
68 QString productId; 68 QString productId;
69 QDateTime revision; 69 QDateTime revision;
70 QString sortString; 70 QString sortString;
71 QString externalUID; 71 QString externalUID;
72 QString originalExternalUID; 72 QString originalExternalUID;
73 KURL url; 73 KURL url;
74 Secrecy secrecy; 74 Secrecy secrecy;
75 Picture logo; 75 Picture logo;
76 Picture photo; 76 Picture photo;
77 Sound sound; 77 Sound sound;
78 Agent agent; 78 Agent agent;
79 QString mExternalId; 79 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 81 Address::List addresses;
82 Key::List keys; 82 Key::List keys;
83 QStringList emails; 83 QStringList emails;
84 QStringList categories; 84 QStringList categories;
85 QStringList custom; 85 QStringList custom;
86 int mTempSyncStat; 86 int mTempSyncStat;
87 Resource *resource; 87 Resource *resource;
88 88
89 bool empty :1; 89 bool empty :1;
90 bool changed :1; 90 bool changed :1;
91 bool tagged :1; 91 bool tagged :1;
92}; 92};
93 93
94Addressee::Addressee() 94Addressee::Addressee()
95{ 95{
96 mData = new AddresseeData; 96 mData = new AddresseeData;
97 mData->empty = true; 97 mData->empty = true;
98 mData->changed = false; 98 mData->changed = false;
99 mData->resource = 0; 99 mData->resource = 0;
100 mData->mExternalId = ":"; 100 mData->mExternalId = ":";
101 mData->revision = QDateTime ( QDate( 2003,1,1)); 101 mData->revision = QDateTime ( QDate( 2003,1,1));
102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
103} 103}
104 104
105Addressee::~Addressee() 105Addressee::~Addressee()
106{ 106{
107} 107}
108 108
109Addressee::Addressee( const Addressee &a ) 109Addressee::Addressee( const Addressee &a )
110{ 110{
111 mData = a.mData; 111 mData = a.mData;
112} 112}
113 113
114Addressee &Addressee::operator=( const Addressee &a ) 114Addressee &Addressee::operator=( const Addressee &a )
115{ 115{
116 mData = a.mData; 116 mData = a.mData;
117 return (*this); 117 return (*this);
118} 118}
119 119
120Addressee Addressee::copy() 120Addressee Addressee::copy()
121{ 121{
122 Addressee a; 122 Addressee a;
123 *(a.mData) = *mData; 123 *(a.mData) = *mData;
124 return a; 124 return a;
125} 125}
126 126
127void Addressee::detach() 127void Addressee::detach()
128{ 128{
129 if ( mData.count() == 1 ) return; 129 if ( mData.count() == 1 ) return;
130 *this = copy(); 130 *this = copy();
131} 131}
132 132
133bool Addressee::operator==( const Addressee &a ) const 133bool Addressee::operator==( const Addressee &a ) const
134{ 134{
135 if ( uid() != a.uid() ) return false; 135 if ( uid() != a.uid() ) return false;
136 if ( mData->name != a.mData->name ) return false; 136 if ( mData->name != a.mData->name ) return false;
137 if ( mData->formattedName != a.mData->formattedName ) return false; 137 if ( mData->formattedName != a.mData->formattedName ) return false;
138 if ( mData->familyName != a.mData->familyName ) return false; 138 if ( mData->familyName != a.mData->familyName ) return false;
139 if ( mData->givenName != a.mData->givenName ) return false; 139 if ( mData->givenName != a.mData->givenName ) return false;
140 if ( mData->additionalName != a.mData->additionalName ) return false; 140 if ( mData->additionalName != a.mData->additionalName ) return false;
141 if ( mData->prefix != a.mData->prefix ) return false; 141 if ( mData->prefix != a.mData->prefix ) return false;
142 if ( mData->suffix != a.mData->suffix ) return false; 142 if ( mData->suffix != a.mData->suffix ) return false;
143 if ( mData->nickName != a.mData->nickName ) return false; 143 if ( mData->nickName != a.mData->nickName ) return false;
144 if ( mData->birthday != a.mData->birthday ) return false; 144 if ( mData->birthday != a.mData->birthday ) return false;
145 if ( mData->mailer != a.mData->mailer ) return false; 145 if ( mData->mailer != a.mData->mailer ) return false;
146 if ( mData->timeZone != a.mData->timeZone ) return false; 146 if ( mData->timeZone != a.mData->timeZone ) return false;
147 if ( mData->geo != a.mData->geo ) return false; 147 if ( mData->geo != a.mData->geo ) return false;
148 if ( mData->title != a.mData->title ) return false; 148 if ( mData->title != a.mData->title ) return false;
149 if ( mData->role != a.mData->role ) return false; 149 if ( mData->role != a.mData->role ) return false;
150 if ( mData->organization != a.mData->organization ) return false; 150 if ( mData->organization != a.mData->organization ) return false;
151 if ( mData->note != a.mData->note ) return false; 151 if ( mData->note != a.mData->note ) return false;
152 if ( mData->productId != a.mData->productId ) return false; 152 if ( mData->productId != a.mData->productId ) return false;
153 //if ( mData->revision != a.mData->revision ) return false; 153 //if ( mData->revision != a.mData->revision ) return false;
154 if ( mData->sortString != a.mData->sortString ) return false; 154 if ( mData->sortString != a.mData->sortString ) return false;
155 if ( mData->secrecy != a.mData->secrecy ) return false; 155 if ( mData->secrecy != a.mData->secrecy ) return false;
156 if ( mData->logo != a.mData->logo ) return false; 156 if ( mData->logo != a.mData->logo ) return false;
157 if ( mData->photo != a.mData->photo ) return false; 157 if ( mData->photo != a.mData->photo ) return false;
158 if ( mData->sound != a.mData->sound ) return false; 158 if ( mData->sound != a.mData->sound ) return false;
159 if ( mData->agent != a.mData->agent ) return false; 159 if ( mData->agent != a.mData->agent ) return false;
160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
161 ( mData->url != a.mData->url ) ) return false; 161 ( mData->url != a.mData->url ) ) return false;
162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
163 if ( mData->addresses != a.mData->addresses ) return false; 163 if ( mData->addresses != a.mData->addresses ) return false;
164 if ( mData->keys != a.mData->keys ) return false; 164 if ( mData->keys != a.mData->keys ) return false;
165 if ( mData->emails != a.mData->emails ) return false; 165 if ( mData->emails != a.mData->emails ) return false;
166 if ( mData->categories != a.mData->categories ) return false; 166 if ( mData->categories != a.mData->categories ) return false;
167 if ( mData->custom != a.mData->custom ) return false; 167 if ( mData->custom != a.mData->custom ) return false;
168 168
169 return true; 169 return true;
170} 170}
171 171
172bool Addressee::operator!=( const Addressee &a ) const 172bool Addressee::operator!=( const Addressee &a ) const
173{ 173{
174 return !( a == *this ); 174 return !( a == *this );
175} 175}
176 176
177bool Addressee::isEmpty() const 177bool Addressee::isEmpty() const
178{ 178{
179 return mData->empty; 179 return mData->empty;
180} 180}
181ulong Addressee::getCsum4List( const QStringList & attList) 181ulong Addressee::getCsum4List( const QStringList & attList)
182{ 182{
183 int max = attList.count(); 183 int max = attList.count();
184 ulong cSum = 0; 184 ulong cSum = 0;
185 int j,k,i; 185 int j,k,i;
186 int add; 186 int add;
187 for ( i = 0; i < max ; ++i ) { 187 for ( i = 0; i < max ; ++i ) {
188 QString s = attList[i]; 188 QString s = attList[i];
189 if ( ! s.isEmpty() ){ 189 if ( ! s.isEmpty() ){
190 j = s.length(); 190 j = s.length();
191 for ( k = 0; k < j; ++k ) { 191 for ( k = 0; k < j; ++k ) {
192 int mul = k +1; 192 int mul = k +1;
193 add = s[k].unicode (); 193 add = s[k].unicode ();
194 if ( k < 16 ) 194 if ( k < 16 )
195 mul = mul * mul; 195 mul = mul * mul;
196 int ii = i+1; 196 int ii = i+1;
197 add = add * mul *ii*ii*ii; 197 add = add * mul *ii*ii*ii;
198 cSum += add; 198 cSum += add;
199 } 199 }
200 } 200 }
201 201
202 } 202 }
203 //QString dump = attList.join(","); 203 //QString dump = attList.join(",");
204 //qDebug("csum: %d %s", cSum,dump.latin1()); 204 //qDebug("csum: %d %s", cSum,dump.latin1());
205 205
206 return cSum; 206 return cSum;
207 207
208} 208}
209void Addressee::computeCsum(const QString &dev) 209void Addressee::computeCsum(const QString &dev)
210{ 210{
211 QStringList l; 211 QStringList l;
212 if ( !mData->name.isEmpty() ) l.append(mData->name); 212 if ( !mData->name.isEmpty() ) l.append(mData->name);
213 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 213 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
216 if ( !mData->additionalName ) l.append( mData->additionalName ); 216 if ( !mData->additionalName ) l.append( mData->additionalName );
217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
224 if ( !mData->title .isEmpty() ) l.append( mData->title ); 224 if ( !mData->title .isEmpty() ) l.append( mData->title );
225 if ( !mData->role.isEmpty() ) l.append( mData->role ); 225 if ( !mData->role.isEmpty() ) l.append( mData->role );
226 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 226 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
227 if ( !mData->note.isEmpty() ) l.append( mData->note ); 227 if ( !mData->note.isEmpty() ) l.append( mData->note );
228 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 228 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
231 // if ( !mData->logo.isEmpty() ) l.append( ); 231 // if ( !mData->logo.isEmpty() ) l.append( );
232 //if ( !mData->photo.isEmpty() ) l.append( ); 232 //if ( !mData->photo.isEmpty() ) l.append( );
233 //if ( !mData->sound.isEmpty() ) l.append( ); 233 //if ( !mData->sound.isEmpty() ) l.append( );
234 //if ( !mData->agent.isEmpty() ) l.append( ); 234 //if ( !mData->agent.isEmpty() ) l.append( );
235 //if ( mData->url.isValid() ) l.append( ); 235 if ( mData->url.isValid() )
236#if 0 236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
237 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
238 if ( !mData->addresses.isEmpty() ) l.append( );
239 //if ( !mData->keys.isEmpty() ) l.append( );
240 if ( !mData->emails.isEmpty() ) l.append( );
241 if ( !mData->categories .isEmpty() ) l.append( );
242 if ( !mData->custom.isEmpty() ) l.append( );
243#endif
244 KABC::PhoneNumber::List phoneNumbers; 237 KABC::PhoneNumber::List phoneNumbers;
245 KABC::PhoneNumber::List::Iterator phoneIter; 238 KABC::PhoneNumber::List::Iterator phoneIter;
246 239
247 QStringList t; 240 QStringList t;
248 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
249 ++phoneIter ) 242 ++phoneIter )
250 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
251 t.sort(); 244 t.sort();
252 uint iii; 245 uint iii;
253 for ( iii = 0; iii < t.count(); ++iii) 246 for ( iii = 0; iii < t.count(); ++iii)
254 l.append( t[iii] ); 247 l.append( t[iii] );
255 t = mData->emails; 248 t = mData->emails;
256 t.sort(); 249 t.sort();
257 for ( iii = 0; iii < t.count(); ++iii) 250 for ( iii = 0; iii < t.count(); ++iii)
258 l.append( t[iii] ); 251 l.append( t[iii] );
259 t = mData->categories; 252 t = mData->categories;
260 t.sort(); 253 t.sort();
261 for ( iii = 0; iii < t.count(); ++iii) 254 for ( iii = 0; iii < t.count(); ++iii)
262 l.append( t[iii] ); 255 l.append( t[iii] );
263 t = mData->custom; 256 t = mData->custom;
264 t.sort(); 257 t.sort();
265 for ( iii = 0; iii < t.count(); ++iii) 258 for ( iii = 0; iii < t.count(); ++iii)
266 l.append( t[iii] ); 259 l.append( t[iii] );
267 KABC::Address::List::Iterator addressIter; 260 KABC::Address::List::Iterator addressIter;
268 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 261 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
269 ++addressIter ) { 262 ++addressIter ) {
270 t = (*addressIter).asList(); 263 t = (*addressIter).asList();
271 t.sort(); 264 t.sort();
272 for ( iii = 0; iii < t.count(); ++iii) 265 for ( iii = 0; iii < t.count(); ++iii)
273 l.append( t[iii] ); 266 l.append( t[iii] );
274 } 267 }
275 uint cs = getCsum4List(l); 268 uint cs = getCsum4List(l);
276 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 269 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
277 setCsum( dev, QString::number (cs )); 270 setCsum( dev, QString::number (cs ));
278} 271}
279 272
280void Addressee::mergeContact( const Addressee& ad ) 273void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
281{ 274{
282 275
283 detach(); 276 detach();
284 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 277 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
285 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 278 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
286 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 279 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
287 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 280 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
288 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 281 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
289 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 282 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
290 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 283 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
291 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 284 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
292 if ( !mData->birthday.isValid() ) 285 if ( !mData->birthday.isValid() )
293 if ( ad.mData->birthday.isValid()) 286 if ( ad.mData->birthday.isValid())
294 mData->birthday = ad.mData->birthday; 287 mData->birthday = ad.mData->birthday;
295 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 288 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
296 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 289 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
297 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 290 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
298 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 291 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
299 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 292 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
300 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 293 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
301 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 294 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
302 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 295 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
303 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 296 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 297 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 298 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
306 PhoneNumber::List phoneAD = phoneNumbers(); 299 QStringList t;
307 PhoneNumber::List::Iterator phoneItAD; 300 QStringList tAD;
308 bool found = false; 301 uint iii;
309 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 302 if ( isSubSet ) {
303 // ********** phone numbers
304 PhoneNumber::List phoneAD = ad.phoneNumbers();
305 PhoneNumber::List::Iterator phoneItAD;
306 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
307 bool found = false;
308 PhoneNumber::List::Iterator it;
309 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
310 if ( (*it) == ( *phoneItAD ) ) {
311 found = true;
312 break;
313 }
314 }
315 if ( ! found )
316 mData->phoneNumbers.append( *phoneItAD );
317 }
318 // ************* emails;
319 t = mData->emails;
320 tAD = ad.mData->emails;
321 for ( iii = 0; iii < tAD.count(); ++iii)
322 if ( !t.contains(tAD[iii] ) )
323 mData->emails.append( tAD[iii] );
324 // ************* categories;
325 t = mData->categories;
326 tAD = ad.mData->categories;
327 for ( iii = 0; iii < tAD.count(); ++iii)
328 if ( !t.contains(tAD[iii] ) )
329 mData->categories.append( tAD[iii] );
310 330
311 331
332 }
333
334 QStringList::ConstIterator it;
335 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
336 QString qualifiedName = (*it).left( (*it).find( ":" ));
337 bool found = false;
338 QStringList::ConstIterator itL;
339 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
340 if ( (*itL).startsWith( qualifiedName ) ) {
341 found = true;
342 break;
343 }
344 }
345 if ( ! found ) {
346 mData->custom.append( *it );
347 }
348 }
349 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
350 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
351 if ( !mData->sound.isIntern() ) {
352 if ( mData->sound.url().isEmpty() ) {
353 mData->sound = ad.mData->sound;
354 }
355 }
356 if ( !mData->agent.isIntern() ) {
357 if ( mData->agent.url().isEmpty() ) {
358 mData->agent = ad.mData->agent;
359 }
312 } 360 }
361
362#if 0
363
364 if ( mData->url.isValid() )
365 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
366 KABC::PhoneNumber::List phoneNumbers;
367 KABC::PhoneNumber::List::Iterator phoneIter;
368
369 QStringList t;
370 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
371 ++phoneIter )
372 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
373 t.sort();
374 uint iii;
375 for ( iii = 0; iii < t.count(); ++iii)
376 l.append( t[iii] );
377 t = mData->emails;
378 t.sort();
379 for ( iii = 0; iii < t.count(); ++iii)
380 l.append( t[iii] );
381 t = mData->categories;
382 t.sort();
383 for ( iii = 0; iii < t.count(); ++iii)
384 l.append( t[iii] );
385 t = mData->custom;
386 t.sort();
387 for ( iii = 0; iii < t.count(); ++iii)
388 l.append( t[iii] );
389 KABC::Address::List::Iterator addressIter;
390 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
391 ++addressIter ) {
392 t = (*addressIter).asList();
393 t.sort();
394 for ( iii = 0; iii < t.count(); ++iii)
395 l.append( t[iii] );
396 }
397
398#endif
399
313 // pending: 400 // pending:
314 // merging phonenumbers
315 // merging addresses 401 // merging addresses
316 // merging emails;
317 // merging categories;
318 // merging custom;
319 // merging keys 402 // merging keys
320 //qDebug("merge contact %s ", ad.uid().latin1()); 403 //qDebug("merge contact %s ", ad.uid().latin1());
321 setUid( ad.uid() ); 404 setUid( ad.uid() );
322 setRevision( ad.revision() ); 405 setRevision( ad.revision() );
323} 406}
324 407
325bool Addressee::removeVoice() 408bool Addressee::removeVoice()
326{ 409{
327 PhoneNumber::List phoneN = phoneNumbers(); 410 PhoneNumber::List phoneN = phoneNumbers();
328 PhoneNumber::List::Iterator phoneIt; 411 PhoneNumber::List::Iterator phoneIt;
329 bool found = false; 412 bool found = false;
330 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 413 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
331 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 414 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
332 if ((*phoneIt).type() - PhoneNumber::Voice ) { 415 if ((*phoneIt).type() - PhoneNumber::Voice ) {
333 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 416 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
334 insertPhoneNumber( (*phoneIt) ); 417 insertPhoneNumber( (*phoneIt) );
335 found = true; 418 found = true;
336 } 419 }
337 } 420 }
338 421
339 } 422 }
340 return found; 423 return found;
341} 424}
342 425
343bool Addressee::containsAdr(const Addressee& ad ) 426bool Addressee::containsAdr(const Addressee& ad )
344{ 427{
345 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 428 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
346 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 429 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
347 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 430 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
348 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 431 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
349 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 432 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
350 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 433 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
351 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 434 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
352 435
353 // compare phone numbers 436 // compare phone numbers
354 PhoneNumber::List phoneN = ad.phoneNumbers(); 437 PhoneNumber::List phoneN = ad.phoneNumbers();
355 PhoneNumber::List::Iterator phoneIt; 438 PhoneNumber::List::Iterator phoneIt;
356 bool found = false; 439 bool found = false;
357 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 440 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
358 bool found = false; 441 bool found = false;
359 PhoneNumber::List phoneL = ad.phoneNumbers(); 442 PhoneNumber::List phoneL = ad.phoneNumbers();
360 PhoneNumber::List::Iterator phoneItL; 443 PhoneNumber::List::Iterator phoneItL;
361 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 444 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
362 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 445 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
363 found = true; 446 found = true;
364 break; 447 break;
365 } 448 }
366 } 449 }
367 if ( ! found ) 450 if ( ! found )
368 return false; 451 return false;
369 } 452 }
370 return true; 453 return true;
371 454
372} 455}
373void Addressee::simplifyAddresses() 456void Addressee::simplifyAddresses()
374{ 457{
375 int max = 2; 458 int max = 2;
376 if ( mData->url.isValid() ) 459 if ( mData->url.isValid() )
377 max = 1; 460 max = 1;
378 if ( mData->addresses.count() <= max ) return ; 461 if ( mData->addresses.count() <= max ) return ;
379 int count = 0; 462 int count = 0;
380 Address::List list; 463 Address::List list;
381 Address::List::Iterator it; 464 Address::List::Iterator it;
382 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 465 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
383 if ( count >= max ) 466 if ( count >= max )
384 list.append( *it ); 467 list.append( *it );
385 ++count; 468 ++count;
386 } 469 }
387 for( it = list.begin(); it != list.end(); ++it ) { 470 for( it = list.begin(); it != list.end(); ++it ) {
388 removeAddress( (*it) ); 471 removeAddress( (*it) );
389 } 472 }
390} 473}
391 474
392// removes all emails but the first 475// removes all emails but the first
393// needed by phone sync 476// needed by phone sync
394void Addressee::simplifyEmails() 477void Addressee::simplifyEmails()
395{ 478{
396 if ( mData->emails.count() == 0 ) return ; 479 if ( mData->emails.count() == 0 ) return ;
397 QString email = mData->emails.first(); 480 QString email = mData->emails.first();
398 detach(); 481 detach();
399 mData->emails.clear(); 482 mData->emails.clear();
400 mData->emails.append( email ); 483 mData->emails.append( email );
401} 484}
402 485
403void Addressee::simplifyPhoneNumbers() 486void Addressee::simplifyPhoneNumbers()
404{ 487{
405 KABC::PhoneNumber::List removeNumbers; 488 KABC::PhoneNumber::List removeNumbers;
406 KABC::PhoneNumber::List::Iterator phoneIter; 489 KABC::PhoneNumber::List::Iterator phoneIter;
407 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 490 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
408 ++phoneIter ) { 491 ++phoneIter ) {
409 if ( ! ( *phoneIter ).simplifyNumber() ) 492 if ( ! ( *phoneIter ).simplifyNumber() )
410 removeNumbers.append( ( *phoneIter ) ); 493 removeNumbers.append( ( *phoneIter ) );
411 } 494 }
412 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 495 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
413 ++phoneIter ) { 496 ++phoneIter ) {
414 removePhoneNumber(( *phoneIter )); 497 removePhoneNumber(( *phoneIter ));
415 } 498 }
416} 499}
417void Addressee::simplifyPhoneNumberTypes() 500void Addressee::simplifyPhoneNumberTypes()
418{ 501{
419 KABC::PhoneNumber::List::Iterator phoneIter; 502 KABC::PhoneNumber::List::Iterator phoneIter;
420 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 503 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
421 ++phoneIter ) 504 ++phoneIter )
422 ( *phoneIter ).simplifyType(); 505 ( *phoneIter ).simplifyType();
423} 506}
424void Addressee::removeID(const QString &prof) 507void Addressee::removeID(const QString &prof)
425{ 508{
426 detach(); 509 detach();
427 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 510 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
428 511
429} 512}
430void Addressee::setID( const QString & prof , const QString & id ) 513void Addressee::setID( const QString & prof , const QString & id )
431{ 514{
432 detach(); 515 detach();
433 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 516 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
434 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 517 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
435} 518}
436void Addressee::setTempSyncStat( int id ) 519void Addressee::setTempSyncStat( int id )
437{ 520{
438 if ( mData->mTempSyncStat == id ) return; 521 if ( mData->mTempSyncStat == id ) return;
439 detach(); 522 detach();
440 mData->mTempSyncStat = id; 523 mData->mTempSyncStat = id;
441} 524}
442int Addressee::tempSyncStat() const 525int Addressee::tempSyncStat() const
443{ 526{
444 return mData->mTempSyncStat; 527 return mData->mTempSyncStat;
445} 528}
446 529
447QString Addressee::getID( const QString & prof) 530QString Addressee::getID( const QString & prof)
448{ 531{
449 return KIdManager::getId ( mData->mExternalId, prof ); 532 return KIdManager::getId ( mData->mExternalId, prof );
450} 533}
451 534
452void Addressee::setCsum( const QString & prof , const QString & id ) 535void Addressee::setCsum( const QString & prof , const QString & id )
453{ 536{
454 detach(); 537 detach();
455 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 538 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
456 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 539 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
457 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 540 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
458} 541}
459 542
460QString Addressee::getCsum( const QString & prof) 543QString Addressee::getCsum( const QString & prof)
461{ 544{
462 return KIdManager::getCsum ( mData->mExternalId, prof ); 545 return KIdManager::getCsum ( mData->mExternalId, prof );
463} 546}
464 547
465void Addressee::setIDStr( const QString & s ) 548void Addressee::setIDStr( const QString & s )
466{ 549{
467 detach(); 550 detach();
468 mData->mExternalId = s; 551 mData->mExternalId = s;
469} 552}
470 553
471QString Addressee::IDStr() const 554QString Addressee::IDStr() const
472{ 555{
473 return mData->mExternalId; 556 return mData->mExternalId;
474} 557}
475 558
476void Addressee::setExternalUID( const QString &id ) 559void Addressee::setExternalUID( const QString &id )
477{ 560{
478 if ( id == mData->externalUID ) return; 561 if ( id == mData->externalUID ) return;
479 detach(); 562 detach();
480 mData->empty = false; 563 mData->empty = false;
481 mData->externalUID = id; 564 mData->externalUID = id;
482} 565}
483 566
484QString Addressee::externalUID() const 567QString Addressee::externalUID() const
485{ 568{
486 return mData->externalUID; 569 return mData->externalUID;
487} 570}
488void Addressee::setOriginalExternalUID( const QString &id ) 571void Addressee::setOriginalExternalUID( const QString &id )
489{ 572{
490 if ( id == mData->originalExternalUID ) return; 573 if ( id == mData->originalExternalUID ) return;
491 detach(); 574 detach();
492 mData->empty = false; 575 mData->empty = false;
493 //qDebug("*******Set orig uid %s ", id.latin1()); 576 //qDebug("*******Set orig uid %s ", id.latin1());
494 mData->originalExternalUID = id; 577 mData->originalExternalUID = id;
495} 578}
496 579
497QString Addressee::originalExternalUID() const 580QString Addressee::originalExternalUID() const
498{ 581{
499 return mData->originalExternalUID; 582 return mData->originalExternalUID;
500} 583}
501 584
502void Addressee::setUid( const QString &id ) 585void Addressee::setUid( const QString &id )
503{ 586{
504 if ( id == mData->uid ) return; 587 if ( id == mData->uid ) return;
505 detach(); 588 detach();
506 //qDebug("****setuid %s ", id.latin1()); 589 //qDebug("****setuid %s ", id.latin1());
507 mData->empty = false; 590 mData->empty = false;
508 mData->uid = id; 591 mData->uid = id;
509} 592}
510 593
511QString Addressee::uid() const 594QString Addressee::uid() const
512{ 595{
513 if ( mData->uid.isEmpty() ) 596 if ( mData->uid.isEmpty() )
514 mData->uid = KApplication::randomString( 10 ); 597 mData->uid = KApplication::randomString( 10 );
515 598
516 return mData->uid; 599 return mData->uid;
517} 600}
518 601
519QString Addressee::uidLabel() 602QString Addressee::uidLabel()
520{ 603{
521 return i18n("Unique Identifier"); 604 return i18n("Unique Identifier");
522} 605}
523 606
524void Addressee::setName( const QString &name ) 607void Addressee::setName( const QString &name )
525{ 608{
526 if ( name == mData->name ) return; 609 if ( name == mData->name ) return;
527 detach(); 610 detach();
528 mData->empty = false; 611 mData->empty = false;
529 mData->name = name; 612 mData->name = name;
530} 613}
531 614
532QString Addressee::name() const 615QString Addressee::name() const
533{ 616{
534 return mData->name; 617 return mData->name;
535} 618}
536 619
537QString Addressee::nameLabel() 620QString Addressee::nameLabel()
538{ 621{
539 return i18n("Name"); 622 return i18n("Name");
540} 623}
541 624
542 625
543void Addressee::setFormattedName( const QString &formattedName ) 626void Addressee::setFormattedName( const QString &formattedName )
544{ 627{
545 if ( formattedName == mData->formattedName ) return; 628 if ( formattedName == mData->formattedName ) return;
546 detach(); 629 detach();
547 mData->empty = false; 630 mData->empty = false;
548 mData->formattedName = formattedName; 631 mData->formattedName = formattedName;
549} 632}
550 633
551QString Addressee::formattedName() const 634QString Addressee::formattedName() const
552{ 635{
553 return mData->formattedName; 636 return mData->formattedName;
554} 637}
555 638
556QString Addressee::formattedNameLabel() 639QString Addressee::formattedNameLabel()
557{ 640{
558 return i18n("Formatted Name"); 641 return i18n("Formatted Name");
559} 642}
560 643
561 644
562void Addressee::setFamilyName( const QString &familyName ) 645void Addressee::setFamilyName( const QString &familyName )
563{ 646{
564 if ( familyName == mData->familyName ) return; 647 if ( familyName == mData->familyName ) return;
565 detach(); 648 detach();
566 mData->empty = false; 649 mData->empty = false;
567 mData->familyName = familyName; 650 mData->familyName = familyName;
568} 651}
569 652
570QString Addressee::familyName() const 653QString Addressee::familyName() const
571{ 654{
572 return mData->familyName; 655 return mData->familyName;
573} 656}
574 657
575QString Addressee::familyNameLabel() 658QString Addressee::familyNameLabel()
576{ 659{
577 return i18n("Family Name"); 660 return i18n("Family Name");
578} 661}
579 662
580 663
581void Addressee::setGivenName( const QString &givenName ) 664void Addressee::setGivenName( const QString &givenName )
582{ 665{
583 if ( givenName == mData->givenName ) return; 666 if ( givenName == mData->givenName ) return;
584 detach(); 667 detach();
585 mData->empty = false; 668 mData->empty = false;
586 mData->givenName = givenName; 669 mData->givenName = givenName;
587} 670}
588 671
589QString Addressee::givenName() const 672QString Addressee::givenName() const
590{ 673{
591 return mData->givenName; 674 return mData->givenName;
592} 675}
593 676
594QString Addressee::givenNameLabel() 677QString Addressee::givenNameLabel()
595{ 678{
596 return i18n("Given Name"); 679 return i18n("Given Name");
597} 680}
598 681
599 682
600void Addressee::setAdditionalName( const QString &additionalName ) 683void Addressee::setAdditionalName( const QString &additionalName )
601{ 684{
602 if ( additionalName == mData->additionalName ) return; 685 if ( additionalName == mData->additionalName ) return;
603 detach(); 686 detach();
604 mData->empty = false; 687 mData->empty = false;
605 mData->additionalName = additionalName; 688 mData->additionalName = additionalName;
606} 689}
607 690
608QString Addressee::additionalName() const 691QString Addressee::additionalName() const
609{ 692{
610 return mData->additionalName; 693 return mData->additionalName;
611} 694}
612 695
613QString Addressee::additionalNameLabel() 696QString Addressee::additionalNameLabel()
614{ 697{
615 return i18n("Additional Names"); 698 return i18n("Additional Names");
616} 699}
617 700
618 701
619void Addressee::setPrefix( const QString &prefix ) 702void Addressee::setPrefix( const QString &prefix )
620{ 703{
621 if ( prefix == mData->prefix ) return; 704 if ( prefix == mData->prefix ) return;
622 detach(); 705 detach();
623 mData->empty = false; 706 mData->empty = false;
624 mData->prefix = prefix; 707 mData->prefix = prefix;
625} 708}
626 709
627QString Addressee::prefix() const 710QString Addressee::prefix() const
628{ 711{
629 return mData->prefix; 712 return mData->prefix;
630} 713}
631 714
632QString Addressee::prefixLabel() 715QString Addressee::prefixLabel()
633{ 716{
634 return i18n("Honorific Prefixes"); 717 return i18n("Honorific Prefixes");
635} 718}
636 719
637 720
638void Addressee::setSuffix( const QString &suffix ) 721void Addressee::setSuffix( const QString &suffix )
639{ 722{
640 if ( suffix == mData->suffix ) return; 723 if ( suffix == mData->suffix ) return;
641 detach(); 724 detach();
642 mData->empty = false; 725 mData->empty = false;
643 mData->suffix = suffix; 726 mData->suffix = suffix;
644} 727}
645 728
646QString Addressee::suffix() const 729QString Addressee::suffix() const
647{ 730{
648 return mData->suffix; 731 return mData->suffix;
649} 732}
650 733
651QString Addressee::suffixLabel() 734QString Addressee::suffixLabel()
652{ 735{
653 return i18n("Honorific Suffixes"); 736 return i18n("Honorific Suffixes");
654} 737}
655 738
656 739
657void Addressee::setNickName( const QString &nickName ) 740void Addressee::setNickName( const QString &nickName )
658{ 741{
659 if ( nickName == mData->nickName ) return; 742 if ( nickName == mData->nickName ) return;
660 detach(); 743 detach();
661 mData->empty = false; 744 mData->empty = false;
662 mData->nickName = nickName; 745 mData->nickName = nickName;
663} 746}
664 747
665QString Addressee::nickName() const 748QString Addressee::nickName() const
666{ 749{
667 return mData->nickName; 750 return mData->nickName;
668} 751}
669 752
670QString Addressee::nickNameLabel() 753QString Addressee::nickNameLabel()
671{ 754{
672 return i18n("Nick Name"); 755 return i18n("Nick Name");
673} 756}
674 757
675 758
676void Addressee::setBirthday( const QDateTime &birthday ) 759void Addressee::setBirthday( const QDateTime &birthday )
677{ 760{
678 if ( birthday == mData->birthday ) return; 761 if ( birthday == mData->birthday ) return;
679 detach(); 762 detach();
680 mData->empty = false; 763 mData->empty = false;
681 mData->birthday = birthday; 764 mData->birthday = birthday;
682} 765}
683 766
684QDateTime Addressee::birthday() const 767QDateTime Addressee::birthday() const
685{ 768{
686 return mData->birthday; 769 return mData->birthday;
687} 770}
688 771
689QString Addressee::birthdayLabel() 772QString Addressee::birthdayLabel()
690{ 773{
691 return i18n("Birthday"); 774 return i18n("Birthday");
692} 775}
693 776
694 777
695QString Addressee::homeAddressStreetLabel() 778QString Addressee::homeAddressStreetLabel()
696{ 779{
697 return i18n("Home Address Street"); 780 return i18n("Home Address Street");
698} 781}
699 782
700 783
701QString Addressee::homeAddressLocalityLabel() 784QString Addressee::homeAddressLocalityLabel()
702{ 785{
703 return i18n("Home Address Locality"); 786 return i18n("Home Address Locality");
704} 787}
705 788
706 789
707QString Addressee::homeAddressRegionLabel() 790QString Addressee::homeAddressRegionLabel()
708{ 791{
709 return i18n("Home Address Region"); 792 return i18n("Home Address Region");
710} 793}
711 794
712 795
713QString Addressee::homeAddressPostalCodeLabel() 796QString Addressee::homeAddressPostalCodeLabel()
714{ 797{
715 return i18n("Home Address Postal Code"); 798 return i18n("Home Address Postal Code");
716} 799}
717 800
718 801
719QString Addressee::homeAddressCountryLabel() 802QString Addressee::homeAddressCountryLabel()
720{ 803{
721 return i18n("Home Address Country"); 804 return i18n("Home Address Country");
722} 805}
723 806
724 807
725QString Addressee::homeAddressLabelLabel() 808QString Addressee::homeAddressLabelLabel()
726{ 809{
727 return i18n("Home Address Label"); 810 return i18n("Home Address Label");
728} 811}
729 812
730 813
731QString Addressee::businessAddressStreetLabel() 814QString Addressee::businessAddressStreetLabel()
732{ 815{
733 return i18n("Business Address Street"); 816 return i18n("Business Address Street");
734} 817}
735 818
736 819
737QString Addressee::businessAddressLocalityLabel() 820QString Addressee::businessAddressLocalityLabel()
738{ 821{
739 return i18n("Business Address Locality"); 822 return i18n("Business Address Locality");
740} 823}
741 824
742 825
743QString Addressee::businessAddressRegionLabel() 826QString Addressee::businessAddressRegionLabel()
744{ 827{
745 return i18n("Business Address Region"); 828 return i18n("Business Address Region");
746} 829}
747 830
748 831
749QString Addressee::businessAddressPostalCodeLabel() 832QString Addressee::businessAddressPostalCodeLabel()
750{ 833{
751 return i18n("Business Address Postal Code"); 834 return i18n("Business Address Postal Code");
752} 835}
753 836
754 837
755QString Addressee::businessAddressCountryLabel() 838QString Addressee::businessAddressCountryLabel()
756{ 839{
757 return i18n("Business Address Country"); 840 return i18n("Business Address Country");
758} 841}
759 842
760 843
761QString Addressee::businessAddressLabelLabel() 844QString Addressee::businessAddressLabelLabel()
762{ 845{
763 return i18n("Business Address Label"); 846 return i18n("Business Address Label");
764} 847}
765 848
766 849
767QString Addressee::homePhoneLabel() 850QString Addressee::homePhoneLabel()
768{ 851{
769 return i18n("Home Phone"); 852 return i18n("Home Phone");
770} 853}
771 854
772 855
773QString Addressee::businessPhoneLabel() 856QString Addressee::businessPhoneLabel()
774{ 857{
775 return i18n("Business Phone"); 858 return i18n("Business Phone");
776} 859}
777 860
778 861
779QString Addressee::mobilePhoneLabel() 862QString Addressee::mobilePhoneLabel()
780{ 863{
781 return i18n("Mobile Phone"); 864 return i18n("Mobile Phone");
782} 865}
783 866
784 867
785QString Addressee::homeFaxLabel() 868QString Addressee::homeFaxLabel()
786{ 869{
787 return i18n("Home Fax"); 870 return i18n("Home Fax");
788} 871}
789 872
790 873
791QString Addressee::businessFaxLabel() 874QString Addressee::businessFaxLabel()
792{ 875{
793 return i18n("Business Fax"); 876 return i18n("Business Fax");
794} 877}
795 878
796 879
797QString Addressee::carPhoneLabel() 880QString Addressee::carPhoneLabel()
798{ 881{
799 return i18n("Car Phone"); 882 return i18n("Car Phone");
800} 883}
801 884
802 885
803QString Addressee::isdnLabel() 886QString Addressee::isdnLabel()
804{ 887{
805 return i18n("ISDN"); 888 return i18n("ISDN");
806} 889}
807 890
808 891
809QString Addressee::pagerLabel() 892QString Addressee::pagerLabel()
810{ 893{
811 return i18n("Pager"); 894 return i18n("Pager");
812} 895}
813 896
814QString Addressee::sipLabel() 897QString Addressee::sipLabel()
815{ 898{
816 return i18n("SIP"); 899 return i18n("SIP");
817} 900}
818 901
819QString Addressee::emailLabel() 902QString Addressee::emailLabel()
820{ 903{
821 return i18n("Email Address"); 904 return i18n("Email Address");
822} 905}
823 906
824 907
825void Addressee::setMailer( const QString &mailer ) 908void Addressee::setMailer( const QString &mailer )
826{ 909{
827 if ( mailer == mData->mailer ) return; 910 if ( mailer == mData->mailer ) return;
828 detach(); 911 detach();
829 mData->empty = false; 912 mData->empty = false;
830 mData->mailer = mailer; 913 mData->mailer = mailer;
831} 914}
832 915
833QString Addressee::mailer() const 916QString Addressee::mailer() const
834{ 917{
835 return mData->mailer; 918 return mData->mailer;
836} 919}
837 920
838QString Addressee::mailerLabel() 921QString Addressee::mailerLabel()
839{ 922{
840 return i18n("Mail Client"); 923 return i18n("Mail Client");
841} 924}
842 925
843 926
844void Addressee::setTimeZone( const TimeZone &timeZone ) 927void Addressee::setTimeZone( const TimeZone &timeZone )
845{ 928{
846 if ( timeZone == mData->timeZone ) return; 929 if ( timeZone == mData->timeZone ) return;
847 detach(); 930 detach();
848 mData->empty = false; 931 mData->empty = false;
849 mData->timeZone = timeZone; 932 mData->timeZone = timeZone;
850} 933}
851 934
852TimeZone Addressee::timeZone() const 935TimeZone Addressee::timeZone() const
853{ 936{
854 return mData->timeZone; 937 return mData->timeZone;
855} 938}
856 939
857QString Addressee::timeZoneLabel() 940QString Addressee::timeZoneLabel()
858{ 941{
859 return i18n("Time Zone"); 942 return i18n("Time Zone");
860} 943}
861 944
862 945
863void Addressee::setGeo( const Geo &geo ) 946void Addressee::setGeo( const Geo &geo )
864{ 947{
865 if ( geo == mData->geo ) return; 948 if ( geo == mData->geo ) return;
866 detach(); 949 detach();
867 mData->empty = false; 950 mData->empty = false;
868 mData->geo = geo; 951 mData->geo = geo;
869} 952}
870 953
871Geo Addressee::geo() const 954Geo Addressee::geo() const
872{ 955{
873 return mData->geo; 956 return mData->geo;
874} 957}
875 958
876QString Addressee::geoLabel() 959QString Addressee::geoLabel()
877{ 960{
878 return i18n("Geographic Position"); 961 return i18n("Geographic Position");
879} 962}
880 963
881 964
882void Addressee::setTitle( const QString &title ) 965void Addressee::setTitle( const QString &title )
883{ 966{
884 if ( title == mData->title ) return; 967 if ( title == mData->title ) return;
885 detach(); 968 detach();
886 mData->empty = false; 969 mData->empty = false;
887 mData->title = title; 970 mData->title = title;
888} 971}
889 972
890QString Addressee::title() const 973QString Addressee::title() const
891{ 974{
892 return mData->title; 975 return mData->title;
893} 976}
894 977
895QString Addressee::titleLabel() 978QString Addressee::titleLabel()
896{ 979{
897 return i18n("Title"); 980 return i18n("Title");
898} 981}
899 982
900 983
901void Addressee::setRole( const QString &role ) 984void Addressee::setRole( const QString &role )
902{ 985{
903 if ( role == mData->role ) return; 986 if ( role == mData->role ) return;
904 detach(); 987 detach();
905 mData->empty = false; 988 mData->empty = false;
906 mData->role = role; 989 mData->role = role;
907} 990}
908 991
909QString Addressee::role() const 992QString Addressee::role() const
910{ 993{
911 return mData->role; 994 return mData->role;
912} 995}
913 996
914QString Addressee::roleLabel() 997QString Addressee::roleLabel()
915{ 998{
916 return i18n("Role"); 999 return i18n("Role");
917} 1000}
918 1001
919 1002
920void Addressee::setOrganization( const QString &organization ) 1003void Addressee::setOrganization( const QString &organization )
921{ 1004{
922 if ( organization == mData->organization ) return; 1005 if ( organization == mData->organization ) return;
923 detach(); 1006 detach();
924 mData->empty = false; 1007 mData->empty = false;
925 mData->organization = organization; 1008 mData->organization = organization;
926} 1009}
927 1010
928QString Addressee::organization() const 1011QString Addressee::organization() const
929{ 1012{
930 return mData->organization; 1013 return mData->organization;
931} 1014}
932 1015
933QString Addressee::organizationLabel() 1016QString Addressee::organizationLabel()
934{ 1017{
935 return i18n("Organization"); 1018 return i18n("Organization");
936} 1019}
937 1020
938 1021
939void Addressee::setNote( const QString &note ) 1022void Addressee::setNote( const QString &note )
940{ 1023{
941 if ( note == mData->note ) return; 1024 if ( note == mData->note ) return;
942 detach(); 1025 detach();
943 mData->empty = false; 1026 mData->empty = false;
944 mData->note = note; 1027 mData->note = note;
945} 1028}
946 1029
947QString Addressee::note() const 1030QString Addressee::note() const
948{ 1031{
949 return mData->note; 1032 return mData->note;
950} 1033}
951 1034
952QString Addressee::noteLabel() 1035QString Addressee::noteLabel()
953{ 1036{
954 return i18n("Note"); 1037 return i18n("Note");
955} 1038}
956 1039
957 1040
958void Addressee::setProductId( const QString &productId ) 1041void Addressee::setProductId( const QString &productId )
959{ 1042{
960 if ( productId == mData->productId ) return; 1043 if ( productId == mData->productId ) return;
961 detach(); 1044 detach();
962 mData->empty = false; 1045 mData->empty = false;
963 mData->productId = productId; 1046 mData->productId = productId;
964} 1047}
965 1048
966QString Addressee::productId() const 1049QString Addressee::productId() const
967{ 1050{
968 return mData->productId; 1051 return mData->productId;
969} 1052}
970 1053
971QString Addressee::productIdLabel() 1054QString Addressee::productIdLabel()
972{ 1055{
973 return i18n("Product Identifier"); 1056 return i18n("Product Identifier");
974} 1057}
975 1058
976 1059
977void Addressee::setRevision( const QDateTime &revision ) 1060void Addressee::setRevision( const QDateTime &revision )
978{ 1061{
979 if ( revision == mData->revision ) return; 1062 if ( revision == mData->revision ) return;
980 detach(); 1063 detach();
981 mData->empty = false; 1064 mData->empty = false;
982 mData->revision = revision; 1065 mData->revision = revision;
983} 1066}
984 1067
985QDateTime Addressee::revision() const 1068QDateTime Addressee::revision() const
986{ 1069{
987 return mData->revision; 1070 return mData->revision;
988} 1071}
989 1072
990QString Addressee::revisionLabel() 1073QString Addressee::revisionLabel()
991{ 1074{
992 return i18n("Revision Date"); 1075 return i18n("Revision Date");
993} 1076}
994 1077
995 1078
996void Addressee::setSortString( const QString &sortString ) 1079void Addressee::setSortString( const QString &sortString )
997{ 1080{
998 if ( sortString == mData->sortString ) return; 1081 if ( sortString == mData->sortString ) return;
999 detach(); 1082 detach();
1000 mData->empty = false; 1083 mData->empty = false;
1001 mData->sortString = sortString; 1084 mData->sortString = sortString;
1002} 1085}
1003 1086
1004QString Addressee::sortString() const 1087QString Addressee::sortString() const
1005{ 1088{
1006 return mData->sortString; 1089 return mData->sortString;
1007} 1090}
1008 1091
1009QString Addressee::sortStringLabel() 1092QString Addressee::sortStringLabel()
1010{ 1093{
1011 return i18n("Sort String"); 1094 return i18n("Sort String");
1012} 1095}
1013 1096
1014 1097
1015void Addressee::setUrl( const KURL &url ) 1098void Addressee::setUrl( const KURL &url )
1016{ 1099{
1017 if ( url == mData->url ) return; 1100 if ( url == mData->url ) return;
1018 detach(); 1101 detach();
1019 mData->empty = false; 1102 mData->empty = false;
1020 mData->url = url; 1103 mData->url = url;
1021} 1104}
1022 1105
1023KURL Addressee::url() const 1106KURL Addressee::url() const
1024{ 1107{
1025 return mData->url; 1108 return mData->url;
1026} 1109}
1027 1110
1028QString Addressee::urlLabel() 1111QString Addressee::urlLabel()
1029{ 1112{
1030 return i18n("URL"); 1113 return i18n("URL");
1031} 1114}
1032 1115
1033 1116
1034void Addressee::setSecrecy( const Secrecy &secrecy ) 1117void Addressee::setSecrecy( const Secrecy &secrecy )
1035{ 1118{
1036 if ( secrecy == mData->secrecy ) return; 1119 if ( secrecy == mData->secrecy ) return;
1037 detach(); 1120 detach();
1038 mData->empty = false; 1121 mData->empty = false;
1039 mData->secrecy = secrecy; 1122 mData->secrecy = secrecy;
1040} 1123}
1041 1124
1042Secrecy Addressee::secrecy() const 1125Secrecy Addressee::secrecy() const
1043{ 1126{
1044 return mData->secrecy; 1127 return mData->secrecy;
1045} 1128}
1046 1129
1047QString Addressee::secrecyLabel() 1130QString Addressee::secrecyLabel()
1048{ 1131{
1049 return i18n("Security Class"); 1132 return i18n("Security Class");
1050} 1133}
1051 1134
1052 1135
1053void Addressee::setLogo( const Picture &logo ) 1136void Addressee::setLogo( const Picture &logo )
1054{ 1137{
1055 if ( logo == mData->logo ) return; 1138 if ( logo == mData->logo ) return;
1056 detach(); 1139 detach();
1057 mData->empty = false; 1140 mData->empty = false;
1058 mData->logo = logo; 1141 mData->logo = logo;
1059} 1142}
1060 1143
1061Picture Addressee::logo() const 1144Picture Addressee::logo() const
1062{ 1145{
1063 return mData->logo; 1146 return mData->logo;
1064} 1147}
1065 1148
1066QString Addressee::logoLabel() 1149QString Addressee::logoLabel()
1067{ 1150{
1068 return i18n("Logo"); 1151 return i18n("Logo");
1069} 1152}
1070 1153
1071 1154
1072void Addressee::setPhoto( const Picture &photo ) 1155void Addressee::setPhoto( const Picture &photo )
1073{ 1156{
1074 if ( photo == mData->photo ) return; 1157 if ( photo == mData->photo ) return;
1075 detach(); 1158 detach();
1076 mData->empty = false; 1159 mData->empty = false;
1077 mData->photo = photo; 1160 mData->photo = photo;
1078} 1161}
1079 1162
1080Picture Addressee::photo() const 1163Picture Addressee::photo() const
1081{ 1164{
1082 return mData->photo; 1165 return mData->photo;
1083} 1166}
1084 1167
1085QString Addressee::photoLabel() 1168QString Addressee::photoLabel()
1086{ 1169{
1087 return i18n("Photo"); 1170 return i18n("Photo");
1088} 1171}
1089 1172
1090 1173
1091void Addressee::setSound( const Sound &sound ) 1174void Addressee::setSound( const Sound &sound )
1092{ 1175{
1093 if ( sound == mData->sound ) return; 1176 if ( sound == mData->sound ) return;
1094 detach(); 1177 detach();
1095 mData->empty = false; 1178 mData->empty = false;
1096 mData->sound = sound; 1179 mData->sound = sound;
1097} 1180}
1098 1181
1099Sound Addressee::sound() const 1182Sound Addressee::sound() const
1100{ 1183{
1101 return mData->sound; 1184 return mData->sound;
1102} 1185}
1103 1186
1104QString Addressee::soundLabel() 1187QString Addressee::soundLabel()
1105{ 1188{
1106 return i18n("Sound"); 1189 return i18n("Sound");
1107} 1190}
1108 1191
1109 1192
1110void Addressee::setAgent( const Agent &agent ) 1193void Addressee::setAgent( const Agent &agent )
1111{ 1194{
1112 if ( agent == mData->agent ) return; 1195 if ( agent == mData->agent ) return;
1113 detach(); 1196 detach();
1114 mData->empty = false; 1197 mData->empty = false;
1115 mData->agent = agent; 1198 mData->agent = agent;
1116} 1199}
1117 1200
1118Agent Addressee::agent() const 1201Agent Addressee::agent() const
1119{ 1202{
1120 return mData->agent; 1203 return mData->agent;
1121} 1204}
1122 1205
1123QString Addressee::agentLabel() 1206QString Addressee::agentLabel()
1124{ 1207{
1125 return i18n("Agent"); 1208 return i18n("Agent");
1126} 1209}
1127 1210
1128 1211
1129 1212
1130void Addressee::setNameFromString( const QString &str ) 1213void Addressee::setNameFromString( const QString &str )
1131{ 1214{
1132 setFormattedName( str ); 1215 setFormattedName( str );
1133 setName( str ); 1216 setName( str );
1134 1217
1135 static bool first = true; 1218 static bool first = true;
1136 static QStringList titles; 1219 static QStringList titles;
1137 static QStringList suffixes; 1220 static QStringList suffixes;
1138 static QStringList prefixes; 1221 static QStringList prefixes;
1139 1222
1140 if ( first ) { 1223 if ( first ) {
1141 first = false; 1224 first = false;
1142 titles += i18n( "Dr." ); 1225 titles += i18n( "Dr." );
1143 titles += i18n( "Miss" ); 1226 titles += i18n( "Miss" );
1144 titles += i18n( "Mr." ); 1227 titles += i18n( "Mr." );
1145 titles += i18n( "Mrs." ); 1228 titles += i18n( "Mrs." );
1146 titles += i18n( "Ms." ); 1229 titles += i18n( "Ms." );
1147 titles += i18n( "Prof." ); 1230 titles += i18n( "Prof." );
1148 1231
1149 suffixes += i18n( "I" ); 1232 suffixes += i18n( "I" );
1150 suffixes += i18n( "II" ); 1233 suffixes += i18n( "II" );
1151 suffixes += i18n( "III" ); 1234 suffixes += i18n( "III" );
1152 suffixes += i18n( "Jr." ); 1235 suffixes += i18n( "Jr." );
1153 suffixes += i18n( "Sr." ); 1236 suffixes += i18n( "Sr." );
1154 1237
1155 prefixes += "van"; 1238 prefixes += "van";
1156 prefixes += "von"; 1239 prefixes += "von";
1157 prefixes += "de"; 1240 prefixes += "de";
1158 1241
1159 KConfig config( locateLocal( "config", "kabcrc") ); 1242 KConfig config( locateLocal( "config", "kabcrc") );
1160 config.setGroup( "General" ); 1243 config.setGroup( "General" );
1161 titles += config.readListEntry( "Prefixes" ); 1244 titles += config.readListEntry( "Prefixes" );
1162 titles.remove( "" ); 1245 titles.remove( "" );
1163 prefixes += config.readListEntry( "Inclusions" ); 1246 prefixes += config.readListEntry( "Inclusions" );
1164 prefixes.remove( "" ); 1247 prefixes.remove( "" );
1165 suffixes += config.readListEntry( "Suffixes" ); 1248 suffixes += config.readListEntry( "Suffixes" );
1166 suffixes.remove( "" ); 1249 suffixes.remove( "" );
1167 } 1250 }
1168 1251
1169 // clear all name parts 1252 // clear all name parts
1170 setPrefix( "" ); 1253 setPrefix( "" );
1171 setGivenName( "" ); 1254 setGivenName( "" );
1172 setAdditionalName( "" ); 1255 setAdditionalName( "" );
1173 setFamilyName( "" ); 1256 setFamilyName( "" );
1174 setSuffix( "" ); 1257 setSuffix( "" );
1175 1258
1176 if ( str.isEmpty() ) 1259 if ( str.isEmpty() )
1177 return; 1260 return;
1178 1261
1179 int i = str.find(','); 1262 int i = str.find(',');
1180 if( i < 0 ) { 1263 if( i < 0 ) {
1181 QStringList parts = QStringList::split( " ", str ); 1264 QStringList parts = QStringList::split( " ", str );
1182 int leftOffset = 0; 1265 int leftOffset = 0;
1183 int rightOffset = parts.count() - 1; 1266 int rightOffset = parts.count() - 1;
1184 1267
1185 QString suffix; 1268 QString suffix;
1186 while ( rightOffset >= 0 ) { 1269 while ( rightOffset >= 0 ) {
1187 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1270 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1188 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1271 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1189 rightOffset--; 1272 rightOffset--;
1190 } else 1273 } else
1191 break; 1274 break;
1192 } 1275 }
1193 setSuffix( suffix ); 1276 setSuffix( suffix );
1194 1277
1195 if ( rightOffset < 0 ) 1278 if ( rightOffset < 0 )
1196 return; 1279 return;
1197 1280
1198 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1281 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1199 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1282 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1200 rightOffset--; 1283 rightOffset--;
1201 } else 1284 } else
1202 setFamilyName( parts[ rightOffset ] ); 1285 setFamilyName( parts[ rightOffset ] );
1203 1286
1204 QString prefix; 1287 QString prefix;
1205 while ( leftOffset < rightOffset ) { 1288 while ( leftOffset < rightOffset ) {
1206 if ( titles.contains( parts[ leftOffset ] ) ) { 1289 if ( titles.contains( parts[ leftOffset ] ) ) {
1207 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1290 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1208 leftOffset++; 1291 leftOffset++;
1209 } else 1292 } else
1210 break; 1293 break;
1211 } 1294 }
1212 setPrefix( prefix ); 1295 setPrefix( prefix );
1213 1296
1214 if ( leftOffset < rightOffset ) { 1297 if ( leftOffset < rightOffset ) {
1215 setGivenName( parts[ leftOffset ] ); 1298 setGivenName( parts[ leftOffset ] );
1216 leftOffset++; 1299 leftOffset++;
1217 } 1300 }
1218 1301
1219 QString additionalName; 1302 QString additionalName;
1220 while ( leftOffset < rightOffset ) { 1303 while ( leftOffset < rightOffset ) {
1221 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1304 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1222 leftOffset++; 1305 leftOffset++;
1223 } 1306 }
1224 setAdditionalName( additionalName ); 1307 setAdditionalName( additionalName );
1225 } else { 1308 } else {
1226 QString part1 = str.left( i ); 1309 QString part1 = str.left( i );
1227 QString part2 = str.mid( i + 1 ); 1310 QString part2 = str.mid( i + 1 );
1228 1311
1229 QStringList parts = QStringList::split( " ", part1 ); 1312 QStringList parts = QStringList::split( " ", part1 );
1230 int leftOffset = 0; 1313 int leftOffset = 0;
1231 int rightOffset = parts.count() - 1; 1314 int rightOffset = parts.count() - 1;
1232 1315
1233 QString suffix; 1316 QString suffix;
1234 while ( rightOffset >= 0 ) { 1317 while ( rightOffset >= 0 ) {
1235 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1318 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1236 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1319 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1237 rightOffset--; 1320 rightOffset--;
1238 } else 1321 } else
1239 break; 1322 break;
1240 } 1323 }
1241 setSuffix( suffix ); 1324 setSuffix( suffix );
1242 1325
1243 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1326 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1244 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1327 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1245 rightOffset--; 1328 rightOffset--;
1246 } else 1329 } else
1247 setFamilyName( parts[ rightOffset ] ); 1330 setFamilyName( parts[ rightOffset ] );
1248 1331
1249 QString prefix; 1332 QString prefix;
1250 while ( leftOffset < rightOffset ) { 1333 while ( leftOffset < rightOffset ) {
1251 if ( titles.contains( parts[ leftOffset ] ) ) { 1334 if ( titles.contains( parts[ leftOffset ] ) ) {
1252 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1335 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1253 leftOffset++; 1336 leftOffset++;
1254 } else 1337 } else
1255 break; 1338 break;
1256 } 1339 }
1257 1340
1258 parts = QStringList::split( " ", part2 ); 1341 parts = QStringList::split( " ", part2 );
1259 1342
1260 leftOffset = 0; 1343 leftOffset = 0;
1261 rightOffset = parts.count(); 1344 rightOffset = parts.count();
1262 1345
1263 while ( leftOffset < rightOffset ) { 1346 while ( leftOffset < rightOffset ) {
1264 if ( titles.contains( parts[ leftOffset ] ) ) { 1347 if ( titles.contains( parts[ leftOffset ] ) ) {
1265 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1348 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1266 leftOffset++; 1349 leftOffset++;
1267 } else 1350 } else
1268 break; 1351 break;
1269 } 1352 }
1270 setPrefix( prefix ); 1353 setPrefix( prefix );
1271 1354
1272 if ( leftOffset < rightOffset ) { 1355 if ( leftOffset < rightOffset ) {
1273 setGivenName( parts[ leftOffset ] ); 1356 setGivenName( parts[ leftOffset ] );
1274 leftOffset++; 1357 leftOffset++;
1275 } 1358 }
1276 1359
1277 QString additionalName; 1360 QString additionalName;
1278 while ( leftOffset < rightOffset ) { 1361 while ( leftOffset < rightOffset ) {
1279 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1362 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1280 leftOffset++; 1363 leftOffset++;
1281 } 1364 }
1282 setAdditionalName( additionalName ); 1365 setAdditionalName( additionalName );
1283 } 1366 }
1284} 1367}
1285 1368
1286QString Addressee::realName() const 1369QString Addressee::realName() const
1287{ 1370{
1288 if ( !formattedName().isEmpty() ) 1371 if ( !formattedName().isEmpty() )
1289 return formattedName(); 1372 return formattedName();
1290 1373
1291 QString n = assembledName(); 1374 QString n = assembledName();
1292 1375
1293 if ( n.isEmpty() ) 1376 if ( n.isEmpty() )
1294 n = name(); 1377 n = name();
1295 1378
1296 return n; 1379 return n;
1297} 1380}
1298 1381
1299QString Addressee::assembledName() const 1382QString Addressee::assembledName() const
1300{ 1383{
1301 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1384 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1302 familyName() + " " + suffix(); 1385 familyName() + " " + suffix();
1303 1386
1304 return name.simplifyWhiteSpace(); 1387 return name.simplifyWhiteSpace();
1305} 1388}
1306 1389
1307QString Addressee::fullEmail( const QString &email ) const 1390QString Addressee::fullEmail( const QString &email ) const
1308{ 1391{
1309 QString e; 1392 QString e;
1310 if ( email.isNull() ) { 1393 if ( email.isNull() ) {
1311 e = preferredEmail(); 1394 e = preferredEmail();
1312 } else { 1395 } else {
1313 e = email; 1396 e = email;
1314 } 1397 }
1315 if ( e.isEmpty() ) return QString::null; 1398 if ( e.isEmpty() ) return QString::null;
1316 1399
1317 QString text; 1400 QString text;
1318 if ( realName().isEmpty() ) 1401 if ( realName().isEmpty() )
1319 text = e; 1402 text = e;
1320 else 1403 else
1321 text = assembledName() + " <" + e + ">"; 1404 text = assembledName() + " <" + e + ">";
1322 1405
1323 return text; 1406 return text;
1324} 1407}
1325 1408
1326void Addressee::insertEmail( const QString &email, bool preferred ) 1409void Addressee::insertEmail( const QString &email, bool preferred )
1327{ 1410{
1328 detach(); 1411 detach();
1329 1412
1330 QStringList::Iterator it = mData->emails.find( email ); 1413 QStringList::Iterator it = mData->emails.find( email );
1331 1414
1332 if ( it != mData->emails.end() ) { 1415 if ( it != mData->emails.end() ) {
1333 if ( !preferred || it == mData->emails.begin() ) return; 1416 if ( !preferred || it == mData->emails.begin() ) return;
1334 mData->emails.remove( it ); 1417 mData->emails.remove( it );
1335 mData->emails.prepend( email ); 1418 mData->emails.prepend( email );
1336 } else { 1419 } else {
1337 if ( preferred ) { 1420 if ( preferred ) {
1338 mData->emails.prepend( email ); 1421 mData->emails.prepend( email );
1339 } else { 1422 } else {
1340 mData->emails.append( email ); 1423 mData->emails.append( email );
1341 } 1424 }
1342 } 1425 }
1343} 1426}
1344 1427
1345void Addressee::removeEmail( const QString &email ) 1428void Addressee::removeEmail( const QString &email )
1346{ 1429{
1347 detach(); 1430 detach();
1348 1431
1349 QStringList::Iterator it = mData->emails.find( email ); 1432 QStringList::Iterator it = mData->emails.find( email );
1350 if ( it == mData->emails.end() ) return; 1433 if ( it == mData->emails.end() ) return;
1351 1434
1352 mData->emails.remove( it ); 1435 mData->emails.remove( it );
1353} 1436}
1354 1437
1355QString Addressee::preferredEmail() const 1438QString Addressee::preferredEmail() const
1356{ 1439{
1357 if ( mData->emails.count() == 0 ) return QString::null; 1440 if ( mData->emails.count() == 0 ) return QString::null;
1358 else return mData->emails.first(); 1441 else return mData->emails.first();
1359} 1442}
1360 1443
1361QStringList Addressee::emails() const 1444QStringList Addressee::emails() const
1362{ 1445{
1363 return mData->emails; 1446 return mData->emails;
1364} 1447}
1365void Addressee::setEmails( const QStringList& emails ) { 1448void Addressee::setEmails( const QStringList& emails ) {
1366 detach(); 1449 detach();
1367 mData->emails = emails; 1450 mData->emails = emails;
1368} 1451}
1369void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1452void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1370{ 1453{
1371 detach(); 1454 detach();
1372 mData->empty = false; 1455 mData->empty = false;
1373 1456
1374 PhoneNumber::List::Iterator it; 1457 PhoneNumber::List::Iterator it;
1375 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1458 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1376 if ( (*it).id() == phoneNumber.id() ) { 1459 if ( (*it).id() == phoneNumber.id() ) {
1377 *it = phoneNumber; 1460 *it = phoneNumber;
1378 return; 1461 return;
1379 } 1462 }
1380 } 1463 }
1381 mData->phoneNumbers.append( phoneNumber ); 1464 mData->phoneNumbers.append( phoneNumber );
1382} 1465}
1383 1466
1384void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1467void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1385{ 1468{
1386 detach(); 1469 detach();
1387 1470
1388 PhoneNumber::List::Iterator it; 1471 PhoneNumber::List::Iterator it;
1389 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1472 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1390 if ( (*it).id() == phoneNumber.id() ) { 1473 if ( (*it).id() == phoneNumber.id() ) {
1391 mData->phoneNumbers.remove( it ); 1474 mData->phoneNumbers.remove( it );
1392 return; 1475 return;
1393 } 1476 }
1394 } 1477 }
1395} 1478}
1396 1479
1397PhoneNumber Addressee::phoneNumber( int type ) const 1480PhoneNumber Addressee::phoneNumber( int type ) const
1398{ 1481{
1399 PhoneNumber phoneNumber( "", type ); 1482 PhoneNumber phoneNumber( "", type );
1400 PhoneNumber::List::ConstIterator it; 1483 PhoneNumber::List::ConstIterator it;
1401 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1484 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1402 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1485 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1403 if ( (*it).type() & PhoneNumber::Pref ) 1486 if ( (*it).type() & PhoneNumber::Pref )
1404 return (*it); 1487 return (*it);
1405 else if ( phoneNumber.number().isEmpty() ) 1488 else if ( phoneNumber.number().isEmpty() )
1406 phoneNumber = (*it); 1489 phoneNumber = (*it);
1407 } 1490 }
1408 } 1491 }
1409 1492
1410 return phoneNumber; 1493 return phoneNumber;
1411} 1494}
1412 1495
1413PhoneNumber::List Addressee::phoneNumbers() const 1496PhoneNumber::List Addressee::phoneNumbers() const
1414{ 1497{
1415 return mData->phoneNumbers; 1498 return mData->phoneNumbers;
1416} 1499}
1417 1500
1418PhoneNumber::List Addressee::phoneNumbers( int type ) const 1501PhoneNumber::List Addressee::phoneNumbers( int type ) const
1419{ 1502{
1420 PhoneNumber::List list; 1503 PhoneNumber::List list;
1421 1504
1422 PhoneNumber::List::ConstIterator it; 1505 PhoneNumber::List::ConstIterator it;
1423 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1506 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1424 if ( matchBinaryPattern( (*it).type(), type ) ) { 1507 if ( matchBinaryPattern( (*it).type(), type ) ) {
1425 list.append( *it ); 1508 list.append( *it );
1426 } 1509 }
1427 } 1510 }
1428 return list; 1511 return list;
1429} 1512}
1430 1513
1431PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1514PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1432{ 1515{
1433 PhoneNumber::List::ConstIterator it; 1516 PhoneNumber::List::ConstIterator it;
1434 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1517 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1435 if ( (*it).id() == id ) { 1518 if ( (*it).id() == id ) {
1436 return *it; 1519 return *it;
1437 } 1520 }
1438 } 1521 }
1439 return PhoneNumber(); 1522 return PhoneNumber();
1440} 1523}
1441 1524
1442void Addressee::insertKey( const Key &key ) 1525void Addressee::insertKey( const Key &key )
1443{ 1526{
1444 detach(); 1527 detach();
1445 mData->empty = false; 1528 mData->empty = false;
1446 1529
1447 Key::List::Iterator it; 1530 Key::List::Iterator it;
1448 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1531 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1449 if ( (*it).id() == key.id() ) { 1532 if ( (*it).id() == key.id() ) {
1450 *it = key; 1533 *it = key;
1451 return; 1534 return;
1452 } 1535 }
1453 } 1536 }
1454 mData->keys.append( key ); 1537 mData->keys.append( key );
1455} 1538}
1456 1539
1457void Addressee::removeKey( const Key &key ) 1540void Addressee::removeKey( const Key &key )
1458{ 1541{
1459 detach(); 1542 detach();
1460 1543
1461 Key::List::Iterator it; 1544 Key::List::Iterator it;
1462 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1545 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1463 if ( (*it).id() == key.id() ) { 1546 if ( (*it).id() == key.id() ) {
1464 mData->keys.remove( key ); 1547 mData->keys.remove( key );
1465 return; 1548 return;
1466 } 1549 }
1467 } 1550 }
1468} 1551}
1469 1552
1470Key Addressee::key( int type, QString customTypeString ) const 1553Key Addressee::key( int type, QString customTypeString ) const
1471{ 1554{
1472 Key::List::ConstIterator it; 1555 Key::List::ConstIterator it;
1473 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1556 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1474 if ( (*it).type() == type ) { 1557 if ( (*it).type() == type ) {
1475 if ( type == Key::Custom ) { 1558 if ( type == Key::Custom ) {
1476 if ( customTypeString.isEmpty() ) { 1559 if ( customTypeString.isEmpty() ) {
1477 return *it; 1560 return *it;
1478 } else { 1561 } else {
1479 if ( (*it).customTypeString() == customTypeString ) 1562 if ( (*it).customTypeString() == customTypeString )
1480 return (*it); 1563 return (*it);
1481 } 1564 }
1482 } else { 1565 } else {
1483 return *it; 1566 return *it;
1484 } 1567 }
1485 } 1568 }
1486 } 1569 }
1487 return Key( QString(), type ); 1570 return Key( QString(), type );
1488} 1571}
1489void Addressee::setKeys( const Key::List& list ) { 1572void Addressee::setKeys( const Key::List& list ) {
1490 detach(); 1573 detach();
1491 mData->keys = list; 1574 mData->keys = list;
1492} 1575}
1493 1576
1494Key::List Addressee::keys() const 1577Key::List Addressee::keys() const
1495{ 1578{
1496 return mData->keys; 1579 return mData->keys;
1497} 1580}
1498 1581
1499Key::List Addressee::keys( int type, QString customTypeString ) const 1582Key::List Addressee::keys( int type, QString customTypeString ) const
1500{ 1583{
1501 Key::List list; 1584 Key::List list;
1502 1585
1503 Key::List::ConstIterator it; 1586 Key::List::ConstIterator it;
1504 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1587 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1505 if ( (*it).type() == type ) { 1588 if ( (*it).type() == type ) {
1506 if ( type == Key::Custom ) { 1589 if ( type == Key::Custom ) {
1507 if ( customTypeString.isEmpty() ) { 1590 if ( customTypeString.isEmpty() ) {
1508 list.append(*it); 1591 list.append(*it);
1509 } else { 1592 } else {
1510 if ( (*it).customTypeString() == customTypeString ) 1593 if ( (*it).customTypeString() == customTypeString )
1511 list.append(*it); 1594 list.append(*it);
1512 } 1595 }
1513 } else { 1596 } else {
1514 list.append(*it); 1597 list.append(*it);
1515 } 1598 }
1516 } 1599 }
1517 } 1600 }
1518 return list; 1601 return list;
1519} 1602}
1520 1603
1521Key Addressee::findKey( const QString &id ) const 1604Key Addressee::findKey( const QString &id ) const
1522{ 1605{
1523 Key::List::ConstIterator it; 1606 Key::List::ConstIterator it;
1524 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1607 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1525 if ( (*it).id() == id ) { 1608 if ( (*it).id() == id ) {
1526 return *it; 1609 return *it;
1527 } 1610 }
1528 } 1611 }
1529 return Key(); 1612 return Key();
1530} 1613}
1531 1614
1532QString Addressee::asString() const 1615QString Addressee::asString() const
1533{ 1616{
1534 return "Smith, agent Smith..."; 1617 return "Smith, agent Smith...";
1535} 1618}
1536 1619
1537void Addressee::dump() const 1620void Addressee::dump() const
1538{ 1621{
1539 return; 1622 return;
1540 kdDebug(5700) << "Addressee {" << endl; 1623 kdDebug(5700) << "Addressee {" << endl;
1541 1624
1542 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1625 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1543 1626
1544 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1627 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1545 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1628 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1546 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1629 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1547 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1630 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1548 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1631 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1549 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1632 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1550 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1633 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1551 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1634 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1552 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1635 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1553 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1636 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1554 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1637 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1555 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1638 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1556 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1639 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1557 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1640 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1558 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1641 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1559 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1642 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1560 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1643 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1561 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1644 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1562 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1645 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1563 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1646 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1564 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1647 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1565 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1648 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1566 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1649 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1567 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1650 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1568 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1651 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1569 1652
1570 kdDebug(5700) << " Emails {" << endl; 1653 kdDebug(5700) << " Emails {" << endl;
1571 QStringList e = emails(); 1654 QStringList e = emails();
1572 QStringList::ConstIterator it; 1655 QStringList::ConstIterator it;
1573 for( it = e.begin(); it != e.end(); ++it ) { 1656 for( it = e.begin(); it != e.end(); ++it ) {
1574 kdDebug(5700) << " " << (*it) << endl; 1657 kdDebug(5700) << " " << (*it) << endl;
1575 } 1658 }
1576 kdDebug(5700) << " }" << endl; 1659 kdDebug(5700) << " }" << endl;
1577 1660
1578 kdDebug(5700) << " PhoneNumbers {" << endl; 1661 kdDebug(5700) << " PhoneNumbers {" << endl;
1579 PhoneNumber::List p = phoneNumbers(); 1662 PhoneNumber::List p = phoneNumbers();
1580 PhoneNumber::List::ConstIterator it2; 1663 PhoneNumber::List::ConstIterator it2;
1581 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1664 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1582 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1665 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1583 } 1666 }
1584 kdDebug(5700) << " }" << endl; 1667 kdDebug(5700) << " }" << endl;
1585 1668
1586 Address::List a = addresses(); 1669 Address::List a = addresses();
1587 Address::List::ConstIterator it3; 1670 Address::List::ConstIterator it3;
1588 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1671 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1589 (*it3).dump(); 1672 (*it3).dump();
1590 } 1673 }
1591 1674
1592 kdDebug(5700) << " Keys {" << endl; 1675 kdDebug(5700) << " Keys {" << endl;
1593 Key::List k = keys(); 1676 Key::List k = keys();
1594 Key::List::ConstIterator it4; 1677 Key::List::ConstIterator it4;
1595 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1678 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1596 kdDebug(5700) << " Type: " << int((*it4).type()) << 1679 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1597 " Key: " << (*it4).textData() << 1680 " Key: " << (*it4).textData() <<
1598 " CustomString: " << (*it4).customTypeString() << endl; 1681 " CustomString: " << (*it4).customTypeString() << endl;
1599 } 1682 }
1600 kdDebug(5700) << " }" << endl; 1683 kdDebug(5700) << " }" << endl;
1601 1684
1602 kdDebug(5700) << "}" << endl; 1685 kdDebug(5700) << "}" << endl;
1603} 1686}
1604 1687
1605 1688
1606void Addressee::insertAddress( const Address &address ) 1689void Addressee::insertAddress( const Address &address )
1607{ 1690{
1608 detach(); 1691 detach();
1609 mData->empty = false; 1692 mData->empty = false;
1610 1693
1611 Address::List::Iterator it; 1694 Address::List::Iterator it;
1612 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1695 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1613 if ( (*it).id() == address.id() ) { 1696 if ( (*it).id() == address.id() ) {
1614 *it = address; 1697 *it = address;
1615 return; 1698 return;
1616 } 1699 }
1617 } 1700 }
1618 mData->addresses.append( address ); 1701 mData->addresses.append( address );
1619} 1702}
1620 1703
1621void Addressee::removeAddress( const Address &address ) 1704void Addressee::removeAddress( const Address &address )
1622{ 1705{
1623 detach(); 1706 detach();
1624 1707
1625 Address::List::Iterator it; 1708 Address::List::Iterator it;
1626 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1709 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1627 if ( (*it).id() == address.id() ) { 1710 if ( (*it).id() == address.id() ) {
1628 mData->addresses.remove( it ); 1711 mData->addresses.remove( it );
1629 return; 1712 return;
1630 } 1713 }
1631 } 1714 }
1632} 1715}
1633 1716
1634Address Addressee::address( int type ) const 1717Address Addressee::address( int type ) const
1635{ 1718{
1636 Address address( type ); 1719 Address address( type );
1637 Address::List::ConstIterator it; 1720 Address::List::ConstIterator it;
1638 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1721 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1639 if ( matchBinaryPatternA( (*it).type(), type ) ) { 1722 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1640 if ( (*it).type() & Address::Pref ) 1723 if ( (*it).type() & Address::Pref )
1641 return (*it); 1724 return (*it);
1642 else if ( address.isEmpty() ) 1725 else if ( address.isEmpty() )
1643 address = (*it); 1726 address = (*it);
1644 } 1727 }
1645 } 1728 }
1646 1729
1647 return address; 1730 return address;
1648} 1731}
1649 1732
1650Address::List Addressee::addresses() const 1733Address::List Addressee::addresses() const
1651{ 1734{
1652 return mData->addresses; 1735 return mData->addresses;
1653} 1736}
1654 1737
1655Address::List Addressee::addresses( int type ) const 1738Address::List Addressee::addresses( int type ) const
1656{ 1739{
1657 Address::List list; 1740 Address::List list;
1658 1741
1659 Address::List::ConstIterator it; 1742 Address::List::ConstIterator it;
1660 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1743 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1661 if ( matchBinaryPattern( (*it).type(), type ) ) { 1744 if ( matchBinaryPattern( (*it).type(), type ) ) {
1662 list.append( *it ); 1745 list.append( *it );
1663 } 1746 }
1664 } 1747 }
1665 1748
1666 return list; 1749 return list;
1667} 1750}
1668 1751
1669Address Addressee::findAddress( const QString &id ) const 1752Address Addressee::findAddress( const QString &id ) const
1670{ 1753{
1671 Address::List::ConstIterator it; 1754 Address::List::ConstIterator it;
1672 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1755 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1673 if ( (*it).id() == id ) { 1756 if ( (*it).id() == id ) {
1674 return *it; 1757 return *it;
1675 } 1758 }
1676 } 1759 }
1677 return Address(); 1760 return Address();
1678} 1761}
1679 1762
1680void Addressee::insertCategory( const QString &c ) 1763void Addressee::insertCategory( const QString &c )
1681{ 1764{
1682 detach(); 1765 detach();
1683 mData->empty = false; 1766 mData->empty = false;
1684 1767
1685 if ( mData->categories.contains( c ) ) return; 1768 if ( mData->categories.contains( c ) ) return;
1686 1769
1687 mData->categories.append( c ); 1770 mData->categories.append( c );
1688} 1771}
1689 1772
1690void Addressee::removeCategory( const QString &c ) 1773void Addressee::removeCategory( const QString &c )
1691{ 1774{
1692 detach(); 1775 detach();
1693 1776
1694 QStringList::Iterator it = mData->categories.find( c ); 1777 QStringList::Iterator it = mData->categories.find( c );
1695 if ( it == mData->categories.end() ) return; 1778 if ( it == mData->categories.end() ) return;
1696 1779
1697 mData->categories.remove( it ); 1780 mData->categories.remove( it );
1698} 1781}
1699 1782
1700bool Addressee::hasCategory( const QString &c ) const 1783bool Addressee::hasCategory( const QString &c ) const
1701{ 1784{
1702 return ( mData->categories.contains( c ) ); 1785 return ( mData->categories.contains( c ) );
1703} 1786}
1704 1787
1705void Addressee::setCategories( const QStringList &c ) 1788void Addressee::setCategories( const QStringList &c )
1706{ 1789{
1707 detach(); 1790 detach();
1708 mData->empty = false; 1791 mData->empty = false;
1709 1792
1710 mData->categories = c; 1793 mData->categories = c;
1711} 1794}
1712 1795
1713QStringList Addressee::categories() const 1796QStringList Addressee::categories() const
1714{ 1797{
1715 return mData->categories; 1798 return mData->categories;
1716} 1799}
1717 1800
1718void Addressee::insertCustom( const QString &app, const QString &name, 1801void Addressee::insertCustom( const QString &app, const QString &name,
1719 const QString &value ) 1802 const QString &value )
1720{ 1803{
1721 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 1804 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
1722 1805
1723 detach(); 1806 detach();
1724 mData->empty = false; 1807 mData->empty = false;
1725 1808
1726 QString qualifiedName = app + "-" + name + ":"; 1809 QString qualifiedName = app + "-" + name + ":";
1727 1810
1728 QStringList::Iterator it; 1811 QStringList::Iterator it;
1729 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1812 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1730 if ( (*it).startsWith( qualifiedName ) ) { 1813 if ( (*it).startsWith( qualifiedName ) ) {
1731 (*it) = qualifiedName + value; 1814 (*it) = qualifiedName + value;
1732 return; 1815 return;
1733 } 1816 }
1734 } 1817 }
1735 mData->custom.append( qualifiedName + value ); 1818 mData->custom.append( qualifiedName + value );
1736} 1819}
1737 1820
1738void Addressee::removeCustom( const QString &app, const QString &name) 1821void Addressee::removeCustom( const QString &app, const QString &name)
1739{ 1822{
1740 detach(); 1823 detach();
1741 1824
1742 QString qualifiedName = app + "-" + name + ":"; 1825 QString qualifiedName = app + "-" + name + ":";
1743 1826
1744 QStringList::Iterator it; 1827 QStringList::Iterator it;
1745 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1828 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1746 if ( (*it).startsWith( qualifiedName ) ) { 1829 if ( (*it).startsWith( qualifiedName ) ) {
1747 mData->custom.remove( it ); 1830 mData->custom.remove( it );
1748 return; 1831 return;
1749 } 1832 }
1750 } 1833 }
1751} 1834}
1752 1835
1753QString Addressee::custom( const QString &app, const QString &name ) const 1836QString Addressee::custom( const QString &app, const QString &name ) const
1754{ 1837{
1755 QString qualifiedName = app + "-" + name + ":"; 1838 QString qualifiedName = app + "-" + name + ":";
1756 QString value; 1839 QString value;
1757 1840
1758 QStringList::ConstIterator it; 1841 QStringList::ConstIterator it;
1759 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1842 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1760 if ( (*it).startsWith( qualifiedName ) ) { 1843 if ( (*it).startsWith( qualifiedName ) ) {
1761 value = (*it).mid( (*it).find( ":" ) + 1 ); 1844 value = (*it).mid( (*it).find( ":" ) + 1 );
1762 break; 1845 break;
1763 } 1846 }
1764 } 1847 }
1765 1848
1766 return value; 1849 return value;
1767} 1850}
1768 1851
1769void Addressee::setCustoms( const QStringList &l ) 1852void Addressee::setCustoms( const QStringList &l )
1770{ 1853{
1771 detach(); 1854 detach();
1772 mData->empty = false; 1855 mData->empty = false;
1773 1856
1774 mData->custom = l; 1857 mData->custom = l;
1775} 1858}
1776 1859
1777QStringList Addressee::customs() const 1860QStringList Addressee::customs() const
1778{ 1861{
1779 return mData->custom; 1862 return mData->custom;
1780} 1863}
1781 1864
1782void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, 1865void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1783 QString &email) 1866 QString &email)
1784{ 1867{
1785 int startPos, endPos, len; 1868 int startPos, endPos, len;
1786 QString partA, partB, result; 1869 QString partA, partB, result;
1787 char endCh = '>'; 1870 char endCh = '>';
1788 1871
1789 startPos = rawEmail.find('<'); 1872 startPos = rawEmail.find('<');
1790 if (startPos < 0) 1873 if (startPos < 0)
1791 { 1874 {
1792 startPos = rawEmail.find('('); 1875 startPos = rawEmail.find('(');
1793 endCh = ')'; 1876 endCh = ')';
1794 } 1877 }
1795 if (startPos < 0) 1878 if (startPos < 0)
1796 { 1879 {
1797 // We couldn't find any separators, so we assume the whole string 1880 // We couldn't find any separators, so we assume the whole string
1798 // is the email address 1881 // is the email address
1799 email = rawEmail; 1882 email = rawEmail;
1800 fullName = ""; 1883 fullName = "";
1801 } 1884 }
1802 else 1885 else
1803 { 1886 {
1804 // We have a start position, try to find an end 1887 // We have a start position, try to find an end
1805 endPos = rawEmail.find(endCh, startPos+1); 1888 endPos = rawEmail.find(endCh, startPos+1);
1806 1889
1807 if (endPos < 0) 1890 if (endPos < 0)
1808 { 1891 {
1809 // We couldn't find the end of the email address. We can only 1892 // We couldn't find the end of the email address. We can only
1810 // assume the entire string is the email address. 1893 // assume the entire string is the email address.
1811 email = rawEmail; 1894 email = rawEmail;
1812 fullName = ""; 1895 fullName = "";
1813 } 1896 }
1814 else 1897 else
1815 { 1898 {
1816 // We have a start and end to the email address 1899 // We have a start and end to the email address
1817 1900
1818 // Grab the name part 1901 // Grab the name part
1819 fullName = rawEmail.left(startPos).stripWhiteSpace(); 1902 fullName = rawEmail.left(startPos).stripWhiteSpace();
1820 1903
1821 // grab the email part 1904 // grab the email part
1822 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 1905 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
1823 1906
1824 // Check that we do not have any extra characters on the end of the 1907 // Check that we do not have any extra characters on the end of the
1825 // strings 1908 // strings
1826 len = fullName.length(); 1909 len = fullName.length();
1827 if (fullName[0]=='"' && fullName[len-1]=='"') 1910 if (fullName[0]=='"' && fullName[len-1]=='"')
1828 fullName = fullName.mid(1, len-2); 1911 fullName = fullName.mid(1, len-2);
1829 else if (fullName[0]=='<' && fullName[len-1]=='>') 1912 else if (fullName[0]=='<' && fullName[len-1]=='>')
1830 fullName = fullName.mid(1, len-2); 1913 fullName = fullName.mid(1, len-2);
1831 else if (fullName[0]=='(' && fullName[len-1]==')') 1914 else if (fullName[0]=='(' && fullName[len-1]==')')
1832 fullName = fullName.mid(1, len-2); 1915 fullName = fullName.mid(1, len-2);
1833 } 1916 }
1834 } 1917 }
1835} 1918}
1836 1919
1837void Addressee::setResource( Resource *resource ) 1920void Addressee::setResource( Resource *resource )
1838{ 1921{
1839 detach(); 1922 detach();
1840 mData->resource = resource; 1923 mData->resource = resource;
1841} 1924}
1842 1925
1843Resource *Addressee::resource() const 1926Resource *Addressee::resource() const
1844{ 1927{
1845 return mData->resource; 1928 return mData->resource;
1846} 1929}
1847 1930
1848//US 1931//US
1849QString Addressee::resourceLabel() 1932QString Addressee::resourceLabel()
1850{ 1933{
1851 return i18n("Resource"); 1934 return i18n("Resource");
1852} 1935}
1853 1936
1854void Addressee::setChanged( bool value ) 1937void Addressee::setChanged( bool value )
1855{ 1938{
1856 detach(); 1939 detach();
1857 mData->changed = value; 1940 mData->changed = value;
1858} 1941}
1859 1942
1860bool Addressee::changed() const 1943bool Addressee::changed() const
1861{ 1944{
1862 return mData->changed; 1945 return mData->changed;
1863} 1946}
1864 1947
1865void Addressee::setTagged( bool value ) 1948void Addressee::setTagged( bool value )
1866{ 1949{
1867 detach(); 1950 detach();
1868 mData->tagged = value; 1951 mData->tagged = value;
1869} 1952}
1870 1953
1871bool Addressee::tagged() const 1954bool Addressee::tagged() const
1872{ 1955{
1873 return mData->tagged; 1956 return mData->tagged;
1874} 1957}
1875 1958
1876QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 1959QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
1877{ 1960{
1878 if (!a.mData) return s; 1961 if (!a.mData) return s;
1879 1962
1880 s << a.uid(); 1963 s << a.uid();
1881 1964
1882 s << a.mData->name; 1965 s << a.mData->name;
1883 s << a.mData->formattedName; 1966 s << a.mData->formattedName;
1884 s << a.mData->familyName; 1967 s << a.mData->familyName;
1885 s << a.mData->givenName; 1968 s << a.mData->givenName;
1886 s << a.mData->additionalName; 1969 s << a.mData->additionalName;
1887 s << a.mData->prefix; 1970 s << a.mData->prefix;
1888 s << a.mData->suffix; 1971 s << a.mData->suffix;
1889 s << a.mData->nickName; 1972 s << a.mData->nickName;
1890 s << a.mData->birthday; 1973 s << a.mData->birthday;
1891 s << a.mData->mailer; 1974 s << a.mData->mailer;
1892 s << a.mData->timeZone; 1975 s << a.mData->timeZone;
1893 s << a.mData->geo; 1976 s << a.mData->geo;
1894 s << a.mData->title; 1977 s << a.mData->title;
1895 s << a.mData->role; 1978 s << a.mData->role;
1896 s << a.mData->organization; 1979 s << a.mData->organization;
1897 s << a.mData->note; 1980 s << a.mData->note;
1898 s << a.mData->productId; 1981 s << a.mData->productId;
1899 s << a.mData->revision; 1982 s << a.mData->revision;
1900 s << a.mData->sortString; 1983 s << a.mData->sortString;
1901 s << a.mData->url; 1984 s << a.mData->url;
1902 s << a.mData->secrecy; 1985 s << a.mData->secrecy;
1903 s << a.mData->logo; 1986 s << a.mData->logo;
1904 s << a.mData->photo; 1987 s << a.mData->photo;
1905 s << a.mData->sound; 1988 s << a.mData->sound;
1906 s << a.mData->agent; 1989 s << a.mData->agent;
1907 s << a.mData->phoneNumbers; 1990 s << a.mData->phoneNumbers;
1908 s << a.mData->addresses; 1991 s << a.mData->addresses;
1909 s << a.mData->emails; 1992 s << a.mData->emails;
1910 s << a.mData->categories; 1993 s << a.mData->categories;
1911 s << a.mData->custom; 1994 s << a.mData->custom;
1912 s << a.mData->keys; 1995 s << a.mData->keys;
1913 return s; 1996 return s;
1914} 1997}
1915 1998
1916QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 1999QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
1917{ 2000{
1918 if (!a.mData) return s; 2001 if (!a.mData) return s;
1919 2002
1920 s >> a.mData->uid; 2003 s >> a.mData->uid;
1921 2004
1922 s >> a.mData->name; 2005 s >> a.mData->name;
1923 s >> a.mData->formattedName; 2006 s >> a.mData->formattedName;
1924 s >> a.mData->familyName; 2007 s >> a.mData->familyName;
1925 s >> a.mData->givenName; 2008 s >> a.mData->givenName;
1926 s >> a.mData->additionalName; 2009 s >> a.mData->additionalName;
1927 s >> a.mData->prefix; 2010 s >> a.mData->prefix;
1928 s >> a.mData->suffix; 2011 s >> a.mData->suffix;
1929 s >> a.mData->nickName; 2012 s >> a.mData->nickName;
1930 s >> a.mData->birthday; 2013 s >> a.mData->birthday;
1931 s >> a.mData->mailer; 2014 s >> a.mData->mailer;
1932 s >> a.mData->timeZone; 2015 s >> a.mData->timeZone;
1933 s >> a.mData->geo; 2016 s >> a.mData->geo;
1934 s >> a.mData->title; 2017 s >> a.mData->title;
1935 s >> a.mData->role; 2018 s >> a.mData->role;
1936 s >> a.mData->organization; 2019 s >> a.mData->organization;
1937 s >> a.mData->note; 2020 s >> a.mData->note;
1938 s >> a.mData->productId; 2021 s >> a.mData->productId;
1939 s >> a.mData->revision; 2022 s >> a.mData->revision;
1940 s >> a.mData->sortString; 2023 s >> a.mData->sortString;
1941 s >> a.mData->url; 2024 s >> a.mData->url;
1942 s >> a.mData->secrecy; 2025 s >> a.mData->secrecy;
1943 s >> a.mData->logo; 2026 s >> a.mData->logo;
1944 s >> a.mData->photo; 2027 s >> a.mData->photo;
1945 s >> a.mData->sound; 2028 s >> a.mData->sound;
1946 s >> a.mData->agent; 2029 s >> a.mData->agent;
1947 s >> a.mData->phoneNumbers; 2030 s >> a.mData->phoneNumbers;
1948 s >> a.mData->addresses; 2031 s >> a.mData->addresses;
1949 s >> a.mData->emails; 2032 s >> a.mData->emails;
1950 s >> a.mData->categories; 2033 s >> a.mData->categories;
1951 s >> a.mData->custom; 2034 s >> a.mData->custom;
1952 s >> a.mData->keys; 2035 s >> a.mData->keys;
1953 2036
1954 a.mData->empty = false; 2037 a.mData->empty = false;
1955 2038
1956 return s; 2039 return s;
1957} 2040}
1958bool matchBinaryPattern( int value, int pattern ) 2041bool matchBinaryPattern( int value, int pattern )
1959{ 2042{
1960 /** 2043 /**
1961 We want to match all telephonnumbers/addresses which have the bits in the 2044 We want to match all telephonnumbers/addresses which have the bits in the
1962 pattern set. More are allowed. 2045 pattern set. More are allowed.
1963 if pattern == 0 we have a special handling, then we want only those with 2046 if pattern == 0 we have a special handling, then we want only those with
1964 exactly no bit set. 2047 exactly no bit set.
1965 */ 2048 */
1966 if ( pattern == 0 ) 2049 if ( pattern == 0 )
1967 return ( value == 0 ); 2050 return ( value == 0 );
1968 else 2051 else
1969 return ( pattern == ( pattern & value ) ); 2052 return ( pattern == ( pattern & value ) );
1970} 2053}
1971 2054
1972bool matchBinaryPatternP( int value, int pattern ) 2055bool matchBinaryPatternP( int value, int pattern )
1973{ 2056{
1974 2057
1975 if ( pattern == 0 ) 2058 if ( pattern == 0 )
1976 return ( value == 0 ); 2059 return ( value == 0 );
1977 else 2060 else
1978 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); 2061 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) );
1979} 2062}
1980bool matchBinaryPatternA( int value, int pattern ) 2063bool matchBinaryPatternA( int value, int pattern )
1981{ 2064{
1982 2065
1983 if ( pattern == 0 ) 2066 if ( pattern == 0 )
1984 return ( value == 0 ); 2067 return ( value == 0 );
1985 else 2068 else
1986 return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); 2069 return ( (pattern | Address::Pref) == ( value | Address::Pref ) );
1987} 2070}
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 03138f6..e7900c6 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -1,853 +1,853 @@
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#ifndef KABC_ADDRESSEE_H 29#ifndef KABC_ADDRESSEE_H
30#define KABC_ADDRESSEE_H 30#define KABC_ADDRESSEE_H
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36 36
37#include <ksharedptr.h> 37#include <ksharedptr.h>
38#include <kurl.h> 38#include <kurl.h>
39 39
40#include "address.h" 40#include "address.h"
41#include "agent.h" 41#include "agent.h"
42#include "geo.h" 42#include "geo.h"
43#include "key.h" 43#include "key.h"
44#include "phonenumber.h" 44#include "phonenumber.h"
45#include "picture.h" 45#include "picture.h"
46#include "secrecy.h" 46#include "secrecy.h"
47#include "sound.h" 47#include "sound.h"
48#include "timezone.h" 48#include "timezone.h"
49 49
50namespace KABC { 50namespace KABC {
51 51
52class Resource; 52class Resource;
53 53
54/** 54/**
55 @short address book entry 55 @short address book entry
56 56
57 This class represents an entry in the address book. 57 This class represents an entry in the address book.
58 58
59 The data of this class is implicitly shared. You can pass this class by value. 59 The data of this class is implicitly shared. You can pass this class by value.
60 60
61 If you need the name of a field for presenting it to the user you should use 61 If you need the name of a field for presenting it to the user you should use
62 the functions ending in Label(). They return a translated string which can be 62 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 63 used as label for the corresponding field.
64 64
65 About the name fields: 65 About the name fields:
66 66
67 givenName() is the first name and familyName() the last name. In some 67 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 68 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 69 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 70 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 71 from the other name fields automatically.
72 72
73 realName() returns a fully formatted name(). It uses formattedName, if set, 73 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 74 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 75 nothing else is set it uses name().
76 76
77 name() is the NAME type of RFC2426. It can be used as internal name for the 77 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 78 data enty, but shouldn't be used for displaying the data to the user.
79 */ 79 */
80class Addressee 80class Addressee
81{ 81{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 82 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 83 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 84
85 public: 85 public:
86 typedef QValueList<Addressee> List; 86 typedef QValueList<Addressee> List;
87 87
88 /** 88 /**
89 Construct an empty address book entry. 89 Construct an empty address book entry.
90 */ 90 */
91 Addressee(); 91 Addressee();
92 ~Addressee(); 92 ~Addressee();
93 93
94 Addressee( const Addressee & ); 94 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 95 Addressee &operator=( const Addressee & );
96 96
97 bool operator==( const Addressee & ) const; 97 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 // sync stuff 99 // sync stuff
100 void setTempSyncStat(int id); 100 void setTempSyncStat(int id);
101 int tempSyncStat() const; 101 int tempSyncStat() const;
102 void setIDStr( const QString & ); 102 void setIDStr( const QString & );
103 QString IDStr() const; 103 QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 QString getID( const QString & ); 105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & ); 107 QString getCsum( const QString & );
108 void removeID(const QString &); 108 void removeID(const QString &);
109 void computeCsum(const QString &dev); 109 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 110 ulong getCsum4List( const QStringList & attList);
111 /** 111 /**
112 Return, if the address book entry is empty. 112 Return, if the address book entry is empty.
113 */ 113 */
114 bool isEmpty() const; 114 bool isEmpty() const;
115 void setExternalUID( const QString &id ); 115 void setExternalUID( const QString &id );
116 QString externalUID() const; 116 QString externalUID() const;
117 void setOriginalExternalUID( const QString &id ); 117 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const; 118 QString originalExternalUID() const;
119 void mergeContact( const Addressee& ad ); 119 void mergeContact( const Addressee& ad, bool isSubSet = false );
120 void simplifyEmails(); 120 void simplifyEmails();
121 void simplifyAddresses(); 121 void simplifyAddresses();
122 void simplifyPhoneNumbers(); 122 void simplifyPhoneNumbers();
123 void simplifyPhoneNumberTypes(); 123 void simplifyPhoneNumberTypes();
124 bool removeVoice(); 124 bool removeVoice();
125 bool containsAdr(const Addressee& addr ); 125 bool containsAdr(const Addressee& addr );
126 126
127 /** 127 /**
128 Set unique identifier. 128 Set unique identifier.
129 */ 129 */
130 void setUid( const QString &uid ); 130 void setUid( const QString &uid );
131 /** 131 /**
132 Return unique identifier. 132 Return unique identifier.
133 */ 133 */
134 QString uid() const; 134 QString uid() const;
135 /** 135 /**
136 Return translated label for uid field. 136 Return translated label for uid field.
137 */ 137 */
138 static QString uidLabel(); 138 static QString uidLabel();
139 139
140 /** 140 /**
141 Set name. 141 Set name.
142 */ 142 */
143 void setName( const QString &name ); 143 void setName( const QString &name );
144 /** 144 /**
145 Return name. 145 Return name.
146 */ 146 */
147 QString name() const; 147 QString name() const;
148 /** 148 /**
149 Return translated label for name field. 149 Return translated label for name field.
150 */ 150 */
151 static QString nameLabel(); 151 static QString nameLabel();
152 152
153 /** 153 /**
154 Set formatted name. 154 Set formatted name.
155 */ 155 */
156 void setFormattedName( const QString &formattedName ); 156 void setFormattedName( const QString &formattedName );
157 /** 157 /**
158 Return formatted name. 158 Return formatted name.
159 */ 159 */
160 QString formattedName() const; 160 QString formattedName() const;
161 /** 161 /**
162 Return translated label for formattedName field. 162 Return translated label for formattedName field.
163 */ 163 */
164 static QString formattedNameLabel(); 164 static QString formattedNameLabel();
165 165
166 /** 166 /**
167 Set family name. 167 Set family name.
168 */ 168 */
169 void setFamilyName( const QString &familyName ); 169 void setFamilyName( const QString &familyName );
170 /** 170 /**
171 Return family name. 171 Return family name.
172 */ 172 */
173 QString familyName() const; 173 QString familyName() const;
174 /** 174 /**
175 Return translated label for familyName field. 175 Return translated label for familyName field.
176 */ 176 */
177 static QString familyNameLabel(); 177 static QString familyNameLabel();
178 178
179 /** 179 /**
180 Set given name. 180 Set given name.
181 */ 181 */
182 void setGivenName( const QString &givenName ); 182 void setGivenName( const QString &givenName );
183 /** 183 /**
184 Return given name. 184 Return given name.
185 */ 185 */
186 QString givenName() const; 186 QString givenName() const;
187 /** 187 /**
188 Return translated label for givenName field. 188 Return translated label for givenName field.
189 */ 189 */
190 static QString givenNameLabel(); 190 static QString givenNameLabel();
191 191
192 /** 192 /**
193 Set additional names. 193 Set additional names.
194 */ 194 */
195 void setAdditionalName( const QString &additionalName ); 195 void setAdditionalName( const QString &additionalName );
196 /** 196 /**
197 Return additional names. 197 Return additional names.
198 */ 198 */
199 QString additionalName() const; 199 QString additionalName() const;
200 /** 200 /**
201 Return translated label for additionalName field. 201 Return translated label for additionalName field.
202 */ 202 */
203 static QString additionalNameLabel(); 203 static QString additionalNameLabel();
204 204
205 /** 205 /**
206 Set honorific prefixes. 206 Set honorific prefixes.
207 */ 207 */
208 void setPrefix( const QString &prefix ); 208 void setPrefix( const QString &prefix );
209 /** 209 /**
210 Return honorific prefixes. 210 Return honorific prefixes.
211 */ 211 */
212 QString prefix() const; 212 QString prefix() const;
213 /** 213 /**
214 Return translated label for prefix field. 214 Return translated label for prefix field.
215 */ 215 */
216 static QString prefixLabel(); 216 static QString prefixLabel();
217 217
218 /** 218 /**
219 Set honorific suffixes. 219 Set honorific suffixes.
220 */ 220 */
221 void setSuffix( const QString &suffix ); 221 void setSuffix( const QString &suffix );
222 /** 222 /**
223 Return honorific suffixes. 223 Return honorific suffixes.
224 */ 224 */
225 QString suffix() const; 225 QString suffix() const;
226 /** 226 /**
227 Return translated label for suffix field. 227 Return translated label for suffix field.
228 */ 228 */
229 static QString suffixLabel(); 229 static QString suffixLabel();
230 230
231 /** 231 /**
232 Set nick name. 232 Set nick name.
233 */ 233 */
234 void setNickName( const QString &nickName ); 234 void setNickName( const QString &nickName );
235 /** 235 /**
236 Return nick name. 236 Return nick name.
237 */ 237 */
238 QString nickName() const; 238 QString nickName() const;
239 /** 239 /**
240 Return translated label for nickName field. 240 Return translated label for nickName field.
241 */ 241 */
242 static QString nickNameLabel(); 242 static QString nickNameLabel();
243 243
244 /** 244 /**
245 Set birthday. 245 Set birthday.
246 */ 246 */
247 void setBirthday( const QDateTime &birthday ); 247 void setBirthday( const QDateTime &birthday );
248 /** 248 /**
249 Return birthday. 249 Return birthday.
250 */ 250 */
251 QDateTime birthday() const; 251 QDateTime birthday() const;
252 /** 252 /**
253 Return translated label for birthday field. 253 Return translated label for birthday field.
254 */ 254 */
255 static QString birthdayLabel(); 255 static QString birthdayLabel();
256 256
257 /** 257 /**
258 Return translated label for homeAddressStreet field. 258 Return translated label for homeAddressStreet field.
259 */ 259 */
260 static QString homeAddressStreetLabel(); 260 static QString homeAddressStreetLabel();
261 261
262 /** 262 /**
263 Return translated label for homeAddressLocality field. 263 Return translated label for homeAddressLocality field.
264 */ 264 */
265 static QString homeAddressLocalityLabel(); 265 static QString homeAddressLocalityLabel();
266 266
267 /** 267 /**
268 Return translated label for homeAddressRegion field. 268 Return translated label for homeAddressRegion field.
269 */ 269 */
270 static QString homeAddressRegionLabel(); 270 static QString homeAddressRegionLabel();
271 271
272 /** 272 /**
273 Return translated label for homeAddressPostalCode field. 273 Return translated label for homeAddressPostalCode field.
274 */ 274 */
275 static QString homeAddressPostalCodeLabel(); 275 static QString homeAddressPostalCodeLabel();
276 276
277 /** 277 /**
278 Return translated label for homeAddressCountry field. 278 Return translated label for homeAddressCountry field.
279 */ 279 */
280 static QString homeAddressCountryLabel(); 280 static QString homeAddressCountryLabel();
281 281
282 /** 282 /**
283 Return translated label for homeAddressLabel field. 283 Return translated label for homeAddressLabel field.
284 */ 284 */
285 static QString homeAddressLabelLabel(); 285 static QString homeAddressLabelLabel();
286 286
287 /** 287 /**
288 Return translated label for businessAddressStreet field. 288 Return translated label for businessAddressStreet field.
289 */ 289 */
290 static QString businessAddressStreetLabel(); 290 static QString businessAddressStreetLabel();
291 291
292 /** 292 /**
293 Return translated label for businessAddressLocality field. 293 Return translated label for businessAddressLocality field.
294 */ 294 */
295 static QString businessAddressLocalityLabel(); 295 static QString businessAddressLocalityLabel();
296 296
297 /** 297 /**
298 Return translated label for businessAddressRegion field. 298 Return translated label for businessAddressRegion field.
299 */ 299 */
300 static QString businessAddressRegionLabel(); 300 static QString businessAddressRegionLabel();
301 301
302 /** 302 /**
303 Return translated label for businessAddressPostalCode field. 303 Return translated label for businessAddressPostalCode field.
304 */ 304 */
305 static QString businessAddressPostalCodeLabel(); 305 static QString businessAddressPostalCodeLabel();
306 306
307 /** 307 /**
308 Return translated label for businessAddressCountry field. 308 Return translated label for businessAddressCountry field.
309 */ 309 */
310 static QString businessAddressCountryLabel(); 310 static QString businessAddressCountryLabel();
311 311
312 /** 312 /**
313 Return translated label for businessAddressLabel field. 313 Return translated label for businessAddressLabel field.
314 */ 314 */
315 static QString businessAddressLabelLabel(); 315 static QString businessAddressLabelLabel();
316 316
317 /** 317 /**
318 Return translated label for homePhone field. 318 Return translated label for homePhone field.
319 */ 319 */
320 static QString homePhoneLabel(); 320 static QString homePhoneLabel();
321 321
322 /** 322 /**
323 Return translated label for businessPhone field. 323 Return translated label for businessPhone field.
324 */ 324 */
325 static QString businessPhoneLabel(); 325 static QString businessPhoneLabel();
326 326
327 /** 327 /**
328 Return translated label for mobilePhone field. 328 Return translated label for mobilePhone field.
329 */ 329 */
330 static QString mobilePhoneLabel(); 330 static QString mobilePhoneLabel();
331 331
332 /** 332 /**
333 Return translated label for homeFax field. 333 Return translated label for homeFax field.
334 */ 334 */
335 static QString homeFaxLabel(); 335 static QString homeFaxLabel();
336 336
337 /** 337 /**
338 Return translated label for businessFax field. 338 Return translated label for businessFax field.
339 */ 339 */
340 static QString businessFaxLabel(); 340 static QString businessFaxLabel();
341 341
342 /** 342 /**
343 Return translated label for carPhone field. 343 Return translated label for carPhone field.
344 */ 344 */
345 static QString carPhoneLabel(); 345 static QString carPhoneLabel();
346 346
347 /** 347 /**
348 Return translated label for isdn field. 348 Return translated label for isdn field.
349 */ 349 */
350 static QString isdnLabel(); 350 static QString isdnLabel();
351 351
352 /** 352 /**
353 Return translated label for pager field. 353 Return translated label for pager field.
354 */ 354 */
355 static QString pagerLabel(); 355 static QString pagerLabel();
356 356
357 /** 357 /**
358 Return translated label for sip field. 358 Return translated label for sip field.
359 */ 359 */
360 static QString sipLabel(); 360 static QString sipLabel();
361 361
362 /** 362 /**
363 Return translated label for email field. 363 Return translated label for email field.
364 */ 364 */
365 static QString emailLabel(); 365 static QString emailLabel();
366 366
367 /** 367 /**
368 Set mail client. 368 Set mail client.
369 */ 369 */
370 void setMailer( const QString &mailer ); 370 void setMailer( const QString &mailer );
371 /** 371 /**
372 Return mail client. 372 Return mail client.
373 */ 373 */
374 QString mailer() const; 374 QString mailer() const;
375 /** 375 /**
376 Return translated label for mailer field. 376 Return translated label for mailer field.
377 */ 377 */
378 static QString mailerLabel(); 378 static QString mailerLabel();
379 379
380 /** 380 /**
381 Set time zone. 381 Set time zone.
382 */ 382 */
383 void setTimeZone( const TimeZone &timeZone ); 383 void setTimeZone( const TimeZone &timeZone );
384 /** 384 /**
385 Return time zone. 385 Return time zone.
386 */ 386 */
387 TimeZone timeZone() const; 387 TimeZone timeZone() const;
388 /** 388 /**
389 Return translated label for timeZone field. 389 Return translated label for timeZone field.
390 */ 390 */
391 static QString timeZoneLabel(); 391 static QString timeZoneLabel();
392 392
393 /** 393 /**
394 Set geographic position. 394 Set geographic position.
395 */ 395 */
396 void setGeo( const Geo &geo ); 396 void setGeo( const Geo &geo );
397 /** 397 /**
398 Return geographic position. 398 Return geographic position.
399 */ 399 */
400 Geo geo() const; 400 Geo geo() const;
401 /** 401 /**
402 Return translated label for geo field. 402 Return translated label for geo field.
403 */ 403 */
404 static QString geoLabel(); 404 static QString geoLabel();
405 405
406 /** 406 /**
407 Set title. 407 Set title.
408 */ 408 */
409 void setTitle( const QString &title ); 409 void setTitle( const QString &title );
410 /** 410 /**
411 Return title. 411 Return title.
412 */ 412 */
413 QString title() const; 413 QString title() const;
414 /** 414 /**
415 Return translated label for title field. 415 Return translated label for title field.
416 */ 416 */
417 static QString titleLabel(); 417 static QString titleLabel();
418 418
419 /** 419 /**
420 Set role. 420 Set role.
421 */ 421 */
422 void setRole( const QString &role ); 422 void setRole( const QString &role );
423 /** 423 /**
424 Return role. 424 Return role.
425 */ 425 */
426 QString role() const; 426 QString role() const;
427 /** 427 /**
428 Return translated label for role field. 428 Return translated label for role field.
429 */ 429 */
430 static QString roleLabel(); 430 static QString roleLabel();
431 431
432 /** 432 /**
433 Set organization. 433 Set organization.
434 */ 434 */
435 void setOrganization( const QString &organization ); 435 void setOrganization( const QString &organization );
436 /** 436 /**
437 Return organization. 437 Return organization.
438 */ 438 */
439 QString organization() const; 439 QString organization() const;
440 /** 440 /**
441 Return translated label for organization field. 441 Return translated label for organization field.
442 */ 442 */
443 static QString organizationLabel(); 443 static QString organizationLabel();
444 444
445 /** 445 /**
446 Set note. 446 Set note.
447 */ 447 */
448 void setNote( const QString &note ); 448 void setNote( const QString &note );
449 /** 449 /**
450 Return note. 450 Return note.
451 */ 451 */
452 QString note() const; 452 QString note() const;
453 /** 453 /**
454 Return translated label for note field. 454 Return translated label for note field.
455 */ 455 */
456 static QString noteLabel(); 456 static QString noteLabel();
457 457
458 /** 458 /**
459 Set product identifier. 459 Set product identifier.
460 */ 460 */
461 void setProductId( const QString &productId ); 461 void setProductId( const QString &productId );
462 /** 462 /**
463 Return product identifier. 463 Return product identifier.
464 */ 464 */
465 QString productId() const; 465 QString productId() const;
466 /** 466 /**
467 Return translated label for productId field. 467 Return translated label for productId field.
468 */ 468 */
469 static QString productIdLabel(); 469 static QString productIdLabel();
470 470
471 /** 471 /**
472 Set revision date. 472 Set revision date.
473 */ 473 */
474 void setRevision( const QDateTime &revision ); 474 void setRevision( const QDateTime &revision );
475 /** 475 /**
476 Return revision date. 476 Return revision date.
477 */ 477 */
478 QDateTime revision() const; 478 QDateTime revision() const;
479 /** 479 /**
480 Return translated label for revision field. 480 Return translated label for revision field.
481 */ 481 */
482 static QString revisionLabel(); 482 static QString revisionLabel();
483 483
484 /** 484 /**
485 Set sort string. 485 Set sort string.
486 */ 486 */
487 void setSortString( const QString &sortString ); 487 void setSortString( const QString &sortString );
488 /** 488 /**
489 Return sort string. 489 Return sort string.
490 */ 490 */
491 QString sortString() const; 491 QString sortString() const;
492 /** 492 /**
493 Return translated label for sortString field. 493 Return translated label for sortString field.
494 */ 494 */
495 static QString sortStringLabel(); 495 static QString sortStringLabel();
496 496
497 /** 497 /**
498 Set URL. 498 Set URL.
499 */ 499 */
500 void setUrl( const KURL &url ); 500 void setUrl( const KURL &url );
501 /** 501 /**
502 Return URL. 502 Return URL.
503 */ 503 */
504 KURL url() const; 504 KURL url() const;
505 /** 505 /**
506 Return translated label for url field. 506 Return translated label for url field.
507 */ 507 */
508 static QString urlLabel(); 508 static QString urlLabel();
509 509
510 /** 510 /**
511 Set security class. 511 Set security class.
512 */ 512 */
513 void setSecrecy( const Secrecy &secrecy ); 513 void setSecrecy( const Secrecy &secrecy );
514 /** 514 /**
515 Return security class. 515 Return security class.
516 */ 516 */
517 Secrecy secrecy() const; 517 Secrecy secrecy() const;
518 /** 518 /**
519 Return translated label for secrecy field. 519 Return translated label for secrecy field.
520 */ 520 */
521 static QString secrecyLabel(); 521 static QString secrecyLabel();
522 522
523 /** 523 /**
524 Set logo. 524 Set logo.
525 */ 525 */
526 void setLogo( const Picture &logo ); 526 void setLogo( const Picture &logo );
527 /** 527 /**
528 Return logo. 528 Return logo.
529 */ 529 */
530 Picture logo() const; 530 Picture logo() const;
531 /** 531 /**
532 Return translated label for logo field. 532 Return translated label for logo field.
533 */ 533 */
534 static QString logoLabel(); 534 static QString logoLabel();
535 535
536 /** 536 /**
537 Set photo. 537 Set photo.
538 */ 538 */
539 void setPhoto( const Picture &photo ); 539 void setPhoto( const Picture &photo );
540 /** 540 /**
541 Return photo. 541 Return photo.
542 */ 542 */
543 Picture photo() const; 543 Picture photo() const;
544 /** 544 /**
545 Return translated label for photo field. 545 Return translated label for photo field.
546 */ 546 */
547 static QString photoLabel(); 547 static QString photoLabel();
548 548
549 /** 549 /**
550 Set sound. 550 Set sound.
551 */ 551 */
552 void setSound( const Sound &sound ); 552 void setSound( const Sound &sound );
553 /** 553 /**
554 Return sound. 554 Return sound.
555 */ 555 */
556 Sound sound() const; 556 Sound sound() const;
557 /** 557 /**
558 Return translated label for sound field. 558 Return translated label for sound field.
559 */ 559 */
560 static QString soundLabel(); 560 static QString soundLabel();
561 561
562 /** 562 /**
563 Set agent. 563 Set agent.
564 */ 564 */
565 void setAgent( const Agent &agent ); 565 void setAgent( const Agent &agent );
566 /** 566 /**
567 Return agent. 567 Return agent.
568 */ 568 */
569 Agent agent() const; 569 Agent agent() const;
570 /** 570 /**
571 Return translated label for agent field. 571 Return translated label for agent field.
572 */ 572 */
573 static QString agentLabel(); 573 static QString agentLabel();
574 574
575 /** 575 /**
576 Set name fields by parsing the given string and trying to associate the 576 Set name fields by parsing the given string and trying to associate the
577 parts of the string with according fields. This function should probably 577 parts of the string with according fields. This function should probably
578 be a bit more clever. 578 be a bit more clever.
579 */ 579 */
580 void setNameFromString( const QString & ); 580 void setNameFromString( const QString & );
581 581
582 /** 582 /**
583 Return the name of the addressee. This is calculated from all the name 583 Return the name of the addressee. This is calculated from all the name
584 fields. 584 fields.
585 */ 585 */
586 QString realName() const; 586 QString realName() const;
587 587
588 /** 588 /**
589 Return the name that consists of all name parts. 589 Return the name that consists of all name parts.
590 */ 590 */
591 QString assembledName() const; 591 QString assembledName() const;
592 592
593 /** 593 /**
594 Return email address including real name. 594 Return email address including real name.
595 595
596 @param email Email address to be used to construct the full email string. 596 @param email Email address to be used to construct the full email string.
597 If this is QString::null the preferred email address is used. 597 If this is QString::null the preferred email address is used.
598 */ 598 */
599 QString fullEmail( const QString &email=QString::null ) const; 599 QString fullEmail( const QString &email=QString::null ) const;
600 600
601 /** 601 /**
602 Insert an email address. If the email address already exists in this 602 Insert an email address. If the email address already exists in this
603 addressee it is not duplicated. 603 addressee it is not duplicated.
604 604
605 @param email Email address 605 @param email Email address
606 @param preferred Set to true, if this is the preferred email address of 606 @param preferred Set to true, if this is the preferred email address of
607 the addressee. 607 the addressee.
608 */ 608 */
609 void insertEmail( const QString &email, bool preferred=false ); 609 void insertEmail( const QString &email, bool preferred=false );
610 610
611 /** 611 /**
612 Remove email address. If the email address doesn't exist, nothing happens. 612 Remove email address. If the email address doesn't exist, nothing happens.
613 */ 613 */
614 void removeEmail( const QString &email ); 614 void removeEmail( const QString &email );
615 615
616 /** 616 /**
617 Return preferred email address. This is the first email address or the 617 Return preferred email address. This is the first email address or the
618 last one added with @ref insertEmail() with a set preferred parameter. 618 last one added with @ref insertEmail() with a set preferred parameter.
619 */ 619 */
620 QString preferredEmail() const; 620 QString preferredEmail() const;
621 621
622 /** 622 /**
623 Return list of all email addresses. 623 Return list of all email addresses.
624 */ 624 */
625 QStringList emails() const; 625 QStringList emails() const;
626 626
627 /** 627 /**
628 Set the emails to @param. 628 Set the emails to @param.
629 The first email address gets the preferred one! 629 The first email address gets the preferred one!
630 @param list The list of email addresses. 630 @param list The list of email addresses.
631 */ 631 */
632 void setEmails( const QStringList& list); 632 void setEmails( const QStringList& list);
633 633
634 /** 634 /**
635 Insert a phone number. If a phone number with the same id already exists 635 Insert a phone number. If a phone number with the same id already exists
636 in this addressee it is not duplicated. 636 in this addressee it is not duplicated.
637 */ 637 */
638 void insertPhoneNumber( const PhoneNumber &phoneNumber ); 638 void insertPhoneNumber( const PhoneNumber &phoneNumber );
639 639
640 /** 640 /**
641 Remove phone number. If no phone number with the given id exists for this 641 Remove phone number. If no phone number with the given id exists for this
642 addresse nothing happens. 642 addresse nothing happens.
643 */ 643 */
644 void removePhoneNumber( const PhoneNumber &phoneNumber ); 644 void removePhoneNumber( const PhoneNumber &phoneNumber );
645 645
646 /** 646 /**
647 Return phone number, which matches the given type. 647 Return phone number, which matches the given type.
648 */ 648 */
649 PhoneNumber phoneNumber( int type ) const; 649 PhoneNumber phoneNumber( int type ) const;
650 650
651 /** 651 /**
652 Return list of all phone numbers. 652 Return list of all phone numbers.
653 */ 653 */
654 PhoneNumber::List phoneNumbers() const; 654 PhoneNumber::List phoneNumbers() const;
655 655
656 /** 656 /**
657 Return list of phone numbers with a special type. 657 Return list of phone numbers with a special type.
658 */ 658 */
659 PhoneNumber::List phoneNumbers( int type ) const; 659 PhoneNumber::List phoneNumbers( int type ) const;
660 660
661 /** 661 /**
662 Return phone number with the given id. 662 Return phone number with the given id.
663 */ 663 */
664 PhoneNumber findPhoneNumber( const QString &id ) const; 664 PhoneNumber findPhoneNumber( const QString &id ) const;
665 665
666 /** 666 /**
667 Insert a key. If a key with the same id already exists 667 Insert a key. If a key with the same id already exists
668 in this addressee it is not duplicated. 668 in this addressee it is not duplicated.
669 */ 669 */
670 void insertKey( const Key &key ); 670 void insertKey( const Key &key );
671 671
672 /** 672 /**
673 Remove a key. If no key with the given id exists for this 673 Remove a key. If no key with the given id exists for this
674 addresse nothing happens. 674 addresse nothing happens.
675 */ 675 */
676 void removeKey( const Key &key ); 676 void removeKey( const Key &key );
677 677
678 /** 678 /**
679 Return key, which matches the given type. 679 Return key, which matches the given type.
680 If @p type == Key::Custom you can specify a string 680 If @p type == Key::Custom you can specify a string
681 that should match. If you leave the string empty, the first 681 that should match. If you leave the string empty, the first
682 key with a custom value is returned. 682 key with a custom value is returned.
683 */ 683 */
684 Key key( int type, QString customTypeString = QString::null ) const; 684 Key key( int type, QString customTypeString = QString::null ) const;
685 685
686 /** 686 /**
687 Return list of all keys. 687 Return list of all keys.
688 */ 688 */
689 Key::List keys() const; 689 Key::List keys() const;
690 690
691 /** 691 /**
692 Set the list of keys 692 Set the list of keys
693 @param keys The keys to be set. 693 @param keys The keys to be set.
694 */ 694 */
695 void setKeys( const Key::List& keys); 695 void setKeys( const Key::List& keys);
696 696
697 /** 697 /**
698 Return list of keys with a special type. 698 Return list of keys with a special type.
699 If @p type == Key::Custom you can specify a string 699 If @p type == Key::Custom you can specify a string
700 that should match. If you leave the string empty, all custom 700 that should match. If you leave the string empty, all custom
701 keys will be returned. 701 keys will be returned.
702 */ 702 */
703 Key::List keys( int type, QString customTypeString = QString::null ) const; 703 Key::List keys( int type, QString customTypeString = QString::null ) const;
704 704
705 /** 705 /**
706 Return key with the given id. 706 Return key with the given id.
707 */ 707 */
708 Key findKey( const QString &id ) const; 708 Key findKey( const QString &id ) const;
709 709
710 /** 710 /**
711 Insert an address. If an address with the same id already exists 711 Insert an address. If an address with the same id already exists
712 in this addressee it is not duplicated. 712 in this addressee it is not duplicated.
713 */ 713 */
714 void insertAddress( const Address &address ); 714 void insertAddress( const Address &address );
715 715
716 /** 716 /**
717 Remove address. If no address with the given id exists for this 717 Remove address. If no address with the given id exists for this
718 addresse nothing happens. 718 addresse nothing happens.
719 */ 719 */
720 void removeAddress( const Address &address ); 720 void removeAddress( const Address &address );
721 721
722 /** 722 /**
723 Return address, which matches the given type. 723 Return address, which matches the given type.
724 */ 724 */
725 Address address( int type ) const; 725 Address address( int type ) const;
726 726
727 /** 727 /**
728 Return list of all addresses. 728 Return list of all addresses.
729 */ 729 */
730 Address::List addresses() const; 730 Address::List addresses() const;
731 731
732 /** 732 /**
733 Return list of addresses with a special type. 733 Return list of addresses with a special type.
734 */ 734 */
735 Address::List addresses( int type ) const; 735 Address::List addresses( int type ) const;
736 736
737 /** 737 /**
738 Return address with the given id. 738 Return address with the given id.
739 */ 739 */
740 Address findAddress( const QString &id ) const; 740 Address findAddress( const QString &id ) const;
741 741
742 /** 742 /**
743 Insert category. If the category already exists it is not duplicated. 743 Insert category. If the category already exists it is not duplicated.
744 */ 744 */
745 void insertCategory( const QString & ); 745 void insertCategory( const QString & );
746 746
747 /** 747 /**
748 Remove category. 748 Remove category.
749 */ 749 */
750 void removeCategory( const QString & ); 750 void removeCategory( const QString & );
751 751
752 /** 752 /**
753 Return, if addressee has the given category. 753 Return, if addressee has the given category.
754 */ 754 */
755 bool hasCategory( const QString & ) const; 755 bool hasCategory( const QString & ) const;
756 756
757 /** 757 /**
758 Set categories to given value. 758 Set categories to given value.
759 */ 759 */
760 void setCategories( const QStringList & ); 760 void setCategories( const QStringList & );
761 761
762 /** 762 /**
763 Return list of all set categories. 763 Return list of all set categories.
764 */ 764 */
765 QStringList categories() const; 765 QStringList categories() const;
766 766
767 /** 767 /**
768 Insert custom entry. The entry is identified by the name of the inserting 768 Insert custom entry. The entry is identified by the name of the inserting
769 application and a unique name. If an entry with the given app and name 769 application and a unique name. If an entry with the given app and name
770 already exists its value is replaced with the new given value. 770 already exists its value is replaced with the new given value.
771 */ 771 */
772 void insertCustom( const QString &app, const QString &name, 772 void insertCustom( const QString &app, const QString &name,
773 const QString &value ); 773 const QString &value );
774 774
775 /** 775 /**
776 Remove custom entry. 776 Remove custom entry.
777 */ 777 */
778 void removeCustom( const QString &app, const QString &name ); 778 void removeCustom( const QString &app, const QString &name );
779 779
780 /** 780 /**
781 Return value of custom entry, identified by app and entry name. 781 Return value of custom entry, identified by app and entry name.
782 */ 782 */
783 QString custom( const QString &app, const QString &name ) const; 783 QString custom( const QString &app, const QString &name ) const;
784 784
785 /** 785 /**
786 Set all custom entries. 786 Set all custom entries.
787 */ 787 */
788 void setCustoms( const QStringList & ); 788 void setCustoms( const QStringList & );
789 789
790 /** 790 /**
791 Return list of all custom entries. 791 Return list of all custom entries.
792 */ 792 */
793 QStringList customs() const; 793 QStringList customs() const;
794 794
795 /** 795 /**
796 Parse full email address. The result is given back in fullName and email. 796 Parse full email address. The result is given back in fullName and email.
797 */ 797 */
798 static void parseEmailAddress( const QString &rawEmail, QString &fullName, 798 static void parseEmailAddress( const QString &rawEmail, QString &fullName,
799 QString &email ); 799 QString &email );
800 800
801 /** 801 /**
802 Debug output. 802 Debug output.
803 */ 803 */
804 void dump() const; 804 void dump() const;
805 805
806 /** 806 /**
807 Returns string representation of the addressee. 807 Returns string representation of the addressee.
808 */ 808 */
809 QString asString() const; 809 QString asString() const;
810 810
811 /** 811 /**
812 Set resource where the addressee is from. 812 Set resource where the addressee is from.
813 */ 813 */
814 void setResource( Resource *resource ); 814 void setResource( Resource *resource );
815 815
816 /** 816 /**
817 Return pointer to resource. 817 Return pointer to resource.
818 */ 818 */
819 Resource *resource() const; 819 Resource *resource() const;
820 820
821 /** 821 /**
822 Return resourcelabel. 822 Return resourcelabel.
823 */ 823 */
824 //US 824 //US
825 static QString resourceLabel(); 825 static QString resourceLabel();
826 826
827 /** 827 /**
828 Mark addressee as changed. 828 Mark addressee as changed.
829 */ 829 */
830 void setChanged( bool value ); 830 void setChanged( bool value );
831 831
832 /** 832 /**
833 Return whether the addressee is changed. 833 Return whether the addressee is changed.
834 */ 834 */
835 bool changed() const; 835 bool changed() const;
836 836
837 void setTagged( bool value ); 837 void setTagged( bool value );
838 bool tagged() const; 838 bool tagged() const;
839 839
840 private: 840 private:
841 Addressee copy(); 841 Addressee copy();
842 void detach(); 842 void detach();
843 843
844 struct AddresseeData; 844 struct AddresseeData;
845 mutable KSharedPtr<AddresseeData> mData; 845 mutable KSharedPtr<AddresseeData> mData;
846}; 846};
847 847
848QDataStream &operator<<( QDataStream &, const Addressee & ); 848QDataStream &operator<<( QDataStream &, const Addressee & );
849QDataStream &operator>>( QDataStream &, Addressee & ); 849QDataStream &operator>>( QDataStream &, Addressee & );
850 850
851} 851}
852 852
853#endif 853#endif