author | eilers <eilers> | 2003-01-31 13:51:13 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-01-31 13:51:13 (UTC) |
commit | 6f5a127080c50eb901ac6a332ac76d9948f91bd5 (patch) (unidiff) | |
tree | 8021e7597b9bc8e527b2fddac1e03dc0959434c9 /core/pim/addressbook/ocontactfields.cpp | |
parent | 84bd32181af3922ccba35fcaed9b404d1e4deed8 (diff) | |
download | opie-6f5a127080c50eb901ac6a332ac76d9948f91bd5.zip opie-6f5a127080c50eb901ac6a332ac76d9948f91bd5.tar.gz opie-6f5a127080c50eb901ac6a332ac76d9948f91bd5.tar.bz2 |
Removed a lot of debug output.. Therefore it should speed up..
The settings of the combo-boxes in the contacteditor are now stored globally
and individual for a contact ( I fear this will not survive any synchronizing! ).
Thanks to tille for his assistance !
I hope there isn't any new bug in the contacteditor.. It is very ugly and hard
to debug..
Diffstat (limited to 'core/pim/addressbook/ocontactfields.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/addressbook/ocontactfields.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/core/pim/addressbook/ocontactfields.cpp b/core/pim/addressbook/ocontactfields.cpp index 0da6a4f..75a7641 100644 --- a/core/pim/addressbook/ocontactfields.cpp +++ b/core/pim/addressbook/ocontactfields.cpp | |||
@@ -3,12 +3,14 @@ | |||
3 | 3 | ||
4 | #include <qstringlist.h> | 4 | #include <qstringlist.h> |
5 | #include <qobject.h> | 5 | #include <qobject.h> |
6 | 6 | ||
7 | // We should use our own enum in the future .. | 7 | // We should use our own enum in the future .. |
8 | #include <qpe/recordfields.h> | 8 | #include <qpe/recordfields.h> |
9 | #include <qpe/config.h> | ||
10 | #include <opie/ocontact.h> | ||
9 | 11 | ||
10 | /*! | 12 | /*! |
11 | \internal | 13 | \internal |
12 | Returns a list of details field names for a contact. | 14 | Returns a list of details field names for a contact. |
13 | */ | 15 | */ |
14 | QStringList OContactFields::untrdetailsfields( bool sorted ) | 16 | QStringList OContactFields::untrdetailsfields( bool sorted ) |
@@ -269,6 +271,99 @@ QMap<QString, int> OContactFields::trFieldsToId() | |||
269 | for( it = idtostr.begin(); it != idtostr.end(); ++it ) | 271 | for( it = idtostr.begin(); it != idtostr.end(); ++it ) |
270 | ret_map.insert( *it, it.key() ); | 272 | ret_map.insert( *it, it.key() ); |
271 | 273 | ||
272 | 274 | ||
273 | return ret_map; | 275 | return ret_map; |
274 | } | 276 | } |
277 | |||
278 | OContactFields::OContactFields(): | ||
279 | fieldOrder( DEFAULT_FIELD_ORDER ), | ||
280 | changedFieldOrder( false ) | ||
281 | { | ||
282 | // Get the global field order from the config file and | ||
283 | // use it as a start pattern | ||
284 | Config cfg ( "AddressBook" ); | ||
285 | cfg.setGroup( "ContactFieldOrder" ); | ||
286 | globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER ); | ||
287 | } | ||
288 | |||
289 | OContactFields::~OContactFields(){ | ||
290 | |||
291 | // We will store the fieldorder into the config file | ||
292 | // to reuse it for the future.. | ||
293 | if ( changedFieldOrder ){ | ||
294 | Config cfg ( "AddressBook" ); | ||
295 | cfg.setGroup( "ContactFieldOrder" ); | ||
296 | cfg.writeEntry( "General", globalFieldOrder ); | ||
297 | } | ||
298 | } | ||
299 | |||
300 | |||
301 | |||
302 | void OContactFields::saveToRecord( OContact &cnt ){ | ||
303 | |||
304 | qDebug("ocontactfields saveToRecord: >%s<",fieldOrder.latin1()); | ||
305 | |||
306 | // Store fieldorder into this contact. | ||
307 | cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder ); | ||
308 | |||
309 | globalFieldOrder = fieldOrder; | ||
310 | changedFieldOrder = true; | ||
311 | |||
312 | } | ||
313 | |||
314 | void OContactFields::loadFromRecord( const OContact &cnt ){ | ||
315 | qDebug("ocontactfields loadFromRecord"); | ||
316 | qDebug("loading >%s<",cnt.fullName().latin1()); | ||
317 | |||
318 | // Get fieldorder for this contact. If none is defined, | ||
319 | // we will use the global one from the config file.. | ||
320 | |||
321 | fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME ); | ||
322 | |||
323 | qDebug("fieldOrder from contact>%s<",fieldOrder.latin1()); | ||
324 | |||
325 | if (fieldOrder.isEmpty()){ | ||
326 | fieldOrder = globalFieldOrder; | ||
327 | } | ||
328 | |||
329 | |||
330 | qDebug("effective fieldOrder in loadFromRecord >%s<",fieldOrder.latin1()); | ||
331 | } | ||
332 | |||
333 | void OContactFields::setFieldOrder( int num, int index ){ | ||
334 | qDebug("qcontactfields setfieldorder pos %i -> %i",num,index); | ||
335 | |||
336 | fieldOrder[num] = QString::number( index )[0]; | ||
337 | |||
338 | // We will store this new fieldorder globally to | ||
339 | // remember it for contacts which have none | ||
340 | globalFieldOrder = fieldOrder; | ||
341 | changedFieldOrder = true; | ||
342 | |||
343 | qDebug("fieldOrder >%s<",fieldOrder.latin1()); | ||
344 | } | ||
345 | |||
346 | int OContactFields::getFieldOrder( int num, int defIndex ){ | ||
347 | qDebug("ocontactfields getFieldOrder"); | ||
348 | qDebug("fieldOrder >%s<",fieldOrder.latin1()); | ||
349 | |||
350 | // Get index of combo as char.. | ||
351 | QChar poschar = fieldOrder[num]; | ||
352 | |||
353 | bool ok; | ||
354 | int ret = 0; | ||
355 | // Convert char to number.. | ||
356 | if ( !( poschar == QChar::null ) ) | ||
357 | ret = QString( poschar ).toInt(&ok, 10); | ||
358 | else | ||
359 | ok = false; | ||
360 | |||
361 | // Return default value if index for | ||
362 | // num was not set or if anything else happened.. | ||
363 | if ( !ok ) ret = defIndex; | ||
364 | |||
365 | qDebug("returning >%i<",ret); | ||
366 | |||
367 | return ret; | ||
368 | |||
369 | } | ||