-rw-r--r-- | kabc/addressbook.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 3 |
2 files changed, 2 insertions, 2 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index bf6d053..1a06956 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -366,97 +366,96 @@ bool AddressBook::load() | |||
366 | 366 | ||
367 | bool AddressBook::save( Ticket *ticket ) | 367 | bool AddressBook::save( Ticket *ticket ) |
368 | { | 368 | { |
369 | kdDebug(5700) << "AddressBook::save()"<< endl; | 369 | kdDebug(5700) << "AddressBook::save()"<< endl; |
370 | 370 | ||
371 | if ( ticket->resource() ) { | 371 | if ( ticket->resource() ) { |
372 | deleteRemovedAddressees(); | 372 | deleteRemovedAddressees(); |
373 | return ticket->resource()->save( ticket ); | 373 | return ticket->resource()->save( ticket ); |
374 | } | 374 | } |
375 | 375 | ||
376 | return false; | 376 | return false; |
377 | } | 377 | } |
378 | void AddressBook::export2File( QString fileName ) | 378 | void AddressBook::export2File( QString fileName ) |
379 | { | 379 | { |
380 | 380 | ||
381 | QFile outFile( fileName ); | 381 | QFile outFile( fileName ); |
382 | if ( !outFile.open( IO_WriteOnly ) ) { | 382 | if ( !outFile.open( IO_WriteOnly ) ) { |
383 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 383 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
384 | KMessageBox::error( 0, text.arg( fileName ) ); | 384 | KMessageBox::error( 0, text.arg( fileName ) ); |
385 | return ; | 385 | return ; |
386 | } | 386 | } |
387 | QTextStream t( &outFile ); | 387 | QTextStream t( &outFile ); |
388 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 388 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
389 | Iterator it; | 389 | Iterator it; |
390 | KABC::VCardConverter::Version version; | 390 | KABC::VCardConverter::Version version; |
391 | version = KABC::VCardConverter::v3_0; | 391 | version = KABC::VCardConverter::v3_0; |
392 | for ( it = begin(); it != end(); ++it ) { | 392 | for ( it = begin(); it != end(); ++it ) { |
393 | if ( !(*it).IDStr().isEmpty() ) { | 393 | if ( !(*it).IDStr().isEmpty() ) { |
394 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 394 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
395 | } | 395 | } |
396 | KABC::VCardConverter converter; | 396 | KABC::VCardConverter converter; |
397 | QString vcard; | 397 | QString vcard; |
398 | //Resource *resource() const; | 398 | //Resource *resource() const; |
399 | converter.addresseeToVCard( *it, vcard, version ); | 399 | converter.addresseeToVCard( *it, vcard, version ); |
400 | t << vcard << "\r\n"; | 400 | t << vcard << "\r\n"; |
401 | } | 401 | } |
402 | t << "\r\n\r\n"; | 402 | t << "\r\n\r\n"; |
403 | outFile.close(); | 403 | outFile.close(); |
404 | } | 404 | } |
405 | void AddressBook::importFromFile( QString fileName, bool replaceLabel ) | 405 | void AddressBook::importFromFile( QString fileName, bool replaceLabel ) |
406 | { | 406 | { |
407 | 407 | ||
408 | KABC::Addressee::List list; | 408 | KABC::Addressee::List list; |
409 | QFile file( fileName ); | 409 | QFile file( fileName ); |
410 | 410 | ||
411 | file.open( IO_ReadOnly ); | 411 | file.open( IO_ReadOnly ); |
412 | QByteArray rawData = file.readAll(); | 412 | QByteArray rawData = file.readAll(); |
413 | file.close(); | 413 | file.close(); |
414 | qDebug("AddressBook::importFromFile "); | ||
415 | QString data; | 414 | QString data; |
416 | if ( replaceLabel ) { | 415 | if ( replaceLabel ) { |
417 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | 416 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); |
418 | data.replace ( QRegExp("LABEL") , "ADR" ); | 417 | data.replace ( QRegExp("LABEL") , "ADR" ); |
419 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | 418 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); |
420 | } else | 419 | } else |
421 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 420 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
422 | KABC::VCardTool tool; | 421 | KABC::VCardTool tool; |
423 | list = tool.parseVCards( data ); | 422 | list = tool.parseVCards( data ); |
424 | KABC::Addressee::List::Iterator it; | 423 | KABC::Addressee::List::Iterator it; |
425 | for ( it = list.begin(); it != list.end(); ++it ) { | 424 | for ( it = list.begin(); it != list.end(); ++it ) { |
426 | (*it).setResource( 0 ); | 425 | (*it).setResource( 0 ); |
427 | if ( replaceLabel ) | 426 | if ( replaceLabel ) |
428 | (*it).removeVoice(); | 427 | (*it).removeVoice(); |
429 | insertAddressee( (*it), false, true ); | 428 | insertAddressee( (*it), false, true ); |
430 | } | 429 | } |
431 | 430 | ||
432 | } | 431 | } |
433 | 432 | ||
434 | bool AddressBook::saveAB() | 433 | bool AddressBook::saveAB() |
435 | { | 434 | { |
436 | bool ok = true; | 435 | bool ok = true; |
437 | 436 | ||
438 | deleteRemovedAddressees(); | 437 | deleteRemovedAddressees(); |
439 | Iterator ait; | 438 | Iterator ait; |
440 | for ( ait = begin(); ait != end(); ++ait ) { | 439 | for ( ait = begin(); ait != end(); ++ait ) { |
441 | if ( !(*ait).IDStr().isEmpty() ) { | 440 | if ( !(*ait).IDStr().isEmpty() ) { |
442 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 441 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
443 | } | 442 | } |
444 | } | 443 | } |
445 | KRES::Manager<Resource>::ActiveIterator it; | 444 | KRES::Manager<Resource>::ActiveIterator it; |
446 | KRES::Manager<Resource> *manager = d->mManager; | 445 | KRES::Manager<Resource> *manager = d->mManager; |
447 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 446 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
448 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 447 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
449 | Ticket *ticket = requestSaveTicket( *it ); | 448 | Ticket *ticket = requestSaveTicket( *it ); |
450 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 449 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
451 | if ( !ticket ) { | 450 | if ( !ticket ) { |
452 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 451 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
453 | .arg( (*it)->resourceName() ) ); | 452 | .arg( (*it)->resourceName() ) ); |
454 | return false; | 453 | return false; |
455 | } | 454 | } |
456 | 455 | ||
457 | //if ( !save( ticket ) ) | 456 | //if ( !save( ticket ) ) |
458 | if ( ticket->resource() ) { | 457 | if ( ticket->resource() ) { |
459 | if ( ! ticket->resource()->save( ticket ) ) | 458 | if ( ! ticket->resource()->save( ticket ) ) |
460 | ok = false; | 459 | ok = false; |
461 | } else | 460 | } else |
462 | ok = false; | 461 | ok = false; |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 3a542ba..efcd492 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -282,98 +282,99 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const | |||
282 | connect( mXXPortManager, SIGNAL( modified() ), | 282 | connect( mXXPortManager, SIGNAL( modified() ), |
283 | SLOT( setModified() ) ); | 283 | SLOT( setModified() ) ); |
284 | 284 | ||
285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
286 | SLOT( incrementalSearch( const QString& ) ) ); | 286 | SLOT( incrementalSearch( const QString& ) ) ); |
287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
288 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 288 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
289 | 289 | ||
290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
291 | SLOT( sendMail( const QString& ) ) ); | 291 | SLOT( sendMail( const QString& ) ) ); |
292 | 292 | ||
293 | 293 | ||
294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
297 | 297 | ||
298 | 298 | ||
299 | #ifndef KAB_EMBEDDED | 299 | #ifndef KAB_EMBEDDED |
300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
302 | 302 | ||
303 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 303 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
304 | SLOT( browse( const QString& ) ) ); | 304 | SLOT( browse( const QString& ) ) ); |
305 | 305 | ||
306 | 306 | ||
307 | mAddressBookService = new KAddressBookService( this ); | 307 | mAddressBookService = new KAddressBookService( this ); |
308 | 308 | ||
309 | #endif //KAB_EMBEDDED | 309 | #endif //KAB_EMBEDDED |
310 | mEditorDialog = 0; | 310 | mEditorDialog = 0; |
311 | createAddresseeEditorDialog( this ); | 311 | createAddresseeEditorDialog( this ); |
312 | setModified( false ); | 312 | setModified( false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | KABCore::~KABCore() | 315 | KABCore::~KABCore() |
316 | { | 316 | { |
317 | // save(); | 317 | // save(); |
318 | //saveSettings(); | 318 | //saveSettings(); |
319 | //KABPrefs::instance()->writeConfig(); | 319 | //KABPrefs::instance()->writeConfig(); |
320 | delete AddresseeConfig::instance(); | 320 | delete AddresseeConfig::instance(); |
321 | mAddressBook = 0; | 321 | mAddressBook = 0; |
322 | KABC::StdAddressBook::close(); | 322 | KABC::StdAddressBook::close(); |
323 | 323 | ||
324 | delete syncManager; | 324 | delete syncManager; |
325 | 325 | ||
326 | } | 326 | } |
327 | 327 | ||
328 | void KABCore::recieve( QString fn ) | 328 | void KABCore::recieve( QString fn ) |
329 | { | 329 | { |
330 | qDebug("KABCore::recieve "); | 330 | //qDebug("KABCore::recieve "); |
331 | mAddressBook->importFromFile( fn, true ); | 331 | mAddressBook->importFromFile( fn, true ); |
332 | mViewManager->refreshView(); | ||
332 | topLevelWidget()->raise(); | 333 | topLevelWidget()->raise(); |
333 | } | 334 | } |
334 | void KABCore::restoreSettings() | 335 | void KABCore::restoreSettings() |
335 | { | 336 | { |
336 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 337 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
337 | 338 | ||
338 | bool state; | 339 | bool state; |
339 | 340 | ||
340 | if (mMultipleViewsAtOnce) | 341 | if (mMultipleViewsAtOnce) |
341 | state = KABPrefs::instance()->mDetailsPageVisible; | 342 | state = KABPrefs::instance()->mDetailsPageVisible; |
342 | else | 343 | else |
343 | state = false; | 344 | state = false; |
344 | 345 | ||
345 | mActionDetails->setChecked( state ); | 346 | mActionDetails->setChecked( state ); |
346 | setDetailsVisible( state ); | 347 | setDetailsVisible( state ); |
347 | 348 | ||
348 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 349 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
349 | 350 | ||
350 | mActionJumpBar->setChecked( state ); | 351 | mActionJumpBar->setChecked( state ); |
351 | setJumpButtonBarVisible( state ); | 352 | setJumpButtonBarVisible( state ); |
352 | /*US | 353 | /*US |
353 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 354 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
354 | if ( splitterSize.count() == 0 ) { | 355 | if ( splitterSize.count() == 0 ) { |
355 | splitterSize.append( width() / 2 ); | 356 | splitterSize.append( width() / 2 ); |
356 | splitterSize.append( width() / 2 ); | 357 | splitterSize.append( width() / 2 ); |
357 | } | 358 | } |
358 | mMiniSplitter->setSizes( splitterSize ); | 359 | mMiniSplitter->setSizes( splitterSize ); |
359 | if ( mExtensionBarSplitter ) { | 360 | if ( mExtensionBarSplitter ) { |
360 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 361 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
361 | if ( splitterSize.count() == 0 ) { | 362 | if ( splitterSize.count() == 0 ) { |
362 | splitterSize.append( width() / 2 ); | 363 | splitterSize.append( width() / 2 ); |
363 | splitterSize.append( width() / 2 ); | 364 | splitterSize.append( width() / 2 ); |
364 | } | 365 | } |
365 | mExtensionBarSplitter->setSizes( splitterSize ); | 366 | mExtensionBarSplitter->setSizes( splitterSize ); |
366 | 367 | ||
367 | } | 368 | } |
368 | */ | 369 | */ |
369 | mViewManager->restoreSettings(); | 370 | mViewManager->restoreSettings(); |
370 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 371 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
371 | mExtensionManager->restoreSettings(); | 372 | mExtensionManager->restoreSettings(); |
372 | #ifdef DESKTOP_VERSION | 373 | #ifdef DESKTOP_VERSION |
373 | int wid = width(); | 374 | int wid = width(); |
374 | if ( wid < 10 ) | 375 | if ( wid < 10 ) |
375 | wid = 400; | 376 | wid = 400; |
376 | #else | 377 | #else |
377 | int wid = QApplication::desktop()->width(); | 378 | int wid = QApplication::desktop()->width(); |
378 | if ( wid < 640 ) | 379 | if ( wid < 640 ) |
379 | wid = QApplication::desktop()->height(); | 380 | wid = QApplication::desktop()->height(); |