-rw-r--r-- | kaddressbook/kabcore.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index b107e2d..3715786 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2483,181 +2483,185 @@ void KABCore::setFormattedName() | |||
2483 | if ( modified ) | 2483 | if ( modified ) |
2484 | setModified( true ); | 2484 | setModified( true ); |
2485 | Addressee add; | 2485 | Addressee add; |
2486 | mDetails->setAddressee( add ); | 2486 | mDetails->setAddressee( add ); |
2487 | if ( count == 0 ) | 2487 | if ( count == 0 ) |
2488 | message(i18n("No contact changed!") ); | 2488 | message(i18n("No contact changed!") ); |
2489 | else | 2489 | else |
2490 | message(i18n("%1 contacts changed!").arg( count ) ); | 2490 | message(i18n("%1 contacts changed!").arg( count ) ); |
2491 | } | 2491 | } |
2492 | 2492 | ||
2493 | void KABCore::clipboardDataChanged() | 2493 | void KABCore::clipboardDataChanged() |
2494 | { | 2494 | { |
2495 | 2495 | ||
2496 | if ( mReadWrite ) | 2496 | if ( mReadWrite ) |
2497 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2497 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2498 | 2498 | ||
2499 | } | 2499 | } |
2500 | 2500 | ||
2501 | void KABCore::updateActionMenu() | 2501 | void KABCore::updateActionMenu() |
2502 | { | 2502 | { |
2503 | UndoStack *undo = UndoStack::instance(); | 2503 | UndoStack *undo = UndoStack::instance(); |
2504 | RedoStack *redo = RedoStack::instance(); | 2504 | RedoStack *redo = RedoStack::instance(); |
2505 | 2505 | ||
2506 | if ( undo->isEmpty() ) | 2506 | if ( undo->isEmpty() ) |
2507 | mActionUndo->setText( i18n( "Undo" ) ); | 2507 | mActionUndo->setText( i18n( "Undo" ) ); |
2508 | else | 2508 | else |
2509 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2509 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2510 | 2510 | ||
2511 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2511 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2512 | 2512 | ||
2513 | if ( !redo->top() ) | 2513 | if ( !redo->top() ) |
2514 | mActionRedo->setText( i18n( "Redo" ) ); | 2514 | mActionRedo->setText( i18n( "Redo" ) ); |
2515 | else | 2515 | else |
2516 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2516 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2517 | 2517 | ||
2518 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2518 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2519 | } | 2519 | } |
2520 | 2520 | ||
2521 | void KABCore::configureKeyBindings() | 2521 | void KABCore::configureKeyBindings() |
2522 | { | 2522 | { |
2523 | #ifndef KAB_EMBEDDED | 2523 | #ifndef KAB_EMBEDDED |
2524 | KKeyDialog::configure( actionCollection(), true ); | 2524 | KKeyDialog::configure( actionCollection(), true ); |
2525 | #else //KAB_EMBEDDED | 2525 | #else //KAB_EMBEDDED |
2526 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2526 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2527 | #endif //KAB_EMBEDDED | 2527 | #endif //KAB_EMBEDDED |
2528 | } | 2528 | } |
2529 | 2529 | ||
2530 | #ifdef KAB_EMBEDDED | 2530 | #ifdef KAB_EMBEDDED |
2531 | void KABCore::configureResources() | 2531 | void KABCore::configureResources() |
2532 | { | 2532 | { |
2533 | KRES::KCMKResources dlg( this, "" , 0 ); | 2533 | KRES::KCMKResources dlg( this, "" , 0 ); |
2534 | 2534 | ||
2535 | if ( !dlg.exec() ) | 2535 | if ( !dlg.exec() ) |
2536 | return; | 2536 | return; |
2537 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2537 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2538 | } | 2538 | } |
2539 | #endif //KAB_EMBEDDED | 2539 | #endif //KAB_EMBEDDED |
2540 | 2540 | ||
2541 | 2541 | ||
2542 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2542 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2543 | * for the attendees list of an event. | 2543 | * for the attendees list of an event. |
2544 | */ | 2544 | */ |
2545 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2545 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2546 | { | 2546 | { |
2547 | 2547 | qDebug("KABCore::requestForNameEmailUidList "); | |
2548 | bool ok = false; | 2548 | bool ok = false; |
2549 | mEmailSourceChannel = sourceChannel; | 2549 | mEmailSourceChannel = sourceChannel; |
2550 | mEmailSourceUID = uid; | 2550 | mEmailSourceUID = uid; |
2551 | callContactdialog(); | 2551 | QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); |
2552 | //callContactdialog(); | ||
2552 | #if 0 | 2553 | #if 0 |
2553 | int wid = uid.toInt( &ok ); | 2554 | int wid = uid.toInt( &ok ); |
2554 | qDebug("UID %s ", uid.latin1()); | 2555 | qDebug("UID %s ", uid.latin1()); |
2555 | if ( ok ) { | 2556 | if ( ok ) { |
2556 | if ( wid != QApplication::desktop()->width() ) { | 2557 | if ( wid != QApplication::desktop()->width() ) { |
2557 | qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); | 2558 | qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); |
2558 | message( i18n("Resizing, please wait...") ); | 2559 | message( i18n("Resizing, please wait...") ); |
2559 | mMainWindow->showMinimized(); | 2560 | mMainWindow->showMinimized(); |
2560 | /* | 2561 | /* |
2561 | { | 2562 | { |
2562 | QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); | 2563 | QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); |
2563 | } | 2564 | } |
2564 | */ | 2565 | */ |
2565 | QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); | 2566 | QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); |
2566 | return; | 2567 | return; |
2567 | } | 2568 | } |
2568 | 2569 | ||
2569 | } else { | 2570 | } else { |
2570 | qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); | 2571 | qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); |
2571 | } | 2572 | } |
2572 | callContactdialog(); | 2573 | callContactdialog(); |
2573 | //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); | 2574 | //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); |
2574 | #endif | 2575 | #endif |
2575 | } | 2576 | } |
2576 | void KABCore::resizeAndCallContactdialog() | 2577 | void KABCore::resizeAndCallContactdialog() |
2577 | { | 2578 | { |
2578 | updateMainWindow(); | 2579 | updateMainWindow(); |
2579 | QTimer::singleShot( 100,this, SLOT ( callContactdialog() ) ); | 2580 | QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); |
2580 | } | 2581 | } |
2581 | 2582 | ||
2582 | void KABCore::callContactdialog() | 2583 | void KABCore::callContactdialog() |
2583 | { | 2584 | { |
2584 | QStringList nameList; | 2585 | static bool running = false; |
2586 | if (running) return; | ||
2587 | running = true; | ||
2588 | QStringList nameList; | ||
2585 | QStringList emailList; | 2589 | QStringList emailList; |
2586 | QStringList uidList; | 2590 | QStringList uidList; |
2587 | qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); | 2591 | qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); |
2588 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2592 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2589 | uint i=0; | 2593 | uint i=0; |
2590 | for (i=0; i < list.count(); i++) | 2594 | for (i=0; i < list.count(); i++) |
2591 | { | 2595 | { |
2592 | nameList.append(list[i].realName()); | 2596 | nameList.append(list[i].realName()); |
2593 | emailList.append(list[i].preferredEmail()); | 2597 | emailList.append(list[i].preferredEmail()); |
2594 | uidList.append(list[i].uid()); | 2598 | uidList.append(list[i].uid()); |
2595 | } | 2599 | } |
2596 | QString uid = mEmailSourceUID; | 2600 | QString uid = mEmailSourceUID; |
2597 | //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); | 2601 | //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); |
2598 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); | 2602 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); |
2599 | 2603 | running = false; | |
2600 | } | 2604 | } |
2601 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2605 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2602 | * to put them into the calendar. | 2606 | * to put them into the calendar. |
2603 | */ | 2607 | */ |
2604 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2608 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2605 | { | 2609 | { |
2606 | // qDebug("KABCore::requestForBirthdayList"); | 2610 | // qDebug("KABCore::requestForBirthdayList"); |
2607 | QStringList birthdayList; | 2611 | QStringList birthdayList; |
2608 | QStringList anniversaryList; | 2612 | QStringList anniversaryList; |
2609 | QStringList realNameList; | 2613 | QStringList realNameList; |
2610 | QStringList preferredEmailList; | 2614 | QStringList preferredEmailList; |
2611 | QStringList assembledNameList; | 2615 | QStringList assembledNameList; |
2612 | QStringList uidList; | 2616 | QStringList uidList; |
2613 | 2617 | ||
2614 | KABC::AddressBook::Iterator it; | 2618 | KABC::AddressBook::Iterator it; |
2615 | 2619 | ||
2616 | int count = 0; | 2620 | int count = 0; |
2617 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2621 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2618 | ++count; | 2622 | ++count; |
2619 | } | 2623 | } |
2620 | QProgressBar bar(count,0 ); | 2624 | QProgressBar bar(count,0 ); |
2621 | int w = 300; | 2625 | int w = 300; |
2622 | if ( QApplication::desktop()->width() < 320 ) | 2626 | if ( QApplication::desktop()->width() < 320 ) |
2623 | w = 220; | 2627 | w = 220; |
2624 | int h = bar.sizeHint().height() ; | 2628 | int h = bar.sizeHint().height() ; |
2625 | int dw = QApplication::desktop()->width(); | 2629 | int dw = QApplication::desktop()->width(); |
2626 | int dh = QApplication::desktop()->height(); | 2630 | int dh = QApplication::desktop()->height(); |
2627 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2631 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2628 | bar.show(); | 2632 | bar.show(); |
2629 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2633 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2630 | qApp->processEvents(); | 2634 | qApp->processEvents(); |
2631 | 2635 | ||
2632 | QDate bday; | 2636 | QDate bday; |
2633 | QString anni; | 2637 | QString anni; |
2634 | QString formattedbday; | 2638 | QString formattedbday; |
2635 | 2639 | ||
2636 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2640 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2637 | { | 2641 | { |
2638 | if ( ! bar.isVisible() ) | 2642 | if ( ! bar.isVisible() ) |
2639 | return; | 2643 | return; |
2640 | bar.setProgress( count++ ); | 2644 | bar.setProgress( count++ ); |
2641 | qApp->processEvents(); | 2645 | qApp->processEvents(); |
2642 | bday = (*it).birthday().date(); | 2646 | bday = (*it).birthday().date(); |
2643 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2647 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2644 | 2648 | ||
2645 | if ( bday.isValid() || !anni.isEmpty()) | 2649 | if ( bday.isValid() || !anni.isEmpty()) |
2646 | { | 2650 | { |
2647 | if (bday.isValid()) | 2651 | if (bday.isValid()) |
2648 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2652 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2649 | else | 2653 | else |
2650 | formattedbday = "NOTVALID"; | 2654 | formattedbday = "NOTVALID"; |
2651 | if (anni.isEmpty()) | 2655 | if (anni.isEmpty()) |
2652 | anni = "INVALID"; | 2656 | anni = "INVALID"; |
2653 | 2657 | ||
2654 | birthdayList.append(formattedbday); | 2658 | birthdayList.append(formattedbday); |
2655 | anniversaryList.append(anni); //should be ISODate | 2659 | anniversaryList.append(anni); //should be ISODate |
2656 | realNameList.append((*it).realName()); | 2660 | realNameList.append((*it).realName()); |
2657 | preferredEmailList.append((*it).preferredEmail()); | 2661 | preferredEmailList.append((*it).preferredEmail()); |
2658 | assembledNameList.append((*it).assembledName()); | 2662 | assembledNameList.append((*it).assembledName()); |
2659 | uidList.append((*it).uid()); | 2663 | uidList.append((*it).uid()); |
2660 | 2664 | ||
2661 | //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() ); | 2665 | //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() ); |
2662 | } | 2666 | } |
2663 | } | 2667 | } |