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