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