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