Diffstat (limited to 'libopie2/opiepim/ocontactfields.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/ocontactfields.cpp | 518 |
1 files changed, 0 insertions, 518 deletions
diff --git a/libopie2/opiepim/ocontactfields.cpp b/libopie2/opiepim/ocontactfields.cpp deleted file mode 100644 index bec00f7..0000000 --- a/libopie2/opiepim/ocontactfields.cpp +++ b/dev/null | |||
@@ -1,518 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | |||
30 | #include "ocontactfields.h" | ||
31 | |||
32 | /* OPIE */ | ||
33 | #include <opie2/ocontact.h> | ||
34 | #include <qpe/recordfields.h> // We should use our own enum in the future .. | ||
35 | #include <qpe/config.h> | ||
36 | |||
37 | /* QT */ | ||
38 | #include <qobject.h> | ||
39 | #include <qstringlist.h> | ||
40 | |||
41 | |||
42 | namespace Opie | ||
43 | { | ||
44 | /*! | ||
45 | \internal | ||
46 | Returns a list of personal field names for a contact. | ||
47 | */ | ||
48 | QStringList OContactFields::personalfields( bool sorted, bool translated ) | ||
49 | { | ||
50 | QStringList list; | ||
51 | QMap<int, QString> mapIdToStr; | ||
52 | if ( translated ) | ||
53 | mapIdToStr = idToTrFields(); | ||
54 | else | ||
55 | mapIdToStr = idToUntrFields(); | ||
56 | |||
57 | list.append( mapIdToStr[ Qtopia::AddressUid ] ); | ||
58 | list.append( mapIdToStr[ Qtopia::AddressCategory ] ); | ||
59 | |||
60 | list.append( mapIdToStr[ Qtopia::Title ] ); | ||
61 | list.append( mapIdToStr[ Qtopia::FirstName ] ); | ||
62 | list.append( mapIdToStr[ Qtopia::MiddleName ] ); | ||
63 | list.append( mapIdToStr[ Qtopia::LastName ] ); | ||
64 | list.append( mapIdToStr[ Qtopia::Suffix ] ); | ||
65 | list.append( mapIdToStr[ Qtopia::FileAs ] ); | ||
66 | |||
67 | list.append( mapIdToStr[ Qtopia::JobTitle ] ); | ||
68 | list.append( mapIdToStr[ Qtopia::Department ] ); | ||
69 | list.append( mapIdToStr[ Qtopia::Company ] ); | ||
70 | |||
71 | list.append( mapIdToStr[ Qtopia::Notes ] ); | ||
72 | list.append( mapIdToStr[ Qtopia::Groups ] ); | ||
73 | |||
74 | if ( sorted ) list.sort(); | ||
75 | return list; | ||
76 | } | ||
77 | |||
78 | /*! | ||
79 | \internal | ||
80 | Returns a list of details field names for a contact. | ||
81 | */ | ||
82 | QStringList OContactFields::detailsfields( bool sorted, bool translated ) | ||
83 | { | ||
84 | QStringList list; | ||
85 | QMap<int, QString> mapIdToStr; | ||
86 | if ( translated ) | ||
87 | mapIdToStr = idToTrFields(); | ||
88 | else | ||
89 | mapIdToStr = idToUntrFields(); | ||
90 | |||
91 | list.append( mapIdToStr[ Qtopia::Office ] ); | ||
92 | list.append( mapIdToStr[ Qtopia::Profession ] ); | ||
93 | list.append( mapIdToStr[ Qtopia::Assistant ] ); | ||
94 | list.append( mapIdToStr[ Qtopia::Manager ] ); | ||
95 | |||
96 | list.append( mapIdToStr[ Qtopia::Spouse ] ); | ||
97 | list.append( mapIdToStr[ Qtopia::Gender ] ); | ||
98 | list.append( mapIdToStr[ Qtopia::Birthday ] ); | ||
99 | list.append( mapIdToStr[ Qtopia::Anniversary ] ); | ||
100 | list.append( mapIdToStr[ Qtopia::Nickname ] ); | ||
101 | list.append( mapIdToStr[ Qtopia::Children ] ); | ||
102 | |||
103 | if ( sorted ) list.sort(); | ||
104 | return list; | ||
105 | } | ||
106 | |||
107 | /*! | ||
108 | \internal | ||
109 | Returns a list of phone field names for a contact. | ||
110 | */ | ||
111 | QStringList OContactFields::phonefields( bool sorted, bool translated ) | ||
112 | { | ||
113 | QStringList list; | ||
114 | QMap<int, QString> mapIdToStr; | ||
115 | if ( translated ) | ||
116 | mapIdToStr = idToTrFields(); | ||
117 | else | ||
118 | mapIdToStr = idToUntrFields(); | ||
119 | |||
120 | list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); | ||
121 | list.append( mapIdToStr[ Qtopia::BusinessFax ] ); | ||
122 | list.append( mapIdToStr[ Qtopia::BusinessMobile ] ); | ||
123 | list.append( mapIdToStr[ Qtopia::BusinessPager ] ); | ||
124 | list.append( mapIdToStr[ Qtopia::BusinessWebPage ] ); | ||
125 | |||
126 | list.append( mapIdToStr[ Qtopia::DefaultEmail ] ); | ||
127 | list.append( mapIdToStr[ Qtopia::Emails ] ); | ||
128 | |||
129 | list.append( mapIdToStr[ Qtopia::HomePhone ] ); | ||
130 | list.append( mapIdToStr[ Qtopia::HomeFax ] ); | ||
131 | list.append( mapIdToStr[ Qtopia::HomeMobile ] ); | ||
132 | // list.append( mapIdToStr[Qtopia::HomePager] ); | ||
133 | list.append( mapIdToStr[ Qtopia::HomeWebPage ] ); | ||
134 | |||
135 | if ( sorted ) list.sort(); | ||
136 | |||
137 | return list; | ||
138 | } | ||
139 | |||
140 | /*! | ||
141 | \internal | ||
142 | Returns a list of field names for a contact. | ||
143 | */ | ||
144 | QStringList OContactFields::fields( bool sorted, bool translated ) | ||
145 | { | ||
146 | QStringList list; | ||
147 | QMap<int, QString> mapIdToStr; | ||
148 | if ( translated ) | ||
149 | mapIdToStr = idToTrFields(); | ||
150 | else | ||
151 | mapIdToStr = idToUntrFields(); | ||
152 | |||
153 | list += personalfields( sorted, translated ); | ||
154 | |||
155 | list += phonefields( sorted, translated ); | ||
156 | |||
157 | list.append( mapIdToStr[ Qtopia::BusinessStreet ] ); | ||
158 | list.append( mapIdToStr[ Qtopia::BusinessCity ] ); | ||
159 | list.append( mapIdToStr[ Qtopia::BusinessState ] ); | ||
160 | list.append( mapIdToStr[ Qtopia::BusinessZip ] ); | ||
161 | list.append( mapIdToStr[ Qtopia::BusinessCountry ] ); | ||
162 | |||
163 | list.append( mapIdToStr[ Qtopia::HomeStreet ] ); | ||
164 | list.append( mapIdToStr[ Qtopia::HomeCity ] ); | ||
165 | list.append( mapIdToStr[ Qtopia::HomeState ] ); | ||
166 | list.append( mapIdToStr[ Qtopia::HomeZip ] ); | ||
167 | list.append( mapIdToStr[ Qtopia::HomeCountry ] ); | ||
168 | |||
169 | list += detailsfields( sorted, translated ); | ||
170 | |||
171 | if ( sorted ) list.sort(); | ||
172 | |||
173 | return list; | ||
174 | } | ||
175 | |||
176 | |||
177 | /*! | ||
178 | \internal | ||
179 | Returns an untranslated list of personal field names for a contact. | ||
180 | */ | ||
181 | QStringList OContactFields::untrpersonalfields( bool sorted ) | ||
182 | { | ||
183 | return personalfields( sorted, false ); | ||
184 | } | ||
185 | |||
186 | |||
187 | /*! | ||
188 | \internal | ||
189 | Returns a translated list of personal field names for a contact. | ||
190 | */ | ||
191 | QStringList OContactFields::trpersonalfields( bool sorted ) | ||
192 | { | ||
193 | return personalfields( sorted, true ); | ||
194 | } | ||
195 | |||
196 | |||
197 | /*! | ||
198 | \internal | ||
199 | Returns an untranslated list of details field names for a contact. | ||
200 | */ | ||
201 | QStringList OContactFields::untrdetailsfields( bool sorted ) | ||
202 | { | ||
203 | return detailsfields( sorted, false ); | ||
204 | } | ||
205 | |||
206 | |||
207 | /*! | ||
208 | \internal | ||
209 | Returns a translated list of details field names for a contact. | ||
210 | */ | ||
211 | QStringList OContactFields::trdetailsfields( bool sorted ) | ||
212 | { | ||
213 | return detailsfields( sorted, true ); | ||
214 | } | ||
215 | |||
216 | |||
217 | /*! | ||
218 | \internal | ||
219 | Returns a translated list of phone field names for a contact. | ||
220 | */ | ||
221 | QStringList OContactFields::trphonefields( bool sorted ) | ||
222 | { | ||
223 | return phonefields( sorted, true ); | ||
224 | } | ||
225 | |||
226 | /*! | ||
227 | \internal | ||
228 | Returns an untranslated list of phone field names for a contact. | ||
229 | */ | ||
230 | QStringList OContactFields::untrphonefields( bool sorted ) | ||
231 | { | ||
232 | return phonefields( sorted, false ); | ||
233 | } | ||
234 | |||
235 | |||
236 | /*! | ||
237 | \internal | ||
238 | Returns a translated list of field names for a contact. | ||
239 | */ | ||
240 | QStringList OContactFields::trfields( bool sorted ) | ||
241 | { | ||
242 | return fields( sorted, true ); | ||
243 | } | ||
244 | |||
245 | /*! | ||
246 | \internal | ||
247 | Returns an untranslated list of field names for a contact. | ||
248 | */ | ||
249 | QStringList OContactFields::untrfields( bool sorted ) | ||
250 | { | ||
251 | return fields( sorted, false ); | ||
252 | } | ||
253 | |||
254 | QMap<int, QString> OContactFields::idToTrFields() | ||
255 | { | ||
256 | QMap<int, QString> ret_map; | ||
257 | |||
258 | ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) ); | ||
259 | ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) ); | ||
260 | |||
261 | ret_map.insert( Qtopia::Title, QObject::tr( "Name Title" ) ); | ||
262 | ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) ); | ||
263 | ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) ); | ||
264 | ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) ); | ||
265 | ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" ) ); | ||
266 | ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) ); | ||
267 | |||
268 | ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) ); | ||
269 | ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) ); | ||
270 | ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) ); | ||
271 | ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) ); | ||
272 | ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) ); | ||
273 | ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" ) ); | ||
274 | |||
275 | |||
276 | ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) ); | ||
277 | ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) ); | ||
278 | |||
279 | ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) ); | ||
280 | ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) ); | ||
281 | ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) ); | ||
282 | |||
283 | // business | ||
284 | ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) ); | ||
285 | ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) ); | ||
286 | ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) ); | ||
287 | ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) ); | ||
288 | ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) ); | ||
289 | ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) ); | ||
290 | ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) ); | ||
291 | |||
292 | ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) ); | ||
293 | ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) ); | ||
294 | ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) ); | ||
295 | ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) ); | ||
296 | |||
297 | // home | ||
298 | ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) ); | ||
299 | ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) ); | ||
300 | ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) ); | ||
301 | ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) ); | ||
302 | ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) ); | ||
303 | ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) ); | ||
304 | |||
305 | //personal | ||
306 | ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) ); | ||
307 | ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) ); | ||
308 | ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) ); | ||
309 | ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) ); | ||
310 | ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) ); | ||
311 | ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) ); | ||
312 | |||
313 | // other | ||
314 | ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) ); | ||
315 | |||
316 | |||
317 | return ret_map; | ||
318 | } | ||
319 | |||
320 | QMap<int, QString> OContactFields::idToUntrFields() | ||
321 | { | ||
322 | QMap<int, QString> ret_map; | ||
323 | |||
324 | ret_map.insert( Qtopia::AddressUid, "User Id" ); | ||
325 | ret_map.insert( Qtopia::AddressCategory, "Categories" ); | ||
326 | |||
327 | ret_map.insert( Qtopia::Title, "Name Title" ); | ||
328 | ret_map.insert( Qtopia::FirstName, "First Name" ); | ||
329 | ret_map.insert( Qtopia::MiddleName, "Middle Name" ); | ||
330 | ret_map.insert( Qtopia::LastName, "Last Name" ); | ||
331 | ret_map.insert( Qtopia::Suffix, "Suffix" ); | ||
332 | ret_map.insert( Qtopia::FileAs, "File As" ); | ||
333 | |||
334 | ret_map.insert( Qtopia::JobTitle, "Job Title" ); | ||
335 | ret_map.insert( Qtopia::Department, "Department" ); | ||
336 | ret_map.insert( Qtopia::Company, "Company" ); | ||
337 | ret_map.insert( Qtopia::BusinessPhone, "Business Phone" ); | ||
338 | ret_map.insert( Qtopia::BusinessFax, "Business Fax" ); | ||
339 | ret_map.insert( Qtopia::BusinessMobile, "Business Mobile" ); | ||
340 | |||
341 | |||
342 | ret_map.insert( Qtopia::DefaultEmail, "Default Email" ); | ||
343 | ret_map.insert( Qtopia::Emails, "Emails" ); | ||
344 | |||
345 | ret_map.insert( Qtopia::HomePhone, "Home Phone" ); | ||
346 | ret_map.insert( Qtopia::HomeFax, "Home Fax" ); | ||
347 | ret_map.insert( Qtopia::HomeMobile, "Home Mobile" ); | ||
348 | |||
349 | // business | ||
350 | ret_map.insert( Qtopia::BusinessStreet, "Business Street" ); | ||
351 | ret_map.insert( Qtopia::BusinessCity, "Business City" ); | ||
352 | ret_map.insert( Qtopia::BusinessState, "Business State" ); | ||
353 | ret_map.insert( Qtopia::BusinessZip, "Business Zip" ); | ||
354 | ret_map.insert( Qtopia::BusinessCountry, "Business Country" ); | ||
355 | ret_map.insert( Qtopia::BusinessPager, "Business Pager" ); | ||
356 | ret_map.insert( Qtopia::BusinessWebPage, "Business WebPage" ); | ||
357 | |||
358 | ret_map.insert( Qtopia::Office, "Office" ); | ||
359 | ret_map.insert( Qtopia::Profession, "Profession" ); | ||
360 | ret_map.insert( Qtopia::Assistant, "Assistant" ); | ||
361 | ret_map.insert( Qtopia::Manager, "Manager" ); | ||
362 | |||
363 | // home | ||
364 | ret_map.insert( Qtopia::HomeStreet, "Home Street" ); | ||
365 | ret_map.insert( Qtopia::HomeCity, "Home City" ); | ||
366 | ret_map.insert( Qtopia::HomeState, "Home State" ); | ||
367 | ret_map.insert( Qtopia::HomeZip, "Home Zip" ); | ||
368 | ret_map.insert( Qtopia::HomeCountry, "Home Country" ); | ||
369 | ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" ); | ||
370 | |||
371 | //personal | ||
372 | ret_map.insert( Qtopia::Spouse, "Spouse" ); | ||
373 | ret_map.insert( Qtopia::Gender, "Gender" ); | ||
374 | ret_map.insert( Qtopia::Birthday, "Birthday" ); | ||
375 | ret_map.insert( Qtopia::Anniversary, "Anniversary" ); | ||
376 | ret_map.insert( Qtopia::Nickname, "Nickname" ); | ||
377 | ret_map.insert( Qtopia::Children, "Children" ); | ||
378 | |||
379 | // other | ||
380 | ret_map.insert( Qtopia::Notes, "Notes" ); | ||
381 | ret_map.insert( Qtopia::Groups, "Groups" ); | ||
382 | |||
383 | |||
384 | return ret_map; | ||
385 | } | ||
386 | |||
387 | QMap<QString, int> OContactFields::trFieldsToId() | ||
388 | { | ||
389 | QMap<int, QString> idtostr = idToTrFields(); | ||
390 | QMap<QString, int> ret_map; | ||
391 | |||
392 | |||
393 | QMap<int, QString>::Iterator it; | ||
394 | for ( it = idtostr.begin(); it != idtostr.end(); ++it ) | ||
395 | ret_map.insert( *it, it.key() ); | ||
396 | |||
397 | |||
398 | return ret_map; | ||
399 | } | ||
400 | |||
401 | /* ======================================================================= */ | ||
402 | |||
403 | QMap<QString, int> OContactFields::untrFieldsToId() | ||
404 | { | ||
405 | QMap<int, QString> idtostr = idToUntrFields(); | ||
406 | QMap<QString, int> ret_map; | ||
407 | |||
408 | |||
409 | QMap<int, QString>::Iterator it; | ||
410 | for ( it = idtostr.begin(); it != idtostr.end(); ++it ) | ||
411 | ret_map.insert( *it, it.key() ); | ||
412 | |||
413 | |||
414 | return ret_map; | ||
415 | } | ||
416 | |||
417 | |||
418 | OContactFields::OContactFields() : | ||
419 | fieldOrder( DEFAULT_FIELD_ORDER ), | ||
420 | changedFieldOrder( false ) | ||
421 | { | ||
422 | // Get the global field order from the config file and | ||
423 | // use it as a start pattern | ||
424 | Config cfg ( "AddressBook" ); | ||
425 | cfg.setGroup( "ContactFieldOrder" ); | ||
426 | globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER ); | ||
427 | } | ||
428 | |||
429 | OContactFields::~OContactFields() | ||
430 | { | ||
431 | |||
432 | // We will store the fieldorder into the config file | ||
433 | // to reuse it for the future.. | ||
434 | if ( changedFieldOrder ) | ||
435 | { | ||
436 | Config cfg ( "AddressBook" ); | ||
437 | cfg.setGroup( "ContactFieldOrder" ); | ||
438 | cfg.writeEntry( "General", globalFieldOrder ); | ||
439 | } | ||
440 | } | ||
441 | |||
442 | |||
443 | |||
444 | void OContactFields::saveToRecord( OContact &cnt ) | ||
445 | { | ||
446 | |||
447 | qDebug( "ocontactfields saveToRecord: >%s<", fieldOrder.latin1() ); | ||
448 | |||
449 | // Store fieldorder into this contact. | ||
450 | cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder ); | ||
451 | |||
452 | globalFieldOrder = fieldOrder; | ||
453 | changedFieldOrder = true; | ||
454 | |||
455 | } | ||
456 | |||
457 | void OContactFields::loadFromRecord( const OContact &cnt ) | ||
458 | { | ||
459 | qDebug( "ocontactfields loadFromRecord" ); | ||
460 | qDebug( "loading >%s<", cnt.fullName().latin1() ); | ||
461 | |||
462 | // Get fieldorder for this contact. If none is defined, | ||
463 | // we will use the global one from the config file.. | ||
464 | |||
465 | fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME ); | ||
466 | |||
467 | qDebug( "fieldOrder from contact>%s<", fieldOrder.latin1() ); | ||
468 | |||
469 | if ( fieldOrder.isEmpty() ) | ||
470 | { | ||
471 | fieldOrder = globalFieldOrder; | ||
472 | } | ||
473 | |||
474 | |||
475 | qDebug( "effective fieldOrder in loadFromRecord >%s<", fieldOrder.latin1() ); | ||
476 | } | ||
477 | |||
478 | void OContactFields::setFieldOrder( int num, int index ) | ||
479 | { | ||
480 | qDebug( "qcontactfields setfieldorder pos %i -> %i", num, index ); | ||
481 | |||
482 | fieldOrder[ num ] = QString::number( index, 16 ) [ 0 ]; | ||
483 | |||
484 | // We will store this new fieldorder globally to | ||
485 | // remember it for contacts which have none | ||
486 | globalFieldOrder = fieldOrder; | ||
487 | changedFieldOrder = true; | ||
488 | |||
489 | qDebug( "fieldOrder >%s<", fieldOrder.latin1() ); | ||
490 | } | ||
491 | |||
492 | int OContactFields::getFieldOrder( int num, int defIndex ) | ||
493 | { | ||
494 | qDebug( "ocontactfields getFieldOrder" ); | ||
495 | qDebug( "fieldOrder >%s<", fieldOrder.latin1() ); | ||
496 | |||
497 | // Get index of combo as char.. | ||
498 | QChar poschar = fieldOrder[ num ]; | ||
499 | |||
500 | bool ok; | ||
501 | int ret = 0; | ||
502 | // Convert char to number.. | ||
503 | if ( !( poschar == QChar::null ) ) | ||
504 | ret = QString( poschar ).toInt( &ok, 16 ); | ||
505 | else | ||
506 | ok = false; | ||
507 | |||
508 | // Return default value if index for | ||
509 | // num was not set or if anything else happened.. | ||
510 | if ( !ok ) ret = defIndex; | ||
511 | |||
512 | qDebug( "returning >%i<", ret ); | ||
513 | |||
514 | return ret; | ||
515 | |||
516 | } | ||
517 | |||
518 | } | ||