summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2005-08-22 15:42:41 (UTC)
committer zautrix <zautrix>2005-08-22 15:42:41 (UTC)
commit1d82d044bbdedd407f6d08305522187ffd256552 (patch) (unidiff)
tree08f5651d72548b643ed012e5f6ad938b36d1ae3f /kabc
parentf516a558e6d18982a54152b28ca3da78fe76e3fc (diff)
downloadkdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.zip
kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.tar.gz
kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.tar.bz2
kapi search fix
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/address.cpp27
-rw-r--r--kabc/address.h2
-rw-r--r--kabc/addressee.cpp25
-rw-r--r--kabc/addressee.h4
4 files changed, 58 insertions, 0 deletions
diff --git a/kabc/address.cpp b/kabc/address.cpp
index 5ffe511..6151f9e 100644
--- a/kabc/address.cpp
+++ b/kabc/address.cpp
@@ -1,295 +1,322 @@
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//US added kglobal.h 28//US added kglobal.h
29#include <kglobal.h> 29#include <kglobal.h>
30 30
31#include <kapplication.h> 31#include <kapplication.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <ksimpleconfig.h> 34#include <ksimpleconfig.h>
35#include <kstandarddirs.h> 35#include <kstandarddirs.h>
36 36
37#include <qfile.h> 37#include <qfile.h>
38 38
39#include "address.h" 39#include "address.h"
40 40
41using namespace KABC; 41using namespace KABC;
42 42
43QMap<QString, QString> Address::mISOMap; 43QMap<QString, QString> Address::mISOMap;
44 44
45Address::Address() : 45Address::Address() :
46 mEmpty( true ), mType( 0 ) 46 mEmpty( true ), mType( 0 )
47{ 47{
48 mId = KApplication::randomString( 10 ); 48 mId = KApplication::randomString( 10 );
49} 49}
50 50
51Address::Address( int type ) : 51Address::Address( int type ) :
52 mEmpty( true ), mType( type ) 52 mEmpty( true ), mType( type )
53{ 53{
54 mId = KApplication::randomString( 10 ); 54 mId = KApplication::randomString( 10 );
55} 55}
56 56
57bool Address::operator==( const Address &a ) const 57bool Address::operator==( const Address &a ) const
58{ 58{
59 if ( mPostOfficeBox != a.mPostOfficeBox ) return false; 59 if ( mPostOfficeBox != a.mPostOfficeBox ) return false;
60 if ( mExtended != a.mExtended ) return false; 60 if ( mExtended != a.mExtended ) return false;
61 if ( mStreet != a.mStreet ) return false; 61 if ( mStreet != a.mStreet ) return false;
62 if ( mLocality != a.mLocality ) return false; 62 if ( mLocality != a.mLocality ) return false;
63 if ( mRegion != a.mRegion ) return false; 63 if ( mRegion != a.mRegion ) return false;
64 if ( mPostalCode != a.mPostalCode ) return false; 64 if ( mPostalCode != a.mPostalCode ) return false;
65 if ( mCountry != a.mCountry ) return false; 65 if ( mCountry != a.mCountry ) return false;
66 if ( mLabel != a.mLabel ) return false; 66 if ( mLabel != a.mLabel ) return false;
67 67
68 return true; 68 return true;
69} 69}
70 70
71bool Address::operator!=( const Address &a ) const 71bool Address::operator!=( const Address &a ) const
72{ 72{
73 return !( a == *this ); 73 return !( a == *this );
74} 74}
75 75
76bool Address::isEmpty() const 76bool Address::isEmpty() const
77{ 77{
78 if ( mPostOfficeBox.isEmpty() && 78 if ( mPostOfficeBox.isEmpty() &&
79 mExtended.isEmpty() && 79 mExtended.isEmpty() &&
80 mStreet.isEmpty() && 80 mStreet.isEmpty() &&
81 mLocality.isEmpty() && 81 mLocality.isEmpty() &&
82 mRegion.isEmpty() && 82 mRegion.isEmpty() &&
83 mPostalCode.isEmpty() && 83 mPostalCode.isEmpty() &&
84 mCountry.isEmpty() && 84 mCountry.isEmpty() &&
85 mLabel.isEmpty() ) { 85 mLabel.isEmpty() ) {
86 return true; 86 return true;
87 } 87 }
88 return false; 88 return false;
89} 89}
90 90
91QStringList Address::asList() 91QStringList Address::asList()
92{ 92{
93 QStringList result; 93 QStringList result;
94 if ( ! mPostOfficeBox.isEmpty() )result.append(mPostOfficeBox); 94 if ( ! mPostOfficeBox.isEmpty() )result.append(mPostOfficeBox);
95 if ( ! mExtended.isEmpty())result.append(mExtended); 95 if ( ! mExtended.isEmpty())result.append(mExtended);
96 if ( ! mStreet.isEmpty())result.append(mStreet); 96 if ( ! mStreet.isEmpty())result.append(mStreet);
97 if ( ! mLocality.isEmpty() )result.append(mLocality); 97 if ( ! mLocality.isEmpty() )result.append(mLocality);
98 if ( ! mRegion.isEmpty())result.append(mRegion); 98 if ( ! mRegion.isEmpty())result.append(mRegion);
99 if ( ! mPostalCode.isEmpty())result.append(mPostalCode); 99 if ( ! mPostalCode.isEmpty())result.append(mPostalCode);
100 if ( ! mCountry.isEmpty())result.append(mCountry); 100 if ( ! mCountry.isEmpty())result.append(mCountry);
101 if ( ! mLabel.isEmpty() )result.append(mLabel); 101 if ( ! mLabel.isEmpty() )result.append(mLabel);
102 return result; 102 return result;
103} 103}
104
105bool Address::matchAddress( QRegExp* re ) const
106{
107
108#if QT_VERSION >= 0x030000
109 if (re->search( mPostOfficeBox ) == 0) return true;
110 if (re->search( mExtended ) == 0) return true;
111 if (re->search( mStreet ) == 0) return true;
112 if (re->search( mLocality ) == 0) return true;
113 if (re->search( mRegion ) == 0) return true;
114 if (re->search( mPostalCode ) == 0) return true;
115 if (re->search( mCountry ) == 0) return true;
116 if (re->search( mLabel ) == 0) return true;
117#else
118 if (re->match( mPostOfficeBox ) == 0) return true;
119 if (re->match( mExtended ) == 0) return true;
120 if (re->match( mStreet ) == 0) return true;
121 if (re->match( mLocality ) == 0) return true;
122 if (re->match( mRegion ) == 0) return true;
123 if (re->match( mPostalCode ) == 0) return true;
124 if (re->match( mCountry ) == 0) return true;
125 if (re->match( mLabel ) == 0) return true;
126#endif
127
128 return false;
129}
130
104void Address::clear() 131void Address::clear()
105{ 132{
106 *this = Address(); 133 *this = Address();
107} 134}
108 135
109void Address::setId( const QString &id ) 136void Address::setId( const QString &id )
110{ 137{
111 mEmpty = false; 138 mEmpty = false;
112 139
113 mId = id; 140 mId = id;
114} 141}
115 142
116QString Address::id() const 143QString Address::id() const
117{ 144{
118 return mId; 145 return mId;
119} 146}
120 147
121void Address::setType( int type ) 148void Address::setType( int type )
122{ 149{
123 mEmpty = false; 150 mEmpty = false;
124 151
125 mType = type; 152 mType = type;
126} 153}
127 154
128int Address::type() const 155int Address::type() const
129{ 156{
130 return mType; 157 return mType;
131} 158}
132 159
133QString Address::typeLabel() const 160QString Address::typeLabel() const
134{ 161{
135 QString label; 162 QString label;
136 bool first = true; 163 bool first = true;
137 164
138 TypeList list = typeList(); 165 TypeList list = typeList();
139 166
140 TypeList::Iterator it; 167 TypeList::Iterator it;
141 for ( it = list.begin(); it != list.end(); ++it ) { 168 for ( it = list.begin(); it != list.end(); ++it ) {
142 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { 169 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
143 label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); 170 label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
144 if ( first ) 171 if ( first )
145 first = false; 172 first = false;
146 } 173 }
147 } 174 }
148 175
149 return label; 176 return label;
150} 177}
151 178
152void Address::setPostOfficeBox( const QString &s ) 179void Address::setPostOfficeBox( const QString &s )
153{ 180{
154 mEmpty = false; 181 mEmpty = false;
155 182
156 mPostOfficeBox = s; 183 mPostOfficeBox = s;
157} 184}
158 185
159QString Address::postOfficeBox() const 186QString Address::postOfficeBox() const
160{ 187{
161 return mPostOfficeBox; 188 return mPostOfficeBox;
162} 189}
163 190
164QString Address::postOfficeBoxLabel() 191QString Address::postOfficeBoxLabel()
165{ 192{
166 return i18n("Post Office Box"); 193 return i18n("Post Office Box");
167} 194}
168 195
169 196
170void Address::setExtended( const QString &s ) 197void Address::setExtended( const QString &s )
171{ 198{
172 mEmpty = false; 199 mEmpty = false;
173 200
174 mExtended = s; 201 mExtended = s;
175} 202}
176 203
177QString Address::extended() const 204QString Address::extended() const
178{ 205{
179 return mExtended; 206 return mExtended;
180} 207}
181 208
182QString Address::extendedLabel() 209QString Address::extendedLabel()
183{ 210{
184 return i18n("Extended Address Information"); 211 return i18n("Extended Address Information");
185} 212}
186 213
187 214
188void Address::setStreet( const QString &s ) 215void Address::setStreet( const QString &s )
189{ 216{
190 mEmpty = false; 217 mEmpty = false;
191 218
192 mStreet = s; 219 mStreet = s;
193} 220}
194 221
195QString Address::street() const 222QString Address::street() const
196{ 223{
197 return mStreet; 224 return mStreet;
198} 225}
199 226
200QString Address::streetLabel() 227QString Address::streetLabel()
201{ 228{
202 return i18n("Street"); 229 return i18n("Street");
203} 230}
204 231
205 232
206void Address::setLocality( const QString &s ) 233void Address::setLocality( const QString &s )
207{ 234{
208 mEmpty = false; 235 mEmpty = false;
209 236
210 mLocality = s; 237 mLocality = s;
211} 238}
212 239
213QString Address::locality() const 240QString Address::locality() const
214{ 241{
215 return mLocality; 242 return mLocality;
216} 243}
217 244
218QString Address::localityLabel() 245QString Address::localityLabel()
219{ 246{
220 return i18n("Locality"); 247 return i18n("Locality");
221} 248}
222 249
223 250
224void Address::setRegion( const QString &s ) 251void Address::setRegion( const QString &s )
225{ 252{
226 mEmpty = false; 253 mEmpty = false;
227 254
228 mRegion = s; 255 mRegion = s;
229} 256}
230 257
231QString Address::region() const 258QString Address::region() const
232{ 259{
233 return mRegion; 260 return mRegion;
234} 261}
235 262
236QString Address::regionLabel() 263QString Address::regionLabel()
237{ 264{
238 return i18n("Region"); 265 return i18n("Region");
239} 266}
240 267
241 268
242void Address::setPostalCode( const QString &s ) 269void Address::setPostalCode( const QString &s )
243{ 270{
244 mEmpty = false; 271 mEmpty = false;
245 272
246 mPostalCode = s; 273 mPostalCode = s;
247} 274}
248 275
249QString Address::postalCode() const 276QString Address::postalCode() const
250{ 277{
251 return mPostalCode; 278 return mPostalCode;
252} 279}
253 280
254QString Address::postalCodeLabel() 281QString Address::postalCodeLabel()
255{ 282{
256 return i18n("Postal Code"); 283 return i18n("Postal Code");
257} 284}
258 285
259 286
260void Address::setCountry( const QString &s ) 287void Address::setCountry( const QString &s )
261{ 288{
262 mEmpty = false; 289 mEmpty = false;
263 290
264 mCountry = s; 291 mCountry = s;
265} 292}
266 293
267QString Address::country() const 294QString Address::country() const
268{ 295{
269 return mCountry; 296 return mCountry;
270} 297}
271 298
272QString Address::countryLabel() 299QString Address::countryLabel()
273{ 300{
274 return i18n("Country"); 301 return i18n("Country");
275} 302}
276 303
277 304
278void Address::setLabel( const QString &s ) 305void Address::setLabel( const QString &s )
279{ 306{
280 mEmpty = false; 307 mEmpty = false;
281 308
282 mLabel = s; 309 mLabel = s;
283} 310}
284 311
285QString Address::label() const 312QString Address::label() const
286{ 313{
287 return mLabel; 314 return mLabel;
288} 315}
289 316
290QString Address::labelLabel() 317QString Address::labelLabel()
291{ 318{
292 return i18n("Delivery Label"); 319 return i18n("Delivery Label");
293} 320}
294 321
295Address::TypeList Address::typeList() 322Address::TypeList Address::typeList()
diff --git a/kabc/address.h b/kabc/address.h
index 37dd851..38ad20b 100644
--- a/kabc/address.h
+++ b/kabc/address.h
@@ -1,289 +1,291 @@
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_ADDRESS_H 28#ifndef KABC_ADDRESS_H
29#define KABC_ADDRESS_H 29#define KABC_ADDRESS_H
30 30
31#include <qmap.h> 31#include <qmap.h>
32#include <qstring.h> 32#include <qstring.h>
33#include <qregexp.h>
33#include <qstringlist.h> 34#include <qstringlist.h>
34#include <qvaluelist.h> 35#include <qvaluelist.h>
35 36
36// template tags for address formatting localization 37// template tags for address formatting localization
37#define KABC_FMTTAG_realname QString("%n") 38#define KABC_FMTTAG_realname QString("%n")
38#define KABC_FMTTAG_REALNAME QString("%N") 39#define KABC_FMTTAG_REALNAME QString("%N")
39#define KABC_FMTTAG_company QString("%cm") 40#define KABC_FMTTAG_company QString("%cm")
40#define KABC_FMTTAG_COMPANY QString("%CM") 41#define KABC_FMTTAG_COMPANY QString("%CM")
41#define KABC_FMTTAG_pobox QString("%p") 42#define KABC_FMTTAG_pobox QString("%p")
42#define KABC_FMTTAG_street QString("%s") 43#define KABC_FMTTAG_street QString("%s")
43#define KABC_FMTTAG_STREET QString("%S") 44#define KABC_FMTTAG_STREET QString("%S")
44#define KABC_FMTTAG_zipcode QString("%z") 45#define KABC_FMTTAG_zipcode QString("%z")
45#define KABC_FMTTAG_location QString("%l") 46#define KABC_FMTTAG_location QString("%l")
46#define KABC_FMTTAG_LOCATION QString("%L") 47#define KABC_FMTTAG_LOCATION QString("%L")
47#define KABC_FMTTAG_region QString("%r") 48#define KABC_FMTTAG_region QString("%r")
48#define KABC_FMTTAG_REGION QString("%R") 49#define KABC_FMTTAG_REGION QString("%R")
49#define KABC_FMTTAG_newline QString("\\n") 50#define KABC_FMTTAG_newline QString("\\n")
50#define KABC_FMTTAG_condcomma QString("%,") 51#define KABC_FMTTAG_condcomma QString("%,")
51#define KABC_FMTTAG_condwhite QString("%w") 52#define KABC_FMTTAG_condwhite QString("%w")
52#define KABC_FMTTAG_purgeempty QString("%0") 53#define KABC_FMTTAG_purgeempty QString("%0")
53 54
54namespace KABC { 55namespace KABC {
55 56
56/** 57/**
57 @short Postal address information. 58 @short Postal address information.
58 59
59 This class represents information about a postal address. 60 This class represents information about a postal address.
60*/ 61*/
61class Address 62class Address
62{ 63{
63 friend QDataStream &operator<<( QDataStream &, const Address & ); 64 friend QDataStream &operator<<( QDataStream &, const Address & );
64 friend QDataStream &operator>>( QDataStream &, Address & ); 65 friend QDataStream &operator>>( QDataStream &, Address & );
65 66
66 public: 67 public:
67 /** 68 /**
68 List of addresses. 69 List of addresses.
69 */ 70 */
70 typedef QValueList<Address> List; 71 typedef QValueList<Address> List;
71 typedef QValueList<int> TypeList; 72 typedef QValueList<int> TypeList;
72 73
73 /** 74 /**
74 Address types: 75 Address types:
75 76
76 @li @p Dom - domestic 77 @li @p Dom - domestic
77 @li @p Intl - international 78 @li @p Intl - international
78 @li @p Postal - postal 79 @li @p Postal - postal
79 @li @p Parcel - parcel 80 @li @p Parcel - parcel
80 @li @p Home - home address 81 @li @p Home - home address
81 @li @p Work - address at work 82 @li @p Work - address at work
82 @li @p Pref - preferred address 83 @li @p Pref - preferred address
83 */ 84 */
84 enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32, 85 enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32,
85 Pref = 64 }; 86 Pref = 64 };
86 87
87 /** 88 /**
88 Constructor that creates an empty Address, which is initialized 89 Constructor that creates an empty Address, which is initialized
89 with a unique id (see @ref id()). 90 with a unique id (see @ref id()).
90 */ 91 */
91 Address(); 92 Address();
92 93
93 /** 94 /**
94 This is like @ref Address() just above, with the difference 95 This is like @ref Address() just above, with the difference
95 that you can specify the type. 96 that you can specify the type.
96 */ 97 */
97 Address( int ); 98 Address( int );
99 bool matchAddress( QRegExp* searchExp ) const;
98 100
99 bool operator==( const Address & ) const; 101 bool operator==( const Address & ) const;
100 bool operator!=( const Address & ) const; 102 bool operator!=( const Address & ) const;
101 103
102 /** 104 /**
103 Returns true, if the address is empty. 105 Returns true, if the address is empty.
104 */ 106 */
105 bool isEmpty() const; 107 bool isEmpty() const;
106 108
107 /** 109 /**
108 Clears all entries of the address. 110 Clears all entries of the address.
109 */ 111 */
110 void clear(); 112 void clear();
111 QStringList asList(); 113 QStringList asList();
112 114
113 /** 115 /**
114 Sets the unique id. 116 Sets the unique id.
115 */ 117 */
116 void setId( const QString & ); 118 void setId( const QString & );
117 119
118 /* 120 /*
119 Returns the unique id. 121 Returns the unique id.
120 */ 122 */
121 QString id() const; 123 QString id() const;
122 124
123 /** 125 /**
124 Sets the type of address. See enum for definiton of types. 126 Sets the type of address. See enum for definiton of types.
125 127
126 @param type type, can be a bitwise or of multiple types. 128 @param type type, can be a bitwise or of multiple types.
127 */ 129 */
128 void setType( int type ); 130 void setType( int type );
129 131
130 /** 132 /**
131 Returns the type of address. Can be a bitwise or of multiple types. 133 Returns the type of address. Can be a bitwise or of multiple types.
132 */ 134 */
133 int type() const; 135 int type() const;
134 136
135 /** 137 /**
136 Returns a translated string of all types the address has. 138 Returns a translated string of all types the address has.
137 */ 139 */
138 QString typeLabel() const; 140 QString typeLabel() const;
139 141
140 /** 142 /**
141 Sets the post office box. 143 Sets the post office box.
142 */ 144 */
143 void setPostOfficeBox( const QString & ); 145 void setPostOfficeBox( const QString & );
144 146
145 /** 147 /**
146 Returns the post office box. 148 Returns the post office box.
147 */ 149 */
148 QString postOfficeBox() const; 150 QString postOfficeBox() const;
149 151
150 /** 152 /**
151 Returns the translated label for post office box field. 153 Returns the translated label for post office box field.
152 */ 154 */
153 static QString postOfficeBoxLabel(); 155 static QString postOfficeBoxLabel();
154 156
155 /** 157 /**
156 Sets the extended address information. 158 Sets the extended address information.
157 */ 159 */
158 void setExtended( const QString & ); 160 void setExtended( const QString & );
159 161
160 /** 162 /**
161 Returns the extended address information. 163 Returns the extended address information.
162 */ 164 */
163 QString extended() const; 165 QString extended() const;
164 166
165 /** 167 /**
166 Returns the translated label for extended field. 168 Returns the translated label for extended field.
167 */ 169 */
168 static QString extendedLabel(); 170 static QString extendedLabel();
169 171
170 /** 172 /**
171 Sets the street (including number). 173 Sets the street (including number).
172 */ 174 */
173 void setStreet( const QString & ); 175 void setStreet( const QString & );
174 176
175 /** 177 /**
176 Returns the street. 178 Returns the street.
177 */ 179 */
178 QString street() const; 180 QString street() const;
179 181
180 /** 182 /**
181 Returns the translated label for street field. 183 Returns the translated label for street field.
182 */ 184 */
183 static QString streetLabel(); 185 static QString streetLabel();
184 186
185 /** 187 /**
186 Sets the locality, e.g. city. 188 Sets the locality, e.g. city.
187 */ 189 */
188 void setLocality( const QString & ); 190 void setLocality( const QString & );
189 191
190 /** 192 /**
191 Returns the locality. 193 Returns the locality.
192 */ 194 */
193 QString locality() const; 195 QString locality() const;
194 196
195 /** 197 /**
196 Returns the translated label for locality field. 198 Returns the translated label for locality field.
197 */ 199 */
198 static QString localityLabel(); 200 static QString localityLabel();
199 201
200 /** 202 /**
201 Sets the region, e.g. state. 203 Sets the region, e.g. state.
202 */ 204 */
203 void setRegion( const QString & ); 205 void setRegion( const QString & );
204 206
205 /** 207 /**
206 Returns the region. 208 Returns the region.
207 */ 209 */
208 QString region() const; 210 QString region() const;
209 211
210 /** 212 /**
211 Returns the translated label for region field. 213 Returns the translated label for region field.
212 */ 214 */
213 static QString regionLabel(); 215 static QString regionLabel();
214 216
215 /** 217 /**
216 Sets the postal code. 218 Sets the postal code.
217 */ 219 */
218 void setPostalCode( const QString & ); 220 void setPostalCode( const QString & );
219 221
220 /** 222 /**
221 Returns the postal code. 223 Returns the postal code.
222 */ 224 */
223 QString postalCode() const; 225 QString postalCode() const;
224 226
225 /** 227 /**
226 Returns the translated label for postal code field. 228 Returns the translated label for postal code field.
227 */ 229 */
228 static QString postalCodeLabel(); 230 static QString postalCodeLabel();
229 231
230 /** 232 /**
231 Sets the country. 233 Sets the country.
232 */ 234 */
233 void setCountry( const QString & ); 235 void setCountry( const QString & );
234 236
235 /** 237 /**
236 Returns the country. 238 Returns the country.
237 */ 239 */
238 QString country() const; 240 QString country() const;
239 241
240 /** 242 /**
241 Returns the translated label for country field. 243 Returns the translated label for country field.
242 */ 244 */
243 static QString countryLabel(); 245 static QString countryLabel();
244 246
245 /** 247 /**
246 Sets the delivery label. This is the literal text to be used as label. 248 Sets the delivery label. This is the literal text to be used as label.
247 */ 249 */
248 void setLabel( const QString & ); 250 void setLabel( const QString & );
249 251
250 /** 252 /**
251 Returns the delivery label. 253 Returns the delivery label.
252 */ 254 */
253 QString label() const; 255 QString label() const;
254 256
255 /** 257 /**
256 Returns the translated label for delivery label field. 258 Returns the translated label for delivery label field.
257 */ 259 */
258 static QString labelLabel(); 260 static QString labelLabel();
259 261
260 /** 262 /**
261 Returns the list of available types. 263 Returns the list of available types.
262 */ 264 */
263 static TypeList typeList(); 265 static TypeList typeList();
264 266
265 /** 267 /**
266 Returns the translated label for a special type. 268 Returns the translated label for a special type.
267 */ 269 */
268 static QString typeLabel( int type ); 270 static QString typeLabel( int type );
269 271
270 /** 272 /**
271 Used for debug output. 273 Used for debug output.
272 */ 274 */
273 void dump() const; 275 void dump() const;
274 276
275 /** 277 /**
276 Returns this address formatted according to the country-specific 278 Returns this address formatted according to the country-specific
277 address formatting rules. The formatting rules applied depend on 279 address formatting rules. The formatting rules applied depend on
278 either the addresses {@link #country country} field, or (if the 280 either the addresses {@link #country country} field, or (if the
279 latter is empty) on the system country setting. If companyName is 281 latter is empty) on the system country setting. If companyName is
280 provided, an available business address format will be preferred. 282 provided, an available business address format will be preferred.
281 283
282 @param realName the formatted name of the contact 284 @param realName the formatted name of the contact
283 @param orgaName the name of the organization or company 285 @param orgaName the name of the organization or company
284 @return the formatted address (containing newline characters) 286 @return the formatted address (containing newline characters)
285 */ 287 */
286 QString formattedAddress( const QString &realName=QString::null 288 QString formattedAddress( const QString &realName=QString::null
287 , const QString &orgaName=QString::null ) const; 289 , const QString &orgaName=QString::null ) const;
288 290
289 /** 291 /**
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 155ce24..7e1e414 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -117,385 +117,410 @@ Addressee &Addressee::operator=( const Addressee &a )
117 return (*this); 117 return (*this);
118} 118}
119 119
120Addressee Addressee::copy() 120Addressee Addressee::copy()
121{ 121{
122 Addressee a; 122 Addressee a;
123 *(a.mData) = *mData; 123 *(a.mData) = *mData;
124 return a; 124 return a;
125} 125}
126 126
127void Addressee::detach() 127void Addressee::detach()
128{ 128{
129 if ( mData.count() == 1 ) return; 129 if ( mData.count() == 1 ) return;
130 *this = copy(); 130 *this = copy();
131} 131}
132 132
133bool Addressee::operator==( const Addressee &a ) const 133bool Addressee::operator==( const Addressee &a ) const
134{ 134{
135 if ( uid() != a.uid() ) return false; 135 if ( uid() != a.uid() ) return false;
136 if ( mData->name != a.mData->name ) return false; 136 if ( mData->name != a.mData->name ) return false;
137 if ( mData->formattedName != a.mData->formattedName ) return false; 137 if ( mData->formattedName != a.mData->formattedName ) return false;
138 if ( mData->familyName != a.mData->familyName ) return false; 138 if ( mData->familyName != a.mData->familyName ) return false;
139 if ( mData->givenName != a.mData->givenName ) return false; 139 if ( mData->givenName != a.mData->givenName ) return false;
140 if ( mData->additionalName != a.mData->additionalName ) return false; 140 if ( mData->additionalName != a.mData->additionalName ) return false;
141 if ( mData->prefix != a.mData->prefix ) return false; 141 if ( mData->prefix != a.mData->prefix ) return false;
142 if ( mData->suffix != a.mData->suffix ) return false; 142 if ( mData->suffix != a.mData->suffix ) return false;
143 if ( mData->nickName != a.mData->nickName ) return false; 143 if ( mData->nickName != a.mData->nickName ) return false;
144 if ( mData->birthday != a.mData->birthday ) return false; 144 if ( mData->birthday != a.mData->birthday ) return false;
145 if ( mData->mailer != a.mData->mailer ) return false; 145 if ( mData->mailer != a.mData->mailer ) return false;
146 if ( mData->timeZone != a.mData->timeZone ) return false; 146 if ( mData->timeZone != a.mData->timeZone ) return false;
147 if ( mData->geo != a.mData->geo ) return false; 147 if ( mData->geo != a.mData->geo ) return false;
148 if ( mData->title != a.mData->title ) return false; 148 if ( mData->title != a.mData->title ) return false;
149 if ( mData->role != a.mData->role ) return false; 149 if ( mData->role != a.mData->role ) return false;
150 if ( mData->organization != a.mData->organization ) return false; 150 if ( mData->organization != a.mData->organization ) return false;
151 if ( mData->note != a.mData->note ) return false; 151 if ( mData->note != a.mData->note ) return false;
152 if ( mData->productId != a.mData->productId ) return false; 152 if ( mData->productId != a.mData->productId ) return false;
153 //if ( mData->revision != a.mData->revision ) return false; 153 //if ( mData->revision != a.mData->revision ) return false;
154 if ( mData->sortString != a.mData->sortString ) return false; 154 if ( mData->sortString != a.mData->sortString ) return false;
155 if ( mData->secrecy != a.mData->secrecy ) return false; 155 if ( mData->secrecy != a.mData->secrecy ) return false;
156 if ( mData->logo != a.mData->logo ) return false; 156 if ( mData->logo != a.mData->logo ) return false;
157 if ( mData->photo != a.mData->photo ) return false; 157 if ( mData->photo != a.mData->photo ) return false;
158 if ( mData->sound != a.mData->sound ) return false; 158 if ( mData->sound != a.mData->sound ) return false;
159 if ( mData->agent != a.mData->agent ) return false; 159 if ( mData->agent != a.mData->agent ) return false;
160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
161 ( mData->url != a.mData->url ) ) return false; 161 ( mData->url != a.mData->url ) ) return false;
162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
163 if ( mData->addresses != a.mData->addresses ) return false; 163 if ( mData->addresses != a.mData->addresses ) return false;
164 if ( mData->keys != a.mData->keys ) return false; 164 if ( mData->keys != a.mData->keys ) return false;
165 if ( mData->emails != a.mData->emails ) return false; 165 if ( mData->emails != a.mData->emails ) return false;
166 if ( mData->categories != a.mData->categories ) return false; 166 if ( mData->categories != a.mData->categories ) return false;
167 if ( mData->custom != a.mData->custom ) return false; 167 if ( mData->custom != a.mData->custom ) return false;
168 168
169 return true; 169 return true;
170} 170}
171 171
172bool Addressee::operator!=( const Addressee &a ) const 172bool Addressee::operator!=( const Addressee &a ) const
173{ 173{
174 return !( a == *this ); 174 return !( a == *this );
175} 175}
176 176
177bool Addressee::isEmpty() const 177bool Addressee::isEmpty() const
178{ 178{
179 return mData->empty; 179 return mData->empty;
180} 180}
181ulong Addressee::getCsum4List( const QStringList & attList) 181ulong Addressee::getCsum4List( const QStringList & attList)
182{ 182{
183 int max = attList.count(); 183 int max = attList.count();
184 ulong cSum = 0; 184 ulong cSum = 0;
185 int j,k,i; 185 int j,k,i;
186 int add; 186 int add;
187 for ( i = 0; i < max ; ++i ) { 187 for ( i = 0; i < max ; ++i ) {
188 QString s = attList[i]; 188 QString s = attList[i];
189 if ( ! s.isEmpty() ){ 189 if ( ! s.isEmpty() ){
190 j = s.length(); 190 j = s.length();
191 for ( k = 0; k < j; ++k ) { 191 for ( k = 0; k < j; ++k ) {
192 int mul = k +1; 192 int mul = k +1;
193 add = s[k].unicode (); 193 add = s[k].unicode ();
194 if ( k < 16 ) 194 if ( k < 16 )
195 mul = mul * mul; 195 mul = mul * mul;
196 int ii = i+1; 196 int ii = i+1;
197 add = add * mul *ii*ii*ii; 197 add = add * mul *ii*ii*ii;
198 cSum += add; 198 cSum += add;
199 //qDebug("csum: %d %d %d", i,k,cSum); 199 //qDebug("csum: %d %d %d", i,k,cSum);
200 } 200 }
201 } 201 }
202 202
203 } 203 }
204 //QString dump = attList.join(","); 204 //QString dump = attList.join(",");
205 //qDebug("csum: %d %s", cSum,dump.latin1()); 205 //qDebug("csum: %d %s", cSum,dump.latin1());
206 206
207 return cSum; 207 return cSum;
208 208
209} 209}
210void Addressee::computeCsum(const QString &dev) 210void Addressee::computeCsum(const QString &dev)
211{ 211{
212 QStringList l; 212 QStringList l;
213 //if ( !mData->name.isEmpty() ) l.append(mData->name); 213 //if ( !mData->name.isEmpty() ) l.append(mData->name);
214 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 214 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
215 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 215 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
216 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 216 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
217 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); 217 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
218 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 218 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
219 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 219 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
220 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 220 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
221 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 221 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
222 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 222 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
223 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 223 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
224 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 224 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
225 if ( !mData->title .isEmpty() ) l.append( mData->title ); 225 if ( !mData->title .isEmpty() ) l.append( mData->title );
226 if ( !mData->role.isEmpty() ) l.append( mData->role ); 226 if ( !mData->role.isEmpty() ) l.append( mData->role );
227 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 227 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
228 if ( !mData->note.isEmpty() ) l.append( mData->note ); 228 if ( !mData->note.isEmpty() ) l.append( mData->note );
229 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 229 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
230 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 230 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
231 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 231 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
232 if ( !mData->logo.undefined() ) { 232 if ( !mData->logo.undefined() ) {
233 if ( !mData->logo.isIntern() ) 233 if ( !mData->logo.isIntern() )
234 l.append( mData->logo.url() ); 234 l.append( mData->logo.url() );
235 else 235 else
236 l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); 236 l.append( QString::number(mData->logo.data().width()* mData->logo.data().height()));
237 } else { 237 } else {
238 l.append( "nologo"); 238 l.append( "nologo");
239 } 239 }
240 if ( !mData->photo.undefined() ) { 240 if ( !mData->photo.undefined() ) {
241 if ( !mData->photo.isIntern() ) 241 if ( !mData->photo.isIntern() )
242 l.append( mData->photo.url() ); 242 l.append( mData->photo.url() );
243 else 243 else
244 l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); 244 l.append( QString::number(mData->photo.data().width()* mData->photo.data().height()));
245 } else { 245 } else {
246 l.append( "nophoto"); 246 l.append( "nophoto");
247 } 247 }
248#if 0 248#if 0
249 if ( !mData->sound.undefined() ) { 249 if ( !mData->sound.undefined() ) {
250 if ( !mData->sound.isIntern() ) 250 if ( !mData->sound.isIntern() )
251 l.append( mData->sound.url() ); 251 l.append( mData->sound.url() );
252 else 252 else
253 l.append( QString(mData->sound.data().with()* mData->sound.data().height())); 253 l.append( QString(mData->sound.data().with()* mData->sound.data().height()));
254 } else { 254 } else {
255 l.append( "nosound"); 255 l.append( "nosound");
256 } 256 }
257#endif 257#endif
258 //if ( !mData->agent.isEmpty() ) l.append( ); 258 //if ( !mData->agent.isEmpty() ) l.append( );
259 if ( mData->url.isValid() ) 259 if ( mData->url.isValid() )
260 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 260 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
261 KABC::PhoneNumber::List phoneNumbers; 261 KABC::PhoneNumber::List phoneNumbers;
262 KABC::PhoneNumber::List::Iterator phoneIter; 262 KABC::PhoneNumber::List::Iterator phoneIter;
263 263
264 QStringList t; 264 QStringList t;
265 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 265 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
266 ++phoneIter ) 266 ++phoneIter )
267 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 267 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
268 t.sort(); 268 t.sort();
269 uint iii; 269 uint iii;
270 for ( iii = 0; iii < t.count(); ++iii) 270 for ( iii = 0; iii < t.count(); ++iii)
271 l.append( t[iii] ); 271 l.append( t[iii] );
272 t = mData->emails; 272 t = mData->emails;
273 t.sort(); 273 t.sort();
274 for ( iii = 0; iii < t.count(); ++iii) 274 for ( iii = 0; iii < t.count(); ++iii)
275 l.append( t[iii] ); 275 l.append( t[iii] );
276 t = mData->categories; 276 t = mData->categories;
277 t.sort(); 277 t.sort();
278 for ( iii = 0; iii < t.count(); ++iii) 278 for ( iii = 0; iii < t.count(); ++iii)
279 l.append( t[iii] ); 279 l.append( t[iii] );
280 t = mData->custom; 280 t = mData->custom;
281 t.sort(); 281 t.sort();
282 for ( iii = 0; iii < t.count(); ++iii) 282 for ( iii = 0; iii < t.count(); ++iii)
283 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { 283 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
284 int find = t[iii].find (':')+1; 284 int find = t[iii].find (':')+1;
285 //qDebug("lennnn %d %d ", find, t[iii].length()); 285 //qDebug("lennnn %d %d ", find, t[iii].length());
286 if ( find < t[iii].length()) 286 if ( find < t[iii].length())
287 l.append( t[iii] ); 287 l.append( t[iii] );
288 288
289 } 289 }
290 KABC::Address::List::Iterator addressIter; 290 KABC::Address::List::Iterator addressIter;
291 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 291 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
292 ++addressIter ) { 292 ++addressIter ) {
293 t = (*addressIter).asList(); 293 t = (*addressIter).asList();
294 t.sort(); 294 t.sort();
295 for ( iii = 0; iii < t.count(); ++iii) 295 for ( iii = 0; iii < t.count(); ++iii)
296 l.append( t[iii] ); 296 l.append( t[iii] );
297 } 297 }
298 uint cs = getCsum4List(l); 298 uint cs = getCsum4List(l);
299 299
300#if 0 300#if 0
301 for ( iii = 0; iii < l.count(); ++iii) 301 for ( iii = 0; iii < l.count(); ++iii)
302 qDebug("%d***%s***",iii,l[iii].latin1()); 302 qDebug("%d***%s***",iii,l[iii].latin1());
303 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 303 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
304#endif 304#endif
305 305
306 306
307 setCsum( dev, QString::number (cs )); 307 setCsum( dev, QString::number (cs ));
308} 308}
309bool Addressee::matchAddress( QRegExp* re ) const
310{
311 KABC::Address::List::Iterator addressIter;
312 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
313 ++addressIter ) {
314 if ( (*addressIter).matchAddress( re ) )
315 return true;
316 }
317 return false;
318}
319bool Addressee::matchPhoneNumber( QRegExp* re ) const
320{
321 KABC::PhoneNumber::List::Iterator phoneIter;
322
323 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) {
324#if QT_VERSION >= 0x030000
325 if (re->search( (*phoneIter).number() ) == 0)
326#else
327 if (re->match( (*phoneIter).number() ) == 0)
328#endif
329 return true;
309 330
331 }
332 return false;
333
334}
310void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 335void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
311{ 336{
312 // merge all standard non-outlook fields. 337 // merge all standard non-outlook fields.
313 //if isSubSet (e.g. mobile phone sync) merge all fields 338 //if isSubSet (e.g. mobile phone sync) merge all fields
314 339
315 detach(); 340 detach();
316 if ( isSubSet ) { 341 if ( isSubSet ) {
317 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 342 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
318 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 343 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
319 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 344 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
320 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 345 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
321 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 346 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
322 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 347 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
323 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 348 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
324 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 349 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
325 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 350 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
326 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 351 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
327 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 352 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
328 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 353 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
329 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 354 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
330 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 355 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
331 if ( !mData->birthday.isValid() ) 356 if ( !mData->birthday.isValid() )
332 if ( ad.mData->birthday.isValid()) 357 if ( ad.mData->birthday.isValid())
333 mData->birthday = ad.mData->birthday; 358 mData->birthday = ad.mData->birthday;
334 359
335 } 360 }
336 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 361 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
337 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 362 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
338 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 363 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
339 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 364 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
340 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 365 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
341 QStringList t; 366 QStringList t;
342 QStringList tAD; 367 QStringList tAD;
343 uint iii; 368 uint iii;
344 369
345 // ********** phone numbers 370 // ********** phone numbers
346 if ( isSubSet ) { 371 if ( isSubSet ) {
347 PhoneNumber::List phoneAD = ad.phoneNumbers(); 372 PhoneNumber::List phoneAD = ad.phoneNumbers();
348 PhoneNumber::List::Iterator phoneItAD; 373 PhoneNumber::List::Iterator phoneItAD;
349 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 374 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
350 bool found = false; 375 bool found = false;
351 PhoneNumber::List::Iterator it; 376 PhoneNumber::List::Iterator it;
352 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 377 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
353 if ( ( *phoneItAD ).contains( (*it) ) ) { 378 if ( ( *phoneItAD ).contains( (*it) ) ) {
354 found = true; 379 found = true;
355 (*it).setType( ( *phoneItAD ).type() ); 380 (*it).setType( ( *phoneItAD ).type() );
356 (*it).setNumber( ( *phoneItAD ).number() ); 381 (*it).setNumber( ( *phoneItAD ).number() );
357 break; 382 break;
358 } 383 }
359 } 384 }
360 // if ( isSubSet && ! found ) 385 // if ( isSubSet && ! found )
361 if ( ! found ) // LR try this one... 386 if ( ! found ) // LR try this one...
362 mData->phoneNumbers.append( *phoneItAD ); 387 mData->phoneNumbers.append( *phoneItAD );
363 } 388 }
364 } else { 389 } else {
365 PhoneNumber::List phoneAD = ad.phoneNumbers(); 390 PhoneNumber::List phoneAD = ad.phoneNumbers();
366 PhoneNumber::List::Iterator phoneItAD; 391 PhoneNumber::List::Iterator phoneItAD;
367 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 392 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
368 bool found = false; 393 bool found = false;
369 PhoneNumber::List::Iterator it; 394 PhoneNumber::List::Iterator it;
370 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 395 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
371 if ( ( *phoneItAD ).contains( (*it) ) ) { 396 if ( ( *phoneItAD ).contains( (*it) ) ) {
372 found = true; 397 found = true;
373 (*it).setType( ( *phoneItAD ).type() ); 398 (*it).setType( ( *phoneItAD ).type() );
374 (*it).setNumber( ( *phoneItAD ).number() ); 399 (*it).setNumber( ( *phoneItAD ).number() );
375 break; 400 break;
376 } 401 }
377 } 402 }
378 if ( ! found ) { // append numbers which do not have work or home type 403 if ( ! found ) { // append numbers which do not have work or home type
379 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) 404 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) )
380 mData->phoneNumbers.append( *phoneItAD ); 405 mData->phoneNumbers.append( *phoneItAD );
381 } 406 }
382 } 407 }
383 } 408 }
384 if ( isSubSet ) { 409 if ( isSubSet ) {
385 // ************* emails; 410 // ************* emails;
386 t = mData->emails; 411 t = mData->emails;
387 tAD = ad.mData->emails; 412 tAD = ad.mData->emails;
388 for ( iii = 0; iii < tAD.count(); ++iii) 413 for ( iii = 0; iii < tAD.count(); ++iii)
389 if ( !t.contains(tAD[iii] ) ) 414 if ( !t.contains(tAD[iii] ) )
390 mData->emails.append( tAD[iii] ); 415 mData->emails.append( tAD[iii] );
391 } 416 }
392 417
393 // ************* categories; 418 // ************* categories;
394 if ( isSubSet ) { 419 if ( isSubSet ) {
395 t = mData->categories; 420 t = mData->categories;
396 tAD = ad.mData->categories; 421 tAD = ad.mData->categories;
397 for ( iii = 0; iii < tAD.count(); ++iii) 422 for ( iii = 0; iii < tAD.count(); ++iii)
398 if ( !t.contains(tAD[iii] ) ) 423 if ( !t.contains(tAD[iii] ) )
399 mData->categories.append( tAD[iii] ); 424 mData->categories.append( tAD[iii] );
400 } 425 }
401 QStringList::ConstIterator it; 426 QStringList::ConstIterator it;
402 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 427 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
403 QString qualifiedName = (*it).left( (*it).find( ":" )); 428 QString qualifiedName = (*it).left( (*it).find( ":" ));
404 bool found = false; 429 bool found = false;
405 QStringList::ConstIterator itL; 430 QStringList::ConstIterator itL;
406 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 431 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
407 if ( (*itL).startsWith( qualifiedName ) ) { 432 if ( (*itL).startsWith( qualifiedName ) ) {
408 found = true; 433 found = true;
409 break; 434 break;
410 } 435 }
411 } 436 }
412 if ( ! found ) { 437 if ( ! found ) {
413 mData->custom.append( *it ); 438 mData->custom.append( *it );
414 } 439 }
415 } 440 }
416 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 441 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
417 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 442 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
418 if ( !mData->sound.isIntern() ) { 443 if ( !mData->sound.isIntern() ) {
419 if ( mData->sound.url().isEmpty() ) { 444 if ( mData->sound.url().isEmpty() ) {
420 mData->sound = ad.mData->sound; 445 mData->sound = ad.mData->sound;
421 } 446 }
422 } 447 }
423 if ( !mData->agent.isIntern() ) { 448 if ( !mData->agent.isIntern() ) {
424 if ( mData->agent.url().isEmpty() ) { 449 if ( mData->agent.url().isEmpty() ) {
425 mData->agent = ad.mData->agent; 450 mData->agent = ad.mData->agent;
426 } 451 }
427 } 452 }
428 { 453 {
429 Key::List::Iterator itA; 454 Key::List::Iterator itA;
430 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 455 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
431 bool found = false; 456 bool found = false;
432 Key::List::Iterator it; 457 Key::List::Iterator it;
433 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 458 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
434 if ( (*it) == (*itA)) { 459 if ( (*it) == (*itA)) {
435 found = true; 460 found = true;
436 break; 461 break;
437 462
438 } 463 }
439 } 464 }
440 if ( ! found ) { 465 if ( ! found ) {
441 mData->keys.append( *itA ); 466 mData->keys.append( *itA );
442 } 467 }
443 } 468 }
444 } 469 }
445 if ( isSubSet ) { 470 if ( isSubSet ) {
446 KABC::Address::List::Iterator addressIterA; 471 KABC::Address::List::Iterator addressIterA;
447 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 472 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
448 bool found = false; 473 bool found = false;
449 KABC::Address::List::Iterator addressIter; 474 KABC::Address::List::Iterator addressIter;
450 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 475 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
451 ++addressIter ) { 476 ++addressIter ) {
452 if ( (*addressIter) == (*addressIterA)) { 477 if ( (*addressIter) == (*addressIterA)) {
453 found = true; 478 found = true;
454 (*addressIter).setType( (*addressIterA).type() ); 479 (*addressIter).setType( (*addressIterA).type() );
455 break; 480 break;
456 } 481 }
457 482
458 } 483 }
459 if ( isSubSet && ! found ) { 484 if ( isSubSet && ! found ) {
460 mData->addresses.append( *addressIterA ); 485 mData->addresses.append( *addressIterA );
461 } 486 }
462 } 487 }
463 } 488 }
464 //qDebug("merge contact %s ", ad.uid().latin1()); 489 //qDebug("merge contact %s ", ad.uid().latin1());
465 setUid( ad.uid() ); 490 setUid( ad.uid() );
466 setRevision( ad.revision() ); 491 setRevision( ad.revision() );
467} 492}
468 493
469bool Addressee::removeVoice() 494bool Addressee::removeVoice()
470{ 495{
471 PhoneNumber::List phoneN = phoneNumbers(); 496 PhoneNumber::List phoneN = phoneNumbers();
472 PhoneNumber::List::Iterator phoneIt; 497 PhoneNumber::List::Iterator phoneIt;
473 bool found = false; 498 bool found = false;
474 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 499 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
475 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 500 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
476 if ((*phoneIt).type() - PhoneNumber::Voice ) { 501 if ((*phoneIt).type() - PhoneNumber::Voice ) {
477 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 502 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
478 insertPhoneNumber( (*phoneIt) ); 503 insertPhoneNumber( (*phoneIt) );
479 found = true; 504 found = true;
480 } 505 }
481 } 506 }
482 507
483 } 508 }
484 return found; 509 return found;
485} 510}
486 511
487bool Addressee::containsAdr(const Addressee& ad ) 512bool Addressee::containsAdr(const Addressee& ad )
488{ 513{
489 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 514 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
490 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 515 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
491 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 516 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
492 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 517 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
493 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 518 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
494 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 519 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
495 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 520 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
496 521
497 // compare phone numbers 522 // compare phone numbers
498 PhoneNumber::List phoneN = ad.phoneNumbers(); 523 PhoneNumber::List phoneN = ad.phoneNumbers();
499 PhoneNumber::List::Iterator phoneIt; 524 PhoneNumber::List::Iterator phoneIt;
500 bool found = false; 525 bool found = false;
501 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 526 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
diff --git a/kabc/addressee.h b/kabc/addressee.h
index a2fbcf5..d1c07cb 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -1,225 +1,226 @@
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 <qregexp.h>
34#include <qstringlist.h> 35#include <qstringlist.h>
35#include <qvaluelist.h> 36#include <qvaluelist.h>
36 37
37#include <ksharedptr.h> 38#include <ksharedptr.h>
38#include <kurl.h> 39#include <kurl.h>
39 40
40#include "address.h" 41#include "address.h"
41#include "agent.h" 42#include "agent.h"
42#include "geo.h" 43#include "geo.h"
43#include "key.h" 44#include "key.h"
44#include "phonenumber.h" 45#include "phonenumber.h"
45#include "picture.h" 46#include "picture.h"
46#include "secrecy.h" 47#include "secrecy.h"
47#include "sound.h" 48#include "sound.h"
48#include "timezone.h" 49#include "timezone.h"
49 50
50namespace KABC { 51namespace KABC {
51 52
52class Resource; 53class Resource;
53 54
54/** 55/**
55 @short address book entry 56 @short address book entry
56 57
57 This class represents an entry in the address book. 58 This class represents an entry in the address book.
58 59
59 The data of this class is implicitly shared. You can pass this class by value. 60 The data of this class is implicitly shared. You can pass this class by value.
60 61
61 If you need the name of a field for presenting it to the user you should use 62 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 63 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 64 used as label for the corresponding field.
64 65
65 About the name fields: 66 About the name fields:
66 67
67 givenName() is the first name and familyName() the last name. In some 68 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 69 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 70 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 71 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 72 from the other name fields automatically.
72 73
73 realName() returns a fully formatted name(). It uses formattedName, if set, 74 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 75 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 76 nothing else is set it uses name().
76 77
77 name() is the NAME type of RFC2426. It can be used as internal name for the 78 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. 79 data enty, but shouldn't be used for displaying the data to the user.
79 */ 80 */
80class Addressee 81class Addressee
81{ 82{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 83 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 84 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 85
85 public: 86 public:
86 typedef QValueList<Addressee> List; 87 typedef QValueList<Addressee> List;
87 88
88 /** 89 /**
89 Construct an empty address book entry. 90 Construct an empty address book entry.
90 */ 91 */
91 Addressee(); 92 Addressee();
92 ~Addressee(); 93 ~Addressee();
93 94
94 Addressee( const Addressee & ); 95 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 96 Addressee &operator=( const Addressee & );
96 97
97 bool operator==( const Addressee & ) const; 98 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 99 bool operator!=( const Addressee & ) const;
99 // sync stuff 100 // sync stuff
100 void setTempSyncStat(int id); 101 void setTempSyncStat(int id);
101 int tempSyncStat() const; 102 int tempSyncStat() const;
102 void setIDStr( const QString & ); 103 void setIDStr( const QString & );
103 const QString IDStr() const; 104 const QString IDStr() const;
104 void setID( const QString &, const QString & ); 105 void setID( const QString &, const QString & );
105 const QString getID( const QString & ) const; 106 const QString getID( const QString & ) const;
106 void setCsum( const QString &, const QString & ); 107 void setCsum( const QString &, const QString & );
107 const QString getCsum( const QString & ) const ; 108 const QString getCsum( const QString & ) const ;
108 void removeID(const QString &); 109 void removeID(const QString &);
109 void computeCsum(const QString &dev); 110 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 111 ulong getCsum4List( const QStringList & attList);
111 /** 112 /**
112 Return, if the address book entry is empty. 113 Return, if the address book entry is empty.
113 */ 114 */
114 bool isEmpty() const; 115 bool isEmpty() const;
115 void setExternalUID( const QString &id ); 116 void setExternalUID( const QString &id );
116 const QString externalUID() const; 117 const QString externalUID() const;
117 void setOriginalExternalUID( const QString &id ); 118 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const; 119 QString originalExternalUID() const;
119 void mergeContact( const Addressee& ad, bool isSubSet ); 120 void mergeContact( const Addressee& ad, bool isSubSet );
120 void simplifyEmails(); 121 void simplifyEmails();
121 void simplifyAddresses(); 122 void simplifyAddresses();
122 void simplifyPhoneNumbers(); 123 void simplifyPhoneNumbers();
123 void simplifyPhoneNumberTypes(); 124 void simplifyPhoneNumberTypes();
124 bool removeVoice(); 125 bool removeVoice();
125 bool containsAdr(const Addressee& addr ); 126 bool containsAdr(const Addressee& addr );
126 127
127 /** 128 /**
128 Set unique identifier. 129 Set unique identifier.
129 */ 130 */
130 void setUid( const QString &uid ); 131 void setUid( const QString &uid );
131 /** 132 /**
132 Return unique identifier. 133 Return unique identifier.
133 */ 134 */
134 const QString uid() const; 135 const QString uid() const;
135 /** 136 /**
136 Return translated label for uid field. 137 Return translated label for uid field.
137 */ 138 */
138 static QString uidLabel(); 139 static QString uidLabel();
139 140
140 /** 141 /**
141 Set name. 142 Set name.
142 */ 143 */
143 void setName( const QString &name ); 144 void setName( const QString &name );
144 /** 145 /**
145 Return name. 146 Return name.
146 */ 147 */
147 QString name() const; 148 QString name() const;
148 /** 149 /**
149 Return translated label for name field. 150 Return translated label for name field.
150 */ 151 */
151 static QString nameLabel(); 152 static QString nameLabel();
152 153
153 /** 154 /**
154 Set formatted name. 155 Set formatted name.
155 */ 156 */
156 void setFormattedName( const QString &formattedName ); 157 void setFormattedName( const QString &formattedName );
157 /** 158 /**
158 Return formatted name. 159 Return formatted name.
159 */ 160 */
160 QString formattedName() const; 161 QString formattedName() const;
161 /** 162 /**
162 Return translated label for formattedName field. 163 Return translated label for formattedName field.
163 */ 164 */
164 static QString formattedNameLabel(); 165 static QString formattedNameLabel();
165 166
166 /** 167 /**
167 Set family name. 168 Set family name.
168 */ 169 */
169 void setFamilyName( const QString &familyName ); 170 void setFamilyName( const QString &familyName );
170 /** 171 /**
171 Return family name. 172 Return family name.
172 */ 173 */
173 QString familyName() const; 174 QString familyName() const;
174 /** 175 /**
175 Return translated label for familyName field. 176 Return translated label for familyName field.
176 */ 177 */
177 static QString familyNameLabel(); 178 static QString familyNameLabel();
178 179
179 /** 180 /**
180 Set given name. 181 Set given name.
181 */ 182 */
182 void setGivenName( const QString &givenName ); 183 void setGivenName( const QString &givenName );
183 /** 184 /**
184 Return given name. 185 Return given name.
185 */ 186 */
186 QString givenName() const; 187 QString givenName() const;
187 /** 188 /**
188 Return translated label for givenName field. 189 Return translated label for givenName field.
189 */ 190 */
190 static QString givenNameLabel(); 191 static QString givenNameLabel();
191 192
192 /** 193 /**
193 Set additional names. 194 Set additional names.
194 */ 195 */
195 void setAdditionalName( const QString &additionalName ); 196 void setAdditionalName( const QString &additionalName );
196 /** 197 /**
197 Return additional names. 198 Return additional names.
198 */ 199 */
199 QString additionalName() const; 200 QString additionalName() const;
200 /** 201 /**
201 Return translated label for additionalName field. 202 Return translated label for additionalName field.
202 */ 203 */
203 static QString additionalNameLabel(); 204 static QString additionalNameLabel();
204 205
205 /** 206 /**
206 Set honorific prefixes. 207 Set honorific prefixes.
207 */ 208 */
208 void setPrefix( const QString &prefix ); 209 void setPrefix( const QString &prefix );
209 /** 210 /**
210 Return honorific prefixes. 211 Return honorific prefixes.
211 */ 212 */
212 QString prefix() const; 213 QString prefix() const;
213 /** 214 /**
214 Return translated label for prefix field. 215 Return translated label for prefix field.
215 */ 216 */
216 static QString prefixLabel(); 217 static QString prefixLabel();
217 218
218 /** 219 /**
219 Set honorific suffixes. 220 Set honorific suffixes.
220 */ 221 */
221 void setSuffix( const QString &suffix ); 222 void setSuffix( const QString &suffix );
222 /** 223 /**
223 Return honorific suffixes. 224 Return honorific suffixes.
224 */ 225 */
225 QString suffix() const; 226 QString suffix() const;
@@ -461,384 +462,387 @@ class Addressee
461 Set product identifier. 462 Set product identifier.
462 */ 463 */
463 void setProductId( const QString &productId ); 464 void setProductId( const QString &productId );
464 /** 465 /**
465 Return product identifier. 466 Return product identifier.
466 */ 467 */
467 QString productId() const; 468 QString productId() const;
468 /** 469 /**
469 Return translated label for productId field. 470 Return translated label for productId field.
470 */ 471 */
471 static QString productIdLabel(); 472 static QString productIdLabel();
472 473
473 /** 474 /**
474 Set revision date. 475 Set revision date.
475 */ 476 */
476 void setRevision( const QDateTime &revision ); 477 void setRevision( const QDateTime &revision );
477 /** 478 /**
478 Return revision date. 479 Return revision date.
479 */ 480 */
480 QDateTime revision() const; 481 QDateTime revision() const;
481 /** 482 /**
482 Return translated label for revision field. 483 Return translated label for revision field.
483 */ 484 */
484 static QString revisionLabel(); 485 static QString revisionLabel();
485 486
486 /** 487 /**
487 Set sort string. 488 Set sort string.
488 */ 489 */
489 void setSortString( const QString &sortString ); 490 void setSortString( const QString &sortString );
490 /** 491 /**
491 Return sort string. 492 Return sort string.
492 */ 493 */
493 QString sortString() const; 494 QString sortString() const;
494 /** 495 /**
495 Return translated label for sortString field. 496 Return translated label for sortString field.
496 */ 497 */
497 static QString sortStringLabel(); 498 static QString sortStringLabel();
498 499
499 /** 500 /**
500 Set URL. 501 Set URL.
501 */ 502 */
502 void setUrl( const KURL &url ); 503 void setUrl( const KURL &url );
503 /** 504 /**
504 Return URL. 505 Return URL.
505 */ 506 */
506 KURL url() const; 507 KURL url() const;
507 /** 508 /**
508 Return translated label for url field. 509 Return translated label for url field.
509 */ 510 */
510 static QString urlLabel(); 511 static QString urlLabel();
511 512
512 /** 513 /**
513 Set security class. 514 Set security class.
514 */ 515 */
515 void setSecrecy( const Secrecy &secrecy ); 516 void setSecrecy( const Secrecy &secrecy );
516 /** 517 /**
517 Return security class. 518 Return security class.
518 */ 519 */
519 Secrecy secrecy() const; 520 Secrecy secrecy() const;
520 /** 521 /**
521 Return translated label for secrecy field. 522 Return translated label for secrecy field.
522 */ 523 */
523 static QString secrecyLabel(); 524 static QString secrecyLabel();
524 525
525 /** 526 /**
526 Set logo. 527 Set logo.
527 */ 528 */
528 void setLogo( const Picture &logo ); 529 void setLogo( const Picture &logo );
529 /** 530 /**
530 Return logo. 531 Return logo.
531 */ 532 */
532 Picture logo() const; 533 Picture logo() const;
533 /** 534 /**
534 Return translated label for logo field. 535 Return translated label for logo field.
535 */ 536 */
536 static QString logoLabel(); 537 static QString logoLabel();
537 538
538 /** 539 /**
539 Set photo. 540 Set photo.
540 */ 541 */
541 void setPhoto( const Picture &photo ); 542 void setPhoto( const Picture &photo );
542 /** 543 /**
543 Return photo. 544 Return photo.
544 */ 545 */
545 Picture photo() const; 546 Picture photo() const;
546 /** 547 /**
547 Return translated label for photo field. 548 Return translated label for photo field.
548 */ 549 */
549 static QString photoLabel(); 550 static QString photoLabel();
550 551
551 /** 552 /**
552 Set sound. 553 Set sound.
553 */ 554 */
554 void setSound( const Sound &sound ); 555 void setSound( const Sound &sound );
555 /** 556 /**
556 Return sound. 557 Return sound.
557 */ 558 */
558 Sound sound() const; 559 Sound sound() const;
559 /** 560 /**
560 Return translated label for sound field. 561 Return translated label for sound field.
561 */ 562 */
562 static QString soundLabel(); 563 static QString soundLabel();
563 564
564 /** 565 /**
565 Set agent. 566 Set agent.
566 */ 567 */
567 void setAgent( const Agent &agent ); 568 void setAgent( const Agent &agent );
568 /** 569 /**
569 Return agent. 570 Return agent.
570 */ 571 */
571 Agent agent() const; 572 Agent agent() const;
572 /** 573 /**
573 Return translated label for agent field. 574 Return translated label for agent field.
574 */ 575 */
575 static QString agentLabel(); 576 static QString agentLabel();
576 577
577 /** 578 /**
578 Set name fields by parsing the given string and trying to associate the 579 Set name fields by parsing the given string and trying to associate the
579 parts of the string with according fields. This function should probably 580 parts of the string with according fields. This function should probably
580 be a bit more clever. 581 be a bit more clever.
581 */ 582 */
582 void setNameFromString( const QString & ); 583 void setNameFromString( const QString & );
583 584
584 /** 585 /**
585 Return the name of the addressee. This is calculated from all the name 586 Return the name of the addressee. This is calculated from all the name
586 fields. 587 fields.
587 */ 588 */
588 QString realName() const; 589 QString realName() const;
589 590
590 /** 591 /**
591 Return the name that consists of all name parts. 592 Return the name that consists of all name parts.
592 */ 593 */
593 QString assembledName() const; 594 QString assembledName() const;
594 595
595 /** 596 /**
596 Return email address including real name. 597 Return email address including real name.
597 598
598 @param email Email address to be used to construct the full email string. 599 @param email Email address to be used to construct the full email string.
599 If this is QString::null the preferred email address is used. 600 If this is QString::null the preferred email address is used.
600 */ 601 */
601 QString fullEmail( const QString &email=QString::null ) const; 602 QString fullEmail( const QString &email=QString::null ) const;
602 603
603 /** 604 /**
604 Insert an email address. If the email address already exists in this 605 Insert an email address. If the email address already exists in this
605 addressee it is not duplicated. 606 addressee it is not duplicated.
606 607
607 @param email Email address 608 @param email Email address
608 @param preferred Set to true, if this is the preferred email address of 609 @param preferred Set to true, if this is the preferred email address of
609 the addressee. 610 the addressee.
610 */ 611 */
611 void insertEmail( const QString &email, bool preferred=false ); 612 void insertEmail( const QString &email, bool preferred=false );
612 613
613 /** 614 /**
614 Remove email address. If the email address doesn't exist, nothing happens. 615 Remove email address. If the email address doesn't exist, nothing happens.
615 */ 616 */
616 void removeEmail( const QString &email ); 617 void removeEmail( const QString &email );
617 618
618 /** 619 /**
619 Return preferred email address. This is the first email address or the 620 Return preferred email address. This is the first email address or the
620 last one added with @ref insertEmail() with a set preferred parameter. 621 last one added with @ref insertEmail() with a set preferred parameter.
621 */ 622 */
622 QString preferredEmail() const; 623 QString preferredEmail() const;
623 624
624 /** 625 /**
625 Return list of all email addresses. 626 Return list of all email addresses.
626 */ 627 */
627 QStringList emails() const; 628 QStringList emails() const;
628 629
629 /** 630 /**
630 Set the emails to @param. 631 Set the emails to @param.
631 The first email address gets the preferred one! 632 The first email address gets the preferred one!
632 @param list The list of email addresses. 633 @param list The list of email addresses.
633 */ 634 */
634 void setEmails( const QStringList& list); 635 void setEmails( const QStringList& list);
635 636
636 /** 637 /**
637 Insert a phone number. If a phone number with the same id already exists 638 Insert a phone number. If a phone number with the same id already exists
638 in this addressee it is not duplicated. 639 in this addressee it is not duplicated.
639 */ 640 */
640 void insertPhoneNumber( const PhoneNumber &phoneNumber ); 641 void insertPhoneNumber( const PhoneNumber &phoneNumber );
641 642
642 /** 643 /**
643 Remove phone number. If no phone number with the given id exists for this 644 Remove phone number. If no phone number with the given id exists for this
644 addresse nothing happens. 645 addresse nothing happens.
645 */ 646 */
646 void removePhoneNumber( const PhoneNumber &phoneNumber ); 647 void removePhoneNumber( const PhoneNumber &phoneNumber );
647 648
648 /** 649 /**
649 Return phone number, which matches the given type. 650 Return phone number, which matches the given type.
650 */ 651 */
651 PhoneNumber phoneNumber( int type ) const; 652 PhoneNumber phoneNumber( int type ) const;
652 653
654 bool matchPhoneNumber( QRegExp* searchExp ) const;
655 bool matchAddress( QRegExp* searchExp ) const;
656
653 /** 657 /**
654 Return list of all phone numbers. 658 Return list of all phone numbers.
655 */ 659 */
656 PhoneNumber::List phoneNumbers() const; 660 PhoneNumber::List phoneNumbers() const;
657 661
658 /** 662 /**
659 Return list of phone numbers with a special type. 663 Return list of phone numbers with a special type.
660 */ 664 */
661 PhoneNumber::List phoneNumbers( int type ) const; 665 PhoneNumber::List phoneNumbers( int type ) const;
662 666
663 /** 667 /**
664 Return phone number with the given id. 668 Return phone number with the given id.
665 */ 669 */
666 PhoneNumber findPhoneNumber( const QString &id ) const; 670 PhoneNumber findPhoneNumber( const QString &id ) const;
667 671
668 /** 672 /**
669 Insert a key. If a key with the same id already exists 673 Insert a key. If a key with the same id already exists
670 in this addressee it is not duplicated. 674 in this addressee it is not duplicated.
671 */ 675 */
672 void insertKey( const Key &key ); 676 void insertKey( const Key &key );
673 677
674 /** 678 /**
675 Remove a key. If no key with the given id exists for this 679 Remove a key. If no key with the given id exists for this
676 addresse nothing happens. 680 addresse nothing happens.
677 */ 681 */
678 void removeKey( const Key &key ); 682 void removeKey( const Key &key );
679 683
680 /** 684 /**
681 Return key, which matches the given type. 685 Return key, which matches the given type.
682 If @p type == Key::Custom you can specify a string 686 If @p type == Key::Custom you can specify a string
683 that should match. If you leave the string empty, the first 687 that should match. If you leave the string empty, the first
684 key with a custom value is returned. 688 key with a custom value is returned.
685 */ 689 */
686 Key key( int type, QString customTypeString = QString::null ) const; 690 Key key( int type, QString customTypeString = QString::null ) const;
687 691
688 /** 692 /**
689 Return list of all keys. 693 Return list of all keys.
690 */ 694 */
691 Key::List keys() const; 695 Key::List keys() const;
692 696
693 /** 697 /**
694 Set the list of keys 698 Set the list of keys
695 @param keys The keys to be set. 699 @param keys The keys to be set.
696 */ 700 */
697 void setKeys( const Key::List& keys); 701 void setKeys( const Key::List& keys);
698 702
699 /** 703 /**
700 Return list of keys with a special type. 704 Return list of keys with a special type.
701 If @p type == Key::Custom you can specify a string 705 If @p type == Key::Custom you can specify a string
702 that should match. If you leave the string empty, all custom 706 that should match. If you leave the string empty, all custom
703 keys will be returned. 707 keys will be returned.
704 */ 708 */
705 Key::List keys( int type, QString customTypeString = QString::null ) const; 709 Key::List keys( int type, QString customTypeString = QString::null ) const;
706 710
707 /** 711 /**
708 Return key with the given id. 712 Return key with the given id.
709 */ 713 */
710 Key findKey( const QString &id ) const; 714 Key findKey( const QString &id ) const;
711 715
712 /** 716 /**
713 Insert an address. If an address with the same id already exists 717 Insert an address. If an address with the same id already exists
714 in this addressee it is not duplicated. 718 in this addressee it is not duplicated.
715 */ 719 */
716 void insertAddress( const Address &address ); 720 void insertAddress( const Address &address );
717 721
718 /** 722 /**
719 Remove address. If no address with the given id exists for this 723 Remove address. If no address with the given id exists for this
720 addresse nothing happens. 724 addresse nothing happens.
721 */ 725 */
722 void removeAddress( const Address &address ); 726 void removeAddress( const Address &address );
723 727
724 /** 728 /**
725 Return address, which matches the given type. 729 Return address, which matches the given type.
726 */ 730 */
727 Address address( int type ) const; 731 Address address( int type ) const;
728 732
729 /** 733 /**
730 Return list of all addresses. 734 Return list of all addresses.
731 */ 735 */
732 Address::List addresses() const; 736 Address::List addresses() const;
733 737
734 /** 738 /**
735 Return list of addresses with a special type. 739 Return list of addresses with a special type.
736 */ 740 */
737 Address::List addresses( int type ) const; 741 Address::List addresses( int type ) const;
738 742
739 /** 743 /**
740 Return address with the given id. 744 Return address with the given id.
741 */ 745 */
742 Address findAddress( const QString &id ) const; 746 Address findAddress( const QString &id ) const;
743 747
744 /** 748 /**
745 Insert category. If the category already exists it is not duplicated. 749 Insert category. If the category already exists it is not duplicated.
746 */ 750 */
747 void insertCategory( const QString & ); 751 void insertCategory( const QString & );
748 752
749 /** 753 /**
750 Remove category. 754 Remove category.
751 */ 755 */
752 void removeCategory( const QString & ); 756 void removeCategory( const QString & );
753 757
754 /** 758 /**
755 Return, if addressee has the given category. 759 Return, if addressee has the given category.
756 */ 760 */
757 bool hasCategory( const QString & ) const; 761 bool hasCategory( const QString & ) const;
758 762
759 /** 763 /**
760 Set categories to given value. 764 Set categories to given value.
761 */ 765 */
762 void setCategories( const QStringList & ); 766 void setCategories( const QStringList & );
763 767
764 /** 768 /**
765 Return list of all set categories. 769 Return list of all set categories.
766 */ 770 */
767 QStringList categories() const; 771 QStringList categories() const;
768 772
769 /** 773 /**
770 Insert custom entry. The entry is identified by the name of the inserting 774 Insert custom entry. The entry is identified by the name of the inserting
771 application and a unique name. If an entry with the given app and name 775 application and a unique name. If an entry with the given app and name
772 already exists its value is replaced with the new given value. 776 already exists its value is replaced with the new given value.
773 */ 777 */
774 void insertCustom( const QString &app, const QString &name, 778 void insertCustom( const QString &app, const QString &name,
775 const QString &value ); 779 const QString &value );
776 780
777 /** 781 /**
778 Remove custom entry. 782 Remove custom entry.
779 */ 783 */
780 void removeCustom( const QString &app, const QString &name ); 784 void removeCustom( const QString &app, const QString &name );
781 785
782 /** 786 /**
783 Return value of custom entry, identified by app and entry name. 787 Return value of custom entry, identified by app and entry name.
784 */ 788 */
785 QString custom( const QString &app, const QString &name ) const; 789 QString custom( const QString &app, const QString &name ) const;
786 790
787 /** 791 /**
788 Set all custom entries. 792 Set all custom entries.
789 */ 793 */
790 void setCustoms( const QStringList & ); 794 void setCustoms( const QStringList & );
791 795
792 /** 796 /**
793 Return list of all custom entries. 797 Return list of all custom entries.
794 */ 798 */
795 QStringList customs() const; 799 QStringList customs() const;
796 800
797 /** 801 /**
798 Parse full email address. The result is given back in fullName and email. 802 Parse full email address. The result is given back in fullName and email.
799 */ 803 */
800 static void parseEmailAddress( const QString &rawEmail, QString &fullName, 804 static void parseEmailAddress( const QString &rawEmail, QString &fullName,
801 QString &email ); 805 QString &email );
802 806
803 /** 807 /**
804 Debug output. 808 Debug output.
805 */ 809 */
806 void dump() const; 810 void dump() const;
807 811
808 /** 812 /**
809 Returns string representation of the addressee. 813 Returns string representation of the addressee.
810 */ 814 */
811 QString asString() const; 815 QString asString() const;
812 816
813 /** 817 /**
814 Set resource where the addressee is from. 818 Set resource where the addressee is from.
815 */ 819 */
816 void setResource( Resource *resource ); 820 void setResource( Resource *resource );
817 821
818 /** 822 /**
819 Return pointer to resource. 823 Return pointer to resource.
820 */ 824 */
821 Resource *resource() const; 825 Resource *resource() const;
822 826
823 /** 827 /**
824 Return resourcelabel. 828 Return resourcelabel.
825 */ 829 */
826 //US 830 //US
827 static QString resourceLabel(); 831 static QString resourceLabel();
828 static QString categoryLabel(); 832 static QString categoryLabel();
829 /** 833 /**
830 Mark addressee as changed. 834 Mark addressee as changed.
831 */ 835 */
832 void setChanged( bool value ); 836 void setChanged( bool value );
833 837
834 /** 838 /**
835 Return whether the addressee is changed. 839 Return whether the addressee is changed.
836 */ 840 */
837 bool changed() const; 841 bool changed() const;
838 842
839 void setTagged( bool value ); 843 void setTagged( bool value );
840 bool tagged() const; 844 bool tagged() const;
841 845
842 private: 846 private:
843 Addressee copy(); 847 Addressee copy();
844 void detach(); 848 void detach();