-rw-r--r-- | korganizer/calendarview.cpp | 3 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 31 |
2 files changed, 21 insertions, 13 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index ab69158..5a2482e 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2429,769 +2429,770 @@ void CalendarView::readSettings() | |||
2429 | mLeftFrame->setSizes(sizes); | 2429 | mLeftFrame->setSizes(sizes); |
2430 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2430 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2431 | resetval = 0; | 2431 | resetval = 0; |
2432 | maxVal = 0; | 2432 | maxVal = 0; |
2433 | if (sizes.count() != 2) { | 2433 | if (sizes.count() != 2) { |
2434 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2434 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2435 | resetval = mDateNavigator->sizeHint().width()+2; | 2435 | resetval = mDateNavigator->sizeHint().width()+2; |
2436 | } else { | 2436 | } else { |
2437 | resetval = mDateNavigator->sizeHint().height()+2; | 2437 | resetval = mDateNavigator->sizeHint().height()+2; |
2438 | } | 2438 | } |
2439 | } | 2439 | } |
2440 | if ( resetval ) { | 2440 | if ( resetval ) { |
2441 | sizes.clear(); | 2441 | sizes.clear(); |
2442 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2442 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2443 | maxVal = QApplication::desktop()->width() -10; | 2443 | maxVal = QApplication::desktop()->width() -10; |
2444 | } else { | 2444 | } else { |
2445 | maxVal = QApplication::desktop()->height()-10; | 2445 | maxVal = QApplication::desktop()->height()-10; |
2446 | } | 2446 | } |
2447 | sizes << resetval; | 2447 | sizes << resetval; |
2448 | if ( maxVal < resetval + resetval) | 2448 | if ( maxVal < resetval + resetval) |
2449 | resetval = maxVal - resetval; | 2449 | resetval = maxVal - resetval; |
2450 | sizes << resetval; | 2450 | sizes << resetval; |
2451 | } | 2451 | } |
2452 | mMainFrame->setSizes(sizes); | 2452 | mMainFrame->setSizes(sizes); |
2453 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2453 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2454 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2454 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2455 | else mNavigator->selectDates( dateCount ); | 2455 | else mNavigator->selectDates( dateCount ); |
2456 | // mViewManager->readSettings( config ); | 2456 | // mViewManager->readSettings( config ); |
2457 | updateConfig(); | 2457 | updateConfig(); |
2458 | globalFlagBlockAgenda = 2; | 2458 | globalFlagBlockAgenda = 2; |
2459 | mViewManager->readSettings( config ); | 2459 | mViewManager->readSettings( config ); |
2460 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2460 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2461 | } | 2461 | } |
2462 | 2462 | ||
2463 | void CalendarView::checkSuspendAlarm() | 2463 | void CalendarView::checkSuspendAlarm() |
2464 | { | 2464 | { |
2465 | if ( mSuspendTimer->isActive() ) { | 2465 | if ( mSuspendTimer->isActive() ) { |
2466 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2466 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2467 | } | 2467 | } |
2468 | } | 2468 | } |
2469 | void CalendarView::writeSettings() | 2469 | void CalendarView::writeSettings() |
2470 | { | 2470 | { |
2471 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2471 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2472 | 2472 | ||
2473 | KConfig *config = KOGlobals::config(); | 2473 | KConfig *config = KOGlobals::config(); |
2474 | 2474 | ||
2475 | mViewManager->writeSettings( config ); | 2475 | mViewManager->writeSettings( config ); |
2476 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2476 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2477 | mDialogManager->writeSettings( config ); | 2477 | mDialogManager->writeSettings( config ); |
2478 | //KOPrefs::instance()->usrWriteConfig(); | 2478 | //KOPrefs::instance()->usrWriteConfig(); |
2479 | KOPrefs::instance()->writeConfig(); | 2479 | KOPrefs::instance()->writeConfig(); |
2480 | 2480 | ||
2481 | writeFilterSettings(config); | 2481 | writeFilterSettings(config); |
2482 | config->setGroup( "AppRun" ); | 2482 | config->setGroup( "AppRun" ); |
2483 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2483 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2484 | int days = dt.daysTo( QDate::currentDate() ); | 2484 | int days = dt.daysTo( QDate::currentDate() ); |
2485 | dt = dt.addDays( days ); | 2485 | dt = dt.addDays( days ); |
2486 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2486 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2487 | config->writeEntry( "LatestProgramStopDays", days ); | 2487 | config->writeEntry( "LatestProgramStopDays", days ); |
2488 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2488 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2489 | //qDebug("KO: Writing stop time: %d ", secs); | 2489 | //qDebug("KO: Writing stop time: %d ", secs); |
2490 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2490 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2491 | //QDateTime latest = dt.addSecs ( secs ); | 2491 | //QDateTime latest = dt.addSecs ( secs ); |
2492 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2492 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2493 | config->setGroup( "Views" ); | 2493 | config->setGroup( "Views" ); |
2494 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2494 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2495 | 2495 | ||
2496 | #if 0 | 2496 | #if 0 |
2497 | qDebug("********************* "); | 2497 | qDebug("********************* "); |
2498 | qDebug("Testcode secsto "); | 2498 | qDebug("Testcode secsto "); |
2499 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2499 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2500 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2500 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2501 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2501 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2502 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2502 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2503 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2503 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2504 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2504 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2505 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2505 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2506 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2506 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2507 | qDebug("********************* testcode end"); | 2507 | qDebug("********************* testcode end"); |
2508 | 2508 | ||
2509 | #endif | 2509 | #endif |
2510 | 2510 | ||
2511 | QValueList<int> listINT = mLeftFrame->sizes(); | 2511 | QValueList<int> listINT = mLeftFrame->sizes(); |
2512 | config->writeEntry("Left Splitter Frame",listINT); | 2512 | config->writeEntry("Left Splitter Frame",listINT); |
2513 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2513 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2514 | config->writeEntry("Main Splitter Frame",listINT2); | 2514 | config->writeEntry("Main Splitter Frame",listINT2); |
2515 | #ifdef DESKTOP_VERSION | 2515 | #ifdef DESKTOP_VERSION |
2516 | config->setGroup("WidgetLayout"); | 2516 | config->setGroup("WidgetLayout"); |
2517 | QStringList list ;//= config->readListEntry("MainLayout"); | 2517 | QStringList list ;//= config->readListEntry("MainLayout"); |
2518 | int x,y,w,h; | 2518 | int x,y,w,h; |
2519 | QWidget* wid; | 2519 | QWidget* wid; |
2520 | wid = topLevelWidget(); | 2520 | wid = topLevelWidget(); |
2521 | x = wid->geometry().x(); | 2521 | x = wid->geometry().x(); |
2522 | y = wid->geometry().y(); | 2522 | y = wid->geometry().y(); |
2523 | w = wid->width(); | 2523 | w = wid->width(); |
2524 | h = wid->height(); | 2524 | h = wid->height(); |
2525 | list.clear(); | 2525 | list.clear(); |
2526 | list << QString::number( x ); | 2526 | list << QString::number( x ); |
2527 | list << QString::number( y ); | 2527 | list << QString::number( y ); |
2528 | list << QString::number( w ); | 2528 | list << QString::number( w ); |
2529 | list << QString::number( h ); | 2529 | list << QString::number( h ); |
2530 | config->writeEntry("MainLayout",list ); | 2530 | config->writeEntry("MainLayout",list ); |
2531 | 2531 | ||
2532 | wid = mEventEditor; | 2532 | wid = mEventEditor; |
2533 | x = wid->geometry().x(); | 2533 | x = wid->geometry().x(); |
2534 | y = wid->geometry().y(); | 2534 | y = wid->geometry().y(); |
2535 | w = wid->width(); | 2535 | w = wid->width(); |
2536 | h = wid->height(); | 2536 | h = wid->height(); |
2537 | list.clear(); | 2537 | list.clear(); |
2538 | list << QString::number( x ); | 2538 | list << QString::number( x ); |
2539 | list << QString::number( y ); | 2539 | list << QString::number( y ); |
2540 | list << QString::number( w ); | 2540 | list << QString::number( w ); |
2541 | list << QString::number( h ); | 2541 | list << QString::number( h ); |
2542 | config->writeEntry("EditEventLayout",list ); | 2542 | config->writeEntry("EditEventLayout",list ); |
2543 | 2543 | ||
2544 | wid = mTodoEditor; | 2544 | wid = mTodoEditor; |
2545 | x = wid->geometry().x(); | 2545 | x = wid->geometry().x(); |
2546 | y = wid->geometry().y(); | 2546 | y = wid->geometry().y(); |
2547 | w = wid->width(); | 2547 | w = wid->width(); |
2548 | h = wid->height(); | 2548 | h = wid->height(); |
2549 | list.clear(); | 2549 | list.clear(); |
2550 | list << QString::number( x ); | 2550 | list << QString::number( x ); |
2551 | list << QString::number( y ); | 2551 | list << QString::number( y ); |
2552 | list << QString::number( w ); | 2552 | list << QString::number( w ); |
2553 | list << QString::number( h ); | 2553 | list << QString::number( h ); |
2554 | config->writeEntry("EditTodoLayout",list ); | 2554 | config->writeEntry("EditTodoLayout",list ); |
2555 | wid = getEventViewerDialog(); | 2555 | wid = getEventViewerDialog(); |
2556 | x = wid->geometry().x(); | 2556 | x = wid->geometry().x(); |
2557 | y = wid->geometry().y(); | 2557 | y = wid->geometry().y(); |
2558 | w = wid->width(); | 2558 | w = wid->width(); |
2559 | h = wid->height(); | 2559 | h = wid->height(); |
2560 | list.clear(); | 2560 | list.clear(); |
2561 | list << QString::number( x ); | 2561 | list << QString::number( x ); |
2562 | list << QString::number( y ); | 2562 | list << QString::number( y ); |
2563 | list << QString::number( w ); | 2563 | list << QString::number( w ); |
2564 | list << QString::number( h ); | 2564 | list << QString::number( h ); |
2565 | config->writeEntry("ViewerLayout",list ); | 2565 | config->writeEntry("ViewerLayout",list ); |
2566 | wid = mDialogManager->getSearchDialog(); | 2566 | wid = mDialogManager->getSearchDialog(); |
2567 | if ( wid ) { | 2567 | if ( wid ) { |
2568 | x = wid->geometry().x(); | 2568 | x = wid->geometry().x(); |
2569 | y = wid->geometry().y(); | 2569 | y = wid->geometry().y(); |
2570 | w = wid->width(); | 2570 | w = wid->width(); |
2571 | h = wid->height(); | 2571 | h = wid->height(); |
2572 | list.clear(); | 2572 | list.clear(); |
2573 | list << QString::number( x ); | 2573 | list << QString::number( x ); |
2574 | list << QString::number( y ); | 2574 | list << QString::number( y ); |
2575 | list << QString::number( w ); | 2575 | list << QString::number( w ); |
2576 | list << QString::number( h ); | 2576 | list << QString::number( h ); |
2577 | config->writeEntry("SearchLayout",list ); | 2577 | config->writeEntry("SearchLayout",list ); |
2578 | } | 2578 | } |
2579 | #endif | 2579 | #endif |
2580 | 2580 | ||
2581 | 2581 | ||
2582 | config->sync(); | 2582 | config->sync(); |
2583 | } | 2583 | } |
2584 | 2584 | ||
2585 | void CalendarView::readFilterSettings(KConfig *config) | 2585 | void CalendarView::readFilterSettings(KConfig *config) |
2586 | { | 2586 | { |
2587 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2587 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2588 | 2588 | ||
2589 | mFilters.clear(); | 2589 | mFilters.clear(); |
2590 | 2590 | ||
2591 | config->setGroup("General"); | 2591 | config->setGroup("General"); |
2592 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2592 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2593 | 2593 | ||
2594 | QStringList::ConstIterator it = filterList.begin(); | 2594 | QStringList::ConstIterator it = filterList.begin(); |
2595 | QStringList::ConstIterator end = filterList.end(); | 2595 | QStringList::ConstIterator end = filterList.end(); |
2596 | while(it != end) { | 2596 | while(it != end) { |
2597 | // kdDebug() << " filter: " << (*it) << endl; | 2597 | // kdDebug() << " filter: " << (*it) << endl; |
2598 | 2598 | ||
2599 | CalFilter *filter; | 2599 | CalFilter *filter; |
2600 | filter = new CalFilter(*it); | 2600 | filter = new CalFilter(*it); |
2601 | config->setGroup("Filter_" + (*it).utf8()); | 2601 | config->setGroup("Filter_" + (*it).utf8()); |
2602 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2602 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2603 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2603 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2604 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2604 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2605 | mFilters.append(filter); | 2605 | mFilters.append(filter); |
2606 | 2606 | ||
2607 | ++it; | 2607 | ++it; |
2608 | } | 2608 | } |
2609 | 2609 | ||
2610 | if (mFilters.count() == 0) { | 2610 | if (mFilters.count() == 0) { |
2611 | CalFilter *filter = new CalFilter(i18n("Default")); | 2611 | CalFilter *filter = new CalFilter(i18n("Default")); |
2612 | mFilters.append(filter); | 2612 | mFilters.append(filter); |
2613 | } | 2613 | } |
2614 | mFilterView->updateFilters(); | 2614 | mFilterView->updateFilters(); |
2615 | config->setGroup("FilterView"); | 2615 | config->setGroup("FilterView"); |
2616 | 2616 | ||
2617 | mFilterView->blockSignals(true); | 2617 | mFilterView->blockSignals(true); |
2618 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2618 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2619 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2619 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2620 | mFilterView->blockSignals(false); | 2620 | mFilterView->blockSignals(false); |
2621 | // We do it manually to avoid it being done twice by the above calls | 2621 | // We do it manually to avoid it being done twice by the above calls |
2622 | updateFilter(); | 2622 | updateFilter(); |
2623 | } | 2623 | } |
2624 | 2624 | ||
2625 | void CalendarView::writeFilterSettings(KConfig *config) | 2625 | void CalendarView::writeFilterSettings(KConfig *config) |
2626 | { | 2626 | { |
2627 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2627 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2628 | 2628 | ||
2629 | QStringList filterList; | 2629 | QStringList filterList; |
2630 | 2630 | ||
2631 | CalFilter *filter = mFilters.first(); | 2631 | CalFilter *filter = mFilters.first(); |
2632 | while(filter) { | 2632 | while(filter) { |
2633 | // kdDebug() << " fn: " << filter->name() << endl; | 2633 | // kdDebug() << " fn: " << filter->name() << endl; |
2634 | filterList << filter->name(); | 2634 | filterList << filter->name(); |
2635 | config->setGroup("Filter_" + filter->name().utf8()); | 2635 | config->setGroup("Filter_" + filter->name().utf8()); |
2636 | config->writeEntry("Criteria",filter->criteria()); | 2636 | config->writeEntry("Criteria",filter->criteria()); |
2637 | config->writeEntry("CategoryList",filter->categoryList()); | 2637 | config->writeEntry("CategoryList",filter->categoryList()); |
2638 | filter = mFilters.next(); | 2638 | filter = mFilters.next(); |
2639 | } | 2639 | } |
2640 | config->setGroup("General"); | 2640 | config->setGroup("General"); |
2641 | config->writeEntry("CalendarFilters",filterList); | 2641 | config->writeEntry("CalendarFilters",filterList); |
2642 | 2642 | ||
2643 | config->setGroup("FilterView"); | 2643 | config->setGroup("FilterView"); |
2644 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2644 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2645 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2645 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2646 | } | 2646 | } |
2647 | 2647 | ||
2648 | 2648 | ||
2649 | void CalendarView::goToday() | 2649 | void CalendarView::goToday() |
2650 | { | 2650 | { |
2651 | if ( mViewManager->currentView()->isMonthView() ) | 2651 | if ( mViewManager->currentView()->isMonthView() ) |
2652 | mNavigator->selectTodayMonth(); | 2652 | mNavigator->selectTodayMonth(); |
2653 | else | 2653 | else |
2654 | mNavigator->selectToday(); | 2654 | mNavigator->selectToday(); |
2655 | } | 2655 | } |
2656 | 2656 | ||
2657 | void CalendarView::goNext() | 2657 | void CalendarView::goNext() |
2658 | { | 2658 | { |
2659 | mNavigator->selectNext(); | 2659 | mNavigator->selectNext(); |
2660 | } | 2660 | } |
2661 | 2661 | ||
2662 | void CalendarView::goPrevious() | 2662 | void CalendarView::goPrevious() |
2663 | { | 2663 | { |
2664 | mNavigator->selectPrevious(); | 2664 | mNavigator->selectPrevious(); |
2665 | } | 2665 | } |
2666 | void CalendarView::goNextMonth() | 2666 | void CalendarView::goNextMonth() |
2667 | { | 2667 | { |
2668 | mNavigator->selectNextMonth(); | 2668 | mNavigator->selectNextMonth(); |
2669 | } | 2669 | } |
2670 | 2670 | ||
2671 | void CalendarView::goPreviousMonth() | 2671 | void CalendarView::goPreviousMonth() |
2672 | { | 2672 | { |
2673 | mNavigator->selectPreviousMonth(); | 2673 | mNavigator->selectPreviousMonth(); |
2674 | } | 2674 | } |
2675 | 2675 | ||
2676 | void CalendarView::updateConfig() | 2676 | void CalendarView::updateConfig() |
2677 | { | 2677 | { |
2678 | if ( KOPrefs::instance()->mUseAppColors ) | 2678 | if ( KOPrefs::instance()->mUseAppColors ) |
2679 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2679 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2680 | emit configChanged(); | 2680 | emit configChanged(); |
2681 | mTodoList->updateConfig(); | 2681 | mTodoList->updateConfig(); |
2682 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2682 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2683 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2683 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2684 | // To make the "fill window" configurations work | 2684 | // To make the "fill window" configurations work |
2685 | //mViewManager->raiseCurrentView(); | 2685 | //mViewManager->raiseCurrentView(); |
2686 | } | 2686 | } |
2687 | 2687 | ||
2688 | 2688 | ||
2689 | void CalendarView::eventChanged(Event *event) | 2689 | void CalendarView::eventChanged(Event *event) |
2690 | { | 2690 | { |
2691 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2691 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2692 | //updateUnmanagedViews(); | 2692 | //updateUnmanagedViews(); |
2693 | } | 2693 | } |
2694 | 2694 | ||
2695 | void CalendarView::eventAdded(Event *event) | 2695 | void CalendarView::eventAdded(Event *event) |
2696 | { | 2696 | { |
2697 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2697 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2698 | } | 2698 | } |
2699 | 2699 | ||
2700 | void CalendarView::eventToBeDeleted(Event *) | 2700 | void CalendarView::eventToBeDeleted(Event *) |
2701 | { | 2701 | { |
2702 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2702 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2703 | } | 2703 | } |
2704 | 2704 | ||
2705 | void CalendarView::eventDeleted() | 2705 | void CalendarView::eventDeleted() |
2706 | { | 2706 | { |
2707 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2707 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2708 | } | 2708 | } |
2709 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2709 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2710 | { | 2710 | { |
2711 | changeIncidenceDisplay((Incidence *)which, action); | 2711 | changeIncidenceDisplay((Incidence *)which, action); |
2712 | mDateNavigator->updateView(); //LR | 2712 | mDateNavigator->updateView(); //LR |
2713 | //mDialogManager->updateSearchDialog(); | 2713 | //mDialogManager->updateSearchDialog(); |
2714 | 2714 | ||
2715 | if (which) { | 2715 | if (which) { |
2716 | mViewManager->updateWNview(); | 2716 | mViewManager->updateWNview(); |
2717 | //mTodoList->updateView(); | 2717 | //mTodoList->updateView(); |
2718 | } | 2718 | } |
2719 | 2719 | ||
2720 | } | 2720 | } |
2721 | 2721 | ||
2722 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2722 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2723 | { | 2723 | { |
2724 | updateUnmanagedViews(); | 2724 | updateUnmanagedViews(); |
2725 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2725 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2726 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2726 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2727 | mCalendar->checkAlarmForIncidence( 0, true ); | 2727 | mCalendar->checkAlarmForIncidence( 0, true ); |
2728 | if ( mEventViewerDialog ) | 2728 | if ( mEventViewerDialog ) |
2729 | mEventViewerDialog->hide(); | 2729 | mEventViewerDialog->hide(); |
2730 | } | 2730 | } |
2731 | else | 2731 | else |
2732 | mCalendar->checkAlarmForIncidence( which , false ); | 2732 | mCalendar->checkAlarmForIncidence( which , false ); |
2733 | } | 2733 | } |
2734 | 2734 | ||
2735 | // most of the changeEventDisplays() right now just call the view's | 2735 | // most of the changeEventDisplays() right now just call the view's |
2736 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2736 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2737 | void CalendarView::changeEventDisplay(Event *which, int action) | 2737 | void CalendarView::changeEventDisplay(Event *which, int action) |
2738 | { | 2738 | { |
2739 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2739 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2740 | changeIncidenceDisplay((Incidence *)which, action); | 2740 | changeIncidenceDisplay((Incidence *)which, action); |
2741 | static bool clearallviews = false; | 2741 | static bool clearallviews = false; |
2742 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2742 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2743 | if ( clearallviews ) { | 2743 | if ( clearallviews ) { |
2744 | clearAllViews(); | 2744 | clearAllViews(); |
2745 | clearallviews = false; | 2745 | clearallviews = false; |
2746 | } | 2746 | } |
2747 | return; | 2747 | return; |
2748 | } | 2748 | } |
2749 | clearallviews = true; | 2749 | clearallviews = true; |
2750 | mDateNavigator->updateView(); | 2750 | mDateNavigator->updateView(); |
2751 | //mDialogManager->updateSearchDialog(); | 2751 | //mDialogManager->updateSearchDialog(); |
2752 | if (which) { | 2752 | if (which) { |
2753 | // If there is an event view visible update the display | 2753 | // If there is an event view visible update the display |
2754 | mViewManager->currentView()->changeEventDisplay(which,action); | 2754 | mViewManager->currentView()->changeEventDisplay(which,action); |
2755 | // TODO: check, if update needed | 2755 | // TODO: check, if update needed |
2756 | // if (which->getTodoStatus()) { | 2756 | // if (which->getTodoStatus()) { |
2757 | mTodoList->updateView(); | 2757 | mTodoList->updateView(); |
2758 | if ( action != KOGlobals::EVENTDELETED ) { | 2758 | if ( action != KOGlobals::EVENTDELETED ) { |
2759 | mConflictingEvent = which ; | 2759 | mConflictingEvent = which ; |
2760 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); | 2760 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); |
2761 | } | 2761 | } |
2762 | // } | 2762 | // } |
2763 | } else { | 2763 | } else { |
2764 | mViewManager->currentView()->updateView(); | 2764 | mViewManager->currentView()->updateView(); |
2765 | } | 2765 | } |
2766 | } | 2766 | } |
2767 | void CalendarView::checkConflictForEvent() | 2767 | void CalendarView::checkConflictForEvent() |
2768 | { | 2768 | { |
2769 | 2769 | ||
2770 | if (!KOPrefs::instance()->mConfirm) | 2770 | if (!KOPrefs::instance()->mConfirm) |
2771 | return; | 2771 | return; |
2772 | if ( ! mConflictingEvent ) return; | 2772 | if ( ! mConflictingEvent ) return; |
2773 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 2773 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
2774 | QPtrList<Event> testlist = mCalendar->events(); | 2774 | QPtrList<Event> testlist = mCalendar->events(); |
2775 | Event * test = testlist.first(); | 2775 | Event * test = testlist.first(); |
2776 | QDateTime conflict; | 2776 | QDateTime conflict; |
2777 | QDateTime retVal; | 2777 | QDateTime retVal; |
2778 | bool found = false; | 2778 | bool found = false; |
2779 | Event * cE = 0; | 2779 | Event * cE = 0; |
2780 | QDateTime current = QDateTime::currentDateTime(); | 2780 | QDateTime current = QDateTime::currentDateTime(); |
2781 | while ( test ) { | 2781 | while ( test ) { |
2782 | qApp->processEvents(); | 2782 | qApp->processEvents(); |
2783 | if ( !test->doesFloat() ) { | 2783 | if ( !test->doesFloat() ) { |
2784 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 2784 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
2785 | if ( ! found ) { | 2785 | if ( ! found ) { |
2786 | conflict = retVal; | 2786 | conflict = retVal; |
2787 | cE = test; | 2787 | cE = test; |
2788 | } else { | 2788 | } else { |
2789 | if ( retVal < conflict ) { | 2789 | if ( retVal < conflict ) { |
2790 | conflict = retVal; | 2790 | conflict = retVal; |
2791 | cE = test; | 2791 | cE = test; |
2792 | } | 2792 | } |
2793 | } | 2793 | } |
2794 | found = true; | 2794 | found = true; |
2795 | } | 2795 | } |
2796 | } | 2796 | } |
2797 | test = testlist.next(); | 2797 | test = testlist.next(); |
2798 | } | 2798 | } |
2799 | if ( found ) { | 2799 | if ( found ) { |
2800 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; | 2800 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; |
2801 | qApp->processEvents(); | 2801 | qApp->processEvents(); |
2802 | int km = KMessageBox::warningContinueCancel(this,mess, | 2802 | int km = KMessageBox::warningContinueCancel(this,mess, |
2803 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); | 2803 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); |
2804 | if ( km != KMessageBox::Continue ) | 2804 | if ( km != KMessageBox::Continue ) |
2805 | return; | 2805 | return; |
2806 | 2806 | ||
2807 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 2807 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
2808 | mViewManager->showDayView(); | 2808 | mViewManager->showDayView(); |
2809 | mNavigator->slotDaySelect( conflict.date() ); | 2809 | mNavigator->slotDaySelect( conflict.date() ); |
2810 | int hour = conflict.time().hour(); | 2810 | int hour = conflict.time().hour(); |
2811 | mViewManager->agendaView()->setStartHour( hour ); | 2811 | mViewManager->agendaView()->setStartHour( hour ); |
2812 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 2812 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
2813 | } | 2813 | } else |
2814 | topLevelWidget()->setCaption( i18n("No conflict found") ); | ||
2814 | mConflictingEvent = 0; | 2815 | mConflictingEvent = 0; |
2815 | return; | 2816 | return; |
2816 | 2817 | ||
2817 | } | 2818 | } |
2818 | 2819 | ||
2819 | void CalendarView::updateTodoViews() | 2820 | void CalendarView::updateTodoViews() |
2820 | { | 2821 | { |
2821 | mTodoList->updateView(); | 2822 | mTodoList->updateView(); |
2822 | mViewManager->currentView()->updateView(); | 2823 | mViewManager->currentView()->updateView(); |
2823 | 2824 | ||
2824 | } | 2825 | } |
2825 | 2826 | ||
2826 | 2827 | ||
2827 | 2828 | ||
2828 | void CalendarView::clearAllViews() | 2829 | void CalendarView::clearAllViews() |
2829 | { | 2830 | { |
2830 | mTodoList->clearList(); | 2831 | mTodoList->clearList(); |
2831 | mViewManager->clearAllViews(); | 2832 | mViewManager->clearAllViews(); |
2832 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2833 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2833 | if ( sd ) { | 2834 | if ( sd ) { |
2834 | KOListView* kol = sd->listview(); | 2835 | KOListView* kol = sd->listview(); |
2835 | if ( kol ) | 2836 | if ( kol ) |
2836 | kol->clearList(); | 2837 | kol->clearList(); |
2837 | } | 2838 | } |
2838 | } | 2839 | } |
2839 | void CalendarView::updateView() | 2840 | void CalendarView::updateView() |
2840 | { | 2841 | { |
2841 | static bool clearallviews = false; | 2842 | static bool clearallviews = false; |
2842 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2843 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2843 | if ( clearallviews ) { | 2844 | if ( clearallviews ) { |
2844 | clearAllViews(); | 2845 | clearAllViews(); |
2845 | clearallviews = false; | 2846 | clearallviews = false; |
2846 | } | 2847 | } |
2847 | return; | 2848 | return; |
2848 | } | 2849 | } |
2849 | clearallviews = true; | 2850 | clearallviews = true; |
2850 | DateList tmpList = mNavigator->selectedDates(); | 2851 | DateList tmpList = mNavigator->selectedDates(); |
2851 | 2852 | ||
2852 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2853 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2853 | mTodoList->updateView(); | 2854 | mTodoList->updateView(); |
2854 | // We assume that the navigator only selects consecutive days. | 2855 | // We assume that the navigator only selects consecutive days. |
2855 | updateView( tmpList.first(), tmpList.last() ); | 2856 | updateView( tmpList.first(), tmpList.last() ); |
2856 | } | 2857 | } |
2857 | 2858 | ||
2858 | void CalendarView::updateUnmanagedViews() | 2859 | void CalendarView::updateUnmanagedViews() |
2859 | { | 2860 | { |
2860 | mDateNavigator->updateDayMatrix(); | 2861 | mDateNavigator->updateDayMatrix(); |
2861 | } | 2862 | } |
2862 | 2863 | ||
2863 | int CalendarView::msgItemDelete(const QString name) | 2864 | int CalendarView::msgItemDelete(const QString name) |
2864 | { | 2865 | { |
2865 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2866 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2866 | i18n("This item will be\npermanently deleted."), | 2867 | i18n("This item will be\npermanently deleted."), |
2867 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2868 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2868 | } | 2869 | } |
2869 | 2870 | ||
2870 | 2871 | ||
2871 | void CalendarView::edit_cut() | 2872 | void CalendarView::edit_cut() |
2872 | { | 2873 | { |
2873 | Event *anEvent=0; | 2874 | Event *anEvent=0; |
2874 | 2875 | ||
2875 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2876 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2876 | 2877 | ||
2877 | if (mViewManager->currentView()->isEventView()) { | 2878 | if (mViewManager->currentView()->isEventView()) { |
2878 | if ( incidence && incidence->typeID() == eventID ) { | 2879 | if ( incidence && incidence->typeID() == eventID ) { |
2879 | anEvent = static_cast<Event *>(incidence); | 2880 | anEvent = static_cast<Event *>(incidence); |
2880 | } | 2881 | } |
2881 | } | 2882 | } |
2882 | 2883 | ||
2883 | if (!anEvent) { | 2884 | if (!anEvent) { |
2884 | KNotifyClient::beep(); | 2885 | KNotifyClient::beep(); |
2885 | return; | 2886 | return; |
2886 | } | 2887 | } |
2887 | DndFactory factory( mCalendar ); | 2888 | DndFactory factory( mCalendar ); |
2888 | factory.cutIncidence(anEvent); | 2889 | factory.cutIncidence(anEvent); |
2889 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2890 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2890 | } | 2891 | } |
2891 | 2892 | ||
2892 | void CalendarView::edit_copy() | 2893 | void CalendarView::edit_copy() |
2893 | { | 2894 | { |
2894 | Event *anEvent=0; | 2895 | Event *anEvent=0; |
2895 | 2896 | ||
2896 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2897 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2897 | 2898 | ||
2898 | if (mViewManager->currentView()->isEventView()) { | 2899 | if (mViewManager->currentView()->isEventView()) { |
2899 | if ( incidence && incidence->typeID() == eventID ) { | 2900 | if ( incidence && incidence->typeID() == eventID ) { |
2900 | anEvent = static_cast<Event *>(incidence); | 2901 | anEvent = static_cast<Event *>(incidence); |
2901 | } | 2902 | } |
2902 | } | 2903 | } |
2903 | 2904 | ||
2904 | if (!anEvent) { | 2905 | if (!anEvent) { |
2905 | KNotifyClient::beep(); | 2906 | KNotifyClient::beep(); |
2906 | return; | 2907 | return; |
2907 | } | 2908 | } |
2908 | DndFactory factory( mCalendar ); | 2909 | DndFactory factory( mCalendar ); |
2909 | factory.copyIncidence(anEvent); | 2910 | factory.copyIncidence(anEvent); |
2910 | } | 2911 | } |
2911 | 2912 | ||
2912 | void CalendarView::edit_paste() | 2913 | void CalendarView::edit_paste() |
2913 | { | 2914 | { |
2914 | QDate date = mNavigator->selectedDates().first(); | 2915 | QDate date = mNavigator->selectedDates().first(); |
2915 | 2916 | ||
2916 | DndFactory factory( mCalendar ); | 2917 | DndFactory factory( mCalendar ); |
2917 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2918 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2918 | 2919 | ||
2919 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2920 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2920 | } | 2921 | } |
2921 | void CalendarView::edit_global_options() | 2922 | void CalendarView::edit_global_options() |
2922 | { | 2923 | { |
2923 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2924 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2924 | emit save(); | 2925 | emit save(); |
2925 | emit saveStopTimer(); | 2926 | emit saveStopTimer(); |
2926 | mDialogManager->showGlobalOptionsDialog(); | 2927 | mDialogManager->showGlobalOptionsDialog(); |
2927 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2928 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2928 | emit saveStopTimer(); | 2929 | emit saveStopTimer(); |
2929 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2930 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2930 | i18n("Timezone settings"),i18n("Reload"))) { | 2931 | i18n("Timezone settings"),i18n("Reload"))) { |
2931 | qDebug("KO: TZ reload cancelled "); | 2932 | qDebug("KO: TZ reload cancelled "); |
2932 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2933 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2933 | return; | 2934 | return; |
2934 | } | 2935 | } |
2935 | qDebug("KO: Timezone change "); | 2936 | qDebug("KO: Timezone change "); |
2936 | loadCalendars(); | 2937 | loadCalendars(); |
2937 | setModified(true); | 2938 | setModified(true); |
2938 | } | 2939 | } |
2939 | else | 2940 | else |
2940 | qDebug("KO: No tz change "); | 2941 | qDebug("KO: No tz change "); |
2941 | } | 2942 | } |
2942 | void CalendarView::edit_options() | 2943 | void CalendarView::edit_options() |
2943 | { | 2944 | { |
2944 | mDialogManager->showOptionsDialog(); | 2945 | mDialogManager->showOptionsDialog(); |
2945 | } | 2946 | } |
2946 | 2947 | ||
2947 | 2948 | ||
2948 | void CalendarView::slotSelectPickerDate( QDate d) | 2949 | void CalendarView::slotSelectPickerDate( QDate d) |
2949 | { | 2950 | { |
2950 | mDateFrame->hide(); | 2951 | mDateFrame->hide(); |
2951 | if ( mDatePickerMode == 1 ) { | 2952 | if ( mDatePickerMode == 1 ) { |
2952 | mNavigator->slotDaySelect( d ); | 2953 | mNavigator->slotDaySelect( d ); |
2953 | } else if ( mDatePickerMode == 2 ) { | 2954 | } else if ( mDatePickerMode == 2 ) { |
2954 | if ( mMoveIncidence->typeID() == todoID ) { | 2955 | if ( mMoveIncidence->typeID() == todoID ) { |
2955 | Todo * to = (Todo *) mMoveIncidence; | 2956 | Todo * to = (Todo *) mMoveIncidence; |
2956 | QTime tim; | 2957 | QTime tim; |
2957 | int len = 0; | 2958 | int len = 0; |
2958 | if ( to->hasStartDate() && to->hasDueDate() ) | 2959 | if ( to->hasStartDate() && to->hasDueDate() ) |
2959 | len = to->dtStart().secsTo( to->dtDue()); | 2960 | len = to->dtStart().secsTo( to->dtDue()); |
2960 | if ( to->hasDueDate() ) | 2961 | if ( to->hasDueDate() ) |
2961 | tim = to->dtDue().time(); | 2962 | tim = to->dtDue().time(); |
2962 | else { | 2963 | else { |
2963 | tim = QTime ( 0,0,0 ); | 2964 | tim = QTime ( 0,0,0 ); |
2964 | to->setFloats( true ); | 2965 | to->setFloats( true ); |
2965 | to->setHasDueDate( true ); | 2966 | to->setHasDueDate( true ); |
2966 | } | 2967 | } |
2967 | QDateTime dt ( d,tim ); | 2968 | QDateTime dt ( d,tim ); |
2968 | to->setDtDue( dt ); | 2969 | to->setDtDue( dt ); |
2969 | 2970 | ||
2970 | if ( to->hasStartDate() ) { | 2971 | if ( to->hasStartDate() ) { |
2971 | if ( len>0 ) | 2972 | if ( len>0 ) |
2972 | to->setDtStart(to->dtDue().addSecs( -len )); | 2973 | to->setDtStart(to->dtDue().addSecs( -len )); |
2973 | else | 2974 | else |
2974 | if (to->dtStart() > to->dtDue() ) | 2975 | if (to->dtStart() > to->dtDue() ) |
2975 | to->setDtStart(to->dtDue().addDays( -3 )); | 2976 | to->setDtStart(to->dtDue().addDays( -3 )); |
2976 | } | 2977 | } |
2977 | 2978 | ||
2978 | todoChanged( to ); | 2979 | todoChanged( to ); |
2979 | } else if ( mMoveIncidence->typeID() == eventID ) { | 2980 | } else if ( mMoveIncidence->typeID() == eventID ) { |
2980 | if ( mMoveIncidence->doesRecur() ) { | 2981 | if ( mMoveIncidence->doesRecur() ) { |
2981 | #if 0 | 2982 | #if 0 |
2982 | // PENDING implement this | 2983 | // PENDING implement this |
2983 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2984 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2984 | mCalendar()->addIncidence( newInc ); | 2985 | mCalendar()->addIncidence( newInc ); |
2985 | if ( mMoveIncidence->typeID() == todoID ) | 2986 | if ( mMoveIncidence->typeID() == todoID ) |
2986 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2987 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2987 | else | 2988 | else |
2988 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2989 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2989 | mMoveIncidence = newInc; | 2990 | mMoveIncidence = newInc; |
2990 | 2991 | ||
2991 | #endif | 2992 | #endif |
2992 | } | 2993 | } |
2993 | QTime tim = mMoveIncidence->dtStart().time(); | 2994 | QTime tim = mMoveIncidence->dtStart().time(); |
2994 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2995 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2995 | QDateTime dt ( d,tim ); | 2996 | QDateTime dt ( d,tim ); |
2996 | mMoveIncidence->setDtStart( dt ); | 2997 | mMoveIncidence->setDtStart( dt ); |
2997 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2998 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2998 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2999 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2999 | } else if ( mMoveIncidence->typeID() == journalID ) { | 3000 | } else if ( mMoveIncidence->typeID() == journalID ) { |
3000 | QTime tim = mMoveIncidence->dtStart().time(); | 3001 | QTime tim = mMoveIncidence->dtStart().time(); |
3001 | QDateTime dt ( d,tim ); | 3002 | QDateTime dt ( d,tim ); |
3002 | mMoveIncidence->setDtStart( dt ); | 3003 | mMoveIncidence->setDtStart( dt ); |
3003 | updateView(); | 3004 | updateView(); |
3004 | } | 3005 | } |
3005 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3006 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3006 | } | 3007 | } |
3007 | } | 3008 | } |
3008 | 3009 | ||
3009 | void CalendarView::removeCategories() | 3010 | void CalendarView::removeCategories() |
3010 | { | 3011 | { |
3011 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3012 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3012 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3013 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3013 | QStringList catIncList; | 3014 | QStringList catIncList; |
3014 | QStringList newCatList; | 3015 | QStringList newCatList; |
3015 | Incidence* inc = incList.first(); | 3016 | Incidence* inc = incList.first(); |
3016 | uint i; | 3017 | uint i; |
3017 | while ( inc ) { | 3018 | while ( inc ) { |
3018 | newCatList.clear(); | 3019 | newCatList.clear(); |
3019 | catIncList = inc->categories() ; | 3020 | catIncList = inc->categories() ; |
3020 | for( i = 0; i< catIncList.count(); ++i ) { | 3021 | for( i = 0; i< catIncList.count(); ++i ) { |
3021 | if ( catList.contains (catIncList[i])) | 3022 | if ( catList.contains (catIncList[i])) |
3022 | newCatList.append( catIncList[i] ); | 3023 | newCatList.append( catIncList[i] ); |
3023 | } | 3024 | } |
3024 | newCatList.sort(); | 3025 | newCatList.sort(); |
3025 | inc->setCategories( newCatList.join(",") ); | 3026 | inc->setCategories( newCatList.join(",") ); |
3026 | inc = incList.next(); | 3027 | inc = incList.next(); |
3027 | } | 3028 | } |
3028 | } | 3029 | } |
3029 | 3030 | ||
3030 | int CalendarView::addCategories() | 3031 | int CalendarView::addCategories() |
3031 | { | 3032 | { |
3032 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3033 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3033 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3034 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3034 | QStringList catIncList; | 3035 | QStringList catIncList; |
3035 | Incidence* inc = incList.first(); | 3036 | Incidence* inc = incList.first(); |
3036 | uint i; | 3037 | uint i; |
3037 | int count = 0; | 3038 | int count = 0; |
3038 | while ( inc ) { | 3039 | while ( inc ) { |
3039 | catIncList = inc->categories() ; | 3040 | catIncList = inc->categories() ; |
3040 | for( i = 0; i< catIncList.count(); ++i ) { | 3041 | for( i = 0; i< catIncList.count(); ++i ) { |
3041 | if ( !catList.contains (catIncList[i])) { | 3042 | if ( !catList.contains (catIncList[i])) { |
3042 | catList.append( catIncList[i] ); | 3043 | catList.append( catIncList[i] ); |
3043 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3044 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3044 | ++count; | 3045 | ++count; |
3045 | } | 3046 | } |
3046 | } | 3047 | } |
3047 | inc = incList.next(); | 3048 | inc = incList.next(); |
3048 | } | 3049 | } |
3049 | catList.sort(); | 3050 | catList.sort(); |
3050 | KOPrefs::instance()->mCustomCategories = catList; | 3051 | KOPrefs::instance()->mCustomCategories = catList; |
3051 | return count; | 3052 | return count; |
3052 | } | 3053 | } |
3053 | 3054 | ||
3054 | void CalendarView::editCategories() | 3055 | void CalendarView::editCategories() |
3055 | { | 3056 | { |
3056 | qDebug("CalendarView::editCategories() "); | 3057 | qDebug("CalendarView::editCategories() "); |
3057 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3058 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3058 | ced.exec(); | 3059 | ced.exec(); |
3059 | } | 3060 | } |
3060 | void CalendarView::manageCategories() | 3061 | void CalendarView::manageCategories() |
3061 | { | 3062 | { |
3062 | KOCatPrefs* cp = new KOCatPrefs(); | 3063 | KOCatPrefs* cp = new KOCatPrefs(); |
3063 | cp->show(); | 3064 | cp->show(); |
3064 | int w =cp->sizeHint().width() ; | 3065 | int w =cp->sizeHint().width() ; |
3065 | int h = cp->sizeHint().height() ; | 3066 | int h = cp->sizeHint().height() ; |
3066 | int dw = QApplication::desktop()->width(); | 3067 | int dw = QApplication::desktop()->width(); |
3067 | int dh = QApplication::desktop()->height(); | 3068 | int dh = QApplication::desktop()->height(); |
3068 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3069 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3069 | if ( !cp->exec() ) { | 3070 | if ( !cp->exec() ) { |
3070 | delete cp; | 3071 | delete cp; |
3071 | return; | 3072 | return; |
3072 | } | 3073 | } |
3073 | int count = 0; | 3074 | int count = 0; |
3074 | if ( cp->addCat() ) { | 3075 | if ( cp->addCat() ) { |
3075 | count = addCategories(); | 3076 | count = addCategories(); |
3076 | if ( count ) { | 3077 | if ( count ) { |
3077 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3078 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3078 | writeSettings(); | 3079 | writeSettings(); |
3079 | } else | 3080 | } else |
3080 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3081 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3081 | } else { | 3082 | } else { |
3082 | removeCategories(); | 3083 | removeCategories(); |
3083 | updateView(); | 3084 | updateView(); |
3084 | } | 3085 | } |
3085 | delete cp; | 3086 | delete cp; |
3086 | } | 3087 | } |
3087 | 3088 | ||
3088 | void CalendarView::beamIncidence(Incidence * Inc) | 3089 | void CalendarView::beamIncidence(Incidence * Inc) |
3089 | { | 3090 | { |
3090 | QPtrList<Incidence> delSel ; | 3091 | QPtrList<Incidence> delSel ; |
3091 | delSel.append(Inc); | 3092 | delSel.append(Inc); |
3092 | beamIncidenceList( delSel ); | 3093 | beamIncidenceList( delSel ); |
3093 | } | 3094 | } |
3094 | void CalendarView::beamCalendar() | 3095 | void CalendarView::beamCalendar() |
3095 | { | 3096 | { |
3096 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3097 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3097 | //qDebug("beamCalendar() "); | 3098 | //qDebug("beamCalendar() "); |
3098 | beamIncidenceList( delSel ); | 3099 | beamIncidenceList( delSel ); |
3099 | } | 3100 | } |
3100 | void CalendarView::beamFilteredCalendar() | 3101 | void CalendarView::beamFilteredCalendar() |
3101 | { | 3102 | { |
3102 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3103 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3103 | //qDebug("beamFilteredCalendar() "); | 3104 | //qDebug("beamFilteredCalendar() "); |
3104 | beamIncidenceList( delSel ); | 3105 | beamIncidenceList( delSel ); |
3105 | } | 3106 | } |
3106 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3107 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3107 | { | 3108 | { |
3108 | 3109 | ||
3109 | KOBeamPrefs beamDialog; | 3110 | KOBeamPrefs beamDialog; |
3110 | if ( beamDialog.exec () == QDialog::Rejected ) | 3111 | if ( beamDialog.exec () == QDialog::Rejected ) |
3111 | return; | 3112 | return; |
3112 | #ifdef DESKTOP_VERSION | 3113 | #ifdef DESKTOP_VERSION |
3113 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3114 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3114 | #else | 3115 | #else |
3115 | QString fn = "/tmp/kopibeamfile"; | 3116 | QString fn = "/tmp/kopibeamfile"; |
3116 | #endif | 3117 | #endif |
3117 | QString mes; | 3118 | QString mes; |
3118 | bool createbup = true; | 3119 | bool createbup = true; |
3119 | if ( createbup ) { | 3120 | if ( createbup ) { |
3120 | QString description = "\n"; | 3121 | QString description = "\n"; |
3121 | CalendarLocal* cal = new CalendarLocal(); | 3122 | CalendarLocal* cal = new CalendarLocal(); |
3122 | if ( beamDialog.beamLocal() ) | 3123 | if ( beamDialog.beamLocal() ) |
3123 | cal->setLocalTime(); | 3124 | cal->setLocalTime(); |
3124 | else | 3125 | else |
3125 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3126 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3126 | Incidence *incidence = delSel.first(); | 3127 | Incidence *incidence = delSel.first(); |
3127 | bool addText = false; | 3128 | bool addText = false; |
3128 | if ( delSel.count() < 10 ) | 3129 | if ( delSel.count() < 10 ) |
3129 | addText = true; | 3130 | addText = true; |
3130 | else { | 3131 | else { |
3131 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3132 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3132 | } | 3133 | } |
3133 | while ( incidence ) { | 3134 | while ( incidence ) { |
3134 | Incidence *in = incidence->clone(); | 3135 | Incidence *in = incidence->clone(); |
3135 | if ( ! in->summary().isEmpty() ) { | 3136 | if ( ! in->summary().isEmpty() ) { |
3136 | in->setDescription(""); | 3137 | in->setDescription(""); |
3137 | } else { | 3138 | } else { |
3138 | in->setSummary( in->description().left(20)); | 3139 | in->setSummary( in->description().left(20)); |
3139 | in->setDescription(""); | 3140 | in->setDescription(""); |
3140 | } | 3141 | } |
3141 | if ( addText ) | 3142 | if ( addText ) |
3142 | description += in->summary() + "\n"; | 3143 | description += in->summary() + "\n"; |
3143 | cal->addIncidence( in ); | 3144 | cal->addIncidence( in ); |
3144 | incidence = delSel.next(); | 3145 | incidence = delSel.next(); |
3145 | } | 3146 | } |
3146 | if ( beamDialog.beamVcal() ) { | 3147 | if ( beamDialog.beamVcal() ) { |
3147 | fn += ".vcs"; | 3148 | fn += ".vcs"; |
3148 | FileStorage storage( cal, fn, new VCalFormat ); | 3149 | FileStorage storage( cal, fn, new VCalFormat ); |
3149 | storage.save(); | 3150 | storage.save(); |
3150 | } else { | 3151 | } else { |
3151 | fn += ".ics"; | 3152 | fn += ".ics"; |
3152 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3153 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3153 | storage.save(); | 3154 | storage.save(); |
3154 | } | 3155 | } |
3155 | delete cal; | 3156 | delete cal; |
3156 | mes = i18n("KO/Pi: Ready for beaming"); | 3157 | mes = i18n("KO/Pi: Ready for beaming"); |
3157 | topLevelWidget()->setCaption(mes); | 3158 | topLevelWidget()->setCaption(mes); |
3158 | KApplication::convert2latin1( fn ); | 3159 | KApplication::convert2latin1( fn ); |
3159 | #ifndef DESKTOP_VERSION | 3160 | #ifndef DESKTOP_VERSION |
3160 | Ir *ir = new Ir( this ); | 3161 | Ir *ir = new Ir( this ); |
3161 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3162 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3162 | ir->send( fn, description, "text/x-vCalendar" ); | 3163 | ir->send( fn, description, "text/x-vCalendar" ); |
3163 | #endif | 3164 | #endif |
3164 | } | 3165 | } |
3165 | } | 3166 | } |
3166 | 3167 | ||
3167 | #ifndef DESKTOP_VERSION | 3168 | #ifndef DESKTOP_VERSION |
3168 | void CalendarView::beamDone( Ir *ir ) | 3169 | void CalendarView::beamDone( Ir *ir ) |
3169 | { | 3170 | { |
3170 | delete ir; | 3171 | delete ir; |
3171 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3172 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3172 | topLevelWidget()->raise(); | 3173 | topLevelWidget()->raise(); |
3173 | } | 3174 | } |
3174 | #else | 3175 | #else |
3175 | void CalendarView::beamDone( Ir *){;} | 3176 | void CalendarView::beamDone( Ir *){;} |
3176 | #endif | 3177 | #endif |
3177 | void CalendarView::moveIncidence(Incidence * inc ) | 3178 | void CalendarView::moveIncidence(Incidence * inc ) |
3178 | { | 3179 | { |
3179 | if ( !inc ) return; | 3180 | if ( !inc ) return; |
3180 | showDatePickerPopup(); | 3181 | showDatePickerPopup(); |
3181 | mDatePickerMode = 2; | 3182 | mDatePickerMode = 2; |
3182 | mMoveIncidence = inc ; | 3183 | mMoveIncidence = inc ; |
3183 | QDate da; | 3184 | QDate da; |
3184 | if ( mMoveIncidence->typeID() == todoID ) { | 3185 | if ( mMoveIncidence->typeID() == todoID ) { |
3185 | Todo * to = (Todo *) mMoveIncidence; | 3186 | Todo * to = (Todo *) mMoveIncidence; |
3186 | if ( to->hasDueDate() ) | 3187 | if ( to->hasDueDate() ) |
3187 | da = to->dtDue().date(); | 3188 | da = to->dtDue().date(); |
3188 | else | 3189 | else |
3189 | da = QDate::currentDate(); | 3190 | da = QDate::currentDate(); |
3190 | } else { | 3191 | } else { |
3191 | da = mMoveIncidence->dtStart().date(); | 3192 | da = mMoveIncidence->dtStart().date(); |
3192 | } | 3193 | } |
3193 | //PENDING set date for recurring incidence to date of recurrence | 3194 | //PENDING set date for recurring incidence to date of recurrence |
3194 | //mMoveIncidenceOldDate; | 3195 | //mMoveIncidenceOldDate; |
3195 | mDatePicker->setDate( da ); | 3196 | mDatePicker->setDate( da ); |
3196 | } | 3197 | } |
3197 | void CalendarView::showDatePickerPopup() | 3198 | void CalendarView::showDatePickerPopup() |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 94f35e6..3ae977d 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -142,1362 +142,1369 @@ KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name | |||
142 | } | 142 | } |
143 | 143 | ||
144 | void KOStopTodoPrefs::accept() | 144 | void KOStopTodoPrefs::accept() |
145 | { | 145 | { |
146 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); | 146 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); |
147 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); | 147 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); |
148 | if ( start > stop ) { | 148 | if ( start > stop ) { |
149 | KMessageBox::sorry(this, | 149 | KMessageBox::sorry(this, |
150 | i18n("The start time is\nafter the end time!"), | 150 | i18n("The start time is\nafter the end time!"), |
151 | i18n("Time mismatch!")); | 151 | i18n("Time mismatch!")); |
152 | return; | 152 | return; |
153 | } | 153 | } |
154 | mTodo->saveRunningInfo( mComment->text(), start, stop ); | 154 | mTodo->saveRunningInfo( mComment->text(), start, stop ); |
155 | QDialog::accept(); | 155 | QDialog::accept(); |
156 | } | 156 | } |
157 | void KOStopTodoPrefs::doNotSave() | 157 | void KOStopTodoPrefs::doNotSave() |
158 | { | 158 | { |
159 | int result = KMessageBox::warningContinueCancel(this, | 159 | int result = KMessageBox::warningContinueCancel(this, |
160 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); | 160 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); |
161 | if (result != KMessageBox::Continue) return; | 161 | if (result != KMessageBox::Continue) return; |
162 | mTodo->stopRunning(); | 162 | mTodo->stopRunning(); |
163 | QDialog::accept(); | 163 | QDialog::accept(); |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | class KOTodoViewWhatsThis :public QWhatsThis | 167 | class KOTodoViewWhatsThis :public QWhatsThis |
168 | { | 168 | { |
169 | public: | 169 | public: |
170 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 170 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
171 | 171 | ||
172 | protected: | 172 | protected: |
173 | virtual QString text( const QPoint& p) | 173 | virtual QString text( const QPoint& p) |
174 | { | 174 | { |
175 | return _view->getWhatsThisText(p) ; | 175 | return _view->getWhatsThisText(p) ; |
176 | } | 176 | } |
177 | private: | 177 | private: |
178 | QWidget* _wid; | 178 | QWidget* _wid; |
179 | KOTodoView * _view; | 179 | KOTodoView * _view; |
180 | }; | 180 | }; |
181 | 181 | ||
182 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 182 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
183 | const char *name) : | 183 | const char *name) : |
184 | KListView(parent,name) | 184 | KListView(parent,name) |
185 | { | 185 | { |
186 | mName = QString ( name ); | 186 | mName = QString ( name ); |
187 | mCalendar = calendar; | 187 | mCalendar = calendar; |
188 | #ifndef DESKTOP_VERSION | 188 | #ifndef DESKTOP_VERSION |
189 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 189 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
190 | #endif | 190 | #endif |
191 | mOldCurrent = 0; | 191 | mOldCurrent = 0; |
192 | mMousePressed = false; | 192 | mMousePressed = false; |
193 | 193 | ||
194 | setAcceptDrops(true); | 194 | setAcceptDrops(true); |
195 | viewport()->setAcceptDrops(true); | 195 | viewport()->setAcceptDrops(true); |
196 | int size = 16; | 196 | int size = 16; |
197 | if (qApp->desktop()->width() < 300 ) | 197 | if (qApp->desktop()->width() < 300 ) |
198 | size = 12; | 198 | size = 12; |
199 | setTreeStepSize( size + 6 ); | 199 | setTreeStepSize( size + 6 ); |
200 | 200 | ||
201 | } | 201 | } |
202 | 202 | ||
203 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 203 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
204 | { | 204 | { |
205 | #ifndef KORG_NODND | 205 | #ifndef KORG_NODND |
206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
208 | !QTextDrag::canDecode( e ) ) { | 208 | !QTextDrag::canDecode( e ) ) { |
209 | e->ignore(); | 209 | e->ignore(); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | 212 | ||
213 | mOldCurrent = currentItem(); | 213 | mOldCurrent = currentItem(); |
214 | #endif | 214 | #endif |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
219 | { | 219 | { |
220 | #ifndef KORG_NODND | 220 | #ifndef KORG_NODND |
221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
222 | 222 | ||
223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
224 | !QTextDrag::canDecode( e ) ) { | 224 | !QTextDrag::canDecode( e ) ) { |
225 | e->ignore(); | 225 | e->ignore(); |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | 228 | ||
229 | e->accept(); | 229 | e->accept(); |
230 | #endif | 230 | #endif |
231 | } | 231 | } |
232 | 232 | ||
233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
234 | { | 234 | { |
235 | #ifndef KORG_NODND | 235 | #ifndef KORG_NODND |
236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
237 | 237 | ||
238 | setCurrentItem(mOldCurrent); | 238 | setCurrentItem(mOldCurrent); |
239 | setSelected(mOldCurrent,true); | 239 | setSelected(mOldCurrent,true); |
240 | #endif | 240 | #endif |
241 | } | 241 | } |
242 | 242 | ||
243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
244 | { | 244 | { |
245 | #ifndef KORG_NODND | 245 | #ifndef KORG_NODND |
246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
247 | 247 | ||
248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
249 | !QTextDrag::canDecode( e ) ) { | 249 | !QTextDrag::canDecode( e ) ) { |
250 | e->ignore(); | 250 | e->ignore(); |
251 | return; | 251 | return; |
252 | } | 252 | } |
253 | 253 | ||
254 | DndFactory factory( mCalendar ); | 254 | DndFactory factory( mCalendar ); |
255 | Todo *todo = factory.createDropTodo(e); | 255 | Todo *todo = factory.createDropTodo(e); |
256 | 256 | ||
257 | if (todo) { | 257 | if (todo) { |
258 | e->acceptAction(); | 258 | e->acceptAction(); |
259 | 259 | ||
260 | KOTodoViewItem *destination = | 260 | KOTodoViewItem *destination = |
261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
262 | Todo *destinationEvent = 0; | 262 | Todo *destinationEvent = 0; |
263 | if (destination) destinationEvent = destination->todo(); | 263 | if (destination) destinationEvent = destination->todo(); |
264 | 264 | ||
265 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 265 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
266 | 266 | ||
267 | if(existingTodo) { | 267 | if(existingTodo) { |
268 | Incidence *to = destinationEvent; | 268 | Incidence *to = destinationEvent; |
269 | while(to) { | 269 | while(to) { |
270 | if (to->uid() == todo->uid()) { | 270 | if (to->uid() == todo->uid()) { |
271 | KMessageBox::sorry(this, | 271 | KMessageBox::sorry(this, |
272 | i18n("Cannot move Todo to itself\nor a child of itself"), | 272 | i18n("Cannot move Todo to itself\nor a child of itself"), |
273 | i18n("Drop Todo")); | 273 | i18n("Drop Todo")); |
274 | delete todo; | 274 | delete todo; |
275 | return; | 275 | return; |
276 | } | 276 | } |
277 | to = to->relatedTo(); | 277 | to = to->relatedTo(); |
278 | } | 278 | } |
279 | internalDrop = true; | 279 | internalDrop = true; |
280 | if ( destinationEvent ) | 280 | if ( destinationEvent ) |
281 | reparentTodoSignal( destinationEvent, existingTodo ); | 281 | reparentTodoSignal( destinationEvent, existingTodo ); |
282 | else | 282 | else |
283 | unparentTodoSignal(existingTodo); | 283 | unparentTodoSignal(existingTodo); |
284 | delete todo; | 284 | delete todo; |
285 | } else { | 285 | } else { |
286 | mCalendar->addTodo(todo); | 286 | mCalendar->addTodo(todo); |
287 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 287 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
288 | if ( destinationEvent ) | 288 | if ( destinationEvent ) |
289 | reparentTodoSignal( destinationEvent, todo ); | 289 | reparentTodoSignal( destinationEvent, todo ); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | else { | 292 | else { |
293 | QString text; | 293 | QString text; |
294 | if (QTextDrag::decode(e,text)) { | 294 | if (QTextDrag::decode(e,text)) { |
295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
297 | qDebug("Dropped : " + text); | 297 | qDebug("Dropped : " + text); |
298 | QStringList emails = QStringList::split(",",text); | 298 | QStringList emails = QStringList::split(",",text); |
299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
300 | int pos = (*it).find("<"); | 300 | int pos = (*it).find("<"); |
301 | QString name = (*it).left(pos); | 301 | QString name = (*it).left(pos); |
302 | QString email = (*it).mid(pos); | 302 | QString email = (*it).mid(pos); |
303 | if (!email.isEmpty() && todoi) { | 303 | if (!email.isEmpty() && todoi) { |
304 | todoi->todo()->addAttendee(new Attendee(name,email)); | 304 | todoi->todo()->addAttendee(new Attendee(name,email)); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
308 | else { | 308 | else { |
309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
310 | e->ignore(); | 310 | e->ignore(); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | #endif | 313 | #endif |
314 | } | 314 | } |
315 | void KOTodoListView::wheelEvent (QWheelEvent *e) | 315 | void KOTodoListView::wheelEvent (QWheelEvent *e) |
316 | { | 316 | { |
317 | QListView::wheelEvent (e); | 317 | QListView::wheelEvent (e); |
318 | } | 318 | } |
319 | 319 | ||
320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
321 | { | 321 | { |
322 | 322 | ||
323 | QPoint p(contentsToViewport(e->pos())); | 323 | QPoint p(contentsToViewport(e->pos())); |
324 | QListViewItem *i = itemAt(p); | 324 | QListViewItem *i = itemAt(p); |
325 | bool rootClicked = true; | 325 | bool rootClicked = true; |
326 | if (i) { | 326 | if (i) { |
327 | // if the user clicked into the root decoration of the item, don't | 327 | // if the user clicked into the root decoration of the item, don't |
328 | // try to start a drag! | 328 | // try to start a drag! |
329 | int X = p.x(); | 329 | int X = p.x(); |
330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); | 330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); |
331 | if (X > header()->sectionPos(0) + | 331 | if (X > header()->sectionPos(0) + |
332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
333 | itemMargin() +i->height()|| | 333 | itemMargin() +i->height()|| |
334 | X < header()->sectionPos(0)) { | 334 | X < header()->sectionPos(0)) { |
335 | rootClicked = false; | 335 | rootClicked = false; |
336 | } | 336 | } |
337 | } else { | 337 | } else { |
338 | rootClicked = false; | 338 | rootClicked = false; |
339 | } | 339 | } |
340 | #ifndef KORG_NODND | 340 | #ifndef KORG_NODND |
341 | mMousePressed = false; | 341 | mMousePressed = false; |
342 | if (! rootClicked && !( e->button() == RightButton) ) { | 342 | if (! rootClicked && !( e->button() == RightButton) ) { |
343 | mPressPos = e->pos(); | 343 | mPressPos = e->pos(); |
344 | mMousePressed = true; | 344 | mMousePressed = true; |
345 | } else { | 345 | } else { |
346 | mMousePressed = false; | 346 | mMousePressed = false; |
347 | } | 347 | } |
348 | #endif | 348 | #endif |
349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); | 349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); |
350 | #ifndef DESKTOP_VERSION | 350 | #ifndef DESKTOP_VERSION |
351 | if (!( e->button() == RightButton && rootClicked) ) | 351 | if (!( e->button() == RightButton && rootClicked) ) |
352 | QListView::contentsMousePressEvent(e); | 352 | QListView::contentsMousePressEvent(e); |
353 | #else | 353 | #else |
354 | QListView::contentsMousePressEvent(e); | 354 | QListView::contentsMousePressEvent(e); |
355 | #endif | 355 | #endif |
356 | } | 356 | } |
357 | void KOTodoListView::paintEvent(QPaintEvent* e) | 357 | void KOTodoListView::paintEvent(QPaintEvent* e) |
358 | { | 358 | { |
359 | emit paintNeeded(); | 359 | emit paintNeeded(); |
360 | QListView::paintEvent( e); | 360 | QListView::paintEvent( e); |
361 | } | 361 | } |
362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
363 | { | 363 | { |
364 | 364 | ||
365 | #ifndef KORG_NODND | 365 | #ifndef KORG_NODND |
366 | //QListView::contentsMouseMoveEvent(e); | 366 | //QListView::contentsMouseMoveEvent(e); |
367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
368 | QApplication::startDragDistance()*3) { | 368 | QApplication::startDragDistance()*3) { |
369 | mMousePressed = false; | 369 | mMousePressed = false; |
370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
371 | if (item) { | 371 | if (item) { |
372 | DndFactory factory( mCalendar ); | 372 | DndFactory factory( mCalendar ); |
373 | ICalDrag *vd = factory.createDrag( | 373 | ICalDrag *vd = factory.createDrag( |
374 | ((KOTodoViewItem *)item)->todo(),viewport()); | 374 | ((KOTodoViewItem *)item)->todo(),viewport()); |
375 | internalDrop = false; | 375 | internalDrop = false; |
376 | // we cannot do any senseful here, because the DnD is still broken in Qt | 376 | // we cannot do any senseful here, because the DnD is still broken in Qt |
377 | if (vd->drag()) { | 377 | if (vd->drag()) { |
378 | if ( !internalDrop ) { | 378 | if ( !internalDrop ) { |
379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
380 | qDebug("Dnd: External move: Delete drag source "); | 380 | qDebug("Dnd: External move: Delete drag source "); |
381 | } else | 381 | } else |
382 | qDebug("Dnd: Internal move "); | 382 | qDebug("Dnd: Internal move "); |
383 | 383 | ||
384 | } else { | 384 | } else { |
385 | if ( !internalDrop ) { | 385 | if ( !internalDrop ) { |
386 | qDebug("Dnd: External Copy"); | 386 | qDebug("Dnd: External Copy"); |
387 | } else | 387 | } else |
388 | qDebug("DnD: Internal copy: Copy pending"); | 388 | qDebug("DnD: Internal copy: Copy pending"); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | } | 391 | } |
392 | #endif | 392 | #endif |
393 | } | 393 | } |
394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) | 394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) |
395 | { | 395 | { |
396 | if ( !e->isAutoRepeat() ) { | 396 | if ( !e->isAutoRepeat() ) { |
397 | mFlagKeyPressed = false; | 397 | mFlagKeyPressed = false; |
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
403 | { | 403 | { |
404 | qApp->processEvents(); | 404 | qApp->processEvents(); |
405 | if ( !isVisible() ) { | 405 | if ( !isVisible() ) { |
406 | e->ignore(); | 406 | e->ignore(); |
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 409 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
410 | e->ignore(); | 410 | e->ignore(); |
411 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 411 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
412 | return; | 412 | return; |
413 | } | 413 | } |
414 | if (! e->isAutoRepeat() ) | 414 | if (! e->isAutoRepeat() ) |
415 | mFlagKeyPressed = true; | 415 | mFlagKeyPressed = true; |
416 | QListViewItem* cn; | 416 | QListViewItem* cn; |
417 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 417 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
418 | cn = currentItem(); | 418 | cn = currentItem(); |
419 | if ( cn ) { | 419 | if ( cn ) { |
420 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 420 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
421 | if ( ci ){ | 421 | if ( ci ){ |
422 | if ( e->state() == ShiftButton ) | 422 | if ( e->state() == ShiftButton ) |
423 | ci->setOn( false ); | 423 | ci->setOn( false ); |
424 | else | 424 | else |
425 | ci->setOn( true ); | 425 | ci->setOn( true ); |
426 | cn = cn->itemBelow(); | 426 | cn = cn->itemBelow(); |
427 | if ( cn ) { | 427 | if ( cn ) { |
428 | setCurrentItem ( cn ); | 428 | setCurrentItem ( cn ); |
429 | ensureItemVisible ( cn ); | 429 | ensureItemVisible ( cn ); |
430 | } | 430 | } |
431 | 431 | ||
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | e->accept(); | 435 | e->accept(); |
436 | return; | 436 | return; |
437 | } | 437 | } |
438 | 438 | ||
439 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 439 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
440 | switch ( e->key() ) { | 440 | switch ( e->key() ) { |
441 | case Qt::Key_Down: | 441 | case Qt::Key_Down: |
442 | case Qt::Key_Up: | 442 | case Qt::Key_Up: |
443 | QListView::keyPressEvent ( e ); | 443 | QListView::keyPressEvent ( e ); |
444 | e->accept(); | 444 | e->accept(); |
445 | break; | 445 | break; |
446 | case Qt::Key_Left: | 446 | case Qt::Key_Left: |
447 | case Qt::Key_Right: | 447 | case Qt::Key_Right: |
448 | QListView::keyPressEvent ( e ); | 448 | QListView::keyPressEvent ( e ); |
449 | e->accept(); | 449 | e->accept(); |
450 | return; | 450 | return; |
451 | break; | 451 | break; |
452 | default: | 452 | default: |
453 | e->ignore(); | 453 | e->ignore(); |
454 | break; | 454 | break; |
455 | } | 455 | } |
456 | return; | 456 | return; |
457 | } | 457 | } |
458 | e->ignore(); | 458 | e->ignore(); |
459 | } | 459 | } |
460 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 460 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
461 | { | 461 | { |
462 | QListView::contentsMouseReleaseEvent(e); | 462 | QListView::contentsMouseReleaseEvent(e); |
463 | mMousePressed = false; | 463 | mMousePressed = false; |
464 | } | 464 | } |
465 | 465 | ||
466 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 466 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
467 | { | 467 | { |
468 | if (!e) return; | 468 | if (!e) return; |
469 | 469 | ||
470 | QPoint vp = contentsToViewport(e->pos()); | 470 | QPoint vp = contentsToViewport(e->pos()); |
471 | 471 | ||
472 | QListViewItem *item = itemAt(vp); | 472 | QListViewItem *item = itemAt(vp); |
473 | 473 | ||
474 | emit double_Clicked(item); | 474 | emit double_Clicked(item); |
475 | if (!item) return; | 475 | if (!item) return; |
476 | 476 | ||
477 | emit doubleClicked(item,vp,0); | 477 | emit doubleClicked(item,vp,0); |
478 | } | 478 | } |
479 | 479 | ||
480 | ///////////////////////////////////////////////////////////////////////////// | 480 | ///////////////////////////////////////////////////////////////////////////// |
481 | 481 | ||
482 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 482 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
483 | QLineEdit(parent) | 483 | QLineEdit(parent) |
484 | { | 484 | { |
485 | setText(i18n("Click to add new Todo")); | 485 | setText(i18n("Click to add new Todo")); |
486 | } | 486 | } |
487 | 487 | ||
488 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 488 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
489 | { | 489 | { |
490 | if ( text()==i18n("Click to add new Todo") ) | 490 | if ( text()==i18n("Click to add new Todo") ) |
491 | setText(""); | 491 | setText(""); |
492 | QLineEdit::focusInEvent(ev); | 492 | QLineEdit::focusInEvent(ev); |
493 | } | 493 | } |
494 | 494 | ||
495 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 495 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
496 | { | 496 | { |
497 | setText(i18n("Click to add new Todo")); | 497 | setText(i18n("Click to add new Todo")); |
498 | QLineEdit::focusOutEvent(ev); | 498 | QLineEdit::focusOutEvent(ev); |
499 | } | 499 | } |
500 | 500 | ||
501 | ///////////////////////////////////////////////////////////////////////////// | 501 | ///////////////////////////////////////////////////////////////////////////// |
502 | 502 | ||
503 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 503 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
504 | KOrg::BaseView(calendar,parent,name) | 504 | KOrg::BaseView(calendar,parent,name) |
505 | { | 505 | { |
506 | mCategoryPopupMenu = 0; | 506 | mCategoryPopupMenu = 0; |
507 | mPendingUpdateBeforeRepaint = false; | 507 | mPendingUpdateBeforeRepaint = false; |
508 | isFlatDisplay = false; | 508 | isFlatDisplay = false; |
509 | mNavigator = 0; | 509 | mNavigator = 0; |
510 | QBoxLayout *topLayout = new QVBoxLayout(this); | 510 | QBoxLayout *topLayout = new QVBoxLayout(this); |
511 | mName = QString ( name ); | 511 | mName = QString ( name ); |
512 | mBlockUpdate = false; | 512 | mBlockUpdate = false; |
513 | mQuickBar = new QWidget( this ); | 513 | mQuickBar = new QWidget( this ); |
514 | topLayout->addWidget(mQuickBar); | 514 | topLayout->addWidget(mQuickBar); |
515 | 515 | ||
516 | mQuickAdd = new KOQuickTodo(mQuickBar); | 516 | mQuickAdd = new KOQuickTodo(mQuickBar); |
517 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); | 517 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); |
518 | quickLayout->addWidget( mQuickAdd ); | 518 | quickLayout->addWidget( mQuickAdd ); |
519 | mNewSubBut = new QPushButton( "sub",mQuickBar ); | 519 | mNewSubBut = new QPushButton( "sub",mQuickBar ); |
520 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); | 520 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); |
521 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); | 521 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); |
522 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); | 522 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); |
523 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); | 523 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); |
524 | QPushButton * flat = new QPushButton( "F",mQuickBar ); | 524 | QPushButton * flat = new QPushButton( "F",mQuickBar ); |
525 | 525 | ||
526 | int fixwid = flat->sizeHint().height(); | 526 | int fixwid = mQuickAdd->sizeHint().height(); |
527 | if ( QApplication::desktop()->width() >= 800 ) | 527 | if ( QApplication::desktop()->width() > 800 ) |
528 | fixwid *= 2; | 528 | fixwid *= 2; |
529 | flat->setFixedWidth( fixwid ); | ||
530 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); | 529 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); |
531 | allopen->setFixedWidth( fixwid ); | ||
532 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); | 530 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); |
533 | allclose->setFixedWidth( fixwid ); | ||
534 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); | 531 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); |
535 | s_done->setPixmap( SmallIcon("greenhook16")); | 532 | s_done->setPixmap( SmallIcon("greenhook16")); |
536 | s_done->setFixedWidth( fixwid ); | ||
537 | s_done->setFixedHeight( flat->sizeHint().height() ); | 533 | s_done->setFixedHeight( flat->sizeHint().height() ); |
538 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); | 534 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); |
539 | s_run->setPixmap( SmallIcon("ko16old")); | 535 | s_run->setPixmap( SmallIcon("ko16old")); |
540 | s_run->setFixedWidth( fixwid ); | ||
541 | s_run->setFixedHeight( flat->sizeHint().height() ); | ||
542 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); | 536 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); |
543 | 537 | ||
544 | mNewSubBut->setFixedWidth( fixwid*3/2 ); | ||
545 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); | 538 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); |
539 | |||
540 | mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); | ||
546 | mNewSubBut->setEnabled( false ); | 541 | mNewSubBut->setEnabled( false ); |
542 | flat->setFixedWidth( fixwid ); | ||
543 | s_done->setFixedWidth( fixwid ); | ||
544 | allopen->setFixedWidth( fixwid ); | ||
545 | allclose->setFixedWidth( fixwid ); | ||
546 | s_run->setFixedWidth( fixwid ); | ||
547 | if ( QApplication::desktop()->width() < 800 ) { | ||
548 | flat->setFixedHeight( fixwid ); | ||
549 | s_done->setFixedHeight( fixwid ); | ||
550 | allopen->setFixedHeight( fixwid ); | ||
551 | allclose->setFixedHeight( fixwid ); | ||
552 | s_run->setFixedHeight( fixwid ); | ||
553 | mNewSubBut->setFixedHeight( fixwid ); | ||
554 | } | ||
547 | quickLayout->addWidget( mNewSubBut ); | 555 | quickLayout->addWidget( mNewSubBut ); |
548 | quickLayout->addWidget( s_done ); | 556 | quickLayout->addWidget( s_done ); |
549 | quickLayout->addWidget( s_run ); | 557 | quickLayout->addWidget( s_run ); |
550 | |||
551 | quickLayout->addWidget( allopen ); | 558 | quickLayout->addWidget( allopen ); |
552 | quickLayout->addWidget( allclose ); | 559 | quickLayout->addWidget( allclose ); |
553 | quickLayout->addWidget( flat ); | 560 | quickLayout->addWidget( flat ); |
554 | 561 | ||
555 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); | 562 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); |
556 | 563 | ||
557 | mTodoListView = new KOTodoListView(calendar,this, name ); | 564 | mTodoListView = new KOTodoListView(calendar,this, name ); |
558 | topLayout->addWidget(mTodoListView); | 565 | topLayout->addWidget(mTodoListView); |
559 | //mTodoListView->header()->setMaximumHeight(30); | 566 | //mTodoListView->header()->setMaximumHeight(30); |
560 | mTodoListView->setRootIsDecorated(true); | 567 | mTodoListView->setRootIsDecorated(true); |
561 | mTodoListView->setAllColumnsShowFocus(true); | 568 | mTodoListView->setAllColumnsShowFocus(true); |
562 | 569 | ||
563 | mTodoListView->setShowSortIndicator(true); | 570 | mTodoListView->setShowSortIndicator(true); |
564 | 571 | ||
565 | mTodoListView->addColumn(i18n("Todo")); | 572 | mTodoListView->addColumn(i18n("Todo")); |
566 | mTodoListView->addColumn(i18n("Prio")); | 573 | mTodoListView->addColumn(i18n("Prio")); |
567 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 574 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
568 | mTodoListView->addColumn(i18n("Complete")); | 575 | mTodoListView->addColumn(i18n("Complete")); |
569 | mTodoListView->setColumnAlignment(2,AlignCenter); | 576 | mTodoListView->setColumnAlignment(2,AlignCenter); |
570 | 577 | ||
571 | mTodoListView->addColumn(i18n("Due Date")); | 578 | mTodoListView->addColumn(i18n("Due Date")); |
572 | mTodoListView->setColumnAlignment(3,AlignLeft); | 579 | mTodoListView->setColumnAlignment(3,AlignLeft); |
573 | mTodoListView->addColumn(i18n("Due Time")); | 580 | mTodoListView->addColumn(i18n("Due Time")); |
574 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 581 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
575 | 582 | ||
576 | mTodoListView->addColumn(i18n("Start Date")); | 583 | mTodoListView->addColumn(i18n("Start Date")); |
577 | mTodoListView->setColumnAlignment(5,AlignLeft); | 584 | mTodoListView->setColumnAlignment(5,AlignLeft); |
578 | mTodoListView->addColumn(i18n("Start Time")); | 585 | mTodoListView->addColumn(i18n("Start Time")); |
579 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 586 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
580 | 587 | ||
581 | //mTodoListView->addColumn(i18n("Cancelled")); | 588 | //mTodoListView->addColumn(i18n("Cancelled")); |
582 | mTodoListView->addColumn(i18n("Categories")); | 589 | mTodoListView->addColumn(i18n("Categories")); |
583 | mTodoListView->addColumn(i18n("Calendar")); | 590 | mTodoListView->addColumn(i18n("Calendar")); |
584 | mTodoListView->addColumn(i18n("Last Modified")); | 591 | mTodoListView->addColumn(i18n("Last Modified")); |
585 | mTodoListView->addColumn(i18n("Created")); | 592 | mTodoListView->addColumn(i18n("Created")); |
586 | mTodoListView->addColumn(i18n("Last Modified Sub")); | 593 | mTodoListView->addColumn(i18n("Last Modified Sub")); |
587 | #if 0 | 594 | #if 0 |
588 | mTodoListView->addColumn(i18n("Sort Id")); | 595 | mTodoListView->addColumn(i18n("Sort Id")); |
589 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 596 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
590 | #endif | 597 | #endif |
591 | 598 | ||
592 | mTodoListView->setMinimumHeight( 60 ); | 599 | mTodoListView->setMinimumHeight( 60 ); |
593 | mTodoListView->setItemsRenameable( true ); | 600 | mTodoListView->setItemsRenameable( true ); |
594 | mTodoListView->setRenameable( 0 ); | 601 | mTodoListView->setRenameable( 0 ); |
595 | mTodoListView->setColumnWidth( 0, 120 ); | 602 | mTodoListView->setColumnWidth( 0, 120 ); |
596 | int iii = 0; | 603 | int iii = 0; |
597 | for ( iii = 0; iii< 12 ; ++iii ) | 604 | for ( iii = 0; iii< 12 ; ++iii ) |
598 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); | 605 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); |
599 | 606 | ||
600 | 607 | ||
601 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 608 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
602 | 609 | ||
603 | mPriorityPopupMenu = new QPopupMenu(this); | 610 | mPriorityPopupMenu = new QPopupMenu(this); |
604 | for (int i = 1; i <= 5; i++) { | 611 | for (int i = 1; i <= 5; i++) { |
605 | QString label = QString ("%1").arg (i); | 612 | QString label = QString ("%1").arg (i); |
606 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 613 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
607 | } | 614 | } |
608 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 615 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
609 | 616 | ||
610 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 617 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
611 | for (int i = 0; i <= 100; i+=20) { | 618 | for (int i = 0; i <= 100; i+=20) { |
612 | QString label = QString ("%1 %").arg (i); | 619 | QString label = QString ("%1 %").arg (i); |
613 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 620 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
614 | } | 621 | } |
615 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 622 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
616 | 623 | ||
617 | 624 | ||
618 | mCategoryPopupMenu = new QPopupMenu (this); | 625 | mCategoryPopupMenu = new QPopupMenu (this); |
619 | mCategoryPopupMenu->setCheckable (true); | 626 | mCategoryPopupMenu->setCheckable (true); |
620 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 627 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
621 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); | 628 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); |
622 | 629 | ||
623 | mCalPopupMenu = new QPopupMenu (this); | 630 | mCalPopupMenu = new QPopupMenu (this); |
624 | mCalPopupMenu->setCheckable (true); | 631 | mCalPopupMenu->setCheckable (true); |
625 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); | 632 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); |
626 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); | 633 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); |
627 | 634 | ||
628 | 635 | ||
629 | 636 | ||
630 | 637 | ||
631 | mItemPopupMenu = new QPopupMenu(this); | 638 | mItemPopupMenu = new QPopupMenu(this); |
632 | mItemPopupMenu->insertItem(i18n("Show"), this, | 639 | mItemPopupMenu->insertItem(i18n("Show"), this, |
633 | SLOT (showTodo())); | 640 | SLOT (showTodo())); |
634 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 641 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
635 | SLOT (editTodo())); | 642 | SLOT (editTodo())); |
636 | mItemPopupMenu->insertItem( i18n("Delete..."), this, | 643 | mItemPopupMenu->insertItem( i18n("Delete..."), this, |
637 | SLOT (deleteTodo())); | 644 | SLOT (deleteTodo())); |
638 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 645 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
639 | SLOT (cloneTodo())); | 646 | SLOT (cloneTodo())); |
640 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 647 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
641 | SLOT (moveTodo())); | 648 | SLOT (moveTodo())); |
642 | #ifndef DESKTOP_VERSION | 649 | #ifndef DESKTOP_VERSION |
643 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 650 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
644 | SLOT (beamTodo())); | 651 | SLOT (beamTodo())); |
645 | #endif | 652 | #endif |
646 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 653 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
647 | SLOT (cancelTodo())); | 654 | SLOT (cancelTodo())); |
648 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); | 655 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); |
649 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); | 656 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); |
650 | mItemPopupMenu->insertSeparator(); | 657 | mItemPopupMenu->insertSeparator(); |
651 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 658 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
652 | SLOT (toggleRunningItem())); | 659 | SLOT (toggleRunningItem())); |
653 | mItemPopupMenu->insertSeparator(); | 660 | mItemPopupMenu->insertSeparator(); |
654 | /* | 661 | /* |
655 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 662 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
656 | SLOT (newTodo())); | 663 | SLOT (newTodo())); |
657 | */ | 664 | */ |
658 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 665 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
659 | SLOT (newSubTodo())); | 666 | SLOT (newSubTodo())); |
660 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 667 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
661 | SLOT (unparentTodo()),0,21); | 668 | SLOT (unparentTodo()),0,21); |
662 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 669 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
663 | SLOT (reparentTodo()),0,22); | 670 | SLOT (reparentTodo()),0,22); |
664 | mItemPopupMenu->insertSeparator(); | 671 | mItemPopupMenu->insertSeparator(); |
665 | #if 0 | 672 | #if 0 |
666 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), | 673 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), |
667 | this, SLOT( purgeCompleted() ) ); | 674 | this, SLOT( purgeCompleted() ) ); |
668 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 675 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
669 | this, SLOT( toggleCompleted() ),0, 33 ); | 676 | this, SLOT( toggleCompleted() ),0, 33 ); |
670 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 677 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
671 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 678 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
672 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 679 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
673 | this, SLOT( toggleRunning() ),0, 35 ); | 680 | this, SLOT( toggleRunning() ),0, 35 ); |
674 | 681 | ||
675 | #endif | 682 | #endif |
676 | mPopupMenu = new QPopupMenu(this); | 683 | mPopupMenu = new QPopupMenu(this); |
677 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 684 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
678 | SLOT (newTodo()),0,1); | 685 | SLOT (newTodo()),0,1); |
679 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), | 686 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), |
680 | this, SLOT(purgeCompleted()),0,2); | 687 | this, SLOT(purgeCompleted()),0,2); |
681 | mPopupMenu->insertItem(i18n("Show Completed"), | 688 | mPopupMenu->insertItem(i18n("Show Completed"), |
682 | this, SLOT( toggleCompleted() ),0,3 ); | 689 | this, SLOT( toggleCompleted() ),0,3 ); |
683 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 690 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
684 | this, SLOT( toggleRunning() ),0,5 ); | 691 | this, SLOT( toggleRunning() ),0,5 ); |
685 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 692 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
686 | this, SLOT( setAllOpen() ),0,6 ); | 693 | this, SLOT( setAllOpen() ),0,6 ); |
687 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 694 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
688 | this, SLOT( setAllClose() ),0,7 ); | 695 | this, SLOT( setAllClose() ),0,7 ); |
689 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 696 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
690 | this, SLOT( setAllFlat() ),0,8 ); | 697 | this, SLOT( setAllFlat() ),0,8 ); |
691 | mPopupMenu->insertSeparator(); | 698 | mPopupMenu->insertSeparator(); |
692 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 699 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
693 | this, SLOT( toggleQuickTodo() ),0,4 ); | 700 | this, SLOT( toggleQuickTodo() ),0,4 ); |
694 | mDocPrefs = new DocPrefs( name ); | 701 | mDocPrefs = new DocPrefs( name ); |
695 | 702 | ||
696 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 703 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
697 | mPopupMenu->setCheckable( true ); | 704 | mPopupMenu->setCheckable( true ); |
698 | mItemPopupMenu->setCheckable( true ); | 705 | mItemPopupMenu->setCheckable( true ); |
699 | 706 | ||
700 | 707 | ||
701 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 708 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
702 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 709 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
703 | 710 | ||
704 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 711 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
705 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 712 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
706 | 713 | ||
707 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 714 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
708 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 715 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
709 | 716 | ||
710 | 717 | ||
711 | // Double clicking conflicts with opening/closing the subtree | 718 | // Double clicking conflicts with opening/closing the subtree |
712 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 719 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
713 | SLOT( editItem( QListViewItem *) ) ); | 720 | SLOT( editItem( QListViewItem *) ) ); |
714 | /* | 721 | /* |
715 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 722 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
716 | const QPoint &,int ) ), | 723 | const QPoint &,int ) ), |
717 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 724 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
718 | */ | 725 | */ |
719 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 726 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
720 | const QPoint &,int ) ), | 727 | const QPoint &,int ) ), |
721 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 728 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
722 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 729 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
723 | SLOT( itemClicked( QListViewItem * ) ) ); | 730 | SLOT( itemClicked( QListViewItem * ) ) ); |
724 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 731 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
725 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 732 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
726 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 733 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
727 | SLOT( updateView() ) ); | 734 | SLOT( updateView() ) ); |
728 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 735 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
729 | SLOT( todoModified(Todo *, int) ) ); | 736 | SLOT( todoModified(Todo *, int) ) ); |
730 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 737 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
731 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 738 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
732 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 739 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
733 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 740 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
734 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 741 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
735 | SLOT( paintNeeded()) ); | 742 | SLOT( paintNeeded()) ); |
736 | 743 | ||
737 | #if 0 | 744 | #if 0 |
738 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 745 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
739 | SLOT(selectionChanged(QListViewItem *))); | 746 | SLOT(selectionChanged(QListViewItem *))); |
740 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 747 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
741 | SLOT(selectionChanged(QListViewItem *))); | 748 | SLOT(selectionChanged(QListViewItem *))); |
742 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 749 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
743 | SLOT(selectionChanged(QListViewItem *))); | 750 | SLOT(selectionChanged(QListViewItem *))); |
744 | #endif | 751 | #endif |
745 | 752 | ||
746 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 753 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
747 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 754 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
748 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 755 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
749 | 756 | ||
750 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 757 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
751 | SLOT( processSelectionChange() ) ); | 758 | SLOT( processSelectionChange() ) ); |
752 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 759 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
753 | SLOT( addQuickTodo() ) ); | 760 | SLOT( addQuickTodo() ) ); |
754 | 761 | ||
755 | } | 762 | } |
756 | 763 | ||
757 | KOTodoView::~KOTodoView() | 764 | KOTodoView::~KOTodoView() |
758 | { | 765 | { |
759 | 766 | ||
760 | #if QT_VERSION >= 0x030000 | 767 | #if QT_VERSION >= 0x030000 |
761 | 768 | ||
762 | #else | 769 | #else |
763 | delete mKOTodoViewWhatsThis; | 770 | delete mKOTodoViewWhatsThis; |
764 | #endif | 771 | #endif |
765 | 772 | ||
766 | delete mDocPrefs; | 773 | delete mDocPrefs; |
767 | } | 774 | } |
768 | QString KOTodoView::getWhatsThisText(QPoint p) | 775 | QString KOTodoView::getWhatsThisText(QPoint p) |
769 | { | 776 | { |
770 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 777 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
771 | if ( item ) | 778 | if ( item ) |
772 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 779 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
773 | KOPrefs::instance()->mWTshowDetails, | 780 | KOPrefs::instance()->mWTshowDetails, |
774 | KOPrefs::instance()->mWTshowCreated, | 781 | KOPrefs::instance()->mWTshowCreated, |
775 | KOPrefs::instance()->mWTshowChanged); | 782 | KOPrefs::instance()->mWTshowChanged); |
776 | return i18n("That is the todo view" ); | 783 | return i18n("That is the todo view" ); |
777 | 784 | ||
778 | } | 785 | } |
779 | 786 | ||
780 | void KOTodoView::jumpToDate () | 787 | void KOTodoView::jumpToDate () |
781 | { | 788 | { |
782 | // if (mActiveItem) { | 789 | // if (mActiveItem) { |
783 | // mActiveItem->todo()); | 790 | // mActiveItem->todo()); |
784 | // if ( mActiveItem->todo()->hasDueDate() ) | 791 | // if ( mActiveItem->todo()->hasDueDate() ) |
785 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 792 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
786 | } | 793 | } |
787 | void KOTodoView::paintNeeded() | 794 | void KOTodoView::paintNeeded() |
788 | { | 795 | { |
789 | if ( mPendingUpdateBeforeRepaint ) { | 796 | if ( mPendingUpdateBeforeRepaint ) { |
790 | updateView(); | 797 | updateView(); |
791 | mPendingUpdateBeforeRepaint = false; | 798 | mPendingUpdateBeforeRepaint = false; |
792 | } | 799 | } |
793 | } | 800 | } |
794 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 801 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
795 | { | 802 | { |
796 | if ( mPendingUpdateBeforeRepaint ) { | 803 | if ( mPendingUpdateBeforeRepaint ) { |
797 | updateView(); | 804 | updateView(); |
798 | mPendingUpdateBeforeRepaint = false; | 805 | mPendingUpdateBeforeRepaint = false; |
799 | } | 806 | } |
800 | KOrg::BaseView::paintEvent( pevent); | 807 | KOrg::BaseView::paintEvent( pevent); |
801 | } | 808 | } |
802 | 809 | ||
803 | void KOTodoView::updateView() | 810 | void KOTodoView::updateView() |
804 | { | 811 | { |
805 | pendingSubtodo = 0; | 812 | pendingSubtodo = 0; |
806 | if ( mBlockUpdate ) { | 813 | if ( mBlockUpdate ) { |
807 | return; | 814 | return; |
808 | } | 815 | } |
809 | if ( !isVisible() ) { | 816 | if ( !isVisible() ) { |
810 | mPendingUpdateBeforeRepaint = true; | 817 | mPendingUpdateBeforeRepaint = true; |
811 | return; | 818 | return; |
812 | } | 819 | } |
813 | //qDebug("KOTodoView::updateView() %x", this); | 820 | //qDebug("KOTodoView::updateView() %x", this); |
814 | if ( isFlatDisplay ) { | 821 | if ( isFlatDisplay ) { |
815 | displayAllFlat(); | 822 | displayAllFlat(); |
816 | return; | 823 | return; |
817 | } | 824 | } |
818 | storeCurrentItem(); | 825 | storeCurrentItem(); |
819 | //qDebug("update "); | 826 | //qDebug("update "); |
820 | // kdDebug() << "KOTodoView::updateView()" << endl; | 827 | // kdDebug() << "KOTodoView::updateView()" << endl; |
821 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 828 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
822 | 829 | ||
823 | 830 | ||
824 | mTodoListView->clear(); | 831 | mTodoListView->clear(); |
825 | if ( mName == "todolistsmall" ) { | 832 | if ( mName == "todolistsmall" ) { |
826 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 833 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
827 | int ps = fo.pointSize() -2; | 834 | int ps = fo.pointSize() -2; |
828 | if ( ps > 12 ) | 835 | if ( ps > 12 ) |
829 | ps -= 2; | 836 | ps -= 2; |
830 | fo.setPointSize( ps ); | 837 | fo.setPointSize( ps ); |
831 | } | 838 | } |
832 | } | 839 | } |
833 | 840 | ||
834 | mTodoListView->setFont( fo ); | 841 | mTodoListView->setFont( fo ); |
835 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 842 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
836 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 843 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
837 | QPtrList<Todo> todoList = calendar()->todos(); | 844 | QPtrList<Todo> todoList = calendar()->todos(); |
838 | 845 | ||
839 | /* | 846 | /* |
840 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 847 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
841 | Event *t; | 848 | Event *t; |
842 | for(t = todoList.first(); t; t = todoList.next()) { | 849 | for(t = todoList.first(); t; t = todoList.next()) { |
843 | kdDebug() << " " << t->getSummary() << endl; | 850 | kdDebug() << " " << t->getSummary() << endl; |
844 | 851 | ||
845 | if (t->getRelatedTo()) { | 852 | if (t->getRelatedTo()) { |
846 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 853 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
847 | } | 854 | } |
848 | 855 | ||
849 | QPtrList<Event> l = t->getRelations(); | 856 | QPtrList<Event> l = t->getRelations(); |
850 | Event *c; | 857 | Event *c; |
851 | for(c=l.first();c;c=l.next()) { | 858 | for(c=l.first();c;c=l.next()) { |
852 | kdDebug() << " - relation: " << c->getSummary() << endl; | 859 | kdDebug() << " - relation: " << c->getSummary() << endl; |
853 | } | 860 | } |
854 | } | 861 | } |
855 | */ | 862 | */ |
856 | 863 | ||
857 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 864 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
858 | // specific order of events. That means that we have to generate parent items | 865 | // specific order of events. That means that we have to generate parent items |
859 | // recursively for proper hierarchical display of Todos. | 866 | // recursively for proper hierarchical display of Todos. |
860 | mTodoMap.clear(); | 867 | mTodoMap.clear(); |
861 | Todo *todo; | 868 | Todo *todo; |
862 | todo = todoList.first();// todo; todo = todoList.next()) { | 869 | todo = todoList.first();// todo; todo = todoList.next()) { |
863 | while ( todo ) { | 870 | while ( todo ) { |
864 | bool next = true; | 871 | bool next = true; |
865 | // qDebug("todo %s ", todo->summary().latin1()); | 872 | // qDebug("todo %s ", todo->summary().latin1()); |
866 | Incidence *incidence = todo->relatedTo(); | 873 | Incidence *incidence = todo->relatedTo(); |
867 | while ( incidence ) { | 874 | while ( incidence ) { |
868 | if ( incidence->typeID() == todoID ) { | 875 | if ( incidence->typeID() == todoID ) { |
869 | //qDebug("related %s ",incidence->summary().latin1() ); | 876 | //qDebug("related %s ",incidence->summary().latin1() ); |
870 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 877 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
871 | //qDebug("related not found "); | 878 | //qDebug("related not found "); |
872 | todoList.remove( ); | 879 | todoList.remove( ); |
873 | todo = todoList.current(); | 880 | todo = todoList.current(); |
874 | next = false; | 881 | next = false; |
875 | incidence = 0; | 882 | incidence = 0; |
876 | 883 | ||
877 | } else { | 884 | } else { |
878 | //qDebug("related found "); | 885 | //qDebug("related found "); |
879 | incidence = incidence->relatedTo(); | 886 | incidence = incidence->relatedTo(); |
880 | } | 887 | } |
881 | } else | 888 | } else |
882 | incidence = 0; | 889 | incidence = 0; |
883 | } | 890 | } |
884 | if ( next ) | 891 | if ( next ) |
885 | todo = todoList.next(); | 892 | todo = todoList.next(); |
886 | } | 893 | } |
887 | 894 | ||
888 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 895 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
889 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 896 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
890 | { | 897 | { |
891 | insertTodoItem(todo); | 898 | insertTodoItem(todo); |
892 | } | 899 | } |
893 | } | 900 | } |
894 | // Restore opened/closed state | 901 | // Restore opened/closed state |
895 | mTodoListView->blockSignals( true ); | 902 | mTodoListView->blockSignals( true ); |
896 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 903 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
897 | mTodoListView->blockSignals( false ); | 904 | mTodoListView->blockSignals( false ); |
898 | resetCurrentItem(); | 905 | resetCurrentItem(); |
899 | } | 906 | } |
900 | 907 | ||
901 | void KOTodoView::storeCurrentItem() | 908 | void KOTodoView::storeCurrentItem() |
902 | { | 909 | { |
903 | mCurItem = 0; | 910 | mCurItem = 0; |
904 | mCurItemRootParent = 0; | 911 | mCurItemRootParent = 0; |
905 | mCurItemParent = 0; | 912 | mCurItemParent = 0; |
906 | mCurItemAbove = 0; | 913 | mCurItemAbove = 0; |
907 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 914 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
908 | if (mActiveItem) { | 915 | if (mActiveItem) { |
909 | mCurItem = mActiveItem->todo(); | 916 | mCurItem = mActiveItem->todo(); |
910 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 917 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
911 | if ( activeItemAbove ) | 918 | if ( activeItemAbove ) |
912 | mCurItemAbove = activeItemAbove->todo(); | 919 | mCurItemAbove = activeItemAbove->todo(); |
913 | mCurItemRootParent = mCurItem; | 920 | mCurItemRootParent = mCurItem; |
914 | mCurItemParent = mCurItemRootParent->relatedTo(); | 921 | mCurItemParent = mCurItemRootParent->relatedTo(); |
915 | while ( mCurItemRootParent->relatedTo() != 0 ) | 922 | while ( mCurItemRootParent->relatedTo() != 0 ) |
916 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 923 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
917 | } | 924 | } |
918 | mActiveItem = 0; | 925 | mActiveItem = 0; |
919 | } | 926 | } |
920 | 927 | ||
921 | void KOTodoView::resetCurrentItem() | 928 | void KOTodoView::resetCurrentItem() |
922 | { | 929 | { |
923 | //mTodoListView->setFocus(); | 930 | //mTodoListView->setFocus(); |
924 | KOTodoViewItem* foundItem = 0; | 931 | KOTodoViewItem* foundItem = 0; |
925 | KOTodoViewItem* foundItemRoot = 0; | 932 | KOTodoViewItem* foundItemRoot = 0; |
926 | KOTodoViewItem* foundItemParent = 0; | 933 | KOTodoViewItem* foundItemParent = 0; |
927 | KOTodoViewItem* foundItemAbove = 0; | 934 | KOTodoViewItem* foundItemAbove = 0; |
928 | if ( mTodoListView->firstChild () ) { | 935 | if ( mTodoListView->firstChild () ) { |
929 | if ( mCurItem ) { | 936 | if ( mCurItem ) { |
930 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 937 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
931 | while ( item ) { | 938 | while ( item ) { |
932 | if ( item->todo() == mCurItem ) { | 939 | if ( item->todo() == mCurItem ) { |
933 | foundItem = item; | 940 | foundItem = item; |
934 | break; | 941 | break; |
935 | } else if ( item->todo() == mCurItemAbove ) { | 942 | } else if ( item->todo() == mCurItemAbove ) { |
936 | foundItemAbove = item; | 943 | foundItemAbove = item; |
937 | 944 | ||
938 | } | 945 | } |
939 | if ( item->todo() == mCurItemRootParent ) { | 946 | if ( item->todo() == mCurItemRootParent ) { |
940 | foundItemRoot = item; | 947 | foundItemRoot = item; |
941 | } | 948 | } |
942 | if ( item->todo() == mCurItemParent ) { | 949 | if ( item->todo() == mCurItemParent ) { |
943 | foundItemParent = item; | 950 | foundItemParent = item; |
944 | } | 951 | } |
945 | item = (KOTodoViewItem*)item->itemBelow(); | 952 | item = (KOTodoViewItem*)item->itemBelow(); |
946 | } | 953 | } |
947 | if ( ! foundItem ) { | 954 | if ( ! foundItem ) { |
948 | if ( foundItemParent ) { | 955 | if ( foundItemParent ) { |
949 | foundItem = foundItemParent; | 956 | foundItem = foundItemParent; |
950 | } else { | 957 | } else { |
951 | if ( foundItemRoot ) | 958 | if ( foundItemRoot ) |
952 | foundItem = foundItemRoot; | 959 | foundItem = foundItemRoot; |
953 | else | 960 | else |
954 | foundItem = foundItemAbove; | 961 | foundItem = foundItemAbove; |
955 | } | 962 | } |
956 | } | 963 | } |
957 | } | 964 | } |
958 | if ( foundItem ) { | 965 | if ( foundItem ) { |
959 | mTodoListView->setSelected ( foundItem, true ); | 966 | mTodoListView->setSelected ( foundItem, true ); |
960 | mTodoListView->setCurrentItem( foundItem ); | 967 | mTodoListView->setCurrentItem( foundItem ); |
961 | mTodoListView->ensureItemVisible( foundItem ); | 968 | mTodoListView->ensureItemVisible( foundItem ); |
962 | } else { | 969 | } else { |
963 | if ( mTodoListView->firstChild () ) { | 970 | if ( mTodoListView->firstChild () ) { |
964 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); | 971 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); |
965 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 972 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
966 | } | 973 | } |
967 | } | 974 | } |
968 | } | 975 | } |
969 | processSelectionChange(); | 976 | processSelectionChange(); |
970 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); | 977 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); |
971 | } | 978 | } |
972 | void KOTodoView::resetFocusToList() | 979 | void KOTodoView::resetFocusToList() |
973 | { | 980 | { |
974 | topLevelWidget()->setActiveWindow(); | 981 | topLevelWidget()->setActiveWindow(); |
975 | mTodoListView->setFocus(); | 982 | mTodoListView->setFocus(); |
976 | } | 983 | } |
977 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 984 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
978 | bool KOTodoView::checkTodo( Todo * todo ) | 985 | bool KOTodoView::checkTodo( Todo * todo ) |
979 | { | 986 | { |
980 | 987 | ||
981 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 988 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
982 | return false; | 989 | return false; |
983 | if ( !todo->isCompleted() ) { | 990 | if ( !todo->isCompleted() ) { |
984 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 991 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
985 | return true; | 992 | return true; |
986 | } | 993 | } |
987 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 994 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
988 | if ( todo->hasStartDate() ) | 995 | if ( todo->hasStartDate() ) |
989 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 996 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
990 | return false; | 997 | return false; |
991 | if ( todo->hasDueDate() ) | 998 | if ( todo->hasDueDate() ) |
992 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 999 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
993 | return false; | 1000 | return false; |
994 | } | 1001 | } |
995 | return true; | 1002 | return true; |
996 | } | 1003 | } |
997 | 1004 | ||
998 | void KOTodoView::restoreItemState( QListViewItem *item ) | 1005 | void KOTodoView::restoreItemState( QListViewItem *item ) |
999 | { | 1006 | { |
1000 | pendingSubtodo = 0; | 1007 | pendingSubtodo = 0; |
1001 | while( item ) { | 1008 | while( item ) { |
1002 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1009 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1003 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 1010 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
1004 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 1011 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
1005 | item = item->nextSibling(); | 1012 | item = item->nextSibling(); |
1006 | } | 1013 | } |
1007 | } | 1014 | } |
1008 | 1015 | ||
1009 | 1016 | ||
1010 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 1017 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
1011 | KOTodoView::insertTodoItem(Todo *todo) | 1018 | KOTodoView::insertTodoItem(Todo *todo) |
1012 | { | 1019 | { |
1013 | 1020 | ||
1014 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 1021 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
1015 | // TODO: Check, if dynmaic cast is necessary | 1022 | // TODO: Check, if dynmaic cast is necessary |
1016 | 1023 | ||
1017 | pendingSubtodo = 0; | 1024 | pendingSubtodo = 0; |
1018 | Incidence *incidence = todo->relatedTo(); | 1025 | Incidence *incidence = todo->relatedTo(); |
1019 | while ( incidence && !incidence->calEnabled() ) | 1026 | while ( incidence && !incidence->calEnabled() ) |
1020 | incidence = incidence->relatedTo(); | 1027 | incidence = incidence->relatedTo(); |
1021 | if (incidence && incidence->typeID() == todoID ) { | 1028 | if (incidence && incidence->typeID() == todoID ) { |
1022 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 1029 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
1023 | 1030 | ||
1024 | // kdDebug() << " has Related" << endl; | 1031 | // kdDebug() << " has Related" << endl; |
1025 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1032 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1026 | itemIterator = mTodoMap.find(relatedTodo); | 1033 | itemIterator = mTodoMap.find(relatedTodo); |
1027 | if (itemIterator == mTodoMap.end()) { | 1034 | if (itemIterator == mTodoMap.end()) { |
1028 | // kdDebug() << " related not yet in list" << endl; | 1035 | // kdDebug() << " related not yet in list" << endl; |
1029 | itemIterator = insertTodoItem (relatedTodo); | 1036 | itemIterator = insertTodoItem (relatedTodo); |
1030 | } | 1037 | } |
1031 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 1038 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
1032 | // and one into the map. Sure finding is more easy but why? -zecke | 1039 | // and one into the map. Sure finding is more easy but why? -zecke |
1033 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 1040 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
1034 | return mTodoMap.insert(todo,todoItem); | 1041 | return mTodoMap.insert(todo,todoItem); |
1035 | } else { | 1042 | } else { |
1036 | // kdDebug() << " no Related" << endl; | 1043 | // kdDebug() << " no Related" << endl; |
1037 | // see above -zecke | 1044 | // see above -zecke |
1038 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1045 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1039 | return mTodoMap.insert(todo,todoItem); | 1046 | return mTodoMap.insert(todo,todoItem); |
1040 | } | 1047 | } |
1041 | } | 1048 | } |
1042 | 1049 | ||
1043 | 1050 | ||
1044 | void KOTodoView::updateConfig() | 1051 | void KOTodoView::updateConfig() |
1045 | { | 1052 | { |
1046 | updateView(); | 1053 | updateView(); |
1047 | mTodoListView->repaintContents(); | 1054 | mTodoListView->repaintContents(); |
1048 | } | 1055 | } |
1049 | 1056 | ||
1050 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 1057 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
1051 | { | 1058 | { |
1052 | QPtrList<Incidence> selected; | 1059 | QPtrList<Incidence> selected; |
1053 | 1060 | ||
1054 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1061 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1055 | // if (!item) item = mActiveItem; | 1062 | // if (!item) item = mActiveItem; |
1056 | if (item) selected.append(item->todo()); | 1063 | if (item) selected.append(item->todo()); |
1057 | 1064 | ||
1058 | return selected; | 1065 | return selected; |
1059 | } | 1066 | } |
1060 | 1067 | ||
1061 | QPtrList<Todo> KOTodoView::selectedTodos() | 1068 | QPtrList<Todo> KOTodoView::selectedTodos() |
1062 | { | 1069 | { |
1063 | QPtrList<Todo> selected; | 1070 | QPtrList<Todo> selected; |
1064 | 1071 | ||
1065 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1072 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1066 | // if (!item) item = mActiveItem; | 1073 | // if (!item) item = mActiveItem; |
1067 | if (item) selected.append(item->todo()); | 1074 | if (item) selected.append(item->todo()); |
1068 | 1075 | ||
1069 | return selected; | 1076 | return selected; |
1070 | } | 1077 | } |
1071 | 1078 | ||
1072 | void KOTodoView::changeEventDisplay(Event *, int) | 1079 | void KOTodoView::changeEventDisplay(Event *, int) |
1073 | { | 1080 | { |
1074 | updateView(); | 1081 | updateView(); |
1075 | } | 1082 | } |
1076 | 1083 | ||
1077 | void KOTodoView::showDates(const QDate &, const QDate &) | 1084 | void KOTodoView::showDates(const QDate &, const QDate &) |
1078 | { | 1085 | { |
1079 | } | 1086 | } |
1080 | 1087 | ||
1081 | void KOTodoView::showEvents(QPtrList<Event>) | 1088 | void KOTodoView::showEvents(QPtrList<Event>) |
1082 | { | 1089 | { |
1083 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 1090 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
1084 | } | 1091 | } |
1085 | 1092 | ||
1086 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1093 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1087 | const QDate &td) | 1094 | const QDate &td) |
1088 | { | 1095 | { |
1089 | #ifndef KORG_NOPRINTER | 1096 | #ifndef KORG_NOPRINTER |
1090 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 1097 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
1091 | #endif | 1098 | #endif |
1092 | } | 1099 | } |
1093 | 1100 | ||
1094 | void KOTodoView::editItem(QListViewItem *item ) | 1101 | void KOTodoView::editItem(QListViewItem *item ) |
1095 | { | 1102 | { |
1096 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 1103 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
1097 | } | 1104 | } |
1098 | 1105 | ||
1099 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 1106 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
1100 | { | 1107 | { |
1101 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 1108 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
1102 | } | 1109 | } |
1103 | 1110 | ||
1104 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 1111 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
1105 | { | 1112 | { |
1106 | pendingSubtodo = 0; | 1113 | pendingSubtodo = 0; |
1107 | mActiveItem = (KOTodoViewItem *)item; | 1114 | mActiveItem = (KOTodoViewItem *)item; |
1108 | if (item) { | 1115 | if (item) { |
1109 | switch (column){ | 1116 | switch (column){ |
1110 | case 1: | 1117 | case 1: |
1111 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 1118 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
1112 | case 2: | 1119 | case 2: |
1113 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 1120 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
1114 | case 3: | 1121 | case 3: |
1115 | moveTodo(); | 1122 | moveTodo(); |
1116 | break; | 1123 | break; |
1117 | case 8: | 1124 | case 7: |
1118 | mCategoryPopupMenu->popup(QCursor::pos ()); break; | 1125 | mCategoryPopupMenu->popup(QCursor::pos ()); break; |
1119 | case 9: | 1126 | case 8: |
1120 | mCalPopupMenu->popup(QCursor::pos ()); break; | 1127 | mCalPopupMenu->popup(QCursor::pos ()); break; |
1121 | default: | 1128 | default: |
1122 | mItemPopupMenu->popup(QCursor::pos()); | 1129 | mItemPopupMenu->popup(QCursor::pos()); |
1123 | } | 1130 | } |
1124 | } else mPopupMenu->popup(QCursor::pos()); | 1131 | } else mPopupMenu->popup(QCursor::pos()); |
1125 | } | 1132 | } |
1126 | void KOTodoView::newTodo() | 1133 | void KOTodoView::newTodo() |
1127 | { | 1134 | { |
1128 | emit newTodoSignal(); | 1135 | emit newTodoSignal(); |
1129 | } | 1136 | } |
1130 | 1137 | ||
1131 | void KOTodoView::newSubTodo() | 1138 | void KOTodoView::newSubTodo() |
1132 | { | 1139 | { |
1133 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1140 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1134 | if (mActiveItem) { | 1141 | if (mActiveItem) { |
1135 | if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) { | 1142 | if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) { |
1136 | addQuickTodoPar( mActiveItem->todo()); | 1143 | addQuickTodoPar( mActiveItem->todo()); |
1137 | } else | 1144 | } else |
1138 | emit newSubTodoSignal(mActiveItem->todo()); | 1145 | emit newSubTodoSignal(mActiveItem->todo()); |
1139 | } | 1146 | } |
1140 | } | 1147 | } |
1141 | void KOTodoView::unparentTodo() | 1148 | void KOTodoView::unparentTodo() |
1142 | { | 1149 | { |
1143 | if (mActiveItem) { | 1150 | if (mActiveItem) { |
1144 | emit unparentTodoSignal(mActiveItem->todo()); | 1151 | emit unparentTodoSignal(mActiveItem->todo()); |
1145 | } | 1152 | } |
1146 | } | 1153 | } |
1147 | 1154 | ||
1148 | void KOTodoView::reparentTodo() | 1155 | void KOTodoView::reparentTodo() |
1149 | { | 1156 | { |
1150 | if (mActiveItem) { | 1157 | if (mActiveItem) { |
1151 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 1158 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
1152 | pendingSubtodo = mActiveItem; | 1159 | pendingSubtodo = mActiveItem; |
1153 | } | 1160 | } |
1154 | } | 1161 | } |
1155 | void KOTodoView::editTodo() | 1162 | void KOTodoView::editTodo() |
1156 | { | 1163 | { |
1157 | if (mActiveItem) { | 1164 | if (mActiveItem) { |
1158 | emit editTodoSignal(mActiveItem->todo()); | 1165 | emit editTodoSignal(mActiveItem->todo()); |
1159 | } | 1166 | } |
1160 | } | 1167 | } |
1161 | void KOTodoView::cloneTodo() | 1168 | void KOTodoView::cloneTodo() |
1162 | { | 1169 | { |
1163 | if (mActiveItem) { | 1170 | if (mActiveItem) { |
1164 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 1171 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
1165 | } | 1172 | } |
1166 | } | 1173 | } |
1167 | void KOTodoView::cancelTodo() | 1174 | void KOTodoView::cancelTodo() |
1168 | { | 1175 | { |
1169 | if (mActiveItem) { | 1176 | if (mActiveItem) { |
1170 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 1177 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
1171 | } | 1178 | } |
1172 | } | 1179 | } |
1173 | void KOTodoView::moveTodo() | 1180 | void KOTodoView::moveTodo() |
1174 | { | 1181 | { |
1175 | if (mActiveItem) { | 1182 | if (mActiveItem) { |
1176 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 1183 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
1177 | } | 1184 | } |
1178 | } | 1185 | } |
1179 | void KOTodoView::beamTodo() | 1186 | void KOTodoView::beamTodo() |
1180 | { | 1187 | { |
1181 | if (mActiveItem) { | 1188 | if (mActiveItem) { |
1182 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 1189 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
1183 | } | 1190 | } |
1184 | } | 1191 | } |
1185 | 1192 | ||
1186 | 1193 | ||
1187 | void KOTodoView::showTodo() | 1194 | void KOTodoView::showTodo() |
1188 | { | 1195 | { |
1189 | if (mActiveItem) { | 1196 | if (mActiveItem) { |
1190 | emit showTodoSignal(mActiveItem->todo()); | 1197 | emit showTodoSignal(mActiveItem->todo()); |
1191 | } | 1198 | } |
1192 | } | 1199 | } |
1193 | 1200 | ||
1194 | void KOTodoView::deleteTodo() | 1201 | void KOTodoView::deleteTodo() |
1195 | { | 1202 | { |
1196 | if (mActiveItem) { | 1203 | if (mActiveItem) { |
1197 | emit deleteTodoSignal(mActiveItem->todo()); | 1204 | emit deleteTodoSignal(mActiveItem->todo()); |
1198 | } | 1205 | } |
1199 | } | 1206 | } |
1200 | 1207 | ||
1201 | void KOTodoView::setNewPriority(int index) | 1208 | void KOTodoView::setNewPriority(int index) |
1202 | { | 1209 | { |
1203 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1210 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1204 | mActiveItem->todo()->setPriority(mPriority[index]); | 1211 | mActiveItem->todo()->setPriority(mPriority[index]); |
1205 | mActiveItem->construct(); | 1212 | mActiveItem->construct(); |
1206 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1213 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1207 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1214 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1208 | } | 1215 | } |
1209 | processSelectionChange(); | 1216 | processSelectionChange(); |
1210 | } | 1217 | } |
1211 | 1218 | ||
1212 | void KOTodoView::setNewPercentage(int index) | 1219 | void KOTodoView::setNewPercentage(int index) |
1213 | { | 1220 | { |
1214 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1221 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1215 | 1222 | ||
1216 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1223 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1217 | mActiveItem->setOn( true ); | 1224 | mActiveItem->setOn( true ); |
1218 | processSelectionChange(); | 1225 | processSelectionChange(); |
1219 | return; | 1226 | return; |
1220 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1227 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1221 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1228 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1222 | if ( par && par->isOn() ) | 1229 | if ( par && par->isOn() ) |
1223 | par->setOn( false ); | 1230 | par->setOn( false ); |
1224 | } | 1231 | } |
1225 | if (mPercentage[index] == 100) { | 1232 | if (mPercentage[index] == 100) { |
1226 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1233 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1227 | } else { | 1234 | } else { |
1228 | mActiveItem->todo()->setCompleted(false); | 1235 | mActiveItem->todo()->setCompleted(false); |
1229 | } | 1236 | } |
1230 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1237 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1231 | mActiveItem->construct(); | 1238 | mActiveItem->construct(); |
1232 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1239 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1233 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1240 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1234 | } | 1241 | } |
1235 | processSelectionChange(); | 1242 | processSelectionChange(); |
1236 | } | 1243 | } |
1237 | 1244 | ||
1238 | void KOTodoView::fillCategories () | 1245 | void KOTodoView::fillCategories () |
1239 | { | 1246 | { |
1240 | mCategoryPopupMenu->clear(); | 1247 | mCategoryPopupMenu->clear(); |
1241 | if ( ! mActiveItem ) return; | 1248 | if ( ! mActiveItem ) return; |
1242 | QStringList checkedCategories = mActiveItem->todo()->categories (); | 1249 | QStringList checkedCategories = mActiveItem->todo()->categories (); |
1243 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1250 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1244 | it != KOPrefs::instance()->mCustomCategories.end (); | 1251 | it != KOPrefs::instance()->mCustomCategories.end (); |
1245 | ++it) { | 1252 | ++it) { |
1246 | int index = mCategoryPopupMenu->insertItem (*it); | 1253 | int index = mCategoryPopupMenu->insertItem (*it); |
1247 | mCategory[index] = *it; | 1254 | mCategory[index] = *it; |
1248 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); | 1255 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); |
1249 | } | 1256 | } |
1250 | } | 1257 | } |
1251 | void KOTodoView::fillCal () | 1258 | void KOTodoView::fillCal () |
1252 | { | 1259 | { |
1253 | mCalPopupMenu->clear(); | 1260 | mCalPopupMenu->clear(); |
1254 | if (!mActiveItem) return; | 1261 | if (!mActiveItem) return; |
1255 | bool readO = mActiveItem->todo()->isReadOnly(); | 1262 | bool readO = mActiveItem->todo()->isReadOnly(); |
1256 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 1263 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
1257 | while ( kkf ) { | 1264 | while ( kkf ) { |
1258 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); | 1265 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); |
1259 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) | 1266 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) |
1260 | mCalPopupMenu->setItemEnabled( index, false ); | 1267 | mCalPopupMenu->setItemEnabled( index, false ); |
1261 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); | 1268 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); |
1262 | kkf = KOPrefs::instance()->mCalendars.next(); | 1269 | kkf = KOPrefs::instance()->mCalendars.next(); |
1263 | } | 1270 | } |
1264 | } | 1271 | } |
1265 | void KOTodoView::changedCal (int index ) | 1272 | void KOTodoView::changedCal (int index ) |
1266 | { | 1273 | { |
1267 | if (!mActiveItem) return; | 1274 | if (!mActiveItem) return; |
1268 | mActiveItem->todo()->setCalID( index ); | 1275 | mActiveItem->todo()->setCalID( index ); |
1269 | mActiveItem->construct(); | 1276 | mActiveItem->construct(); |
1270 | } | 1277 | } |
1271 | void KOTodoView::changedCategories(int index) | 1278 | void KOTodoView::changedCategories(int index) |
1272 | { | 1279 | { |
1273 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1280 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1274 | QStringList categories = mActiveItem->todo()->categories (); | 1281 | QStringList categories = mActiveItem->todo()->categories (); |
1275 | QString colcat = categories.first(); | 1282 | QString colcat = categories.first(); |
1276 | if (categories.find (mCategory[index]) != categories.end ()) | 1283 | if (categories.find (mCategory[index]) != categories.end ()) |
1277 | categories.remove (mCategory[index]); | 1284 | categories.remove (mCategory[index]); |
1278 | else | 1285 | else |
1279 | categories.insert (categories.end(), mCategory[index]); | 1286 | categories.insert (categories.end(), mCategory[index]); |
1280 | categories.sort (); | 1287 | categories.sort (); |
1281 | if ( !colcat.isEmpty() ) { | 1288 | if ( !colcat.isEmpty() ) { |
1282 | if ( categories.find ( colcat ) != categories.end () ) { | 1289 | if ( categories.find ( colcat ) != categories.end () ) { |
1283 | categories.remove( colcat ); | 1290 | categories.remove( colcat ); |
1284 | categories.prepend( colcat ); | 1291 | categories.prepend( colcat ); |
1285 | } | 1292 | } |
1286 | } | 1293 | } |
1287 | mActiveItem->todo()->setCategories (categories); | 1294 | mActiveItem->todo()->setCategories (categories); |
1288 | mActiveItem->construct(); | 1295 | mActiveItem->construct(); |
1289 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1296 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1290 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1297 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1291 | } | 1298 | } |
1292 | } | 1299 | } |
1293 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1300 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1294 | { | 1301 | { |
1295 | if ( pendingSubtodo != 0 ) { | 1302 | if ( pendingSubtodo != 0 ) { |
1296 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1303 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1297 | } | 1304 | } |
1298 | pendingSubtodo = 0; | 1305 | pendingSubtodo = 0; |
1299 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1306 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1300 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1307 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1301 | //qDebug("ROW %d ", row); | 1308 | //qDebug("ROW %d ", row); |
1302 | if (!item) { | 1309 | if (!item) { |
1303 | newTodo(); | 1310 | newTodo(); |
1304 | return; | 1311 | return; |
1305 | } else { | 1312 | } else { |
1306 | if ( row == 1 ) { | 1313 | if ( row == 1 ) { |
1307 | mActiveItem = (KOTodoViewItem *) item; | 1314 | mActiveItem = (KOTodoViewItem *) item; |
1308 | newSubTodo(); | 1315 | newSubTodo(); |
1309 | return; | 1316 | return; |
1310 | } | 1317 | } |
1311 | if ( row == 5 || row == 6 || row == 2) { | 1318 | if ( row == 5 || row == 6 || row == 2) { |
1312 | mActiveItem = (KOTodoViewItem *) item; | 1319 | mActiveItem = (KOTodoViewItem *) item; |
1313 | Todo * t = mActiveItem->todo(); | 1320 | Todo * t = mActiveItem->todo(); |
1314 | if ( t->isRunning() ) { | 1321 | if ( t->isRunning() ) { |
1315 | if ( t->runTime() < 15) { | 1322 | if ( t->runTime() < 15) { |
1316 | t->stopRunning(); | 1323 | t->stopRunning(); |
1317 | mActiveItem->construct(); | 1324 | mActiveItem->construct(); |
1318 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); | 1325 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); |
1319 | return; | 1326 | return; |
1320 | } | 1327 | } |
1321 | else | 1328 | else |
1322 | toggleRunningItem(); | 1329 | toggleRunningItem(); |
1323 | return; | 1330 | return; |
1324 | } else { | 1331 | } else { |
1325 | t->setRunning( true ); | 1332 | t->setRunning( true ); |
1326 | mActiveItem->construct(); | 1333 | mActiveItem->construct(); |
1327 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); | 1334 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); |
1328 | return; | 1335 | return; |
1329 | } | 1336 | } |
1330 | } | 1337 | } |
1331 | } | 1338 | } |
1332 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1339 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1333 | editItem( item ); | 1340 | editItem( item ); |
1334 | else | 1341 | else |
1335 | showItem( item , QPoint(), 0 ); | 1342 | showItem( item , QPoint(), 0 ); |
1336 | } | 1343 | } |
1337 | void KOTodoView::toggleRunningItem() | 1344 | void KOTodoView::toggleRunningItem() |
1338 | { | 1345 | { |
1339 | // qDebug("KOTodoView::toggleRunning() "); | 1346 | // qDebug("KOTodoView::toggleRunning() "); |
1340 | if ( ! mActiveItem ) | 1347 | if ( ! mActiveItem ) |
1341 | return; | 1348 | return; |
1342 | Todo * t = mActiveItem->todo(); | 1349 | Todo * t = mActiveItem->todo(); |
1343 | if ( t->isRunning() ) { | 1350 | if ( t->isRunning() ) { |
1344 | KOStopTodoPrefs tp ( t, this ); | 1351 | KOStopTodoPrefs tp ( t, this ); |
1345 | if (QApplication::desktop()->width() <= 800 ){ | 1352 | if (QApplication::desktop()->width() <= 800 ){ |
1346 | int wid = tp.width(); | 1353 | int wid = tp.width(); |
1347 | int hei = tp.height(); | 1354 | int hei = tp.height(); |
1348 | int xx = (QApplication::desktop()->width()-wid)/2; | 1355 | int xx = (QApplication::desktop()->width()-wid)/2; |
1349 | int yy = (QApplication::desktop()->height()-hei)/2; | 1356 | int yy = (QApplication::desktop()->height()-hei)/2; |
1350 | tp.setGeometry( xx,yy,wid,hei ); | 1357 | tp.setGeometry( xx,yy,wid,hei ); |
1351 | } | 1358 | } |
1352 | tp.exec(); | 1359 | tp.exec(); |
1353 | mActiveItem->construct(); | 1360 | mActiveItem->construct(); |
1354 | } else { | 1361 | } else { |
1355 | KOStartTodoPrefs tp ( t->summary(), this ); | 1362 | KOStartTodoPrefs tp ( t->summary(), this ); |
1356 | if (QApplication::desktop()->width() <= 800 ){ | 1363 | if (QApplication::desktop()->width() <= 800 ){ |
1357 | int wid = tp.width(); | 1364 | int wid = tp.width(); |
1358 | int hei = tp.height(); | 1365 | int hei = tp.height(); |
1359 | int xx = (QApplication::desktop()->width()-wid)/2; | 1366 | int xx = (QApplication::desktop()->width()-wid)/2; |
1360 | int yy = (QApplication::desktop()->height()-hei)/2; | 1367 | int yy = (QApplication::desktop()->height()-hei)/2; |
1361 | tp.setGeometry( xx,yy,wid,hei ); | 1368 | tp.setGeometry( xx,yy,wid,hei ); |
1362 | } | 1369 | } |
1363 | if ( !tp.exec() ) return; | 1370 | if ( !tp.exec() ) return; |
1364 | if ( tp.stopAll() ) { | 1371 | if ( tp.stopAll() ) { |
1365 | mCalendar->stopAllTodos(); | 1372 | mCalendar->stopAllTodos(); |
1366 | t->setRunning( true ); | 1373 | t->setRunning( true ); |
1367 | updateView(); | 1374 | updateView(); |
1368 | } else { | 1375 | } else { |
1369 | t->setRunning( true ); | 1376 | t->setRunning( true ); |
1370 | mActiveItem->construct(); | 1377 | mActiveItem->construct(); |
1371 | } | 1378 | } |
1372 | } | 1379 | } |
1373 | } | 1380 | } |
1374 | 1381 | ||
1375 | void KOTodoView::itemClicked(QListViewItem *item) | 1382 | void KOTodoView::itemClicked(QListViewItem *item) |
1376 | { | 1383 | { |
1377 | //qDebug("KOTodoView::itemClicked %d", item); | 1384 | //qDebug("KOTodoView::itemClicked %d", item); |
1378 | if (!item) { | 1385 | if (!item) { |
1379 | if ( pendingSubtodo != 0 ) { | 1386 | if ( pendingSubtodo != 0 ) { |
1380 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1387 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1381 | } | 1388 | } |
1382 | pendingSubtodo = 0; | 1389 | pendingSubtodo = 0; |
1383 | return; | 1390 | return; |
1384 | } | 1391 | } |
1385 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1392 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1386 | if ( pendingSubtodo != 0 ) { | 1393 | if ( pendingSubtodo != 0 ) { |
1387 | bool allowReparent = true; | 1394 | bool allowReparent = true; |
1388 | QListViewItem *par = item; | 1395 | QListViewItem *par = item; |
1389 | while ( par ) { | 1396 | while ( par ) { |
1390 | if ( par == pendingSubtodo ) { | 1397 | if ( par == pendingSubtodo ) { |
1391 | allowReparent = false; | 1398 | allowReparent = false; |
1392 | break; | 1399 | break; |
1393 | } | 1400 | } |
1394 | par = par->parent(); | 1401 | par = par->parent(); |
1395 | } | 1402 | } |
1396 | if ( !allowReparent ) { | 1403 | if ( !allowReparent ) { |
1397 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1404 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1398 | pendingSubtodo = 0; | 1405 | pendingSubtodo = 0; |
1399 | } else { | 1406 | } else { |
1400 | Todo* newParent = todoItem->todo(); | 1407 | Todo* newParent = todoItem->todo(); |
1401 | Todo* newSub = pendingSubtodo->todo(); | 1408 | Todo* newSub = pendingSubtodo->todo(); |
1402 | pendingSubtodo = 0; | 1409 | pendingSubtodo = 0; |
1403 | emit reparentTodoSignal( newParent,newSub ); | 1410 | emit reparentTodoSignal( newParent,newSub ); |
1404 | return; | 1411 | return; |
1405 | } | 1412 | } |
1406 | } | 1413 | } |
1407 | 1414 | ||
1408 | } | 1415 | } |
1409 | 1416 | ||
1410 | void KOTodoView::setDocumentId( const QString &id ) | 1417 | void KOTodoView::setDocumentId( const QString &id ) |
1411 | { | 1418 | { |
1412 | 1419 | ||
1413 | mDocPrefs->setDoc( id ); | 1420 | mDocPrefs->setDoc( id ); |
1414 | } | 1421 | } |
1415 | 1422 | ||
1416 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1423 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1417 | { | 1424 | { |
1418 | if (!item) return; | 1425 | if (!item) return; |
1419 | 1426 | ||
1420 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1427 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1421 | 1428 | ||
1422 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1429 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1423 | 1430 | ||
1424 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1431 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1425 | } | 1432 | } |
1426 | 1433 | ||
1427 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1434 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1428 | { | 1435 | { |
1429 | mTodoListView->saveLayout(config,group); | 1436 | mTodoListView->saveLayout(config,group); |
1430 | } | 1437 | } |
1431 | 1438 | ||
1432 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1439 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1433 | { | 1440 | { |
1434 | mTodoListView->restoreLayout(config,group); | 1441 | mTodoListView->restoreLayout(config,group); |
1435 | } | 1442 | } |
1436 | 1443 | ||
1437 | void KOTodoView::processSelectionChange() | 1444 | void KOTodoView::processSelectionChange() |
1438 | { | 1445 | { |
1439 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1446 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1440 | 1447 | ||
1441 | KOTodoViewItem *item = | 1448 | KOTodoViewItem *item = |
1442 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1449 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1443 | 1450 | ||
1444 | if ( !item ) { | 1451 | if ( !item ) { |
1445 | emit incidenceSelected( 0 ); | 1452 | emit incidenceSelected( 0 ); |
1446 | mNewSubBut->setEnabled( false ); | 1453 | mNewSubBut->setEnabled( false ); |
1447 | } else { | 1454 | } else { |
1448 | emit incidenceSelected( item->todo() ); | 1455 | emit incidenceSelected( item->todo() ); |
1449 | mNewSubBut->setEnabled( true ); | 1456 | mNewSubBut->setEnabled( true ); |
1450 | } | 1457 | } |
1451 | } | 1458 | } |
1452 | 1459 | ||
1453 | void KOTodoView::modified(bool b) | 1460 | void KOTodoView::modified(bool b) |
1454 | { | 1461 | { |
1455 | emit isModified(b); | 1462 | emit isModified(b); |
1456 | } | 1463 | } |
1457 | void KOTodoView::setTodoModified( Todo* todo ) | 1464 | void KOTodoView::setTodoModified( Todo* todo ) |
1458 | { | 1465 | { |
1459 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1466 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1460 | } | 1467 | } |
1461 | void KOTodoView::clearSelection() | 1468 | void KOTodoView::clearSelection() |
1462 | { | 1469 | { |
1463 | mTodoListView->selectAll( false ); | 1470 | mTodoListView->selectAll( false ); |
1464 | } | 1471 | } |
1465 | void KOTodoView::setAllOpen() | 1472 | void KOTodoView::setAllOpen() |
1466 | { | 1473 | { |
1467 | if ( isFlatDisplay ) { | 1474 | if ( isFlatDisplay ) { |
1468 | isFlatDisplay = false; | 1475 | isFlatDisplay = false; |
1469 | mPopupMenu->setItemChecked( 8,false ); | 1476 | mPopupMenu->setItemChecked( 8,false ); |
1470 | updateView(); | 1477 | updateView(); |
1471 | } else { | 1478 | } else { |
1472 | storeCurrentItem(); | 1479 | storeCurrentItem(); |
1473 | } | 1480 | } |
1474 | setOpen(mTodoListView->firstChild(), true); | 1481 | setOpen(mTodoListView->firstChild(), true); |
1475 | resetCurrentItem(); | 1482 | resetCurrentItem(); |
1476 | } | 1483 | } |
1477 | void KOTodoView::setAllClose() | 1484 | void KOTodoView::setAllClose() |
1478 | { | 1485 | { |
1479 | if ( isFlatDisplay ) { | 1486 | if ( isFlatDisplay ) { |
1480 | isFlatDisplay = false; | 1487 | isFlatDisplay = false; |
1481 | mPopupMenu->setItemChecked( 8,false ); | 1488 | mPopupMenu->setItemChecked( 8,false ); |
1482 | updateView(); | 1489 | updateView(); |
1483 | } else { | 1490 | } else { |
1484 | storeCurrentItem(); | 1491 | storeCurrentItem(); |
1485 | } | 1492 | } |
1486 | setOpen(mTodoListView->firstChild(), false); | 1493 | setOpen(mTodoListView->firstChild(), false); |
1487 | resetCurrentItem(); | 1494 | resetCurrentItem(); |
1488 | } | 1495 | } |
1489 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1496 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1490 | { | 1497 | { |
1491 | 1498 | ||
1492 | while ( item ) { | 1499 | while ( item ) { |
1493 | setOpen( item->firstChild(), setOpenI ); | 1500 | setOpen( item->firstChild(), setOpenI ); |
1494 | item->setOpen( setOpenI ); | 1501 | item->setOpen( setOpenI ); |
1495 | item = item->nextSibling(); | 1502 | item = item->nextSibling(); |
1496 | } | 1503 | } |
1497 | } | 1504 | } |
1498 | 1505 | ||
1499 | void KOTodoView::displayAllFlat() | 1506 | void KOTodoView::displayAllFlat() |
1500 | { | 1507 | { |
1501 | storeCurrentItem(); | 1508 | storeCurrentItem(); |
1502 | pendingSubtodo = 0; | 1509 | pendingSubtodo = 0; |
1503 | if ( mBlockUpdate ) { | 1510 | if ( mBlockUpdate ) { |