-rw-r--r-- | kaddressbook/kabcore.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index b06e1bc..7cba9aa 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -286,769 +286,769 @@ void KABCore::saveSettings() | |||
286 | mExtensionManager->saveSettings(); | 286 | mExtensionManager->saveSettings(); |
287 | mViewManager->saveSettings(); | 287 | mViewManager->saveSettings(); |
288 | 288 | ||
289 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 289 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
290 | 290 | ||
291 | } | 291 | } |
292 | 292 | ||
293 | KABC::AddressBook *KABCore::addressBook() const | 293 | KABC::AddressBook *KABCore::addressBook() const |
294 | { | 294 | { |
295 | return mAddressBook; | 295 | return mAddressBook; |
296 | } | 296 | } |
297 | 297 | ||
298 | KConfig *KABCore::config() | 298 | KConfig *KABCore::config() |
299 | { | 299 | { |
300 | #ifndef KAB_EMBEDDED | 300 | #ifndef KAB_EMBEDDED |
301 | return KABPrefs::instance()->config(); | 301 | return KABPrefs::instance()->config(); |
302 | #else //KAB_EMBEDDED | 302 | #else //KAB_EMBEDDED |
303 | return KABPrefs::instance()->getConfig(); | 303 | return KABPrefs::instance()->getConfig(); |
304 | #endif //KAB_EMBEDDED | 304 | #endif //KAB_EMBEDDED |
305 | } | 305 | } |
306 | 306 | ||
307 | KActionCollection *KABCore::actionCollection() const | 307 | KActionCollection *KABCore::actionCollection() const |
308 | { | 308 | { |
309 | return mGUIClient->actionCollection(); | 309 | return mGUIClient->actionCollection(); |
310 | } | 310 | } |
311 | 311 | ||
312 | KABC::Field *KABCore::currentSearchField() const | 312 | KABC::Field *KABCore::currentSearchField() const |
313 | { | 313 | { |
314 | if (mIncSearchWidget) | 314 | if (mIncSearchWidget) |
315 | return mIncSearchWidget->currentField(); | 315 | return mIncSearchWidget->currentField(); |
316 | else | 316 | else |
317 | return 0; | 317 | return 0; |
318 | } | 318 | } |
319 | 319 | ||
320 | QStringList KABCore::selectedUIDs() const | 320 | QStringList KABCore::selectedUIDs() const |
321 | { | 321 | { |
322 | return mViewManager->selectedUids(); | 322 | return mViewManager->selectedUids(); |
323 | } | 323 | } |
324 | 324 | ||
325 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 325 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
326 | { | 326 | { |
327 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 327 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
328 | 328 | ||
329 | QPtrList<KRES::Resource> kresResources; | 329 | QPtrList<KRES::Resource> kresResources; |
330 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 330 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
331 | KABC::Resource *resource; | 331 | KABC::Resource *resource; |
332 | while ( ( resource = resIt.current() ) != 0 ) { | 332 | while ( ( resource = resIt.current() ) != 0 ) { |
333 | ++resIt; | 333 | ++resIt; |
334 | if ( !resource->readOnly() ) { | 334 | if ( !resource->readOnly() ) { |
335 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 335 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
336 | if ( res ) | 336 | if ( res ) |
337 | kresResources.append( res ); | 337 | kresResources.append( res ); |
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 341 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
342 | return static_cast<KABC::Resource*>( res ); | 342 | return static_cast<KABC::Resource*>( res ); |
343 | } | 343 | } |
344 | 344 | ||
345 | #ifndef KAB_EMBEDDED | 345 | #ifndef KAB_EMBEDDED |
346 | KAboutData *KABCore::createAboutData() | 346 | KAboutData *KABCore::createAboutData() |
347 | #else //KAB_EMBEDDED | 347 | #else //KAB_EMBEDDED |
348 | void KABCore::createAboutData() | 348 | void KABCore::createAboutData() |
349 | #endif //KAB_EMBEDDED | 349 | #endif //KAB_EMBEDDED |
350 | { | 350 | { |
351 | #ifndef KAB_EMBEDDED | 351 | #ifndef KAB_EMBEDDED |
352 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 352 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
353 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 353 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
354 | KAboutData::License_GPL_V2, | 354 | KAboutData::License_GPL_V2, |
355 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 355 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
356 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 356 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
357 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 357 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
358 | about->addAuthor( "Cornelius Schumacher", | 358 | about->addAuthor( "Cornelius Schumacher", |
359 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 359 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
360 | "schumacher@kde.org" ); | 360 | "schumacher@kde.org" ); |
361 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 361 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
362 | "mpilone@slac.com" ); | 362 | "mpilone@slac.com" ); |
363 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 363 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
364 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 364 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
365 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 365 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
366 | "michel@klaralvdalens-datakonsult.se" ); | 366 | "michel@klaralvdalens-datakonsult.se" ); |
367 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 367 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
368 | "hansen@kde.org" ); | 368 | "hansen@kde.org" ); |
369 | 369 | ||
370 | return about; | 370 | return about; |
371 | #endif //KAB_EMBEDDED | 371 | #endif //KAB_EMBEDDED |
372 | 372 | ||
373 | QString version; | 373 | QString version; |
374 | #include <../version> | 374 | #include <../version> |
375 | QMessageBox::about( this, "About KAddressbook/Pi", | 375 | QMessageBox::about( this, "About KAddressbook/Pi", |
376 | "KAddressbook/Platform-independent\n" | 376 | "KAddressbook/Platform-independent\n" |
377 | "(KA/Pi) " +version + " - " + | 377 | "(KA/Pi) " +version + " - " + |
378 | #ifdef DESKTOP_VERSION | 378 | #ifdef DESKTOP_VERSION |
379 | "Desktop Edition\n" | 379 | "Desktop Edition\n" |
380 | #else | 380 | #else |
381 | "PDA-Edition\n" | 381 | "PDA-Edition\n" |
382 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 382 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
383 | #endif | 383 | #endif |
384 | 384 | ||
385 | "(c) 2004 Ulf Schenk\n" | 385 | "(c) 2004 Ulf Schenk\n" |
386 | "(c) 1997-2003, The KDE PIM Team\n" | 386 | "(c) 1997-2003, The KDE PIM Team\n" |
387 | "Tobias Koenig Current maintainer tokoe@kde.org\n" | 387 | "Tobias Koenig Current maintainer tokoe@kde.org\n" |
388 | "Don Sanders Original author\n" | 388 | "Don Sanders Original author\n" |
389 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" | 389 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" |
390 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" | 390 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" |
391 | "Greg Stern DCOP interface\n" | 391 | "Greg Stern DCOP interface\n" |
392 | "Mark Westcot Contact pinning\n" | 392 | "Mark Westcot Contact pinning\n" |
393 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 393 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
394 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" ); | 394 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" ); |
395 | } | 395 | } |
396 | 396 | ||
397 | void KABCore::setContactSelected( const QString &uid ) | 397 | void KABCore::setContactSelected( const QString &uid ) |
398 | { | 398 | { |
399 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 399 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
400 | if ( !mDetails->isHidden() ) | 400 | if ( !mDetails->isHidden() ) |
401 | mDetails->setAddressee( addr ); | 401 | mDetails->setAddressee( addr ); |
402 | 402 | ||
403 | if ( !addr.isEmpty() ) { | 403 | if ( !addr.isEmpty() ) { |
404 | emit contactSelected( addr.formattedName() ); | 404 | emit contactSelected( addr.formattedName() ); |
405 | KABC::Picture pic = addr.photo(); | 405 | KABC::Picture pic = addr.photo(); |
406 | if ( pic.isIntern() ) { | 406 | if ( pic.isIntern() ) { |
407 | //US emit contactSelected( pic.data() ); | 407 | //US emit contactSelected( pic.data() ); |
408 | //US instead use: | 408 | //US instead use: |
409 | QPixmap px; | 409 | QPixmap px; |
410 | if (pic.data().isNull() != true) | 410 | if (pic.data().isNull() != true) |
411 | { | 411 | { |
412 | px.convertFromImage(pic.data()); | 412 | px.convertFromImage(pic.data()); |
413 | } | 413 | } |
414 | 414 | ||
415 | emit contactSelected( px ); | 415 | emit contactSelected( px ); |
416 | } | 416 | } |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | mExtensionManager->setSelectionChanged(); | 420 | mExtensionManager->setSelectionChanged(); |
421 | 421 | ||
422 | // update the actions | 422 | // update the actions |
423 | bool selected = !uid.isEmpty(); | 423 | bool selected = !uid.isEmpty(); |
424 | 424 | ||
425 | if ( mReadWrite ) { | 425 | if ( mReadWrite ) { |
426 | mActionCut->setEnabled( selected ); | 426 | mActionCut->setEnabled( selected ); |
427 | mActionPaste->setEnabled( selected ); | 427 | mActionPaste->setEnabled( selected ); |
428 | } | 428 | } |
429 | 429 | ||
430 | mActionCopy->setEnabled( selected ); | 430 | mActionCopy->setEnabled( selected ); |
431 | mActionDelete->setEnabled( selected ); | 431 | mActionDelete->setEnabled( selected ); |
432 | mActionEditAddressee->setEnabled( selected ); | 432 | mActionEditAddressee->setEnabled( selected ); |
433 | mActionMail->setEnabled( selected ); | 433 | mActionMail->setEnabled( selected ); |
434 | mActionMailVCard->setEnabled( selected ); | 434 | mActionMailVCard->setEnabled( selected ); |
435 | mActionWhoAmI->setEnabled( selected ); | 435 | mActionWhoAmI->setEnabled( selected ); |
436 | mActionCategories->setEnabled( selected ); | 436 | mActionCategories->setEnabled( selected ); |
437 | } | 437 | } |
438 | 438 | ||
439 | void KABCore::sendMail() | 439 | void KABCore::sendMail() |
440 | { | 440 | { |
441 | #ifndef KAB_EMBEDDED | 441 | #ifndef KAB_EMBEDDED |
442 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 442 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
443 | #else //KAB_EMBEDDED | 443 | #else //KAB_EMBEDDED |
444 | qDebug("KABCore::sendMail() ust be fixed"); | 444 | qDebug("KABCore::sendMail() ust be fixed"); |
445 | #endif //KAB_EMBEDDED | 445 | #endif //KAB_EMBEDDED |
446 | } | 446 | } |
447 | 447 | ||
448 | void KABCore::sendMail( const QString& email ) | 448 | void KABCore::sendMail( const QString& email ) |
449 | { | 449 | { |
450 | #ifndef KAB_EMBEDDED | 450 | #ifndef KAB_EMBEDDED |
451 | kapp->invokeMailer( email, "" ); | 451 | kapp->invokeMailer( email, "" ); |
452 | #else //KAB_EMBEDDED | 452 | #else //KAB_EMBEDDED |
453 | qDebug("KABCore::sendMail(const QString& email) ust be fixed"); | 453 | qDebug("KABCore::sendMail(const QString& email) ust be fixed"); |
454 | #endif //KAB_EMBEDDED | 454 | #endif //KAB_EMBEDDED |
455 | } | 455 | } |
456 | 456 | ||
457 | void KABCore::mailVCard() | 457 | void KABCore::mailVCard() |
458 | { | 458 | { |
459 | #ifndef KAB_EMBEDDED | 459 | #ifndef KAB_EMBEDDED |
460 | QStringList uids = mViewManager->selectedUids(); | 460 | QStringList uids = mViewManager->selectedUids(); |
461 | if ( !uids.isEmpty() ) | 461 | if ( !uids.isEmpty() ) |
462 | mailVCard( uids ); | 462 | mailVCard( uids ); |
463 | #else //KAB_EMBEDDED | 463 | #else //KAB_EMBEDDED |
464 | qDebug("KABCore::mailVCard() must be fixed"); | 464 | qDebug("KABCore::mailVCard() must be fixed"); |
465 | #endif //KAB_EMBEDDED | 465 | #endif //KAB_EMBEDDED |
466 | } | 466 | } |
467 | 467 | ||
468 | void KABCore::mailVCard( const QStringList& uids ) | 468 | void KABCore::mailVCard( const QStringList& uids ) |
469 | { | 469 | { |
470 | #ifndef KAB_EMBEDDED | 470 | #ifndef KAB_EMBEDDED |
471 | QStringList urls; | 471 | QStringList urls; |
472 | 472 | ||
473 | // Create a temp dir, so that we can put the files in it with proper names | 473 | // Create a temp dir, so that we can put the files in it with proper names |
474 | KTempFile tempDir; | 474 | KTempFile tempDir; |
475 | if ( tempDir.status() != 0 ) { | 475 | if ( tempDir.status() != 0 ) { |
476 | kdWarning() << strerror( tempDir.status() ) << endl; | 476 | kdWarning() << strerror( tempDir.status() ) << endl; |
477 | return; | 477 | return; |
478 | } | 478 | } |
479 | 479 | ||
480 | QString dirName = tempDir.name(); | 480 | QString dirName = tempDir.name(); |
481 | tempDir.unlink(); | 481 | tempDir.unlink(); |
482 | QDir().mkdir( dirName, true ); | 482 | QDir().mkdir( dirName, true ); |
483 | 483 | ||
484 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 484 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
485 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 485 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
486 | 486 | ||
487 | if ( a.isEmpty() ) | 487 | if ( a.isEmpty() ) |
488 | continue; | 488 | continue; |
489 | 489 | ||
490 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 490 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
491 | 491 | ||
492 | QString fileName = dirName + "/" + name; | 492 | QString fileName = dirName + "/" + name; |
493 | 493 | ||
494 | QFile outFile(fileName); | 494 | QFile outFile(fileName); |
495 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 495 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
496 | KABC::VCardConverter converter; | 496 | KABC::VCardConverter converter; |
497 | QString vcard; | 497 | QString vcard; |
498 | 498 | ||
499 | converter.addresseeToVCard( a, vcard ); | 499 | converter.addresseeToVCard( a, vcard ); |
500 | 500 | ||
501 | QTextStream t( &outFile ); // use a text stream | 501 | QTextStream t( &outFile ); // use a text stream |
502 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 502 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
503 | t << vcard; | 503 | t << vcard; |
504 | 504 | ||
505 | outFile.close(); | 505 | outFile.close(); |
506 | 506 | ||
507 | urls.append( fileName ); | 507 | urls.append( fileName ); |
508 | } | 508 | } |
509 | } | 509 | } |
510 | 510 | ||
511 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 511 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
512 | QString::null, // subject | 512 | QString::null, // subject |
513 | QString::null, // body | 513 | QString::null, // body |
514 | QString::null, | 514 | QString::null, |
515 | urls ); // attachments | 515 | urls ); // attachments |
516 | #else //KAB_EMBEDDED | 516 | #else //KAB_EMBEDDED |
517 | qDebug("KABCore::mailVCard( must be fixed"); | 517 | qDebug("KABCore::mailVCard( must be fixed"); |
518 | #endif //KAB_EMBEDDED | 518 | #endif //KAB_EMBEDDED |
519 | 519 | ||
520 | } | 520 | } |
521 | 521 | ||
522 | void KABCore::browse( const QString& url ) | 522 | void KABCore::browse( const QString& url ) |
523 | { | 523 | { |
524 | #ifndef KAB_EMBEDDED | 524 | #ifndef KAB_EMBEDDED |
525 | kapp->invokeBrowser( url ); | 525 | kapp->invokeBrowser( url ); |
526 | #else //KAB_EMBEDDED | 526 | #else //KAB_EMBEDDED |
527 | qDebug("KABCore::browse must be fixed"); | 527 | qDebug("KABCore::browse must be fixed"); |
528 | #endif //KAB_EMBEDDED | 528 | #endif //KAB_EMBEDDED |
529 | } | 529 | } |
530 | 530 | ||
531 | void KABCore::selectAllContacts() | 531 | void KABCore::selectAllContacts() |
532 | { | 532 | { |
533 | mViewManager->setSelected( QString::null, true ); | 533 | mViewManager->setSelected( QString::null, true ); |
534 | } | 534 | } |
535 | 535 | ||
536 | void KABCore::deleteContacts() | 536 | void KABCore::deleteContacts() |
537 | { | 537 | { |
538 | QStringList uidList = mViewManager->selectedUids(); | 538 | QStringList uidList = mViewManager->selectedUids(); |
539 | deleteContacts( uidList ); | 539 | deleteContacts( uidList ); |
540 | } | 540 | } |
541 | 541 | ||
542 | void KABCore::deleteContacts( const QStringList &uids ) | 542 | void KABCore::deleteContacts( const QStringList &uids ) |
543 | { | 543 | { |
544 | if ( uids.count() > 0 ) { | 544 | if ( uids.count() > 0 ) { |
545 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 545 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
546 | UndoStack::instance()->push( command ); | 546 | UndoStack::instance()->push( command ); |
547 | RedoStack::instance()->clear(); | 547 | RedoStack::instance()->clear(); |
548 | 548 | ||
549 | // now if we deleted anything, refresh | 549 | // now if we deleted anything, refresh |
550 | setContactSelected( QString::null ); | 550 | setContactSelected( QString::null ); |
551 | setModified( true ); | 551 | setModified( true ); |
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | void KABCore::copyContacts() | 555 | void KABCore::copyContacts() |
556 | { | 556 | { |
557 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 557 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
558 | 558 | ||
559 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 559 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
560 | 560 | ||
561 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 561 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
562 | 562 | ||
563 | QClipboard *cb = QApplication::clipboard(); | 563 | QClipboard *cb = QApplication::clipboard(); |
564 | cb->setText( clipText ); | 564 | cb->setText( clipText ); |
565 | } | 565 | } |
566 | 566 | ||
567 | void KABCore::cutContacts() | 567 | void KABCore::cutContacts() |
568 | { | 568 | { |
569 | QStringList uidList = mViewManager->selectedUids(); | 569 | QStringList uidList = mViewManager->selectedUids(); |
570 | 570 | ||
571 | //US if ( uidList.size() > 0 ) { | 571 | //US if ( uidList.size() > 0 ) { |
572 | if ( uidList.count() > 0 ) { | 572 | if ( uidList.count() > 0 ) { |
573 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 573 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
574 | UndoStack::instance()->push( command ); | 574 | UndoStack::instance()->push( command ); |
575 | RedoStack::instance()->clear(); | 575 | RedoStack::instance()->clear(); |
576 | 576 | ||
577 | setModified( true ); | 577 | setModified( true ); |
578 | } | 578 | } |
579 | } | 579 | } |
580 | 580 | ||
581 | void KABCore::pasteContacts() | 581 | void KABCore::pasteContacts() |
582 | { | 582 | { |
583 | QClipboard *cb = QApplication::clipboard(); | 583 | QClipboard *cb = QApplication::clipboard(); |
584 | 584 | ||
585 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 585 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
586 | 586 | ||
587 | pasteContacts( list ); | 587 | pasteContacts( list ); |
588 | } | 588 | } |
589 | 589 | ||
590 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 590 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
591 | { | 591 | { |
592 | KABC::Resource *resource = requestResource( this ); | 592 | KABC::Resource *resource = requestResource( this ); |
593 | KABC::Addressee::List::Iterator it; | 593 | KABC::Addressee::List::Iterator it; |
594 | for ( it = list.begin(); it != list.end(); ++it ) | 594 | for ( it = list.begin(); it != list.end(); ++it ) |
595 | (*it).setResource( resource ); | 595 | (*it).setResource( resource ); |
596 | 596 | ||
597 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 597 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
598 | UndoStack::instance()->push( command ); | 598 | UndoStack::instance()->push( command ); |
599 | RedoStack::instance()->clear(); | 599 | RedoStack::instance()->clear(); |
600 | 600 | ||
601 | setModified( true ); | 601 | setModified( true ); |
602 | } | 602 | } |
603 | 603 | ||
604 | void KABCore::setWhoAmI() | 604 | void KABCore::setWhoAmI() |
605 | { | 605 | { |
606 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 606 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
607 | 607 | ||
608 | if ( addrList.count() > 1 ) { | 608 | if ( addrList.count() > 1 ) { |
609 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 609 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | 612 | ||
613 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 613 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
614 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 614 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
615 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 615 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
616 | } | 616 | } |
617 | 617 | ||
618 | void KABCore::setCategories() | 618 | void KABCore::setCategories() |
619 | { | 619 | { |
620 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 620 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
621 | if ( !dlg.exec() ) | 621 | if ( !dlg.exec() ) |
622 | return; | 622 | return; |
623 | 623 | ||
624 | bool merge = false; | 624 | bool merge = false; |
625 | QString msg = i18n( "Merge with existing categories?" ); | 625 | QString msg = i18n( "Merge with existing categories?" ); |
626 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 626 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
627 | merge = true; | 627 | merge = true; |
628 | 628 | ||
629 | QStringList categories = dlg.selectedCategories(); | 629 | QStringList categories = dlg.selectedCategories(); |
630 | 630 | ||
631 | QStringList uids = mViewManager->selectedUids(); | 631 | QStringList uids = mViewManager->selectedUids(); |
632 | QStringList::Iterator it; | 632 | QStringList::Iterator it; |
633 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 633 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
634 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 634 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
635 | if ( !addr.isEmpty() ) { | 635 | if ( !addr.isEmpty() ) { |
636 | if ( !merge ) | 636 | if ( !merge ) |
637 | addr.setCategories( categories ); | 637 | addr.setCategories( categories ); |
638 | else { | 638 | else { |
639 | QStringList addrCategories = addr.categories(); | 639 | QStringList addrCategories = addr.categories(); |
640 | QStringList::Iterator catIt; | 640 | QStringList::Iterator catIt; |
641 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 641 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
642 | if ( !addrCategories.contains( *catIt ) ) | 642 | if ( !addrCategories.contains( *catIt ) ) |
643 | addrCategories.append( *catIt ); | 643 | addrCategories.append( *catIt ); |
644 | } | 644 | } |
645 | addr.setCategories( addrCategories ); | 645 | addr.setCategories( addrCategories ); |
646 | } | 646 | } |
647 | 647 | ||
648 | mAddressBook->insertAddressee( addr ); | 648 | mAddressBook->insertAddressee( addr ); |
649 | } | 649 | } |
650 | } | 650 | } |
651 | 651 | ||
652 | if ( uids.count() > 0 ) | 652 | if ( uids.count() > 0 ) |
653 | setModified( true ); | 653 | setModified( true ); |
654 | } | 654 | } |
655 | 655 | ||
656 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 656 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
657 | { | 657 | { |
658 | mIncSearchWidget->setFields( fields ); | 658 | mIncSearchWidget->setFields( fields ); |
659 | } | 659 | } |
660 | 660 | ||
661 | void KABCore::incrementalSearch( const QString& text ) | 661 | void KABCore::incrementalSearch( const QString& text ) |
662 | { | 662 | { |
663 | mViewManager->setSelected( QString::null, false ); | 663 | mViewManager->setSelected( QString::null, false ); |
664 | 664 | ||
665 | if ( !text.isEmpty() ) { | 665 | if ( !text.isEmpty() ) { |
666 | KABC::Field *field = mIncSearchWidget->currentField(); | 666 | KABC::Field *field = mIncSearchWidget->currentField(); |
667 | 667 | ||
668 | QString pattern = text.lower(); | 668 | QString pattern = text.lower(); |
669 | 669 | ||
670 | #if KDE_VERSION >= 319 | 670 | #if 1 //KDE_VERSION >= 319 |
671 | KABC::AddresseeList list( mAddressBook->allAddressees() ); | 671 | KABC::AddresseeList list( mAddressBook->allAddressees() ); |
672 | if ( field ) { | 672 | if ( field ) { |
673 | list.sortByField( field ); | 673 | list.sortByField( field ); |
674 | KABC::AddresseeList::Iterator it; | 674 | KABC::AddresseeList::Iterator it; |
675 | for ( it = list.begin(); it != list.end(); ++it ) { | 675 | for ( it = list.begin(); it != list.end(); ++it ) { |
676 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 676 | if ( field->value( *it ).lower().startsWith( pattern ) ) { |
677 | mViewManager->setSelected( (*it).uid(), true ); | 677 | mViewManager->setSelected( (*it).uid(), true ); |
678 | return; | 678 | return; |
679 | } | 679 | } |
680 | } | 680 | } |
681 | } else { | 681 | } else { |
682 | KABC::AddresseeList::Iterator it; | 682 | KABC::AddresseeList::Iterator it; |
683 | for ( it = list.begin(); it != list.end(); ++it ) { | 683 | for ( it = list.begin(); it != list.end(); ++it ) { |
684 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | 684 | KABC::Field::List fieldList = mIncSearchWidget->fields(); |
685 | KABC::Field::List::ConstIterator fieldIt; | 685 | KABC::Field::List::ConstIterator fieldIt; |
686 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 686 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
687 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | 687 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { |
688 | mViewManager->setSelected( (*it).uid(), true ); | 688 | mViewManager->setSelected( (*it).uid(), true ); |
689 | return; | 689 | return; |
690 | } | 690 | } |
691 | } | 691 | } |
692 | } | 692 | } |
693 | } | 693 | } |
694 | #else | 694 | #else |
695 | KABC::AddressBook::Iterator it; | 695 | KABC::AddressBook::Iterator it; |
696 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 696 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
697 | if ( field ) { | 697 | if ( field ) { |
698 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 698 | if ( field->value( *it ).lower().startsWith( pattern ) ) { |
699 | mViewManager->setSelected( (*it).uid(), true ); | 699 | mViewManager->setSelected( (*it).uid(), true ); |
700 | return; | 700 | return; |
701 | } | 701 | } |
702 | } else { | 702 | } else { |
703 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | 703 | KABC::Field::List fieldList = mIncSearchWidget->fields(); |
704 | KABC::Field::List::ConstIterator fieldIt; | 704 | KABC::Field::List::ConstIterator fieldIt; |
705 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 705 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
706 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | 706 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { |
707 | mViewManager->setSelected( (*it).uid(), true ); | 707 | mViewManager->setSelected( (*it).uid(), true ); |
708 | return; | 708 | return; |
709 | } | 709 | } |
710 | } | 710 | } |
711 | } | 711 | } |
712 | } | 712 | } |
713 | #endif | 713 | #endif |
714 | } | 714 | } |
715 | } | 715 | } |
716 | 716 | ||
717 | void KABCore::setModified() | 717 | void KABCore::setModified() |
718 | { | 718 | { |
719 | setModified( true ); | 719 | setModified( true ); |
720 | } | 720 | } |
721 | 721 | ||
722 | void KABCore::setModifiedWOrefresh() | 722 | void KABCore::setModifiedWOrefresh() |
723 | { | 723 | { |
724 | // qDebug("KABCore::setModifiedWOrefresh() "); | 724 | // qDebug("KABCore::setModifiedWOrefresh() "); |
725 | mModified = true; | 725 | mModified = true; |
726 | mActionSave->setEnabled( mModified ); | 726 | mActionSave->setEnabled( mModified ); |
727 | #ifdef DESKTOP_VERSION | 727 | #ifdef DESKTOP_VERSION |
728 | mDetails->refreshView(); | 728 | mDetails->refreshView(); |
729 | #endif | 729 | #endif |
730 | 730 | ||
731 | } | 731 | } |
732 | void KABCore::setModified( bool modified ) | 732 | void KABCore::setModified( bool modified ) |
733 | { | 733 | { |
734 | mModified = modified; | 734 | mModified = modified; |
735 | mActionSave->setEnabled( mModified ); | 735 | mActionSave->setEnabled( mModified ); |
736 | 736 | ||
737 | if ( modified ) | 737 | if ( modified ) |
738 | mJumpButtonBar->recreateButtons(); | 738 | mJumpButtonBar->recreateButtons(); |
739 | 739 | ||
740 | mViewManager->refreshView(); | 740 | mViewManager->refreshView(); |
741 | mDetails->refreshView(); | 741 | mDetails->refreshView(); |
742 | 742 | ||
743 | } | 743 | } |
744 | 744 | ||
745 | bool KABCore::modified() const | 745 | bool KABCore::modified() const |
746 | { | 746 | { |
747 | return mModified; | 747 | return mModified; |
748 | } | 748 | } |
749 | 749 | ||
750 | void KABCore::contactModified( const KABC::Addressee &addr ) | 750 | void KABCore::contactModified( const KABC::Addressee &addr ) |
751 | { | 751 | { |
752 | 752 | ||
753 | Command *command = 0; | 753 | Command *command = 0; |
754 | QString uid; | 754 | QString uid; |
755 | 755 | ||
756 | // check if it exists already | 756 | // check if it exists already |
757 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 757 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
758 | if ( origAddr.isEmpty() ) | 758 | if ( origAddr.isEmpty() ) |
759 | command = new PwNewCommand( mAddressBook, addr ); | 759 | command = new PwNewCommand( mAddressBook, addr ); |
760 | else { | 760 | else { |
761 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 761 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
762 | uid = addr.uid(); | 762 | uid = addr.uid(); |
763 | } | 763 | } |
764 | 764 | ||
765 | UndoStack::instance()->push( command ); | 765 | UndoStack::instance()->push( command ); |
766 | RedoStack::instance()->clear(); | 766 | RedoStack::instance()->clear(); |
767 | 767 | ||
768 | setModified( true ); | 768 | setModified( true ); |
769 | } | 769 | } |
770 | 770 | ||
771 | void KABCore::newContact() | 771 | void KABCore::newContact() |
772 | { | 772 | { |
773 | AddresseeEditorDialog *dialog = 0; | 773 | AddresseeEditorDialog *dialog = 0; |
774 | 774 | ||
775 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 775 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
776 | 776 | ||
777 | QPtrList<KRES::Resource> kresResources; | 777 | QPtrList<KRES::Resource> kresResources; |
778 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 778 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
779 | KABC::Resource *resource; | 779 | KABC::Resource *resource; |
780 | while ( ( resource = it.current() ) != 0 ) { | 780 | while ( ( resource = it.current() ) != 0 ) { |
781 | ++it; | 781 | ++it; |
782 | if ( !resource->readOnly() ) { | 782 | if ( !resource->readOnly() ) { |
783 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 783 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
784 | if ( res ) | 784 | if ( res ) |
785 | kresResources.append( res ); | 785 | kresResources.append( res ); |
786 | } | 786 | } |
787 | } | 787 | } |
788 | 788 | ||
789 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 789 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
790 | resource = static_cast<KABC::Resource*>( res ); | 790 | resource = static_cast<KABC::Resource*>( res ); |
791 | 791 | ||
792 | if ( resource ) { | 792 | if ( resource ) { |
793 | KABC::Addressee addr; | 793 | KABC::Addressee addr; |
794 | addr.setResource( resource ); | 794 | addr.setResource( resource ); |
795 | mEditorDialog->setAddressee( addr ); | 795 | mEditorDialog->setAddressee( addr ); |
796 | KApplication::execDialog ( mEditorDialog ); | 796 | KApplication::execDialog ( mEditorDialog ); |
797 | 797 | ||
798 | } else | 798 | } else |
799 | return; | 799 | return; |
800 | 800 | ||
801 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 801 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
802 | 802 | ||
803 | dialog->show(); | 803 | dialog->show(); |
804 | 804 | ||
805 | } | 805 | } |
806 | 806 | ||
807 | void KABCore::addEmail( QString aStr ) | 807 | void KABCore::addEmail( QString aStr ) |
808 | { | 808 | { |
809 | #ifndef KAB_EMBEDDED | 809 | #ifndef KAB_EMBEDDED |
810 | QString fullName, email; | 810 | QString fullName, email; |
811 | 811 | ||
812 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 812 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
813 | 813 | ||
814 | // Try to lookup the addressee matching the email address | 814 | // Try to lookup the addressee matching the email address |
815 | bool found = false; | 815 | bool found = false; |
816 | QStringList emailList; | 816 | QStringList emailList; |
817 | KABC::AddressBook::Iterator it; | 817 | KABC::AddressBook::Iterator it; |
818 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 818 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
819 | emailList = (*it).emails(); | 819 | emailList = (*it).emails(); |
820 | if ( emailList.contains( email ) > 0 ) { | 820 | if ( emailList.contains( email ) > 0 ) { |
821 | found = true; | 821 | found = true; |
822 | (*it).setNameFromString( fullName ); | 822 | (*it).setNameFromString( fullName ); |
823 | editContact( (*it).uid() ); | 823 | editContact( (*it).uid() ); |
824 | } | 824 | } |
825 | } | 825 | } |
826 | 826 | ||
827 | if ( !found ) { | 827 | if ( !found ) { |
828 | KABC::Addressee addr; | 828 | KABC::Addressee addr; |
829 | addr.setNameFromString( fullName ); | 829 | addr.setNameFromString( fullName ); |
830 | addr.insertEmail( email, true ); | 830 | addr.insertEmail( email, true ); |
831 | 831 | ||
832 | mAddressBook->insertAddressee( addr ); | 832 | mAddressBook->insertAddressee( addr ); |
833 | mViewManager->refreshView( addr.uid() ); | 833 | mViewManager->refreshView( addr.uid() ); |
834 | editContact( addr.uid() ); | 834 | editContact( addr.uid() ); |
835 | } | 835 | } |
836 | #else //KAB_EMBEDDED | 836 | #else //KAB_EMBEDDED |
837 | qDebug("KABCore::addEmail finsih method"); | 837 | qDebug("KABCore::addEmail finsih method"); |
838 | #endif //KAB_EMBEDDED | 838 | #endif //KAB_EMBEDDED |
839 | } | 839 | } |
840 | 840 | ||
841 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 841 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
842 | { | 842 | { |
843 | mXXPortManager->importVCard( url, showPreview ); | 843 | mXXPortManager->importVCard( url, showPreview ); |
844 | } | 844 | } |
845 | 845 | ||
846 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 846 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
847 | { | 847 | { |
848 | mXXPortManager->importVCard( vCard, showPreview ); | 848 | mXXPortManager->importVCard( vCard, showPreview ); |
849 | } | 849 | } |
850 | 850 | ||
851 | //US added a second method without defaultparameter | 851 | //US added a second method without defaultparameter |
852 | void KABCore::editContact2() { | 852 | void KABCore::editContact2() { |
853 | editContact( QString::null ); | 853 | editContact( QString::null ); |
854 | } | 854 | } |
855 | 855 | ||
856 | void KABCore::editContact( const QString &uid ) | 856 | void KABCore::editContact( const QString &uid ) |
857 | { | 857 | { |
858 | 858 | ||
859 | if ( mExtensionManager->isQuickEditVisible() ) | 859 | if ( mExtensionManager->isQuickEditVisible() ) |
860 | return; | 860 | return; |
861 | 861 | ||
862 | // First, locate the contact entry | 862 | // First, locate the contact entry |
863 | QString localUID = uid; | 863 | QString localUID = uid; |
864 | if ( localUID.isNull() ) { | 864 | if ( localUID.isNull() ) { |
865 | QStringList uidList = mViewManager->selectedUids(); | 865 | QStringList uidList = mViewManager->selectedUids(); |
866 | if ( uidList.count() > 0 ) | 866 | if ( uidList.count() > 0 ) |
867 | localUID = *( uidList.at( 0 ) ); | 867 | localUID = *( uidList.at( 0 ) ); |
868 | } | 868 | } |
869 | 869 | ||
870 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 870 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
871 | if ( !addr.isEmpty() ) { | 871 | if ( !addr.isEmpty() ) { |
872 | mEditorDialog->setAddressee( addr ); | 872 | mEditorDialog->setAddressee( addr ); |
873 | KApplication::execDialog ( mEditorDialog ); | 873 | KApplication::execDialog ( mEditorDialog ); |
874 | } | 874 | } |
875 | } | 875 | } |
876 | 876 | ||
877 | void KABCore::save() | 877 | void KABCore::save() |
878 | { | 878 | { |
879 | if ( !mModified ) | 879 | if ( !mModified ) |
880 | return; | 880 | return; |
881 | QString text = i18n( "There was an error while attempting to save\n the " | 881 | QString text = i18n( "There was an error while attempting to save\n the " |
882 | "address book. Please check that some \nother application is " | 882 | "address book. Please check that some \nother application is " |
883 | "not using it. " ); | 883 | "not using it. " ); |
884 | statusMessage(i18n("Saving addressbook ... ")); | 884 | statusMessage(i18n("Saving addressbook ... ")); |
885 | #ifndef KAB_EMBEDDED | 885 | #ifndef KAB_EMBEDDED |
886 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 886 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
887 | if ( !b || !b->save() ) { | 887 | if ( !b || !b->save() ) { |
888 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 888 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
889 | } | 889 | } |
890 | #else //KAB_EMBEDDED | 890 | #else //KAB_EMBEDDED |
891 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 891 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
892 | if ( !b || !b->save() ) { | 892 | if ( !b || !b->save() ) { |
893 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 893 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
894 | } | 894 | } |
895 | #endif //KAB_EMBEDDED | 895 | #endif //KAB_EMBEDDED |
896 | 896 | ||
897 | statusMessage(i18n("Addressbook saved!")); | 897 | statusMessage(i18n("Addressbook saved!")); |
898 | setModified( false ); | 898 | setModified( false ); |
899 | } | 899 | } |
900 | 900 | ||
901 | void KABCore::statusMessage(QString mess , int time ) | 901 | void KABCore::statusMessage(QString mess , int time ) |
902 | { | 902 | { |
903 | //topLevelWidget()->setCaption( mess ); | 903 | //topLevelWidget()->setCaption( mess ); |
904 | // pending setting timer to revome message | 904 | // pending setting timer to revome message |
905 | } | 905 | } |
906 | void KABCore::undo() | 906 | void KABCore::undo() |
907 | { | 907 | { |
908 | UndoStack::instance()->undo(); | 908 | UndoStack::instance()->undo(); |
909 | 909 | ||
910 | // Refresh the view | 910 | // Refresh the view |
911 | mViewManager->refreshView(); | 911 | mViewManager->refreshView(); |
912 | } | 912 | } |
913 | 913 | ||
914 | void KABCore::redo() | 914 | void KABCore::redo() |
915 | { | 915 | { |
916 | RedoStack::instance()->redo(); | 916 | RedoStack::instance()->redo(); |
917 | 917 | ||
918 | // Refresh the view | 918 | // Refresh the view |
919 | mViewManager->refreshView(); | 919 | mViewManager->refreshView(); |
920 | } | 920 | } |
921 | 921 | ||
922 | void KABCore::setJumpButtonBarVisible( bool visible ) | 922 | void KABCore::setJumpButtonBarVisible( bool visible ) |
923 | { | 923 | { |
924 | if ( visible ) | 924 | if ( visible ) |
925 | mJumpButtonBar->show(); | 925 | mJumpButtonBar->show(); |
926 | else | 926 | else |
927 | mJumpButtonBar->hide(); | 927 | mJumpButtonBar->hide(); |
928 | } | 928 | } |
929 | void KABCore::setDetailsToState() | 929 | void KABCore::setDetailsToState() |
930 | { | 930 | { |
931 | setDetailsVisible( mActionDetails->isChecked() ); | 931 | setDetailsVisible( mActionDetails->isChecked() ); |
932 | } | 932 | } |
933 | 933 | ||
934 | void KABCore::setDetailsVisible( bool visible ) | 934 | void KABCore::setDetailsVisible( bool visible ) |
935 | { | 935 | { |
936 | if ( visible ) | 936 | if ( visible ) |
937 | mDetails->show(); | 937 | mDetails->show(); |
938 | else | 938 | else |
939 | mDetails->hide(); | 939 | mDetails->hide(); |
940 | } | 940 | } |
941 | 941 | ||
942 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 942 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
943 | { | 943 | { |
944 | 944 | ||
945 | if ( list.count() != 0 ) { | 945 | if ( list.count() != 0 ) { |
946 | KABC::Addressee::List::ConstIterator it; | 946 | KABC::Addressee::List::ConstIterator it; |
947 | for ( it = list.begin(); it != list.end(); ++it ) | 947 | for ( it = list.begin(); it != list.end(); ++it ) |
948 | mAddressBook->insertAddressee( *it ); | 948 | mAddressBook->insertAddressee( *it ); |
949 | if ( list.count() > 1 ) | 949 | if ( list.count() > 1 ) |
950 | setModified(); | 950 | setModified(); |
951 | else | 951 | else |
952 | setModifiedWOrefresh(); | 952 | setModifiedWOrefresh(); |
953 | } | 953 | } |
954 | if ( list.count() == 0 ) | 954 | if ( list.count() == 0 ) |
955 | mViewManager->refreshView(); | 955 | mViewManager->refreshView(); |
956 | else | 956 | else |
957 | mViewManager->refreshView( list[ 0 ].uid() ); | 957 | mViewManager->refreshView( list[ 0 ].uid() ); |
958 | 958 | ||
959 | 959 | ||
960 | 960 | ||
961 | } | 961 | } |
962 | 962 | ||
963 | QString KABCore::getNameByPhone( const QString &phone ) | 963 | QString KABCore::getNameByPhone( const QString &phone ) |
964 | { | 964 | { |
965 | #ifndef KAB_EMBEDDED | 965 | #ifndef KAB_EMBEDDED |
966 | QRegExp r( "[/*/-/ ]" ); | 966 | QRegExp r( "[/*/-/ ]" ); |
967 | QString localPhone( phone ); | 967 | QString localPhone( phone ); |
968 | 968 | ||
969 | bool found = false; | 969 | bool found = false; |
970 | QString ownerName = ""; | 970 | QString ownerName = ""; |
971 | KABC::AddressBook::Iterator iter; | 971 | KABC::AddressBook::Iterator iter; |
972 | KABC::PhoneNumber::List::Iterator phoneIter; | 972 | KABC::PhoneNumber::List::Iterator phoneIter; |
973 | KABC::PhoneNumber::List phoneList; | 973 | KABC::PhoneNumber::List phoneList; |
974 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 974 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
975 | phoneList = (*iter).phoneNumbers(); | 975 | phoneList = (*iter).phoneNumbers(); |
976 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 976 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
977 | ++phoneIter) { | 977 | ++phoneIter) { |
978 | // Get rid of separator chars so just the numbers are compared. | 978 | // Get rid of separator chars so just the numbers are compared. |
979 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 979 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
980 | ownerName = (*iter).formattedName(); | 980 | ownerName = (*iter).formattedName(); |
981 | found = true; | 981 | found = true; |
982 | } | 982 | } |
983 | } | 983 | } |
984 | } | 984 | } |
985 | 985 | ||
986 | return ownerName; | 986 | return ownerName; |
987 | #else //KAB_EMBEDDED | 987 | #else //KAB_EMBEDDED |
988 | qDebug("KABCore::getNameByPhone finsih method"); | 988 | qDebug("KABCore::getNameByPhone finsih method"); |
989 | return ""; | 989 | return ""; |
990 | #endif //KAB_EMBEDDED | 990 | #endif //KAB_EMBEDDED |
991 | 991 | ||
992 | } | 992 | } |
993 | 993 | ||
994 | void KABCore::openConfigDialog() | 994 | void KABCore::openConfigDialog() |
995 | { | 995 | { |
996 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 996 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
997 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 997 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
998 | ConfigureDialog->addModule(kabcfg ); | 998 | ConfigureDialog->addModule(kabcfg ); |
999 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 999 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1000 | this, SLOT( configurationChanged() ) ); | 1000 | this, SLOT( configurationChanged() ) ); |
1001 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1001 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1002 | this, SLOT( configurationChanged() ) ); | 1002 | this, SLOT( configurationChanged() ) ); |
1003 | saveSettings(); | 1003 | saveSettings(); |
1004 | ConfigureDialog->showMaximized(); | 1004 | ConfigureDialog->showMaximized(); |
1005 | if ( ConfigureDialog->exec() ) | 1005 | if ( ConfigureDialog->exec() ) |
1006 | KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") ); | 1006 | KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") ); |
1007 | delete ConfigureDialog; | 1007 | delete ConfigureDialog; |
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | void KABCore::openLDAPDialog() | 1010 | void KABCore::openLDAPDialog() |
1011 | { | 1011 | { |
1012 | #ifndef KAB_EMBEDDED | 1012 | #ifndef KAB_EMBEDDED |
1013 | if ( !mLdapSearchDialog ) { | 1013 | if ( !mLdapSearchDialog ) { |
1014 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1014 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1015 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1015 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1016 | SLOT( refreshView() ) ); | 1016 | SLOT( refreshView() ) ); |
1017 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1017 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1018 | SLOT( setModified() ) ); | 1018 | SLOT( setModified() ) ); |
1019 | } else | 1019 | } else |
1020 | mLdapSearchDialog->restoreSettings(); | 1020 | mLdapSearchDialog->restoreSettings(); |
1021 | 1021 | ||
1022 | if ( mLdapSearchDialog->isOK() ) | 1022 | if ( mLdapSearchDialog->isOK() ) |
1023 | mLdapSearchDialog->exec(); | 1023 | mLdapSearchDialog->exec(); |
1024 | #else //KAB_EMBEDDED | 1024 | #else //KAB_EMBEDDED |
1025 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1025 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1026 | #endif //KAB_EMBEDDED | 1026 | #endif //KAB_EMBEDDED |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | void KABCore::print() | 1029 | void KABCore::print() |
1030 | { | 1030 | { |
1031 | #ifndef KAB_EMBEDDED | 1031 | #ifndef KAB_EMBEDDED |
1032 | KPrinter printer; | 1032 | KPrinter printer; |
1033 | if ( !printer.setup( this ) ) | 1033 | if ( !printer.setup( this ) ) |
1034 | return; | 1034 | return; |
1035 | 1035 | ||
1036 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1036 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1037 | mViewManager->selectedUids(), this ); | 1037 | mViewManager->selectedUids(), this ); |
1038 | 1038 | ||
1039 | wizard.exec(); | 1039 | wizard.exec(); |
1040 | #else //KAB_EMBEDDED | 1040 | #else //KAB_EMBEDDED |
1041 | qDebug("KABCore::print() finsih method"); | 1041 | qDebug("KABCore::print() finsih method"); |
1042 | #endif //KAB_EMBEDDED | 1042 | #endif //KAB_EMBEDDED |
1043 | 1043 | ||
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | 1046 | ||
1047 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1047 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1048 | { | 1048 | { |
1049 | if ( mGUIClient ) | 1049 | if ( mGUIClient ) |
1050 | mGUIClient->insertChildClient( client ); | 1050 | mGUIClient->insertChildClient( client ); |
1051 | else | 1051 | else |
1052 | KMessageBox::error( this, "no KXMLGUICLient"); | 1052 | KMessageBox::error( this, "no KXMLGUICLient"); |
1053 | } | 1053 | } |
1054 | 1054 | ||