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