summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-06 14:53:38 (UTC)
committer zautrix <zautrix>2005-07-06 14:53:38 (UTC)
commit2038f7363c31e1a0ab139a1184cbed10086e1862 (patch) (unidiff)
tree532bc409b7046938614417a8043455de0e86c8fe
parent2e8199c8aa82c018d24d67c299a09b2aa6a786f1 (diff)
downloadkdepimpi-2038f7363c31e1a0ab139a1184cbed10086e1862.zip
kdepimpi-2038f7363c31e1a0ab139a1184cbed10086e1862.tar.gz
kdepimpi-2038f7363c31e1a0ab139a1184cbed10086e1862.tar.bz2
huhu
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 558fc55..98e0ac1 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -2248,768 +2248,782 @@ void CalendarView::readSettings()
2248 config->setGroup("WidgetLayout"); 2248 config->setGroup("WidgetLayout");
2249 QStringList list; 2249 QStringList list;
2250 list = config->readListEntry("MainLayout"); 2250 list = config->readListEntry("MainLayout");
2251 int x,y,w,h; 2251 int x,y,w,h;
2252 if ( ! list.isEmpty() ) { 2252 if ( ! list.isEmpty() ) {
2253 x = list[0].toInt(); 2253 x = list[0].toInt();
2254 y = list[1].toInt(); 2254 y = list[1].toInt();
2255 w = list[2].toInt(); 2255 w = list[2].toInt();
2256 h = list[3].toInt(); 2256 h = list[3].toInt();
2257 KApplication::testCoords( &x,&y,&w,&h ); 2257 KApplication::testCoords( &x,&y,&w,&h );
2258 topLevelWidget()->setGeometry(x,y,w,h); 2258 topLevelWidget()->setGeometry(x,y,w,h);
2259 2259
2260 } else { 2260 } else {
2261 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2261 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2262 } 2262 }
2263 list = config->readListEntry("EditEventLayout"); 2263 list = config->readListEntry("EditEventLayout");
2264 if ( ! list.isEmpty() ) { 2264 if ( ! list.isEmpty() ) {
2265 x = list[0].toInt(); 2265 x = list[0].toInt();
2266 y = list[1].toInt(); 2266 y = list[1].toInt();
2267 w = list[2].toInt(); 2267 w = list[2].toInt();
2268 h = list[3].toInt(); 2268 h = list[3].toInt();
2269 KApplication::testCoords( &x,&y,&w,&h ); 2269 KApplication::testCoords( &x,&y,&w,&h );
2270 mEventEditor->setGeometry(x,y,w,h); 2270 mEventEditor->setGeometry(x,y,w,h);
2271 2271
2272 } 2272 }
2273 list = config->readListEntry("EditTodoLayout"); 2273 list = config->readListEntry("EditTodoLayout");
2274 if ( ! list.isEmpty() ) { 2274 if ( ! list.isEmpty() ) {
2275 x = list[0].toInt(); 2275 x = list[0].toInt();
2276 y = list[1].toInt(); 2276 y = list[1].toInt();
2277 w = list[2].toInt(); 2277 w = list[2].toInt();
2278 h = list[3].toInt(); 2278 h = list[3].toInt();
2279 KApplication::testCoords( &x,&y,&w,&h ); 2279 KApplication::testCoords( &x,&y,&w,&h );
2280 mTodoEditor->setGeometry(x,y,w,h); 2280 mTodoEditor->setGeometry(x,y,w,h);
2281 2281
2282 } 2282 }
2283 list = config->readListEntry("ViewerLayout"); 2283 list = config->readListEntry("ViewerLayout");
2284 if ( ! list.isEmpty() ) { 2284 if ( ! list.isEmpty() ) {
2285 x = list[0].toInt(); 2285 x = list[0].toInt();
2286 y = list[1].toInt(); 2286 y = list[1].toInt();
2287 w = list[2].toInt(); 2287 w = list[2].toInt();
2288 h = list[3].toInt(); 2288 h = list[3].toInt();
2289 KApplication::testCoords( &x,&y,&w,&h ); 2289 KApplication::testCoords( &x,&y,&w,&h );
2290 getEventViewerDialog()->setGeometry(x,y,w,h); 2290 getEventViewerDialog()->setGeometry(x,y,w,h);
2291 } 2291 }
2292#endif 2292#endif
2293 config->setGroup( "Views" ); 2293 config->setGroup( "Views" );
2294 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2294 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2295 2295
2296 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2296 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2297 2297
2298 int resetval = 0; 2298 int resetval = 0;
2299 int maxVal = 0; 2299 int maxVal = 0;
2300 if (sizes.count() != 3) { 2300 if (sizes.count() != 3) {
2301 if ( KOPrefs::instance()->mVerticalScreen ) { 2301 if ( KOPrefs::instance()->mVerticalScreen ) {
2302 resetval = mDateNavigator->sizeHint().width()+2; 2302 resetval = mDateNavigator->sizeHint().width()+2;
2303 } else { 2303 } else {
2304 resetval = mDateNavigator->sizeHint().height()+2; 2304 resetval = mDateNavigator->sizeHint().height()+2;
2305 } 2305 }
2306 } 2306 }
2307 if ( resetval ) { 2307 if ( resetval ) {
2308 sizes.clear(); 2308 sizes.clear();
2309 if ( KOPrefs::instance()->mVerticalScreen ) { 2309 if ( KOPrefs::instance()->mVerticalScreen ) {
2310 maxVal = QApplication::desktop()->width() -10; 2310 maxVal = QApplication::desktop()->width() -10;
2311 } else { 2311 } else {
2312 maxVal = QApplication::desktop()->height()-10; 2312 maxVal = QApplication::desktop()->height()-10;
2313 } 2313 }
2314 sizes << resetval; 2314 sizes << resetval;
2315 if ( maxVal < resetval + resetval) 2315 if ( maxVal < resetval + resetval)
2316 resetval = maxVal - resetval; 2316 resetval = maxVal - resetval;
2317 sizes << resetval; 2317 sizes << resetval;
2318 sizes << 100; 2318 sizes << 100;
2319 } 2319 }
2320 mLeftFrame->setSizes(sizes); 2320 mLeftFrame->setSizes(sizes);
2321 sizes = config->readIntListEntry("Main Splitter Frame"); 2321 sizes = config->readIntListEntry("Main Splitter Frame");
2322 resetval = 0; 2322 resetval = 0;
2323 maxVal = 0; 2323 maxVal = 0;
2324 if (sizes.count() != 2) { 2324 if (sizes.count() != 2) {
2325 if ( !KOPrefs::instance()->mVerticalScreen ) { 2325 if ( !KOPrefs::instance()->mVerticalScreen ) {
2326 resetval = mDateNavigator->sizeHint().width()+2; 2326 resetval = mDateNavigator->sizeHint().width()+2;
2327 } else { 2327 } else {
2328 resetval = mDateNavigator->sizeHint().height()+2; 2328 resetval = mDateNavigator->sizeHint().height()+2;
2329 } 2329 }
2330 } 2330 }
2331 if ( resetval ) { 2331 if ( resetval ) {
2332 sizes.clear(); 2332 sizes.clear();
2333 if ( !KOPrefs::instance()->mVerticalScreen ) { 2333 if ( !KOPrefs::instance()->mVerticalScreen ) {
2334 maxVal = QApplication::desktop()->width() -10; 2334 maxVal = QApplication::desktop()->width() -10;
2335 } else { 2335 } else {
2336 maxVal = QApplication::desktop()->height()-10; 2336 maxVal = QApplication::desktop()->height()-10;
2337 } 2337 }
2338 sizes << resetval; 2338 sizes << resetval;
2339 if ( maxVal < resetval + resetval) 2339 if ( maxVal < resetval + resetval)
2340 resetval = maxVal - resetval; 2340 resetval = maxVal - resetval;
2341 sizes << resetval; 2341 sizes << resetval;
2342 } 2342 }
2343 mMainFrame->setSizes(sizes); 2343 mMainFrame->setSizes(sizes);
2344 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2344 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2345 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2345 else if ( dateCount == 7 ) mNavigator->selectWeek();
2346 else mNavigator->selectDates( dateCount ); 2346 else mNavigator->selectDates( dateCount );
2347 // mViewManager->readSettings( config ); 2347 // mViewManager->readSettings( config );
2348 updateConfig(); 2348 updateConfig();
2349 globalFlagBlockAgenda = 2; 2349 globalFlagBlockAgenda = 2;
2350 mViewManager->readSettings( config ); 2350 mViewManager->readSettings( config );
2351 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2351 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2352} 2352}
2353 2353
2354void CalendarView::checkSuspendAlarm() 2354void CalendarView::checkSuspendAlarm()
2355{ 2355{
2356 if ( mSuspendTimer->isActive() ) { 2356 if ( mSuspendTimer->isActive() ) {
2357 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2357 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2358 } 2358 }
2359} 2359}
2360void CalendarView::writeSettings() 2360void CalendarView::writeSettings()
2361{ 2361{
2362 // kdDebug() << "CalendarView::writeSettings" << endl; 2362 // kdDebug() << "CalendarView::writeSettings" << endl;
2363 2363
2364 KConfig *config = KOGlobals::config(); 2364 KConfig *config = KOGlobals::config();
2365 2365
2366 mViewManager->writeSettings( config ); 2366 mViewManager->writeSettings( config );
2367 mTodoList->saveLayout(config,QString("Todo Layout")); 2367 mTodoList->saveLayout(config,QString("Todo Layout"));
2368 mDialogManager->writeSettings( config ); 2368 mDialogManager->writeSettings( config );
2369 //KOPrefs::instance()->usrWriteConfig(); 2369 //KOPrefs::instance()->usrWriteConfig();
2370 KOPrefs::instance()->writeConfig(); 2370 KOPrefs::instance()->writeConfig();
2371 2371
2372 writeFilterSettings(config); 2372 writeFilterSettings(config);
2373 config->setGroup( "AppRun" ); 2373 config->setGroup( "AppRun" );
2374 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2374 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2375 int days = dt.daysTo( QDate::currentDate() ); 2375 int days = dt.daysTo( QDate::currentDate() );
2376 dt = dt.addDays( days ); 2376 dt = dt.addDays( days );
2377 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2377 int secs = dt.secsTo( QDateTime::currentDateTime() );
2378 config->writeEntry( "LatestProgramStopDays", days ); 2378 config->writeEntry( "LatestProgramStopDays", days );
2379 config->writeEntry( "LatestProgramStopSecs", secs ); 2379 config->writeEntry( "LatestProgramStopSecs", secs );
2380 //qDebug("KO: Writing stop time: %d ", secs); 2380 //qDebug("KO: Writing stop time: %d ", secs);
2381 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2381 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2382 //QDateTime latest = dt.addSecs ( secs ); 2382 //QDateTime latest = dt.addSecs ( secs );
2383 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2383 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2384 config->setGroup( "Views" ); 2384 config->setGroup( "Views" );
2385 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2385 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2386 2386
2387#if 0 2387#if 0
2388 qDebug("********************* "); 2388 qDebug("********************* ");
2389 qDebug("Testcode secsto "); 2389 qDebug("Testcode secsto ");
2390 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2390 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2391 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2391 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2392 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2392 int secsto = dt_nodaylight.secsTo( dt_daylight );
2393 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2393 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2394 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2394 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2395 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2395 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2396 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2396 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2397 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2397 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2398 qDebug("********************* testcode end"); 2398 qDebug("********************* testcode end");
2399 2399
2400#endif 2400#endif
2401 2401
2402 QValueList<int> listINT = mLeftFrame->sizes(); 2402 QValueList<int> listINT = mLeftFrame->sizes();
2403 config->writeEntry("Left Splitter Frame",listINT); 2403 config->writeEntry("Left Splitter Frame",listINT);
2404 QValueList<int> listINT2 = mMainFrame->sizes(); 2404 QValueList<int> listINT2 = mMainFrame->sizes();
2405 config->writeEntry("Main Splitter Frame",listINT2); 2405 config->writeEntry("Main Splitter Frame",listINT2);
2406#ifdef DESKTOP_VERSION 2406#ifdef DESKTOP_VERSION
2407 config->setGroup("WidgetLayout"); 2407 config->setGroup("WidgetLayout");
2408 QStringList list ;//= config->readListEntry("MainLayout"); 2408 QStringList list ;//= config->readListEntry("MainLayout");
2409 int x,y,w,h; 2409 int x,y,w,h;
2410 QWidget* wid; 2410 QWidget* wid;
2411 wid = topLevelWidget(); 2411 wid = topLevelWidget();
2412 x = wid->geometry().x(); 2412 x = wid->geometry().x();
2413 y = wid->geometry().y(); 2413 y = wid->geometry().y();
2414 w = wid->width(); 2414 w = wid->width();
2415 h = wid->height(); 2415 h = wid->height();
2416 list.clear(); 2416 list.clear();
2417 list << QString::number( x ); 2417 list << QString::number( x );
2418 list << QString::number( y ); 2418 list << QString::number( y );
2419 list << QString::number( w ); 2419 list << QString::number( w );
2420 list << QString::number( h ); 2420 list << QString::number( h );
2421 config->writeEntry("MainLayout",list ); 2421 config->writeEntry("MainLayout",list );
2422 2422
2423 wid = mEventEditor; 2423 wid = mEventEditor;
2424 x = wid->geometry().x(); 2424 x = wid->geometry().x();
2425 y = wid->geometry().y(); 2425 y = wid->geometry().y();
2426 w = wid->width(); 2426 w = wid->width();
2427 h = wid->height(); 2427 h = wid->height();
2428 list.clear(); 2428 list.clear();
2429 list << QString::number( x ); 2429 list << QString::number( x );
2430 list << QString::number( y ); 2430 list << QString::number( y );
2431 list << QString::number( w ); 2431 list << QString::number( w );
2432 list << QString::number( h ); 2432 list << QString::number( h );
2433 config->writeEntry("EditEventLayout",list ); 2433 config->writeEntry("EditEventLayout",list );
2434 2434
2435 wid = mTodoEditor; 2435 wid = mTodoEditor;
2436 x = wid->geometry().x(); 2436 x = wid->geometry().x();
2437 y = wid->geometry().y(); 2437 y = wid->geometry().y();
2438 w = wid->width(); 2438 w = wid->width();
2439 h = wid->height(); 2439 h = wid->height();
2440 list.clear(); 2440 list.clear();
2441 list << QString::number( x ); 2441 list << QString::number( x );
2442 list << QString::number( y ); 2442 list << QString::number( y );
2443 list << QString::number( w ); 2443 list << QString::number( w );
2444 list << QString::number( h ); 2444 list << QString::number( h );
2445 config->writeEntry("EditTodoLayout",list ); 2445 config->writeEntry("EditTodoLayout",list );
2446 wid = getEventViewerDialog(); 2446 wid = getEventViewerDialog();
2447 x = wid->geometry().x(); 2447 x = wid->geometry().x();
2448 y = wid->geometry().y(); 2448 y = wid->geometry().y();
2449 w = wid->width(); 2449 w = wid->width();
2450 h = wid->height(); 2450 h = wid->height();
2451 list.clear(); 2451 list.clear();
2452 list << QString::number( x ); 2452 list << QString::number( x );
2453 list << QString::number( y ); 2453 list << QString::number( y );
2454 list << QString::number( w ); 2454 list << QString::number( w );
2455 list << QString::number( h ); 2455 list << QString::number( h );
2456 config->writeEntry("ViewerLayout",list ); 2456 config->writeEntry("ViewerLayout",list );
2457 wid = mDialogManager->getSearchDialog(); 2457 wid = mDialogManager->getSearchDialog();
2458 if ( wid ) { 2458 if ( wid ) {
2459 x = wid->geometry().x(); 2459 x = wid->geometry().x();
2460 y = wid->geometry().y(); 2460 y = wid->geometry().y();
2461 w = wid->width(); 2461 w = wid->width();
2462 h = wid->height(); 2462 h = wid->height();
2463 list.clear(); 2463 list.clear();
2464 list << QString::number( x ); 2464 list << QString::number( x );
2465 list << QString::number( y ); 2465 list << QString::number( y );
2466 list << QString::number( w ); 2466 list << QString::number( w );
2467 list << QString::number( h ); 2467 list << QString::number( h );
2468 config->writeEntry("SearchLayout",list ); 2468 config->writeEntry("SearchLayout",list );
2469 } 2469 }
2470#endif 2470#endif
2471 2471
2472 2472
2473 config->sync(); 2473 config->sync();
2474} 2474}
2475 2475
2476void CalendarView::readFilterSettings(KConfig *config) 2476void CalendarView::readFilterSettings(KConfig *config)
2477{ 2477{
2478 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2478 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2479 2479
2480 mFilters.clear(); 2480 mFilters.clear();
2481 2481
2482 config->setGroup("General"); 2482 config->setGroup("General");
2483 QStringList filterList = config->readListEntry("CalendarFilters"); 2483 QStringList filterList = config->readListEntry("CalendarFilters");
2484 2484
2485 QStringList::ConstIterator it = filterList.begin(); 2485 QStringList::ConstIterator it = filterList.begin();
2486 QStringList::ConstIterator end = filterList.end(); 2486 QStringList::ConstIterator end = filterList.end();
2487 while(it != end) { 2487 while(it != end) {
2488 // kdDebug() << " filter: " << (*it) << endl; 2488 // kdDebug() << " filter: " << (*it) << endl;
2489 2489
2490 CalFilter *filter; 2490 CalFilter *filter;
2491 filter = new CalFilter(*it); 2491 filter = new CalFilter(*it);
2492 config->setGroup("Filter_" + (*it).utf8()); 2492 config->setGroup("Filter_" + (*it).utf8());
2493 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2493 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2494 filter->setCriteria(config->readNumEntry("Criteria",0)); 2494 filter->setCriteria(config->readNumEntry("Criteria",0));
2495 filter->setCategoryList(config->readListEntry("CategoryList")); 2495 filter->setCategoryList(config->readListEntry("CategoryList"));
2496 mFilters.append(filter); 2496 mFilters.append(filter);
2497 2497
2498 ++it; 2498 ++it;
2499 } 2499 }
2500 2500
2501 if (mFilters.count() == 0) { 2501 if (mFilters.count() == 0) {
2502 CalFilter *filter = new CalFilter(i18n("Default")); 2502 CalFilter *filter = new CalFilter(i18n("Default"));
2503 mFilters.append(filter); 2503 mFilters.append(filter);
2504 } 2504 }
2505 mFilterView->updateFilters(); 2505 mFilterView->updateFilters();
2506 config->setGroup("FilterView"); 2506 config->setGroup("FilterView");
2507 2507
2508 mFilterView->blockSignals(true); 2508 mFilterView->blockSignals(true);
2509 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2509 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2510 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2510 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2511 mFilterView->blockSignals(false); 2511 mFilterView->blockSignals(false);
2512 // We do it manually to avoid it being done twice by the above calls 2512 // We do it manually to avoid it being done twice by the above calls
2513 updateFilter(); 2513 updateFilter();
2514} 2514}
2515 2515
2516void CalendarView::writeFilterSettings(KConfig *config) 2516void CalendarView::writeFilterSettings(KConfig *config)
2517{ 2517{
2518 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2518 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2519 2519
2520 QStringList filterList; 2520 QStringList filterList;
2521 2521
2522 CalFilter *filter = mFilters.first(); 2522 CalFilter *filter = mFilters.first();
2523 while(filter) { 2523 while(filter) {
2524 // kdDebug() << " fn: " << filter->name() << endl; 2524 // kdDebug() << " fn: " << filter->name() << endl;
2525 filterList << filter->name(); 2525 filterList << filter->name();
2526 config->setGroup("Filter_" + filter->name().utf8()); 2526 config->setGroup("Filter_" + filter->name().utf8());
2527 config->writeEntry("Criteria",filter->criteria()); 2527 config->writeEntry("Criteria",filter->criteria());
2528 config->writeEntry("CategoryList",filter->categoryList()); 2528 config->writeEntry("CategoryList",filter->categoryList());
2529 filter = mFilters.next(); 2529 filter = mFilters.next();
2530 } 2530 }
2531 config->setGroup("General"); 2531 config->setGroup("General");
2532 config->writeEntry("CalendarFilters",filterList); 2532 config->writeEntry("CalendarFilters",filterList);
2533 2533
2534 config->setGroup("FilterView"); 2534 config->setGroup("FilterView");
2535 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2535 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2536 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2536 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2537} 2537}
2538 2538
2539 2539
2540void CalendarView::goToday() 2540void CalendarView::goToday()
2541{ 2541{
2542 if ( mViewManager->currentView()->isMonthView() ) 2542 if ( mViewManager->currentView()->isMonthView() )
2543 mNavigator->selectTodayMonth(); 2543 mNavigator->selectTodayMonth();
2544 else 2544 else
2545 mNavigator->selectToday(); 2545 mNavigator->selectToday();
2546} 2546}
2547 2547
2548void CalendarView::goNext() 2548void CalendarView::goNext()
2549{ 2549{
2550 mNavigator->selectNext(); 2550 mNavigator->selectNext();
2551} 2551}
2552 2552
2553void CalendarView::goPrevious() 2553void CalendarView::goPrevious()
2554{ 2554{
2555 mNavigator->selectPrevious(); 2555 mNavigator->selectPrevious();
2556} 2556}
2557void CalendarView::goNextMonth() 2557void CalendarView::goNextMonth()
2558{ 2558{
2559 mNavigator->selectNextMonth(); 2559 mNavigator->selectNextMonth();
2560} 2560}
2561 2561
2562void CalendarView::goPreviousMonth() 2562void CalendarView::goPreviousMonth()
2563{ 2563{
2564 mNavigator->selectPreviousMonth(); 2564 mNavigator->selectPreviousMonth();
2565} 2565}
2566 2566
2567void CalendarView::updateConfig() 2567void CalendarView::updateConfig()
2568{ 2568{
2569 if ( KOPrefs::instance()->mUseAppColors ) 2569 if ( KOPrefs::instance()->mUseAppColors )
2570 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2570 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2571 emit configChanged(); 2571 emit configChanged();
2572 mTodoList->updateConfig(); 2572 mTodoList->updateConfig();
2573 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2573 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2574 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2574 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2575 // To make the "fill window" configurations work 2575 // To make the "fill window" configurations work
2576 //mViewManager->raiseCurrentView(); 2576 //mViewManager->raiseCurrentView();
2577} 2577}
2578 2578
2579 2579
2580void CalendarView::eventChanged(Event *event) 2580void CalendarView::eventChanged(Event *event)
2581{ 2581{
2582 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2582 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2583 //updateUnmanagedViews(); 2583 //updateUnmanagedViews();
2584} 2584}
2585 2585
2586void CalendarView::eventAdded(Event *event) 2586void CalendarView::eventAdded(Event *event)
2587{ 2587{
2588 changeEventDisplay(event,KOGlobals::EVENTADDED); 2588 changeEventDisplay(event,KOGlobals::EVENTADDED);
2589} 2589}
2590 2590
2591void CalendarView::eventToBeDeleted(Event *) 2591void CalendarView::eventToBeDeleted(Event *)
2592{ 2592{
2593 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2593 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2594} 2594}
2595 2595
2596void CalendarView::eventDeleted() 2596void CalendarView::eventDeleted()
2597{ 2597{
2598 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2598 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2599} 2599}
2600void CalendarView::changeTodoDisplay(Todo *which, int action) 2600void CalendarView::changeTodoDisplay(Todo *which, int action)
2601{ 2601{
2602 changeIncidenceDisplay((Incidence *)which, action); 2602 changeIncidenceDisplay((Incidence *)which, action);
2603 mDateNavigator->updateView(); //LR 2603 mDateNavigator->updateView(); //LR
2604 //mDialogManager->updateSearchDialog(); 2604 //mDialogManager->updateSearchDialog();
2605 2605
2606 if (which) { 2606 if (which) {
2607 mViewManager->updateWNview(); 2607 mViewManager->updateWNview();
2608 //mTodoList->updateView(); 2608 //mTodoList->updateView();
2609 } 2609 }
2610 2610
2611} 2611}
2612 2612
2613void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2613void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2614{ 2614{
2615 updateUnmanagedViews(); 2615 updateUnmanagedViews();
2616 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2616 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2617 if ( action == KOGlobals::EVENTDELETED ) { //delete 2617 if ( action == KOGlobals::EVENTDELETED ) { //delete
2618 mCalendar->checkAlarmForIncidence( 0, true ); 2618 mCalendar->checkAlarmForIncidence( 0, true );
2619 if ( mEventViewerDialog ) 2619 if ( mEventViewerDialog )
2620 mEventViewerDialog->hide(); 2620 mEventViewerDialog->hide();
2621 } 2621 }
2622 else 2622 else
2623 mCalendar->checkAlarmForIncidence( which , false ); 2623 mCalendar->checkAlarmForIncidence( which , false );
2624} 2624}
2625 2625
2626// most of the changeEventDisplays() right now just call the view's 2626// most of the changeEventDisplays() right now just call the view's
2627// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2627// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2628void CalendarView::changeEventDisplay(Event *which, int action) 2628void CalendarView::changeEventDisplay(Event *which, int action)
2629{ 2629{
2630 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2630 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2631 changeIncidenceDisplay((Incidence *)which, action); 2631 changeIncidenceDisplay((Incidence *)which, action);
2632
2633
2634 static bool clearallviews = false;
2635 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2636 if ( clearallviews ) {
2637 clearAllViews();
2638 clearallviews = false;
2639 }
2640 return;
2641 }
2642 clearallviews = true;
2643
2644
2645
2632 mDateNavigator->updateView(); 2646 mDateNavigator->updateView();
2633 //mDialogManager->updateSearchDialog(); 2647 //mDialogManager->updateSearchDialog();
2634 2648
2635 if (which) { 2649 if (which) {
2636 // If there is an event view visible update the display 2650 // If there is an event view visible update the display
2637 mViewManager->currentView()->changeEventDisplay(which,action); 2651 mViewManager->currentView()->changeEventDisplay(which,action);
2638 // TODO: check, if update needed 2652 // TODO: check, if update needed
2639 // if (which->getTodoStatus()) { 2653 // if (which->getTodoStatus()) {
2640 mTodoList->updateView(); 2654 mTodoList->updateView();
2641 // } 2655 // }
2642 } else { 2656 } else {
2643 mViewManager->currentView()->updateView(); 2657 mViewManager->currentView()->updateView();
2644 } 2658 }
2645} 2659}
2646 2660
2647 2661
2648void CalendarView::updateTodoViews() 2662void CalendarView::updateTodoViews()
2649{ 2663{
2650 mTodoList->updateView(); 2664 mTodoList->updateView();
2651 mViewManager->currentView()->updateView(); 2665 mViewManager->currentView()->updateView();
2652 2666
2653} 2667}
2654 2668
2655 2669
2656 2670
2657void CalendarView::clearAllViews() 2671void CalendarView::clearAllViews()
2658{ 2672{
2659 mTodoList->clearList(); 2673 mTodoList->clearList();
2660 mViewManager->clearAllViews(); 2674 mViewManager->clearAllViews();
2661 SearchDialog * sd = mDialogManager->getSearchDialog(); 2675 SearchDialog * sd = mDialogManager->getSearchDialog();
2662 if ( sd ) { 2676 if ( sd ) {
2663 KOListView* kol = sd->listview(); 2677 KOListView* kol = sd->listview();
2664 if ( kol ) 2678 if ( kol )
2665 kol->clearList(); 2679 kol->clearList();
2666 } 2680 }
2667} 2681}
2668void CalendarView::updateView() 2682void CalendarView::updateView()
2669{ 2683{
2670 static bool clearallviews = false; 2684 static bool clearallviews = false;
2671 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2685 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2672 if ( clearallviews ) { 2686 if ( clearallviews ) {
2673 clearAllViews(); 2687 clearAllViews();
2674 clearallviews = false; 2688 clearallviews = false;
2675 } 2689 }
2676 return; 2690 return;
2677 } 2691 }
2678 clearallviews = true; 2692 clearallviews = true;
2679 DateList tmpList = mNavigator->selectedDates(); 2693 DateList tmpList = mNavigator->selectedDates();
2680 2694
2681 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2695 if ( KOPrefs::instance()->mHideNonStartedTodos )
2682 mTodoList->updateView(); 2696 mTodoList->updateView();
2683 // We assume that the navigator only selects consecutive days. 2697 // We assume that the navigator only selects consecutive days.
2684 updateView( tmpList.first(), tmpList.last() ); 2698 updateView( tmpList.first(), tmpList.last() );
2685} 2699}
2686 2700
2687void CalendarView::updateUnmanagedViews() 2701void CalendarView::updateUnmanagedViews()
2688{ 2702{
2689 mDateNavigator->updateDayMatrix(); 2703 mDateNavigator->updateDayMatrix();
2690} 2704}
2691 2705
2692int CalendarView::msgItemDelete(const QString name) 2706int CalendarView::msgItemDelete(const QString name)
2693{ 2707{
2694 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2708 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2695 i18n("This item will be\npermanently deleted."), 2709 i18n("This item will be\npermanently deleted."),
2696 i18n("KO/Pi Confirmation"),i18n("Delete")); 2710 i18n("KO/Pi Confirmation"),i18n("Delete"));
2697} 2711}
2698 2712
2699 2713
2700void CalendarView::edit_cut() 2714void CalendarView::edit_cut()
2701{ 2715{
2702 Event *anEvent=0; 2716 Event *anEvent=0;
2703 2717
2704 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2718 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2705 2719
2706 if (mViewManager->currentView()->isEventView()) { 2720 if (mViewManager->currentView()->isEventView()) {
2707 if ( incidence && incidence->typeID() == eventID ) { 2721 if ( incidence && incidence->typeID() == eventID ) {
2708 anEvent = static_cast<Event *>(incidence); 2722 anEvent = static_cast<Event *>(incidence);
2709 } 2723 }
2710 } 2724 }
2711 2725
2712 if (!anEvent) { 2726 if (!anEvent) {
2713 KNotifyClient::beep(); 2727 KNotifyClient::beep();
2714 return; 2728 return;
2715 } 2729 }
2716 DndFactory factory( mCalendar ); 2730 DndFactory factory( mCalendar );
2717 factory.cutIncidence(anEvent); 2731 factory.cutIncidence(anEvent);
2718 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2732 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2719} 2733}
2720 2734
2721void CalendarView::edit_copy() 2735void CalendarView::edit_copy()
2722{ 2736{
2723 Event *anEvent=0; 2737 Event *anEvent=0;
2724 2738
2725 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2739 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2726 2740
2727 if (mViewManager->currentView()->isEventView()) { 2741 if (mViewManager->currentView()->isEventView()) {
2728 if ( incidence && incidence->typeID() == eventID ) { 2742 if ( incidence && incidence->typeID() == eventID ) {
2729 anEvent = static_cast<Event *>(incidence); 2743 anEvent = static_cast<Event *>(incidence);
2730 } 2744 }
2731 } 2745 }
2732 2746
2733 if (!anEvent) { 2747 if (!anEvent) {
2734 KNotifyClient::beep(); 2748 KNotifyClient::beep();
2735 return; 2749 return;
2736 } 2750 }
2737 DndFactory factory( mCalendar ); 2751 DndFactory factory( mCalendar );
2738 factory.copyIncidence(anEvent); 2752 factory.copyIncidence(anEvent);
2739} 2753}
2740 2754
2741void CalendarView::edit_paste() 2755void CalendarView::edit_paste()
2742{ 2756{
2743 QDate date = mNavigator->selectedDates().first(); 2757 QDate date = mNavigator->selectedDates().first();
2744 2758
2745 DndFactory factory( mCalendar ); 2759 DndFactory factory( mCalendar );
2746 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2760 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2747 2761
2748 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2762 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2749} 2763}
2750void CalendarView::edit_global_options() 2764void CalendarView::edit_global_options()
2751{ 2765{
2752 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2766 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2753 emit save(); 2767 emit save();
2754 emit saveStopTimer(); 2768 emit saveStopTimer();
2755 mDialogManager->showGlobalOptionsDialog(); 2769 mDialogManager->showGlobalOptionsDialog();
2756 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2770 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2757 emit saveStopTimer(); 2771 emit saveStopTimer();
2758 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!"), 2772 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!"),
2759 i18n("Timezone settings"),i18n("Reload"))) { 2773 i18n("Timezone settings"),i18n("Reload"))) {
2760 qDebug("KO: TZ reload cancelled "); 2774 qDebug("KO: TZ reload cancelled ");
2761 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2775 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2762 return; 2776 return;
2763 } 2777 }
2764 qDebug("KO: Timezone change "); 2778 qDebug("KO: Timezone change ");
2765 loadCalendars(); 2779 loadCalendars();
2766 setModified(true); 2780 setModified(true);
2767 } 2781 }
2768 else 2782 else
2769 qDebug("KO: No tz change "); 2783 qDebug("KO: No tz change ");
2770} 2784}
2771void CalendarView::edit_options() 2785void CalendarView::edit_options()
2772{ 2786{
2773 mDialogManager->showOptionsDialog(); 2787 mDialogManager->showOptionsDialog();
2774} 2788}
2775 2789
2776 2790
2777void CalendarView::slotSelectPickerDate( QDate d) 2791void CalendarView::slotSelectPickerDate( QDate d)
2778{ 2792{
2779 mDateFrame->hide(); 2793 mDateFrame->hide();
2780 if ( mDatePickerMode == 1 ) { 2794 if ( mDatePickerMode == 1 ) {
2781 mNavigator->slotDaySelect( d ); 2795 mNavigator->slotDaySelect( d );
2782 } else if ( mDatePickerMode == 2 ) { 2796 } else if ( mDatePickerMode == 2 ) {
2783 if ( mMoveIncidence->typeID() == todoID ) { 2797 if ( mMoveIncidence->typeID() == todoID ) {
2784 Todo * to = (Todo *) mMoveIncidence; 2798 Todo * to = (Todo *) mMoveIncidence;
2785 QTime tim; 2799 QTime tim;
2786 int len = 0; 2800 int len = 0;
2787 if ( to->hasStartDate() && to->hasDueDate() ) 2801 if ( to->hasStartDate() && to->hasDueDate() )
2788 len = to->dtStart().secsTo( to->dtDue()); 2802 len = to->dtStart().secsTo( to->dtDue());
2789 if ( to->hasDueDate() ) 2803 if ( to->hasDueDate() )
2790 tim = to->dtDue().time(); 2804 tim = to->dtDue().time();
2791 else { 2805 else {
2792 tim = QTime ( 0,0,0 ); 2806 tim = QTime ( 0,0,0 );
2793 to->setFloats( true ); 2807 to->setFloats( true );
2794 to->setHasDueDate( true ); 2808 to->setHasDueDate( true );
2795 } 2809 }
2796 QDateTime dt ( d,tim ); 2810 QDateTime dt ( d,tim );
2797 to->setDtDue( dt ); 2811 to->setDtDue( dt );
2798 2812
2799 if ( to->hasStartDate() ) { 2813 if ( to->hasStartDate() ) {
2800 if ( len>0 ) 2814 if ( len>0 )
2801 to->setDtStart(to->dtDue().addSecs( -len )); 2815 to->setDtStart(to->dtDue().addSecs( -len ));
2802 else 2816 else
2803 if (to->dtStart() > to->dtDue() ) 2817 if (to->dtStart() > to->dtDue() )
2804 to->setDtStart(to->dtDue().addDays( -3 )); 2818 to->setDtStart(to->dtDue().addDays( -3 ));
2805 } 2819 }
2806 2820
2807 todoChanged( to ); 2821 todoChanged( to );
2808 } else { 2822 } else {
2809 if ( mMoveIncidence->doesRecur() ) { 2823 if ( mMoveIncidence->doesRecur() ) {
2810#if 0 2824#if 0
2811 // PENDING implement this 2825 // PENDING implement this
2812 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2826 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2813 mCalendar()->addIncidence( newInc ); 2827 mCalendar()->addIncidence( newInc );
2814 if ( mMoveIncidence->typeID() == todoID ) 2828 if ( mMoveIncidence->typeID() == todoID )
2815 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2829 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2816 else 2830 else
2817 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2831 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2818 mMoveIncidence = newInc; 2832 mMoveIncidence = newInc;
2819 2833
2820#endif 2834#endif
2821 } 2835 }
2822 QTime tim = mMoveIncidence->dtStart().time(); 2836 QTime tim = mMoveIncidence->dtStart().time();
2823 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2837 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2824 QDateTime dt ( d,tim ); 2838 QDateTime dt ( d,tim );
2825 mMoveIncidence->setDtStart( dt ); 2839 mMoveIncidence->setDtStart( dt );
2826 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2840 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2827 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2841 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2828 } 2842 }
2829 2843
2830 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2844 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2831 } 2845 }
2832} 2846}
2833 2847
2834void CalendarView::removeCategories() 2848void CalendarView::removeCategories()
2835{ 2849{
2836 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2850 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2837 QStringList catList = KOPrefs::instance()->mCustomCategories; 2851 QStringList catList = KOPrefs::instance()->mCustomCategories;
2838 QStringList catIncList; 2852 QStringList catIncList;
2839 QStringList newCatList; 2853 QStringList newCatList;
2840 Incidence* inc = incList.first(); 2854 Incidence* inc = incList.first();
2841 uint i; 2855 uint i;
2842 while ( inc ) { 2856 while ( inc ) {
2843 newCatList.clear(); 2857 newCatList.clear();
2844 catIncList = inc->categories() ; 2858 catIncList = inc->categories() ;
2845 for( i = 0; i< catIncList.count(); ++i ) { 2859 for( i = 0; i< catIncList.count(); ++i ) {
2846 if ( catList.contains (catIncList[i])) 2860 if ( catList.contains (catIncList[i]))
2847 newCatList.append( catIncList[i] ); 2861 newCatList.append( catIncList[i] );
2848 } 2862 }
2849 newCatList.sort(); 2863 newCatList.sort();
2850 inc->setCategories( newCatList.join(",") ); 2864 inc->setCategories( newCatList.join(",") );
2851 inc = incList.next(); 2865 inc = incList.next();
2852 } 2866 }
2853} 2867}
2854 2868
2855int CalendarView::addCategories() 2869int CalendarView::addCategories()
2856{ 2870{
2857 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2871 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2858 QStringList catList = KOPrefs::instance()->mCustomCategories; 2872 QStringList catList = KOPrefs::instance()->mCustomCategories;
2859 QStringList catIncList; 2873 QStringList catIncList;
2860 Incidence* inc = incList.first(); 2874 Incidence* inc = incList.first();
2861 uint i; 2875 uint i;
2862 int count = 0; 2876 int count = 0;
2863 while ( inc ) { 2877 while ( inc ) {
2864 catIncList = inc->categories() ; 2878 catIncList = inc->categories() ;
2865 for( i = 0; i< catIncList.count(); ++i ) { 2879 for( i = 0; i< catIncList.count(); ++i ) {
2866 if ( !catList.contains (catIncList[i])) { 2880 if ( !catList.contains (catIncList[i])) {
2867 catList.append( catIncList[i] ); 2881 catList.append( catIncList[i] );
2868 //qDebug("add cat %s ", catIncList[i].latin1()); 2882 //qDebug("add cat %s ", catIncList[i].latin1());
2869 ++count; 2883 ++count;
2870 } 2884 }
2871 } 2885 }
2872 inc = incList.next(); 2886 inc = incList.next();
2873 } 2887 }
2874 catList.sort(); 2888 catList.sort();
2875 KOPrefs::instance()->mCustomCategories = catList; 2889 KOPrefs::instance()->mCustomCategories = catList;
2876 return count; 2890 return count;
2877} 2891}
2878 2892
2879void CalendarView::editCategories() 2893void CalendarView::editCategories()
2880{ 2894{
2881 qDebug("CalendarView::editCategories() "); 2895 qDebug("CalendarView::editCategories() ");
2882 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); 2896 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this );
2883 ced.exec(); 2897 ced.exec();
2884} 2898}
2885void CalendarView::manageCategories() 2899void CalendarView::manageCategories()
2886{ 2900{
2887 KOCatPrefs* cp = new KOCatPrefs(); 2901 KOCatPrefs* cp = new KOCatPrefs();
2888 cp->show(); 2902 cp->show();
2889 int w =cp->sizeHint().width() ; 2903 int w =cp->sizeHint().width() ;
2890 int h = cp->sizeHint().height() ; 2904 int h = cp->sizeHint().height() ;
2891 int dw = QApplication::desktop()->width(); 2905 int dw = QApplication::desktop()->width();
2892 int dh = QApplication::desktop()->height(); 2906 int dh = QApplication::desktop()->height();
2893 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2907 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2894 if ( !cp->exec() ) { 2908 if ( !cp->exec() ) {
2895 delete cp; 2909 delete cp;
2896 return; 2910 return;
2897 } 2911 }
2898 int count = 0; 2912 int count = 0;
2899 if ( cp->addCat() ) { 2913 if ( cp->addCat() ) {
2900 count = addCategories(); 2914 count = addCategories();
2901 if ( count ) { 2915 if ( count ) {
2902 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2916 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2903 writeSettings(); 2917 writeSettings();
2904 } else 2918 } else
2905 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2919 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2906 } else { 2920 } else {
2907 removeCategories(); 2921 removeCategories();
2908 updateView(); 2922 updateView();
2909 } 2923 }
2910 delete cp; 2924 delete cp;
2911} 2925}
2912 2926
2913void CalendarView::beamIncidence(Incidence * Inc) 2927void CalendarView::beamIncidence(Incidence * Inc)
2914{ 2928{
2915 QPtrList<Incidence> delSel ; 2929 QPtrList<Incidence> delSel ;
2916 delSel.append(Inc); 2930 delSel.append(Inc);
2917 beamIncidenceList( delSel ); 2931 beamIncidenceList( delSel );
2918} 2932}
2919void CalendarView::beamCalendar() 2933void CalendarView::beamCalendar()
2920{ 2934{
2921 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2935 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2922 //qDebug("beamCalendar() "); 2936 //qDebug("beamCalendar() ");
2923 beamIncidenceList( delSel ); 2937 beamIncidenceList( delSel );
2924} 2938}
2925void CalendarView::beamFilteredCalendar() 2939void CalendarView::beamFilteredCalendar()
2926{ 2940{
2927 QPtrList<Incidence> delSel = mCalendar->incidences(); 2941 QPtrList<Incidence> delSel = mCalendar->incidences();
2928 //qDebug("beamFilteredCalendar() "); 2942 //qDebug("beamFilteredCalendar() ");
2929 beamIncidenceList( delSel ); 2943 beamIncidenceList( delSel );
2930} 2944}
2931void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2945void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2932{ 2946{
2933 2947
2934 KOBeamPrefs beamDialog; 2948 KOBeamPrefs beamDialog;
2935 if ( beamDialog.exec () == QDialog::Rejected ) 2949 if ( beamDialog.exec () == QDialog::Rejected )
2936 return; 2950 return;
2937#ifdef DESKTOP_VERSION 2951#ifdef DESKTOP_VERSION
2938 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2952 QString fn = locateLocal( "tmp", "kopibeamfile" );
2939#else 2953#else
2940 QString fn = "/tmp/kopibeamfile"; 2954 QString fn = "/tmp/kopibeamfile";
2941#endif 2955#endif
2942 QString mes; 2956 QString mes;
2943 bool createbup = true; 2957 bool createbup = true;
2944 if ( createbup ) { 2958 if ( createbup ) {
2945 QString description = "\n"; 2959 QString description = "\n";
2946 CalendarLocal* cal = new CalendarLocal(); 2960 CalendarLocal* cal = new CalendarLocal();
2947 if ( beamDialog.beamLocal() ) 2961 if ( beamDialog.beamLocal() )
2948 cal->setLocalTime(); 2962 cal->setLocalTime();
2949 else 2963 else
2950 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2964 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2951 Incidence *incidence = delSel.first(); 2965 Incidence *incidence = delSel.first();
2952 bool addText = false; 2966 bool addText = false;
2953 if ( delSel.count() < 10 ) 2967 if ( delSel.count() < 10 )
2954 addText = true; 2968 addText = true;
2955 else { 2969 else {
2956 description.sprintf(i18n(" %d items?"),delSel.count() ); 2970 description.sprintf(i18n(" %d items?"),delSel.count() );
2957 } 2971 }
2958 while ( incidence ) { 2972 while ( incidence ) {
2959 Incidence *in = incidence->clone(); 2973 Incidence *in = incidence->clone();
2960 if ( ! in->summary().isEmpty() ) { 2974 if ( ! in->summary().isEmpty() ) {
2961 in->setDescription(""); 2975 in->setDescription("");
2962 } else { 2976 } else {
2963 in->setSummary( in->description().left(20)); 2977 in->setSummary( in->description().left(20));
2964 in->setDescription(""); 2978 in->setDescription("");
2965 } 2979 }
2966 if ( addText ) 2980 if ( addText )
2967 description += in->summary() + "\n"; 2981 description += in->summary() + "\n";
2968 cal->addIncidence( in ); 2982 cal->addIncidence( in );
2969 incidence = delSel.next(); 2983 incidence = delSel.next();
2970 } 2984 }
2971 if ( beamDialog.beamVcal() ) { 2985 if ( beamDialog.beamVcal() ) {
2972 fn += ".vcs"; 2986 fn += ".vcs";
2973 FileStorage storage( cal, fn, new VCalFormat ); 2987 FileStorage storage( cal, fn, new VCalFormat );
2974 storage.save(); 2988 storage.save();
2975 } else { 2989 } else {
2976 fn += ".ics"; 2990 fn += ".ics";
2977 FileStorage storage( cal, fn, new ICalFormat( ) ); 2991 FileStorage storage( cal, fn, new ICalFormat( ) );
2978 storage.save(); 2992 storage.save();
2979 } 2993 }
2980 delete cal; 2994 delete cal;
2981 mes = i18n("KO/Pi: Ready for beaming"); 2995 mes = i18n("KO/Pi: Ready for beaming");
2982 topLevelWidget()->setCaption(mes); 2996 topLevelWidget()->setCaption(mes);
2983 KApplication::convert2latin1( fn ); 2997 KApplication::convert2latin1( fn );
2984#ifndef DESKTOP_VERSION 2998#ifndef DESKTOP_VERSION
2985 Ir *ir = new Ir( this ); 2999 Ir *ir = new Ir( this );
2986 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 3000 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2987 ir->send( fn, description, "text/x-vCalendar" ); 3001 ir->send( fn, description, "text/x-vCalendar" );
2988#endif 3002#endif
2989 } 3003 }
2990} 3004}
2991 3005
2992#ifndef DESKTOP_VERSION 3006#ifndef DESKTOP_VERSION
2993void CalendarView::beamDone( Ir *ir ) 3007void CalendarView::beamDone( Ir *ir )
2994{ 3008{
2995 delete ir; 3009 delete ir;
2996 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 3010 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2997 topLevelWidget()->raise(); 3011 topLevelWidget()->raise();
2998} 3012}
2999#else 3013#else
3000void CalendarView::beamDone( Ir *){;} 3014void CalendarView::beamDone( Ir *){;}
3001#endif 3015#endif
3002void CalendarView::moveIncidence(Incidence * inc ) 3016void CalendarView::moveIncidence(Incidence * inc )
3003{ 3017{
3004 if ( !inc ) return; 3018 if ( !inc ) return;
3005 showDatePickerPopup(); 3019 showDatePickerPopup();
3006 mDatePickerMode = 2; 3020 mDatePickerMode = 2;
3007 mMoveIncidence = inc ; 3021 mMoveIncidence = inc ;
3008 QDate da; 3022 QDate da;
3009 if ( mMoveIncidence->typeID() == todoID ) { 3023 if ( mMoveIncidence->typeID() == todoID ) {
3010 Todo * to = (Todo *) mMoveIncidence; 3024 Todo * to = (Todo *) mMoveIncidence;
3011 if ( to->hasDueDate() ) 3025 if ( to->hasDueDate() )
3012 da = to->dtDue().date(); 3026 da = to->dtDue().date();
3013 else 3027 else
3014 da = QDate::currentDate(); 3028 da = QDate::currentDate();
3015 } else { 3029 } else {