summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 2582931..68d1bc6 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -2366,813 +2366,812 @@ void CalendarView::readSettings()
2366 mTodoEditor->setGeometry(x,y,w,h); 2366 mTodoEditor->setGeometry(x,y,w,h);
2367 2367
2368 } 2368 }
2369 list = config->readListEntry("ViewerLayout"); 2369 list = config->readListEntry("ViewerLayout");
2370 if ( ! list.isEmpty() ) { 2370 if ( ! list.isEmpty() ) {
2371 x = list[0].toInt(); 2371 x = list[0].toInt();
2372 y = list[1].toInt(); 2372 y = list[1].toInt();
2373 w = list[2].toInt(); 2373 w = list[2].toInt();
2374 h = list[3].toInt(); 2374 h = list[3].toInt();
2375 KApplication::testCoords( &x,&y,&w,&h ); 2375 KApplication::testCoords( &x,&y,&w,&h );
2376 getEventViewerDialog()->setGeometry(x,y,w,h); 2376 getEventViewerDialog()->setGeometry(x,y,w,h);
2377 } 2377 }
2378#endif 2378#endif
2379 config->setGroup( "Views" ); 2379 config->setGroup( "Views" );
2380 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2380 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2381 2381
2382 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2382 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2383 2383
2384 int resetval = 0; 2384 int resetval = 0;
2385 int maxVal = 0; 2385 int maxVal = 0;
2386 if (sizes.count() != 3) { 2386 if (sizes.count() != 3) {
2387 if ( KOPrefs::instance()->mVerticalScreen ) { 2387 if ( KOPrefs::instance()->mVerticalScreen ) {
2388 resetval = mDateNavigator->sizeHint().width()+2; 2388 resetval = mDateNavigator->sizeHint().width()+2;
2389 } else { 2389 } else {
2390 resetval = mDateNavigator->sizeHint().height()+2; 2390 resetval = mDateNavigator->sizeHint().height()+2;
2391 } 2391 }
2392 } 2392 }
2393 if ( resetval ) { 2393 if ( resetval ) {
2394 sizes.clear(); 2394 sizes.clear();
2395 if ( KOPrefs::instance()->mVerticalScreen ) { 2395 if ( KOPrefs::instance()->mVerticalScreen ) {
2396 maxVal = QApplication::desktop()->width() -10; 2396 maxVal = QApplication::desktop()->width() -10;
2397 } else { 2397 } else {
2398 maxVal = QApplication::desktop()->height()-10; 2398 maxVal = QApplication::desktop()->height()-10;
2399 } 2399 }
2400 sizes << resetval; 2400 sizes << resetval;
2401 if ( maxVal < resetval + resetval) 2401 if ( maxVal < resetval + resetval)
2402 resetval = maxVal - resetval; 2402 resetval = maxVal - resetval;
2403 sizes << resetval; 2403 sizes << resetval;
2404 sizes << 100; 2404 sizes << 100;
2405 } 2405 }
2406 mLeftFrame->setSizes(sizes); 2406 mLeftFrame->setSizes(sizes);
2407 sizes = config->readIntListEntry("Main Splitter Frame"); 2407 sizes = config->readIntListEntry("Main Splitter Frame");
2408 resetval = 0; 2408 resetval = 0;
2409 maxVal = 0; 2409 maxVal = 0;
2410 if (sizes.count() != 2) { 2410 if (sizes.count() != 2) {
2411 if ( !KOPrefs::instance()->mVerticalScreen ) { 2411 if ( !KOPrefs::instance()->mVerticalScreen ) {
2412 resetval = mDateNavigator->sizeHint().width()+2; 2412 resetval = mDateNavigator->sizeHint().width()+2;
2413 } else { 2413 } else {
2414 resetval = mDateNavigator->sizeHint().height()+2; 2414 resetval = mDateNavigator->sizeHint().height()+2;
2415 } 2415 }
2416 } 2416 }
2417 if ( resetval ) { 2417 if ( resetval ) {
2418 sizes.clear(); 2418 sizes.clear();
2419 if ( !KOPrefs::instance()->mVerticalScreen ) { 2419 if ( !KOPrefs::instance()->mVerticalScreen ) {
2420 maxVal = QApplication::desktop()->width() -10; 2420 maxVal = QApplication::desktop()->width() -10;
2421 } else { 2421 } else {
2422 maxVal = QApplication::desktop()->height()-10; 2422 maxVal = QApplication::desktop()->height()-10;
2423 } 2423 }
2424 sizes << resetval; 2424 sizes << resetval;
2425 if ( maxVal < resetval + resetval) 2425 if ( maxVal < resetval + resetval)
2426 resetval = maxVal - resetval; 2426 resetval = maxVal - resetval;
2427 sizes << resetval; 2427 sizes << resetval;
2428 } 2428 }
2429 mMainFrame->setSizes(sizes); 2429 mMainFrame->setSizes(sizes);
2430 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2430 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2431 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2431 else if ( dateCount == 7 ) mNavigator->selectWeek();
2432 else mNavigator->selectDates( dateCount ); 2432 else mNavigator->selectDates( dateCount );
2433 // mViewManager->readSettings( config ); 2433 // mViewManager->readSettings( config );
2434 updateConfig(); 2434 updateConfig();
2435 globalFlagBlockAgenda = 2; 2435 globalFlagBlockAgenda = 2;
2436 mViewManager->readSettings( config ); 2436 mViewManager->readSettings( config );
2437 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2437 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2438} 2438}
2439 2439
2440void CalendarView::checkSuspendAlarm() 2440void CalendarView::checkSuspendAlarm()
2441{ 2441{
2442 if ( mSuspendTimer->isActive() ) { 2442 if ( mSuspendTimer->isActive() ) {
2443 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2443 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2444 } 2444 }
2445} 2445}
2446void CalendarView::writeSettings() 2446void CalendarView::writeSettings()
2447{ 2447{
2448 // kdDebug() << "CalendarView::writeSettings" << endl; 2448 // kdDebug() << "CalendarView::writeSettings" << endl;
2449 2449
2450 KConfig *config = KOGlobals::config(); 2450 KConfig *config = KOGlobals::config();
2451 2451
2452 mViewManager->writeSettings( config ); 2452 mViewManager->writeSettings( config );
2453 mTodoList->saveLayout(config,QString("Todo Layout")); 2453 mTodoList->saveLayout(config,QString("Todo Layout"));
2454 mDialogManager->writeSettings( config ); 2454 mDialogManager->writeSettings( config );
2455 //KOPrefs::instance()->usrWriteConfig(); 2455 //KOPrefs::instance()->usrWriteConfig();
2456 KOPrefs::instance()->writeConfig(); 2456 KOPrefs::instance()->writeConfig();
2457 2457
2458 writeFilterSettings(config); 2458 writeFilterSettings(config);
2459 config->setGroup( "AppRun" ); 2459 config->setGroup( "AppRun" );
2460 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2460 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2461 int days = dt.daysTo( QDate::currentDate() ); 2461 int days = dt.daysTo( QDate::currentDate() );
2462 dt = dt.addDays( days ); 2462 dt = dt.addDays( days );
2463 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2463 int secs = dt.secsTo( QDateTime::currentDateTime() );
2464 config->writeEntry( "LatestProgramStopDays", days ); 2464 config->writeEntry( "LatestProgramStopDays", days );
2465 config->writeEntry( "LatestProgramStopSecs", secs ); 2465 config->writeEntry( "LatestProgramStopSecs", secs );
2466 //qDebug("KO: Writing stop time: %d ", secs); 2466 //qDebug("KO: Writing stop time: %d ", secs);
2467 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2467 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2468 //QDateTime latest = dt.addSecs ( secs ); 2468 //QDateTime latest = dt.addSecs ( secs );
2469 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2469 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2470 config->setGroup( "Views" ); 2470 config->setGroup( "Views" );
2471 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2471 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2472 2472
2473#if 0 2473#if 0
2474 qDebug("********************* "); 2474 qDebug("********************* ");
2475 qDebug("Testcode secsto "); 2475 qDebug("Testcode secsto ");
2476 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2476 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2477 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2477 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2478 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2478 int secsto = dt_nodaylight.secsTo( dt_daylight );
2479 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2479 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2480 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2480 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2481 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2481 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2482 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2482 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2483 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2483 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2484 qDebug("********************* testcode end"); 2484 qDebug("********************* testcode end");
2485 2485
2486#endif 2486#endif
2487 2487
2488 QValueList<int> listINT = mLeftFrame->sizes(); 2488 QValueList<int> listINT = mLeftFrame->sizes();
2489 config->writeEntry("Left Splitter Frame",listINT); 2489 config->writeEntry("Left Splitter Frame",listINT);
2490 QValueList<int> listINT2 = mMainFrame->sizes(); 2490 QValueList<int> listINT2 = mMainFrame->sizes();
2491 config->writeEntry("Main Splitter Frame",listINT2); 2491 config->writeEntry("Main Splitter Frame",listINT2);
2492#ifdef DESKTOP_VERSION 2492#ifdef DESKTOP_VERSION
2493 config->setGroup("WidgetLayout"); 2493 config->setGroup("WidgetLayout");
2494 QStringList list ;//= config->readListEntry("MainLayout"); 2494 QStringList list ;//= config->readListEntry("MainLayout");
2495 int x,y,w,h; 2495 int x,y,w,h;
2496 QWidget* wid; 2496 QWidget* wid;
2497 wid = topLevelWidget(); 2497 wid = topLevelWidget();
2498 x = wid->geometry().x(); 2498 x = wid->geometry().x();
2499 y = wid->geometry().y(); 2499 y = wid->geometry().y();
2500 w = wid->width(); 2500 w = wid->width();
2501 h = wid->height(); 2501 h = wid->height();
2502 list.clear(); 2502 list.clear();
2503 list << QString::number( x ); 2503 list << QString::number( x );
2504 list << QString::number( y ); 2504 list << QString::number( y );
2505 list << QString::number( w ); 2505 list << QString::number( w );
2506 list << QString::number( h ); 2506 list << QString::number( h );
2507 config->writeEntry("MainLayout",list ); 2507 config->writeEntry("MainLayout",list );
2508 2508
2509 wid = mEventEditor; 2509 wid = mEventEditor;
2510 x = wid->geometry().x(); 2510 x = wid->geometry().x();
2511 y = wid->geometry().y(); 2511 y = wid->geometry().y();
2512 w = wid->width(); 2512 w = wid->width();
2513 h = wid->height(); 2513 h = wid->height();
2514 list.clear(); 2514 list.clear();
2515 list << QString::number( x ); 2515 list << QString::number( x );
2516 list << QString::number( y ); 2516 list << QString::number( y );
2517 list << QString::number( w ); 2517 list << QString::number( w );
2518 list << QString::number( h ); 2518 list << QString::number( h );
2519 config->writeEntry("EditEventLayout",list ); 2519 config->writeEntry("EditEventLayout",list );
2520 2520
2521 wid = mTodoEditor; 2521 wid = mTodoEditor;
2522 x = wid->geometry().x(); 2522 x = wid->geometry().x();
2523 y = wid->geometry().y(); 2523 y = wid->geometry().y();
2524 w = wid->width(); 2524 w = wid->width();
2525 h = wid->height(); 2525 h = wid->height();
2526 list.clear(); 2526 list.clear();
2527 list << QString::number( x ); 2527 list << QString::number( x );
2528 list << QString::number( y ); 2528 list << QString::number( y );
2529 list << QString::number( w ); 2529 list << QString::number( w );
2530 list << QString::number( h ); 2530 list << QString::number( h );
2531 config->writeEntry("EditTodoLayout",list ); 2531 config->writeEntry("EditTodoLayout",list );
2532 wid = getEventViewerDialog(); 2532 wid = getEventViewerDialog();
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("ViewerLayout",list ); 2542 config->writeEntry("ViewerLayout",list );
2543 wid = mDialogManager->getSearchDialog(); 2543 wid = mDialogManager->getSearchDialog();
2544 if ( wid ) { 2544 if ( wid ) {
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("SearchLayout",list ); 2554 config->writeEntry("SearchLayout",list );
2555 } 2555 }
2556#endif 2556#endif
2557 2557
2558 2558
2559 config->sync(); 2559 config->sync();
2560} 2560}
2561 2561
2562void CalendarView::readFilterSettings(KConfig *config) 2562void CalendarView::readFilterSettings(KConfig *config)
2563{ 2563{
2564 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2564 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2565 2565
2566 mFilters.clear(); 2566 mFilters.clear();
2567 2567
2568 config->setGroup("General"); 2568 config->setGroup("General");
2569 QStringList filterList = config->readListEntry("CalendarFilters"); 2569 QStringList filterList = config->readListEntry("CalendarFilters");
2570 2570
2571 QStringList::ConstIterator it = filterList.begin(); 2571 QStringList::ConstIterator it = filterList.begin();
2572 QStringList::ConstIterator end = filterList.end(); 2572 QStringList::ConstIterator end = filterList.end();
2573 while(it != end) { 2573 while(it != end) {
2574 // kdDebug() << " filter: " << (*it) << endl; 2574 // kdDebug() << " filter: " << (*it) << endl;
2575 2575
2576 CalFilter *filter; 2576 CalFilter *filter;
2577 filter = new CalFilter(*it); 2577 filter = new CalFilter(*it);
2578 config->setGroup("Filter_" + (*it).utf8()); 2578 config->setGroup("Filter_" + (*it).utf8());
2579 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2579 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2580 filter->setCriteria(config->readNumEntry("Criteria",0)); 2580 filter->setCriteria(config->readNumEntry("Criteria",0));
2581 filter->setCategoryList(config->readListEntry("CategoryList")); 2581 filter->setCategoryList(config->readListEntry("CategoryList"));
2582 mFilters.append(filter); 2582 mFilters.append(filter);
2583 2583
2584 ++it; 2584 ++it;
2585 } 2585 }
2586 2586
2587 if (mFilters.count() == 0) { 2587 if (mFilters.count() == 0) {
2588 CalFilter *filter = new CalFilter(i18n("Default")); 2588 CalFilter *filter = new CalFilter(i18n("Default"));
2589 mFilters.append(filter); 2589 mFilters.append(filter);
2590 } 2590 }
2591 mFilterView->updateFilters(); 2591 mFilterView->updateFilters();
2592 config->setGroup("FilterView"); 2592 config->setGroup("FilterView");
2593 2593
2594 mFilterView->blockSignals(true); 2594 mFilterView->blockSignals(true);
2595 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2595 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2596 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2596 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2597 mFilterView->blockSignals(false); 2597 mFilterView->blockSignals(false);
2598 // We do it manually to avoid it being done twice by the above calls 2598 // We do it manually to avoid it being done twice by the above calls
2599 updateFilter(); 2599 updateFilter();
2600} 2600}
2601 2601
2602void CalendarView::writeFilterSettings(KConfig *config) 2602void CalendarView::writeFilterSettings(KConfig *config)
2603{ 2603{
2604 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2604 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2605 2605
2606 QStringList filterList; 2606 QStringList filterList;
2607 2607
2608 CalFilter *filter = mFilters.first(); 2608 CalFilter *filter = mFilters.first();
2609 while(filter) { 2609 while(filter) {
2610 // kdDebug() << " fn: " << filter->name() << endl; 2610 // kdDebug() << " fn: " << filter->name() << endl;
2611 filterList << filter->name(); 2611 filterList << filter->name();
2612 config->setGroup("Filter_" + filter->name().utf8()); 2612 config->setGroup("Filter_" + filter->name().utf8());
2613 config->writeEntry("Criteria",filter->criteria()); 2613 config->writeEntry("Criteria",filter->criteria());
2614 config->writeEntry("CategoryList",filter->categoryList()); 2614 config->writeEntry("CategoryList",filter->categoryList());
2615 filter = mFilters.next(); 2615 filter = mFilters.next();
2616 } 2616 }
2617 config->setGroup("General"); 2617 config->setGroup("General");
2618 config->writeEntry("CalendarFilters",filterList); 2618 config->writeEntry("CalendarFilters",filterList);
2619 2619
2620 config->setGroup("FilterView"); 2620 config->setGroup("FilterView");
2621 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2621 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2622 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2622 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2623} 2623}
2624 2624
2625 2625
2626void CalendarView::goToday() 2626void CalendarView::goToday()
2627{ 2627{
2628 if ( mViewManager->currentView()->isMonthView() ) 2628 if ( mViewManager->currentView()->isMonthView() )
2629 mNavigator->selectTodayMonth(); 2629 mNavigator->selectTodayMonth();
2630 else 2630 else
2631 mNavigator->selectToday(); 2631 mNavigator->selectToday();
2632} 2632}
2633 2633
2634void CalendarView::goNext() 2634void CalendarView::goNext()
2635{ 2635{
2636 mNavigator->selectNext(); 2636 mNavigator->selectNext();
2637} 2637}
2638 2638
2639void CalendarView::goPrevious() 2639void CalendarView::goPrevious()
2640{ 2640{
2641 mNavigator->selectPrevious(); 2641 mNavigator->selectPrevious();
2642} 2642}
2643void CalendarView::goNextMonth() 2643void CalendarView::goNextMonth()
2644{ 2644{
2645 mNavigator->selectNextMonth(); 2645 mNavigator->selectNextMonth();
2646} 2646}
2647 2647
2648void CalendarView::goPreviousMonth() 2648void CalendarView::goPreviousMonth()
2649{ 2649{
2650 mNavigator->selectPreviousMonth(); 2650 mNavigator->selectPreviousMonth();
2651} 2651}
2652 2652
2653void CalendarView::updateConfig() 2653void CalendarView::updateConfig()
2654{ 2654{
2655 if ( KOPrefs::instance()->mUseAppColors ) 2655 if ( KOPrefs::instance()->mUseAppColors )
2656 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2656 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2657 emit configChanged(); 2657 emit configChanged();
2658 mTodoList->updateConfig(); 2658 mTodoList->updateConfig();
2659 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2659 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2660 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2660 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2661 // To make the "fill window" configurations work 2661 // To make the "fill window" configurations work
2662 //mViewManager->raiseCurrentView(); 2662 //mViewManager->raiseCurrentView();
2663} 2663}
2664 2664
2665 2665
2666void CalendarView::eventChanged(Event *event) 2666void CalendarView::eventChanged(Event *event)
2667{ 2667{
2668 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2668 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2669 //updateUnmanagedViews(); 2669 //updateUnmanagedViews();
2670} 2670}
2671 2671
2672void CalendarView::eventAdded(Event *event) 2672void CalendarView::eventAdded(Event *event)
2673{ 2673{
2674 changeEventDisplay(event,KOGlobals::EVENTADDED); 2674 changeEventDisplay(event,KOGlobals::EVENTADDED);
2675} 2675}
2676 2676
2677void CalendarView::eventToBeDeleted(Event *) 2677void CalendarView::eventToBeDeleted(Event *)
2678{ 2678{
2679 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2679 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2680} 2680}
2681 2681
2682void CalendarView::eventDeleted() 2682void CalendarView::eventDeleted()
2683{ 2683{
2684 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2684 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2685} 2685}
2686void CalendarView::changeTodoDisplay(Todo *which, int action) 2686void CalendarView::changeTodoDisplay(Todo *which, int action)
2687{ 2687{
2688 changeIncidenceDisplay((Incidence *)which, action); 2688 changeIncidenceDisplay((Incidence *)which, action);
2689 mDateNavigator->updateView(); //LR 2689 mDateNavigator->updateView(); //LR
2690 //mDialogManager->updateSearchDialog(); 2690 //mDialogManager->updateSearchDialog();
2691 2691
2692 if (which) { 2692 if (which) {
2693 mViewManager->updateWNview(); 2693 mViewManager->updateWNview();
2694 //mTodoList->updateView(); 2694 //mTodoList->updateView();
2695 } 2695 }
2696 2696
2697} 2697}
2698 2698
2699void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2699void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2700{ 2700{
2701 updateUnmanagedViews(); 2701 updateUnmanagedViews();
2702 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2702 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2703 if ( action == KOGlobals::EVENTDELETED ) { //delete 2703 if ( action == KOGlobals::EVENTDELETED ) { //delete
2704 mCalendar->checkAlarmForIncidence( 0, true ); 2704 mCalendar->checkAlarmForIncidence( 0, true );
2705 if ( mEventViewerDialog ) 2705 if ( mEventViewerDialog )
2706 mEventViewerDialog->hide(); 2706 mEventViewerDialog->hide();
2707 } 2707 }
2708 else 2708 else
2709 mCalendar->checkAlarmForIncidence( which , false ); 2709 mCalendar->checkAlarmForIncidence( which , false );
2710} 2710}
2711 2711
2712// most of the changeEventDisplays() right now just call the view's 2712// most of the changeEventDisplays() right now just call the view's
2713// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2713// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2714void CalendarView::changeEventDisplay(Event *which, int action) 2714void CalendarView::changeEventDisplay(Event *which, int action)
2715{ 2715{
2716 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2716 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2717 changeIncidenceDisplay((Incidence *)which, action); 2717 changeIncidenceDisplay((Incidence *)which, action);
2718 static bool clearallviews = false; 2718 static bool clearallviews = false;
2719 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2719 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2720 if ( clearallviews ) { 2720 if ( clearallviews ) {
2721 clearAllViews(); 2721 clearAllViews();
2722 clearallviews = false; 2722 clearallviews = false;
2723 } 2723 }
2724 return; 2724 return;
2725 } 2725 }
2726 clearallviews = true; 2726 clearallviews = true;
2727 mDateNavigator->updateView(); 2727 mDateNavigator->updateView();
2728 //mDialogManager->updateSearchDialog(); 2728 //mDialogManager->updateSearchDialog();
2729 if (which) { 2729 if (which) {
2730 // If there is an event view visible update the display 2730 // If there is an event view visible update the display
2731 mViewManager->currentView()->changeEventDisplay(which,action); 2731 mViewManager->currentView()->changeEventDisplay(which,action);
2732 // TODO: check, if update needed 2732 // TODO: check, if update needed
2733 // if (which->getTodoStatus()) { 2733 // if (which->getTodoStatus()) {
2734 mTodoList->updateView(); 2734 mTodoList->updateView();
2735 if ( action != KOGlobals::EVENTDELETED ) { 2735 if ( action != KOGlobals::EVENTDELETED ) {
2736 mConflictingEvent = which ; 2736 mConflictingEvent = which ;
2737 QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); 2737 QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) );
2738 } 2738 }
2739 // } 2739 // }
2740 } else { 2740 } else {
2741 mViewManager->currentView()->updateView(); 2741 mViewManager->currentView()->updateView();
2742 } 2742 }
2743} 2743}
2744void CalendarView::checkConflictForEvent() 2744void CalendarView::checkConflictForEvent()
2745{ 2745{
2746 2746
2747 if (!KOPrefs::instance()->mConfirm) 2747 if (!KOPrefs::instance()->mConfirm)
2748 return; 2748 return;
2749 if ( ! mConflictingEvent ) return; 2749 if ( ! mConflictingEvent ) return;
2750 if ( mConflictingEvent->doesFloat() ) { 2750 if ( mConflictingEvent->isHoliday() || mConflictingEvent->isBirthday() || mConflictingEvent->isAnniversary() ) {
2751 mConflictingEvent = 0; 2751 mConflictingEvent = 0;
2752 return; 2752 return;
2753 } 2753 }
2754 QPtrList<Event> testlist = mCalendar->events(); 2754 QPtrList<Event> testlist = mCalendar->events();
2755 Event * test = testlist.first(); 2755 Event * test = testlist.first();
2756 QDateTime conflict; 2756 QDateTime conflict;
2757 QDateTime retVal; 2757 QDateTime retVal;
2758 bool found = false; 2758 bool found = false;
2759 Event * cE = 0; 2759 Event * cE = 0;
2760 QDateTime current = QDateTime::currentDateTime(); 2760 QDateTime current = QDateTime::currentDateTime();
2761 while ( test ) { 2761 while ( test ) {
2762 if ( !test->doesFloat() ) { 2762 if ( !test->doesFloat() ) {
2763 if ( mConflictingEvent->isOverlapping ( test, &retVal, &current ) ) { 2763 if ( mConflictingEvent->isOverlapping ( test, &retVal, &current ) ) {
2764 if ( ! found ) { 2764 if ( ! found ) {
2765 conflict = retVal; 2765 conflict = retVal;
2766 cE = test; 2766 cE = test;
2767 } else { 2767 } else {
2768 if ( retVal < conflict ) { 2768 if ( retVal < conflict ) {
2769 conflict = retVal; 2769 conflict = retVal;
2770 cE = test; 2770 cE = test;
2771 } 2771 }
2772 } 2772 }
2773 found = true; 2773 found = true;
2774 } 2774 }
2775 } 2775 }
2776 test = testlist.next(); 2776 test = testlist.next();
2777 } 2777 }
2778 if ( found ) { 2778 if ( found ) {
2779 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()) ) ; 2779 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()) ) ;
2780 qApp->processEvents(); 2780 qApp->processEvents();
2781 int km = KMessageBox::warningContinueCancel(this,mess, 2781 int km = KMessageBox::warningContinueCancel(this,mess,
2782 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); 2782 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!"));
2783 if ( km != KMessageBox::Continue ) 2783 if ( km != KMessageBox::Continue )
2784 return; 2784 return;
2785 2785
2786 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 2786 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
2787 mViewManager->showDayView(); 2787 mViewManager->showDayView();
2788 mNavigator->slotDaySelect( conflict.date() ); 2788 mNavigator->slotDaySelect( conflict.date() );
2789 int hour = conflict.time().hour(); 2789 int hour = conflict.time().hour();
2790 mViewManager->agendaView()->setStartHour( hour ); 2790 mViewManager->agendaView()->setStartHour( hour );
2791 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); 2791 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
2792 return;
2793 } 2792 }
2794 2793 mConflictingEvent = 0;
2795 return; 2794 return;
2796 2795
2797} 2796}
2798 2797
2799void CalendarView::updateTodoViews() 2798void CalendarView::updateTodoViews()
2800{ 2799{
2801 mTodoList->updateView(); 2800 mTodoList->updateView();
2802 mViewManager->currentView()->updateView(); 2801 mViewManager->currentView()->updateView();
2803 2802
2804} 2803}
2805 2804
2806 2805
2807 2806
2808void CalendarView::clearAllViews() 2807void CalendarView::clearAllViews()
2809{ 2808{
2810 mTodoList->clearList(); 2809 mTodoList->clearList();
2811 mViewManager->clearAllViews(); 2810 mViewManager->clearAllViews();
2812 SearchDialog * sd = mDialogManager->getSearchDialog(); 2811 SearchDialog * sd = mDialogManager->getSearchDialog();
2813 if ( sd ) { 2812 if ( sd ) {
2814 KOListView* kol = sd->listview(); 2813 KOListView* kol = sd->listview();
2815 if ( kol ) 2814 if ( kol )
2816 kol->clearList(); 2815 kol->clearList();
2817 } 2816 }
2818} 2817}
2819void CalendarView::updateView() 2818void CalendarView::updateView()
2820{ 2819{
2821 static bool clearallviews = false; 2820 static bool clearallviews = false;
2822 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2821 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2823 if ( clearallviews ) { 2822 if ( clearallviews ) {
2824 clearAllViews(); 2823 clearAllViews();
2825 clearallviews = false; 2824 clearallviews = false;
2826 } 2825 }
2827 return; 2826 return;
2828 } 2827 }
2829 clearallviews = true; 2828 clearallviews = true;
2830 DateList tmpList = mNavigator->selectedDates(); 2829 DateList tmpList = mNavigator->selectedDates();
2831 2830
2832 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2831 if ( KOPrefs::instance()->mHideNonStartedTodos )
2833 mTodoList->updateView(); 2832 mTodoList->updateView();
2834 // We assume that the navigator only selects consecutive days. 2833 // We assume that the navigator only selects consecutive days.
2835 updateView( tmpList.first(), tmpList.last() ); 2834 updateView( tmpList.first(), tmpList.last() );
2836} 2835}
2837 2836
2838void CalendarView::updateUnmanagedViews() 2837void CalendarView::updateUnmanagedViews()
2839{ 2838{
2840 mDateNavigator->updateDayMatrix(); 2839 mDateNavigator->updateDayMatrix();
2841} 2840}
2842 2841
2843int CalendarView::msgItemDelete(const QString name) 2842int CalendarView::msgItemDelete(const QString name)
2844{ 2843{
2845 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2844 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2846 i18n("This item will be\npermanently deleted."), 2845 i18n("This item will be\npermanently deleted."),
2847 i18n("KO/Pi Confirmation"),i18n("Delete")); 2846 i18n("KO/Pi Confirmation"),i18n("Delete"));
2848} 2847}
2849 2848
2850 2849
2851void CalendarView::edit_cut() 2850void CalendarView::edit_cut()
2852{ 2851{
2853 Event *anEvent=0; 2852 Event *anEvent=0;
2854 2853
2855 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2854 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2856 2855
2857 if (mViewManager->currentView()->isEventView()) { 2856 if (mViewManager->currentView()->isEventView()) {
2858 if ( incidence && incidence->typeID() == eventID ) { 2857 if ( incidence && incidence->typeID() == eventID ) {
2859 anEvent = static_cast<Event *>(incidence); 2858 anEvent = static_cast<Event *>(incidence);
2860 } 2859 }
2861 } 2860 }
2862 2861
2863 if (!anEvent) { 2862 if (!anEvent) {
2864 KNotifyClient::beep(); 2863 KNotifyClient::beep();
2865 return; 2864 return;
2866 } 2865 }
2867 DndFactory factory( mCalendar ); 2866 DndFactory factory( mCalendar );
2868 factory.cutIncidence(anEvent); 2867 factory.cutIncidence(anEvent);
2869 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2868 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2870} 2869}
2871 2870
2872void CalendarView::edit_copy() 2871void CalendarView::edit_copy()
2873{ 2872{
2874 Event *anEvent=0; 2873 Event *anEvent=0;
2875 2874
2876 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2875 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2877 2876
2878 if (mViewManager->currentView()->isEventView()) { 2877 if (mViewManager->currentView()->isEventView()) {
2879 if ( incidence && incidence->typeID() == eventID ) { 2878 if ( incidence && incidence->typeID() == eventID ) {
2880 anEvent = static_cast<Event *>(incidence); 2879 anEvent = static_cast<Event *>(incidence);
2881 } 2880 }
2882 } 2881 }
2883 2882
2884 if (!anEvent) { 2883 if (!anEvent) {
2885 KNotifyClient::beep(); 2884 KNotifyClient::beep();
2886 return; 2885 return;
2887 } 2886 }
2888 DndFactory factory( mCalendar ); 2887 DndFactory factory( mCalendar );
2889 factory.copyIncidence(anEvent); 2888 factory.copyIncidence(anEvent);
2890} 2889}
2891 2890
2892void CalendarView::edit_paste() 2891void CalendarView::edit_paste()
2893{ 2892{
2894 QDate date = mNavigator->selectedDates().first(); 2893 QDate date = mNavigator->selectedDates().first();
2895 2894
2896 DndFactory factory( mCalendar ); 2895 DndFactory factory( mCalendar );
2897 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2896 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2898 2897
2899 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2898 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2900} 2899}
2901void CalendarView::edit_global_options() 2900void CalendarView::edit_global_options()
2902{ 2901{
2903 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2902 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2904 emit save(); 2903 emit save();
2905 emit saveStopTimer(); 2904 emit saveStopTimer();
2906 mDialogManager->showGlobalOptionsDialog(); 2905 mDialogManager->showGlobalOptionsDialog();
2907 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2906 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2908 emit saveStopTimer(); 2907 emit saveStopTimer();
2909 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!"), 2908 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!"),
2910 i18n("Timezone settings"),i18n("Reload"))) { 2909 i18n("Timezone settings"),i18n("Reload"))) {
2911 qDebug("KO: TZ reload cancelled "); 2910 qDebug("KO: TZ reload cancelled ");
2912 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2911 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2913 return; 2912 return;
2914 } 2913 }
2915 qDebug("KO: Timezone change "); 2914 qDebug("KO: Timezone change ");
2916 loadCalendars(); 2915 loadCalendars();
2917 setModified(true); 2916 setModified(true);
2918 } 2917 }
2919 else 2918 else
2920 qDebug("KO: No tz change "); 2919 qDebug("KO: No tz change ");
2921} 2920}
2922void CalendarView::edit_options() 2921void CalendarView::edit_options()
2923{ 2922{
2924 mDialogManager->showOptionsDialog(); 2923 mDialogManager->showOptionsDialog();
2925} 2924}
2926 2925
2927 2926
2928void CalendarView::slotSelectPickerDate( QDate d) 2927void CalendarView::slotSelectPickerDate( QDate d)
2929{ 2928{
2930 mDateFrame->hide(); 2929 mDateFrame->hide();
2931 if ( mDatePickerMode == 1 ) { 2930 if ( mDatePickerMode == 1 ) {
2932 mNavigator->slotDaySelect( d ); 2931 mNavigator->slotDaySelect( d );
2933 } else if ( mDatePickerMode == 2 ) { 2932 } else if ( mDatePickerMode == 2 ) {
2934 if ( mMoveIncidence->typeID() == todoID ) { 2933 if ( mMoveIncidence->typeID() == todoID ) {
2935 Todo * to = (Todo *) mMoveIncidence; 2934 Todo * to = (Todo *) mMoveIncidence;
2936 QTime tim; 2935 QTime tim;
2937 int len = 0; 2936 int len = 0;
2938 if ( to->hasStartDate() && to->hasDueDate() ) 2937 if ( to->hasStartDate() && to->hasDueDate() )
2939 len = to->dtStart().secsTo( to->dtDue()); 2938 len = to->dtStart().secsTo( to->dtDue());
2940 if ( to->hasDueDate() ) 2939 if ( to->hasDueDate() )
2941 tim = to->dtDue().time(); 2940 tim = to->dtDue().time();
2942 else { 2941 else {
2943 tim = QTime ( 0,0,0 ); 2942 tim = QTime ( 0,0,0 );
2944 to->setFloats( true ); 2943 to->setFloats( true );
2945 to->setHasDueDate( true ); 2944 to->setHasDueDate( true );
2946 } 2945 }
2947 QDateTime dt ( d,tim ); 2946 QDateTime dt ( d,tim );
2948 to->setDtDue( dt ); 2947 to->setDtDue( dt );
2949 2948
2950 if ( to->hasStartDate() ) { 2949 if ( to->hasStartDate() ) {
2951 if ( len>0 ) 2950 if ( len>0 )
2952 to->setDtStart(to->dtDue().addSecs( -len )); 2951 to->setDtStart(to->dtDue().addSecs( -len ));
2953 else 2952 else
2954 if (to->dtStart() > to->dtDue() ) 2953 if (to->dtStart() > to->dtDue() )
2955 to->setDtStart(to->dtDue().addDays( -3 )); 2954 to->setDtStart(to->dtDue().addDays( -3 ));
2956 } 2955 }
2957 2956
2958 todoChanged( to ); 2957 todoChanged( to );
2959 } else if ( mMoveIncidence->typeID() == eventID ) { 2958 } else if ( mMoveIncidence->typeID() == eventID ) {
2960 if ( mMoveIncidence->doesRecur() ) { 2959 if ( mMoveIncidence->doesRecur() ) {
2961#if 0 2960#if 0
2962 // PENDING implement this 2961 // PENDING implement this
2963 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2962 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2964 mCalendar()->addIncidence( newInc ); 2963 mCalendar()->addIncidence( newInc );
2965 if ( mMoveIncidence->typeID() == todoID ) 2964 if ( mMoveIncidence->typeID() == todoID )
2966 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2965 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2967 else 2966 else
2968 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2967 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2969 mMoveIncidence = newInc; 2968 mMoveIncidence = newInc;
2970 2969
2971#endif 2970#endif
2972 } 2971 }
2973 QTime tim = mMoveIncidence->dtStart().time(); 2972 QTime tim = mMoveIncidence->dtStart().time();
2974 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2973 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2975 QDateTime dt ( d,tim ); 2974 QDateTime dt ( d,tim );
2976 mMoveIncidence->setDtStart( dt ); 2975 mMoveIncidence->setDtStart( dt );
2977 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2976 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2978 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2977 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2979 } else if ( mMoveIncidence->typeID() == journalID ) { 2978 } else if ( mMoveIncidence->typeID() == journalID ) {
2980 QTime tim = mMoveIncidence->dtStart().time(); 2979 QTime tim = mMoveIncidence->dtStart().time();
2981 QDateTime dt ( d,tim ); 2980 QDateTime dt ( d,tim );
2982 mMoveIncidence->setDtStart( dt ); 2981 mMoveIncidence->setDtStart( dt );
2983 updateView(); 2982 updateView();
2984 } 2983 }
2985 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2984 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2986 } 2985 }
2987} 2986}
2988 2987
2989void CalendarView::removeCategories() 2988void CalendarView::removeCategories()
2990{ 2989{
2991 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2990 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2992 QStringList catList = KOPrefs::instance()->mCustomCategories; 2991 QStringList catList = KOPrefs::instance()->mCustomCategories;
2993 QStringList catIncList; 2992 QStringList catIncList;
2994 QStringList newCatList; 2993 QStringList newCatList;
2995 Incidence* inc = incList.first(); 2994 Incidence* inc = incList.first();
2996 uint i; 2995 uint i;
2997 while ( inc ) { 2996 while ( inc ) {
2998 newCatList.clear(); 2997 newCatList.clear();
2999 catIncList = inc->categories() ; 2998 catIncList = inc->categories() ;
3000 for( i = 0; i< catIncList.count(); ++i ) { 2999 for( i = 0; i< catIncList.count(); ++i ) {
3001 if ( catList.contains (catIncList[i])) 3000 if ( catList.contains (catIncList[i]))
3002 newCatList.append( catIncList[i] ); 3001 newCatList.append( catIncList[i] );
3003 } 3002 }
3004 newCatList.sort(); 3003 newCatList.sort();
3005 inc->setCategories( newCatList.join(",") ); 3004 inc->setCategories( newCatList.join(",") );
3006 inc = incList.next(); 3005 inc = incList.next();
3007 } 3006 }
3008} 3007}
3009 3008
3010int CalendarView::addCategories() 3009int CalendarView::addCategories()
3011{ 3010{
3012 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3011 QPtrList<Incidence> incList = mCalendar->rawIncidences();
3013 QStringList catList = KOPrefs::instance()->mCustomCategories; 3012 QStringList catList = KOPrefs::instance()->mCustomCategories;
3014 QStringList catIncList; 3013 QStringList catIncList;
3015 Incidence* inc = incList.first(); 3014 Incidence* inc = incList.first();
3016 uint i; 3015 uint i;
3017 int count = 0; 3016 int count = 0;
3018 while ( inc ) { 3017 while ( inc ) {
3019 catIncList = inc->categories() ; 3018 catIncList = inc->categories() ;
3020 for( i = 0; i< catIncList.count(); ++i ) { 3019 for( i = 0; i< catIncList.count(); ++i ) {
3021 if ( !catList.contains (catIncList[i])) { 3020 if ( !catList.contains (catIncList[i])) {
3022 catList.append( catIncList[i] ); 3021 catList.append( catIncList[i] );
3023 //qDebug("add cat %s ", catIncList[i].latin1()); 3022 //qDebug("add cat %s ", catIncList[i].latin1());
3024 ++count; 3023 ++count;
3025 } 3024 }
3026 } 3025 }
3027 inc = incList.next(); 3026 inc = incList.next();
3028 } 3027 }
3029 catList.sort(); 3028 catList.sort();
3030 KOPrefs::instance()->mCustomCategories = catList; 3029 KOPrefs::instance()->mCustomCategories = catList;
3031 return count; 3030 return count;
3032} 3031}
3033 3032
3034void CalendarView::editCategories() 3033void CalendarView::editCategories()
3035{ 3034{
3036 qDebug("CalendarView::editCategories() "); 3035 qDebug("CalendarView::editCategories() ");
3037 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); 3036 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this );
3038 ced.exec(); 3037 ced.exec();
3039} 3038}
3040void CalendarView::manageCategories() 3039void CalendarView::manageCategories()
3041{ 3040{
3042 KOCatPrefs* cp = new KOCatPrefs(); 3041 KOCatPrefs* cp = new KOCatPrefs();
3043 cp->show(); 3042 cp->show();
3044 int w =cp->sizeHint().width() ; 3043 int w =cp->sizeHint().width() ;
3045 int h = cp->sizeHint().height() ; 3044 int h = cp->sizeHint().height() ;
3046 int dw = QApplication::desktop()->width(); 3045 int dw = QApplication::desktop()->width();
3047 int dh = QApplication::desktop()->height(); 3046 int dh = QApplication::desktop()->height();
3048 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 3047 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
3049 if ( !cp->exec() ) { 3048 if ( !cp->exec() ) {
3050 delete cp; 3049 delete cp;
3051 return; 3050 return;
3052 } 3051 }
3053 int count = 0; 3052 int count = 0;
3054 if ( cp->addCat() ) { 3053 if ( cp->addCat() ) {
3055 count = addCategories(); 3054 count = addCategories();
3056 if ( count ) { 3055 if ( count ) {
3057 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 3056 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
3058 writeSettings(); 3057 writeSettings();
3059 } else 3058 } else
3060 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 3059 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
3061 } else { 3060 } else {
3062 removeCategories(); 3061 removeCategories();
3063 updateView(); 3062 updateView();
3064 } 3063 }
3065 delete cp; 3064 delete cp;
3066} 3065}
3067 3066
3068void CalendarView::beamIncidence(Incidence * Inc) 3067void CalendarView::beamIncidence(Incidence * Inc)
3069{ 3068{
3070 QPtrList<Incidence> delSel ; 3069 QPtrList<Incidence> delSel ;
3071 delSel.append(Inc); 3070 delSel.append(Inc);
3072 beamIncidenceList( delSel ); 3071 beamIncidenceList( delSel );
3073} 3072}
3074void CalendarView::beamCalendar() 3073void CalendarView::beamCalendar()
3075{ 3074{
3076 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 3075 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
3077 //qDebug("beamCalendar() "); 3076 //qDebug("beamCalendar() ");
3078 beamIncidenceList( delSel ); 3077 beamIncidenceList( delSel );
3079} 3078}
3080void CalendarView::beamFilteredCalendar() 3079void CalendarView::beamFilteredCalendar()
3081{ 3080{
3082 QPtrList<Incidence> delSel = mCalendar->incidences(); 3081 QPtrList<Incidence> delSel = mCalendar->incidences();
3083 //qDebug("beamFilteredCalendar() "); 3082 //qDebug("beamFilteredCalendar() ");
3084 beamIncidenceList( delSel ); 3083 beamIncidenceList( delSel );
3085} 3084}
3086void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 3085void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
3087{ 3086{
3088 3087
3089 KOBeamPrefs beamDialog; 3088 KOBeamPrefs beamDialog;
3090 if ( beamDialog.exec () == QDialog::Rejected ) 3089 if ( beamDialog.exec () == QDialog::Rejected )
3091 return; 3090 return;
3092#ifdef DESKTOP_VERSION 3091#ifdef DESKTOP_VERSION
3093 QString fn = locateLocal( "tmp", "kopibeamfile" ); 3092 QString fn = locateLocal( "tmp", "kopibeamfile" );
3094#else 3093#else
3095 QString fn = "/tmp/kopibeamfile"; 3094 QString fn = "/tmp/kopibeamfile";
3096#endif 3095#endif
3097 QString mes; 3096 QString mes;
3098 bool createbup = true; 3097 bool createbup = true;
3099 if ( createbup ) { 3098 if ( createbup ) {
3100 QString description = "\n"; 3099 QString description = "\n";
3101 CalendarLocal* cal = new CalendarLocal(); 3100 CalendarLocal* cal = new CalendarLocal();
3102 if ( beamDialog.beamLocal() ) 3101 if ( beamDialog.beamLocal() )
3103 cal->setLocalTime(); 3102 cal->setLocalTime();
3104 else 3103 else
3105 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3104 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
3106 Incidence *incidence = delSel.first(); 3105 Incidence *incidence = delSel.first();
3107 bool addText = false; 3106 bool addText = false;
3108 if ( delSel.count() < 10 ) 3107 if ( delSel.count() < 10 )
3109 addText = true; 3108 addText = true;
3110 else { 3109 else {
3111 description.sprintf(i18n(" %d items?"),delSel.count() ); 3110 description.sprintf(i18n(" %d items?"),delSel.count() );
3112 } 3111 }
3113 while ( incidence ) { 3112 while ( incidence ) {
3114 Incidence *in = incidence->clone(); 3113 Incidence *in = incidence->clone();
3115 if ( ! in->summary().isEmpty() ) { 3114 if ( ! in->summary().isEmpty() ) {
3116 in->setDescription(""); 3115 in->setDescription("");
3117 } else { 3116 } else {
3118 in->setSummary( in->description().left(20)); 3117 in->setSummary( in->description().left(20));
3119 in->setDescription(""); 3118 in->setDescription("");
3120 } 3119 }
3121 if ( addText ) 3120 if ( addText )
3122 description += in->summary() + "\n"; 3121 description += in->summary() + "\n";
3123 cal->addIncidence( in ); 3122 cal->addIncidence( in );
3124 incidence = delSel.next(); 3123 incidence = delSel.next();
3125 } 3124 }
3126 if ( beamDialog.beamVcal() ) { 3125 if ( beamDialog.beamVcal() ) {
3127 fn += ".vcs"; 3126 fn += ".vcs";
3128 FileStorage storage( cal, fn, new VCalFormat ); 3127 FileStorage storage( cal, fn, new VCalFormat );
3129 storage.save(); 3128 storage.save();
3130 } else { 3129 } else {
3131 fn += ".ics"; 3130 fn += ".ics";
3132 FileStorage storage( cal, fn, new ICalFormat( ) ); 3131 FileStorage storage( cal, fn, new ICalFormat( ) );
3133 storage.save(); 3132 storage.save();
3134 } 3133 }
3135 delete cal; 3134 delete cal;
3136 mes = i18n("KO/Pi: Ready for beaming"); 3135 mes = i18n("KO/Pi: Ready for beaming");
3137 topLevelWidget()->setCaption(mes); 3136 topLevelWidget()->setCaption(mes);
3138 KApplication::convert2latin1( fn ); 3137 KApplication::convert2latin1( fn );
3139#ifndef DESKTOP_VERSION 3138#ifndef DESKTOP_VERSION
3140 Ir *ir = new Ir( this ); 3139 Ir *ir = new Ir( this );
3141 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 3140 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
3142 ir->send( fn, description, "text/x-vCalendar" ); 3141 ir->send( fn, description, "text/x-vCalendar" );
3143#endif 3142#endif
3144 } 3143 }
3145} 3144}
3146 3145
3147#ifndef DESKTOP_VERSION 3146#ifndef DESKTOP_VERSION
3148void CalendarView::beamDone( Ir *ir ) 3147void CalendarView::beamDone( Ir *ir )
3149{ 3148{
3150 delete ir; 3149 delete ir;
3151 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 3150 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
3152 topLevelWidget()->raise(); 3151 topLevelWidget()->raise();
3153} 3152}
3154#else 3153#else
3155void CalendarView::beamDone( Ir *){;} 3154void CalendarView::beamDone( Ir *){;}
3156#endif 3155#endif
3157void CalendarView::moveIncidence(Incidence * inc ) 3156void CalendarView::moveIncidence(Incidence * inc )
3158{ 3157{
3159 if ( !inc ) return; 3158 if ( !inc ) return;
3160 showDatePickerPopup(); 3159 showDatePickerPopup();
3161 mDatePickerMode = 2; 3160 mDatePickerMode = 2;
3162 mMoveIncidence = inc ; 3161 mMoveIncidence = inc ;
3163 QDate da; 3162 QDate da;
3164 if ( mMoveIncidence->typeID() == todoID ) { 3163 if ( mMoveIncidence->typeID() == todoID ) {
3165 Todo * to = (Todo *) mMoveIncidence; 3164 Todo * to = (Todo *) mMoveIncidence;
3166 if ( to->hasDueDate() ) 3165 if ( to->hasDueDate() )
3167 da = to->dtDue().date(); 3166 da = to->dtDue().date();
3168 else 3167 else
3169 da = QDate::currentDate(); 3168 da = QDate::currentDate();
3170 } else { 3169 } else {
3171 da = mMoveIncidence->dtStart().date(); 3170 da = mMoveIncidence->dtStart().date();
3172 } 3171 }
3173 //PENDING set date for recurring incidence to date of recurrence 3172 //PENDING set date for recurring incidence to date of recurrence
3174 //mMoveIncidenceOldDate; 3173 //mMoveIncidenceOldDate;
3175 mDatePicker->setDate( da ); 3174 mDatePicker->setDate( da );
3176} 3175}
3177void CalendarView::showDatePickerPopup() 3176void CalendarView::showDatePickerPopup()
3178{ 3177{