summaryrefslogtreecommitdiffabout
path: root/kabc/field.cpp
Unidiff
Diffstat (limited to 'kabc/field.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/field.cpp12
1 files changed, 0 insertions, 12 deletions
diff --git a/kabc/field.cpp b/kabc/field.cpp
index 6f2b307..7c6d7a9 100644
--- a/kabc/field.cpp
+++ b/kabc/field.cpp
@@ -1,596 +1,584 @@
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) 2002 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2002 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 <klocale.h> 29#include <klocale.h>
30#include <kconfig.h> 30#include <kconfig.h>
31#include <kconfigbase.h> 31#include <kconfigbase.h>
32#include <kglobal.h> 32#include <kglobal.h>
33 33
34#include "field.h" 34#include "field.h"
35#include "resource.h" 35#include "resource.h"
36 36
37using namespace KABC; 37using namespace KABC;
38 38
39class Field::FieldImpl 39class Field::FieldImpl
40{ 40{
41 public: 41 public:
42 FieldImpl( int fieldId, int category = 0, 42 FieldImpl( int fieldId, int category = 0,
43 const QString &label = QString::null, 43 const QString &label = QString::null,
44 const QString &key = QString::null, 44 const QString &key = QString::null,
45 const QString &app = QString::null ) 45 const QString &app = QString::null )
46 : mFieldId( fieldId ), mCategory( category ), mLabel( label ), 46 : mFieldId( fieldId ), mCategory( category ), mLabel( label ),
47 mKey( key ), mApp( app ) {} 47 mKey( key ), mApp( app ) {}
48 48
49 enum FieldId 49 enum FieldId
50 { 50 {
51 CustomField, 51 CustomField,
52 FormattedName, 52 FormattedName,
53 FamilyName, 53 FamilyName,
54 GivenName, 54 GivenName,
55 AdditionalName, 55 AdditionalName,
56 Prefix, 56 Prefix,
57 Suffix, 57 Suffix,
58 NickName, 58 NickName,
59 Birthday, 59 Birthday,
60 Category, 60 Category,
61 HomeAddressStreet, 61 HomeAddressStreet,
62 HomeAddressLocality, 62 HomeAddressLocality,
63 HomeAddressRegion, 63 HomeAddressRegion,
64 HomeAddressPostalCode, 64 HomeAddressPostalCode,
65 HomeAddressCountry, 65 HomeAddressCountry,
66 HomeAddressLabel, 66 HomeAddressLabel,
67 BusinessAddressStreet, 67 BusinessAddressStreet,
68 BusinessAddressLocality, 68 BusinessAddressLocality,
69 BusinessAddressRegion, 69 BusinessAddressRegion,
70 BusinessAddressPostalCode, 70 BusinessAddressPostalCode,
71 BusinessAddressCountry, 71 BusinessAddressCountry,
72 BusinessAddressLabel, 72 BusinessAddressLabel,
73 HomePhone, 73 HomePhone,
74 BusinessPhone, 74 BusinessPhone,
75 MobilePhone, 75 MobilePhone,
76 HomeFax, 76 HomeFax,
77 BusinessFax, 77 BusinessFax,
78 CarPhone,
79 Isdn, 78 Isdn,
80 Pager, 79 Pager,
81 Email, 80 Email,
82 Mailer, 81 Mailer,
83 Title, 82 Title,
84 Role, 83 Role,
85 Organization, 84 Organization,
86 Note, 85 Note,
87 Url, 86 Url,
88 Resource, 87 Resource,
89 Sip, 88 Sip,
90 MobileWorkPhone, 89 MobileWorkPhone,
91 MobileHomePhone,
92 OtherPhone 90 OtherPhone
93 }; 91 };
94 92
95 int fieldId() { return mFieldId; } 93 int fieldId() { return mFieldId; }
96 int category() { return mCategory; } 94 int category() { return mCategory; }
97 95
98 QString label() { return mLabel; } 96 QString label() { return mLabel; }
99 QString key() { return mKey; } 97 QString key() { return mKey; }
100 QString app() { return mApp; } 98 QString app() { return mApp; }
101 99
102 private: 100 private:
103 int mFieldId; 101 int mFieldId;
104 int mCategory; 102 int mCategory;
105 103
106 QString mLabel; 104 QString mLabel;
107 QString mKey; 105 QString mKey;
108 QString mApp; 106 QString mApp;
109}; 107};
110 108
111 109
112Field::List Field::mAllFields; 110Field::List Field::mAllFields;
113Field::List Field::mDefaultFields; 111Field::List Field::mDefaultFields;
114Field::List Field::mCustomFields; 112Field::List Field::mCustomFields;
115 113
116 114
117Field::Field( FieldImpl *impl ) 115Field::Field( FieldImpl *impl )
118{ 116{
119 mImpl = impl; 117 mImpl = impl;
120} 118}
121 119
122Field::~Field() 120Field::~Field()
123{ 121{
124 delete mImpl; 122 delete mImpl;
125} 123}
126 124
127QString Field::label() 125QString Field::label()
128{ 126{
129 switch ( mImpl->fieldId() ) { 127 switch ( mImpl->fieldId() ) {
130 case FieldImpl::FormattedName: 128 case FieldImpl::FormattedName:
131 return Addressee::formattedNameLabel(); 129 return Addressee::formattedNameLabel();
132 case FieldImpl::FamilyName: 130 case FieldImpl::FamilyName:
133 return Addressee::familyNameLabel(); 131 return Addressee::familyNameLabel();
134 case FieldImpl::GivenName: 132 case FieldImpl::GivenName:
135 return Addressee::givenNameLabel(); 133 return Addressee::givenNameLabel();
136 case FieldImpl::AdditionalName: 134 case FieldImpl::AdditionalName:
137 return Addressee::additionalNameLabel(); 135 return Addressee::additionalNameLabel();
138 case FieldImpl::Prefix: 136 case FieldImpl::Prefix:
139 return Addressee::prefixLabel(); 137 return Addressee::prefixLabel();
140 case FieldImpl::Suffix: 138 case FieldImpl::Suffix:
141 return Addressee::suffixLabel(); 139 return Addressee::suffixLabel();
142 case FieldImpl::NickName: 140 case FieldImpl::NickName:
143 return Addressee::nickNameLabel(); 141 return Addressee::nickNameLabel();
144 case FieldImpl::Birthday: 142 case FieldImpl::Birthday:
145 return Addressee::birthdayLabel(); 143 return Addressee::birthdayLabel();
146 case FieldImpl::HomeAddressStreet: 144 case FieldImpl::HomeAddressStreet:
147 return Addressee::homeAddressStreetLabel(); 145 return Addressee::homeAddressStreetLabel();
148 case FieldImpl::HomeAddressLocality: 146 case FieldImpl::HomeAddressLocality:
149 return Addressee::homeAddressLocalityLabel(); 147 return Addressee::homeAddressLocalityLabel();
150 case FieldImpl::HomeAddressRegion: 148 case FieldImpl::HomeAddressRegion:
151 return Addressee::homeAddressRegionLabel(); 149 return Addressee::homeAddressRegionLabel();
152 case FieldImpl::HomeAddressPostalCode: 150 case FieldImpl::HomeAddressPostalCode:
153 return Addressee::homeAddressPostalCodeLabel(); 151 return Addressee::homeAddressPostalCodeLabel();
154 case FieldImpl::HomeAddressCountry: 152 case FieldImpl::HomeAddressCountry:
155 return Addressee::homeAddressCountryLabel(); 153 return Addressee::homeAddressCountryLabel();
156 case FieldImpl::HomeAddressLabel: 154 case FieldImpl::HomeAddressLabel:
157 return Addressee::homeAddressLabelLabel(); 155 return Addressee::homeAddressLabelLabel();
158 case FieldImpl::BusinessAddressStreet: 156 case FieldImpl::BusinessAddressStreet:
159 return Addressee::businessAddressStreetLabel(); 157 return Addressee::businessAddressStreetLabel();
160 case FieldImpl::BusinessAddressLocality: 158 case FieldImpl::BusinessAddressLocality:
161 return Addressee::businessAddressLocalityLabel(); 159 return Addressee::businessAddressLocalityLabel();
162 case FieldImpl::BusinessAddressRegion: 160 case FieldImpl::BusinessAddressRegion:
163 return Addressee::businessAddressRegionLabel(); 161 return Addressee::businessAddressRegionLabel();
164 case FieldImpl::BusinessAddressPostalCode: 162 case FieldImpl::BusinessAddressPostalCode:
165 return Addressee::businessAddressPostalCodeLabel(); 163 return Addressee::businessAddressPostalCodeLabel();
166 case FieldImpl::BusinessAddressCountry: 164 case FieldImpl::BusinessAddressCountry:
167 return Addressee::businessAddressCountryLabel(); 165 return Addressee::businessAddressCountryLabel();
168 case FieldImpl::BusinessAddressLabel: 166 case FieldImpl::BusinessAddressLabel:
169 return Addressee::businessAddressLabelLabel(); 167 return Addressee::businessAddressLabelLabel();
170 case FieldImpl::HomePhone: 168 case FieldImpl::HomePhone:
171 return Addressee::homePhoneLabel(); 169 return Addressee::homePhoneLabel();
172 case FieldImpl::BusinessPhone: 170 case FieldImpl::BusinessPhone:
173 return Addressee::businessPhoneLabel(); 171 return Addressee::businessPhoneLabel();
174 case FieldImpl::MobilePhone: 172 case FieldImpl::MobilePhone:
175 return Addressee::mobilePhoneLabel(); 173 return Addressee::mobilePhoneLabel();
176 case FieldImpl::MobileHomePhone:
177 return Addressee::mobileHomePhoneLabel();
178 case FieldImpl::MobileWorkPhone: 174 case FieldImpl::MobileWorkPhone:
179 return Addressee::mobileWorkPhoneLabel(); 175 return Addressee::mobileWorkPhoneLabel();
180 case FieldImpl::HomeFax: 176 case FieldImpl::HomeFax:
181 return Addressee::homeFaxLabel(); 177 return Addressee::homeFaxLabel();
182 case FieldImpl::BusinessFax: 178 case FieldImpl::BusinessFax:
183 return Addressee::businessFaxLabel(); 179 return Addressee::businessFaxLabel();
184 case FieldImpl::CarPhone:
185 return Addressee::carPhoneLabel();
186 case FieldImpl::Isdn: 180 case FieldImpl::Isdn:
187 return Addressee::isdnLabel(); 181 return Addressee::isdnLabel();
188 case FieldImpl::Pager: 182 case FieldImpl::Pager:
189 return Addressee::pagerLabel(); 183 return Addressee::pagerLabel();
190 case FieldImpl::Email: 184 case FieldImpl::Email:
191 return Addressee::emailLabel(); 185 return Addressee::emailLabel();
192 case FieldImpl::Mailer: 186 case FieldImpl::Mailer:
193 return Addressee::mailerLabel(); 187 return Addressee::mailerLabel();
194 case FieldImpl::Title: 188 case FieldImpl::Title:
195 return Addressee::titleLabel(); 189 return Addressee::titleLabel();
196 case FieldImpl::Role: 190 case FieldImpl::Role:
197 return Addressee::roleLabel(); 191 return Addressee::roleLabel();
198 case FieldImpl::Organization: 192 case FieldImpl::Organization:
199 return Addressee::organizationLabel(); 193 return Addressee::organizationLabel();
200 case FieldImpl::Note: 194 case FieldImpl::Note:
201 return Addressee::noteLabel(); 195 return Addressee::noteLabel();
202 case FieldImpl::Url: 196 case FieldImpl::Url:
203 return Addressee::urlLabel(); 197 return Addressee::urlLabel();
204 case FieldImpl::Resource: 198 case FieldImpl::Resource:
205 return Addressee::resourceLabel(); 199 return Addressee::resourceLabel();
206 case FieldImpl::Category: 200 case FieldImpl::Category:
207 return Addressee::categoryLabel(); 201 return Addressee::categoryLabel();
208 case FieldImpl::Sip: 202 case FieldImpl::Sip:
209 return Addressee::sipLabel(); 203 return Addressee::sipLabel();
210 case FieldImpl::OtherPhone: 204 case FieldImpl::OtherPhone:
211 return Addressee::otherPhoneLabel(); 205 return Addressee::otherPhoneLabel();
212 case FieldImpl::CustomField: 206 case FieldImpl::CustomField:
213 return mImpl->label(); 207 return mImpl->label();
214 default: 208 default:
215 return i18n("Unknown Field"); 209 return i18n("Unknown Field");
216 } 210 }
217} 211}
218 212
219int Field::category() 213int Field::category()
220{ 214{
221 return mImpl->category(); 215 return mImpl->category();
222} 216}
223 217
224QString Field::categoryLabel( int category ) 218QString Field::categoryLabel( int category )
225{ 219{
226 switch ( category ) { 220 switch ( category ) {
227 case All: 221 case All:
228 return i18n("All"); 222 return i18n("All");
229 case Frequent: 223 case Frequent:
230 return i18n("Frequent"); 224 return i18n("Frequent");
231 case Address: 225 case Address:
232 return i18n("Address"); 226 return i18n("Address");
233 case Email: 227 case Email:
234 return i18n("Email"); 228 return i18n("Email");
235 case Personal: 229 case Personal:
236 return i18n("Personal"); 230 return i18n("Personal");
237 case Organization: 231 case Organization:
238 return i18n("Organization"); 232 return i18n("Organization");
239 case CustomCategory: 233 case CustomCategory:
240 return i18n("Custom"); 234 return i18n("Custom");
241 default: 235 default:
242 return i18n("Undefined"); 236 return i18n("Undefined");
243 } 237 }
244} 238}
245 239
246QString Field::value( const KABC::Addressee &a ) 240QString Field::value( const KABC::Addressee &a )
247{ 241{
248 switch ( mImpl->fieldId() ) { 242 switch ( mImpl->fieldId() ) {
249 case FieldImpl::FormattedName: 243 case FieldImpl::FormattedName:
250 return a.formattedName(); 244 return a.formattedName();
251 case FieldImpl::FamilyName: 245 case FieldImpl::FamilyName:
252 return a.familyName(); 246 return a.familyName();
253 case FieldImpl::GivenName: 247 case FieldImpl::GivenName:
254 return a.givenName(); 248 return a.givenName();
255 case FieldImpl::AdditionalName: 249 case FieldImpl::AdditionalName:
256 return a.additionalName(); 250 return a.additionalName();
257 case FieldImpl::Prefix: 251 case FieldImpl::Prefix:
258 return a.prefix(); 252 return a.prefix();
259 case FieldImpl::Suffix: 253 case FieldImpl::Suffix:
260 return a.suffix(); 254 return a.suffix();
261 case FieldImpl::NickName: 255 case FieldImpl::NickName:
262 return a.nickName(); 256 return a.nickName();
263 case FieldImpl::Mailer: 257 case FieldImpl::Mailer:
264 return a.mailer(); 258 return a.mailer();
265 case FieldImpl::Title: 259 case FieldImpl::Title:
266 return a.title(); 260 return a.title();
267 case FieldImpl::Role: 261 case FieldImpl::Role:
268 return a.role(); 262 return a.role();
269 case FieldImpl::Organization: 263 case FieldImpl::Organization:
270 return a.organization(); 264 return a.organization();
271 case FieldImpl::Note: 265 case FieldImpl::Note:
272 return a.note(); 266 return a.note();
273 case FieldImpl::Email: 267 case FieldImpl::Email:
274 return a.preferredEmail(); 268 return a.preferredEmail();
275 case FieldImpl::Birthday: 269 case FieldImpl::Birthday:
276 if ( a.birthday().isValid() ) { 270 if ( a.birthday().isValid() ) {
277//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); 271//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate );
278// But Qt::IsoDate was not specified. 272// But Qt::IsoDate was not specified.
279// QString _oldFormat = KGlobal::locale()->dateFormat(); 273// QString _oldFormat = KGlobal::locale()->dateFormat();
280// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate 274// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate
281 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); 275 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate);
282// KGlobal::locale()->setDateFormat(_oldFormat); 276// KGlobal::locale()->setDateFormat(_oldFormat);
283 return dt; 277 return dt;
284 } 278 }
285 else 279 else
286 return QString::null; 280 return QString::null;
287 case FieldImpl::Url: 281 case FieldImpl::Url:
288 return a.url().prettyURL(); 282 return a.url().prettyURL();
289//US 283//US
290 case FieldImpl::Resource: 284 case FieldImpl::Resource:
291 return a.resource()->resourceName(); 285 return a.resource()->resourceName();
292 case FieldImpl::Category: 286 case FieldImpl::Category:
293 return a.categories().join(","); 287 return a.categories().join(",");
294 case FieldImpl::HomePhone: 288 case FieldImpl::HomePhone:
295 return a.phoneNumber( PhoneNumber::Home| PhoneNumber::Pref ).number(); 289 return a.phoneNumber( PhoneNumber::Home| PhoneNumber::Pref ).number();
296 case FieldImpl::BusinessPhone: 290 case FieldImpl::BusinessPhone:
297 return a.phoneNumber( PhoneNumber::Work| PhoneNumber::Pref ).number(); 291 return a.phoneNumber( PhoneNumber::Work| PhoneNumber::Pref ).number();
298 case FieldImpl::MobilePhone: 292 case FieldImpl::MobilePhone:
299 return a.phoneNumber( PhoneNumber::Cell ).number(); 293 return a.phoneNumber( PhoneNumber::Cell ).number();
300 case FieldImpl::MobileWorkPhone: 294 case FieldImpl::MobileWorkPhone:
301 return a.phoneNumber( PhoneNumber::Car ).number(); 295 return a.phoneNumber( PhoneNumber::Car ).number();
302 case FieldImpl::MobileHomePhone:
303 return a.phoneNumber( PhoneNumber::Cell ).number();
304 case FieldImpl::HomeFax: 296 case FieldImpl::HomeFax:
305 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); 297 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number();
306 case FieldImpl::BusinessFax: 298 case FieldImpl::BusinessFax:
307 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); 299 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number();
308 case FieldImpl::CarPhone:
309 return a.phoneNumber( PhoneNumber::Car ).number();
310 case FieldImpl::Isdn: 300 case FieldImpl::Isdn:
311 return a.phoneNumber( PhoneNumber::Isdn ).number(); 301 return a.phoneNumber( PhoneNumber::Isdn ).number();
312 case FieldImpl::Pager: 302 case FieldImpl::Pager:
313 return a.phoneNumber( PhoneNumber::Pager ).number(); 303 return a.phoneNumber( PhoneNumber::Pager ).number();
314 case FieldImpl::Sip: 304 case FieldImpl::Sip:
315 return a.phoneNumber( PhoneNumber::Pcs | PhoneNumber::Pref ).number(); 305 return a.phoneNumber( PhoneNumber::Pcs | PhoneNumber::Pref ).number();
316 case FieldImpl::OtherPhone: 306 case FieldImpl::OtherPhone:
317 return a.phoneNumber( PhoneNumber::Voice ).number(); 307 return a.phoneNumber( PhoneNumber::Voice ).number();
318 case FieldImpl::HomeAddressStreet: 308 case FieldImpl::HomeAddressStreet:
319 return a.address( Address::Home ).street(); 309 return a.address( Address::Home ).street();
320 case FieldImpl::HomeAddressLocality: 310 case FieldImpl::HomeAddressLocality:
321 return a.address( Address::Home ).locality(); 311 return a.address( Address::Home ).locality();
322 case FieldImpl::HomeAddressRegion: 312 case FieldImpl::HomeAddressRegion:
323 return a.address( Address::Home ).region(); 313 return a.address( Address::Home ).region();
324 case FieldImpl::HomeAddressPostalCode: 314 case FieldImpl::HomeAddressPostalCode:
325 return a.address( Address::Home ).postalCode(); 315 return a.address( Address::Home ).postalCode();
326 case FieldImpl::HomeAddressCountry: 316 case FieldImpl::HomeAddressCountry:
327 return a.address( Address::Home ).country(); 317 return a.address( Address::Home ).country();
328 case FieldImpl::BusinessAddressStreet: 318 case FieldImpl::BusinessAddressStreet:
329 return a.address( Address::Work ).street(); 319 return a.address( Address::Work ).street();
330 case FieldImpl::BusinessAddressLocality: 320 case FieldImpl::BusinessAddressLocality:
331 return a.address( Address::Work ).locality(); 321 return a.address( Address::Work ).locality();
332 case FieldImpl::BusinessAddressRegion: 322 case FieldImpl::BusinessAddressRegion:
333 return a.address( Address::Work ).region(); 323 return a.address( Address::Work ).region();
334 case FieldImpl::BusinessAddressPostalCode: 324 case FieldImpl::BusinessAddressPostalCode:
335 return a.address( Address::Work ).postalCode(); 325 return a.address( Address::Work ).postalCode();
336 case FieldImpl::BusinessAddressCountry: 326 case FieldImpl::BusinessAddressCountry:
337 return a.address( Address::Work ).country(); 327 return a.address( Address::Work ).country();
338 case FieldImpl::CustomField: 328 case FieldImpl::CustomField:
339 return a.custom( mImpl->app(), mImpl->key() ); 329 return a.custom( mImpl->app(), mImpl->key() );
340 default: 330 default:
341 return QString::null; 331 return QString::null;
342 } 332 }
343} 333}
344 334
345bool Field::setValue( KABC::Addressee &a, const QString &value ) 335bool Field::setValue( KABC::Addressee &a, const QString &value )
346{ 336{
347 switch ( mImpl->fieldId() ) { 337 switch ( mImpl->fieldId() ) {
348 case FieldImpl::FormattedName: 338 case FieldImpl::FormattedName:
349 a.setFormattedName( value ); 339 a.setFormattedName( value );
350 return true; 340 return true;
351 case FieldImpl::FamilyName: 341 case FieldImpl::FamilyName:
352 a.setFamilyName( value ); 342 a.setFamilyName( value );
353 return true; 343 return true;
354 case FieldImpl::GivenName: 344 case FieldImpl::GivenName:
355 a.setGivenName( value ); 345 a.setGivenName( value );
356 return true; 346 return true;
357 case FieldImpl::AdditionalName: 347 case FieldImpl::AdditionalName:
358 a.setAdditionalName( value ); 348 a.setAdditionalName( value );
359 return true; 349 return true;
360 case FieldImpl::Prefix: 350 case FieldImpl::Prefix:
361 a.setPrefix( value ); 351 a.setPrefix( value );
362 return true; 352 return true;
363 case FieldImpl::Suffix: 353 case FieldImpl::Suffix:
364 a.setSuffix( value ); 354 a.setSuffix( value );
365 return true; 355 return true;
366 case FieldImpl::NickName: 356 case FieldImpl::NickName:
367 a.setNickName( value ); 357 a.setNickName( value );
368 return true; 358 return true;
369 case FieldImpl::Mailer: 359 case FieldImpl::Mailer:
370 a.setMailer( value ); 360 a.setMailer( value );
371 return true; 361 return true;
372 case FieldImpl::Title: 362 case FieldImpl::Title:
373 a.setTitle( value ); 363 a.setTitle( value );
374 return true; 364 return true;
375 case FieldImpl::Role: 365 case FieldImpl::Role:
376 a.setRole( value ); 366 a.setRole( value );
377 return true; 367 return true;
378 case FieldImpl::Organization: 368 case FieldImpl::Organization:
379 a.setOrganization( value ); 369 a.setOrganization( value );
380 return true; 370 return true;
381 case FieldImpl::Note: 371 case FieldImpl::Note:
382 a.setNote( value ); 372 a.setNote( value );
383 return true; 373 return true;
384 case FieldImpl::Birthday: 374 case FieldImpl::Birthday:
385//US 375//US
386//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); 376//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) );
387// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? 377// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ?
388 { 378 {
389 QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate 379 QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate
390 a.setBirthday(dt); 380 a.setBirthday(dt);
391 } 381 }
392 return true; 382 return true;
393 case FieldImpl::CustomField: 383 case FieldImpl::CustomField:
394 a.insertCustom( mImpl->app(), mImpl->key(), value ); 384 a.insertCustom( mImpl->app(), mImpl->key(), value );
395//US never copy the resourcename back to the adressee. 385//US never copy the resourcename back to the adressee.
396 case FieldImpl::Resource: 386 case FieldImpl::Resource:
397 default: 387 default:
398 return false; 388 return false;
399 } 389 }
400} 390}
401 391
402bool Field::isCustom() 392bool Field::isCustom()
403{ 393{
404 return mImpl->fieldId() == FieldImpl::CustomField; 394 return mImpl->fieldId() == FieldImpl::CustomField;
405} 395}
406 396
407Field::List Field::allFields() 397Field::List Field::allFields()
408{ 398{
409 if ( mAllFields.isEmpty() ) { 399 if ( mAllFields.isEmpty() ) {
410 createField( FieldImpl::FormattedName, Frequent ); 400 createField( FieldImpl::FormattedName, Frequent );
411 createField( FieldImpl::FamilyName, Frequent ); 401 createField( FieldImpl::FamilyName, Frequent );
412 createField( FieldImpl::GivenName, Frequent ); 402 createField( FieldImpl::GivenName, Frequent );
413 createField( FieldImpl::AdditionalName ); 403 createField( FieldImpl::AdditionalName );
414 createField( FieldImpl::Prefix ); 404 createField( FieldImpl::Prefix );
415 createField( FieldImpl::Suffix ); 405 createField( FieldImpl::Suffix );
416 createField( FieldImpl::NickName, Personal ); 406 createField( FieldImpl::NickName, Personal );
417 createField( FieldImpl::Birthday, Personal ); 407 createField( FieldImpl::Birthday, Personal );
418 createField( FieldImpl::Category ); 408 createField( FieldImpl::Category );
419 createField( FieldImpl::HomeAddressStreet, Address|Personal ); 409 createField( FieldImpl::HomeAddressStreet, Address|Personal );
420 createField( FieldImpl::HomeAddressLocality, Address|Personal ); 410 createField( FieldImpl::HomeAddressLocality, Address|Personal );
421 createField( FieldImpl::HomeAddressRegion, Address|Personal ); 411 createField( FieldImpl::HomeAddressRegion, Address|Personal );
422 createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); 412 createField( FieldImpl::HomeAddressPostalCode, Address|Personal );
423 createField( FieldImpl::HomeAddressCountry, Address|Personal ); 413 createField( FieldImpl::HomeAddressCountry, Address|Personal );
424 createField( FieldImpl::HomeAddressLabel, Address|Personal ); 414 createField( FieldImpl::HomeAddressLabel, Address|Personal );
425 createField( FieldImpl::BusinessAddressStreet, Address|Organization ); 415 createField( FieldImpl::BusinessAddressStreet, Address|Organization );
426 createField( FieldImpl::BusinessAddressLocality, Address|Organization ); 416 createField( FieldImpl::BusinessAddressLocality, Address|Organization );
427 createField( FieldImpl::BusinessAddressRegion, Address|Organization ); 417 createField( FieldImpl::BusinessAddressRegion, Address|Organization );
428 createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); 418 createField( FieldImpl::BusinessAddressPostalCode, Address|Organization );
429 createField( FieldImpl::BusinessAddressCountry, Address|Organization ); 419 createField( FieldImpl::BusinessAddressCountry, Address|Organization );
430 createField( FieldImpl::BusinessAddressLabel, Address|Organization ); 420 createField( FieldImpl::BusinessAddressLabel, Address|Organization );
431 createField( FieldImpl::HomePhone, Personal|Frequent ); 421 createField( FieldImpl::HomePhone, Personal|Frequent );
432 createField( FieldImpl::BusinessPhone, Organization|Frequent ); 422 createField( FieldImpl::BusinessPhone, Organization|Frequent );
433 createField( FieldImpl::MobilePhone, Frequent ); 423 createField( FieldImpl::MobilePhone, Frequent );
434 createField( FieldImpl::MobileHomePhone, Frequent );
435 createField( FieldImpl::MobileWorkPhone, Frequent ); 424 createField( FieldImpl::MobileWorkPhone, Frequent );
436 createField( FieldImpl::HomeFax ); 425 createField( FieldImpl::HomeFax );
437 createField( FieldImpl::BusinessFax ); 426 createField( FieldImpl::BusinessFax );
438 createField( FieldImpl::CarPhone );
439 createField( FieldImpl::Isdn ); 427 createField( FieldImpl::Isdn );
440 createField( FieldImpl::Pager ); 428 createField( FieldImpl::Pager );
441 createField( FieldImpl::Email, Email|Frequent ); 429 createField( FieldImpl::Email, Email|Frequent );
442 createField( FieldImpl::Mailer, Email ); 430 createField( FieldImpl::Mailer, Email );
443 createField( FieldImpl::Title, Organization ); 431 createField( FieldImpl::Title, Organization );
444 createField( FieldImpl::Role, Organization ); 432 createField( FieldImpl::Role, Organization );
445 createField( FieldImpl::Organization, Organization ); 433 createField( FieldImpl::Organization, Organization );
446 createField( FieldImpl::Note ); 434 createField( FieldImpl::Note );
447 createField( FieldImpl::Url ); 435 createField( FieldImpl::Url );
448 createField( FieldImpl::Resource ); 436 createField( FieldImpl::Resource );
449 createField( FieldImpl::Sip ); 437 createField( FieldImpl::Sip );
450 createField( FieldImpl::OtherPhone ); 438 createField( FieldImpl::OtherPhone );
451 } 439 }
452 440
453 return mAllFields; 441 return mAllFields;
454} 442}
455 443
456Field::List Field::defaultFields() 444Field::List Field::defaultFields()
457{ 445{
458 if ( mDefaultFields.isEmpty() ) { 446 if ( mDefaultFields.isEmpty() ) {
459 createDefaultField( FieldImpl::GivenName ); 447 createDefaultField( FieldImpl::GivenName );
460 createDefaultField( FieldImpl::FamilyName ); 448 createDefaultField( FieldImpl::FamilyName );
461 createDefaultField( FieldImpl::Email ); 449 createDefaultField( FieldImpl::Email );
462 } 450 }
463 451
464 return mDefaultFields; 452 return mDefaultFields;
465} 453}
466 454
467void Field::createField( int id, int category ) 455void Field::createField( int id, int category )
468{ 456{
469 mAllFields.append( new Field( new FieldImpl( id, category ) ) ); 457 mAllFields.append( new Field( new FieldImpl( id, category ) ) );
470} 458}
471 459
472void Field::createDefaultField( int id, int category ) 460void Field::createDefaultField( int id, int category )
473{ 461{
474 mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); 462 mDefaultFields.append( new Field( new FieldImpl( id, category ) ) );
475} 463}
476 464
477void Field::deleteFields() 465void Field::deleteFields()
478{ 466{
479 Field::List::ConstIterator it; 467 Field::List::ConstIterator it;
480 468
481 for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { 469 for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) {
482 delete (*it); 470 delete (*it);
483 } 471 }
484 mAllFields.clear(); 472 mAllFields.clear();
485 473
486 for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { 474 for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) {
487 delete (*it); 475 delete (*it);
488 } 476 }
489 mDefaultFields.clear(); 477 mDefaultFields.clear();
490 478
491 for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { 479 for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) {
492 delete (*it); 480 delete (*it);
493 } 481 }
494 mCustomFields.clear(); 482 mCustomFields.clear();
495} 483}
496 484
497void Field::saveFields( const QString &identifier, 485void Field::saveFields( const QString &identifier,
498 const Field::List &fields ) 486 const Field::List &fields )
499{ 487{
500 KConfig *cfg = KGlobal::config(); 488 KConfig *cfg = KGlobal::config();
501 KConfigGroupSaver( cfg, "KABCFields" ); 489 KConfigGroupSaver( cfg, "KABCFields" );
502 saveFields( cfg, identifier, fields ); 490 saveFields( cfg, identifier, fields );
503} 491}
504 492
505void Field::saveFields( KConfig *cfg, const QString &identifier, 493void Field::saveFields( KConfig *cfg, const QString &identifier,
506 const Field::List &fields ) 494 const Field::List &fields )
507{ 495{
508 QValueList<int> fieldIds; 496 QValueList<int> fieldIds;
509 497
510//US 498//US
511// qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); 499// qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1());
512 500
513 int custom = 0; 501 int custom = 0;
514 Field::List::ConstIterator it; 502 Field::List::ConstIterator it;
515 for( it = fields.begin(); it != fields.end(); ++it ) { 503 for( it = fields.begin(); it != fields.end(); ++it ) {
516//US 504//US
517// qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); 505// qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId());
518 506
519 fieldIds.append( (*it)->mImpl->fieldId() ); 507 fieldIds.append( (*it)->mImpl->fieldId() );
520 if( (*it)->isCustom() ) { 508 if( (*it)->isCustom() ) {
521 QStringList customEntry; 509 QStringList customEntry;
522 customEntry << (*it)->mImpl->label(); 510 customEntry << (*it)->mImpl->label();
523 customEntry << (*it)->mImpl->key(); 511 customEntry << (*it)->mImpl->key();
524 customEntry << (*it)->mImpl->app(); 512 customEntry << (*it)->mImpl->app();
525 cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" + 513 cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" +
526 QString::number( custom++ ), customEntry ); 514 QString::number( custom++ ), customEntry );
527 } 515 }
528 } 516 }
529 cfg->writeEntry( identifier, fieldIds ); 517 cfg->writeEntry( identifier, fieldIds );
530} 518}
531 519
532Field::List Field::restoreFields( const QString &identifier ) 520Field::List Field::restoreFields( const QString &identifier )
533{ 521{
534//US 522//US
535// qDebug("Field::restoreFields, identifier: %s", identifier.latin1()); 523// qDebug("Field::restoreFields, identifier: %s", identifier.latin1());
536 524
537 KConfig *cfg = KGlobal::config(); 525 KConfig *cfg = KGlobal::config();
538 KConfigGroupSaver( cfg, "KABCFields" ); 526 KConfigGroupSaver( cfg, "KABCFields" );
539 cfg->setGroup( "KABCFields" ); 527 cfg->setGroup( "KABCFields" );
540 528
541 Field::List l = restoreFields( cfg, identifier ); 529 Field::List l = restoreFields( cfg, identifier );
542 530
543 return l; 531 return l;
544} 532}
545 533
546Field::List Field::restoreFields( KConfig *cfg, const QString &identifier ) 534Field::List Field::restoreFields( KConfig *cfg, const QString &identifier )
547{ 535{
548 QValueList<int> fieldIds = cfg->readIntListEntry( identifier); 536 QValueList<int> fieldIds = cfg->readIntListEntry( identifier);
549//US 537//US
550// qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1()); 538// qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1());
551 539
552 Field::List fields; 540 Field::List fields;
553 541
554 int custom = 0; 542 int custom = 0;
555 QValueList<int>::ConstIterator it; 543 QValueList<int>::ConstIterator it;
556 for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) { 544 for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) {
557 FieldImpl *f = 0; 545 FieldImpl *f = 0;
558 if ( (*it) == FieldImpl::CustomField ) { 546 if ( (*it) == FieldImpl::CustomField ) {
559 QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" + 547 QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" +
560 identifier + "_" + 548 identifier + "_" +
561 QString::number( custom++ ) ); 549 QString::number( custom++ ) );
562 f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ], 550 f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ],
563 customEntry[ 1 ], customEntry[ 2 ] ); 551 customEntry[ 1 ], customEntry[ 2 ] );
564 } else { 552 } else {
565 f = new FieldImpl( *it ); 553 f = new FieldImpl( *it );
566 } 554 }
567 fields.append( new Field( f ) ); 555 fields.append( new Field( f ) );
568 } 556 }
569 557
570 return fields; 558 return fields;
571} 559}
572 560
573bool Field::equals( Field *field ) 561bool Field::equals( Field *field )
574{ 562{
575 bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() ); 563 bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() );
576 564
577 if ( !sameId ) return false; 565 if ( !sameId ) return false;
578 566
579 if ( mImpl->fieldId() != FieldImpl::CustomField ) return true; 567 if ( mImpl->fieldId() != FieldImpl::CustomField ) return true;
580 568
581 return mImpl->key() == field->mImpl->key(); 569 return mImpl->key() == field->mImpl->key();
582} 570}
583 571
584Field *Field::createCustomField( const QString &label, int category, 572Field *Field::createCustomField( const QString &label, int category,
585 const QString &key, const QString &app ) 573 const QString &key, const QString &app )
586{ 574{
587 Field *field = new Field( new FieldImpl( FieldImpl::CustomField, 575 Field *field = new Field( new FieldImpl( FieldImpl::CustomField,
588 category | CustomCategory, 576 category | CustomCategory,
589 label, key, app ) ); 577 label, key, app ) );
590//US 578//US
591// qDebug("Field::createCustomField label %s", label.latin1() ); 579// qDebug("Field::createCustomField label %s", label.latin1() );
592 580
593 mCustomFields.append( field ); 581 mCustomFields.append( field );
594 582
595 return field; 583 return field;
596} 584}