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