summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2005-08-17 14:48:16 (UTC)
committer zautrix <zautrix>2005-08-17 14:48:16 (UTC)
commit9e6d1f7f45ef1444dc6ee96347a2dbd67a0d79dd (patch) (unidiff)
tree4db3dfc9b67b56f415a9aab4306cc6375c6e7310 /kaddressbook
parentcb4e02944327194bc6066c4ec96826afc0ea178f (diff)
downloadkdepimpi-9e6d1f7f45ef1444dc6ee96347a2dbd67a0d79dd.zip
kdepimpi-9e6d1f7f45ef1444dc6ee96347a2dbd67a0d79dd.tar.gz
kdepimpi-9e6d1f7f45ef1444dc6ee96347a2dbd67a0d79dd.tar.bz2
kapi dlete conf
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp20
-rw-r--r--kaddressbook/kabprefs.cpp1
-rw-r--r--kaddressbook/kabprefs.h1
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.cpp6
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.h1
5 files changed, 27 insertions, 2 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d5de9cb..b9830b1 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -263,1607 +263,1623 @@ class KAex2phonePrefs : public QDialog
263 new QLabel( i18n("Model(opt.): "), temphb ); 263 new QLabel( i18n("Model(opt.): "), temphb );
264 mPhoneModel = new QLineEdit( temphb); 264 mPhoneModel = new QLineEdit( temphb);
265 lay->addWidget( temphb ); 265 lay->addWidget( temphb );
266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
267 // lay->addWidget( mWriteToSim ); 267 // lay->addWidget( mWriteToSim );
268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
269 lab->setAlignment (AlignHCenter); 269 lab->setAlignment (AlignHCenter);
270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
271 lay->addWidget( ok ); 271 lay->addWidget( ok );
272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
273 lay->addWidget( cancel ); 273 lay->addWidget( cancel );
274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
276 resize( 220, 240 ); 276 resize( 220, 240 );
277 277
278 } 278 }
279 279
280public: 280public:
281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
282 QCheckBox* mWriteToSim; 282 QCheckBox* mWriteToSim;
283}; 283};
284 284
285 285
286bool pasteWithNewUid = true; 286bool pasteWithNewUid = true;
287 287
288#ifdef KAB_EMBEDDED 288#ifdef KAB_EMBEDDED
289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
293#else //KAB_EMBEDDED 293#else //KAB_EMBEDDED
294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
297 mReadWrite( readWrite ), mModified( false ) 297 mReadWrite( readWrite ), mModified( false )
298#endif //KAB_EMBEDDED 298#endif //KAB_EMBEDDED
299{ 299{
300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
301 // syncManager->setBlockSave(false); 301 // syncManager->setBlockSave(false);
302 mIncSearchWidget = 0; 302 mIncSearchWidget = 0;
303 mMiniSplitter = 0; 303 mMiniSplitter = 0;
304 mExtensionBarSplitter = 0; 304 mExtensionBarSplitter = 0;
305 mIsPart = !parent->inherits( "KAddressBookMain" ); 305 mIsPart = !parent->inherits( "KAddressBookMain" );
306 mAddressBook = KABC::StdAddressBook::self(); 306 mAddressBook = KABC::StdAddressBook::self();
307 KABC::StdAddressBook::setAutomaticSave( false ); 307 KABC::StdAddressBook::setAutomaticSave( false );
308 308
309#ifndef KAB_EMBEDDED 309#ifndef KAB_EMBEDDED
310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
311#endif //KAB_EMBEDDED 311#endif //KAB_EMBEDDED
312 312
313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
314 SLOT( addressBookChanged() ) ); 314 SLOT( addressBookChanged() ) );
315 315
316#if 0 316#if 0
317 // LR moved to addressbook init method 317 // LR moved to addressbook init method
318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
319 "X-Department", "KADDRESSBOOK" ); 319 "X-Department", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
321 "X-Profession", "KADDRESSBOOK" ); 321 "X-Profession", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
323 "X-AssistantsName", "KADDRESSBOOK" ); 323 "X-AssistantsName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
325 "X-ManagersName", "KADDRESSBOOK" ); 325 "X-ManagersName", "KADDRESSBOOK" );
326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
327 "X-SpousesName", "KADDRESSBOOK" ); 327 "X-SpousesName", "KADDRESSBOOK" );
328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
329 "X-Office", "KADDRESSBOOK" ); 329 "X-Office", "KADDRESSBOOK" );
330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
331 "X-IMAddress", "KADDRESSBOOK" ); 331 "X-IMAddress", "KADDRESSBOOK" );
332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
333 "X-Anniversary", "KADDRESSBOOK" ); 333 "X-Anniversary", "KADDRESSBOOK" );
334 334
335 //US added this field to become compatible with Opie/qtopia addressbook 335 //US added this field to become compatible with Opie/qtopia addressbook
336 // values can be "female" or "male" or "". An empty field represents undefined. 336 // values can be "female" or "male" or "". An empty field represents undefined.
337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
338 "X-Gender", "KADDRESSBOOK" ); 338 "X-Gender", "KADDRESSBOOK" );
339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
340 "X-Children", "KADDRESSBOOK" ); 340 "X-Children", "KADDRESSBOOK" );
341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
342 "X-FreeBusyUrl", "KADDRESSBOOK" ); 342 "X-FreeBusyUrl", "KADDRESSBOOK" );
343#endif 343#endif
344 initGUI(); 344 initGUI();
345 345
346 mIncSearchWidget->setFocus(); 346 mIncSearchWidget->setFocus();
347 347
348 348
349 connect( mViewManager, SIGNAL( selected( const QString& ) ), 349 connect( mViewManager, SIGNAL( selected( const QString& ) ),
350 SLOT( setContactSelected( const QString& ) ) ); 350 SLOT( setContactSelected( const QString& ) ) );
351 connect( mViewManager, SIGNAL( executed( const QString& ) ), 351 connect( mViewManager, SIGNAL( executed( const QString& ) ),
352 SLOT( executeContact( const QString& ) ) ); 352 SLOT( executeContact( const QString& ) ) );
353 353
354 connect( mViewManager, SIGNAL( deleteRequest( ) ), 354 connect( mViewManager, SIGNAL( deleteRequest( ) ),
355 SLOT( deleteContacts( ) ) ); 355 SLOT( deleteContacts( ) ) );
356 connect( mViewManager, SIGNAL( modified() ), 356 connect( mViewManager, SIGNAL( modified() ),
357 SLOT( setModified() ) ); 357 SLOT( setModified() ) );
358 358
359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
361 361
362 connect( mXXPortManager, SIGNAL( modified() ), 362 connect( mXXPortManager, SIGNAL( modified() ),
363 SLOT( setModified() ) ); 363 SLOT( setModified() ) );
364 364
365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
366 SLOT( incrementalSearchJump( const QString& ) ) ); 366 SLOT( incrementalSearchJump( const QString& ) ) );
367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
368 mJumpButtonBar, SLOT( recreateButtons() ) ); 368 mJumpButtonBar, SLOT( recreateButtons() ) );
369 369
370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
371 SLOT( sendMail( const QString& ) ) ); 371 SLOT( sendMail( const QString& ) ) );
372 372
373 373
374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
375 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&))); 375 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&)));
376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync())); 378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync()));
379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); 379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog()));
380 380
381 381
382#ifndef KAB_EMBEDDED 382#ifndef KAB_EMBEDDED
383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
384 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 384 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
385 385
386 connect( mDetails, SIGNAL( browse( const QString& ) ), 386 connect( mDetails, SIGNAL( browse( const QString& ) ),
387 SLOT( browse( const QString& ) ) ); 387 SLOT( browse( const QString& ) ) );
388 388
389 389
390 mAddressBookService = new KAddressBookService( this ); 390 mAddressBookService = new KAddressBookService( this );
391 391
392#endif //KAB_EMBEDDED 392#endif //KAB_EMBEDDED
393 393
394 mMessageTimer = new QTimer( this ); 394 mMessageTimer = new QTimer( this );
395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
396 mEditorDialog = 0; 396 mEditorDialog = 0;
397 createAddresseeEditorDialog( this ); 397 createAddresseeEditorDialog( this );
398 setModified( false ); 398 setModified( false );
399 mBRdisabled = false; 399 mBRdisabled = false;
400#ifndef DESKTOP_VERSION 400#ifndef DESKTOP_VERSION
401 infrared = 0; 401 infrared = 0;
402#endif 402#endif
403 //toggleBeamReceive( ); 403 //toggleBeamReceive( );
404 mMainWindow->toolBar()->show(); 404 mMainWindow->toolBar()->show();
405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
406 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 406 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
407} 407}
408 408
409void KABCore::updateToolBar() 409void KABCore::updateToolBar()
410{ 410{
411 static int iii = 0; 411 static int iii = 0;
412 ++iii; 412 ++iii;
413 mMainWindow->toolBar()->repaintMe(); 413 mMainWindow->toolBar()->repaintMe();
414 if ( iii < 4 ) 414 if ( iii < 4 )
415 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); 415 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar()));
416} 416}
417KABCore::~KABCore() 417KABCore::~KABCore()
418{ 418{
419 // save(); 419 // save();
420 //saveSettings(); 420 //saveSettings();
421 //KABPrefs::instance()->writeConfig(); 421 //KABPrefs::instance()->writeConfig();
422 delete AddresseeConfig::instance(); 422 delete AddresseeConfig::instance();
423 mAddressBook = 0; 423 mAddressBook = 0;
424 KABC::StdAddressBook::close(); 424 KABC::StdAddressBook::close();
425 425
426 delete syncManager; 426 delete syncManager;
427#ifndef DESKTOP_VERSION 427#ifndef DESKTOP_VERSION
428 if ( infrared ) 428 if ( infrared )
429 delete infrared; 429 delete infrared;
430#endif 430#endif
431} 431}
432void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 432void KABCore::receive( const QCString& cmsg, const QByteArray& data )
433{ 433{
434 //qDebug("KA: QCOP message received: %s ", cmsg.data() ); 434 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
435 if ( cmsg == "setDocument(QString)" ) { 435 if ( cmsg == "setDocument(QString)" ) {
436 QDataStream stream( data, IO_ReadOnly ); 436 QDataStream stream( data, IO_ReadOnly );
437 QString fileName; 437 QString fileName;
438 stream >> fileName; 438 stream >> fileName;
439 recieve( fileName ); 439 recieve( fileName );
440 return; 440 return;
441 } 441 }
442} 442}
443void KABCore::toggleBeamReceive( ) 443void KABCore::toggleBeamReceive( )
444{ 444{
445 if ( mBRdisabled ) 445 if ( mBRdisabled )
446 return; 446 return;
447#ifndef DESKTOP_VERSION 447#ifndef DESKTOP_VERSION
448 if ( infrared ) { 448 if ( infrared ) {
449 qDebug("KA: AB disable BeamReceive "); 449 qDebug("KA: AB disable BeamReceive ");
450 delete infrared; 450 delete infrared;
451 infrared = 0; 451 infrared = 0;
452 mActionBR->setChecked(false); 452 mActionBR->setChecked(false);
453 return; 453 return;
454 } 454 }
455 qDebug("KA: AB enable BeamReceive "); 455 qDebug("KA: AB enable BeamReceive ");
456 mActionBR->setChecked(true); 456 mActionBR->setChecked(true);
457 457
458 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 458 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
459 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 459 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
460#endif 460#endif
461} 461}
462 462
463 463
464void KABCore::disableBR(bool b) 464void KABCore::disableBR(bool b)
465{ 465{
466#ifndef DESKTOP_VERSION 466#ifndef DESKTOP_VERSION
467 if ( b ) { 467 if ( b ) {
468 if ( infrared ) { 468 if ( infrared ) {
469 toggleBeamReceive( ); 469 toggleBeamReceive( );
470 } 470 }
471 mBRdisabled = true; 471 mBRdisabled = true;
472 } else { 472 } else {
473 if ( mBRdisabled ) { 473 if ( mBRdisabled ) {
474 mBRdisabled = false; 474 mBRdisabled = false;
475 //toggleBeamReceive( ); 475 //toggleBeamReceive( );
476 } 476 }
477 } 477 }
478#endif 478#endif
479 479
480} 480}
481void KABCore::recieve( QString fn ) 481void KABCore::recieve( QString fn )
482{ 482{
483 //qDebug("KABCore::recieve "); 483 //qDebug("KABCore::recieve ");
484 int count = mAddressBook->importFromFile( fn, true ); 484 int count = mAddressBook->importFromFile( fn, true );
485 if ( count ) 485 if ( count )
486 setModified( true ); 486 setModified( true );
487 mViewManager->refreshView(); 487 mViewManager->refreshView();
488 message(i18n("%1 contact(s) received!").arg( count )); 488 message(i18n("%1 contact(s) received!").arg( count ));
489 topLevelWidget()->showMaximized(); 489 topLevelWidget()->showMaximized();
490 topLevelWidget()->raise(); 490 topLevelWidget()->raise();
491} 491}
492void KABCore::restoreSettings() 492void KABCore::restoreSettings()
493{ 493{
494 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 494 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
495 495
496 bool state; 496 bool state;
497 497
498 if (mMultipleViewsAtOnce) 498 if (mMultipleViewsAtOnce)
499 state = KABPrefs::instance()->mDetailsPageVisible; 499 state = KABPrefs::instance()->mDetailsPageVisible;
500 else 500 else
501 state = false; 501 state = false;
502 502
503 mActionDetails->setChecked( state ); 503 mActionDetails->setChecked( state );
504 setDetailsVisible( state ); 504 setDetailsVisible( state );
505 505
506 state = KABPrefs::instance()->mJumpButtonBarVisible; 506 state = KABPrefs::instance()->mJumpButtonBarVisible;
507 507
508 mActionJumpBar->setChecked( state ); 508 mActionJumpBar->setChecked( state );
509 setJumpButtonBarVisible( state ); 509 setJumpButtonBarVisible( state );
510/*US 510/*US
511 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 511 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
512 if ( splitterSize.count() == 0 ) { 512 if ( splitterSize.count() == 0 ) {
513 splitterSize.append( width() / 2 ); 513 splitterSize.append( width() / 2 );
514 splitterSize.append( width() / 2 ); 514 splitterSize.append( width() / 2 );
515 } 515 }
516 mMiniSplitter->setSizes( splitterSize ); 516 mMiniSplitter->setSizes( splitterSize );
517 if ( mExtensionBarSplitter ) { 517 if ( mExtensionBarSplitter ) {
518 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 518 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
519 if ( splitterSize.count() == 0 ) { 519 if ( splitterSize.count() == 0 ) {
520 splitterSize.append( width() / 2 ); 520 splitterSize.append( width() / 2 );
521 splitterSize.append( width() / 2 ); 521 splitterSize.append( width() / 2 );
522 } 522 }
523 mExtensionBarSplitter->setSizes( splitterSize ); 523 mExtensionBarSplitter->setSizes( splitterSize );
524 524
525 } 525 }
526*/ 526*/
527 mViewManager->restoreSettings(); 527 mViewManager->restoreSettings();
528 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 528 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
529 mExtensionManager->restoreSettings(); 529 mExtensionManager->restoreSettings();
530#ifdef DESKTOP_VERSION 530#ifdef DESKTOP_VERSION
531 int wid = width(); 531 int wid = width();
532 if ( wid < 10 ) 532 if ( wid < 10 )
533 wid = 400; 533 wid = 400;
534#else 534#else
535 int wid = QApplication::desktop()->width(); 535 int wid = QApplication::desktop()->width();
536 if ( wid < 640 ) 536 if ( wid < 640 )
537 wid = QApplication::desktop()->height(); 537 wid = QApplication::desktop()->height();
538#endif 538#endif
539 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 539 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
540 if ( true /*splitterSize.count() == 0*/ ) { 540 if ( true /*splitterSize.count() == 0*/ ) {
541 splitterSize.append( wid / 2 ); 541 splitterSize.append( wid / 2 );
542 splitterSize.append( wid / 2 ); 542 splitterSize.append( wid / 2 );
543 } 543 }
544 mMiniSplitter->setSizes( splitterSize ); 544 mMiniSplitter->setSizes( splitterSize );
545 if ( mExtensionBarSplitter ) { 545 if ( mExtensionBarSplitter ) {
546 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 546 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
547 if ( true /*splitterSize.count() == 0*/ ) { 547 if ( true /*splitterSize.count() == 0*/ ) {
548 splitterSize.append( wid / 2 ); 548 splitterSize.append( wid / 2 );
549 splitterSize.append( wid / 2 ); 549 splitterSize.append( wid / 2 );
550 } 550 }
551 mExtensionBarSplitter->setSizes( splitterSize ); 551 mExtensionBarSplitter->setSizes( splitterSize );
552 552
553 } 553 }
554#ifdef DESKTOP_VERSION 554#ifdef DESKTOP_VERSION
555 KConfig *config = KABPrefs::instance()->getConfig(); 555 KConfig *config = KABPrefs::instance()->getConfig();
556 config->setGroup("WidgetLayout"); 556 config->setGroup("WidgetLayout");
557 QStringList list; 557 QStringList list;
558 list = config->readListEntry("MainLayout"); 558 list = config->readListEntry("MainLayout");
559 int x,y,w,h; 559 int x,y,w,h;
560 if ( ! list.isEmpty() ) { 560 if ( ! list.isEmpty() ) {
561 x = list[0].toInt(); 561 x = list[0].toInt();
562 y = list[1].toInt(); 562 y = list[1].toInt();
563 w = list[2].toInt(); 563 w = list[2].toInt();
564 h = list[3].toInt(); 564 h = list[3].toInt();
565 KApplication::testCoords( &x,&y,&w,&h ); 565 KApplication::testCoords( &x,&y,&w,&h );
566 topLevelWidget()->setGeometry(x,y,w,h); 566 topLevelWidget()->setGeometry(x,y,w,h);
567 567
568 } else { 568 } else {
569 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 569 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
570 } 570 }
571#endif 571#endif
572} 572}
573 573
574void KABCore::saveSettings() 574void KABCore::saveSettings()
575{ 575{
576 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 576 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
577 if ( mExtensionBarSplitter ) 577 if ( mExtensionBarSplitter )
578 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 578 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
579 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 579 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
580 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 580 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
581#ifndef KAB_EMBEDDED 581#ifndef KAB_EMBEDDED
582 582
583 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 583 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
584 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 584 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
585#endif //KAB_EMBEDDED 585#endif //KAB_EMBEDDED
586 mExtensionManager->saveSettings(); 586 mExtensionManager->saveSettings();
587 mViewManager->saveSettings(); 587 mViewManager->saveSettings();
588 588
589 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 589 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
590 590
591 KABPrefs::instance()->writeConfig(); 591 KABPrefs::instance()->writeConfig();
592 qDebug("KA: KABCore::saveSettings() "); 592 qDebug("KA: KABCore::saveSettings() ");
593} 593}
594 594
595KABC::AddressBook *KABCore::addressBook() const 595KABC::AddressBook *KABCore::addressBook() const
596{ 596{
597 return mAddressBook; 597 return mAddressBook;
598} 598}
599 599
600KConfig *KABCore::config() 600KConfig *KABCore::config()
601{ 601{
602#ifndef KAB_EMBEDDED 602#ifndef KAB_EMBEDDED
603 return KABPrefs::instance()->config(); 603 return KABPrefs::instance()->config();
604#else //KAB_EMBEDDED 604#else //KAB_EMBEDDED
605 return KABPrefs::instance()->getConfig(); 605 return KABPrefs::instance()->getConfig();
606#endif //KAB_EMBEDDED 606#endif //KAB_EMBEDDED
607} 607}
608 608
609KActionCollection *KABCore::actionCollection() const 609KActionCollection *KABCore::actionCollection() const
610{ 610{
611 return mGUIClient->actionCollection(); 611 return mGUIClient->actionCollection();
612} 612}
613 613
614KABC::Field *KABCore::currentSearchField() const 614KABC::Field *KABCore::currentSearchField() const
615{ 615{
616 if (mIncSearchWidget) 616 if (mIncSearchWidget)
617 return mIncSearchWidget->currentField(); 617 return mIncSearchWidget->currentField();
618 else 618 else
619 return 0; 619 return 0;
620} 620}
621 621
622QStringList KABCore::selectedUIDs() const 622QStringList KABCore::selectedUIDs() const
623{ 623{
624 return mViewManager->selectedUids(); 624 return mViewManager->selectedUids();
625} 625}
626 626
627KABC::Resource *KABCore::requestResource( QWidget *parent ) 627KABC::Resource *KABCore::requestResource( QWidget *parent )
628{ 628{
629 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 629 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
630 630
631 QPtrList<KRES::Resource> kresResources; 631 QPtrList<KRES::Resource> kresResources;
632 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 632 QPtrListIterator<KABC::Resource> resIt( kabcResources );
633 KABC::Resource *resource; 633 KABC::Resource *resource;
634 while ( ( resource = resIt.current() ) != 0 ) { 634 while ( ( resource = resIt.current() ) != 0 ) {
635 ++resIt; 635 ++resIt;
636 if ( !resource->readOnly() ) { 636 if ( !resource->readOnly() ) {
637 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 637 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
638 if ( res ) 638 if ( res )
639 kresResources.append( res ); 639 kresResources.append( res );
640 } 640 }
641 } 641 }
642 642
643 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 643 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
644 return static_cast<KABC::Resource*>( res ); 644 return static_cast<KABC::Resource*>( res );
645} 645}
646 646
647#ifndef KAB_EMBEDDED 647#ifndef KAB_EMBEDDED
648KAboutData *KABCore::createAboutData() 648KAboutData *KABCore::createAboutData()
649#else //KAB_EMBEDDED 649#else //KAB_EMBEDDED
650void KABCore::createAboutData() 650void KABCore::createAboutData()
651#endif //KAB_EMBEDDED 651#endif //KAB_EMBEDDED
652{ 652{
653 653
654 654
655 QString version; 655 QString version;
656#include <../version> 656#include <../version>
657 QMessageBox::about( this, "About KAddressbook/Pi", 657 QMessageBox::about( this, "About KAddressbook/Pi",
658 "KAddressbook/Platform-independent\n" 658 "KAddressbook/Platform-independent\n"
659 "(KA/Pi) " +version + " - " + 659 "(KA/Pi) " +version + " - " +
660#ifdef DESKTOP_VERSION 660#ifdef DESKTOP_VERSION
661 "Desktop Edition\n" 661 "Desktop Edition\n"
662#else 662#else
663 "PDA-Edition\n" 663 "PDA-Edition\n"
664 "for: Zaurus 5500 / 7x0 / 8x0\n" 664 "for: Zaurus 5500 / 7x0 / 8x0\n"
665#endif 665#endif
666 666
667 "(c) 2004 Ulf Schenk\n" 667 "(c) 2004 Ulf Schenk\n"
668 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" 668 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n"
669 "(c) 1997-2003, The KDE PIM Team\n" 669 "(c) 1997-2003, The KDE PIM Team\n"
670 "Tobias Koenig Maintainer\n" 670 "Tobias Koenig Maintainer\n"
671 "Don Sanders Original author\n" 671 "Don Sanders Original author\n"
672 "Cornelius Schumacher Co-maintainer\n" 672 "Cornelius Schumacher Co-maintainer\n"
673 "Mike Pilone GUI and framework redesign\n" 673 "Mike Pilone GUI and framework redesign\n"
674 "Greg Stern DCOP interface\n" 674 "Greg Stern DCOP interface\n"
675 "Mark Westcot Contact pinning\n" 675 "Mark Westcot Contact pinning\n"
676 "Michel Boyer de la Giroday LDAP Lookup\n" 676 "Michel Boyer de la Giroday LDAP Lookup\n"
677 "Steffen Hansen LDAP Lookup" 677 "Steffen Hansen LDAP Lookup"
678#ifdef _WIN32_ 678#ifdef _WIN32_
679 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 679 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
680#endif 680#endif
681 ); 681 );
682} 682}
683 683
684void KABCore::setContactSelected( const QString &uid ) 684void KABCore::setContactSelected( const QString &uid )
685{ 685{
686 KABC::Addressee addr = mAddressBook->findByUid( uid ); 686 KABC::Addressee addr = mAddressBook->findByUid( uid );
687 if ( !mDetails->isHidden() ) 687 if ( !mDetails->isHidden() )
688 mDetails->setAddressee( addr ); 688 mDetails->setAddressee( addr );
689 689
690 if ( !addr.isEmpty() ) { 690 if ( !addr.isEmpty() ) {
691 emit contactSelected( addr.formattedName() ); 691 emit contactSelected( addr.formattedName() );
692 KABC::Picture pic = addr.photo(); 692 KABC::Picture pic = addr.photo();
693 if ( pic.isIntern() ) { 693 if ( pic.isIntern() ) {
694//US emit contactSelected( pic.data() ); 694//US emit contactSelected( pic.data() );
695//US instead use: 695//US instead use:
696 QPixmap px; 696 QPixmap px;
697 if (pic.data().isNull() != true) 697 if (pic.data().isNull() != true)
698 { 698 {
699 px.convertFromImage(pic.data()); 699 px.convertFromImage(pic.data());
700 } 700 }
701 701
702 emit contactSelected( px ); 702 emit contactSelected( px );
703 } 703 }
704 } 704 }
705 705
706 706
707 mExtensionManager->setSelectionChanged(); 707 mExtensionManager->setSelectionChanged();
708 708
709 // update the actions 709 // update the actions
710 bool selected = !uid.isEmpty(); 710 bool selected = !uid.isEmpty();
711 711
712 if ( mReadWrite ) { 712 if ( mReadWrite ) {
713 mActionCut->setEnabled( selected ); 713 mActionCut->setEnabled( selected );
714 mActionPaste->setEnabled( selected ); 714 mActionPaste->setEnabled( selected );
715 } 715 }
716 716
717 mActionCopy->setEnabled( selected ); 717 mActionCopy->setEnabled( selected );
718 mActionDelete->setEnabled( selected ); 718 mActionDelete->setEnabled( selected );
719 mActionEditAddressee->setEnabled( selected ); 719 mActionEditAddressee->setEnabled( selected );
720 mActionMail->setEnabled( selected ); 720 mActionMail->setEnabled( selected );
721 mActionMailVCard->setEnabled( selected ); 721 mActionMailVCard->setEnabled( selected );
722 //if (mActionBeam) 722 //if (mActionBeam)
723 //mActionBeam->setEnabled( selected ); 723 //mActionBeam->setEnabled( selected );
724 mActionWhoAmI->setEnabled( selected ); 724 mActionWhoAmI->setEnabled( selected );
725} 725}
726 726
727void KABCore::sendMail() 727void KABCore::sendMail()
728{ 728{
729 sendMail( mViewManager->selectedEmails().join( ", " ) ); 729 sendMail( mViewManager->selectedEmails().join( ", " ) );
730} 730}
731 731
732void KABCore::sendMail( const QString& emaillist ) 732void KABCore::sendMail( const QString& emaillist )
733{ 733{
734 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 734 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
735 if (emaillist.contains(",") > 0) 735 if (emaillist.contains(",") > 0)
736 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 736 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
737 else 737 else
738 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 738 ExternalAppHandler::instance()->mailToOneContact( emaillist );
739} 739}
740 740
741 741
742 742
743void KABCore::mailVCard() 743void KABCore::mailVCard()
744{ 744{
745 QStringList uids = mViewManager->selectedUids(); 745 QStringList uids = mViewManager->selectedUids();
746 if ( !uids.isEmpty() ) 746 if ( !uids.isEmpty() )
747 mailVCard( uids ); 747 mailVCard( uids );
748} 748}
749 749
750void KABCore::mailVCard( const QStringList& uids ) 750void KABCore::mailVCard( const QStringList& uids )
751{ 751{
752 QStringList urls; 752 QStringList urls;
753 753
754// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 754// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
755 755
756 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 756 QString dirName = "/tmp/" + KApplication::randomString( 8 );
757 757
758 758
759 759
760 QDir().mkdir( dirName, true ); 760 QDir().mkdir( dirName, true );
761 761
762 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 762 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
763 KABC::Addressee a = mAddressBook->findByUid( *it ); 763 KABC::Addressee a = mAddressBook->findByUid( *it );
764 764
765 if ( a.isEmpty() ) 765 if ( a.isEmpty() )
766 continue; 766 continue;
767 767
768 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 768 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
769 769
770 QString fileName = dirName + "/" + name; 770 QString fileName = dirName + "/" + name;
771 771
772 QFile outFile(fileName); 772 QFile outFile(fileName);
773 773
774 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 774 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
775 KABC::VCardConverter converter; 775 KABC::VCardConverter converter;
776 QString vcard; 776 QString vcard;
777 777
778 converter.addresseeToVCard( a, vcard ); 778 converter.addresseeToVCard( a, vcard );
779 779
780 QTextStream t( &outFile ); // use a text stream 780 QTextStream t( &outFile ); // use a text stream
781 t.setEncoding( QTextStream::UnicodeUTF8 ); 781 t.setEncoding( QTextStream::UnicodeUTF8 );
782 t << vcard; 782 t << vcard;
783 783
784 outFile.close(); 784 outFile.close();
785 785
786 urls.append( fileName ); 786 urls.append( fileName );
787 } 787 }
788 } 788 }
789 789
790 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 790 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
791 791
792 792
793/*US 793/*US
794 kapp->invokeMailer( QString::null, QString::null, QString::null, 794 kapp->invokeMailer( QString::null, QString::null, QString::null,
795 QString::null, // subject 795 QString::null, // subject
796 QString::null, // body 796 QString::null, // body
797 QString::null, 797 QString::null,
798 urls ); // attachments 798 urls ); // attachments
799*/ 799*/
800 800
801} 801}
802 802
803/** 803/**
804 Beams the "WhoAmI contact. 804 Beams the "WhoAmI contact.
805*/ 805*/
806void KABCore::beamMySelf() 806void KABCore::beamMySelf()
807{ 807{
808 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 808 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
809 if (!a.isEmpty()) 809 if (!a.isEmpty())
810 { 810 {
811 QStringList uids; 811 QStringList uids;
812 uids << a.uid(); 812 uids << a.uid();
813 813
814 beamVCard(uids); 814 beamVCard(uids);
815 } else { 815 } else {
816 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 816 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
817 817
818 818
819 } 819 }
820} 820}
821void KABCore::updateMainWindow() 821void KABCore::updateMainWindow()
822{ 822{
823 mMainWindow->showMaximized(); 823 mMainWindow->showMaximized();
824 mMainWindow->update(); 824 mMainWindow->update();
825} 825}
826void KABCore::resizeEvent(QResizeEvent* e ) 826void KABCore::resizeEvent(QResizeEvent* e )
827{ 827{
828 if ( !mMiniSplitter ) 828 if ( !mMiniSplitter )
829 return; 829 return;
830 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 830 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
831 if ( e->oldSize().width() != e->size().width() ) 831 if ( e->oldSize().width() != e->size().width() )
832 if ( QApplication::desktop()->width() >= 480 ) { 832 if ( QApplication::desktop()->width() >= 480 ) {
833 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 833 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
834 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 834 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
835 mMiniSplitter->setOrientation( Qt::Horizontal); 835 mMiniSplitter->setOrientation( Qt::Horizontal);
836 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 836 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
837 } 837 }
838 if ( QApplication::desktop()->width() <= 640 ) { 838 if ( QApplication::desktop()->width() <= 640 ) {
839 mMainWindow->showMinimized(); 839 mMainWindow->showMinimized();
840 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 840 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
841 mViewManager->getFilterAction()->setComboWidth( 150 ); 841 mViewManager->getFilterAction()->setComboWidth( 150 );
842 if ( mIncSearchWidget ) 842 if ( mIncSearchWidget )
843 mIncSearchWidget->setSize(); 843 mIncSearchWidget->setSize();
844 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 844 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
845 } 845 }
846 846
847 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 847 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
848 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 848 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
849 mMiniSplitter->setOrientation( Qt::Vertical ); 849 mMiniSplitter->setOrientation( Qt::Vertical );
850 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 850 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
851 } 851 }
852 if ( QApplication::desktop()->width() <= 640 ) { 852 if ( QApplication::desktop()->width() <= 640 ) {
853 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 853 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
854 mMainWindow->showMinimized(); 854 mMainWindow->showMinimized();
855 if ( KABPrefs::instance()->mHideSearchOnSwitch ) { 855 if ( KABPrefs::instance()->mHideSearchOnSwitch ) {
856 if ( mIncSearchWidget ) { 856 if ( mIncSearchWidget ) {
857 mIncSearchWidget->setSize(); 857 mIncSearchWidget->setSize();
858 } 858 }
859 } else { 859 } else {
860 mViewManager->getFilterAction()->setComboWidth( 0 ); 860 mViewManager->getFilterAction()->setComboWidth( 0 );
861 } 861 }
862 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 862 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
863 } 863 }
864 } 864 }
865 } 865 }
866 QWidget::resizeEvent( e ); 866 QWidget::resizeEvent( e );
867 867
868} 868}
869void KABCore::export2phone() 869void KABCore::export2phone()
870{ 870{
871 871
872 QStringList uids; 872 QStringList uids;
873 XXPortSelectDialog dlg( this, false, this ); 873 XXPortSelectDialog dlg( this, false, this );
874 if ( dlg.exec() ) 874 if ( dlg.exec() )
875 uids = dlg.uids(); 875 uids = dlg.uids();
876 else 876 else
877 return; 877 return;
878 if ( uids.isEmpty() ) 878 if ( uids.isEmpty() )
879 return; 879 return;
880 // qDebug("count %d ", uids.count()); 880 // qDebug("count %d ", uids.count());
881 881
882 KAex2phonePrefs ex2phone; 882 KAex2phonePrefs ex2phone;
883 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 883 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
884 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 884 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
885 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 885 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
886 886
887 if ( !ex2phone.exec() ) { 887 if ( !ex2phone.exec() ) {
888 return; 888 return;
889 } 889 }
890 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 890 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
891 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 891 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
892 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 892 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
893 893
894 894
895 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 895 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
896 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 896 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
897 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 897 KPimGlobalPrefs::instance()->mEx2PhoneModel );
898 898
899 QString fileName = getPhoneFile(); 899 QString fileName = getPhoneFile();
900 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 900 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
901 return; 901 return;
902 902
903 message(i18n("Exporting to phone...")); 903 message(i18n("Exporting to phone..."));
904 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 904 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
905 905
906} 906}
907QString KABCore::getPhoneFile() 907QString KABCore::getPhoneFile()
908{ 908{
909#ifdef DESKTOP_VERSION 909#ifdef DESKTOP_VERSION
910 return locateLocal("tmp", "phonefile.vcf"); 910 return locateLocal("tmp", "phonefile.vcf");
911#else 911#else
912 return "/tmp/phonefile.vcf"; 912 return "/tmp/phonefile.vcf";
913#endif 913#endif
914 914
915} 915}
916void KABCore::writeToPhone( ) 916void KABCore::writeToPhone( )
917{ 917{
918 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 918 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
919 message(i18n("Export to phone finished!")); 919 message(i18n("Export to phone finished!"));
920 else 920 else
921 qDebug(i18n("KA: Error exporting to phone")); 921 qDebug(i18n("KA: Error exporting to phone"));
922} 922}
923void KABCore::beamVCard() 923void KABCore::beamVCard()
924{ 924{
925 QStringList uids; 925 QStringList uids;
926 XXPortSelectDialog dlg( this, false, this ); 926 XXPortSelectDialog dlg( this, false, this );
927 if ( dlg.exec() ) 927 if ( dlg.exec() )
928 uids = dlg.uids(); 928 uids = dlg.uids();
929 else 929 else
930 return; 930 return;
931 if ( uids.isEmpty() ) 931 if ( uids.isEmpty() )
932 return; 932 return;
933 beamVCard( uids ); 933 beamVCard( uids );
934} 934}
935 935
936 936
937void KABCore::beamVCard(const QStringList& uids) 937void KABCore::beamVCard(const QStringList& uids)
938{ 938{
939 939
940 // LR: we should use the /tmp dir on the Zaurus, 940 // LR: we should use the /tmp dir on the Zaurus,
941 // because: /tmp = RAM, (HOME)/kdepim = flash memory 941 // because: /tmp = RAM, (HOME)/kdepim = flash memory
942 942
943#ifdef DESKTOP_VERSION 943#ifdef DESKTOP_VERSION
944 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 944 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
945#else 945#else
946 QString fileName = "/tmp/kapibeamfile.vcf"; 946 QString fileName = "/tmp/kapibeamfile.vcf";
947#endif 947#endif
948 948
949 KABC::VCardConverter converter; 949 KABC::VCardConverter converter;
950 QString description; 950 QString description;
951 QString datastream; 951 QString datastream;
952 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 952 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
953 KABC::Addressee a = mAddressBook->findByUid( *it ); 953 KABC::Addressee a = mAddressBook->findByUid( *it );
954 954
955 if ( a.isEmpty() ) 955 if ( a.isEmpty() )
956 continue; 956 continue;
957 957
958 if (description.isEmpty()) 958 if (description.isEmpty())
959 description = a.formattedName(); 959 description = a.formattedName();
960 960
961 QString vcard; 961 QString vcard;
962 converter.addresseeToVCard( a, vcard ); 962 converter.addresseeToVCard( a, vcard );
963 int start = 0; 963 int start = 0;
964 int next; 964 int next;
965 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 965 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
966 int semi = vcard.find(";", next); 966 int semi = vcard.find(";", next);
967 int dopp = vcard.find(":", next); 967 int dopp = vcard.find(":", next);
968 int sep; 968 int sep;
969 if ( semi < dopp && semi >= 0 ) 969 if ( semi < dopp && semi >= 0 )
970 sep = semi ; 970 sep = semi ;
971 else 971 else
972 sep = dopp; 972 sep = dopp;
973 datastream +=vcard.mid( start, next - start); 973 datastream +=vcard.mid( start, next - start);
974 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 974 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
975 start = sep; 975 start = sep;
976 } 976 }
977 datastream += vcard.mid( start,vcard.length() ); 977 datastream += vcard.mid( start,vcard.length() );
978 } 978 }
979#ifndef DESKTOP_VERSION 979#ifndef DESKTOP_VERSION
980 QFile outFile(fileName); 980 QFile outFile(fileName);
981 if ( outFile.open(IO_WriteOnly) ) { 981 if ( outFile.open(IO_WriteOnly) ) {
982 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 982 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
983 QTextStream t( &outFile ); // use a text stream 983 QTextStream t( &outFile ); // use a text stream
984 //t.setEncoding( QTextStream::UnicodeUTF8 ); 984 //t.setEncoding( QTextStream::UnicodeUTF8 );
985 t.setEncoding( QTextStream::Latin1 ); 985 t.setEncoding( QTextStream::Latin1 );
986 t <<datastream.latin1(); 986 t <<datastream.latin1();
987 outFile.close(); 987 outFile.close();
988 Ir *ir = new Ir( this ); 988 Ir *ir = new Ir( this );
989 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 989 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
990 ir->send( fileName, description, "text/x-vCard" ); 990 ir->send( fileName, description, "text/x-vCard" );
991 } else { 991 } else {
992 qDebug("KA: Error open temp beam file "); 992 qDebug("KA: Error open temp beam file ");
993 return; 993 return;
994 } 994 }
995#endif 995#endif
996 996
997} 997}
998 998
999void KABCore::beamDone( Ir *ir ) 999void KABCore::beamDone( Ir *ir )
1000{ 1000{
1001#ifndef DESKTOP_VERSION 1001#ifndef DESKTOP_VERSION
1002 delete ir; 1002 delete ir;
1003#endif 1003#endif
1004 topLevelWidget()->raise(); 1004 topLevelWidget()->raise();
1005 message( i18n("Beaming finished!") ); 1005 message( i18n("Beaming finished!") );
1006} 1006}
1007 1007
1008 1008
1009void KABCore::browse( const QString& url ) 1009void KABCore::browse( const QString& url )
1010{ 1010{
1011#ifndef KAB_EMBEDDED 1011#ifndef KAB_EMBEDDED
1012 kapp->invokeBrowser( url ); 1012 kapp->invokeBrowser( url );
1013#else //KAB_EMBEDDED 1013#else //KAB_EMBEDDED
1014 qDebug("KABCore::browse must be fixed"); 1014 qDebug("KABCore::browse must be fixed");
1015#endif //KAB_EMBEDDED 1015#endif //KAB_EMBEDDED
1016} 1016}
1017 1017
1018void KABCore::selectAllContacts() 1018void KABCore::selectAllContacts()
1019{ 1019{
1020 mViewManager->setSelected( QString::null, true ); 1020 mViewManager->setSelected( QString::null, true );
1021} 1021}
1022 1022
1023void KABCore::deleteContacts() 1023void KABCore::deleteContacts()
1024{ 1024{
1025 QStringList uidList = mViewManager->selectedUids(); 1025 QStringList uidList = mViewManager->selectedUids();
1026 deleteContacts( uidList ); 1026 deleteContacts( uidList );
1027} 1027}
1028 1028
1029void KABCore::deleteContacts( const QStringList &uids ) 1029void KABCore::deleteContacts( const QStringList &uids )
1030{ 1030{
1031
1031 if ( uids.count() > 0 ) { 1032 if ( uids.count() > 0 ) {
1033
1034 if ( KABPrefs::instance()->mAskForDelete ) {
1035 int count = uids.count();
1036 if ( count > 5 ) count = 5;
1037 QString cNames;
1038 int i;
1039 for ( i = 0; i < count ; ++i ) {
1040 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n";
1041 }
1042 if ( uids.count() > 5 )
1043 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 );
1044 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ;
1045 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes )
1046 return;
1047 }
1032 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1048 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1033 UndoStack::instance()->push( command ); 1049 UndoStack::instance()->push( command );
1034 RedoStack::instance()->clear(); 1050 RedoStack::instance()->clear();
1035 1051
1036 // now if we deleted anything, refresh 1052 // now if we deleted anything, refresh
1037 setContactSelected( QString::null ); 1053 setContactSelected( QString::null );
1038 setModified( true ); 1054 setModified( true );
1039 } 1055 }
1040} 1056}
1041 1057
1042void KABCore::copyContacts() 1058void KABCore::copyContacts()
1043{ 1059{
1044 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1060 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1045 1061
1046 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1062 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1047 1063
1048 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1064 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1049 1065
1050 QClipboard *cb = QApplication::clipboard(); 1066 QClipboard *cb = QApplication::clipboard();
1051 cb->setText( clipText ); 1067 cb->setText( clipText );
1052} 1068}
1053 1069
1054void KABCore::cutContacts() 1070void KABCore::cutContacts()
1055{ 1071{
1056 QStringList uidList = mViewManager->selectedUids(); 1072 QStringList uidList = mViewManager->selectedUids();
1057 1073
1058//US if ( uidList.size() > 0 ) { 1074//US if ( uidList.size() > 0 ) {
1059 if ( uidList.count() > 0 ) { 1075 if ( uidList.count() > 0 ) {
1060 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1076 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1061 UndoStack::instance()->push( command ); 1077 UndoStack::instance()->push( command );
1062 RedoStack::instance()->clear(); 1078 RedoStack::instance()->clear();
1063 1079
1064 setModified( true ); 1080 setModified( true );
1065 } 1081 }
1066} 1082}
1067 1083
1068void KABCore::pasteContacts() 1084void KABCore::pasteContacts()
1069{ 1085{
1070 QClipboard *cb = QApplication::clipboard(); 1086 QClipboard *cb = QApplication::clipboard();
1071 1087
1072 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1088 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1073 1089
1074 pasteContacts( list ); 1090 pasteContacts( list );
1075} 1091}
1076 1092
1077void KABCore::pasteContacts( KABC::Addressee::List &list ) 1093void KABCore::pasteContacts( KABC::Addressee::List &list )
1078{ 1094{
1079 KABC::Resource *resource = requestResource( this ); 1095 KABC::Resource *resource = requestResource( this );
1080 KABC::Addressee::List::Iterator it; 1096 KABC::Addressee::List::Iterator it;
1081 for ( it = list.begin(); it != list.end(); ++it ) 1097 for ( it = list.begin(); it != list.end(); ++it )
1082 (*it).setResource( resource ); 1098 (*it).setResource( resource );
1083 1099
1084 PwPasteCommand *command = new PwPasteCommand( this, list ); 1100 PwPasteCommand *command = new PwPasteCommand( this, list );
1085 UndoStack::instance()->push( command ); 1101 UndoStack::instance()->push( command );
1086 RedoStack::instance()->clear(); 1102 RedoStack::instance()->clear();
1087 1103
1088 setModified( true ); 1104 setModified( true );
1089} 1105}
1090 1106
1091void KABCore::setWhoAmI() 1107void KABCore::setWhoAmI()
1092{ 1108{
1093 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1109 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1094 1110
1095 if ( addrList.count() > 1 ) { 1111 if ( addrList.count() > 1 ) {
1096 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1112 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1097 return; 1113 return;
1098 } 1114 }
1099 1115
1100 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1116 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1101 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1117 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes )
1102 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1118 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1103} 1119}
1104void KABCore::editCategories() 1120void KABCore::editCategories()
1105{ 1121{
1106 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1122 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1107 dlg.exec(); 1123 dlg.exec();
1108} 1124}
1109void KABCore::setCategories() 1125void KABCore::setCategories()
1110{ 1126{
1111 1127
1112 QStringList uids; 1128 QStringList uids;
1113 XXPortSelectDialog dlgx( this, false, this ); 1129 XXPortSelectDialog dlgx( this, false, this );
1114 if ( dlgx.exec() ) 1130 if ( dlgx.exec() )
1115 uids = dlgx.uids(); 1131 uids = dlgx.uids();
1116 else 1132 else
1117 return; 1133 return;
1118 if ( uids.isEmpty() ) 1134 if ( uids.isEmpty() )
1119 return; 1135 return;
1120 // qDebug("count %d ", uids.count()); 1136 // qDebug("count %d ", uids.count());
1121 1137
1122 1138
1123 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1139 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1124 if ( !dlg.exec() ) { 1140 if ( !dlg.exec() ) {
1125 message( i18n("Setting categories cancelled") ); 1141 message( i18n("Setting categories cancelled") );
1126 return; 1142 return;
1127 } 1143 }
1128 bool merge = false; 1144 bool merge = false;
1129 QString msg = i18n( "Merge with existing categories?" ); 1145 QString msg = i18n( "Merge with existing categories?" );
1130 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1146 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1131 merge = true; 1147 merge = true;
1132 1148
1133 message( i18n("Setting categories ... please wait!") ); 1149 message( i18n("Setting categories ... please wait!") );
1134 QStringList categories = dlg.selectedCategories(); 1150 QStringList categories = dlg.selectedCategories();
1135 1151
1136 //QStringList uids = mViewManager->selectedUids(); 1152 //QStringList uids = mViewManager->selectedUids();
1137 QStringList::Iterator it; 1153 QStringList::Iterator it;
1138 for ( it = uids.begin(); it != uids.end(); ++it ) { 1154 for ( it = uids.begin(); it != uids.end(); ++it ) {
1139 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1155 KABC::Addressee addr = mAddressBook->findByUid( *it );
1140 if ( !addr.isEmpty() ) { 1156 if ( !addr.isEmpty() ) {
1141 if ( !merge ) 1157 if ( !merge )
1142 addr.setCategories( categories ); 1158 addr.setCategories( categories );
1143 else { 1159 else {
1144 QStringList addrCategories = addr.categories(); 1160 QStringList addrCategories = addr.categories();
1145 QStringList::Iterator catIt; 1161 QStringList::Iterator catIt;
1146 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1162 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1147 if ( !addrCategories.contains( *catIt ) ) 1163 if ( !addrCategories.contains( *catIt ) )
1148 addrCategories.append( *catIt ); 1164 addrCategories.append( *catIt );
1149 } 1165 }
1150 addr.setCategories( addrCategories ); 1166 addr.setCategories( addrCategories );
1151 } 1167 }
1152 mAddressBook->insertAddressee( addr ); 1168 mAddressBook->insertAddressee( addr );
1153 } 1169 }
1154 } 1170 }
1155 1171
1156 if ( uids.count() > 0 ) 1172 if ( uids.count() > 0 )
1157 setModified( true ); 1173 setModified( true );
1158 message( i18n("Setting categories completed!") ); 1174 message( i18n("Setting categories completed!") );
1159} 1175}
1160 1176
1161void KABCore::setSearchFields( const KABC::Field::List &fields ) 1177void KABCore::setSearchFields( const KABC::Field::List &fields )
1162{ 1178{
1163 mIncSearchWidget->setFields( fields ); 1179 mIncSearchWidget->setFields( fields );
1164} 1180}
1165 1181
1166void KABCore::incrementalSearch( const QString& text ) 1182void KABCore::incrementalSearch( const QString& text )
1167{ 1183{
1168 QString stext; 1184 QString stext;
1169 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1185 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1170 stext = "*" + text; 1186 stext = "*" + text;
1171 } else { 1187 } else {
1172 stext = text; 1188 stext = text;
1173 } 1189 }
1174 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1190 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1175} 1191}
1176void KABCore::incrementalSearchJump( const QString& text ) 1192void KABCore::incrementalSearchJump( const QString& text )
1177{ 1193{
1178 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1194 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1179} 1195}
1180 1196
1181void KABCore::setModified() 1197void KABCore::setModified()
1182{ 1198{
1183 setModified( true ); 1199 setModified( true );
1184} 1200}
1185 1201
1186void KABCore::setModifiedWOrefresh() 1202void KABCore::setModifiedWOrefresh()
1187{ 1203{
1188 // qDebug("KABCore::setModifiedWOrefresh() "); 1204 // qDebug("KABCore::setModifiedWOrefresh() ");
1189 mModified = true; 1205 mModified = true;
1190 mActionSave->setEnabled( mModified ); 1206 mActionSave->setEnabled( mModified );
1191 1207
1192 1208
1193} 1209}
1194void KABCore::setModified( bool modified ) 1210void KABCore::setModified( bool modified )
1195{ 1211{
1196 mModified = modified; 1212 mModified = modified;
1197 mActionSave->setEnabled( mModified ); 1213 mActionSave->setEnabled( mModified );
1198 1214
1199 if ( modified ) 1215 if ( modified )
1200 mJumpButtonBar->recreateButtons(); 1216 mJumpButtonBar->recreateButtons();
1201 1217
1202 mViewManager->refreshView(); 1218 mViewManager->refreshView();
1203 1219
1204} 1220}
1205 1221
1206bool KABCore::modified() const 1222bool KABCore::modified() const
1207{ 1223{
1208 return mModified; 1224 return mModified;
1209} 1225}
1210 1226
1211void KABCore::contactModified( const KABC::Addressee &addr ) 1227void KABCore::contactModified( const KABC::Addressee &addr )
1212{ 1228{
1213 addrModified( addr ); 1229 addrModified( addr );
1214#if 0 // debug only 1230#if 0 // debug only
1215 KABC::Addressee ad = addr; 1231 KABC::Addressee ad = addr;
1216 ad.computeCsum( "123"); 1232 ad.computeCsum( "123");
1217#endif 1233#endif
1218} 1234}
1219 1235
1220void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1236void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1221{ 1237{
1222 1238
1223 Command *command = 0; 1239 Command *command = 0;
1224 QString uid; 1240 QString uid;
1225 1241
1226 // check if it exists already 1242 // check if it exists already
1227 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1243 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1228 if ( origAddr.isEmpty() ) 1244 if ( origAddr.isEmpty() )
1229 command = new PwNewCommand( mAddressBook, addr ); 1245 command = new PwNewCommand( mAddressBook, addr );
1230 else { 1246 else {
1231 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1247 command = new PwEditCommand( mAddressBook, origAddr, addr );
1232 uid = addr.uid(); 1248 uid = addr.uid();
1233 } 1249 }
1234 1250
1235 UndoStack::instance()->push( command ); 1251 UndoStack::instance()->push( command );
1236 RedoStack::instance()->clear(); 1252 RedoStack::instance()->clear();
1237 if ( updateDetails ) 1253 if ( updateDetails )
1238 mDetails->setAddressee( addr ); 1254 mDetails->setAddressee( addr );
1239 setModified( true ); 1255 setModified( true );
1240} 1256}
1241 1257
1242void KABCore::newContact() 1258void KABCore::newContact()
1243{ 1259{
1244 1260
1245 1261
1246 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1262 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1247 1263
1248 QPtrList<KRES::Resource> kresResources; 1264 QPtrList<KRES::Resource> kresResources;
1249 QPtrListIterator<KABC::Resource> it( kabcResources ); 1265 QPtrListIterator<KABC::Resource> it( kabcResources );
1250 KABC::Resource *resource; 1266 KABC::Resource *resource;
1251 while ( ( resource = it.current() ) != 0 ) { 1267 while ( ( resource = it.current() ) != 0 ) {
1252 ++it; 1268 ++it;
1253 if ( !resource->readOnly() ) { 1269 if ( !resource->readOnly() ) {
1254 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1270 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1255 if ( res ) 1271 if ( res )
1256 kresResources.append( res ); 1272 kresResources.append( res );
1257 } 1273 }
1258 } 1274 }
1259 1275
1260 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1276 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1261 resource = static_cast<KABC::Resource*>( res ); 1277 resource = static_cast<KABC::Resource*>( res );
1262 1278
1263 if ( resource ) { 1279 if ( resource ) {
1264 KABC::Addressee addr; 1280 KABC::Addressee addr;
1265 addr.setResource( resource ); 1281 addr.setResource( resource );
1266 mEditorDialog->setAddressee( addr ); 1282 mEditorDialog->setAddressee( addr );
1267 mEditorDialog->setCaption( i18n("Edit new contact")); 1283 mEditorDialog->setCaption( i18n("Edit new contact"));
1268 KApplication::execDialog ( mEditorDialog ); 1284 KApplication::execDialog ( mEditorDialog );
1269 1285
1270 } else 1286 } else
1271 return; 1287 return;
1272 1288
1273 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1289 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1274 1290
1275 1291
1276} 1292}
1277 1293
1278void KABCore::addEmail( QString aStr ) 1294void KABCore::addEmail( QString aStr )
1279{ 1295{
1280#ifndef KAB_EMBEDDED 1296#ifndef KAB_EMBEDDED
1281 QString fullName, email; 1297 QString fullName, email;
1282 1298
1283 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1299 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1284 1300
1285 // Try to lookup the addressee matching the email address 1301 // Try to lookup the addressee matching the email address
1286 bool found = false; 1302 bool found = false;
1287 QStringList emailList; 1303 QStringList emailList;
1288 KABC::AddressBook::Iterator it; 1304 KABC::AddressBook::Iterator it;
1289 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1305 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1290 emailList = (*it).emails(); 1306 emailList = (*it).emails();
1291 if ( emailList.contains( email ) > 0 ) { 1307 if ( emailList.contains( email ) > 0 ) {
1292 found = true; 1308 found = true;
1293 (*it).setNameFromString( fullName ); 1309 (*it).setNameFromString( fullName );
1294 editContact( (*it).uid() ); 1310 editContact( (*it).uid() );
1295 } 1311 }
1296 } 1312 }
1297 1313
1298 if ( !found ) { 1314 if ( !found ) {
1299 KABC::Addressee addr; 1315 KABC::Addressee addr;
1300 addr.setNameFromString( fullName ); 1316 addr.setNameFromString( fullName );
1301 addr.insertEmail( email, true ); 1317 addr.insertEmail( email, true );
1302 1318
1303 mAddressBook->insertAddressee( addr ); 1319 mAddressBook->insertAddressee( addr );
1304 mViewManager->refreshView( addr.uid() ); 1320 mViewManager->refreshView( addr.uid() );
1305 editContact( addr.uid() ); 1321 editContact( addr.uid() );
1306 } 1322 }
1307#else //KAB_EMBEDDED 1323#else //KAB_EMBEDDED
1308 qDebug("KABCore::addEmail finsih method"); 1324 qDebug("KABCore::addEmail finsih method");
1309#endif //KAB_EMBEDDED 1325#endif //KAB_EMBEDDED
1310} 1326}
1311 1327
1312void KABCore::importVCard( const KURL &url, bool showPreview ) 1328void KABCore::importVCard( const KURL &url, bool showPreview )
1313{ 1329{
1314 mXXPortManager->importVCard( url, showPreview ); 1330 mXXPortManager->importVCard( url, showPreview );
1315} 1331}
1316void KABCore::importFromOL() 1332void KABCore::importFromOL()
1317{ 1333{
1318#ifdef _OL_IMPORT_ 1334#ifdef _OL_IMPORT_
1319 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1335 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1320 idgl->exec(); 1336 idgl->exec();
1321 KABC::Addressee::List list = idgl->getAddressList(); 1337 KABC::Addressee::List list = idgl->getAddressList();
1322 if ( list.count() > 0 ) { 1338 if ( list.count() > 0 ) {
1323 KABC::Addressee::List listNew; 1339 KABC::Addressee::List listNew;
1324 KABC::Addressee::List listExisting; 1340 KABC::Addressee::List listExisting;
1325 KABC::Addressee::List::Iterator it; 1341 KABC::Addressee::List::Iterator it;
1326 KABC::AddressBook::Iterator iter; 1342 KABC::AddressBook::Iterator iter;
1327 for ( it = list.begin(); it != list.end(); ++it ) { 1343 for ( it = list.begin(); it != list.end(); ++it ) {
1328 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1344 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1329 listNew.append( (*it) ); 1345 listNew.append( (*it) );
1330 else 1346 else
1331 listExisting.append( (*it) ); 1347 listExisting.append( (*it) );
1332 } 1348 }
1333 if ( listExisting.count() > 0 ) 1349 if ( listExisting.count() > 0 )
1334 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1350 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1335 if ( listNew.count() > 0 ) { 1351 if ( listNew.count() > 0 ) {
1336 pasteWithNewUid = false; 1352 pasteWithNewUid = false;
1337 pasteContacts( listNew ); 1353 pasteContacts( listNew );
1338 pasteWithNewUid = true; 1354 pasteWithNewUid = true;
1339 } 1355 }
1340 } 1356 }
1341 delete idgl; 1357 delete idgl;
1342#endif 1358#endif
1343} 1359}
1344 1360
1345void KABCore::importVCard( const QString &vCard, bool showPreview ) 1361void KABCore::importVCard( const QString &vCard, bool showPreview )
1346{ 1362{
1347 mXXPortManager->importVCard( vCard, showPreview ); 1363 mXXPortManager->importVCard( vCard, showPreview );
1348} 1364}
1349 1365
1350//US added a second method without defaultparameter 1366//US added a second method without defaultparameter
1351void KABCore::editContact2() { 1367void KABCore::editContact2() {
1352 editContact( QString::null ); 1368 editContact( QString::null );
1353} 1369}
1354 1370
1355void KABCore::editContact( const QString &uid ) 1371void KABCore::editContact( const QString &uid )
1356{ 1372{
1357 1373
1358 if ( mExtensionManager->isQuickEditVisible() ) 1374 if ( mExtensionManager->isQuickEditVisible() )
1359 return; 1375 return;
1360 1376
1361 // First, locate the contact entry 1377 // First, locate the contact entry
1362 QString localUID = uid; 1378 QString localUID = uid;
1363 if ( localUID.isNull() ) { 1379 if ( localUID.isNull() ) {
1364 QStringList uidList = mViewManager->selectedUids(); 1380 QStringList uidList = mViewManager->selectedUids();
1365 if ( uidList.count() > 0 ) 1381 if ( uidList.count() > 0 )
1366 localUID = *( uidList.at( 0 ) ); 1382 localUID = *( uidList.at( 0 ) );
1367 } 1383 }
1368 1384
1369 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1385 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1370 if ( !addr.isEmpty() ) { 1386 if ( !addr.isEmpty() ) {
1371 mEditorDialog->setAddressee( addr ); 1387 mEditorDialog->setAddressee( addr );
1372 KApplication::execDialog ( mEditorDialog ); 1388 KApplication::execDialog ( mEditorDialog );
1373 } 1389 }
1374} 1390}
1375 1391
1376/** 1392/**
1377 Shows or edits the detail view for the given uid. If the uid is QString::null, 1393 Shows or edits the detail view for the given uid. If the uid is QString::null,
1378 the method will try to find a selected addressee in the view. 1394 the method will try to find a selected addressee in the view.
1379 */ 1395 */
1380void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1396void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1381{ 1397{
1382 if ( mMultipleViewsAtOnce ) 1398 if ( mMultipleViewsAtOnce )
1383 { 1399 {
1384 editContact( uid ); 1400 editContact( uid );
1385 } 1401 }
1386 else 1402 else
1387 { 1403 {
1388 setDetailsVisible( true ); 1404 setDetailsVisible( true );
1389 mActionDetails->setChecked(true); 1405 mActionDetails->setChecked(true);
1390 } 1406 }
1391 1407
1392} 1408}
1393 1409
1394void KABCore::save() 1410void KABCore::save()
1395{ 1411{
1396 if (syncManager->blockSave()) 1412 if (syncManager->blockSave())
1397 return; 1413 return;
1398 if ( !mModified ) 1414 if ( !mModified )
1399 return; 1415 return;
1400 1416
1401 syncManager->setBlockSave(true); 1417 syncManager->setBlockSave(true);
1402 QString text = i18n( "There was an error while attempting to save\n the " 1418 QString text = i18n( "There was an error while attempting to save\n the "
1403 "address book. Please check that some \nother application is " 1419 "address book. Please check that some \nother application is "
1404 "not using it. " ); 1420 "not using it. " );
1405 message(i18n("Saving ... please wait! "), false); 1421 message(i18n("Saving ... please wait! "), false);
1406 //qApp->processEvents(); 1422 //qApp->processEvents();
1407#ifndef KAB_EMBEDDED 1423#ifndef KAB_EMBEDDED
1408 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1424 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1409 if ( !b || !b->save() ) { 1425 if ( !b || !b->save() ) {
1410 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1426 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1411 } 1427 }
1412#else //KAB_EMBEDDED 1428#else //KAB_EMBEDDED
1413 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1429 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1414 if ( !b || !b->save() ) { 1430 if ( !b || !b->save() ) {
1415 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1431 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1416 } 1432 }
1417#endif //KAB_EMBEDDED 1433#endif //KAB_EMBEDDED
1418 1434
1419 message(i18n("Addressbook saved!")); 1435 message(i18n("Addressbook saved!"));
1420 setModified( false ); 1436 setModified( false );
1421 syncManager->setBlockSave(false); 1437 syncManager->setBlockSave(false);
1422} 1438}
1423 1439
1424 1440
1425void KABCore::undo() 1441void KABCore::undo()
1426{ 1442{
1427 UndoStack::instance()->undo(); 1443 UndoStack::instance()->undo();
1428 1444
1429 // Refresh the view 1445 // Refresh the view
1430 mViewManager->refreshView(); 1446 mViewManager->refreshView();
1431} 1447}
1432 1448
1433void KABCore::redo() 1449void KABCore::redo()
1434{ 1450{
1435 RedoStack::instance()->redo(); 1451 RedoStack::instance()->redo();
1436 1452
1437 // Refresh the view 1453 // Refresh the view
1438 mViewManager->refreshView(); 1454 mViewManager->refreshView();
1439} 1455}
1440void KABCore::setJumpButtonBar( bool visible ) 1456void KABCore::setJumpButtonBar( bool visible )
1441{ 1457{
1442 setJumpButtonBarVisible(visible ); 1458 setJumpButtonBarVisible(visible );
1443 saveSettings(); 1459 saveSettings();
1444} 1460}
1445void KABCore::setJumpButtonBarVisible( bool visible ) 1461void KABCore::setJumpButtonBarVisible( bool visible )
1446{ 1462{
1447 if (mMultipleViewsAtOnce) 1463 if (mMultipleViewsAtOnce)
1448 { 1464 {
1449 if ( visible ) 1465 if ( visible )
1450 mJumpButtonBar->show(); 1466 mJumpButtonBar->show();
1451 else 1467 else
1452 mJumpButtonBar->hide(); 1468 mJumpButtonBar->hide();
1453 } 1469 }
1454 else 1470 else
1455 { 1471 {
1456 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1472 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1457 if (mViewManager->isVisible()) 1473 if (mViewManager->isVisible())
1458 { 1474 {
1459 if ( visible ) 1475 if ( visible )
1460 mJumpButtonBar->show(); 1476 mJumpButtonBar->show();
1461 else 1477 else
1462 mJumpButtonBar->hide(); 1478 mJumpButtonBar->hide();
1463 } 1479 }
1464 else 1480 else
1465 { 1481 {
1466 mJumpButtonBar->hide(); 1482 mJumpButtonBar->hide();
1467 } 1483 }
1468 } 1484 }
1469 if ( visible ) { 1485 if ( visible ) {
1470 if ( mIncSearchWidget->currentItem() == 0 ) { 1486 if ( mIncSearchWidget->currentItem() == 0 ) {
1471 message( i18n("Change search field enable jump bar") ); 1487 message( i18n("Change search field enable jump bar") );
1472 } 1488 }
1473 } 1489 }
1474} 1490}
1475 1491
1476 1492
1477void KABCore::setDetailsToState() 1493void KABCore::setDetailsToState()
1478{ 1494{
1479 setDetailsVisible( mActionDetails->isChecked() ); 1495 setDetailsVisible( mActionDetails->isChecked() );
1480} 1496}
1481void KABCore::setDetailsToggle() 1497void KABCore::setDetailsToggle()
1482{ 1498{
1483 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1499 mActionDetails->setChecked( !mActionDetails->isChecked() );
1484 setDetailsToState(); 1500 setDetailsToState();
1485} 1501}
1486 1502
1487 1503
1488 1504
1489void KABCore::setDetailsVisible( bool visible ) 1505void KABCore::setDetailsVisible( bool visible )
1490{ 1506{
1491 if (visible && mDetails->isHidden()) 1507 if (visible && mDetails->isHidden())
1492 { 1508 {
1493 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1509 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1494 if ( addrList.count() > 0 ) 1510 if ( addrList.count() > 0 )
1495 mDetails->setAddressee( addrList[ 0 ] ); 1511 mDetails->setAddressee( addrList[ 0 ] );
1496 } 1512 }
1497 1513
1498 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1514 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1499 // the listview and the detailview. We do that by changing the splitbar size. 1515 // the listview and the detailview. We do that by changing the splitbar size.
1500 if (mMultipleViewsAtOnce) 1516 if (mMultipleViewsAtOnce)
1501 { 1517 {
1502 if ( visible ) 1518 if ( visible )
1503 mDetails->show(); 1519 mDetails->show();
1504 else 1520 else
1505 mDetails->hide(); 1521 mDetails->hide();
1506 } 1522 }
1507 else 1523 else
1508 { 1524 {
1509 if ( visible ) { 1525 if ( visible ) {
1510 mViewManager->hide(); 1526 mViewManager->hide();
1511 mDetails->show(); 1527 mDetails->show();
1512 mIncSearchWidget->setFocus(); 1528 mIncSearchWidget->setFocus();
1513 } 1529 }
1514 else { 1530 else {
1515 mViewManager->show(); 1531 mViewManager->show();
1516 mDetails->hide(); 1532 mDetails->hide();
1517 mViewManager->setFocusAV(); 1533 mViewManager->setFocusAV();
1518 } 1534 }
1519 setJumpButtonBarVisible( !visible ); 1535 setJumpButtonBarVisible( !visible );
1520 } 1536 }
1521 1537
1522} 1538}
1523 1539
1524void KABCore::extensionChanged( int id ) 1540void KABCore::extensionChanged( int id )
1525{ 1541{
1526 //change the details view only for non desktop systems 1542 //change the details view only for non desktop systems
1527#ifndef DESKTOP_VERSION 1543#ifndef DESKTOP_VERSION
1528 1544
1529 if (id == 0) 1545 if (id == 0)
1530 { 1546 {
1531 //the user disabled the extension. 1547 //the user disabled the extension.
1532 1548
1533 if (mMultipleViewsAtOnce) 1549 if (mMultipleViewsAtOnce)
1534 { // enable detailsview again 1550 { // enable detailsview again
1535 setDetailsVisible( true ); 1551 setDetailsVisible( true );
1536 mActionDetails->setChecked( true ); 1552 mActionDetails->setChecked( true );
1537 } 1553 }
1538 else 1554 else
1539 { //go back to the listview 1555 { //go back to the listview
1540 setDetailsVisible( false ); 1556 setDetailsVisible( false );
1541 mActionDetails->setChecked( false ); 1557 mActionDetails->setChecked( false );
1542 mActionDetails->setEnabled(true); 1558 mActionDetails->setEnabled(true);
1543 } 1559 }
1544 1560
1545 } 1561 }
1546 else 1562 else
1547 { 1563 {
1548 //the user enabled the extension. 1564 //the user enabled the extension.
1549 setDetailsVisible( false ); 1565 setDetailsVisible( false );
1550 mActionDetails->setChecked( false ); 1566 mActionDetails->setChecked( false );
1551 1567
1552 if (!mMultipleViewsAtOnce) 1568 if (!mMultipleViewsAtOnce)
1553 { 1569 {
1554 mActionDetails->setEnabled(false); 1570 mActionDetails->setEnabled(false);
1555 } 1571 }
1556 1572
1557 mExtensionManager->setSelectionChanged(); 1573 mExtensionManager->setSelectionChanged();
1558 1574
1559 } 1575 }
1560 1576
1561#endif// DESKTOP_VERSION 1577#endif// DESKTOP_VERSION
1562 1578
1563} 1579}
1564 1580
1565 1581
1566void KABCore::extensionModified( const KABC::Addressee::List &list ) 1582void KABCore::extensionModified( const KABC::Addressee::List &list )
1567{ 1583{
1568 1584
1569 if ( list.count() != 0 ) { 1585 if ( list.count() != 0 ) {
1570 KABC::Addressee::List::ConstIterator it; 1586 KABC::Addressee::List::ConstIterator it;
1571 for ( it = list.begin(); it != list.end(); ++it ) 1587 for ( it = list.begin(); it != list.end(); ++it )
1572 mAddressBook->insertAddressee( *it ); 1588 mAddressBook->insertAddressee( *it );
1573 if ( list.count() > 1 ) 1589 if ( list.count() > 1 )
1574 setModified(); 1590 setModified();
1575 else 1591 else
1576 setModifiedWOrefresh(); 1592 setModifiedWOrefresh();
1577 } 1593 }
1578 if ( list.count() == 0 ) 1594 if ( list.count() == 0 )
1579 mViewManager->refreshView(); 1595 mViewManager->refreshView();
1580 else 1596 else
1581 mViewManager->refreshView( list[ 0 ].uid() ); 1597 mViewManager->refreshView( list[ 0 ].uid() );
1582 1598
1583 1599
1584 1600
1585} 1601}
1586 1602
1587QString KABCore::getNameByPhone( const QString &phone ) 1603QString KABCore::getNameByPhone( const QString &phone )
1588{ 1604{
1589#ifndef KAB_EMBEDDED 1605#ifndef KAB_EMBEDDED
1590 QRegExp r( "[/*/-/ ]" ); 1606 QRegExp r( "[/*/-/ ]" );
1591 QString localPhone( phone ); 1607 QString localPhone( phone );
1592 1608
1593 bool found = false; 1609 bool found = false;
1594 QString ownerName = ""; 1610 QString ownerName = "";
1595 KABC::AddressBook::Iterator iter; 1611 KABC::AddressBook::Iterator iter;
1596 KABC::PhoneNumber::List::Iterator phoneIter; 1612 KABC::PhoneNumber::List::Iterator phoneIter;
1597 KABC::PhoneNumber::List phoneList; 1613 KABC::PhoneNumber::List phoneList;
1598 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1614 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1599 phoneList = (*iter).phoneNumbers(); 1615 phoneList = (*iter).phoneNumbers();
1600 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1616 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1601 ++phoneIter) { 1617 ++phoneIter) {
1602 // Get rid of separator chars so just the numbers are compared. 1618 // Get rid of separator chars so just the numbers are compared.
1603 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1619 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1604 ownerName = (*iter).formattedName(); 1620 ownerName = (*iter).formattedName();
1605 found = true; 1621 found = true;
1606 } 1622 }
1607 } 1623 }
1608 } 1624 }
1609 1625
1610 return ownerName; 1626 return ownerName;
1611#else //KAB_EMBEDDED 1627#else //KAB_EMBEDDED
1612 qDebug("KABCore::getNameByPhone finsih method"); 1628 qDebug("KABCore::getNameByPhone finsih method");
1613 return ""; 1629 return "";
1614#endif //KAB_EMBEDDED 1630#endif //KAB_EMBEDDED
1615 1631
1616} 1632}
1617void KABCore::openConfigGlobalDialog() 1633void KABCore::openConfigGlobalDialog()
1618{ 1634{
1619 KPimPrefsGlobalDialog gc ( this ); 1635 KPimPrefsGlobalDialog gc ( this );
1620 gc.exec(); 1636 gc.exec();
1621} 1637}
1622void KABCore::openConfigDialog() 1638void KABCore::openConfigDialog()
1623{ 1639{
1624 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true); 1640 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true);
1625 1641
1626 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" ); 1642 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" );
1627 ConfigureDialog->setMainWidget( kabcfg ); 1643 ConfigureDialog->setMainWidget( kabcfg );
1628 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1644 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1629 this, SLOT( configurationChanged() ) ); 1645 this, SLOT( configurationChanged() ) );
1630 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1646 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1631 kabcfg, SLOT( save() ) ); 1647 kabcfg, SLOT( save() ) );
1632 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1648 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1633 this, SLOT( configurationChanged() ) ); 1649 this, SLOT( configurationChanged() ) );
1634 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1650 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1635 kabcfg, SLOT( save() ) ); 1651 kabcfg, SLOT( save() ) );
1636 connect( ConfigureDialog, SIGNAL( defaultClicked() ), 1652 connect( ConfigureDialog, SIGNAL( defaultClicked() ),
1637 kabcfg, SLOT( defaults() ) ); 1653 kabcfg, SLOT( defaults() ) );
1638 saveSettings(); 1654 saveSettings();
1639 kabcfg->load(); 1655 kabcfg->load();
1640#ifndef DESKTOP_VERSION 1656#ifndef DESKTOP_VERSION
1641 if ( QApplication::desktop()->height() <= 480 ) 1657 if ( QApplication::desktop()->height() <= 480 )
1642 ConfigureDialog->hideButtons(); 1658 ConfigureDialog->hideButtons();
1643 ConfigureDialog->showMaximized(); 1659 ConfigureDialog->showMaximized();
1644#endif 1660#endif
1645 if ( ConfigureDialog->exec() ) 1661 if ( ConfigureDialog->exec() )
1646 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1662 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1647 delete ConfigureDialog; 1663 delete ConfigureDialog;
1648} 1664}
1649 1665
1650void KABCore::openLDAPDialog() 1666void KABCore::openLDAPDialog()
1651{ 1667{
1652#ifndef KAB_EMBEDDED 1668#ifndef KAB_EMBEDDED
1653 if ( !mLdapSearchDialog ) { 1669 if ( !mLdapSearchDialog ) {
1654 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1670 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1655 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1671 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1656 SLOT( refreshView() ) ); 1672 SLOT( refreshView() ) );
1657 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1673 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1658 SLOT( setModified() ) ); 1674 SLOT( setModified() ) );
1659 } else 1675 } else
1660 mLdapSearchDialog->restoreSettings(); 1676 mLdapSearchDialog->restoreSettings();
1661 1677
1662 if ( mLdapSearchDialog->isOK() ) 1678 if ( mLdapSearchDialog->isOK() )
1663 mLdapSearchDialog->exec(); 1679 mLdapSearchDialog->exec();
1664#else //KAB_EMBEDDED 1680#else //KAB_EMBEDDED
1665 qDebug("KABCore::openLDAPDialog() finsih method"); 1681 qDebug("KABCore::openLDAPDialog() finsih method");
1666#endif //KAB_EMBEDDED 1682#endif //KAB_EMBEDDED
1667} 1683}
1668 1684
1669void KABCore::print() 1685void KABCore::print()
1670{ 1686{
1671#ifndef KAB_EMBEDDED 1687#ifndef KAB_EMBEDDED
1672 KPrinter printer; 1688 KPrinter printer;
1673 if ( !printer.setup( this ) ) 1689 if ( !printer.setup( this ) )
1674 return; 1690 return;
1675 1691
1676 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1692 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1677 mViewManager->selectedUids(), this ); 1693 mViewManager->selectedUids(), this );
1678 1694
1679 wizard.exec(); 1695 wizard.exec();
1680#else //KAB_EMBEDDED 1696#else //KAB_EMBEDDED
1681 qDebug("KABCore::print() finsih method"); 1697 qDebug("KABCore::print() finsih method");
1682#endif //KAB_EMBEDDED 1698#endif //KAB_EMBEDDED
1683 1699
1684} 1700}
1685 1701
1686 1702
1687void KABCore::addGUIClient( KXMLGUIClient *client ) 1703void KABCore::addGUIClient( KXMLGUIClient *client )
1688{ 1704{
1689 if ( mGUIClient ) 1705 if ( mGUIClient )
1690 mGUIClient->insertChildClient( client ); 1706 mGUIClient->insertChildClient( client );
1691 else 1707 else
1692 KMessageBox::error( this, "no KXMLGUICLient"); 1708 KMessageBox::error( this, "no KXMLGUICLient");
1693} 1709}
1694 1710
1695 1711
1696void KABCore::configurationChanged() 1712void KABCore::configurationChanged()
1697{ 1713{
1698 mExtensionManager->reconfigure(); 1714 mExtensionManager->reconfigure();
1699} 1715}
1700 1716
1701void KABCore::addressBookChanged() 1717void KABCore::addressBookChanged()
1702{ 1718{
1703/*US 1719/*US
1704 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1720 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1705 while ( it.current() ) { 1721 while ( it.current() ) {
1706 if ( it.current()->dirty() ) { 1722 if ( it.current()->dirty() ) {
1707 QString text = i18n( "Data has been changed externally. Unsaved " 1723 QString text = i18n( "Data has been changed externally. Unsaved "
1708 "changes will be lost." ); 1724 "changes will be lost." );
1709 KMessageBox::information( this, text ); 1725 KMessageBox::information( this, text );
1710 } 1726 }
1711 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1727 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1712 ++it; 1728 ++it;
1713 } 1729 }
1714*/ 1730*/
1715 if (mEditorDialog) 1731 if (mEditorDialog)
1716 { 1732 {
1717 if (mEditorDialog->dirty()) 1733 if (mEditorDialog->dirty())
1718 { 1734 {
1719 QString text = i18n( "Data has been changed externally. Unsaved " 1735 QString text = i18n( "Data has been changed externally. Unsaved "
1720 "changes will be lost." ); 1736 "changes will be lost." );
1721 KMessageBox::information( this, text ); 1737 KMessageBox::information( this, text );
1722 } 1738 }
1723 QString currentuid = mEditorDialog->addressee().uid(); 1739 QString currentuid = mEditorDialog->addressee().uid();
1724 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1740 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1725 } 1741 }
1726 mViewManager->refreshView(); 1742 mViewManager->refreshView();
1727 1743
1728 1744
1729} 1745}
1730 1746
1731AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1747AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1732 const char *name ) 1748 const char *name )
1733{ 1749{
1734 1750
1735 if ( mEditorDialog == 0 ) { 1751 if ( mEditorDialog == 0 ) {
1736 mEditorDialog = new AddresseeEditorDialog( this, parent, 1752 mEditorDialog = new AddresseeEditorDialog( this, parent,
1737 name ? name : "editorDialog" ); 1753 name ? name : "editorDialog" );
1738 1754
1739 1755
1740 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1756 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1741 SLOT( contactModified( const KABC::Addressee& ) ) ); 1757 SLOT( contactModified( const KABC::Addressee& ) ) );
1742 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1758 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1743 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1759 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1744 } 1760 }
1745 1761
1746 return mEditorDialog; 1762 return mEditorDialog;
1747} 1763}
1748 1764
1749void KABCore::slotEditorDestroyed( const QString &uid ) 1765void KABCore::slotEditorDestroyed( const QString &uid )
1750{ 1766{
1751 //mEditorDict.remove( uid ); 1767 //mEditorDict.remove( uid );
1752} 1768}
1753 1769
1754void KABCore::initGUI() 1770void KABCore::initGUI()
1755{ 1771{
1756#ifndef KAB_EMBEDDED 1772#ifndef KAB_EMBEDDED
1757 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1773 QHBoxLayout *topLayout = new QHBoxLayout( this );
1758 topLayout->setSpacing( KDialogBase::spacingHint() ); 1774 topLayout->setSpacing( KDialogBase::spacingHint() );
1759 1775
1760 mExtensionBarSplitter = new QSplitter( this ); 1776 mExtensionBarSplitter = new QSplitter( this );
1761 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1777 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1762 1778
1763 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1779 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1764 1780
1765 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1781 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1766 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1782 mIncSearchWidget = new IncSearchWidget( viewSpace );
1767 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1783 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1768 SLOT( incrementalSearch( const QString& ) ) ); 1784 SLOT( incrementalSearch( const QString& ) ) );
1769 1785
1770 mViewManager = new ViewManager( this, viewSpace ); 1786 mViewManager = new ViewManager( this, viewSpace );
1771 viewSpace->setStretchFactor( mViewManager, 1 ); 1787 viewSpace->setStretchFactor( mViewManager, 1 );
1772 1788
1773 mDetails = new ViewContainer( mDetailsSplitter ); 1789 mDetails = new ViewContainer( mDetailsSplitter );
1774 1790
1775 mJumpButtonBar = new JumpButtonBar( this, this ); 1791 mJumpButtonBar = new JumpButtonBar( this, this );
1776 1792
1777 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1793 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1778 1794
1779 topLayout->addWidget( mExtensionBarSplitter ); 1795 topLayout->addWidget( mExtensionBarSplitter );
1780 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1796 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1781 topLayout->addWidget( mJumpButtonBar ); 1797 topLayout->addWidget( mJumpButtonBar );
1782 //topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1798 //topLayout->setStretchFactor( mJumpButtonBar, 1 );
1783 1799
1784 mXXPortManager = new XXPortManager( this, this ); 1800 mXXPortManager = new XXPortManager( this, this );
1785 1801
1786#else //KAB_EMBEDDED 1802#else //KAB_EMBEDDED
1787 //US initialize viewMenu before settingup viewmanager. 1803 //US initialize viewMenu before settingup viewmanager.
1788 // Viewmanager needs this menu to plugin submenues. 1804 // Viewmanager needs this menu to plugin submenues.
1789 viewMenu = new QPopupMenu( this ); 1805 viewMenu = new QPopupMenu( this );
1790 settingsMenu = new QPopupMenu( this ); 1806 settingsMenu = new QPopupMenu( this );
1791 //filterMenu = new QPopupMenu( this ); 1807 //filterMenu = new QPopupMenu( this );
1792 ImportMenu = new QPopupMenu( this ); 1808 ImportMenu = new QPopupMenu( this );
1793 ExportMenu = new QPopupMenu( this ); 1809 ExportMenu = new QPopupMenu( this );
1794 syncMenu = new QPopupMenu( this ); 1810 syncMenu = new QPopupMenu( this );
1795 changeMenu= new QPopupMenu( this ); 1811 changeMenu= new QPopupMenu( this );
1796 beamMenu= new QPopupMenu( this ); 1812 beamMenu= new QPopupMenu( this );
1797 1813
1798//US since we have no splitter for the embedded system, setup 1814//US since we have no splitter for the embedded system, setup
1799// a layout with two frames. One left and one right. 1815// a layout with two frames. One left and one right.
1800 1816
1801 QBoxLayout *topLayout; 1817 QBoxLayout *topLayout;
1802 1818
1803 // = new QHBoxLayout( this ); 1819 // = new QHBoxLayout( this );
1804// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1820// QBoxLayout *topLayout = (QBoxLayout*)layout();
1805 1821
1806// QWidget *mainBox = new QWidget( this ); 1822// QWidget *mainBox = new QWidget( this );
1807// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1823// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1808 1824
1809#ifdef DESKTOP_VERSION 1825#ifdef DESKTOP_VERSION
1810 topLayout = new QHBoxLayout( this ); 1826 topLayout = new QHBoxLayout( this );
1811 1827
1812 1828
1813 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1829 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1814 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1830 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1815 1831
1816 topLayout->addWidget(mMiniSplitter ); 1832 topLayout->addWidget(mMiniSplitter );
1817 1833
1818 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1834 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1819 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1835 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1820 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1836 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1821 mDetails = new ViewContainer( mMiniSplitter ); 1837 mDetails = new ViewContainer( mMiniSplitter );
1822 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1838 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1823#else 1839#else
1824 if ( QApplication::desktop()->width() > 480 ) { 1840 if ( QApplication::desktop()->width() > 480 ) {
1825 topLayout = new QHBoxLayout( this ); 1841 topLayout = new QHBoxLayout( this );
1826 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1842 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1827 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1843 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1828 } else { 1844 } else {
1829 1845
1830 topLayout = new QHBoxLayout( this ); 1846 topLayout = new QHBoxLayout( this );
1831 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1847 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1832 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1848 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1833 } 1849 }
1834 1850
1835 topLayout->addWidget(mMiniSplitter ); 1851 topLayout->addWidget(mMiniSplitter );
1836 mViewManager = new ViewManager( this, mMiniSplitter ); 1852 mViewManager = new ViewManager( this, mMiniSplitter );
1837 mDetails = new ViewContainer( mMiniSplitter ); 1853 mDetails = new ViewContainer( mMiniSplitter );
1838 1854
1839 1855
1840 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1856 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1841#endif 1857#endif
1842 //eh->hide(); 1858 //eh->hide();
1843 // topLayout->addWidget(mExtensionManager ); 1859 // topLayout->addWidget(mExtensionManager );
1844 1860
1845 1861
1846/*US 1862/*US
1847#ifndef KAB_NOSPLITTER 1863#ifndef KAB_NOSPLITTER
1848 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1864 QHBoxLayout *topLayout = new QHBoxLayout( this );
1849//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1865//US topLayout->setSpacing( KDialogBase::spacingHint() );
1850 topLayout->setSpacing( 10 ); 1866 topLayout->setSpacing( 10 );
1851 1867
1852 mDetailsSplitter = new QSplitter( this ); 1868 mDetailsSplitter = new QSplitter( this );
1853 1869
1854 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1870 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1855 1871
1856 mViewManager = new ViewManager( this, viewSpace ); 1872 mViewManager = new ViewManager( this, viewSpace );
1857 viewSpace->setStretchFactor( mViewManager, 1 ); 1873 viewSpace->setStretchFactor( mViewManager, 1 );
1858 1874
1859 mDetails = new ViewContainer( mDetailsSplitter ); 1875 mDetails = new ViewContainer( mDetailsSplitter );
1860 1876
1861 topLayout->addWidget( mDetailsSplitter ); 1877 topLayout->addWidget( mDetailsSplitter );
1862 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1878 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1863#else //KAB_NOSPLITTER 1879#else //KAB_NOSPLITTER
1864 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1880 QHBoxLayout *topLayout = new QHBoxLayout( this );
1865//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1881//US topLayout->setSpacing( KDialogBase::spacingHint() );
1866 topLayout->setSpacing( 10 ); 1882 topLayout->setSpacing( 10 );
1867 1883
1868// mDetailsSplitter = new QSplitter( this ); 1884// mDetailsSplitter = new QSplitter( this );
1869 1885
@@ -1901,1537 +1917,1537 @@ void KABCore::initGUI()
1901 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1917 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1902 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1918 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1903 // mActionQuit->plug ( mMainWindow->toolBar()); 1919 // mActionQuit->plug ( mMainWindow->toolBar());
1904 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1920 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1905 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1921 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1906 // mIncSearchWidget->hide(); 1922 // mIncSearchWidget->hide();
1907 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1923 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1908 SLOT( incrementalSearch( const QString& ) ) ); 1924 SLOT( incrementalSearch( const QString& ) ) );
1909 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1925 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1910 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1926 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1911 1927
1912 mJumpButtonBar = new JumpButtonBar( this, this ); 1928 mJumpButtonBar = new JumpButtonBar( this, this );
1913 1929
1914 topLayout->addWidget( mJumpButtonBar ); 1930 topLayout->addWidget( mJumpButtonBar );
1915//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1931//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1916 1932
1917// mMainWindow->getIconToolBar()->raise(); 1933// mMainWindow->getIconToolBar()->raise();
1918 1934
1919#endif //KAB_EMBEDDED 1935#endif //KAB_EMBEDDED
1920 1936
1921} 1937}
1922void KABCore::initActions() 1938void KABCore::initActions()
1923{ 1939{
1924//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1940//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1925 1941
1926#ifndef KAB_EMBEDDED 1942#ifndef KAB_EMBEDDED
1927 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1943 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1928 SLOT( clipboardDataChanged() ) ); 1944 SLOT( clipboardDataChanged() ) );
1929#endif //KAB_EMBEDDED 1945#endif //KAB_EMBEDDED
1930 1946
1931 // file menu 1947 // file menu
1932 1948
1933 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1949 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1934 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1950 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1935 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 1951 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1936 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 1952 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1937 1953
1938 1954
1939 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 1955 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1940 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 1956 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1941 1957
1942 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1958 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1943 SLOT( save() ), actionCollection(), "file_sync" ); 1959 SLOT( save() ), actionCollection(), "file_sync" );
1944 1960
1945 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1961 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1946 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1962 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1947 1963
1948 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1964 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1949 this, SLOT( mailVCard() ), 1965 this, SLOT( mailVCard() ),
1950 actionCollection(), "file_mail_vcard"); 1966 actionCollection(), "file_mail_vcard");
1951 1967
1952 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1968 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1953 SLOT( export2phone() ), actionCollection(), 1969 SLOT( export2phone() ), actionCollection(),
1954 "kaddressbook_ex2phone" ); 1970 "kaddressbook_ex2phone" );
1955 1971
1956 mActionBeamVCard = 0; 1972 mActionBeamVCard = 0;
1957 mActionBeam = 0; 1973 mActionBeam = 0;
1958 1974
1959#ifndef DESKTOP_VERSION 1975#ifndef DESKTOP_VERSION
1960 if ( Ir::supported() ) { 1976 if ( Ir::supported() ) {
1961 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 1977 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
1962 SLOT( beamVCard() ), actionCollection(), 1978 SLOT( beamVCard() ), actionCollection(),
1963 "kaddressbook_beam_vcard" ); 1979 "kaddressbook_beam_vcard" );
1964 1980
1965 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1981 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1966 SLOT( beamMySelf() ), actionCollection(), 1982 SLOT( beamMySelf() ), actionCollection(),
1967 "kaddressbook_beam_myself" ); 1983 "kaddressbook_beam_myself" );
1968 } 1984 }
1969#endif 1985#endif
1970 1986
1971 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1987 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1972 this, SLOT( editContact2() ), 1988 this, SLOT( editContact2() ),
1973 actionCollection(), "file_properties" ); 1989 actionCollection(), "file_properties" );
1974 1990
1975#ifdef KAB_EMBEDDED 1991#ifdef KAB_EMBEDDED
1976 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1992 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1977 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1993 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1978 mMainWindow, SLOT( exit() ), 1994 mMainWindow, SLOT( exit() ),
1979 actionCollection(), "quit" ); 1995 actionCollection(), "quit" );
1980#endif //KAB_EMBEDDED 1996#endif //KAB_EMBEDDED
1981 1997
1982 // edit menu 1998 // edit menu
1983 if ( mIsPart ) { 1999 if ( mIsPart ) {
1984 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 2000 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1985 SLOT( copyContacts() ), actionCollection(), 2001 SLOT( copyContacts() ), actionCollection(),
1986 "kaddressbook_copy" ); 2002 "kaddressbook_copy" );
1987 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 2003 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1988 SLOT( cutContacts() ), actionCollection(), 2004 SLOT( cutContacts() ), actionCollection(),
1989 "kaddressbook_cut" ); 2005 "kaddressbook_cut" );
1990 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 2006 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1991 SLOT( pasteContacts() ), actionCollection(), 2007 SLOT( pasteContacts() ), actionCollection(),
1992 "kaddressbook_paste" ); 2008 "kaddressbook_paste" );
1993 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 2009 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1994 SLOT( selectAllContacts() ), actionCollection(), 2010 SLOT( selectAllContacts() ), actionCollection(),
1995 "kaddressbook_select_all" ); 2011 "kaddressbook_select_all" );
1996 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 2012 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1997 SLOT( undo() ), actionCollection(), 2013 SLOT( undo() ), actionCollection(),
1998 "kaddressbook_undo" ); 2014 "kaddressbook_undo" );
1999 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 2015 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
2000 this, SLOT( redo() ), actionCollection(), 2016 this, SLOT( redo() ), actionCollection(),
2001 "kaddressbook_redo" ); 2017 "kaddressbook_redo" );
2002 } else { 2018 } else {
2003 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 2019 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
2004 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 2020 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
2005 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 2021 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
2006 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 2022 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
2007 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 2023 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
2008 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 2024 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
2009 } 2025 }
2010 2026
2011 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 2027 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
2012 Key_Delete, this, SLOT( deleteContacts() ), 2028 Key_Delete, this, SLOT( deleteContacts() ),
2013 actionCollection(), "edit_delete" ); 2029 actionCollection(), "edit_delete" );
2014 2030
2015 mActionUndo->setEnabled( false ); 2031 mActionUndo->setEnabled( false );
2016 mActionRedo->setEnabled( false ); 2032 mActionRedo->setEnabled( false );
2017 2033
2018 // settings menu 2034 // settings menu
2019#ifdef KAB_EMBEDDED 2035#ifdef KAB_EMBEDDED
2020//US special menuentry to configure the addressbook resources. On KDE 2036//US special menuentry to configure the addressbook resources. On KDE
2021// you do that through the control center !!! 2037// you do that through the control center !!!
2022 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 2038 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
2023 SLOT( configureResources() ), actionCollection(), 2039 SLOT( configureResources() ), actionCollection(),
2024 "kaddressbook_configure_resources" ); 2040 "kaddressbook_configure_resources" );
2025#endif //KAB_EMBEDDED 2041#endif //KAB_EMBEDDED
2026 2042
2027 if ( mIsPart ) { 2043 if ( mIsPart ) {
2028 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 2044 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
2029 SLOT( openConfigDialog() ), actionCollection(), 2045 SLOT( openConfigDialog() ), actionCollection(),
2030 "kaddressbook_configure" ); 2046 "kaddressbook_configure" );
2031 2047
2032 //US not implemented yet 2048 //US not implemented yet
2033 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 2049 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
2034 // this, SLOT( configureKeyBindings() ), actionCollection(), 2050 // this, SLOT( configureKeyBindings() ), actionCollection(),
2035 // "kaddressbook_configure_shortcuts" ); 2051 // "kaddressbook_configure_shortcuts" );
2036#ifdef KAB_EMBEDDED 2052#ifdef KAB_EMBEDDED
2037 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 2053 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
2038 mActionConfigureToolbars->setEnabled( false ); 2054 mActionConfigureToolbars->setEnabled( false );
2039#endif //KAB_EMBEDDED 2055#endif //KAB_EMBEDDED
2040 2056
2041 } else { 2057 } else {
2042 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this, 2058 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this,
2043 SLOT( openConfigDialog() ), actionCollection(), 2059 SLOT( openConfigDialog() ), actionCollection(),
2044 "kaddressbook_configure" ); 2060 "kaddressbook_configure" );
2045 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this, 2061 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this,
2046 SLOT( openConfigGlobalDialog() ), actionCollection(), 2062 SLOT( openConfigGlobalDialog() ), actionCollection(),
2047 "kaddressbook_configure" ); 2063 "kaddressbook_configure" );
2048 } 2064 }
2049 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2065 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2050 actionCollection(), "options_show_jump_bar" ); 2066 actionCollection(), "options_show_jump_bar" );
2051 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); 2067 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) );
2052 2068
2053 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2069 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2054 actionCollection(), "options_show_details" ); 2070 actionCollection(), "options_show_details" );
2055 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2071 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2056 2072
2057 2073
2058 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2074 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2059 SLOT( toggleBeamReceive() ), actionCollection(), 2075 SLOT( toggleBeamReceive() ), actionCollection(),
2060 "kaddressbook_beam_rec" ); 2076 "kaddressbook_beam_rec" );
2061 2077
2062 2078
2063 // misc 2079 // misc
2064 // only enable LDAP lookup if we can handle the protocol 2080 // only enable LDAP lookup if we can handle the protocol
2065#ifndef KAB_EMBEDDED 2081#ifndef KAB_EMBEDDED
2066 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2082 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2067 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2083 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2068 this, SLOT( openLDAPDialog() ), actionCollection(), 2084 this, SLOT( openLDAPDialog() ), actionCollection(),
2069 "ldap_lookup" ); 2085 "ldap_lookup" );
2070 } 2086 }
2071#else //KAB_EMBEDDED 2087#else //KAB_EMBEDDED
2072 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2088 //qDebug("KABCore::initActions() LDAP has to be implemented");
2073#endif //KAB_EMBEDDED 2089#endif //KAB_EMBEDDED
2074 2090
2075 2091
2076 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2092 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2077 SLOT( setWhoAmI() ), actionCollection(), 2093 SLOT( setWhoAmI() ), actionCollection(),
2078 "set_personal" ); 2094 "set_personal" );
2079 2095
2080 2096
2081 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, 2097 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this,
2082 SLOT( setCategories() ), actionCollection(), 2098 SLOT( setCategories() ), actionCollection(),
2083 "edit_set_categories" ); 2099 "edit_set_categories" );
2084 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, 2100 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this,
2085 SLOT( editCategories() ), actionCollection(), 2101 SLOT( editCategories() ), actionCollection(),
2086 "edit__categories" ); 2102 "edit__categories" );
2087 2103
2088 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2104 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2089 SLOT( removeVoice() ), actionCollection(), 2105 SLOT( removeVoice() ), actionCollection(),
2090 "remove_voice" ); 2106 "remove_voice" );
2091 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2107 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2092 SLOT( setFormattedName() ), actionCollection(), 2108 SLOT( setFormattedName() ), actionCollection(),
2093 "set_formatted" ); 2109 "set_formatted" );
2094 2110
2095 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2111 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2096 SLOT( manageCategories() ), actionCollection(), 2112 SLOT( manageCategories() ), actionCollection(),
2097 "remove_voice" ); 2113 "remove_voice" );
2098 2114
2099 2115
2100 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2116 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2101 SLOT( importFromOL() ), actionCollection(), 2117 SLOT( importFromOL() ), actionCollection(),
2102 "import_OL" ); 2118 "import_OL" );
2103#ifdef KAB_EMBEDDED 2119#ifdef KAB_EMBEDDED
2104 mActionLicence = new KAction( i18n( "Licence" ), 0, 2120 mActionLicence = new KAction( i18n( "Licence" ), 0,
2105 this, SLOT( showLicence() ), actionCollection(), 2121 this, SLOT( showLicence() ), actionCollection(),
2106 "licence_about_data" ); 2122 "licence_about_data" );
2107 mActionFaq = new KAction( i18n( "Faq" ), 0, 2123 mActionFaq = new KAction( i18n( "Faq" ), 0,
2108 this, SLOT( faq() ), actionCollection(), 2124 this, SLOT( faq() ), actionCollection(),
2109 "faq_about_data" ); 2125 "faq_about_data" );
2110 mActionWN = new KAction( i18n( "What's New?" ), 0, 2126 mActionWN = new KAction( i18n( "What's New?" ), 0,
2111 this, SLOT( whatsnew() ), actionCollection(), 2127 this, SLOT( whatsnew() ), actionCollection(),
2112 "wn" ); 2128 "wn" );
2113 2129
2114 2130
2115 2131
2116 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, 2132 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0,
2117 this, SLOT( storagehowto() ), actionCollection(), 2133 this, SLOT( storagehowto() ), actionCollection(),
2118 "storage" ); 2134 "storage" );
2119 2135
2120 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2136 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2121 this, SLOT( synchowto() ), actionCollection(), 2137 this, SLOT( synchowto() ), actionCollection(),
2122 "sync" ); 2138 "sync" );
2123 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2139 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2124 this, SLOT( kdesynchowto() ), actionCollection(), 2140 this, SLOT( kdesynchowto() ), actionCollection(),
2125 "kdesync" ); 2141 "kdesync" );
2126 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2142 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2127 this, SLOT( multisynchowto() ), actionCollection(), 2143 this, SLOT( multisynchowto() ), actionCollection(),
2128 "multisync" ); 2144 "multisync" );
2129 2145
2130 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2146 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2131 this, SLOT( createAboutData() ), actionCollection(), 2147 this, SLOT( createAboutData() ), actionCollection(),
2132 "kaddressbook_about_data" ); 2148 "kaddressbook_about_data" );
2133#endif //KAB_EMBEDDED 2149#endif //KAB_EMBEDDED
2134 2150
2135 clipboardDataChanged(); 2151 clipboardDataChanged();
2136 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2152 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2137 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2153 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2138} 2154}
2139 2155
2140//US we need this function, to plug all actions into the correct menues. 2156//US we need this function, to plug all actions into the correct menues.
2141// KDE uses a XML format to plug the actions, but we work her without this overhead. 2157// KDE uses a XML format to plug the actions, but we work her without this overhead.
2142void KABCore::addActionsManually() 2158void KABCore::addActionsManually()
2143{ 2159{
2144//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2160//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2145 2161
2146#ifdef KAB_EMBEDDED 2162#ifdef KAB_EMBEDDED
2147 QPopupMenu *fileMenu = new QPopupMenu( this ); 2163 QPopupMenu *fileMenu = new QPopupMenu( this );
2148 QPopupMenu *editMenu = new QPopupMenu( this ); 2164 QPopupMenu *editMenu = new QPopupMenu( this );
2149 QPopupMenu *helpMenu = new QPopupMenu( this ); 2165 QPopupMenu *helpMenu = new QPopupMenu( this );
2150 2166
2151 KToolBar* tb = mMainWindow->toolBar(); 2167 KToolBar* tb = mMainWindow->toolBar();
2152 mMainWindow->setToolBarsMovable (false ); 2168 mMainWindow->setToolBarsMovable (false );
2153#ifndef DESKTOP_VERSION 2169#ifndef DESKTOP_VERSION
2154 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2170 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2155#endif 2171#endif
2156 QMenuBar* mb = mMainWindow->menuBar(); 2172 QMenuBar* mb = mMainWindow->menuBar();
2157 2173
2158 //US setup menubar. 2174 //US setup menubar.
2159 //Disable the following block if you do not want to have a menubar. 2175 //Disable the following block if you do not want to have a menubar.
2160 mb->insertItem( i18n("&File"), fileMenu ); 2176 mb->insertItem( i18n("&File"), fileMenu );
2161 mb->insertItem( i18n("&Edit"), editMenu ); 2177 mb->insertItem( i18n("&Edit"), editMenu );
2162 mb->insertItem( i18n("&View"), viewMenu ); 2178 mb->insertItem( i18n("&View"), viewMenu );
2163 mb->insertItem( i18n("&Settings"), settingsMenu ); 2179 mb->insertItem( i18n("&Settings"), settingsMenu );
2164#ifdef DESKTOP_VERSION 2180#ifdef DESKTOP_VERSION
2165 mb->insertItem( i18n("Synchronize"), syncMenu ); 2181 mb->insertItem( i18n("Synchronize"), syncMenu );
2166#else 2182#else
2167 mb->insertItem( i18n("Sync"), syncMenu ); 2183 mb->insertItem( i18n("Sync"), syncMenu );
2168#endif 2184#endif
2169 //mb->insertItem( i18n("&Change"), changeMenu ); 2185 //mb->insertItem( i18n("&Change"), changeMenu );
2170 mb->insertItem( i18n("&Help"), helpMenu ); 2186 mb->insertItem( i18n("&Help"), helpMenu );
2171 mIncSearchWidget = new IncSearchWidget( tb ); 2187 mIncSearchWidget = new IncSearchWidget( tb );
2172 // tb->insertWidget(-1, 0, mIncSearchWidget); 2188 // tb->insertWidget(-1, 0, mIncSearchWidget);
2173#ifndef DESKTOP_VERSION 2189#ifndef DESKTOP_VERSION
2174 } else { 2190 } else {
2175 //US setup toolbar 2191 //US setup toolbar
2176 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2192 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2177 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2193 QPopupMenu *popupBarTB = new QPopupMenu( this );
2178 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); 2194 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB);
2179 tb->insertWidget(-1, 0, menuBarTB); 2195 tb->insertWidget(-1, 0, menuBarTB);
2180 mIncSearchWidget = new IncSearchWidget( tb ); 2196 mIncSearchWidget = new IncSearchWidget( tb );
2181 tb->enableMoving(false); 2197 tb->enableMoving(false);
2182 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2198 popupBarTB->insertItem( i18n("&File"), fileMenu );
2183 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2199 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2184 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2200 popupBarTB->insertItem( i18n("&View"), viewMenu );
2185 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2201 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2186 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2202 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2187 mViewManager->getFilterAction()->plug ( popupBarTB); 2203 mViewManager->getFilterAction()->plug ( popupBarTB);
2188 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2204 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2189 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2205 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2190 if (QApplication::desktop()->width() > 320 ) { 2206 if (QApplication::desktop()->width() > 320 ) {
2191 // mViewManager->getFilterAction()->plug ( tb); 2207 // mViewManager->getFilterAction()->plug ( tb);
2192 } 2208 }
2193 } 2209 }
2194#endif 2210#endif
2195 mIncSearchWidget->setSize(); 2211 mIncSearchWidget->setSize();
2196 // mActionQuit->plug ( mMainWindow->toolBar()); 2212 // mActionQuit->plug ( mMainWindow->toolBar());
2197 2213
2198 2214
2199 2215
2200 //US Now connect the actions with the menue entries. 2216 //US Now connect the actions with the menue entries.
2201#ifdef DESKTOP_VERSION 2217#ifdef DESKTOP_VERSION
2202 mActionPrint->plug( fileMenu ); 2218 mActionPrint->plug( fileMenu );
2203 mActionPrintDetails->plug( fileMenu ); 2219 mActionPrintDetails->plug( fileMenu );
2204 fileMenu->insertSeparator(); 2220 fileMenu->insertSeparator();
2205#endif 2221#endif
2206 mActionMail->plug( fileMenu ); 2222 mActionMail->plug( fileMenu );
2207 fileMenu->insertSeparator(); 2223 fileMenu->insertSeparator();
2208 2224
2209 mActionNewContact->plug( editMenu ); 2225 mActionNewContact->plug( editMenu );
2210 mActionNewContact->plug( tb ); 2226 mActionNewContact->plug( tb );
2211 2227
2212 mActionEditAddressee->plug( editMenu ); 2228 mActionEditAddressee->plug( editMenu );
2213 editMenu->insertSeparator(); 2229 editMenu->insertSeparator();
2214 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2230 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2215 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2231 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2216 mActionEditAddressee->plug( tb ); 2232 mActionEditAddressee->plug( tb );
2217 2233
2218 // fileMenu->insertSeparator(); 2234 // fileMenu->insertSeparator();
2219 mActionSave->plug( fileMenu ); 2235 mActionSave->plug( fileMenu );
2220 fileMenu->insertItem( "&Import", ImportMenu ); 2236 fileMenu->insertItem( "&Import", ImportMenu );
2221 fileMenu->insertItem( "&Export", ExportMenu ); 2237 fileMenu->insertItem( "&Export", ExportMenu );
2222 editMenu->insertItem( i18n("&Change"), changeMenu ); 2238 editMenu->insertItem( i18n("&Change"), changeMenu );
2223 editMenu->insertSeparator(); 2239 editMenu->insertSeparator();
2224#ifndef DESKTOP_VERSION 2240#ifndef DESKTOP_VERSION
2225 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2241 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2226#endif 2242#endif
2227#if 0 2243#if 0
2228 // PENDING fix MailVCard 2244 // PENDING fix MailVCard
2229 fileMenu->insertSeparator(); 2245 fileMenu->insertSeparator();
2230 mActionMailVCard->plug( fileMenu ); 2246 mActionMailVCard->plug( fileMenu );
2231#endif 2247#endif
2232#ifndef DESKTOP_VERSION 2248#ifndef DESKTOP_VERSION
2233 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2249 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2234 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2250 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2235 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2251 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2236#endif 2252#endif
2237 fileMenu->insertSeparator(); 2253 fileMenu->insertSeparator();
2238 mActionQuit->plug( fileMenu ); 2254 mActionQuit->plug( fileMenu );
2239#ifdef _OL_IMPORT_ 2255#ifdef _OL_IMPORT_
2240 mActionImportOL->plug( ImportMenu ); 2256 mActionImportOL->plug( ImportMenu );
2241#endif 2257#endif
2242 // edit menu 2258 // edit menu
2243 mActionUndo->plug( editMenu ); 2259 mActionUndo->plug( editMenu );
2244 mActionRedo->plug( editMenu ); 2260 mActionRedo->plug( editMenu );
2245 editMenu->insertSeparator(); 2261 editMenu->insertSeparator();
2246 mActionCut->plug( editMenu ); 2262 mActionCut->plug( editMenu );
2247 mActionCopy->plug( editMenu ); 2263 mActionCopy->plug( editMenu );
2248 mActionPaste->plug( editMenu ); 2264 mActionPaste->plug( editMenu );
2249 mActionDelete->plug( editMenu ); 2265 mActionDelete->plug( editMenu );
2250 editMenu->insertSeparator(); 2266 editMenu->insertSeparator();
2251 mActionSelectAll->plug( editMenu ); 2267 mActionSelectAll->plug( editMenu );
2252 2268
2253 mActionSetFormattedName->plug( changeMenu ); 2269 mActionSetFormattedName->plug( changeMenu );
2254 mActionRemoveVoice->plug( changeMenu ); 2270 mActionRemoveVoice->plug( changeMenu );
2255 // settingsmings menu 2271 // settingsmings menu
2256//US special menuentry to configure the addressbook resources. On KDE 2272//US special menuentry to configure the addressbook resources. On KDE
2257// you do that through the control center !!! 2273// you do that through the control center !!!
2258 // settingsMenu->insertSeparator(); 2274 // settingsMenu->insertSeparator();
2259 2275
2260 mActionConfigKAddressbook->plug( settingsMenu, 0 ); 2276 mActionConfigKAddressbook->plug( settingsMenu, 0 );
2261 mActionConfigGlobal->plug( settingsMenu, 1 ); 2277 mActionConfigGlobal->plug( settingsMenu, 1 );
2262 mActionConfigResources->plug( settingsMenu,2 ); 2278 mActionConfigResources->plug( settingsMenu,2 );
2263 settingsMenu->insertSeparator(3); 2279 settingsMenu->insertSeparator(3);
2264 2280
2265 if ( mIsPart ) { 2281 if ( mIsPart ) {
2266 //US not implemented yet 2282 //US not implemented yet
2267 //mActionConfigShortcuts->plug( settingsMenu ); 2283 //mActionConfigShortcuts->plug( settingsMenu );
2268 //mActionConfigureToolbars->plug( settingsMenu ); 2284 //mActionConfigureToolbars->plug( settingsMenu );
2269 2285
2270 } else { 2286 } else {
2271 //US not implemented yet 2287 //US not implemented yet
2272 //mActionKeyBindings->plug( settingsMenu ); 2288 //mActionKeyBindings->plug( settingsMenu );
2273 } 2289 }
2274 2290
2275 mActionEditCategories->plug( settingsMenu ); 2291 mActionEditCategories->plug( settingsMenu );
2276 mActionManageCategories->plug( settingsMenu ); 2292 mActionManageCategories->plug( settingsMenu );
2277 mActionJumpBar->plug( viewMenu,0 ); 2293 mActionJumpBar->plug( viewMenu,0 );
2278 mActionDetails->plug( viewMenu,0 ); 2294 mActionDetails->plug( viewMenu,0 );
2279 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2295 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2280 mActionDetails->plug( tb ); 2296 mActionDetails->plug( tb );
2281 settingsMenu->insertSeparator(); 2297 settingsMenu->insertSeparator();
2282#ifndef DESKTOP_VERSION 2298#ifndef DESKTOP_VERSION
2283 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2299 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2284 settingsMenu->insertSeparator(); 2300 settingsMenu->insertSeparator();
2285#endif 2301#endif
2286 2302
2287 mActionWhoAmI->plug( settingsMenu ); 2303 mActionWhoAmI->plug( settingsMenu );
2288 //mActionEditCategories->plug( changeMenu ); 2304 //mActionEditCategories->plug( changeMenu );
2289 mActionCategories->plug( changeMenu ); 2305 mActionCategories->plug( changeMenu );
2290 //mActionManageCategories->plug( changeMenu ); 2306 //mActionManageCategories->plug( changeMenu );
2291 2307
2292 //mActionCategories->plug( settingsMenu ); 2308 //mActionCategories->plug( settingsMenu );
2293 2309
2294 2310
2295 mActionWN->plug( helpMenu ); 2311 mActionWN->plug( helpMenu );
2296 mActionStorageHowto->plug( helpMenu ); 2312 mActionStorageHowto->plug( helpMenu );
2297 mActionSyncHowto->plug( helpMenu ); 2313 mActionSyncHowto->plug( helpMenu );
2298 mActionKdeSyncHowto->plug( helpMenu ); 2314 mActionKdeSyncHowto->plug( helpMenu );
2299 mActionMultiSyncHowto->plug( helpMenu ); 2315 mActionMultiSyncHowto->plug( helpMenu );
2300 mActionFaq->plug( helpMenu ); 2316 mActionFaq->plug( helpMenu );
2301 mActionLicence->plug( helpMenu ); 2317 mActionLicence->plug( helpMenu );
2302 mActionAboutKAddressbook->plug( helpMenu ); 2318 mActionAboutKAddressbook->plug( helpMenu );
2303 2319
2304 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2320 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2305 2321
2306 mActionSave->plug( tb ); 2322 mActionSave->plug( tb );
2307 mViewManager->getFilterAction()->plug ( tb); 2323 mViewManager->getFilterAction()->plug ( tb);
2308 //LR hide filteraction on started in 480x640 2324 //LR hide filteraction on started in 480x640
2309 if (QApplication::desktop()->width() == 480 ) { 2325 if (QApplication::desktop()->width() == 480 ) {
2310 mViewManager->getFilterAction()->setComboWidth( 0 ); 2326 mViewManager->getFilterAction()->setComboWidth( 0 );
2311 } 2327 }
2312 mActionUndo->plug( tb ); 2328 mActionUndo->plug( tb );
2313 mActionDelete->plug( tb ); 2329 mActionDelete->plug( tb );
2314 mActionRedo->plug( tb ); 2330 mActionRedo->plug( tb );
2315 } else { 2331 } else {
2316 mActionSave->plug( tb ); 2332 mActionSave->plug( tb );
2317 tb->enableMoving(false); 2333 tb->enableMoving(false);
2318 } 2334 }
2319 //mActionQuit->plug ( tb ); 2335 //mActionQuit->plug ( tb );
2320 //tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2336 //tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2321 2337
2322 //US link the searchwidget first to this. 2338 //US link the searchwidget first to this.
2323 // The real linkage to the toolbar happens later. 2339 // The real linkage to the toolbar happens later.
2324//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2340//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2325//US tb->insertItem( mIncSearchWidget ); 2341//US tb->insertItem( mIncSearchWidget );
2326/*US 2342/*US
2327 mIncSearchWidget = new IncSearchWidget( tb ); 2343 mIncSearchWidget = new IncSearchWidget( tb );
2328 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2344 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2329 SLOT( incrementalSearch( const QString& ) ) ); 2345 SLOT( incrementalSearch( const QString& ) ) );
2330 2346
2331 mJumpButtonBar = new JumpButtonBar( this, this ); 2347 mJumpButtonBar = new JumpButtonBar( this, this );
2332 2348
2333//US topLayout->addWidget( mJumpButtonBar ); 2349//US topLayout->addWidget( mJumpButtonBar );
2334 this->layout()->add( mJumpButtonBar ); 2350 this->layout()->add( mJumpButtonBar );
2335*/ 2351*/
2336 2352
2337#endif //KAB_EMBEDDED 2353#endif //KAB_EMBEDDED
2338 2354
2339 mActionExport2phone->plug( ExportMenu ); 2355 mActionExport2phone->plug( ExportMenu );
2340 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2356 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2341 syncManager->fillSyncMenu(); 2357 syncManager->fillSyncMenu();
2342 2358
2343} 2359}
2344void KABCore::showLicence() 2360void KABCore::showLicence()
2345{ 2361{
2346 KApplication::showLicence(); 2362 KApplication::showLicence();
2347} 2363}
2348 2364
2349void KABCore::manageCategories( ) 2365void KABCore::manageCategories( )
2350{ 2366{
2351 KABCatPrefs* cp = new KABCatPrefs(); 2367 KABCatPrefs* cp = new KABCatPrefs();
2352 cp->show(); 2368 cp->show();
2353 int w =cp->sizeHint().width() ; 2369 int w =cp->sizeHint().width() ;
2354 int h = cp->sizeHint().height() ; 2370 int h = cp->sizeHint().height() ;
2355 int dw = QApplication::desktop()->width(); 2371 int dw = QApplication::desktop()->width();
2356 int dh = QApplication::desktop()->height(); 2372 int dh = QApplication::desktop()->height();
2357 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2373 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2358 if ( !cp->exec() ) { 2374 if ( !cp->exec() ) {
2359 delete cp; 2375 delete cp;
2360 return; 2376 return;
2361 } 2377 }
2362 int count = 0; 2378 int count = 0;
2363 int cc = 0; 2379 int cc = 0;
2364 message( i18n("Please wait, processing categories...")); 2380 message( i18n("Please wait, processing categories..."));
2365 if ( cp->addCat() ) { 2381 if ( cp->addCat() ) {
2366 KABC::AddressBook::Iterator it; 2382 KABC::AddressBook::Iterator it;
2367 QStringList catList = KABPrefs::instance()->mCustomCategories; 2383 QStringList catList = KABPrefs::instance()->mCustomCategories;
2368 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2384 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2369 ++cc; 2385 ++cc;
2370 if ( cc %10 == 0) 2386 if ( cc %10 == 0)
2371 message(i18n("Processing contact #%1").arg(cc)); 2387 message(i18n("Processing contact #%1").arg(cc));
2372 QStringList catIncList = (*it).categories(); 2388 QStringList catIncList = (*it).categories();
2373 int i; 2389 int i;
2374 for( i = 0; i< catIncList.count(); ++i ) { 2390 for( i = 0; i< catIncList.count(); ++i ) {
2375 if ( !catList.contains (catIncList[i])) { 2391 if ( !catList.contains (catIncList[i])) {
2376 catList.append( catIncList[i] ); 2392 catList.append( catIncList[i] );
2377 //qDebug("add cat %s ", catIncList[i].latin1()); 2393 //qDebug("add cat %s ", catIncList[i].latin1());
2378 ++count; 2394 ++count;
2379 } 2395 }
2380 } 2396 }
2381 } 2397 }
2382 catList.sort(); 2398 catList.sort();
2383 KABPrefs::instance()->mCustomCategories = catList; 2399 KABPrefs::instance()->mCustomCategories = catList;
2384 KABPrefs::instance()->writeConfig(); 2400 KABPrefs::instance()->writeConfig();
2385 message(QString::number( count )+ i18n(" categories added to list! ")); 2401 message(QString::number( count )+ i18n(" categories added to list! "));
2386 } else { 2402 } else {
2387 QStringList catList = KABPrefs::instance()->mCustomCategories; 2403 QStringList catList = KABPrefs::instance()->mCustomCategories;
2388 QStringList catIncList; 2404 QStringList catIncList;
2389 QStringList newCatList; 2405 QStringList newCatList;
2390 KABC::AddressBook::Iterator it; 2406 KABC::AddressBook::Iterator it;
2391 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2407 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2392 ++cc; 2408 ++cc;
2393 if ( cc %10 == 0) 2409 if ( cc %10 == 0)
2394 message(i18n("Processing contact #%1").arg(cc)); 2410 message(i18n("Processing contact #%1").arg(cc));
2395 QStringList catIncList = (*it).categories(); 2411 QStringList catIncList = (*it).categories();
2396 int i; 2412 int i;
2397 if ( catIncList.count() ) { 2413 if ( catIncList.count() ) {
2398 newCatList.clear(); 2414 newCatList.clear();
2399 for( i = 0; i< catIncList.count(); ++i ) { 2415 for( i = 0; i< catIncList.count(); ++i ) {
2400 if ( catList.contains (catIncList[i])) { 2416 if ( catList.contains (catIncList[i])) {
2401 newCatList.append( catIncList[i] ); 2417 newCatList.append( catIncList[i] );
2402 } 2418 }
2403 } 2419 }
2404 newCatList.sort(); 2420 newCatList.sort();
2405 (*it).setCategories( newCatList ); 2421 (*it).setCategories( newCatList );
2406 mAddressBook->insertAddressee( (*it) ); 2422 mAddressBook->insertAddressee( (*it) );
2407 } 2423 }
2408 } 2424 }
2409 setModified( true ); 2425 setModified( true );
2410 mViewManager->refreshView(); 2426 mViewManager->refreshView();
2411 message( i18n("Removing categories done!")); 2427 message( i18n("Removing categories done!"));
2412 } 2428 }
2413 delete cp; 2429 delete cp;
2414} 2430}
2415void KABCore::removeVoice() 2431void KABCore::removeVoice()
2416{ 2432{
2417 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2433 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2418 return; 2434 return;
2419 XXPortSelectDialog dlg( this, false, this ); 2435 XXPortSelectDialog dlg( this, false, this );
2420 if ( !dlg.exec() ) 2436 if ( !dlg.exec() )
2421 return; 2437 return;
2422 mAddressBook->setUntagged(); 2438 mAddressBook->setUntagged();
2423 dlg.tagSelected(); 2439 dlg.tagSelected();
2424 message(i18n("Removing voice..."), false ); 2440 message(i18n("Removing voice..."), false );
2425 KABC::AddressBook::Iterator it; 2441 KABC::AddressBook::Iterator it;
2426 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2442 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2427 if ( (*it).tagged() ) { 2443 if ( (*it).tagged() ) {
2428 (*it).removeVoice(); 2444 (*it).removeVoice();
2429 } 2445 }
2430 } 2446 }
2431 message(i18n("Refreshing view...") ); 2447 message(i18n("Refreshing view...") );
2432 qApp->processEvents(); 2448 qApp->processEvents();
2433 mViewManager->refreshView( "" ); 2449 mViewManager->refreshView( "" );
2434 Addressee add; 2450 Addressee add;
2435 mDetails->setAddressee( add ); 2451 mDetails->setAddressee( add );
2436 message(i18n("Remove voice completed!") ); 2452 message(i18n("Remove voice completed!") );
2437 2453
2438 2454
2439 2455
2440} 2456}
2441 2457
2442void KABCore::setFormattedName() 2458void KABCore::setFormattedName()
2443{ 2459{
2444 KABFormatPrefs setpref; 2460 KABFormatPrefs setpref;
2445 if ( !setpref.exec() ) { 2461 if ( !setpref.exec() ) {
2446 return; 2462 return;
2447 } 2463 }
2448 XXPortSelectDialog dlg( this, false, this ); 2464 XXPortSelectDialog dlg( this, false, this );
2449 if ( !dlg.exec() ) 2465 if ( !dlg.exec() )
2450 return; 2466 return;
2451 mAddressBook->setUntagged(); 2467 mAddressBook->setUntagged();
2452 dlg.tagSelected(); 2468 dlg.tagSelected();
2453 int count = 0; 2469 int count = 0;
2454 KABC::AddressBook::Iterator it; 2470 KABC::AddressBook::Iterator it;
2455 bool modified = false; 2471 bool modified = false;
2456 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2472 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2457 if ( (*it).tagged() ) { 2473 if ( (*it).tagged() ) {
2458 if ( (*it).uid().left( 2 ) == "la" ) 2474 if ( (*it).uid().left( 2 ) == "la" )
2459 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) 2475 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") )
2460 continue; 2476 continue;
2461 ++count; 2477 ++count;
2462 if ( count %10 == 0 ) 2478 if ( count %10 == 0 )
2463 message(i18n("Changing contact #%1").arg( count ) ); 2479 message(i18n("Changing contact #%1").arg( count ) );
2464 qApp->processEvents(); 2480 qApp->processEvents();
2465 QString fName; 2481 QString fName;
2466 if ( setpref.simple->isChecked() ) 2482 if ( setpref.simple->isChecked() )
2467 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2483 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2468 else if ( setpref.full->isChecked() ) 2484 else if ( setpref.full->isChecked() )
2469 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2485 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2470 else if ( setpref.reverse->isChecked() ) 2486 else if ( setpref.reverse->isChecked() )
2471 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2487 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2472 else 2488 else
2473 fName = (*it).organization(); 2489 fName = (*it).organization();
2474 if ( setpref.setCompany->isChecked() ) 2490 if ( setpref.setCompany->isChecked() )
2475 if ( fName.isEmpty() || fName =="," ) 2491 if ( fName.isEmpty() || fName =="," )
2476 fName = (*it).organization(); 2492 fName = (*it).organization();
2477 (*it).setFormattedName( fName ); 2493 (*it).setFormattedName( fName );
2478 (*it).setChanged( true ); 2494 (*it).setChanged( true );
2479 modified = true; 2495 modified = true;
2480 (*it).setRevision( QDateTime::currentDateTime() ); 2496 (*it).setRevision( QDateTime::currentDateTime() );
2481 } 2497 }
2482 } 2498 }
2483 message(i18n("Refreshing view...") ); 2499 message(i18n("Refreshing view...") );
2484 qApp->processEvents(); 2500 qApp->processEvents();
2485 if ( modified ) 2501 if ( modified )
2486 setModified( true ); 2502 setModified( true );
2487 Addressee add; 2503 Addressee add;
2488 mDetails->setAddressee( add ); 2504 mDetails->setAddressee( add );
2489 if ( count == 0 ) 2505 if ( count == 0 )
2490 message(i18n("No contact changed!") ); 2506 message(i18n("No contact changed!") );
2491 else 2507 else
2492 message(i18n("%1 contacts changed!").arg( count ) ); 2508 message(i18n("%1 contacts changed!").arg( count ) );
2493} 2509}
2494 2510
2495void KABCore::clipboardDataChanged() 2511void KABCore::clipboardDataChanged()
2496{ 2512{
2497 2513
2498 if ( mReadWrite ) 2514 if ( mReadWrite )
2499 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2515 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2500 2516
2501} 2517}
2502 2518
2503void KABCore::updateActionMenu() 2519void KABCore::updateActionMenu()
2504{ 2520{
2505 UndoStack *undo = UndoStack::instance(); 2521 UndoStack *undo = UndoStack::instance();
2506 RedoStack *redo = RedoStack::instance(); 2522 RedoStack *redo = RedoStack::instance();
2507 2523
2508 if ( undo->isEmpty() ) 2524 if ( undo->isEmpty() )
2509 mActionUndo->setText( i18n( "Undo" ) ); 2525 mActionUndo->setText( i18n( "Undo" ) );
2510 else 2526 else
2511 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2527 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2512 2528
2513 mActionUndo->setEnabled( !undo->isEmpty() ); 2529 mActionUndo->setEnabled( !undo->isEmpty() );
2514 2530
2515 if ( !redo->top() ) 2531 if ( !redo->top() )
2516 mActionRedo->setText( i18n( "Redo" ) ); 2532 mActionRedo->setText( i18n( "Redo" ) );
2517 else 2533 else
2518 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2534 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2519 2535
2520 mActionRedo->setEnabled( !redo->isEmpty() ); 2536 mActionRedo->setEnabled( !redo->isEmpty() );
2521} 2537}
2522 2538
2523void KABCore::configureKeyBindings() 2539void KABCore::configureKeyBindings()
2524{ 2540{
2525#ifndef KAB_EMBEDDED 2541#ifndef KAB_EMBEDDED
2526 KKeyDialog::configure( actionCollection(), true ); 2542 KKeyDialog::configure( actionCollection(), true );
2527#else //KAB_EMBEDDED 2543#else //KAB_EMBEDDED
2528 qDebug("KABCore::configureKeyBindings() not implemented"); 2544 qDebug("KABCore::configureKeyBindings() not implemented");
2529#endif //KAB_EMBEDDED 2545#endif //KAB_EMBEDDED
2530} 2546}
2531 2547
2532#ifdef KAB_EMBEDDED 2548#ifdef KAB_EMBEDDED
2533void KABCore::configureResources() 2549void KABCore::configureResources()
2534{ 2550{
2535 KRES::KCMKResources dlg( this, "" , 0 ); 2551 KRES::KCMKResources dlg( this, "" , 0 );
2536 2552
2537 if ( !dlg.exec() ) 2553 if ( !dlg.exec() )
2538 return; 2554 return;
2539 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2555 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2540} 2556}
2541#endif //KAB_EMBEDDED 2557#endif //KAB_EMBEDDED
2542 2558
2543 2559
2544/* this method will be called through the QCop interface from Ko/Pi to select addresses 2560/* this method will be called through the QCop interface from Ko/Pi to select addresses
2545 * for the attendees list of an event. 2561 * for the attendees list of an event.
2546 */ 2562 */
2547void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2563void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2548{ 2564{
2549 qDebug("KABCore::requestForNameEmailUidList "); 2565 qDebug("KABCore::requestForNameEmailUidList ");
2550 bool ok = false; 2566 bool ok = false;
2551 mEmailSourceChannel = sourceChannel; 2567 mEmailSourceChannel = sourceChannel;
2552 mEmailSourceUID = uid; 2568 mEmailSourceUID = uid;
2553 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2569 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2554 //callContactdialog(); 2570 //callContactdialog();
2555#if 0 2571#if 0
2556 int wid = uid.toInt( &ok ); 2572 int wid = uid.toInt( &ok );
2557 qDebug("UID %s ", uid.latin1()); 2573 qDebug("UID %s ", uid.latin1());
2558 if ( ok ) { 2574 if ( ok ) {
2559 if ( wid != QApplication::desktop()->width() ) { 2575 if ( wid != QApplication::desktop()->width() ) {
2560 qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); 2576 qDebug("KA/Pi: Request from different desktop geometry. Resizing ...");
2561 message( i18n("Resizing, please wait...") ); 2577 message( i18n("Resizing, please wait...") );
2562 mMainWindow->showMinimized(); 2578 mMainWindow->showMinimized();
2563 /* 2579 /*
2564 { 2580 {
2565 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2581 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2566 } 2582 }
2567 */ 2583 */
2568 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); 2584 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) );
2569 return; 2585 return;
2570 } 2586 }
2571 2587
2572 } else { 2588 } else {
2573 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); 2589 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid ");
2574 } 2590 }
2575 callContactdialog(); 2591 callContactdialog();
2576 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2592 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2577#endif 2593#endif
2578} 2594}
2579void KABCore::resizeAndCallContactdialog() 2595void KABCore::resizeAndCallContactdialog()
2580{ 2596{
2581 updateMainWindow(); 2597 updateMainWindow();
2582 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2598 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2583} 2599}
2584 2600
2585void KABCore::doRingSync() 2601void KABCore::doRingSync()
2586{ 2602{
2587 topLevelWidget()->raise(); 2603 topLevelWidget()->raise();
2588 syncManager->multiSync( false ); 2604 syncManager->multiSync( false );
2589} 2605}
2590void KABCore::callContactdialog() 2606void KABCore::callContactdialog()
2591{ 2607{
2592 static bool running = false; 2608 static bool running = false;
2593 if (running) return; 2609 if (running) return;
2594 running = true; 2610 running = true;
2595 QStringList nameList; 2611 QStringList nameList;
2596 QStringList emailList; 2612 QStringList emailList;
2597 QStringList uidList; 2613 QStringList uidList;
2598 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); 2614 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() );
2599 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2615 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2600 uint i=0; 2616 uint i=0;
2601 for (i=0; i < list.count(); i++) 2617 for (i=0; i < list.count(); i++)
2602 { 2618 {
2603 nameList.append(list[i].realName()); 2619 nameList.append(list[i].realName());
2604 emailList.append(list[i].preferredEmail()); 2620 emailList.append(list[i].preferredEmail());
2605 uidList.append(list[i].uid()); 2621 uidList.append(list[i].uid());
2606 } 2622 }
2607 QString uid = mEmailSourceUID; 2623 QString uid = mEmailSourceUID;
2608 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); 2624 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1());
2609 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); 2625 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList);
2610 running = false; 2626 running = false;
2611} 2627}
2612/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2628/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2613 * to put them into the calendar. 2629 * to put them into the calendar.
2614 */ 2630 */
2615void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2631void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2616{ 2632{
2617 // qDebug("KABCore::requestForBirthdayList"); 2633 // qDebug("KABCore::requestForBirthdayList");
2618 QStringList birthdayList; 2634 QStringList birthdayList;
2619 QStringList anniversaryList; 2635 QStringList anniversaryList;
2620 QStringList realNameList; 2636 QStringList realNameList;
2621 QStringList preferredEmailList; 2637 QStringList preferredEmailList;
2622 QStringList assembledNameList; 2638 QStringList assembledNameList;
2623 QStringList uidList; 2639 QStringList uidList;
2624 2640
2625 KABC::AddressBook::Iterator it; 2641 KABC::AddressBook::Iterator it;
2626 2642
2627 int count = 0; 2643 int count = 0;
2628 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2644 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2629 ++count; 2645 ++count;
2630 } 2646 }
2631 QProgressBar bar(count,0 ); 2647 QProgressBar bar(count,0 );
2632 int w = 300; 2648 int w = 300;
2633 if ( QApplication::desktop()->width() < 320 ) 2649 if ( QApplication::desktop()->width() < 320 )
2634 w = 220; 2650 w = 220;
2635 int h = bar.sizeHint().height() ; 2651 int h = bar.sizeHint().height() ;
2636 int dw = QApplication::desktop()->width(); 2652 int dw = QApplication::desktop()->width();
2637 int dh = QApplication::desktop()->height(); 2653 int dh = QApplication::desktop()->height();
2638 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2654 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2639 bar.show(); 2655 bar.show();
2640 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2656 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2641 qApp->processEvents(); 2657 qApp->processEvents();
2642 2658
2643 QDate bday; 2659 QDate bday;
2644 QString anni; 2660 QString anni;
2645 QString formattedbday; 2661 QString formattedbday;
2646 2662
2647 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2663 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2648 { 2664 {
2649 if ( ! bar.isVisible() ) 2665 if ( ! bar.isVisible() )
2650 return; 2666 return;
2651 bar.setProgress( count++ ); 2667 bar.setProgress( count++ );
2652 qApp->processEvents(); 2668 qApp->processEvents();
2653 bday = (*it).birthday().date(); 2669 bday = (*it).birthday().date();
2654 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2670 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2655 2671
2656 if ( bday.isValid() || !anni.isEmpty()) 2672 if ( bday.isValid() || !anni.isEmpty())
2657 { 2673 {
2658 if (bday.isValid()) 2674 if (bday.isValid())
2659 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2675 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2660 else 2676 else
2661 formattedbday = "NOTVALID"; 2677 formattedbday = "NOTVALID";
2662 if (anni.isEmpty()) 2678 if (anni.isEmpty())
2663 anni = "INVALID"; 2679 anni = "INVALID";
2664 2680
2665 birthdayList.append(formattedbday); 2681 birthdayList.append(formattedbday);
2666 anniversaryList.append(anni); //should be ISODate 2682 anniversaryList.append(anni); //should be ISODate
2667 realNameList.append((*it).realName()); 2683 realNameList.append((*it).realName());
2668 preferredEmailList.append((*it).preferredEmail()); 2684 preferredEmailList.append((*it).preferredEmail());
2669 assembledNameList.append((*it).assembledName()); 2685 assembledNameList.append((*it).realName());
2670 uidList.append((*it).uid()); 2686 uidList.append((*it).uid());
2671 2687
2672 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2688 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2673 } 2689 }
2674 } 2690 }
2675 2691
2676 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2692 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2677 2693
2678} 2694}
2679 2695
2680/* this method will be called through the QCop interface from other apps to show details of a contact. 2696/* this method will be called through the QCop interface from other apps to show details of a contact.
2681 */ 2697 */
2682void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2698void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2683{ 2699{
2684 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2700 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2685 2701
2686 QString foundUid = QString::null; 2702 QString foundUid = QString::null;
2687 if ( ! uid.isEmpty() ) { 2703 if ( ! uid.isEmpty() ) {
2688 Addressee adrr = mAddressBook->findByUid( uid ); 2704 Addressee adrr = mAddressBook->findByUid( uid );
2689 if ( !adrr.isEmpty() ) { 2705 if ( !adrr.isEmpty() ) {
2690 foundUid = uid; 2706 foundUid = uid;
2691 } 2707 }
2692 if ( email == "sendbacklist" ) { 2708 if ( email == "sendbacklist" ) {
2693 //qDebug("ssssssssssssssssssssssend "); 2709 //qDebug("ssssssssssssssssssssssend ");
2694 QStringList nameList; 2710 QStringList nameList;
2695 QStringList emailList; 2711 QStringList emailList;
2696 QStringList uidList; 2712 QStringList uidList;
2697 nameList.append(adrr.realName()); 2713 nameList.append(adrr.realName());
2698 emailList = adrr.emails(); 2714 emailList = adrr.emails();
2699 uidList.append( adrr.preferredEmail()); 2715 uidList.append( adrr.preferredEmail());
2700 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2716 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2701 return; 2717 return;
2702 } 2718 }
2703 2719
2704 } 2720 }
2705 2721
2706 if ( email == "sendbacklist" ) 2722 if ( email == "sendbacklist" )
2707 return; 2723 return;
2708 if (foundUid.isEmpty()) 2724 if (foundUid.isEmpty())
2709 { 2725 {
2710 //find the uid of the person first 2726 //find the uid of the person first
2711 Addressee::List namelist; 2727 Addressee::List namelist;
2712 Addressee::List emaillist; 2728 Addressee::List emaillist;
2713 2729
2714 if (!name.isEmpty()) 2730 if (!name.isEmpty())
2715 namelist = mAddressBook->findByName( name ); 2731 namelist = mAddressBook->findByName( name );
2716 2732
2717 if (!email.isEmpty()) 2733 if (!email.isEmpty())
2718 emaillist = mAddressBook->findByEmail( email ); 2734 emaillist = mAddressBook->findByEmail( email );
2719 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2735 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2720 //check if we have a match in Namelist and Emaillist 2736 //check if we have a match in Namelist and Emaillist
2721 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2737 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2722 foundUid = emaillist[0].uid(); 2738 foundUid = emaillist[0].uid();
2723 } 2739 }
2724 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2740 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2725 foundUid = namelist[0].uid(); 2741 foundUid = namelist[0].uid();
2726 else 2742 else
2727 { 2743 {
2728 for (int i = 0; i < namelist.count(); i++) 2744 for (int i = 0; i < namelist.count(); i++)
2729 { 2745 {
2730 for (int j = 0; j < emaillist.count(); j++) 2746 for (int j = 0; j < emaillist.count(); j++)
2731 { 2747 {
2732 if (namelist[i] == emaillist[j]) 2748 if (namelist[i] == emaillist[j])
2733 { 2749 {
2734 foundUid = namelist[i].uid(); 2750 foundUid = namelist[i].uid();
2735 } 2751 }
2736 } 2752 }
2737 } 2753 }
2738 } 2754 }
2739 } 2755 }
2740 else 2756 else
2741 { 2757 {
2742 foundUid = uid; 2758 foundUid = uid;
2743 } 2759 }
2744 2760
2745 if (!foundUid.isEmpty()) 2761 if (!foundUid.isEmpty())
2746 { 2762 {
2747 2763
2748 // raise Ka/Pi if it is in the background 2764 // raise Ka/Pi if it is in the background
2749#ifndef DESKTOP_VERSION 2765#ifndef DESKTOP_VERSION
2750#ifndef KORG_NODCOP 2766#ifndef KORG_NODCOP
2751 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2767 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2752#endif 2768#endif
2753#endif 2769#endif
2754 2770
2755 mMainWindow->showMaximized(); 2771 mMainWindow->showMaximized();
2756 mMainWindow-> raise(); 2772 mMainWindow-> raise();
2757 2773
2758 mViewManager->setSelected( "", false); 2774 mViewManager->setSelected( "", false);
2759 mViewManager->refreshView( "" ); 2775 mViewManager->refreshView( "" );
2760 mViewManager->setSelected( foundUid, true ); 2776 mViewManager->setSelected( foundUid, true );
2761 mViewManager->refreshView( foundUid ); 2777 mViewManager->refreshView( foundUid );
2762 2778
2763 if ( !mMultipleViewsAtOnce ) 2779 if ( !mMultipleViewsAtOnce )
2764 { 2780 {
2765 setDetailsVisible( true ); 2781 setDetailsVisible( true );
2766 mActionDetails->setChecked(true); 2782 mActionDetails->setChecked(true);
2767 } 2783 }
2768 } 2784 }
2769} 2785}
2770void KABCore::storagehowto() 2786void KABCore::storagehowto()
2771{ 2787{
2772 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 2788 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
2773} 2789}
2774void KABCore::whatsnew() 2790void KABCore::whatsnew()
2775{ 2791{
2776 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2792 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2777} 2793}
2778void KABCore::synchowto() 2794void KABCore::synchowto()
2779{ 2795{
2780 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2796 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2781} 2797}
2782void KABCore::kdesynchowto() 2798void KABCore::kdesynchowto()
2783{ 2799{
2784 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2800 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2785} 2801}
2786void KABCore::multisynchowto() 2802void KABCore::multisynchowto()
2787{ 2803{
2788 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2804 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2789} 2805}
2790void KABCore::faq() 2806void KABCore::faq()
2791{ 2807{
2792 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2808 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2793} 2809}
2794 2810
2795#include <libkcal/syncdefines.h> 2811#include <libkcal/syncdefines.h>
2796 2812
2797KABC::Addressee KABCore::getLastSyncAddressee() 2813KABC::Addressee KABCore::getLastSyncAddressee()
2798{ 2814{
2799 Addressee lse; 2815 Addressee lse;
2800 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2816 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2801 2817
2802 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2818 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2803 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2819 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2804 if (lse.isEmpty()) { 2820 if (lse.isEmpty()) {
2805 qDebug("KA: Creating new last-syncAddressee "); 2821 qDebug("KA: Creating new last-syncAddressee ");
2806 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2822 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2807 QString sum = ""; 2823 QString sum = "";
2808 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2824 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2809 sum = "E: "; 2825 sum = "E: ";
2810 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2826 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2811 lse.setRevision( mLastAddressbookSync ); 2827 lse.setRevision( mLastAddressbookSync );
2812 lse.setCategories( i18n("SyncEvent") ); 2828 lse.setCategories( i18n("SyncEvent") );
2813 mAddressBook->insertAddressee( lse ); 2829 mAddressBook->insertAddressee( lse );
2814 } 2830 }
2815 return lse; 2831 return lse;
2816} 2832}
2817int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2833int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2818{ 2834{
2819 2835
2820 //void setZaurusId(int id); 2836 //void setZaurusId(int id);
2821 // int zaurusId() const; 2837 // int zaurusId() const;
2822 // void setZaurusUid(int id); 2838 // void setZaurusUid(int id);
2823 // int zaurusUid() const; 2839 // int zaurusUid() const;
2824 // void setZaurusStat(int id); 2840 // void setZaurusStat(int id);
2825 // int zaurusStat() const; 2841 // int zaurusStat() const;
2826 // 0 equal 2842 // 0 equal
2827 // 1 take local 2843 // 1 take local
2828 // 2 take remote 2844 // 2 take remote
2829 // 3 cancel 2845 // 3 cancel
2830 QDateTime lastSync = mLastAddressbookSync; 2846 QDateTime lastSync = mLastAddressbookSync;
2831 QDateTime localMod = local->revision(); 2847 QDateTime localMod = local->revision();
2832 QDateTime remoteMod = remote->revision(); 2848 QDateTime remoteMod = remote->revision();
2833 2849
2834 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2850 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2835 2851
2836 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2852 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2837 bool remCh, locCh; 2853 bool remCh, locCh;
2838 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2854 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2839 //if ( remCh ) 2855 //if ( remCh )
2840 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2856 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2841 locCh = ( localMod > mLastAddressbookSync ); 2857 locCh = ( localMod > mLastAddressbookSync );
2842 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2858 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2843 if ( !remCh && ! locCh ) { 2859 if ( !remCh && ! locCh ) {
2844 //qDebug("both not changed "); 2860 //qDebug("both not changed ");
2845 lastSync = localMod.addDays(1); 2861 lastSync = localMod.addDays(1);
2846 if ( mode <= SYNC_PREF_ASK ) 2862 if ( mode <= SYNC_PREF_ASK )
2847 return 0; 2863 return 0;
2848 } else { 2864 } else {
2849 if ( locCh ) { 2865 if ( locCh ) {
2850 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2866 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2851 lastSync = localMod.addDays( -1 ); 2867 lastSync = localMod.addDays( -1 );
2852 if ( !remCh ) 2868 if ( !remCh )
2853 remoteMod =( lastSync.addDays( -1 ) ); 2869 remoteMod =( lastSync.addDays( -1 ) );
2854 } else { 2870 } else {
2855 //qDebug(" not loc changed "); 2871 //qDebug(" not loc changed ");
2856 lastSync = localMod.addDays( 1 ); 2872 lastSync = localMod.addDays( 1 );
2857 if ( remCh ) { 2873 if ( remCh ) {
2858 //qDebug("rem changed "); 2874 //qDebug("rem changed ");
2859 remoteMod =( lastSync.addDays( 1 ) ); 2875 remoteMod =( lastSync.addDays( 1 ) );
2860 } 2876 }
2861 2877
2862 } 2878 }
2863 } 2879 }
2864 full = true; 2880 full = true;
2865 if ( mode < SYNC_PREF_ASK ) 2881 if ( mode < SYNC_PREF_ASK )
2866 mode = SYNC_PREF_ASK; 2882 mode = SYNC_PREF_ASK;
2867 } else { 2883 } else {
2868 if ( localMod == remoteMod ) 2884 if ( localMod == remoteMod )
2869 return 0; 2885 return 0;
2870 2886
2871 } 2887 }
2872 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2888 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2873 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2889 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2874 //full = true; //debug only 2890 //full = true; //debug only
2875 if ( full ) { 2891 if ( full ) {
2876 bool equ = ( (*local) == (*remote) ); 2892 bool equ = ( (*local) == (*remote) );
2877 if ( equ ) { 2893 if ( equ ) {
2878 //qDebug("equal "); 2894 //qDebug("equal ");
2879 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2895 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2880 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2896 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2881 } 2897 }
2882 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2898 if ( mode < SYNC_PREF_FORCE_LOCAL )
2883 return 0; 2899 return 0;
2884 2900
2885 }//else //debug only 2901 }//else //debug only
2886 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2902 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2887 } 2903 }
2888 int result; 2904 int result;
2889 bool localIsNew; 2905 bool localIsNew;
2890 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2906 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2891 2907
2892 if ( full && mode < SYNC_PREF_NEWEST ) 2908 if ( full && mode < SYNC_PREF_NEWEST )
2893 mode = SYNC_PREF_ASK; 2909 mode = SYNC_PREF_ASK;
2894 2910
2895 switch( mode ) { 2911 switch( mode ) {
2896 case SYNC_PREF_LOCAL: 2912 case SYNC_PREF_LOCAL:
2897 if ( lastSync > remoteMod ) 2913 if ( lastSync > remoteMod )
2898 return 1; 2914 return 1;
2899 if ( lastSync > localMod ) 2915 if ( lastSync > localMod )
2900 return 2; 2916 return 2;
2901 return 1; 2917 return 1;
2902 break; 2918 break;
2903 case SYNC_PREF_REMOTE: 2919 case SYNC_PREF_REMOTE:
2904 if ( lastSync > localMod ) 2920 if ( lastSync > localMod )
2905 return 2; 2921 return 2;
2906 if ( lastSync > remoteMod ) 2922 if ( lastSync > remoteMod )
2907 return 1; 2923 return 1;
2908 return 2; 2924 return 2;
2909 break; 2925 break;
2910 case SYNC_PREF_NEWEST: 2926 case SYNC_PREF_NEWEST:
2911 if ( localMod > remoteMod ) 2927 if ( localMod > remoteMod )
2912 return 1; 2928 return 1;
2913 else 2929 else
2914 return 2; 2930 return 2;
2915 break; 2931 break;
2916 case SYNC_PREF_ASK: 2932 case SYNC_PREF_ASK:
2917 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2933 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2918 if ( lastSync > remoteMod && lastSync > localMod) 2934 if ( lastSync > remoteMod && lastSync > localMod)
2919 return 0; 2935 return 0;
2920 if ( lastSync > remoteMod ) 2936 if ( lastSync > remoteMod )
2921 return 1; 2937 return 1;
2922 if ( lastSync > localMod ) { 2938 if ( lastSync > localMod ) {
2923 return 2; 2939 return 2;
2924 } 2940 }
2925 localIsNew = localMod >= remoteMod; 2941 localIsNew = localMod >= remoteMod;
2926 //qDebug("conflict! ************************************** "); 2942 //qDebug("conflict! ************************************** ");
2927 { 2943 {
2928 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2944 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2929 result = acd.executeD(localIsNew); 2945 result = acd.executeD(localIsNew);
2930 return result; 2946 return result;
2931 } 2947 }
2932 break; 2948 break;
2933 case SYNC_PREF_FORCE_LOCAL: 2949 case SYNC_PREF_FORCE_LOCAL:
2934 return 1; 2950 return 1;
2935 break; 2951 break;
2936 case SYNC_PREF_FORCE_REMOTE: 2952 case SYNC_PREF_FORCE_REMOTE:
2937 return 2; 2953 return 2;
2938 break; 2954 break;
2939 2955
2940 default: 2956 default:
2941 // SYNC_PREF_TAKE_BOTH not implemented 2957 // SYNC_PREF_TAKE_BOTH not implemented
2942 break; 2958 break;
2943 } 2959 }
2944 return 0; 2960 return 0;
2945} 2961}
2946 2962
2947 2963
2948bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2964bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2949{ 2965{
2950 bool syncOK = true; 2966 bool syncOK = true;
2951 int addedAddressee = 0; 2967 int addedAddressee = 0;
2952 int addedAddresseeR = 0; 2968 int addedAddresseeR = 0;
2953 int deletedAddresseeR = 0; 2969 int deletedAddresseeR = 0;
2954 int deletedAddresseeL = 0; 2970 int deletedAddresseeL = 0;
2955 int changedLocal = 0; 2971 int changedLocal = 0;
2956 int changedRemote = 0; 2972 int changedRemote = 0;
2957 int filteredIN = 0; 2973 int filteredIN = 0;
2958 int filteredOUT = 0; 2974 int filteredOUT = 0;
2959 2975
2960 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2976 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2961 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2977 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2962 2978
2963 //QPtrList<Addressee> el = local->rawAddressees(); 2979 //QPtrList<Addressee> el = local->rawAddressees();
2964 Addressee addresseeR; 2980 Addressee addresseeR;
2965 QString uid; 2981 QString uid;
2966 int take; 2982 int take;
2967 Addressee addresseeL; 2983 Addressee addresseeL;
2968 Addressee addresseeRSync; 2984 Addressee addresseeRSync;
2969 Addressee addresseeLSync; 2985 Addressee addresseeLSync;
2970 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2986 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2971 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2987 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2972 bool fullDateRange = false; 2988 bool fullDateRange = false;
2973 local->resetTempSyncStat(); 2989 local->resetTempSyncStat();
2974 mLastAddressbookSync = QDateTime::currentDateTime(); 2990 mLastAddressbookSync = QDateTime::currentDateTime();
2975 if ( syncManager->syncWithDesktop() ) { 2991 if ( syncManager->syncWithDesktop() ) {
2976 // remote->removeSyncInfo( QString());//remove all info 2992 // remote->removeSyncInfo( QString());//remove all info
2977 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2993 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2978 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2994 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2979 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2995 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2980 } else { 2996 } else {
2981 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); 2997 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime ");
2982 } 2998 }
2983 } 2999 }
2984 QDateTime modifiedCalendar = mLastAddressbookSync; 3000 QDateTime modifiedCalendar = mLastAddressbookSync;
2985 addresseeLSync = getLastSyncAddressee(); 3001 addresseeLSync = getLastSyncAddressee();
2986 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); 3002 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1());
2987 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 3003 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2988 if ( !addresseeR.isEmpty() ) { 3004 if ( !addresseeR.isEmpty() ) {
2989 addresseeRSync = addresseeR; 3005 addresseeRSync = addresseeR;
2990 remote->removeAddressee(addresseeR ); 3006 remote->removeAddressee(addresseeR );
2991 3007
2992 } else { 3008 } else {
2993 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3009 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2994 addresseeRSync = addresseeLSync ; 3010 addresseeRSync = addresseeLSync ;
2995 } else { 3011 } else {
2996 //qDebug("FULLDATE 1"); 3012 //qDebug("FULLDATE 1");
2997 fullDateRange = true; 3013 fullDateRange = true;
2998 Addressee newAdd; 3014 Addressee newAdd;
2999 addresseeRSync = newAdd; 3015 addresseeRSync = newAdd;
3000 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 3016 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
3001 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 3017 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
3002 addresseeRSync.setRevision( mLastAddressbookSync ); 3018 addresseeRSync.setRevision( mLastAddressbookSync );
3003 addresseeRSync.setCategories( i18n("SyncAddressee") ); 3019 addresseeRSync.setCategories( i18n("SyncAddressee") );
3004 } 3020 }
3005 } 3021 }
3006 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 3022 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
3007 // qDebug("FULLDATE 2"); 3023 // qDebug("FULLDATE 2");
3008 fullDateRange = true; 3024 fullDateRange = true;
3009 } 3025 }
3010 if ( ! fullDateRange ) { 3026 if ( ! fullDateRange ) {
3011 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 3027 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
3012 3028
3013 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 3029 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
3014 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 3030 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
3015 fullDateRange = true; 3031 fullDateRange = true;
3016 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 3032 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
3017 } 3033 }
3018 } 3034 }
3019 // fullDateRange = true; // debug only! 3035 // fullDateRange = true; // debug only!
3020 if ( fullDateRange ) 3036 if ( fullDateRange )
3021 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 3037 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
3022 else 3038 else
3023 mLastAddressbookSync = addresseeLSync.revision(); 3039 mLastAddressbookSync = addresseeLSync.revision();
3024 // for resyncing if own file has changed 3040 // for resyncing if own file has changed
3025 // PENDING fixme later when implemented 3041 // PENDING fixme later when implemented
3026#if 0 3042#if 0
3027 if ( mCurrentSyncDevice == "deleteaftersync" ) { 3043 if ( mCurrentSyncDevice == "deleteaftersync" ) {
3028 mLastAddressbookSync = loadedFileVersion; 3044 mLastAddressbookSync = loadedFileVersion;
3029 qDebug("setting mLastAddressbookSync "); 3045 qDebug("setting mLastAddressbookSync ");
3030 } 3046 }
3031#endif 3047#endif
3032 3048
3033 3049
3034 // ********** setting filters **************** 3050 // ********** setting filters ****************
3035 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 3051 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
3036 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 3052 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
3037 3053
3038 //qDebug("*************************** "); 3054 //qDebug("*************************** ");
3039 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 3055 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
3040 QStringList er = remote->uidList(); 3056 QStringList er = remote->uidList();
3041 Addressee inR ;//= er.first(); 3057 Addressee inR ;//= er.first();
3042 Addressee inL; 3058 Addressee inL;
3043 3059
3044 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3060 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3045 3061
3046 int modulo = (er.count()/10)+1; 3062 int modulo = (er.count()/10)+1;
3047 int incCounter = 0; 3063 int incCounter = 0;
3048 while ( incCounter < er.count()) { 3064 while ( incCounter < er.count()) {
3049 if (syncManager->isProgressBarCanceled()) 3065 if (syncManager->isProgressBarCanceled())
3050 return false; 3066 return false;
3051 if ( incCounter % modulo == 0 ) 3067 if ( incCounter % modulo == 0 )
3052 syncManager->showProgressBar(incCounter); 3068 syncManager->showProgressBar(incCounter);
3053 3069
3054 uid = er[ incCounter ]; 3070 uid = er[ incCounter ];
3055 bool skipIncidence = false; 3071 bool skipIncidence = false;
3056 if ( uid.left(19) == QString("last-syncAddressee-") ) 3072 if ( uid.left(19) == QString("last-syncAddressee-") )
3057 skipIncidence = true; 3073 skipIncidence = true;
3058 QString idS,OidS; 3074 QString idS,OidS;
3059 qApp->processEvents(); 3075 qApp->processEvents();
3060 if ( !skipIncidence ) { 3076 if ( !skipIncidence ) {
3061 inL = local->findByUid( uid ); 3077 inL = local->findByUid( uid );
3062 inR = remote->findByUid( uid ); 3078 inR = remote->findByUid( uid );
3063 //inL.setResource( 0 ); 3079 //inL.setResource( 0 );
3064 //inR.setResource( 0 ); 3080 //inR.setResource( 0 );
3065 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 3081 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
3066 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3082 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3067 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 3083 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
3068 //qDebug("take %d %s ", take, inL.summary().latin1()); 3084 //qDebug("take %d %s ", take, inL.summary().latin1());
3069 if ( take == 3 ) 3085 if ( take == 3 )
3070 return false; 3086 return false;
3071 if ( take == 1 ) {// take local ********************** 3087 if ( take == 1 ) {// take local **********************
3072 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3088 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3073 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3089 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3074 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3090 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3075 local->insertAddressee( inL, false ); 3091 local->insertAddressee( inL, false );
3076 idS = inR.externalUID(); 3092 idS = inR.externalUID();
3077 OidS = inR.originalExternalUID(); 3093 OidS = inR.originalExternalUID();
3078 } 3094 }
3079 else 3095 else
3080 idS = inR.IDStr(); 3096 idS = inR.IDStr();
3081 remote->removeAddressee( inR ); 3097 remote->removeAddressee( inR );
3082 inR = inL; 3098 inR = inL;
3083 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 3099 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
3084 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3100 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3085 inR.setOriginalExternalUID( OidS ); 3101 inR.setOriginalExternalUID( OidS );
3086 inR.setExternalUID( idS ); 3102 inR.setExternalUID( idS );
3087 if ( syncManager->syncWithDesktop() ) { 3103 if ( syncManager->syncWithDesktop() ) {
3088 inR.setIDStr("changed" ); 3104 inR.setIDStr("changed" );
3089 } 3105 }
3090 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 3106 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
3091 } else { 3107 } else {
3092 inR.setIDStr( idS ); 3108 inR.setIDStr( idS );
3093 } 3109 }
3094 inR.setResource( 0 ); 3110 inR.setResource( 0 );
3095 remote->insertAddressee( inR , false); 3111 remote->insertAddressee( inR , false);
3096 ++changedRemote; 3112 ++changedRemote;
3097 } else { // take == 2 take remote ********************** 3113 } else { // take == 2 take remote **********************
3098 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3114 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3099 if ( inR.revision().date().year() < 2004 ) 3115 if ( inR.revision().date().year() < 2004 )
3100 inR.setRevision( modifiedCalendar ); 3116 inR.setRevision( modifiedCalendar );
3101 } 3117 }
3102 idS = inL.IDStr(); 3118 idS = inL.IDStr();
3103 local->removeAddressee( inL ); 3119 local->removeAddressee( inL );
3104 inL = inR; 3120 inL = inR;
3105 inL.setIDStr( idS ); 3121 inL.setIDStr( idS );
3106 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3107 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3123 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3108 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3124 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3109 } 3125 }
3110 inL.setResource( 0 ); 3126 inL.setResource( 0 );
3111 local->insertAddressee( inL , false ); 3127 local->insertAddressee( inL , false );
3112 ++changedLocal; 3128 ++changedLocal;
3113 } 3129 }
3114 } 3130 }
3115 } 3131 }
3116 } else { // no conflict ********** add or delete remote 3132 } else { // no conflict ********** add or delete remote
3117 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 3133 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
3118 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3119 QString des = addresseeLSync.note(); 3135 QString des = addresseeLSync.note();
3120 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 3136 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
3121 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 3137 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
3122 remote->insertAddressee( inR, false ); 3138 remote->insertAddressee( inR, false );
3123 ++deletedAddresseeR; 3139 ++deletedAddresseeR;
3124 } else { 3140 } else {
3125 inR.setRevision( modifiedCalendar ); 3141 inR.setRevision( modifiedCalendar );
3126 remote->insertAddressee( inR, false ); 3142 remote->insertAddressee( inR, false );
3127 inL = inR; 3143 inL = inR;
3128 inL.setIDStr( ":" ); 3144 inL.setIDStr( ":" );
3129 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3145 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3130 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3146 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3131 inL.setResource( 0 ); 3147 inL.setResource( 0 );
3132 local->insertAddressee( inL , false); 3148 local->insertAddressee( inL , false);
3133 ++addedAddressee; 3149 ++addedAddressee;
3134 } 3150 }
3135 } else { 3151 } else {
3136 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3152 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3137 inR.setRevision( modifiedCalendar ); 3153 inR.setRevision( modifiedCalendar );
3138 remote->insertAddressee( inR, false ); 3154 remote->insertAddressee( inR, false );
3139 inR.setResource( 0 ); 3155 inR.setResource( 0 );
3140 local->insertAddressee( inR, false ); 3156 local->insertAddressee( inR, false );
3141 ++addedAddressee; 3157 ++addedAddressee;
3142 } else { 3158 } else {
3143 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3159 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3144 remote->removeAddressee( inR ); 3160 remote->removeAddressee( inR );
3145 ++deletedAddresseeR; 3161 ++deletedAddresseeR;
3146 } 3162 }
3147 } 3163 }
3148 } else { 3164 } else {
3149 ++filteredIN; 3165 ++filteredIN;
3150 } 3166 }
3151 } 3167 }
3152 } 3168 }
3153 ++incCounter; 3169 ++incCounter;
3154 } 3170 }
3155 er.clear(); 3171 er.clear();
3156 QStringList el = local->uidList(); 3172 QStringList el = local->uidList();
3157 modulo = (el.count()/10)+1; 3173 modulo = (el.count()/10)+1;
3158 3174
3159 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3175 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3160 incCounter = 0; 3176 incCounter = 0;
3161 while ( incCounter < el.count()) { 3177 while ( incCounter < el.count()) {
3162 qApp->processEvents(); 3178 qApp->processEvents();
3163 if (syncManager->isProgressBarCanceled()) 3179 if (syncManager->isProgressBarCanceled())
3164 return false; 3180 return false;
3165 if ( incCounter % modulo == 0 ) 3181 if ( incCounter % modulo == 0 )
3166 syncManager->showProgressBar(incCounter); 3182 syncManager->showProgressBar(incCounter);
3167 uid = el[ incCounter ]; 3183 uid = el[ incCounter ];
3168 bool skipIncidence = false; 3184 bool skipIncidence = false;
3169 if ( uid.left(19) == QString("last-syncAddressee-") ) 3185 if ( uid.left(19) == QString("last-syncAddressee-") )
3170 skipIncidence = true; 3186 skipIncidence = true;
3171 if ( !skipIncidence ) { 3187 if ( !skipIncidence ) {
3172 inL = local->findByUid( uid ); 3188 inL = local->findByUid( uid );
3173 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3189 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3174 inR = remote->findByUid( uid ); 3190 inR = remote->findByUid( uid );
3175 if ( inR.isEmpty() ){ 3191 if ( inR.isEmpty() ){
3176 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3192 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3177 // no conflict ********** add or delete local 3193 // no conflict ********** add or delete local
3178 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3194 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3179 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3195 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3180 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3196 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3181 local->removeAddressee( inL ); 3197 local->removeAddressee( inL );
3182 ++deletedAddresseeL; 3198 ++deletedAddresseeL;
3183 } else { 3199 } else {
3184 if ( ! syncManager->mWriteBackExistingOnly ) { 3200 if ( ! syncManager->mWriteBackExistingOnly ) {
3185 inL.removeID(mCurrentSyncDevice ); 3201 inL.removeID(mCurrentSyncDevice );
3186 ++addedAddresseeR; 3202 ++addedAddresseeR;
3187 inL.setRevision( modifiedCalendar ); 3203 inL.setRevision( modifiedCalendar );
3188 local->insertAddressee( inL, false ); 3204 local->insertAddressee( inL, false );
3189 inR = inL; 3205 inR = inL;
3190 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3206 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3191 inR.setResource( 0 ); 3207 inR.setResource( 0 );
3192 remote->insertAddressee( inR, false ); 3208 remote->insertAddressee( inR, false );
3193 } 3209 }
3194 } 3210 }
3195 } else { 3211 } else {
3196 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3212 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3197 //qDebug("data %s ", inL.revision().toString().latin1()); 3213 //qDebug("data %s ", inL.revision().toString().latin1());
3198 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3214 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3199 local->removeAddressee( inL ); 3215 local->removeAddressee( inL );
3200 ++deletedAddresseeL; 3216 ++deletedAddresseeL;
3201 } else { 3217 } else {
3202 if ( ! syncManager->mWriteBackExistingOnly ) { 3218 if ( ! syncManager->mWriteBackExistingOnly ) {
3203 ++addedAddresseeR; 3219 ++addedAddresseeR;
3204 inL.setRevision( modifiedCalendar ); 3220 inL.setRevision( modifiedCalendar );
3205 local->insertAddressee( inL, false ); 3221 local->insertAddressee( inL, false );
3206 inR = inL; 3222 inR = inL;
3207 inR.setIDStr( ":" ); 3223 inR.setIDStr( ":" );
3208 inR.setResource( 0 ); 3224 inR.setResource( 0 );
3209 remote->insertAddressee( inR, false ); 3225 remote->insertAddressee( inR, false );
3210 } 3226 }
3211 } 3227 }
3212 } 3228 }
3213 } else { 3229 } else {
3214 ++filteredOUT; 3230 ++filteredOUT;
3215 } 3231 }
3216 } 3232 }
3217 } 3233 }
3218 } 3234 }
3219 ++incCounter; 3235 ++incCounter;
3220 } 3236 }
3221 el.clear(); 3237 el.clear();
3222 syncManager->hideProgressBar(); 3238 syncManager->hideProgressBar();
3223 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3239 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3224 // get rid of micro seconds 3240 // get rid of micro seconds
3225 QTime t = mLastAddressbookSync.time(); 3241 QTime t = mLastAddressbookSync.time();
3226 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3242 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3227 addresseeLSync.setRevision( mLastAddressbookSync ); 3243 addresseeLSync.setRevision( mLastAddressbookSync );
3228 addresseeRSync.setRevision( mLastAddressbookSync ); 3244 addresseeRSync.setRevision( mLastAddressbookSync );
3229 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3245 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3230 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3246 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3231 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3247 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3232 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3248 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3233 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3249 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3234 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3250 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3235 addresseeRSync.setNote( "" ) ; 3251 addresseeRSync.setNote( "" ) ;
3236 addresseeLSync.setNote( "" ); 3252 addresseeLSync.setNote( "" );
3237 3253
3238 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3254 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3239 remote->insertAddressee( addresseeRSync, false ); 3255 remote->insertAddressee( addresseeRSync, false );
3240 local->insertAddressee( addresseeLSync, false ); 3256 local->insertAddressee( addresseeLSync, false );
3241 QString mes; 3257 QString mes;
3242 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3258 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3243 qDebug( mes ); 3259 qDebug( mes );
3244 mes = i18n("Local addressbook changed!\n") +mes; 3260 mes = i18n("Local addressbook changed!\n") +mes;
3245 if ( syncManager->mShowSyncSummary ) { 3261 if ( syncManager->mShowSyncSummary ) {
3246 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3262 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3247 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3263 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3248 qDebug("KA: WB cancelled "); 3264 qDebug("KA: WB cancelled ");
3249 syncManager->mWriteBackFile = false; 3265 syncManager->mWriteBackFile = false;
3250 return syncOK; 3266 return syncOK;
3251 } 3267 }
3252 } 3268 }
3253 return syncOK; 3269 return syncOK;
3254} 3270}
3255 3271
3256 3272
3257//this is a overwritten callbackmethods from the syncinterface 3273//this is a overwritten callbackmethods from the syncinterface
3258bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3274bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3259{ 3275{
3260 3276
3261 //pending prepare addresseeview for output 3277 //pending prepare addresseeview for output
3262 //pending detect, if remote file has REV field. if not switch to external sync 3278 //pending detect, if remote file has REV field. if not switch to external sync
3263 mGlobalSyncMode = SYNC_MODE_NORMAL; 3279 mGlobalSyncMode = SYNC_MODE_NORMAL;
3264 if ( manager != syncManager ) 3280 if ( manager != syncManager )
3265 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3281 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3266 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3282 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3267 3283
3268 AddressBook abLocal(filename,"syncContact"); 3284 AddressBook abLocal(filename,"syncContact");
3269 bool syncOK = false; 3285 bool syncOK = false;
3270 if ( abLocal.load() ) { 3286 if ( abLocal.load() ) {
3271 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); 3287 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
3272 bool external = false; 3288 bool external = false;
3273 bool isXML = false; 3289 bool isXML = false;
3274 if ( filename.right(4) == ".xml") { 3290 if ( filename.right(4) == ".xml") {
3275 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3291 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3276 isXML = true; 3292 isXML = true;
3277 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3293 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3278 } else { 3294 } else {
3279 external = !manager->mIsKapiFile; 3295 external = !manager->mIsKapiFile;
3280 if ( external ) { 3296 if ( external ) {
3281 qDebug("KA: Sync::Setting vcf mode to external "); 3297 qDebug("KA: Sync::Setting vcf mode to external ");
3282 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3298 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3283 AddressBook::Iterator it; 3299 AddressBook::Iterator it;
3284 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3300 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3285 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3301 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3286 (*it).computeCsum( mCurrentSyncDevice ); 3302 (*it).computeCsum( mCurrentSyncDevice );
3287 } 3303 }
3288 } 3304 }
3289 } 3305 }
3290 //AddressBook::Iterator it; 3306 //AddressBook::Iterator it;
3291 //QStringList vcards; 3307 //QStringList vcards;
3292 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3308 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3293 // qDebug("Name %s ", (*it).familyName().latin1()); 3309 // qDebug("Name %s ", (*it).familyName().latin1());
3294 //} 3310 //}
3295 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3311 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3296 syncManager->hideProgressBar(); 3312 syncManager->hideProgressBar();
3297 if ( syncOK ) { 3313 if ( syncOK ) {
3298 if ( syncManager->mWriteBackFile ) 3314 if ( syncManager->mWriteBackFile )
3299 { 3315 {
3300 if ( external ) 3316 if ( external )
3301 abLocal.removeSyncAddressees( !isXML); 3317 abLocal.removeSyncAddressees( !isXML);
3302 qDebug("KA: Sync::Saving remote AB "); 3318 qDebug("KA: Sync::Saving remote AB ");
3303 if ( ! abLocal.saveAB()) 3319 if ( ! abLocal.saveAB())
3304 qDebug("KA: sync::Error writing back AB to file "); 3320 qDebug("KA: sync::Error writing back AB to file ");
3305 if ( external ) { 3321 if ( external ) {
3306 // afterwrite processing 3322 // afterwrite processing
3307 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3323 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3308 } 3324 }
3309 } 3325 }
3310 } 3326 }
3311 setModified(); 3327 setModified();
3312 3328
3313 } 3329 }
3314 abLocal.removeResources(); 3330 abLocal.removeResources();
3315 if ( syncOK ) 3331 if ( syncOK )
3316 mViewManager->refreshView(); 3332 mViewManager->refreshView();
3317 return syncOK; 3333 return syncOK;
3318 3334
3319} 3335}
3320void KABCore::removeSyncInfo( QString syncProfile) 3336void KABCore::removeSyncInfo( QString syncProfile)
3321{ 3337{
3322 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3338 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3323 mAddressBook->removeSyncInfo( syncProfile ); 3339 mAddressBook->removeSyncInfo( syncProfile );
3324 setModified(); 3340 setModified();
3325} 3341}
3326 3342
3327 3343
3328//this is a overwritten callbackmethods from the syncinterface 3344//this is a overwritten callbackmethods from the syncinterface
3329bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3345bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3330{ 3346{
3331 if ( resource == "phone" ) 3347 if ( resource == "phone" )
3332 return syncPhone(); 3348 return syncPhone();
3333 disableBR( true ); 3349 disableBR( true );
3334 if ( manager != syncManager ) 3350 if ( manager != syncManager )
3335 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3351 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3336 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3352 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3337 3353
3338 AddressBook abLocal( resource,"syncContact"); 3354 AddressBook abLocal( resource,"syncContact");
3339 bool syncOK = false; 3355 bool syncOK = false;
3340 message(i18n("Loading DTM address data..."), false); 3356 message(i18n("Loading DTM address data..."), false);
3341 if ( abLocal.load() ) { 3357 if ( abLocal.load() ) {
3342 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3358 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3343 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3359 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3344 message(i18n("Sync preprocessing..."),false); 3360 message(i18n("Sync preprocessing..."),false);
3345 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3361 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3346 message(i18n("Synchronizing..."),false); 3362 message(i18n("Synchronizing..."),false);
3347 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3363 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3348 syncManager->hideProgressBar(); 3364 syncManager->hideProgressBar();
3349 if ( syncOK ) { 3365 if ( syncOK ) {
3350 if ( syncManager->mWriteBackFile ) { 3366 if ( syncManager->mWriteBackFile ) {
3351 abLocal.removeSyncAddressees( false ); 3367 abLocal.removeSyncAddressees( false );
3352 message(i18n("Saving DTM address data..."),false); 3368 message(i18n("Saving DTM address data..."),false);
3353 abLocal.saveAB(); 3369 abLocal.saveAB();
3354 message(i18n("Sync postprocessing..."),false); 3370 message(i18n("Sync postprocessing..."),false);
3355 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3371 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3356 } 3372 }
3357 } else 3373 } else
3358 message( i18n("Sync cancelled or failed.") ); 3374 message( i18n("Sync cancelled or failed.") );
3359 setModified(); 3375 setModified();
3360 } 3376 }
3361 abLocal.removeResources(); 3377 abLocal.removeResources();
3362 if ( syncOK ) { 3378 if ( syncOK ) {
3363 mViewManager->refreshView(); 3379 mViewManager->refreshView();
3364 message(i18n("DTM syncing finished.")); 3380 message(i18n("DTM syncing finished."));
3365 } 3381 }
3366 disableBR( false ); 3382 disableBR( false );
3367 return syncOK; 3383 return syncOK;
3368 3384
3369} 3385}
3370void KABCore::message( QString m, bool startTimer) 3386void KABCore::message( QString m, bool startTimer)
3371{ 3387{
3372 topLevelWidget()->setCaption( m ); 3388 topLevelWidget()->setCaption( m );
3373 qApp->processEvents(); 3389 qApp->processEvents();
3374 if ( startTimer ) 3390 if ( startTimer )
3375 mMessageTimer->start( 15000, true ); 3391 mMessageTimer->start( 15000, true );
3376 else 3392 else
3377 mMessageTimer->stop(); 3393 mMessageTimer->stop();
3378} 3394}
3379bool KABCore::syncPhone() 3395bool KABCore::syncPhone()
3380{ 3396{
3381 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3397 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3382 QString fileName = getPhoneFile(); 3398 QString fileName = getPhoneFile();
3383 if ( !PhoneAccess::readFromPhone( fileName) ) { 3399 if ( !PhoneAccess::readFromPhone( fileName) ) {
3384 message(i18n("Phone access failed!")); 3400 message(i18n("Phone access failed!"));
3385 return false; 3401 return false;
3386 } 3402 }
3387 AddressBook abLocal( fileName,"syncContact"); 3403 AddressBook abLocal( fileName,"syncContact");
3388 bool syncOK = false; 3404 bool syncOK = false;
3389 { 3405 {
3390 abLocal.importFromFile( fileName ); 3406 abLocal.importFromFile( fileName );
3391 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3407 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3392 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3408 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3393 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3409 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3394 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3410 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3395 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3411 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3396 syncManager->hideProgressBar(); 3412 syncManager->hideProgressBar();
3397 if ( syncOK ) { 3413 if ( syncOK ) {
3398 if ( syncManager->mWriteBackFile ) { 3414 if ( syncManager->mWriteBackFile ) {
3399 abLocal.removeSyncAddressees( true ); 3415 abLocal.removeSyncAddressees( true );
3400 abLocal.saveABphone( fileName ); 3416 abLocal.saveABphone( fileName );
3401 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3417 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3402 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3418 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3403 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3419 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3404 } 3420 }
3405 } 3421 }
3406 setModified(); 3422 setModified();
3407 } 3423 }
3408 abLocal.removeResources(); 3424 abLocal.removeResources();
3409 if ( syncOK ) 3425 if ( syncOK )
3410 mViewManager->refreshView(); 3426 mViewManager->refreshView();
3411 return syncOK; 3427 return syncOK;
3412} 3428}
3413void KABCore::getFile( bool success ) 3429void KABCore::getFile( bool success )
3414{ 3430{
3415 if ( ! success ) { 3431 if ( ! success ) {
3416 message( i18n("Error receiving file. Nothing changed!") ); 3432 message( i18n("Error receiving file. Nothing changed!") );
3417 return; 3433 return;
3418 } 3434 }
3419 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3435 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3420 if ( count ) 3436 if ( count )
3421 setModified( true ); 3437 setModified( true );
3422 message( i18n("Pi-Sync successful!") ); 3438 message( i18n("Pi-Sync successful!") );
3423 mViewManager->refreshView(); 3439 mViewManager->refreshView();
3424} 3440}
3425void KABCore::syncFileRequest() 3441void KABCore::syncFileRequest()
3426{ 3442{
3427 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3443 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3428 syncManager->slotSyncMenu( 999 ); 3444 syncManager->slotSyncMenu( 999 );
3429 } 3445 }
3430 mAddressBook->export2File( sentSyncFile() ); 3446 mAddressBook->export2File( sentSyncFile() );
3431} 3447}
3432QString KABCore::sentSyncFile() 3448QString KABCore::sentSyncFile()
3433{ 3449{
3434#ifdef DESKTOP_VERSION 3450#ifdef DESKTOP_VERSION
3435 return locateLocal( "tmp", "copysyncab.vcf" ); 3451 return locateLocal( "tmp", "copysyncab.vcf" );
3436#else 3452#else
3437 return QString( "/tmp/copysyncab.vcf" ); 3453 return QString( "/tmp/copysyncab.vcf" );
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index ea254b7..42d541b 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -1,156 +1,157 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24//US#ifdef KAB_EMBEDDED 24//US#ifdef KAB_EMBEDDED
25//#include <qstring.h> 25//#include <qstring.h>
26//#endif //KAB_EMBEDDED 26//#endif //KAB_EMBEDDED
27 27
28#include <qtextstream.h> 28#include <qtextstream.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qregexp.h> 30#include <qregexp.h>
31#include <stdlib.h> 31#include <stdlib.h>
32#include <libkdepim/kpimglobalprefs.h> 32#include <libkdepim/kpimglobalprefs.h>
33 33
34#include <kconfig.h> 34#include <kconfig.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kstaticdeleter.h> 36#include <kstaticdeleter.h>
37#include <kglobalsettings.h> 37#include <kglobalsettings.h>
38//US#include <kdebug.h> // defines kdDebug() 38//US#include <kdebug.h> // defines kdDebug()
39 39
40#include "kabprefs.h" 40#include "kabprefs.h"
41 41
42#ifdef DESKTOP_VERSION 42#ifdef DESKTOP_VERSION
43#include <qapplication.h> 43#include <qapplication.h>
44#endif 44#endif
45 45
46KABPrefs *KABPrefs::sInstance = 0; 46KABPrefs *KABPrefs::sInstance = 0;
47static KStaticDeleter<KABPrefs> staticDeleterAB; 47static KStaticDeleter<KABPrefs> staticDeleterAB;
48 48
49KABPrefs::KABPrefs() 49KABPrefs::KABPrefs()
50 : KPimPrefs("kaddressbookrc") 50 : KPimPrefs("kaddressbookrc")
51{ 51{
52 KPrefs::setCurrentGroup( "Views" ); 52 KPrefs::setCurrentGroup( "Views" );
53 addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); 53 addItemBool( "HonorSingleClick", &mHonorSingleClick, false );
54 54
55 KPrefs::setCurrentGroup( "General" ); 55 KPrefs::setCurrentGroup( "General" );
56 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); 56 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true );
57 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); 57 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 );
58#ifdef KAB_EMBEDDED 58#ifdef KAB_EMBEDDED
59 addItemBool("AskForDelete",&mAskForDelete,true);
59 addItemBool("AskForQuit",&mAskForQuit,true); 60 addItemBool("AskForQuit",&mAskForQuit,true);
60 addItemBool("ToolBarHor",&mToolBarHor, true ); 61 addItemBool("ToolBarHor",&mToolBarHor, true );
61 addItemBool("ToolBarUp",&mToolBarUp, false ); 62 addItemBool("ToolBarUp",&mToolBarUp, false );
62 addItemBool("SearchWithReturn",&mSearchWithReturn, false ); 63 addItemBool("SearchWithReturn",&mSearchWithReturn, false );
63 addItemBool("AutoSearchWithWildcard",&mAutoSearchWithWildcard, false ); 64 addItemBool("AutoSearchWithWildcard",&mAutoSearchWithWildcard, false );
64 addItemBool("HideSearchOnSwitch",&mHideSearchOnSwitch, false ); 65 addItemBool("HideSearchOnSwitch",&mHideSearchOnSwitch, false );
65 addItemFont("DetailsFont",&mDetailsFont,KGlobalSettings::generalFont()); 66 addItemFont("DetailsFont",&mDetailsFont,KGlobalSettings::generalFont());
66 67
67 68
68#endif //KAB_EMBEDDED 69#endif //KAB_EMBEDDED
69 70
70 KPrefs::setCurrentGroup( "MainWindow" ); 71 KPrefs::setCurrentGroup( "MainWindow" );
71 bool m_visible = false; 72 bool m_visible = false;
72#ifdef DESKTOP_VERSION 73#ifdef DESKTOP_VERSION
73 m_visible = true; 74 m_visible = true;
74#endif 75#endif
75 addItemBool( "FullMenuBarVisible", &mFullMenuBarVisible, m_visible ); 76 addItemBool( "FullMenuBarVisible", &mFullMenuBarVisible, m_visible );
76 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); 77 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false );
77 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); 78 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true );
78 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); 79 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter );
79 addItemIntList( "DetailsSplitter", &mDetailsSplitter ); 80 addItemIntList( "DetailsSplitter", &mDetailsSplitter );
80 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); 81 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true );
81 82
82 83
83 KPrefs::setCurrentGroup( "Extensions_General" ); 84 KPrefs::setCurrentGroup( "Extensions_General" );
84 QStringList defaultExtensions; 85 QStringList defaultExtensions;
85 defaultExtensions << "merge"; 86 defaultExtensions << "merge";
86 defaultExtensions << "distribution_list_editor"; 87 defaultExtensions << "distribution_list_editor";
87 addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); 88 addItemInt( "CurrentExtension", &mCurrentExtension, 0 );
88 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); 89 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions );
89 90
90 KPrefs::setCurrentGroup( "Views" ); 91 KPrefs::setCurrentGroup( "Views" );
91 QString defaultView = i18n( "Default Table View" ); 92 QString defaultView = i18n( "Default Table View" );
92 addItemString( "CurrentView", &mCurrentView, defaultView ); 93 addItemString( "CurrentView", &mCurrentView, defaultView );
93 addItemStringList( "ViewNames", &mViewNames, defaultView ); 94 addItemStringList( "ViewNames", &mViewNames, defaultView );
94 95
95 KPrefs::setCurrentGroup( "Filters" ); 96 KPrefs::setCurrentGroup( "Filters" );
96 addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); 97 addItemInt( "CurrentFilter", &mCurrentFilter, 0 );
97 98
98} 99}
99 100
100KABPrefs::~KABPrefs() 101KABPrefs::~KABPrefs()
101{ 102{
102 //qDebug("KABPrefs::~KABPrefs() "); 103 //qDebug("KABPrefs::~KABPrefs() ");
103 if (sInstance == this) 104 if (sInstance == this)
104 sInstance = staticDeleterAB.setObject(0); 105 sInstance = staticDeleterAB.setObject(0);
105} 106}
106 107
107KABPrefs *KABPrefs::instance() 108KABPrefs *KABPrefs::instance()
108{ 109{
109 if ( !sInstance ) { 110 if ( !sInstance ) {
110#ifdef KAB_EMBEDDED 111#ifdef KAB_EMBEDDED
111 sInstance = staticDeleterAB.setObject( new KABPrefs() ); 112 sInstance = staticDeleterAB.setObject( new KABPrefs() );
112#else //KAB_EMBEDDED 113#else //KAB_EMBEDDED
113 //US the following line has changed ???. Why 114 //US the following line has changed ???. Why
114 staticDeleterAB.setObject( sInstance, new KABPrefs() ); 115 staticDeleterAB.setObject( sInstance, new KABPrefs() );
115#endif //KAB_EMBEDDED 116#endif //KAB_EMBEDDED
116 sInstance->readConfig(); 117 sInstance->readConfig();
117 } 118 }
118 119
119 return sInstance; 120 return sInstance;
120} 121}
121 122
122void KABPrefs::setCategoryDefaults() 123void KABPrefs::setCategoryDefaults()
123{ 124{
124 mCustomCategories.clear(); 125 mCustomCategories.clear();
125 126
126 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) 127 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" )
127 << i18n( "Customer" ) << i18n( "Friend" ); 128 << i18n( "Customer" ) << i18n( "Friend" );
128} 129}
129 130
130 // US introduce a nonconst way to return the config object. 131 // US introduce a nonconst way to return the config object.
131KConfig* KABPrefs::getConfig() 132KConfig* KABPrefs::getConfig()
132{ 133{
133 return config(); 134 return config();
134} 135}
135void KABPrefs::usrReadConfig() 136void KABPrefs::usrReadConfig()
136{ 137{
137 KPimPrefs::usrReadConfig(); 138 KPimPrefs::usrReadConfig();
138} 139}
139 140
140 141
141/*US 142/*US
142void KABPrefs::usrSetDefaults() 143void KABPrefs::usrSetDefaults()
143{ 144{
144 KPimPrefs::usrSetDefaults(); 145 KPimPrefs::usrSetDefaults();
145} 146}
146 147
147void KABPrefs::usrReadConfig() 148void KABPrefs::usrReadConfig()
148{ 149{
149 KPimPrefs::usrReadConfig(); 150 KPimPrefs::usrReadConfig();
150} 151}
151 152
152void KABPrefs::usrWriteConfig() 153void KABPrefs::usrWriteConfig()
153{ 154{
154 KPimPrefs::usrWriteConfig(); 155 KPimPrefs::usrWriteConfig();
155} 156}
156*/ 157*/
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index 2bb173d..ddbc0c0 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -1,98 +1,99 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABPREFS_H 24#ifndef KABPREFS_H
25#define KABPREFS_H 25#define KABPREFS_H
26 26
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qdict.h> 28#include <qdict.h>
29 29
30#include <libkdepim/kpimprefs.h> 30#include <libkdepim/kpimprefs.h>
31 31
32class KConfig; 32class KConfig;
33 33
34class KABPrefs : public KPimPrefs 34class KABPrefs : public KPimPrefs
35{ 35{
36 public: 36 public:
37 virtual ~KABPrefs(); 37 virtual ~KABPrefs();
38 38
39 static KABPrefs *instance(); 39 static KABPrefs *instance();
40 40
41 // General 41 // General
42 bool mHonorSingleClick; 42 bool mHonorSingleClick;
43 bool mAutomaticNameParsing; 43 bool mAutomaticNameParsing;
44 int mCurrentIncSearchField; 44 int mCurrentIncSearchField;
45 45
46#ifdef KAB_EMBEDDED 46#ifdef KAB_EMBEDDED
47 // US introduce a nonconst way to return the config object. 47 // US introduce a nonconst way to return the config object.
48 KConfig* getConfig(); 48 KConfig* getConfig();
49 49
50 bool mToolBarHor; 50 bool mToolBarHor;
51 bool mToolBarUp; 51 bool mToolBarUp;
52 bool mAskForQuit; 52 bool mAskForQuit;
53 53
54 54
55 /** Set preferences to default values */ 55 /** Set preferences to default values */
56// void usrSetDefaults(); 56// void usrSetDefaults();
57 57
58 /** Read preferences from config file */ 58 /** Read preferences from config file */
59// void usrReadConfig(); 59// void usrReadConfig();
60 60
61 /** Write preferences to config file */ 61 /** Write preferences to config file */
62// void usrWriteConfig(); 62// void usrWriteConfig();
63#endif //KAB_EMBEDDED 63#endif //KAB_EMBEDDED
64 void usrReadConfig(); 64 void usrReadConfig();
65 65
66 66
67 // GUI 67 // GUI
68 bool mFullMenuBarVisible; 68 bool mFullMenuBarVisible;
69 bool mJumpButtonBarVisible; 69 bool mJumpButtonBarVisible;
70 bool mDetailsPageVisible; 70 bool mDetailsPageVisible;
71 bool mMultipleViewsAtOnce; 71 bool mMultipleViewsAtOnce;
72 bool mSearchWithReturn; 72 bool mSearchWithReturn;
73 bool mAutoSearchWithWildcard; 73 bool mAutoSearchWithWildcard;
74 bool mHideSearchOnSwitch; 74 bool mHideSearchOnSwitch;
75 bool mAskForDelete;
75 QValueList<int> mExtensionsSplitter; 76 QValueList<int> mExtensionsSplitter;
76 QValueList<int> mDetailsSplitter; 77 QValueList<int> mDetailsSplitter;
77 78
78 // Extensions stuff 79 // Extensions stuff
79 int mCurrentExtension; 80 int mCurrentExtension;
80 QStringList mActiveExtensions; 81 QStringList mActiveExtensions;
81 82
82 // Views stuff 83 // Views stuff
83 QString mCurrentView; 84 QString mCurrentView;
84 QStringList mViewNames; 85 QStringList mViewNames;
85 86
86 // Filter 87 // Filter
87 int mCurrentFilter; 88 int mCurrentFilter;
88 89
89 void setCategoryDefaults(); 90 void setCategoryDefaults();
90 QFont mDetailsFont; 91 QFont mDetailsFont;
91 92
92 private: 93 private:
93 KABPrefs(); 94 KABPrefs();
94 95
95 static KABPrefs *sInstance; 96 static KABPrefs *sInstance;
96}; 97};
97 98
98#endif 99#endif
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
index 1b4652a..9e4db74 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
@@ -1,418 +1,424 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qframe.h> 25#include <qframe.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30#include <qcombobox.h> 30#include <qcombobox.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qvbox.h> 34#include <qvbox.h>
35 35
36#include <kconfig.h> 36#include <kconfig.h>
37#include <kdebug.h> 37#include <kdebug.h>
38#include <kdialog.h> 38#include <kdialog.h>
39#include <klistview.h> 39#include <klistview.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kglobal.h> 41#include <kglobal.h>
42#include <kmessagebox.h> 42#include <kmessagebox.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <ktrader.h> 46#include <ktrader.h>
47#else // KAB_EMBEDDED 47#else // KAB_EMBEDDED
48#include <mergewidget.h> 48#include <mergewidget.h>
49#include <distributionlistwidget.h> 49#include <distributionlistwidget.h>
50#endif // KAB_EMBEDDED 50#endif // KAB_EMBEDDED
51 51
52#include "addresseewidget.h" 52#include "addresseewidget.h"
53#include "extensionconfigdialog.h" 53#include "extensionconfigdialog.h"
54#include "extensionwidget.h" 54#include "extensionwidget.h"
55#include "kabprefs.h" 55#include "kabprefs.h"
56 56
57#include "kabconfigwidget.h" 57#include "kabconfigwidget.h"
58#include <kglobalsettings.h> 58#include <kglobalsettings.h>
59 59
60class ExtensionItem : public QCheckListItem 60class ExtensionItem : public QCheckListItem
61{ 61{
62 public: 62 public:
63 63
64#ifndef KAB_EMBEDDED 64#ifndef KAB_EMBEDDED
65 ExtensionItem( QListView *parent, const QString &text ); 65 ExtensionItem( QListView *parent, const QString &text );
66 void setService( const KService::Ptr &ptr ); 66 void setService( const KService::Ptr &ptr );
67#else //KAB_EMBEDDED 67#else //KAB_EMBEDDED
68 ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); 68 ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment );
69 void setFactory( ExtensionFactory* fac ); 69 void setFactory( ExtensionFactory* fac );
70#endif //KAB_EMBEDDED 70#endif //KAB_EMBEDDED
71 71
72 bool configWidgetAvailable() const; 72 bool configWidgetAvailable() const;
73 ExtensionFactory *factory() const; 73 ExtensionFactory *factory() const;
74 74
75 virtual QString text( int column ) const; 75 virtual QString text( int column ) const;
76 76
77 private: 77 private:
78#ifndef KAB_EMBEDDED 78#ifndef KAB_EMBEDDED
79 KService::Ptr mPtr; 79 KService::Ptr mPtr;
80#else //KAB_EMBEDDED 80#else //KAB_EMBEDDED
81 ExtensionFactory* mFactory; 81 ExtensionFactory* mFactory;
82 QString mName; 82 QString mName;
83 QString mComment; 83 QString mComment;
84 84
85#endif //KAB_EMBEDDED 85#endif //KAB_EMBEDDED
86 86
87}; 87};
88 88
89KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name ) 89KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name )
90 : KPrefsWidget( prefs, parent, name ) 90 : KPrefsWidget( prefs, parent, name )
91{ 91{
92 92
93 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 93 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
94 KDialog::spacingHintSmall() ); 94 KDialog::spacingHintSmall() );
95 95
96 QTabWidget *tabWidget = new QTabWidget( this ); 96 QTabWidget *tabWidget = new QTabWidget( this );
97 topLayout->addWidget( tabWidget ); 97 topLayout->addWidget( tabWidget );
98 98
99 // General page 99 // General page
100 QWidget *generalPage = new QWidget( this ); 100 QWidget *generalPage = new QWidget( this );
101 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), 101 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(),
102 KDialog::spacingHintSmall() ); 102 KDialog::spacingHintSmall() );
103 103
104 104
105 QWidget *hBox = new QWidget( generalPage, "qhbox" ); 105 QWidget *hBox = new QWidget( generalPage, "qhbox" );
106 QHBoxLayout *hboxLayout = new QHBoxLayout( hBox); 106 QHBoxLayout *hboxLayout = new QHBoxLayout( hBox);
107 KPrefsWidFont *detailsFont = 107 KPrefsWidFont *detailsFont =
108 addWidFont(i18n("phone:123"),i18n("Details view font"), 108 addWidFont(i18n("phone:123"),i18n("Details view font"),
109 &(KABPrefs::instance()->mDetailsFont),hBox); 109 &(KABPrefs::instance()->mDetailsFont),hBox);
110 hboxLayout->addWidget(detailsFont->label()); 110 hboxLayout->addWidget(detailsFont->label());
111 hboxLayout->addWidget(detailsFont->preview()); 111 hboxLayout->addWidget(detailsFont->preview());
112 hboxLayout->addWidget(detailsFont->button()); 112 hboxLayout->addWidget(detailsFont->button());
113 hboxLayout->setMargin(KDialog::marginHintSmall() ); 113 hboxLayout->setMargin(KDialog::marginHintSmall() );
114 hboxLayout->setSpacing(KDialog::spacingHintSmall()); 114 hboxLayout->setSpacing(KDialog::spacingHintSmall());
115 //hBox->setBackgroundColor( black); 115 //hBox->setBackgroundColor( black);
116 layout->addWidget( hBox ); 116 layout->addWidget( hBox );
117 117
118 //general groupbox 118 //general groupbox
119 QWidget *vBox = new QWidget( generalPage, "qvbox" ); 119 QWidget *vBox = new QWidget( generalPage, "qvbox" );
120 QVBoxLayout *boxLayout = new QVBoxLayout( vBox ); 120 QVBoxLayout *boxLayout = new QVBoxLayout( vBox );
121 boxLayout->setAlignment( Qt::AlignTop ); 121 boxLayout->setAlignment( Qt::AlignTop );
122 boxLayout->setMargin(KDialog::marginHintSmall() ); 122 boxLayout->setMargin(KDialog::marginHintSmall() );
123 boxLayout->setSpacing( KDialog::spacingHintSmall() ); 123 boxLayout->setSpacing( KDialog::spacingHintSmall() );
124 mMenuBarBox = new QCheckBox( i18n( "Full Menu bar (restart)" ), vBox, "mremenuturn" ); 124 mMenuBarBox = new QCheckBox( i18n( "Full Menu bar (restart)" ), vBox, "mremenuturn" );
125 boxLayout->addWidget( mMenuBarBox ); 125 boxLayout->addWidget( mMenuBarBox );
126 mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" ); 126 mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" );
127 boxLayout->addWidget( mSearchReturnBox ); 127 boxLayout->addWidget( mSearchReturnBox );
128 mAutoSearchWithWildcardBox = new QCheckBox( i18n( "Search with '*' prefix (wildcard)" ), vBox, "mwildcard" ); 128 mAutoSearchWithWildcardBox = new QCheckBox( i18n( "Search with '*' prefix (wildcard)" ), vBox, "mwildcard" );
129 boxLayout->addWidget( mAutoSearchWithWildcardBox); 129 boxLayout->addWidget( mAutoSearchWithWildcardBox);
130 mHideSearchOnSwitchBox = new QCheckBox( i18n( "Shrink searchfield in portrait view" ), vBox, "mswitch" ); 130 mHideSearchOnSwitchBox = new QCheckBox( i18n( "Shrink searchfield in portrait view" ), vBox, "mswitch" );
131 boxLayout->addWidget( mHideSearchOnSwitchBox ); 131 boxLayout->addWidget( mHideSearchOnSwitchBox );
132 132
133#ifdef DESKTOP_VERSION 133#ifdef DESKTOP_VERSION
134 mHideSearchOnSwitchBox->hide(); 134 mHideSearchOnSwitchBox->hide();
135#endif 135#endif
136 mViewsSingleClickBox = new QCheckBox( i18n( "Show edit dialog on single click" ), vBox, "msingle" ); 136 mViewsSingleClickBox = new QCheckBox( i18n( "Show edit dialog on single click" ), vBox, "msingle" );
137 boxLayout->addWidget( mViewsSingleClickBox ); 137 boxLayout->addWidget( mViewsSingleClickBox );
138 138
139 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new contacts" ), vBox, "mparse" ); 139 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new contacts" ), vBox, "mparse" );
140 boxLayout->addWidget( mNameParsing ); 140 boxLayout->addWidget( mNameParsing );
141 141
142 mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); 142 mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" );
143 boxLayout->addWidget( mMultipleViewsAtOnce ); 143 boxLayout->addWidget( mMultipleViewsAtOnce );
144 144
145 mAskForDelete = new QCheckBox( i18n( "Ask before delete contact" ), vBox, "mdel" );
146 boxLayout->addWidget( mAskForDelete );
147
145 mAskForQuit = new QCheckBox( i18n( "Show exit confirmation" ), vBox, "mquit" ); 148 mAskForQuit = new QCheckBox( i18n( "Show exit confirmation" ), vBox, "mquit" );
146 boxLayout->addWidget( mAskForQuit ); 149 boxLayout->addWidget( mAskForQuit );
147 150
148 layout->addWidget( vBox ); 151 layout->addWidget( vBox );
149 152
150 tabWidget->addTab( generalPage, i18n( "General" ) ); 153 tabWidget->addTab( generalPage, i18n( "General" ) );
151 154
152 // Extension page 155 // Extension page
153 QWidget *extensionPage = new QWidget( this ); 156 QWidget *extensionPage = new QWidget( this );
154 QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), 157 QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(),
155 KDialog::spacingHintSmall() ); 158 KDialog::spacingHintSmall() );
156 159
157 //extensions groupbox 160 //extensions groupbox
158 161
159 QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); 162 QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage );
160 boxLayout = new QVBoxLayout( groupBox->layout() ); 163 boxLayout = new QVBoxLayout( groupBox->layout() );
161 boxLayout->setAlignment( Qt::AlignTop ); 164 boxLayout->setAlignment( Qt::AlignTop );
162 boxLayout->setMargin(KDialog::marginHintSmall()); 165 boxLayout->setMargin(KDialog::marginHintSmall());
163 boxLayout->setSpacing(KDialog::spacingHintSmall()); 166 boxLayout->setSpacing(KDialog::spacingHintSmall());
164 groupBox->layout()->setMargin(1) ; 167 groupBox->layout()->setMargin(1) ;
165 groupBox->layout()->setSpacing(0); 168 groupBox->layout()->setSpacing(0);
166 mExtensionView = new KListView( groupBox ); 169 mExtensionView = new KListView( groupBox );
167 mExtensionView->setAllColumnsShowFocus( true ); 170 mExtensionView->setAllColumnsShowFocus( true );
168 mExtensionView->addColumn( i18n( "Name" ) ); 171 mExtensionView->addColumn( i18n( "Name" ) );
169 mExtensionView->addColumn( i18n( "Description" ) ); 172 mExtensionView->addColumn( i18n( "Description" ) );
170 //mExtensionView->setMaximumHeight(80); 173 //mExtensionView->setMaximumHeight(80);
171 174
172 boxLayout->addWidget( mExtensionView ); 175 boxLayout->addWidget( mExtensionView );
173 176
174 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); 177 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox );
175 mConfigureButton->setEnabled( false ); 178 mConfigureButton->setEnabled( false );
176 boxLayout->addWidget( mConfigureButton ); 179 boxLayout->addWidget( mConfigureButton );
177 180
178 extensionLayout->addWidget( groupBox ); 181 extensionLayout->addWidget( groupBox );
179 182
180 connect( mMenuBarBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 183 connect( mMenuBarBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
181 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 184 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
182 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 185 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
183 connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 186 connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
184 connect( mAutoSearchWithWildcardBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 187 connect( mAutoSearchWithWildcardBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
185 connect( mHideSearchOnSwitchBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 188 connect( mHideSearchOnSwitchBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
186 connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 189 connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
187 connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 190 connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
191 connect( mAskForDelete, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
188 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), 192 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ),
189 SLOT( selectionChanged( QListViewItem* ) ) ); 193 SLOT( selectionChanged( QListViewItem* ) ) );
190 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), 194 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ),
191 SLOT( itemClicked( QListViewItem* ) ) ); 195 SLOT( itemClicked( QListViewItem* ) ) );
192 connect( mConfigureButton, SIGNAL( clicked() ), 196 connect( mConfigureButton, SIGNAL( clicked() ),
193 SLOT( configureExtension() ) ); 197 SLOT( configureExtension() ) );
194 198
195 tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); 199 tabWidget->addTab( extensionPage, i18n( "Extensions" ) );
196 200
197 // Addressee page 201 // Addressee page
198 mAddresseeWidget = new AddresseeWidget( this ); 202 mAddresseeWidget = new AddresseeWidget( this );
199 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); 203 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
200 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); 204 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
201 205
202} 206}
203 207
204void KABConfigWidget::usrReadConfig() 208void KABConfigWidget::usrReadConfig()
205{ 209{
206 KABPrefs* prefs = KABPrefs::instance(); 210 KABPrefs* prefs = KABPrefs::instance();
207 211
208 bool blocked = signalsBlocked(); 212 bool blocked = signalsBlocked();
209 blockSignals( true ); 213 blockSignals( true );
210 mMenuBarBox->setChecked( prefs->mFullMenuBarVisible); 214 mMenuBarBox->setChecked( prefs->mFullMenuBarVisible);
211 mNameParsing->setChecked( prefs->mAutomaticNameParsing ); 215 mNameParsing->setChecked( prefs->mAutomaticNameParsing );
212 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); 216 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick );
213 mSearchReturnBox->setChecked( prefs->mSearchWithReturn ); 217 mSearchReturnBox->setChecked( prefs->mSearchWithReturn );
214 mAutoSearchWithWildcardBox->setChecked( prefs->mAutoSearchWithWildcard ); 218 mAutoSearchWithWildcardBox->setChecked( prefs->mAutoSearchWithWildcard );
215 mHideSearchOnSwitchBox->setChecked( prefs->mHideSearchOnSwitch ); 219 mHideSearchOnSwitchBox->setChecked( prefs->mHideSearchOnSwitch );
216 mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); 220 mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce );
217 mAskForQuit->setChecked( prefs->mAskForQuit ); 221 mAskForQuit->setChecked( prefs->mAskForQuit );
222 mAskForDelete->setChecked( prefs->mAskForDelete );
218 223
219 mAddresseeWidget->restoreSettings(); 224 mAddresseeWidget->restoreSettings();
220 225
221 restoreExtensionSettings(); 226 restoreExtensionSettings();
222 227
223 blockSignals( blocked ); 228 blockSignals( blocked );
224 229
225} 230}
226 231
227void KABConfigWidget::usrWriteConfig() 232void KABConfigWidget::usrWriteConfig()
228{ 233{
229 KABPrefs* prefs = KABPrefs::instance(); 234 KABPrefs* prefs = KABPrefs::instance();
230 prefs->mFullMenuBarVisible = mMenuBarBox->isChecked(); 235 prefs->mFullMenuBarVisible = mMenuBarBox->isChecked();
231 prefs->mAutomaticNameParsing = mNameParsing->isChecked(); 236 prefs->mAutomaticNameParsing = mNameParsing->isChecked();
232 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); 237 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked();
233 prefs->mSearchWithReturn = mSearchReturnBox->isChecked(); 238 prefs->mSearchWithReturn = mSearchReturnBox->isChecked();
234 prefs->mAutoSearchWithWildcard = mAutoSearchWithWildcardBox->isChecked(); 239 prefs->mAutoSearchWithWildcard = mAutoSearchWithWildcardBox->isChecked();
235 prefs->mHideSearchOnSwitch = mHideSearchOnSwitchBox->isChecked(); 240 prefs->mHideSearchOnSwitch = mHideSearchOnSwitchBox->isChecked();
236 241
237 prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); 242 prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked();
238 prefs->mAskForQuit = mAskForQuit->isChecked(); 243 prefs->mAskForQuit = mAskForQuit->isChecked();
244 prefs->mAskForDelete = mAskForDelete->isChecked();
239 245
240 mAddresseeWidget->saveSettings(); 246 mAddresseeWidget->saveSettings();
241 247
242 saveExtensionSettings(); 248 saveExtensionSettings();
243 249
244} 250}
245 251
246void KABConfigWidget::restoreExtensionSettings() 252void KABConfigWidget::restoreExtensionSettings()
247{ 253{
248 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; 254 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions;
249 255
250 mExtensionView->clear(); 256 mExtensionView->clear();
251 257
252#ifndef KAB_EMBEDDED 258#ifndef KAB_EMBEDDED
253 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); 259 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" );
254 KTrader::OfferList::ConstIterator it; 260 KTrader::OfferList::ConstIterator it;
255 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 261 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
256 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) 262 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) )
257 continue; 263 continue;
258 264
259 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); 265 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() );
260 item->setService( *it ); 266 item->setService( *it );
261 if ( activeExtensions.contains( item->factory()->identifier() ) ) 267 if ( activeExtensions.contains( item->factory()->identifier() ) )
262 item->setOn( true ); 268 item->setOn( true );
263 } 269 }
264#else //KAB_EMBEDDED 270#else //KAB_EMBEDDED
265 ExtensionFactory *extensionFactory = new MergeFactory(); 271 ExtensionFactory *extensionFactory = new MergeFactory();
266 272
267 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); 273 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts");
268 274
269 item->setFactory( extensionFactory ); 275 item->setFactory( extensionFactory );
270 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 276 if ( activeExtensions.contains( extensionFactory->identifier() ) )
271 item->setOn( true ); 277 item->setOn( true );
272 278
273 279
274 280
275 extensionFactory = new DistributionListFactory(); 281 extensionFactory = new DistributionListFactory();
276 282
277 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); 283 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists");
278 284
279 item->setFactory( extensionFactory ); 285 item->setFactory( extensionFactory );
280 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 286 if ( activeExtensions.contains( extensionFactory->identifier() ) )
281 item->setOn( true ); 287 item->setOn( true );
282 288
283 289
284#endif //KAB_EMBEDDED 290#endif //KAB_EMBEDDED
285 291
286} 292}
287 293
288void KABConfigWidget::saveExtensionSettings() 294void KABConfigWidget::saveExtensionSettings()
289{ 295{
290 QStringList activeExtensions; 296 QStringList activeExtensions;
291 297
292 QPtrList<QListViewItem> list; 298 QPtrList<QListViewItem> list;
293 QListViewItemIterator it( mExtensionView ); 299 QListViewItemIterator it( mExtensionView );
294 while ( it.current() ) { 300 while ( it.current() ) {
295 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); 301 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() );
296 if ( item ) { 302 if ( item ) {
297 if ( item->isOn() ) 303 if ( item->isOn() )
298 activeExtensions.append( item->factory()->identifier() ); 304 activeExtensions.append( item->factory()->identifier() );
299 } 305 }
300 ++it; 306 ++it;
301 } 307 }
302 308
303 KABPrefs::instance()->mActiveExtensions = activeExtensions; 309 KABPrefs::instance()->mActiveExtensions = activeExtensions;
304} 310}
305 311
306void KABConfigWidget::configureExtension() 312void KABConfigWidget::configureExtension()
307{ 313{
308 ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); 314 ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() );
309 if ( !item ) 315 if ( !item )
310 return; 316 return;
311 317
312#ifndef KAB_EMBEDDED 318#ifndef KAB_EMBEDDED
313 KConfig config( "kaddressbookrc" ); 319 KConfig config( "kaddressbookrc" );
314#else //KAB_EMBEDDED 320#else //KAB_EMBEDDED
315 KConfig config( locateLocal("config", "kaddressbookrc") ); 321 KConfig config( locateLocal("config", "kaddressbookrc") );
316#endif //KAB_EMBEDDED 322#endif //KAB_EMBEDDED
317 config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); 323 config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) );
318 324
319 ExtensionConfigDialog dlg( item->factory(), &config, this ); 325 ExtensionConfigDialog dlg( item->factory(), &config, this );
320 dlg.exec(); 326 dlg.exec();
321 327
322 config.sync(); 328 config.sync();
323} 329}
324 330
325void KABConfigWidget::selectionChanged( QListViewItem *i ) 331void KABConfigWidget::selectionChanged( QListViewItem *i )
326{ 332{
327 ExtensionItem *item = static_cast<ExtensionItem*>( i ); 333 ExtensionItem *item = static_cast<ExtensionItem*>( i );
328 if ( !item ) 334 if ( !item )
329 return; 335 return;
330 336
331 mConfigureButton->setEnabled( item->configWidgetAvailable() ); 337 mConfigureButton->setEnabled( item->configWidgetAvailable() );
332} 338}
333 339
334void KABConfigWidget::itemClicked( QListViewItem *item ) 340void KABConfigWidget::itemClicked( QListViewItem *item )
335{ 341{
336 if ( item != 0 ) 342 if ( item != 0 )
337 modified(); 343 modified();
338} 344}
339 345
340#ifndef KAB_EMBEDDED 346#ifndef KAB_EMBEDDED
341ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) 347ExtensionItem::ExtensionItem( QListView *parent, const QString &text )
342 : QCheckListItem( parent, text, CheckBox ) 348 : QCheckListItem( parent, text, CheckBox )
343{ 349{
344} 350}
345 351
346void ExtensionItem::setService( const KService::Ptr &ptr ) 352void ExtensionItem::setService( const KService::Ptr &ptr )
347{ 353{
348 mPtr = ptr; 354 mPtr = ptr;
349} 355}
350#else //KAB_EMBEDDED 356#else //KAB_EMBEDDED
351ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) 357ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment )
352 : QCheckListItem( parent, text, CheckBox ) 358 : QCheckListItem( parent, text, CheckBox )
353{ 359{
354 mName = name; 360 mName = name;
355 mComment = comment; 361 mComment = comment;
356} 362}
357 363
358 364
359void ExtensionItem::setFactory( ExtensionFactory* fac ) 365void ExtensionItem::setFactory( ExtensionFactory* fac )
360{ 366{
361 mFactory = fac; 367 mFactory = fac;
362} 368}
363#endif //KAB_EMBEDDED 369#endif //KAB_EMBEDDED
364 370
365bool ExtensionItem::configWidgetAvailable() const 371bool ExtensionItem::configWidgetAvailable() const
366{ 372{
367#ifndef KAB_EMBEDDED 373#ifndef KAB_EMBEDDED
368 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); 374 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() );
369 if ( !factory ) 375 if ( !factory )
370 return false; 376 return false;
371 377
372 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); 378 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory );
373 if ( !extensionFactory ) 379 if ( !extensionFactory )
374 return false; 380 return false;
375 381
376 return extensionFactory->configureWidgetAvailable(); 382 return extensionFactory->configureWidgetAvailable();
377#else //KAB_EMBEDDED 383#else //KAB_EMBEDDED
378 return mFactory->configureWidgetAvailable(); 384 return mFactory->configureWidgetAvailable();
379#endif //KAB_EMBEDDED 385#endif //KAB_EMBEDDED
380 386
381} 387}
382 388
383ExtensionFactory *ExtensionItem::factory() const 389ExtensionFactory *ExtensionItem::factory() const
384{ 390{
385#ifndef KAB_EMBEDDED 391#ifndef KAB_EMBEDDED
386 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); 392 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() );
387 if ( !factory ) 393 if ( !factory )
388 return 0; 394 return 0;
389 395
390 return static_cast<ExtensionFactory*>( factory ); 396 return static_cast<ExtensionFactory*>( factory );
391#else //KAB_EMBEDDED 397#else //KAB_EMBEDDED
392 return mFactory; 398 return mFactory;
393#endif //KAB_EMBEDDED 399#endif //KAB_EMBEDDED
394} 400}
395 401
396QString ExtensionItem::text( int column ) const 402QString ExtensionItem::text( int column ) const
397{ 403{
398#ifndef KAB_EMBEDDED 404#ifndef KAB_EMBEDDED
399 if ( column == 0 ) 405 if ( column == 0 )
400 return mPtr->name(); 406 return mPtr->name();
401 else if ( column == 1 ) 407 else if ( column == 1 )
402 return mPtr->comment(); 408 return mPtr->comment();
403 else 409 else
404 return QString::null; 410 return QString::null;
405#else //KAB_EMBEDDED 411#else //KAB_EMBEDDED
406 if ( column == 0 ) 412 if ( column == 0 )
407 return mName; 413 return mName;
408 else if ( column == 1 ) 414 else if ( column == 1 )
409 return mComment; 415 return mComment;
410 else 416 else
411 return QString::null; 417 return QString::null;
412#endif //KAB_EMBEDDED 418#endif //KAB_EMBEDDED
413} 419}
414 420
415#ifndef KAB_EMBEDDED 421#ifndef KAB_EMBEDDED
416#include "kabconfigwidget.moc" 422#include "kabconfigwidget.moc"
417#endif //KAB_EMBEDDED 423#endif //KAB_EMBEDDED
418 424
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h
index a172e97..f2a6b1b 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.h
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.h
@@ -1,77 +1,78 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCONFIGWIDGET_H 24#ifndef KABCONFIGWIDGET_H
25#define KABCONFIGWIDGET_H 25#define KABCONFIGWIDGET_H
26 26
27#include <kprefswidget.h> 27#include <kprefswidget.h>
28 28
29class QCheckBox; 29class QCheckBox;
30class QListViewItem; 30class QListViewItem;
31class QPushButton; 31class QPushButton;
32class QComboBox; 32class QComboBox;
33class QLineEdit; 33class QLineEdit;
34class KListView; 34class KListView;
35class KABPrefs; 35class KABPrefs;
36 36
37class AddresseeWidget; 37class AddresseeWidget;
38 38
39class KABConfigWidget : public KPrefsWidget 39class KABConfigWidget : public KPrefsWidget
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 42
43 public: 43 public:
44 KABConfigWidget(KABPrefs *prefs, QWidget *parent, const char *name = 0 ); 44 KABConfigWidget(KABPrefs *prefs, QWidget *parent, const char *name = 0 );
45 45
46 protected: 46 protected:
47 /** Implement this to read custom configuration widgets. */ 47 /** Implement this to read custom configuration widgets. */
48 virtual void usrReadConfig(); 48 virtual void usrReadConfig();
49 /** Implement this to write custom configuration widgets. */ 49 /** Implement this to write custom configuration widgets. */
50 virtual void usrWriteConfig(); 50 virtual void usrWriteConfig();
51 51
52 52
53 53
54 private slots: 54 private slots:
55 void configureExtension(); 55 void configureExtension();
56 void selectionChanged( QListViewItem* ); 56 void selectionChanged( QListViewItem* );
57 void itemClicked( QListViewItem* ); 57 void itemClicked( QListViewItem* );
58 58
59 private: 59 private:
60 void restoreExtensionSettings(); 60 void restoreExtensionSettings();
61 void saveExtensionSettings(); 61 void saveExtensionSettings();
62 62
63 KListView *mExtensionView; 63 KListView *mExtensionView;
64 QCheckBox *mSearchReturnBox; 64 QCheckBox *mSearchReturnBox;
65 QCheckBox *mNameParsing; 65 QCheckBox *mNameParsing;
66 QCheckBox *mViewsSingleClickBox; 66 QCheckBox *mViewsSingleClickBox;
67 QCheckBox *mAutoSearchWithWildcardBox; 67 QCheckBox *mAutoSearchWithWildcardBox;
68 QCheckBox *mHideSearchOnSwitchBox; 68 QCheckBox *mHideSearchOnSwitchBox;
69 QCheckBox *mMultipleViewsAtOnce; 69 QCheckBox *mMultipleViewsAtOnce;
70 QCheckBox *mAskForQuit; 70 QCheckBox *mAskForQuit;
71 QCheckBox *mMenuBarBox; 71 QCheckBox *mMenuBarBox;
72 QCheckBox *mAskForDelete;
72 QPushButton *mConfigureButton; 73 QPushButton *mConfigureButton;
73 74
74 AddresseeWidget *mAddresseeWidget; 75 AddresseeWidget *mAddresseeWidget;
75}; 76};
76 77
77#endif 78#endif