summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-02-23 21:53:18 (UTC)
committer zautrix <zautrix>2005-02-23 21:53:18 (UTC)
commit4a9bf75c2ef12a40be3aea1d147f3703aee48638 (patch) (unidiff)
tree62b2e4d0b63487ff2818c18f8bc1a3233df46e76
parent31f24d21cd23bb7e4033e7ffa000e6c979133ce7 (diff)
downloadkdepimpi-4a9bf75c2ef12a40be3aea1d147f3703aee48638.zip
kdepimpi-4a9bf75c2ef12a40be3aea1d147f3703aee48638.tar.gz
kdepimpi-4a9bf75c2ef12a40be3aea1d147f3703aee48638.tar.bz2
morelayout fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp16
-rw-r--r--korganizer/koagenda.cpp25
-rw-r--r--korganizer/koagendaitem.cpp18
-rw-r--r--korganizer/koagendaitem.h1
-rw-r--r--korganizer/koeventviewerdialog.cpp11
5 files changed, 68 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 1009956..d6918d3 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -291,384 +291,385 @@ void CalendarView::init()
291 291
292 mRightFrame = new QWidgetStack( rightBox ); 292 mRightFrame = new QWidgetStack( rightBox );
293 rightLayout->addWidget( mRightFrame, 1 ); 293 rightLayout->addWidget( mRightFrame, 1 );
294 294
295 mLeftFrame = mLeftSplitter; 295 mLeftFrame = mLeftSplitter;
296#else 296#else
297 QWidget *mainBox = new QWidget( this ); 297 QWidget *mainBox = new QWidget( this );
298 QWidget *leftFrame = new QWidget( mainBox ); 298 QWidget *leftFrame = new QWidget( mainBox );
299 299
300 QBoxLayout * mainBoxLayout; 300 QBoxLayout * mainBoxLayout;
301 QBoxLayout * leftFrameLayout; 301 QBoxLayout * leftFrameLayout;
302 if ( KOPrefs::instance()->mVerticalScreen ) { 302 if ( KOPrefs::instance()->mVerticalScreen ) {
303 mainBoxLayout = new QVBoxLayout(mainBox); 303 mainBoxLayout = new QVBoxLayout(mainBox);
304 leftFrameLayout = new QHBoxLayout(leftFrame ); 304 leftFrameLayout = new QHBoxLayout(leftFrame );
305 } else { 305 } else {
306 mainBoxLayout = new QHBoxLayout(mainBox); 306 mainBoxLayout = new QHBoxLayout(mainBox);
307 leftFrameLayout = new QVBoxLayout(leftFrame ); 307 leftFrameLayout = new QVBoxLayout(leftFrame );
308 } 308 }
309 topLayout->addWidget( mainBox ); 309 topLayout->addWidget( mainBox );
310 mainBoxLayout->addWidget (leftFrame); 310 mainBoxLayout->addWidget (leftFrame);
311 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 311 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
312 "CalendarView::DateNavigator", QDate::currentDate()); 312 "CalendarView::DateNavigator", QDate::currentDate());
313 // mDateNavigator->blockSignals( true ); 313 // mDateNavigator->blockSignals( true );
314 leftFrameLayout->addWidget( mDateNavigator ); 314 leftFrameLayout->addWidget( mDateNavigator );
315 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 315 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
316 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 316 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
317 mTodoList->setNavigator( mNavigator ); 317 mTodoList->setNavigator( mNavigator );
318 318
319 if ( QApplication::desktop()->width() < 480 ) { 319 if ( QApplication::desktop()->width() < 480 ) {
320 leftFrameLayout->addWidget(mFilterView); 320 leftFrameLayout->addWidget(mFilterView);
321 leftFrameLayout->addWidget(mTodoList, 2 ); 321 leftFrameLayout->addWidget(mTodoList, 2 );
322 322
323 } else { 323 } else {
324 leftFrameLayout->addWidget(mTodoList,2 ); 324 leftFrameLayout->addWidget(mTodoList,2 );
325 leftFrameLayout->addWidget(mFilterView ); 325 leftFrameLayout->addWidget(mFilterView );
326 } 326 }
327 mFilterView->hide(); 327 mFilterView->hide();
328 QWidget *rightBox = new QWidget( mainBox ); 328 QWidget *rightBox = new QWidget( mainBox );
329 mainBoxLayout->addWidget ( rightBox, 10 ); 329 mainBoxLayout->addWidget ( rightBox, 10 );
330 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 330 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
331 mRightFrame = new QWidgetStack( rightBox ); 331 mRightFrame = new QWidgetStack( rightBox );
332 rightLayout->addWidget( mRightFrame, 10 ); 332 rightLayout->addWidget( mRightFrame, 10 );
333 333
334 mLeftFrame = leftFrame; 334 mLeftFrame = leftFrame;
335 if ( KOPrefs::instance()->mVerticalScreen ) { 335 if ( KOPrefs::instance()->mVerticalScreen ) {
336 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 336 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
337 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 337 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
338 } else { 338 } else {
339 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 339 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
340 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 340 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
341 } 341 }
342 if ( !KOPrefs::instance()->mShowDateNavigator) 342 if ( !KOPrefs::instance()->mShowDateNavigator)
343 mDateNavigator->hide(); 343 mDateNavigator->hide();
344 //qDebug("Calendarview Size %d %d ", width(), height()); 344 //qDebug("Calendarview Size %d %d ", width(), height());
345#endif 345#endif
346 346
347 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 347 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
348 SLOT( showDates( const KCal::DateList & ) ) ); 348 SLOT( showDates( const KCal::DateList & ) ) );
349 349
350 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 350 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
351 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 351 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
352 352
353 353
354 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 354 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
355 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 355 mNavigator, SLOT( selectWeek( const QDate & ) ) );
356 356
357 connect( mDateNavigator, SIGNAL( goPrevYear() ), 357 connect( mDateNavigator, SIGNAL( goPrevYear() ),
358 mNavigator, SLOT( selectPreviousYear() ) ); 358 mNavigator, SLOT( selectPreviousYear() ) );
359 connect( mDateNavigator, SIGNAL( goNextYear() ), 359 connect( mDateNavigator, SIGNAL( goNextYear() ),
360 mNavigator, SLOT( selectNextYear() ) ); 360 mNavigator, SLOT( selectNextYear() ) );
361 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 361 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
362 mNavigator, SLOT( selectPreviousMonth() ) ); 362 mNavigator, SLOT( selectPreviousMonth() ) );
363 connect( mDateNavigator, SIGNAL( goNextMonth() ), 363 connect( mDateNavigator, SIGNAL( goNextMonth() ),
364 mNavigator, SLOT( selectNextMonth() ) ); 364 mNavigator, SLOT( selectNextMonth() ) );
365 365
366 connect( mDateNavigator, SIGNAL( goPrevious() ), 366 connect( mDateNavigator, SIGNAL( goPrevious() ),
367 mNavigator, SLOT( selectPrevious() ) ); 367 mNavigator, SLOT( selectPrevious() ) );
368 connect( mDateNavigator, SIGNAL( goNext() ), 368 connect( mDateNavigator, SIGNAL( goNext() ),
369 mNavigator, SLOT( selectNext() ) ); 369 mNavigator, SLOT( selectNext() ) );
370 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 370 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
371 mNavigator, SLOT( slotMonthSelect( int ) ) ); 371 mNavigator, SLOT( slotMonthSelect( int ) ) );
372 372
373 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 373 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
374 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 374 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
375 375
376 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 376 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
377 SLOT( eventAdded( Event *) ) ); 377 SLOT( eventAdded( Event *) ) );
378 378
379 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 379 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
380 380
381 connect( this, SIGNAL( configChanged() ), 381 connect( this, SIGNAL( configChanged() ),
382 mDateNavigator, SLOT( updateConfig() ) ); 382 mDateNavigator, SLOT( updateConfig() ) );
383 383
384 connect( mTodoList, SIGNAL( newTodoSignal() ), 384 connect( mTodoList, SIGNAL( newTodoSignal() ),
385 SLOT( newTodo() ) ); 385 SLOT( newTodo() ) );
386 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 386 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
387 SLOT( newSubTodo( Todo * ) ) ); 387 SLOT( newSubTodo( Todo * ) ) );
388 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 388 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
389 SLOT( editTodo( Todo * ) ) ); 389 SLOT( editTodo( Todo * ) ) );
390 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 390 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
391 SLOT( showTodo( Todo *) ) ); 391 SLOT( showTodo( Todo *) ) );
392 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 392 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
393 SLOT( deleteTodo( Todo *) ) ); 393 SLOT( deleteTodo( Todo *) ) );
394 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 394 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
395 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 395 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
396 SLOT( purgeCompleted() ) ); 396 SLOT( purgeCompleted() ) );
397 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 397 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
398 SIGNAL( todoModified( Todo *, int ) ) ); 398 SIGNAL( todoModified( Todo *, int ) ) );
399 399
400 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 400 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
401 this, SLOT ( cloneIncidence( Incidence * ) ) ); 401 this, SLOT ( cloneIncidence( Incidence * ) ) );
402 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 402 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
403 this, SLOT (cancelIncidence( Incidence * ) ) ); 403 this, SLOT (cancelIncidence( Incidence * ) ) );
404 404
405 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 405 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
406 this, SLOT ( moveIncidence( Incidence * ) ) ); 406 this, SLOT ( moveIncidence( Incidence * ) ) );
407 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 407 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
408 this, SLOT ( beamIncidence( Incidence * ) ) ); 408 this, SLOT ( beamIncidence( Incidence * ) ) );
409 409
410 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 410 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
411 this, SLOT ( todo_unsub( Todo * ) ) ); 411 this, SLOT ( todo_unsub( Todo * ) ) );
412 412
413 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 413 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
414 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 414 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
415 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 415 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
416 SLOT( updateTodo( Todo *, int ) ) ); 416 SLOT( updateTodo( Todo *, int ) ) );
417 connect( this, SIGNAL( todoModified( Todo *, int )), this, 417 connect( this, SIGNAL( todoModified( Todo *, int )), this,
418 SLOT( changeTodoDisplay( Todo *, int ) ) ); 418 SLOT( changeTodoDisplay( Todo *, int ) ) );
419 419
420 420
421 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 421 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
422 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 422 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
423 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 423 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
424 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 424 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
425 425
426 426
427 427
428 428
429 429
430 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 430 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
431 SLOT(checkClipboard())); 431 SLOT(checkClipboard()));
432 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 432 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
433 SLOT( processTodoListSelection( Incidence * ) ) ); 433 SLOT( processTodoListSelection( Incidence * ) ) );
434 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 434 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
435 435
436 // kdDebug() << "CalendarView::CalendarView() done" << endl; 436 // kdDebug() << "CalendarView::CalendarView() done" << endl;
437 437
438 mDateFrame = new QVBox(0,0,WType_Popup); 438 mDateFrame = new QVBox(0,0,WType_Popup);
439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
441 mDateFrame->setLineWidth(3); 441 mDateFrame->setLineWidth(3);
442 mDateFrame->hide(); 442 mDateFrame->hide();
443 mDateFrame->setCaption( i18n( "Pick a date to display")); 443 mDateFrame->setCaption( i18n( "Pick a date to display"));
444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
445 445
446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
447 447
448 mEventEditor = mDialogManager->getEventEditor(); 448 mEventEditor = mDialogManager->getEventEditor();
449 mTodoEditor = mDialogManager->getTodoEditor(); 449 mTodoEditor = mDialogManager->getTodoEditor();
450 450
451 mFlagEditDescription = false; 451 mFlagEditDescription = false;
452 452
453 mSuspendTimer = new QTimer( this ); 453 mSuspendTimer = new QTimer( this );
454 mAlarmTimer = new QTimer( this ); 454 mAlarmTimer = new QTimer( this );
455 mRecheckAlarmTimer = new QTimer( this ); 455 mRecheckAlarmTimer = new QTimer( this );
456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
459 mAlarmDialog = new AlarmDialog( this ); 459 mAlarmDialog = new AlarmDialog( this );
460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
461 mAlarmDialog->setServerNotification( false ); 461 mAlarmDialog->setServerNotification( false );
462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
463 463
464 464
465#ifndef DESKTOP_VERSION 465#ifndef DESKTOP_VERSION
466//US listen for arriving address resultsets 466//US listen for arriving address resultsets
467 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 467 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
468 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 468 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
469#endif 469#endif
470 470
471} 471}
472 472
473 473
474CalendarView::~CalendarView() 474CalendarView::~CalendarView()
475{ 475{
476 // kdDebug() << "~CalendarView()" << endl; 476 // kdDebug() << "~CalendarView()" << endl;
477 //qDebug("CalendarView::~CalendarView() "); 477 //qDebug("CalendarView::~CalendarView() ");
478 delete mDialogManager; 478 delete mDialogManager;
479 delete mViewManager; 479 delete mViewManager;
480 delete mStorage; 480 delete mStorage;
481 delete mDateFrame ; 481 delete mDateFrame ;
482 delete beamDialog; 482 delete beamDialog;
483 delete mEventViewerDialog;
483 //kdDebug() << "~CalendarView() done" << endl; 484 //kdDebug() << "~CalendarView() done" << endl;
484} 485}
485 486
486void CalendarView::showDay( QDate d ) 487void CalendarView::showDay( QDate d )
487{ 488{
488 dateNavigator()->blockSignals( true ); 489 dateNavigator()->blockSignals( true );
489 dateNavigator()->selectDate( d ); 490 dateNavigator()->selectDate( d );
490 dateNavigator()->blockSignals( false ); 491 dateNavigator()->blockSignals( false );
491 mViewManager->showDayView(); 492 mViewManager->showDayView();
492 //dateNavigator()->selectDate( d ); 493 //dateNavigator()->selectDate( d );
493} 494}
494void CalendarView::timerAlarm() 495void CalendarView::timerAlarm()
495{ 496{
496 //qDebug("CalendarView::timerAlarm() "); 497 //qDebug("CalendarView::timerAlarm() ");
497 computeAlarm(mAlarmNotification ); 498 computeAlarm(mAlarmNotification );
498} 499}
499 500
500void CalendarView::suspendAlarm() 501void CalendarView::suspendAlarm()
501{ 502{
502 //qDebug(" CalendarView::suspendAlarm() "); 503 //qDebug(" CalendarView::suspendAlarm() ");
503 computeAlarm(mSuspendAlarmNotification ); 504 computeAlarm(mSuspendAlarmNotification );
504 505
505} 506}
506 507
507void CalendarView::startAlarm( QString mess , QString filename) 508void CalendarView::startAlarm( QString mess , QString filename)
508{ 509{
509 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 510 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
510 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 511 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
511 512
512} 513}
513 514
514void CalendarView::checkNextTimerAlarm() 515void CalendarView::checkNextTimerAlarm()
515{ 516{
516 mCalendar->checkAlarmForIncidence( 0, true ); 517 mCalendar->checkAlarmForIncidence( 0, true );
517} 518}
518 519
519void CalendarView::computeAlarm( QString msg ) 520void CalendarView::computeAlarm( QString msg )
520{ 521{
521 522
522 QString mess = msg; 523 QString mess = msg;
523 QString mAlarmMessage = mess.mid( 9 ); 524 QString mAlarmMessage = mess.mid( 9 );
524 QString filename = MainWindow::resourcePath(); 525 QString filename = MainWindow::resourcePath();
525 filename += "koalarm.wav"; 526 filename += "koalarm.wav";
526 QString tempfilename; 527 QString tempfilename;
527 if ( mess.left( 13 ) == "suspend_alarm") { 528 if ( mess.left( 13 ) == "suspend_alarm") {
528 bool error = false; 529 bool error = false;
529 int len = mess.mid( 13 ).find("+++"); 530 int len = mess.mid( 13 ).find("+++");
530 if ( len < 2 ) 531 if ( len < 2 )
531 error = true; 532 error = true;
532 else { 533 else {
533 tempfilename = mess.mid( 13, len ); 534 tempfilename = mess.mid( 13, len );
534 if ( !QFile::exists( tempfilename ) ) 535 if ( !QFile::exists( tempfilename ) )
535 error = true; 536 error = true;
536 } 537 }
537 if ( ! error ) { 538 if ( ! error ) {
538 filename = tempfilename; 539 filename = tempfilename;
539 } 540 }
540 mAlarmMessage = mess.mid( 13+len+3 ); 541 mAlarmMessage = mess.mid( 13+len+3 );
541 //qDebug("suspend file %s ",tempfilename.latin1() ); 542 //qDebug("suspend file %s ",tempfilename.latin1() );
542 startAlarm( mAlarmMessage, filename); 543 startAlarm( mAlarmMessage, filename);
543 return; 544 return;
544 } 545 }
545 if ( mess.left( 11 ) == "timer_alarm") { 546 if ( mess.left( 11 ) == "timer_alarm") {
546 //mTimerTime = 0; 547 //mTimerTime = 0;
547 startAlarm( mess.mid( 11 ), filename ); 548 startAlarm( mess.mid( 11 ), filename );
548 return; 549 return;
549 } 550 }
550 if ( mess.left( 10 ) == "proc_alarm") { 551 if ( mess.left( 10 ) == "proc_alarm") {
551 bool error = false; 552 bool error = false;
552 int len = mess.mid( 10 ).find("+++"); 553 int len = mess.mid( 10 ).find("+++");
553 if ( len < 2 ) 554 if ( len < 2 )
554 error = true; 555 error = true;
555 else { 556 else {
556 tempfilename = mess.mid( 10, len ); 557 tempfilename = mess.mid( 10, len );
557 if ( !QFile::exists( tempfilename ) ) 558 if ( !QFile::exists( tempfilename ) )
558 error = true; 559 error = true;
559 } 560 }
560 if ( error ) { 561 if ( error ) {
561 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 562 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
562 mAlarmMessage += mess.mid( 10+len+3+9 ); 563 mAlarmMessage += mess.mid( 10+len+3+9 );
563 } else { 564 } else {
564 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 565 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
565 //qDebug("-----system command %s ",tempfilename.latin1() ); 566 //qDebug("-----system command %s ",tempfilename.latin1() );
566#ifndef _WIN32_ 567#ifndef _WIN32_
567 if ( vfork () == 0 ) { 568 if ( vfork () == 0 ) {
568 execl ( tempfilename.latin1(), 0 ); 569 execl ( tempfilename.latin1(), 0 );
569 return; 570 return;
570 } 571 }
571#else 572#else
572 QProcess* p = new QProcess(); 573 QProcess* p = new QProcess();
573 p->addArgument( tempfilename.latin1() ); 574 p->addArgument( tempfilename.latin1() );
574 p->start(); 575 p->start();
575 return; 576 return;
576#endif 577#endif
577 578
578 return; 579 return;
579 } 580 }
580 581
581 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 582 //qDebug("+++++++system command %s ",tempfilename.latin1() );
582 } 583 }
583 if ( mess.left( 11 ) == "audio_alarm") { 584 if ( mess.left( 11 ) == "audio_alarm") {
584 bool error = false; 585 bool error = false;
585 int len = mess.mid( 11 ).find("+++"); 586 int len = mess.mid( 11 ).find("+++");
586 if ( len < 2 ) 587 if ( len < 2 )
587 error = true; 588 error = true;
588 else { 589 else {
589 tempfilename = mess.mid( 11, len ); 590 tempfilename = mess.mid( 11, len );
590 if ( !QFile::exists( tempfilename ) ) 591 if ( !QFile::exists( tempfilename ) )
591 error = true; 592 error = true;
592 } 593 }
593 if ( ! error ) { 594 if ( ! error ) {
594 filename = tempfilename; 595 filename = tempfilename;
595 } 596 }
596 mAlarmMessage = mess.mid( 11+len+3+9 ); 597 mAlarmMessage = mess.mid( 11+len+3+9 );
597 //qDebug("audio file command %s ",tempfilename.latin1() ); 598 //qDebug("audio file command %s ",tempfilename.latin1() );
598 } 599 }
599 if ( mess.left( 9 ) == "cal_alarm") { 600 if ( mess.left( 9 ) == "cal_alarm") {
600 mAlarmMessage = mess.mid( 9 ) ; 601 mAlarmMessage = mess.mid( 9 ) ;
601 } 602 }
602 603
603 startAlarm( mAlarmMessage, filename ); 604 startAlarm( mAlarmMessage, filename );
604 605
605 606
606} 607}
607 608
608void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 609void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
609{ 610{
610 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 611 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
611 612
612 mSuspendAlarmNotification = noti; 613 mSuspendAlarmNotification = noti;
613 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 614 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
614 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 615 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
615 mSuspendTimer->start( ms , true ); 616 mSuspendTimer->start( ms , true );
616 617
617} 618}
618 619
619void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 620void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
620{ 621{
621 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 622 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
622 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 623 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
623#ifndef DESKTOP_VERSION 624#ifndef DESKTOP_VERSION
624 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 625 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
625#endif 626#endif
626 return; 627 return;
627 } 628 }
628 int maxSec; 629 int maxSec;
629 //maxSec = 5; //testing only 630 //maxSec = 5; //testing only
630 maxSec = 86400+3600; // one day+1hour 631 maxSec = 86400+3600; // one day+1hour
631 mAlarmNotification = noti; 632 mAlarmNotification = noti;
632 int sec = QDateTime::currentDateTime().secsTo( qdt ); 633 int sec = QDateTime::currentDateTime().secsTo( qdt );
633 if ( sec > maxSec ) { 634 if ( sec > maxSec ) {
634 mRecheckAlarmTimer->start( maxSec * 1000 ); 635 mRecheckAlarmTimer->start( maxSec * 1000 );
635 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 636 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
636 return; 637 return;
637 } else { 638 } else {
638 mRecheckAlarmTimer->stop(); 639 mRecheckAlarmTimer->stop();
639 } 640 }
640 //qDebug("Alarm timer started with secs: %d ", sec); 641 //qDebug("Alarm timer started with secs: %d ", sec);
641 mAlarmTimer->start( sec *1000 , true ); 642 mAlarmTimer->start( sec *1000 , true );
642 643
643} 644}
644// called by mRecheckAlarmTimer to get next alarm 645// called by mRecheckAlarmTimer to get next alarm
645// we need this, because a QTimer has only a max range of 25 days 646// we need this, because a QTimer has only a max range of 25 days
646void CalendarView::recheckTimerAlarm() 647void CalendarView::recheckTimerAlarm()
647{ 648{
648 mAlarmTimer->stop(); 649 mAlarmTimer->stop();
649 mRecheckAlarmTimer->stop(); 650 mRecheckAlarmTimer->stop();
650 mCalendar->checkAlarmForIncidence( 0, true ); 651 mCalendar->checkAlarmForIncidence( 0, true );
651} 652}
652void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 653void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
653{ 654{
654 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 655 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
655 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 656 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
656#ifndef DESKTOP_VERSION 657#ifndef DESKTOP_VERSION
657 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 658 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
658#endif 659#endif
659 return; 660 return;
660 } 661 }
661 mAlarmTimer->stop(); 662 mAlarmTimer->stop();
662} 663}
663void CalendarView::selectWeekNum ( int num ) 664void CalendarView::selectWeekNum ( int num )
664{ 665{
665 dateNavigator()->blockSignals( true ); 666 dateNavigator()->blockSignals( true );
666 dateNavigator()->selectWeek( num ); 667 dateNavigator()->selectWeek( num );
667 dateNavigator()->blockSignals( false ); 668 dateNavigator()->blockSignals( false );
668 mViewManager->showWeekView(); 669 mViewManager->showWeekView();
669} 670}
670KOViewManager *CalendarView::viewManager() 671KOViewManager *CalendarView::viewManager()
671{ 672{
672 return mViewManager; 673 return mViewManager;
673} 674}
674 675
@@ -2338,651 +2339,663 @@ void CalendarView::removeCategories()
2338} 2339}
2339 2340
2340int CalendarView::addCategories() 2341int CalendarView::addCategories()
2341{ 2342{
2342 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2343 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2343 QStringList catList = KOPrefs::instance()->mCustomCategories; 2344 QStringList catList = KOPrefs::instance()->mCustomCategories;
2344 QStringList catIncList; 2345 QStringList catIncList;
2345 Incidence* inc = incList.first(); 2346 Incidence* inc = incList.first();
2346 int i; 2347 int i;
2347 int count = 0; 2348 int count = 0;
2348 while ( inc ) { 2349 while ( inc ) {
2349 catIncList = inc->categories() ; 2350 catIncList = inc->categories() ;
2350 for( i = 0; i< catIncList.count(); ++i ) { 2351 for( i = 0; i< catIncList.count(); ++i ) {
2351 if ( !catList.contains (catIncList[i])) { 2352 if ( !catList.contains (catIncList[i])) {
2352 catList.append( catIncList[i] ); 2353 catList.append( catIncList[i] );
2353 //qDebug("add cat %s ", catIncList[i].latin1()); 2354 //qDebug("add cat %s ", catIncList[i].latin1());
2354 ++count; 2355 ++count;
2355 } 2356 }
2356 } 2357 }
2357 inc = incList.next(); 2358 inc = incList.next();
2358 } 2359 }
2359 catList.sort(); 2360 catList.sort();
2360 KOPrefs::instance()->mCustomCategories = catList; 2361 KOPrefs::instance()->mCustomCategories = catList;
2361 return count; 2362 return count;
2362} 2363}
2363 2364
2364void CalendarView::manageCategories() 2365void CalendarView::manageCategories()
2365{ 2366{
2366 KOCatPrefs* cp = new KOCatPrefs(); 2367 KOCatPrefs* cp = new KOCatPrefs();
2367 cp->show(); 2368 cp->show();
2368 int w =cp->sizeHint().width() ; 2369 int w =cp->sizeHint().width() ;
2369 int h = cp->sizeHint().height() ; 2370 int h = cp->sizeHint().height() ;
2370 int dw = QApplication::desktop()->width(); 2371 int dw = QApplication::desktop()->width();
2371 int dh = QApplication::desktop()->height(); 2372 int dh = QApplication::desktop()->height();
2372 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2373 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2373 if ( !cp->exec() ) { 2374 if ( !cp->exec() ) {
2374 delete cp; 2375 delete cp;
2375 return; 2376 return;
2376 } 2377 }
2377 int count = 0; 2378 int count = 0;
2378 if ( cp->addCat() ) { 2379 if ( cp->addCat() ) {
2379 count = addCategories(); 2380 count = addCategories();
2380 if ( count ) { 2381 if ( count ) {
2381 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2382 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2382 writeSettings(); 2383 writeSettings();
2383 } else 2384 } else
2384 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2385 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2385 } else { 2386 } else {
2386 removeCategories(); 2387 removeCategories();
2387 updateView(); 2388 updateView();
2388 } 2389 }
2389 delete cp; 2390 delete cp;
2390} 2391}
2391 2392
2392void CalendarView::beamIncidence(Incidence * Inc) 2393void CalendarView::beamIncidence(Incidence * Inc)
2393{ 2394{
2394 QPtrList<Incidence> delSel ; 2395 QPtrList<Incidence> delSel ;
2395 delSel.append(Inc); 2396 delSel.append(Inc);
2396 beamIncidenceList( delSel ); 2397 beamIncidenceList( delSel );
2397} 2398}
2398void CalendarView::beamCalendar() 2399void CalendarView::beamCalendar()
2399{ 2400{
2400 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2401 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2401 //qDebug("beamCalendar() "); 2402 //qDebug("beamCalendar() ");
2402 beamIncidenceList( delSel ); 2403 beamIncidenceList( delSel );
2403} 2404}
2404void CalendarView::beamFilteredCalendar() 2405void CalendarView::beamFilteredCalendar()
2405{ 2406{
2406 QPtrList<Incidence> delSel = mCalendar->incidences(); 2407 QPtrList<Incidence> delSel = mCalendar->incidences();
2407 //qDebug("beamFilteredCalendar() "); 2408 //qDebug("beamFilteredCalendar() ");
2408 beamIncidenceList( delSel ); 2409 beamIncidenceList( delSel );
2409} 2410}
2410void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2411void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2411{ 2412{
2412 if ( beamDialog->exec () == QDialog::Rejected ) 2413 if ( beamDialog->exec () == QDialog::Rejected )
2413 return; 2414 return;
2414#ifdef DESKTOP_VERSION 2415#ifdef DESKTOP_VERSION
2415 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2416 QString fn = locateLocal( "tmp", "kopibeamfile" );
2416#else 2417#else
2417 QString fn = "/tmp/kopibeamfile"; 2418 QString fn = "/tmp/kopibeamfile";
2418#endif 2419#endif
2419 QString mes; 2420 QString mes;
2420 bool createbup = true; 2421 bool createbup = true;
2421 if ( createbup ) { 2422 if ( createbup ) {
2422 QString description = "\n"; 2423 QString description = "\n";
2423 CalendarLocal* cal = new CalendarLocal(); 2424 CalendarLocal* cal = new CalendarLocal();
2424 if ( beamDialog->beamLocal() ) 2425 if ( beamDialog->beamLocal() )
2425 cal->setLocalTime(); 2426 cal->setLocalTime();
2426 else 2427 else
2427 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2428 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2428 Incidence *incidence = delSel.first(); 2429 Incidence *incidence = delSel.first();
2429 bool addText = false; 2430 bool addText = false;
2430 if ( delSel.count() < 10 ) 2431 if ( delSel.count() < 10 )
2431 addText = true; 2432 addText = true;
2432 else { 2433 else {
2433 description.sprintf(i18n(" %d items?"),delSel.count() ); 2434 description.sprintf(i18n(" %d items?"),delSel.count() );
2434 } 2435 }
2435 while ( incidence ) { 2436 while ( incidence ) {
2436 Incidence *in = incidence->clone(); 2437 Incidence *in = incidence->clone();
2437 if ( ! in->summary().isEmpty() ) { 2438 if ( ! in->summary().isEmpty() ) {
2438 in->setDescription(""); 2439 in->setDescription("");
2439 } else { 2440 } else {
2440 in->setSummary( in->description().left(20)); 2441 in->setSummary( in->description().left(20));
2441 in->setDescription(""); 2442 in->setDescription("");
2442 } 2443 }
2443 if ( addText ) 2444 if ( addText )
2444 description += in->summary() + "\n"; 2445 description += in->summary() + "\n";
2445 cal->addIncidence( in ); 2446 cal->addIncidence( in );
2446 incidence = delSel.next(); 2447 incidence = delSel.next();
2447 } 2448 }
2448 if ( beamDialog->beamVcal() ) { 2449 if ( beamDialog->beamVcal() ) {
2449 fn += ".vcs"; 2450 fn += ".vcs";
2450 FileStorage storage( cal, fn, new VCalFormat ); 2451 FileStorage storage( cal, fn, new VCalFormat );
2451 storage.save(); 2452 storage.save();
2452 } else { 2453 } else {
2453 fn += ".ics"; 2454 fn += ".ics";
2454 FileStorage storage( cal, fn, new ICalFormat( ) ); 2455 FileStorage storage( cal, fn, new ICalFormat( ) );
2455 storage.save(); 2456 storage.save();
2456 } 2457 }
2457 delete cal; 2458 delete cal;
2458 mes = i18n("KO/Pi: Ready for beaming"); 2459 mes = i18n("KO/Pi: Ready for beaming");
2459 topLevelWidget()->setCaption(mes); 2460 topLevelWidget()->setCaption(mes);
2460 KApplication::convert2latin1( fn ); 2461 KApplication::convert2latin1( fn );
2461#ifndef DESKTOP_VERSION 2462#ifndef DESKTOP_VERSION
2462 Ir *ir = new Ir( this ); 2463 Ir *ir = new Ir( this );
2463 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2464 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2464 ir->send( fn, description, "text/x-vCalendar" ); 2465 ir->send( fn, description, "text/x-vCalendar" );
2465#endif 2466#endif
2466 } 2467 }
2467} 2468}
2468void CalendarView::beamDone( Ir *ir ) 2469void CalendarView::beamDone( Ir *ir )
2469{ 2470{
2470#ifndef DESKTOP_VERSION 2471#ifndef DESKTOP_VERSION
2471 delete ir; 2472 delete ir;
2472#endif 2473#endif
2473 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2474 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2474 topLevelWidget()->raise(); 2475 topLevelWidget()->raise();
2475} 2476}
2476 2477
2477void CalendarView::moveIncidence(Incidence * inc ) 2478void CalendarView::moveIncidence(Incidence * inc )
2478{ 2479{
2479 if ( !inc ) return; 2480 if ( !inc ) return;
2480 showDatePickerPopup(); 2481 showDatePickerPopup();
2481 mDatePickerMode = 2; 2482 mDatePickerMode = 2;
2482 mMoveIncidence = inc ; 2483 mMoveIncidence = inc ;
2483 QDate da; 2484 QDate da;
2484 if ( mMoveIncidence->type() == "Todo" ) { 2485 if ( mMoveIncidence->type() == "Todo" ) {
2485 Todo * to = (Todo *) mMoveIncidence; 2486 Todo * to = (Todo *) mMoveIncidence;
2486 if ( to->hasDueDate() ) 2487 if ( to->hasDueDate() )
2487 da = to->dtDue().date(); 2488 da = to->dtDue().date();
2488 else 2489 else
2489 da = QDate::currentDate(); 2490 da = QDate::currentDate();
2490 } else { 2491 } else {
2491 da = mMoveIncidence->dtStart().date(); 2492 da = mMoveIncidence->dtStart().date();
2492 } 2493 }
2493 //PENDING set date for recurring incidence to date of recurrence 2494 //PENDING set date for recurring incidence to date of recurrence
2494 //mMoveIncidenceOldDate; 2495 //mMoveIncidenceOldDate;
2495 mDatePicker->setDate( da ); 2496 mDatePicker->setDate( da );
2496} 2497}
2497void CalendarView::showDatePickerPopup() 2498void CalendarView::showDatePickerPopup()
2498{ 2499{
2499 if ( mDateFrame->isVisible() ) 2500 if ( mDateFrame->isVisible() )
2500 mDateFrame->hide(); 2501 mDateFrame->hide();
2501 else { 2502 else {
2502 int offX = 0, offY = 0; 2503 int offX = 0, offY = 0;
2503#ifdef DESKTOP_VERSION 2504#ifdef DESKTOP_VERSION
2504 int w =mDatePicker->sizeHint().width() ; 2505 int w =mDatePicker->sizeHint().width() ;
2505 int h = mDatePicker->sizeHint().height() ; 2506 int h = mDatePicker->sizeHint().height() ;
2506 int dw = topLevelWidget()->width(); 2507 int dw = topLevelWidget()->width();
2507 int dh = topLevelWidget()->height(); 2508 int dh = topLevelWidget()->height();
2508 offX = topLevelWidget()->x(); 2509 offX = topLevelWidget()->x();
2509 offY = topLevelWidget()->y(); 2510 offY = topLevelWidget()->y();
2510#else 2511#else
2511 int w =mDatePicker->sizeHint().width() ; 2512 int w =mDatePicker->sizeHint().width() ;
2512 int h = mDatePicker->sizeHint().height() ; 2513 int h = mDatePicker->sizeHint().height() ;
2513 int dw = QApplication::desktop()->width(); 2514 int dw = QApplication::desktop()->width();
2514 int dh = QApplication::desktop()->height(); 2515 int dh = QApplication::desktop()->height();
2515#endif 2516#endif
2516 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2517 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2517 mDateFrame->show(); 2518 mDateFrame->show();
2518 } 2519 }
2519} 2520}
2520void CalendarView::showDatePicker( ) 2521void CalendarView::showDatePicker( )
2521{ 2522{
2522 showDatePickerPopup(); 2523 showDatePickerPopup();
2523 mDatePickerMode = 1; 2524 mDatePickerMode = 1;
2524 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2525 mDatePicker->setDate( mNavigator->selectedDates().first() );
2525} 2526}
2526 2527
2527void CalendarView::showEventEditor() 2528void CalendarView::showEventEditor()
2528{ 2529{
2529#ifdef DESKTOP_VERSION 2530#ifdef DESKTOP_VERSION
2531 int x,y,w,h;
2532 x = mEventEditor->geometry().x();
2533 y = mEventEditor->geometry().y();
2534 w = mEventEditor->width();
2535 h = mEventEditor->height();
2530 mEventEditor->show(); 2536 mEventEditor->show();
2537 mEventEditor->setGeometry(x,y,w,h);
2531#else 2538#else
2532 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2539 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2533 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2540 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2534 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2541 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2535 qApp->processEvents(); 2542 qApp->processEvents();
2536 delete mEventEditor; 2543 delete mEventEditor;
2537 mEventEditor = mDialogManager->getEventEditor(); 2544 mEventEditor = mDialogManager->getEventEditor();
2538 topLevelWidget()->setCaption( i18n("") ); 2545 topLevelWidget()->setCaption( i18n("") );
2539 } 2546 }
2540 mEventEditor->showMaximized(); 2547 mEventEditor->showMaximized();
2541#endif 2548#endif
2542} 2549}
2543void CalendarView::showTodoEditor() 2550void CalendarView::showTodoEditor()
2544{ 2551{
2545#ifdef DESKTOP_VERSION 2552#ifdef DESKTOP_VERSION
2553 int x,y,w,h;
2554 x = mTodoEditor->geometry().x();
2555 y = mTodoEditor->geometry().y();
2556 w = mTodoEditor->width();
2557 h = mTodoEditor->height();
2546 mTodoEditor->show(); 2558 mTodoEditor->show();
2559 mTodoEditor->setGeometry(x,y,w,h);
2547#else 2560#else
2548 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2561 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2549 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2562 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2550 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2563 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2551 qApp->processEvents(); 2564 qApp->processEvents();
2552 delete mTodoEditor; 2565 delete mTodoEditor;
2553 mTodoEditor = mDialogManager->getTodoEditor(); 2566 mTodoEditor = mDialogManager->getTodoEditor();
2554 topLevelWidget()->setCaption( i18n("") ); 2567 topLevelWidget()->setCaption( i18n("") );
2555 } 2568 }
2556 mTodoEditor->showMaximized(); 2569 mTodoEditor->showMaximized();
2557#endif 2570#endif
2558} 2571}
2559 2572
2560void CalendarView::cloneIncidence() 2573void CalendarView::cloneIncidence()
2561{ 2574{
2562 Incidence *incidence = currentSelection(); 2575 Incidence *incidence = currentSelection();
2563 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2576 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2564 if ( incidence ) { 2577 if ( incidence ) {
2565 cloneIncidence(incidence); 2578 cloneIncidence(incidence);
2566 } 2579 }
2567} 2580}
2568void CalendarView::moveIncidence() 2581void CalendarView::moveIncidence()
2569{ 2582{
2570 Incidence *incidence = currentSelection(); 2583 Incidence *incidence = currentSelection();
2571 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2584 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2572 if ( incidence ) { 2585 if ( incidence ) {
2573 moveIncidence(incidence); 2586 moveIncidence(incidence);
2574 } 2587 }
2575} 2588}
2576void CalendarView::beamIncidence() 2589void CalendarView::beamIncidence()
2577{ 2590{
2578 Incidence *incidence = currentSelection(); 2591 Incidence *incidence = currentSelection();
2579 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2592 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2580 if ( incidence ) { 2593 if ( incidence ) {
2581 beamIncidence(incidence); 2594 beamIncidence(incidence);
2582 } 2595 }
2583} 2596}
2584void CalendarView::toggleCancelIncidence() 2597void CalendarView::toggleCancelIncidence()
2585{ 2598{
2586 Incidence *incidence = currentSelection(); 2599 Incidence *incidence = currentSelection();
2587 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2600 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2588 if ( incidence ) { 2601 if ( incidence ) {
2589 cancelIncidence(incidence); 2602 cancelIncidence(incidence);
2590 } 2603 }
2591} 2604}
2592 2605
2593 2606
2594void CalendarView::cancelIncidence(Incidence * inc ) 2607void CalendarView::cancelIncidence(Incidence * inc )
2595{ 2608{
2596 inc->setCancelled( ! inc->cancelled() ); 2609 inc->setCancelled( ! inc->cancelled() );
2597 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2610 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2598 updateView(); 2611 updateView();
2599} 2612}
2600void CalendarView::cloneIncidence(Incidence * orgInc ) 2613void CalendarView::cloneIncidence(Incidence * orgInc )
2601{ 2614{
2602 Incidence * newInc = orgInc->clone(); 2615 Incidence * newInc = orgInc->clone();
2603 newInc->recreate(); 2616 newInc->recreate();
2604 2617
2605 if ( newInc->type() == "Todo" ) { 2618 if ( newInc->type() == "Todo" ) {
2606 Todo* t = (Todo*) newInc; 2619 Todo* t = (Todo*) newInc;
2607 showTodoEditor(); 2620 showTodoEditor();
2608 mTodoEditor->editTodo( t ); 2621 mTodoEditor->editTodo( t );
2609 if ( mTodoEditor->exec() ) { 2622 if ( mTodoEditor->exec() ) {
2610 mCalendar->addTodo( t ); 2623 mCalendar->addTodo( t );
2611 updateView(); 2624 updateView();
2612 } else { 2625 } else {
2613 delete t; 2626 delete t;
2614 } 2627 }
2615 } 2628 }
2616 else { 2629 else {
2617 Event* e = (Event*) newInc; 2630 Event* e = (Event*) newInc;
2618 showEventEditor(); 2631 showEventEditor();
2619 mEventEditor->editEvent( e ); 2632 mEventEditor->editEvent( e );
2620 if ( mEventEditor->exec() ) { 2633 if ( mEventEditor->exec() ) {
2621 mCalendar->addEvent( e ); 2634 mCalendar->addEvent( e );
2622 updateView(); 2635 updateView();
2623 } else { 2636 } else {
2624 delete e; 2637 delete e;
2625 } 2638 }
2626 } 2639 }
2627 setActiveWindow(); 2640 setActiveWindow();
2628} 2641}
2629 2642
2630void CalendarView::newEvent() 2643void CalendarView::newEvent()
2631{ 2644{
2632 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2645 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2633 KOAgendaView *aView = mViewManager->agendaView(); 2646 KOAgendaView *aView = mViewManager->agendaView();
2634 if (aView) { 2647 if (aView) {
2635 if (aView->selectionStart().isValid()) { 2648 if (aView->selectionStart().isValid()) {
2636 if (aView->selectedIsAllDay()) { 2649 if (aView->selectedIsAllDay()) {
2637 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2650 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2638 } else { 2651 } else {
2639 newEvent(aView->selectionStart(),aView->selectionEnd()); 2652 newEvent(aView->selectionStart(),aView->selectionEnd());
2640 } 2653 }
2641 return; 2654 return;
2642 } 2655 }
2643 } 2656 }
2644 2657
2645 QDate date = mNavigator->selectedDates().first(); 2658 QDate date = mNavigator->selectedDates().first();
2646 QDateTime current = QDateTime::currentDateTime(); 2659 QDateTime current = QDateTime::currentDateTime();
2647 if ( date <= current.date() ) { 2660 if ( date <= current.date() ) {
2648 int hour = current.time().hour() +1; 2661 int hour = current.time().hour() +1;
2649 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2662 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2650 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2663 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2651 } else 2664 } else
2652 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2665 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2653 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2666 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2654 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2667 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2655} 2668}
2656 2669
2657void CalendarView::newEvent(QDateTime fh) 2670void CalendarView::newEvent(QDateTime fh)
2658{ 2671{
2659 newEvent(fh, 2672 newEvent(fh,
2660 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2673 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2661} 2674}
2662 2675
2663void CalendarView::newEvent(QDate dt) 2676void CalendarView::newEvent(QDate dt)
2664{ 2677{
2665 newEvent(QDateTime(dt, QTime(0,0,0)), 2678 newEvent(QDateTime(dt, QTime(0,0,0)),
2666 QDateTime(dt, QTime(0,0,0)), true); 2679 QDateTime(dt, QTime(0,0,0)), true);
2667} 2680}
2668void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2681void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2669{ 2682{
2670 newEvent(fromHint, toHint, false); 2683 newEvent(fromHint, toHint, false);
2671} 2684}
2672void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2685void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2673{ 2686{
2674 2687
2675 showEventEditor(); 2688 showEventEditor();
2676 mEventEditor->newEvent(fromHint,toHint,allDay); 2689 mEventEditor->newEvent(fromHint,toHint,allDay);
2677 if ( mFilterView->filtersEnabled() ) { 2690 if ( mFilterView->filtersEnabled() ) {
2678 CalFilter *filter = mFilterView->selectedFilter(); 2691 CalFilter *filter = mFilterView->selectedFilter();
2679 if (filter && filter->showCategories()) { 2692 if (filter && filter->showCategories()) {
2680 mEventEditor->setCategories(filter->categoryList().join(",") ); 2693 mEventEditor->setCategories(filter->categoryList().join(",") );
2681 } 2694 }
2682 if ( filter ) 2695 if ( filter )
2683 mEventEditor->setSecrecy( filter->getSecrecy() ); 2696 mEventEditor->setSecrecy( filter->getSecrecy() );
2684 } 2697 }
2685 mEventEditor->exec(); 2698 mEventEditor->exec();
2686 setActiveWindow(); 2699 setActiveWindow();
2687} 2700}
2688void CalendarView::todoAdded(Todo * t) 2701void CalendarView::todoAdded(Todo * t)
2689{ 2702{
2690 2703
2691 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2704 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2692 updateTodoViews(); 2705 updateTodoViews();
2693} 2706}
2694void CalendarView::todoChanged(Todo * t) 2707void CalendarView::todoChanged(Todo * t)
2695{ 2708{
2696 emit todoModified( t, 4 ); 2709 emit todoModified( t, 4 );
2697 // updateTodoViews(); 2710 // updateTodoViews();
2698} 2711}
2699void CalendarView::todoToBeDeleted(Todo *) 2712void CalendarView::todoToBeDeleted(Todo *)
2700{ 2713{
2701 //qDebug("todoToBeDeleted(Todo *) "); 2714 //qDebug("todoToBeDeleted(Todo *) ");
2702 updateTodoViews(); 2715 updateTodoViews();
2703} 2716}
2704void CalendarView::todoDeleted() 2717void CalendarView::todoDeleted()
2705{ 2718{
2706 //qDebug(" todoDeleted()"); 2719 //qDebug(" todoDeleted()");
2707 updateTodoViews(); 2720 updateTodoViews();
2708} 2721}
2709 2722
2710 2723
2711void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2724void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2712{ 2725{
2713 showTodoEditor(); 2726 showTodoEditor();
2714 mTodoEditor->newTodo(dt,0,allday); 2727 mTodoEditor->newTodo(dt,0,allday);
2715 if ( mFilterView->filtersEnabled() ) { 2728 if ( mFilterView->filtersEnabled() ) {
2716 CalFilter *filter = mFilterView->selectedFilter(); 2729 CalFilter *filter = mFilterView->selectedFilter();
2717 if (filter && filter->showCategories()) { 2730 if (filter && filter->showCategories()) {
2718 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2731 mTodoEditor->setCategories(filter->categoryList().join(",") );
2719 } 2732 }
2720 if ( filter ) 2733 if ( filter )
2721 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2734 mTodoEditor->setSecrecy( filter->getSecrecy() );
2722 } 2735 }
2723 mTodoEditor->exec(); 2736 mTodoEditor->exec();
2724 setActiveWindow(); 2737 setActiveWindow();
2725} 2738}
2726 2739
2727void CalendarView::newTodo() 2740void CalendarView::newTodo()
2728{ 2741{
2729 newTodoDateTime( QDateTime(),true ); 2742 newTodoDateTime( QDateTime(),true );
2730} 2743}
2731 2744
2732void CalendarView::newSubTodo() 2745void CalendarView::newSubTodo()
2733{ 2746{
2734 Todo *todo = selectedTodo(); 2747 Todo *todo = selectedTodo();
2735 if ( todo ) newSubTodo( todo ); 2748 if ( todo ) newSubTodo( todo );
2736} 2749}
2737 2750
2738void CalendarView::newSubTodo(Todo *parentEvent) 2751void CalendarView::newSubTodo(Todo *parentEvent)
2739{ 2752{
2740 2753
2741 showTodoEditor(); 2754 showTodoEditor();
2742 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 2755 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
2743 mTodoEditor->exec(); 2756 mTodoEditor->exec();
2744 setActiveWindow(); 2757 setActiveWindow();
2745} 2758}
2746 2759
2747void CalendarView::newFloatingEvent() 2760void CalendarView::newFloatingEvent()
2748{ 2761{
2749 DateList tmpList = mNavigator->selectedDates(); 2762 DateList tmpList = mNavigator->selectedDates();
2750 QDate date = tmpList.first(); 2763 QDate date = tmpList.first();
2751 2764
2752 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2765 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2753 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2766 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2754} 2767}
2755 2768
2756 2769
2757void CalendarView::editEvent( Event *event ) 2770void CalendarView::editEvent( Event *event )
2758{ 2771{
2759 2772
2760 if ( !event ) return; 2773 if ( !event ) return;
2761 if ( event->isReadOnly() ) { 2774 if ( event->isReadOnly() ) {
2762 showEvent( event ); 2775 showEvent( event );
2763 return; 2776 return;
2764 } 2777 }
2765 showEventEditor(); 2778 showEventEditor();
2766 mEventEditor->editEvent( event , mFlagEditDescription); 2779 mEventEditor->editEvent( event , mFlagEditDescription);
2767 mEventEditor->exec(); 2780 mEventEditor->exec();
2768 setActiveWindow(); 2781 setActiveWindow();
2769 2782
2770} 2783}
2771void CalendarView::editJournal( Journal *jour ) 2784void CalendarView::editJournal( Journal *jour )
2772{ 2785{
2773 if ( !jour ) return; 2786 if ( !jour ) return;
2774 mDialogManager->hideSearchDialog(); 2787 mDialogManager->hideSearchDialog();
2775 mViewManager->showJournalView(); 2788 mViewManager->showJournalView();
2776 mNavigator->slotDaySelect( jour->dtStart().date() ); 2789 mNavigator->slotDaySelect( jour->dtStart().date() );
2777} 2790}
2778void CalendarView::editTodo( Todo *todo ) 2791void CalendarView::editTodo( Todo *todo )
2779{ 2792{
2780 if ( !todo ) return; 2793 if ( !todo ) return;
2781 2794
2782 if ( todo->isReadOnly() ) { 2795 if ( todo->isReadOnly() ) {
2783 showTodo( todo ); 2796 showTodo( todo );
2784 return; 2797 return;
2785 } 2798 }
2786 showTodoEditor(); 2799 showTodoEditor();
2787 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2800 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2788 mTodoEditor->exec(); 2801 mTodoEditor->exec();
2789 setActiveWindow(); 2802 setActiveWindow();
2790 2803
2791} 2804}
2792 2805
2793KOEventViewerDialog* CalendarView::getEventViewerDialog() 2806KOEventViewerDialog* CalendarView::getEventViewerDialog()
2794{ 2807{
2795 if ( !mEventViewerDialog ) { 2808 if ( !mEventViewerDialog ) {
2796 mEventViewerDialog = new KOEventViewerDialog(this); 2809 mEventViewerDialog = new KOEventViewerDialog(0);
2797 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2810 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2798 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2811 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2799 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2812 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2800 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2813 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2801 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2814 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2802 viewManager(), SLOT( showAgendaView( bool ) ) ); 2815 viewManager(), SLOT( showAgendaView( bool ) ) );
2803 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 2816 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
2804 this, SLOT( slotViewerClosed() ) ); 2817 this, SLOT( slotViewerClosed() ) );
2805 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2818 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2806 this, SLOT( todoChanged(Todo *) ) ); 2819 this, SLOT( todoChanged(Todo *) ) );
2807 mEventViewerDialog->resize( 640, 480 ); 2820 mEventViewerDialog->resize( 640, 480 );
2808 2821
2809 } 2822 }
2810 return mEventViewerDialog; 2823 return mEventViewerDialog;
2811} 2824}
2812void CalendarView::showEvent(Event *event) 2825void CalendarView::showEvent(Event *event)
2813{ 2826{
2814 getEventViewerDialog()->setEvent(event); 2827 getEventViewerDialog()->setEvent(event);
2815 getEventViewerDialog()->showMe(); 2828 getEventViewerDialog()->showMe();
2816} 2829}
2817 2830
2818void CalendarView::showTodo(Todo *event) 2831void CalendarView::showTodo(Todo *event)
2819{ 2832{
2820 getEventViewerDialog()->setTodo(event); 2833 getEventViewerDialog()->setTodo(event);
2821 getEventViewerDialog()->showMe(); 2834 getEventViewerDialog()->showMe();
2822} 2835}
2823void CalendarView::showJournal( Journal *jour ) 2836void CalendarView::showJournal( Journal *jour )
2824{ 2837{
2825 getEventViewerDialog()->setJournal(jour); 2838 getEventViewerDialog()->setJournal(jour);
2826 getEventViewerDialog()->showMe(); 2839 getEventViewerDialog()->showMe();
2827 2840
2828} 2841}
2829// void CalendarView::todoModified (Todo *event, int changed) 2842// void CalendarView::todoModified (Todo *event, int changed)
2830// { 2843// {
2831// // if (mDialogList.find (event) != mDialogList.end ()) { 2844// // if (mDialogList.find (event) != mDialogList.end ()) {
2832// // kdDebug() << "Todo modified and open" << endl; 2845// // kdDebug() << "Todo modified and open" << endl;
2833// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2846// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2834// // temp->modified (changed); 2847// // temp->modified (changed);
2835 2848
2836// // } 2849// // }
2837 2850
2838// mViewManager->updateView(); 2851// mViewManager->updateView();
2839// } 2852// }
2840 2853
2841void CalendarView::appointment_show() 2854void CalendarView::appointment_show()
2842{ 2855{
2843 Event *anEvent = 0; 2856 Event *anEvent = 0;
2844 2857
2845 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2858 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2846 2859
2847 if (mViewManager->currentView()->isEventView()) { 2860 if (mViewManager->currentView()->isEventView()) {
2848 if ( incidence && incidence->type() == "Event" ) { 2861 if ( incidence && incidence->type() == "Event" ) {
2849 anEvent = static_cast<Event *>(incidence); 2862 anEvent = static_cast<Event *>(incidence);
2850 } 2863 }
2851 } 2864 }
2852 2865
2853 if (!anEvent) { 2866 if (!anEvent) {
2854 KNotifyClient::beep(); 2867 KNotifyClient::beep();
2855 return; 2868 return;
2856 } 2869 }
2857 2870
2858 showEvent(anEvent); 2871 showEvent(anEvent);
2859} 2872}
2860 2873
2861void CalendarView::appointment_edit() 2874void CalendarView::appointment_edit()
2862{ 2875{
2863 Event *anEvent = 0; 2876 Event *anEvent = 0;
2864 2877
2865 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2878 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2866 2879
2867 if (mViewManager->currentView()->isEventView()) { 2880 if (mViewManager->currentView()->isEventView()) {
2868 if ( incidence && incidence->type() == "Event" ) { 2881 if ( incidence && incidence->type() == "Event" ) {
2869 anEvent = static_cast<Event *>(incidence); 2882 anEvent = static_cast<Event *>(incidence);
2870 } 2883 }
2871 } 2884 }
2872 2885
2873 if (!anEvent) { 2886 if (!anEvent) {
2874 KNotifyClient::beep(); 2887 KNotifyClient::beep();
2875 return; 2888 return;
2876 } 2889 }
2877 2890
2878 editEvent(anEvent); 2891 editEvent(anEvent);
2879} 2892}
2880 2893
2881void CalendarView::appointment_delete() 2894void CalendarView::appointment_delete()
2882{ 2895{
2883 Event *anEvent = 0; 2896 Event *anEvent = 0;
2884 2897
2885 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2898 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2886 2899
2887 if (mViewManager->currentView()->isEventView()) { 2900 if (mViewManager->currentView()->isEventView()) {
2888 if ( incidence && incidence->type() == "Event" ) { 2901 if ( incidence && incidence->type() == "Event" ) {
2889 anEvent = static_cast<Event *>(incidence); 2902 anEvent = static_cast<Event *>(incidence);
2890 } 2903 }
2891 } 2904 }
2892 2905
2893 if (!anEvent) { 2906 if (!anEvent) {
2894 KNotifyClient::beep(); 2907 KNotifyClient::beep();
2895 return; 2908 return;
2896 } 2909 }
2897 2910
2898 deleteEvent(anEvent); 2911 deleteEvent(anEvent);
2899} 2912}
2900 2913
2901void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2914void CalendarView::todo_resub( Todo * parent, Todo * sub )
2902{ 2915{
2903 if (!sub) return; 2916 if (!sub) return;
2904 if (!parent) return; 2917 if (!parent) return;
2905 if ( sub->relatedTo() ) 2918 if ( sub->relatedTo() )
2906 sub->relatedTo()->removeRelation(sub); 2919 sub->relatedTo()->removeRelation(sub);
2907 sub->setRelatedTo(parent); 2920 sub->setRelatedTo(parent);
2908 sub->setRelatedToUid(parent->uid()); 2921 sub->setRelatedToUid(parent->uid());
2909 parent->addRelation(sub); 2922 parent->addRelation(sub);
2910 sub->updated(); 2923 sub->updated();
2911 parent->updated(); 2924 parent->updated();
2912 setModified(true); 2925 setModified(true);
2913 updateView(); 2926 updateView();
2914} 2927}
2915void CalendarView::todo_unsub(Todo *anTodo ) 2928void CalendarView::todo_unsub(Todo *anTodo )
2916{ 2929{
2917 // Todo *anTodo = selectedTodo(); 2930 // Todo *anTodo = selectedTodo();
2918 if (!anTodo) return; 2931 if (!anTodo) return;
2919 if (!anTodo->relatedTo()) return; 2932 if (!anTodo->relatedTo()) return;
2920 anTodo->relatedTo()->removeRelation(anTodo); 2933 anTodo->relatedTo()->removeRelation(anTodo);
2921 anTodo->setRelatedTo(0); 2934 anTodo->setRelatedTo(0);
2922 anTodo->updated(); 2935 anTodo->updated();
2923 anTodo->setRelatedToUid(""); 2936 anTodo->setRelatedToUid("");
2924 setModified(true); 2937 setModified(true);
2925 updateView(); 2938 updateView();
2926} 2939}
2927 2940
2928void CalendarView::deleteTodo(Todo *todo) 2941void CalendarView::deleteTodo(Todo *todo)
2929{ 2942{
2930 if (!todo) { 2943 if (!todo) {
2931 KNotifyClient::beep(); 2944 KNotifyClient::beep();
2932 return; 2945 return;
2933 } 2946 }
2934 if (KOPrefs::instance()->mConfirm) { 2947 if (KOPrefs::instance()->mConfirm) {
2935 QString text = todo->summary().left(20); 2948 QString text = todo->summary().left(20);
2936 if (!todo->relations().isEmpty()) { 2949 if (!todo->relations().isEmpty()) {
2937 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 2950 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
2938 2951
2939 } 2952 }
2940 switch (msgItemDelete(text)) { 2953 switch (msgItemDelete(text)) {
2941 case KMessageBox::Continue: // OK 2954 case KMessageBox::Continue: // OK
2942 bool deleteT = false; 2955 bool deleteT = false;
2943 if (!todo->relations().isEmpty()) { 2956 if (!todo->relations().isEmpty()) {
2944 deleteT = removeCompletedSubTodos( todo ); 2957 deleteT = removeCompletedSubTodos( todo );
2945 } 2958 }
2946 // deleteT == true: todo already deleted in removeCompletedSubTodos 2959 // deleteT == true: todo already deleted in removeCompletedSubTodos
2947 if ( !deleteT ) { 2960 if ( !deleteT ) {
2948 checkExternalId( todo ); 2961 checkExternalId( todo );
2949 calendar()->deleteTodo(todo); 2962 calendar()->deleteTodo(todo);
2950 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2963 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2951 updateView(); 2964 updateView();
2952 } 2965 }
2953 break; 2966 break;
2954 } // switch 2967 } // switch
2955 } else { 2968 } else {
2956 checkExternalId( todo ); 2969 checkExternalId( todo );
2957 mCalendar->deleteTodo(todo); 2970 mCalendar->deleteTodo(todo);
2958 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2971 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2959 updateView(); 2972 updateView();
2960 } 2973 }
2961 2974
2962 emit updateSearchDialog(); 2975 emit updateSearchDialog();
2963} 2976}
2964void CalendarView::deleteJournal(Journal *jour) 2977void CalendarView::deleteJournal(Journal *jour)
2965{ 2978{
2966 if (!jour) { 2979 if (!jour) {
2967 KNotifyClient::beep(); 2980 KNotifyClient::beep();
2968 return; 2981 return;
2969 } 2982 }
2970 if (KOPrefs::instance()->mConfirm) { 2983 if (KOPrefs::instance()->mConfirm) {
2971 switch (msgItemDelete( jour->description().left(20))) { 2984 switch (msgItemDelete( jour->description().left(20))) {
2972 case KMessageBox::Continue: // OK 2985 case KMessageBox::Continue: // OK
2973 calendar()->deleteJournal(jour); 2986 calendar()->deleteJournal(jour);
2974 updateView(); 2987 updateView();
2975 break; 2988 break;
2976 } // switch 2989 } // switch
2977 } else { 2990 } else {
2978 calendar()->deleteJournal(jour);; 2991 calendar()->deleteJournal(jour);;
2979 updateView(); 2992 updateView();
2980 } 2993 }
2981 emit updateSearchDialog(); 2994 emit updateSearchDialog();
2982} 2995}
2983 2996
2984void CalendarView::deleteEvent(Event *anEvent) 2997void CalendarView::deleteEvent(Event *anEvent)
2985{ 2998{
2986 if (!anEvent) { 2999 if (!anEvent) {
2987 KNotifyClient::beep(); 3000 KNotifyClient::beep();
2988 return; 3001 return;
@@ -3778,197 +3791,198 @@ void CalendarView::editIncidence()
3778 if ( incidence ) { 3791 if ( incidence ) {
3779 EditIncidenceVisitor v; 3792 EditIncidenceVisitor v;
3780 v.act( incidence, this ); 3793 v.act( incidence, this );
3781 } 3794 }
3782} 3795}
3783 3796
3784void CalendarView::deleteIncidence() 3797void CalendarView::deleteIncidence()
3785{ 3798{
3786 Incidence *incidence = currentSelection(); 3799 Incidence *incidence = currentSelection();
3787 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3800 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3788 if ( incidence ) { 3801 if ( incidence ) {
3789 deleteIncidence(incidence); 3802 deleteIncidence(incidence);
3790 } 3803 }
3791} 3804}
3792 3805
3793void CalendarView::showIncidence(Incidence *incidence) 3806void CalendarView::showIncidence(Incidence *incidence)
3794{ 3807{
3795 mViewerCallerIsSearchDialog = false; 3808 mViewerCallerIsSearchDialog = false;
3796 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 3809 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
3797 if ( sender() && mDialogManager->getSearchDialog() ) { 3810 if ( sender() && mDialogManager->getSearchDialog() ) {
3798 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 3811 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
3799 mViewerCallerIsSearchDialog = true; 3812 mViewerCallerIsSearchDialog = true;
3800 } 3813 }
3801 } 3814 }
3802 if ( incidence ) { 3815 if ( incidence ) {
3803 ShowIncidenceVisitor v; 3816 ShowIncidenceVisitor v;
3804 v.act( incidence, this ); 3817 v.act( incidence, this );
3805 } 3818 }
3806} 3819}
3807 3820
3808void CalendarView::editIncidence(Incidence *incidence) 3821void CalendarView::editIncidence(Incidence *incidence)
3809{ 3822{
3810 if ( incidence ) { 3823 if ( incidence ) {
3811 3824
3812 EditIncidenceVisitor v; 3825 EditIncidenceVisitor v;
3813 v.act( incidence, this ); 3826 v.act( incidence, this );
3814 3827
3815 } 3828 }
3816} 3829}
3817 3830
3818void CalendarView::deleteIncidence(Incidence *incidence) 3831void CalendarView::deleteIncidence(Incidence *incidence)
3819{ 3832{
3820 //qDebug(" CalendarView::deleteIncidence "); 3833 //qDebug(" CalendarView::deleteIncidence ");
3821 if ( incidence ) { 3834 if ( incidence ) {
3822 DeleteIncidenceVisitor v; 3835 DeleteIncidenceVisitor v;
3823 v.act( incidence, this ); 3836 v.act( incidence, this );
3824 } 3837 }
3825} 3838}
3826 3839
3827 3840
3828void CalendarView::lookForOutgoingMessages() 3841void CalendarView::lookForOutgoingMessages()
3829{ 3842{
3830 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3843 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3831 ogd->loadMessages(); 3844 ogd->loadMessages();
3832} 3845}
3833 3846
3834void CalendarView::lookForIncomingMessages() 3847void CalendarView::lookForIncomingMessages()
3835{ 3848{
3836 IncomingDialog *icd = mDialogManager->incomingDialog(); 3849 IncomingDialog *icd = mDialogManager->incomingDialog();
3837 icd->retrieve(); 3850 icd->retrieve();
3838} 3851}
3839 3852
3840bool CalendarView::removeCompletedSubTodos( Todo* t ) 3853bool CalendarView::removeCompletedSubTodos( Todo* t )
3841{ 3854{
3842 bool deleteTodo = true; 3855 bool deleteTodo = true;
3843 QPtrList<Incidence> subTodos; 3856 QPtrList<Incidence> subTodos;
3844 Incidence *aTodo; 3857 Incidence *aTodo;
3845 subTodos = t->relations(); 3858 subTodos = t->relations();
3846 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3859 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3847 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3860 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3848 deleteTodo = false; 3861 deleteTodo = false;
3849 } 3862 }
3850 if ( deleteTodo ) { 3863 if ( deleteTodo ) {
3851 if ( t->isCompleted() && !t->doesRecur()) { 3864 if ( t->isCompleted() && !t->doesRecur()) {
3852 checkExternalId( t ); 3865 checkExternalId( t );
3853 mCalendar->deleteTodo( t ); 3866 mCalendar->deleteTodo( t );
3854 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3867 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3855 } 3868 }
3856 else 3869 else
3857 deleteTodo = false; 3870 deleteTodo = false;
3858 } 3871 }
3859 return deleteTodo; 3872 return deleteTodo;
3860 3873
3861} 3874}
3862void CalendarView::purgeCompleted() 3875void CalendarView::purgeCompleted()
3863{ 3876{
3864 int result = KMessageBox::warningContinueCancel(this, 3877 int result = KMessageBox::warningContinueCancel(this,
3865 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3878 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3866 3879
3867 if (result == KMessageBox::Continue) { 3880 if (result == KMessageBox::Continue) {
3868 3881
3869 QPtrList<Todo> todoCal; 3882 QPtrList<Todo> todoCal;
3870 QPtrList<Todo> rootTodos; 3883 QPtrList<Todo> rootTodos;
3871 //QPtrList<Incidence> rel; 3884 //QPtrList<Incidence> rel;
3872 Todo *aTodo;//, *rTodo; 3885 Todo *aTodo;//, *rTodo;
3873 Incidence *rIncidence; 3886 Incidence *rIncidence;
3874 bool childDelete = false; 3887 bool childDelete = false;
3875 bool deletedOne = true; 3888 bool deletedOne = true;
3876 todoCal = calendar()->todos(); 3889 todoCal = calendar()->todos();
3877 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3890 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3878 if ( !aTodo->relatedTo() ) 3891 if ( !aTodo->relatedTo() )
3879 rootTodos.append( aTodo ); 3892 rootTodos.append( aTodo );
3880 } 3893 }
3881 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3894 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3882 removeCompletedSubTodos( aTodo ); 3895 removeCompletedSubTodos( aTodo );
3883 } 3896 }
3884 3897
3885 updateView(); 3898 updateView();
3886 } 3899 }
3887} 3900}
3888 3901
3889void CalendarView::slotCalendarChanged() 3902void CalendarView::slotCalendarChanged()
3890{ 3903{
3891 ; 3904 ;
3892} 3905}
3893 3906
3894void CalendarView::keyPressEvent ( QKeyEvent *e) 3907void CalendarView::keyPressEvent ( QKeyEvent *e)
3895{ 3908{
3896 //qDebug(" alendarView::keyPressEvent "); 3909 //qDebug(" alendarView::keyPressEvent ");
3897 e->ignore(); 3910 e->ignore();
3898} 3911}
3899 3912
3900 3913
3901bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3914bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3902{ 3915{
3903 // mSyncManager = manager; 3916 // mSyncManager = manager;
3904 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3917 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3905 qDebug("KO: SyncKDE request detected!"); 3918 qDebug("KO: SyncKDE request detected!");
3906 } 3919 }
3907 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3920 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3908 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3921 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3909 return syncCalendar( filename, mode ); 3922 return syncCalendar( filename, mode );
3910} 3923}
3911bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3924bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3912{ 3925{
3913 //mSyncManager = manager; 3926 //mSyncManager = manager;
3914 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3927 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3915 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3928 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3916 if ( resource == "sharp" ) 3929 if ( resource == "sharp" )
3917 syncExternal( 0 ); 3930 syncExternal( 0 );
3918 if ( resource == "phone" ) 3931 if ( resource == "phone" )
3919 syncExternal( 1 ); 3932 syncExternal( 1 );
3920 // pending setmodified 3933 // pending setmodified
3921 return true; 3934 return true;
3922} 3935}
3923void CalendarView::setSyncManager(KSyncManager* manager) 3936void CalendarView::setSyncManager(KSyncManager* manager)
3924{ 3937{
3925 mSyncManager = manager; 3938 mSyncManager = manager;
3926} 3939}
3927 3940
3928void CalendarView::removeSyncInfo( QString syncProfile) 3941void CalendarView::removeSyncInfo( QString syncProfile)
3929{ 3942{
3930 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 3943 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
3931 mCalendar->removeSyncInfo( syncProfile ); 3944 mCalendar->removeSyncInfo( syncProfile );
3932 3945
3933} 3946}
3934 3947
3935void CalendarView::undo_delete() 3948void CalendarView::undo_delete()
3936{ 3949{
3937 //qDebug("undo_delete() "); 3950 //qDebug("undo_delete() ");
3938 Incidence* undo = mCalendar->undoIncidence(); 3951 Incidence* undo = mCalendar->undoIncidence();
3939 if ( !undo ) { 3952 if ( !undo ) {
3940 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 3953 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
3941 i18n("KO/Pi")); 3954 i18n("KO/Pi"));
3942 return; 3955 return;
3943 } 3956 }
3944 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 3957 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
3945 i18n("\nAre you sure you want\nto restore this?"), 3958 i18n("\nAre you sure you want\nto restore this?"),
3946 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 3959 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
3947 mCalendar->undoDeleteIncidence(); 3960 mCalendar->undoDeleteIncidence();
3948 updateView(); 3961 updateView();
3949 } 3962 }
3950} 3963}
3951 3964
3952void CalendarView::slotViewerClosed() 3965void CalendarView::slotViewerClosed()
3953{ 3966{
3954 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 3967 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
3955} 3968}
3956 3969
3957void CalendarView::resetFocus() 3970void CalendarView::resetFocus()
3958{ 3971{
3959 if ( mViewerCallerIsSearchDialog ) { 3972 if ( mViewerCallerIsSearchDialog ) {
3960 if ( mDialogManager->getSearchDialog()->isVisible() ){ 3973 if ( mDialogManager->getSearchDialog()->isVisible() ){
3961 mDialogManager->getSearchDialog()->raise(); 3974 mDialogManager->getSearchDialog()->raise();
3962 mDialogManager->getSearchDialog()->setActiveWindow(); 3975 mDialogManager->getSearchDialog()->setActiveWindow();
3963 mDialogManager->getSearchDialog()->listview()->resetFocus(); 3976 mDialogManager->getSearchDialog()->listview()->resetFocus();
3964 } else 3977 } else
3965 mViewerCallerIsSearchDialog = false; 3978 mViewerCallerIsSearchDialog = false;
3966 } 3979 }
3967 if ( !mViewerCallerIsSearchDialog ) { 3980 if ( !mViewerCallerIsSearchDialog ) {
3968 //mViewManager->currentView()->setFocus(); 3981 //mViewManager->currentView()->setFocus();
3969 //qDebug("sssssssssssssssset focus "); 3982 //qDebug("sssssssssssssssset focus ");
3983 topLevelWidget()->raise();
3970 setActiveWindow(); 3984 setActiveWindow();
3971 //setFocus(); 3985 //setFocus();
3972 } 3986 }
3973 mViewerCallerIsSearchDialog = false; 3987 mViewerCallerIsSearchDialog = false;
3974} 3988}
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 195b1fa..ec81d44 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -992,385 +992,408 @@ void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
992 992
993 int x,y; 993 int x,y;
994 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 994 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
995// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 995// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
996 int gx,gy; 996 int gx,gy;
997 contentsToGrid(x,y,gx,gy); 997 contentsToGrid(x,y,gx,gy);
998 998
999 // Change cursor to resize cursor if appropriate 999 // Change cursor to resize cursor if appropriate
1000 if (mAllDayMode) { 1000 if (mAllDayMode) {
1001 int gridDistanceX = (x - gx * mGridSpacingX); 1001 int gridDistanceX = (x - gx * mGridSpacingX);
1002 if (gridDistanceX < mResizeBorderWidth && 1002 if (gridDistanceX < mResizeBorderWidth &&
1003 moveItem->cellX() == gx) { 1003 moveItem->cellX() == gx) {
1004 setCursor(sizeHorCursor); 1004 setCursor(sizeHorCursor);
1005 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 1005 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
1006 moveItem->cellXWidth() == gx) { 1006 moveItem->cellXWidth() == gx) {
1007 setCursor(sizeHorCursor); 1007 setCursor(sizeHorCursor);
1008 } else { 1008 } else {
1009 setCursor(arrowCursor); 1009 setCursor(arrowCursor);
1010 } 1010 }
1011 } else { 1011 } else {
1012 int gridDistanceY = (y - gy * mGridSpacingY); 1012 int gridDistanceY = (y - gy * mGridSpacingY);
1013 if (gridDistanceY < mResizeBorderWidth && 1013 if (gridDistanceY < mResizeBorderWidth &&
1014 moveItem->cellYTop() == gy && 1014 moveItem->cellYTop() == gy &&
1015 !moveItem->firstMultiItem()) { 1015 !moveItem->firstMultiItem()) {
1016 setCursor(sizeVerCursor); 1016 setCursor(sizeVerCursor);
1017 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 1017 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
1018 moveItem->cellYBottom() == gy && 1018 moveItem->cellYBottom() == gy &&
1019 !moveItem->lastMultiItem()) { 1019 !moveItem->lastMultiItem()) {
1020 setCursor(sizeVerCursor); 1020 setCursor(sizeVerCursor);
1021 } else { 1021 } else {
1022 setCursor(arrowCursor); 1022 setCursor(arrowCursor);
1023 } 1023 }
1024 } 1024 }
1025} 1025}
1026 1026
1027 1027
1028/* 1028/*
1029 Place item in cell and take care that multiple items using the same cell do 1029 Place item in cell and take care that multiple items using the same cell do
1030 not overlap. This method is not yet optimal. It doesn´t use the maximum space 1030 not overlap. This method is not yet optimal. It doesn´t use the maximum space
1031 it can get in all cases. 1031 it can get in all cases.
1032 At the moment the method has a bug: When an item is placed only the sub cell 1032 At the moment the method has a bug: When an item is placed only the sub cell
1033 widths of the items are changed, which are within the Y region the item to 1033 widths of the items are changed, which are within the Y region the item to
1034 place spans. When the sub cell width change of one of this items affects a 1034 place spans. When the sub cell width change of one of this items affects a
1035 cell, where other items are, which do not overlap in Y with the item to place, 1035 cell, where other items are, which do not overlap in Y with the item to place,
1036 the display gets corrupted, although the corruption looks quite nice. 1036 the display gets corrupted, although the corruption looks quite nice.
1037*/ 1037*/
1038void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 1038void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1039{ 1039{
1040 1040
1041 QPtrList<KOAgendaItem> conflictItems; 1041 QPtrList<KOAgendaItem> conflictItems;
1042 int maxSubCells = 0; 1042 int maxSubCells = 0;
1043 QIntDict<KOAgendaItem> subCellDict(5); 1043 QIntDict<KOAgendaItem> subCellDict(5);
1044 1044
1045 KOAgendaItem *item; 1045 KOAgendaItem *item;
1046 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1046 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1047 if (item != placeItem) { 1047 if (item != placeItem) {
1048 if (placeItem->cellX() <= item->cellXWidth() && 1048 if (placeItem->cellX() <= item->cellXWidth() &&
1049 placeItem->cellXWidth() >= item->cellX()) { 1049 placeItem->cellXWidth() >= item->cellX()) {
1050 if ((placeItem->cellYTop() <= item->cellYBottom()) && 1050 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
1051 (placeItem->cellYBottom() >= item->cellYTop())) { 1051 (placeItem->cellYBottom() >= item->cellYTop())) {
1052 conflictItems.append(item); 1052 conflictItems.append(item);
1053 if (item->subCells() > maxSubCells) 1053 if (item->subCells() > maxSubCells)
1054 maxSubCells = item->subCells(); 1054 maxSubCells = item->subCells();
1055 subCellDict.insert(item->subCell(),item); 1055 subCellDict.insert(item->subCell(),item);
1056 } 1056 }
1057 } 1057 }
1058 } 1058 }
1059 } 1059 }
1060 1060
1061 if (conflictItems.count() > 0) { 1061 if (conflictItems.count() > 0) {
1062 // Look for unused sub cell and insert item 1062 // Look for unused sub cell and insert item
1063 int i; 1063 int i;
1064 for(i=0;i<maxSubCells;++i) { 1064 for(i=0;i<maxSubCells;++i) {
1065 if (!subCellDict.find(i)) { 1065 if (!subCellDict.find(i)) {
1066 placeItem->setSubCell(i); 1066 placeItem->setSubCell(i);
1067 break; 1067 break;
1068 } 1068 }
1069 } 1069 }
1070 if (i == maxSubCells) { 1070 if (i == maxSubCells) {
1071 placeItem->setSubCell(maxSubCells); 1071 placeItem->setSubCell(maxSubCells);
1072 maxSubCells++; // add new item to number of sub cells 1072 maxSubCells++; // add new item to number of sub cells
1073 } 1073 }
1074 1074
1075 // Prepare for sub cell geometry adjustment 1075 // Prepare for sub cell geometry adjustment
1076 int newSubCellWidth; 1076 int newSubCellWidth;
1077 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1077 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1078 else newSubCellWidth = mGridSpacingX / maxSubCells; 1078 else newSubCellWidth = mGridSpacingX / maxSubCells;
1079 conflictItems.append(placeItem); 1079 conflictItems.append(placeItem);
1080 1080
1081 1081
1082 // Adjust sub cell geometry of all direct conflict items 1082 // Adjust sub cell geometry of all direct conflict items
1083 for ( item=conflictItems.first(); item != 0; 1083 for ( item=conflictItems.first(); item != 0;
1084 item=conflictItems.next() ) { 1084 item=conflictItems.next() ) {
1085 item->setSubCells(maxSubCells); 1085 item->setSubCells(maxSubCells);
1086 if (mAllDayMode) { 1086 if (mAllDayMode) {
1087 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1087 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1088 } else { 1088 } else {
1089 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1089 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1090 } 1090 }
1091 int x,y; 1091 int x,y;
1092 gridToContents(item->cellX(),item->cellYTop(),x,y); 1092 gridToContents(item->cellX(),item->cellYTop(),x,y);
1093 if (mAllDayMode) { 1093 if (mAllDayMode) {
1094 y += item->subCell() * newSubCellWidth; 1094 y += item->subCell() * newSubCellWidth;
1095 } else { 1095 } else {
1096 x += item->subCell() * newSubCellWidth; 1096 x += item->subCell() * newSubCellWidth;
1097 } 1097 }
1098 moveChild(item,x,y); 1098 moveChild(item,x,y);
1099 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1099 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1100 //item->updateItem(); 1100 //item->updateItem();
1101 } 1101 }
1102 // Adjust sub cell geometry of all conflict items of all conflict items 1102 // Adjust sub cell geometry of all conflict items of all conflict items
1103 for ( item=conflictItems.first(); item != 0; 1103 for ( item=conflictItems.first(); item != 0;
1104 item=conflictItems.next() ) { 1104 item=conflictItems.next() ) {
1105 if ( placeItem != item ) { 1105 if ( placeItem != item ) {
1106 KOAgendaItem *item2; 1106 KOAgendaItem *item2;
1107 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1107 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1108 for ( item2=conflictItems2.first(); item2 != 0; 1108 for ( item2=conflictItems2.first(); item2 != 0;
1109 item2=conflictItems2.next() ) { 1109 item2=conflictItems2.next() ) {
1110 if ( item2->subCells() != maxSubCells) { 1110 if ( item2->subCells() != maxSubCells) {
1111 item2->setSubCells(maxSubCells); 1111 item2->setSubCells(maxSubCells);
1112 if (mAllDayMode) { 1112 if (mAllDayMode) {
1113 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1113 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1114 } else { 1114 } else {
1115 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1115 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1116 } 1116 }
1117 int x,y; 1117 int x,y;
1118 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1118 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1119 if (mAllDayMode) { 1119 if (mAllDayMode) {
1120 y += item2->subCell() * newSubCellWidth; 1120 y += item2->subCell() * newSubCellWidth;
1121 } else { 1121 } else {
1122 x += item2->subCell() * newSubCellWidth; 1122 x += item2->subCell() * newSubCellWidth;
1123 } 1123 }
1124 moveChild(item2,x,y); 1124 moveChild(item2,x,y);
1125 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1125 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1126 } 1126 }
1127 } 1127 }
1128 } 1128 }
1129 } 1129 }
1130 } else { 1130 } else {
1131 placeItem->setSubCell(0); 1131 placeItem->setSubCell(0);
1132 placeItem->setSubCells(1); 1132 placeItem->setSubCells(1);
1133 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1133 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1134 else placeItem->resize(mGridSpacingX,placeItem->height()); 1134 else placeItem->resize(mGridSpacingX,placeItem->height());
1135 int x,y; 1135 int x,y;
1136 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1136 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1137 moveChild(placeItem,x,y); 1137 moveChild(placeItem,x,y);
1138 } 1138 }
1139 placeItem->setConflictItems(conflictItems); 1139 placeItem->setConflictItems(conflictItems);
1140 // for ( item=conflictItems.first(); item != 0; 1140 // for ( item=conflictItems.first(); item != 0;
1141// item=conflictItems.next() ) { 1141// item=conflictItems.next() ) {
1142// //item->updateItem(); 1142// //item->updateItem();
1143// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1143// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1144// } 1144// }
1145// placeItem->updateItem(); 1145// placeItem->updateItem();
1146} 1146}
1147 1147
1148void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1148void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1149{ 1149{
1150 if ( globalFlagBlockAgenda ) 1150 if ( globalFlagBlockAgenda )
1151 return; 1151 return;
1152 //qDebug("KOAgenda::drawContents "); 1152 //qDebug("KOAgenda::drawContents ");
1153 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1153 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1154 ;//drawContentsToPainter(); 1154 ;//drawContentsToPainter();
1155 1155
1156 QPaintDevice* pd = p->device(); 1156 QPaintDevice* pd = p->device();
1157 p->end(); 1157 p->end();
1158 int vx, vy; 1158 int vx, vy;
1159 int selectionX = KOGlobals::self()->reverseLayout() ? 1159 int selectionX = KOGlobals::self()->reverseLayout() ?
1160 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1160 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1161 mSelectionCellX * mGridSpacingX; 1161 mSelectionCellX * mGridSpacingX;
1162 contentsToViewport ( cx, cy, vx,vy); 1162 contentsToViewport ( cx, cy, vx,vy);
1163 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1163 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1164 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1164 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1165 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1165 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1166 1166
1167 if ( mSelectionHeight > 0 ) { 1167 if ( mSelectionHeight > 0 ) {
1168 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1168 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1169 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1169 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1170 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1170 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1171 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1171 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1172 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1172 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1173 } 1173 }
1174 } 1174 }
1175 //qDebug("btbl "); 1175 //qDebug("btbl ");
1176 p->begin( pd ); 1176 p->begin( pd );
1177 //qDebug("end "); 1177 //qDebug("end ");
1178} 1178}
1179 1179
1180void KOAgenda::finishUpdate() 1180void KOAgenda::finishUpdate()
1181{ 1181{
1182 1182
1183 KOAgendaItem *item; 1183 KOAgendaItem *item;
1184 globalFlagBlockAgendaItemPaint = 1; 1184 globalFlagBlockAgendaItemPaint = 1;
1185 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems
1186 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1187 if ( !item->checkLayout() ) {
1188 //qDebug(" conflictitem found ");
1189 int newSubCellWidth;
1190 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1191 else newSubCellWidth = mGridSpacingX / item->subCells();
1192
1193 if (mAllDayMode) {
1194 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1195 } else {
1196 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1197 }
1198 int x,y;
1199 gridToContents(item->cellX(),item->cellYTop(),x,y);
1200 if (mAllDayMode) {
1201 y += item->subCell() * newSubCellWidth;
1202 } else {
1203 x += item->subCell() * newSubCellWidth;
1204 }
1205 moveChild(item,x,y);
1206 }
1207 }
1185 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1208 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1186 if ( !item->isVisible() ) 1209 if ( !item->isVisible() )
1187 item->show(); 1210 item->show();
1188 1211
1189 } 1212 }
1190 globalFlagBlockAgendaItemUpdate = 0; 1213 globalFlagBlockAgendaItemUpdate = 0;
1191 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1214 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1192 item->repaintMe( ); 1215 item->repaintMe( );
1193 } 1216 }
1194 globalFlagBlockAgendaItemUpdate = 1; 1217 globalFlagBlockAgendaItemUpdate = 1;
1195 qApp->processEvents(); 1218 qApp->processEvents();
1196 globalFlagBlockAgendaItemPaint = 0; 1219 globalFlagBlockAgendaItemPaint = 0;
1197 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1220 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1198 item->repaint( false ); 1221 item->repaint( false );
1199 } 1222 }
1200 1223
1201} 1224}
1202 1225
1203/* 1226/*
1204 Draw grid in the background of the agenda. 1227 Draw grid in the background of the agenda.
1205*/ 1228*/
1206void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1229void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1207{ 1230{
1208 1231
1209 1232
1210 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1233 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1211 return; 1234 return;
1212 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1235 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1213 return; 1236 return;
1214 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1237 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1215 if ( ch < 1 ) 1238 if ( ch < 1 )
1216 ch = 1; 1239 ch = 1;
1217 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1240 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1218 mPaintPixmap.resize( contentsWidth()+42, ch ); 1241 mPaintPixmap.resize( contentsWidth()+42, ch );
1219 } 1242 }
1220 mCurPixWid = contentsWidth(); 1243 mCurPixWid = contentsWidth();
1221 mCurPixHei = ch; 1244 mCurPixHei = ch;
1222 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { 1245 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) {
1223 mHighlightPixmap.resize( mGridSpacingX-1, ch ); 1246 mHighlightPixmap.resize( mGridSpacingX-1, ch );
1224 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1247 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1225 } 1248 }
1226 mPixPainter.begin( &mPaintPixmap) ; 1249 mPixPainter.begin( &mPaintPixmap) ;
1227 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1250 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1228 QPainter * p ; 1251 QPainter * p ;
1229 if (paint == 0) { 1252 if (paint == 0) {
1230 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1253 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1231 p = &mPixPainter; 1254 p = &mPixPainter;
1232 } 1255 }
1233 else 1256 else
1234 p = paint ; 1257 p = paint ;
1235 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1258 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1236 1259
1237 //--cx;++cw; 1260 //--cx;++cw;
1238 int lGridSpacingY = mGridSpacingY*2; 1261 int lGridSpacingY = mGridSpacingY*2;
1239 int selDay; 1262 int selDay;
1240 if ( !backgroundOnly ) 1263 if ( !backgroundOnly )
1241 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1264 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1242 { 1265 {
1243 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { 1266 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) {
1244 int x1 = cx; 1267 int x1 = cx;
1245 int y1 = 0; 1268 int y1 = 0;
1246 if (y1 < cy) y1 = cy; 1269 if (y1 < cy) y1 = cy;
1247 int x2 = cx+cw-1; 1270 int x2 = cx+cw-1;
1248 int y2 = contentsHeight(); 1271 int y2 = contentsHeight();
1249 if (y2 > cy+ch-1) y2=cy+ch-1; 1272 if (y2 > cy+ch-1) y2=cy+ch-1;
1250 if (x2 >= x1 && y2 >= y1) { 1273 if (x2 >= x1 && y2 >= y1) {
1251 int gxStart = selDay; 1274 int gxStart = selDay;
1252 int gxEnd = gxStart ; 1275 int gxEnd = gxStart ;
1253 int xStart = KOGlobals::self()->reverseLayout() ? 1276 int xStart = KOGlobals::self()->reverseLayout() ?
1254 (mColumns - 1 - gxStart)*mGridSpacingX : 1277 (mColumns - 1 - gxStart)*mGridSpacingX :
1255 gxStart*mGridSpacingX; 1278 gxStart*mGridSpacingX;
1256 if (xStart < x1) xStart = x1; 1279 if (xStart < x1) xStart = x1;
1257 int xEnd = KOGlobals::self()->reverseLayout() ? 1280 int xEnd = KOGlobals::self()->reverseLayout() ?
1258 (mColumns - gxStart)*mGridSpacingX-1 : 1281 (mColumns - gxStart)*mGridSpacingX-1 :
1259 (gxStart+1)*mGridSpacingX-1; 1282 (gxStart+1)*mGridSpacingX-1;
1260 if (xEnd > x2) xEnd = x2; 1283 if (xEnd > x2) xEnd = x2;
1261 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1284 if ( KOPrefs::instance()->mUseHighlightLightColor )
1262 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1285 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1263 KOPrefs::instance()->mAgendaBgColor.light()); 1286 KOPrefs::instance()->mAgendaBgColor.light());
1264 else 1287 else
1265 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1288 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1266 KOPrefs::instance()->mAgendaBgColor.dark()); 1289 KOPrefs::instance()->mAgendaBgColor.dark());
1267 1290
1268 } 1291 }
1269 } 1292 }
1270 } 1293 }
1271 // Highlight working hours 1294 // Highlight working hours
1272 1295
1273 if ( !backgroundOnly ) 1296 if ( !backgroundOnly )
1274 if (mWorkingHoursEnable) { 1297 if (mWorkingHoursEnable) {
1275 int x1 = cx; 1298 int x1 = cx;
1276 int y1 = mWorkingHoursYTop; 1299 int y1 = mWorkingHoursYTop;
1277 if (y1 < cy) y1 = cy; 1300 if (y1 < cy) y1 = cy;
1278 int x2 = cx+cw-1; 1301 int x2 = cx+cw-1;
1279 // int x2 = mGridSpacingX * 5 - 1; 1302 // int x2 = mGridSpacingX * 5 - 1;
1280 // if (x2 > cx+cw-1) x2 = cx + cw - 1; 1303 // if (x2 > cx+cw-1) x2 = cx + cw - 1;
1281 int y2 = mWorkingHoursYBottom; 1304 int y2 = mWorkingHoursYBottom;
1282 if (y2 > cy+ch-1) y2=cy+ch-1; 1305 if (y2 > cy+ch-1) y2=cy+ch-1;
1283 1306
1284 if (x2 >= x1 && y2 >= y1) { 1307 if (x2 >= x1 && y2 >= y1) {
1285 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); 1308 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
1286 int gxStart = x1/mGridSpacingX; 1309 int gxStart = x1/mGridSpacingX;
1287 int gxEnd = x2/mGridSpacingX; 1310 int gxEnd = x2/mGridSpacingX;
1288 while(gxStart <= gxEnd) { 1311 while(gxStart <= gxEnd) {
1289 if (gxStart < int(mHolidayMask->count()) && 1312 if (gxStart < int(mHolidayMask->count()) &&
1290 !mHolidayMask->at(gxStart)) { 1313 !mHolidayMask->at(gxStart)) {
1291 int xStart = KOGlobals::self()->reverseLayout() ? 1314 int xStart = KOGlobals::self()->reverseLayout() ?
1292 (mColumns - 1 - gxStart)*mGridSpacingX : 1315 (mColumns - 1 - gxStart)*mGridSpacingX :
1293 gxStart*mGridSpacingX; 1316 gxStart*mGridSpacingX;
1294 if (xStart < x1) xStart = x1; 1317 if (xStart < x1) xStart = x1;
1295 int xEnd = KOGlobals::self()->reverseLayout() ? 1318 int xEnd = KOGlobals::self()->reverseLayout() ?
1296 (mColumns - gxStart)*mGridSpacingX-1 : 1319 (mColumns - gxStart)*mGridSpacingX-1 :
1297 (gxStart+1)*mGridSpacingX-1; 1320 (gxStart+1)*mGridSpacingX-1;
1298 if (xEnd > x2) xEnd = x2; 1321 if (xEnd > x2) xEnd = x2;
1299 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { 1322 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) {
1300 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1323 if ( KOPrefs::instance()->mUseHighlightLightColor )
1301 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1324 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1302 KOPrefs::instance()->mWorkingHoursColor.light()); 1325 KOPrefs::instance()->mWorkingHoursColor.light());
1303 else 1326 else
1304 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1327 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1305 KOPrefs::instance()->mWorkingHoursColor.dark()); 1328 KOPrefs::instance()->mWorkingHoursColor.dark());
1306 } else { 1329 } else {
1307 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1330 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1308 KOPrefs::instance()->mWorkingHoursColor); 1331 KOPrefs::instance()->mWorkingHoursColor);
1309 } 1332 }
1310 } 1333 }
1311 ++gxStart; 1334 ++gxStart;
1312 } 1335 }
1313 } 1336 }
1314 } 1337 }
1315 /* 1338 /*
1316 int selectionX = KOGlobals::self()->reverseLayout() ? 1339 int selectionX = KOGlobals::self()->reverseLayout() ?
1317 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1340 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1318 mSelectionCellX * mGridSpacingX; 1341 mSelectionCellX * mGridSpacingX;
1319 1342
1320 // Draw selection 1343 // Draw selection
1321 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1344 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1322 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1345 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1323 // TODO: paint only part within cx,cy,cw,ch 1346 // TODO: paint only part within cx,cy,cw,ch
1324 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, 1347 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
1325 mSelectionHeight, KOPrefs::instance()->mHighlightColor ); 1348 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1326 } 1349 }
1327 */ 1350 */
1328 // Draw vertical lines of grid 1351 // Draw vertical lines of grid
1329 1352
1330 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 1353 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1331 if ( mGridSpacingX > 0 ) { 1354 if ( mGridSpacingX > 0 ) {
1332 while (x < cx + cw) { 1355 while (x < cx + cw) {
1333 p->drawLine(x,cy,x,cy+ch); 1356 p->drawLine(x,cy,x,cy+ch);
1334 x+=mGridSpacingX; 1357 x+=mGridSpacingX;
1335 } 1358 }
1336 } 1359 }
1337 // Draw horizontal lines of grid 1360 // Draw horizontal lines of grid
1338 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; 1361 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1339 if ( lGridSpacingY > 0 ) { 1362 if ( lGridSpacingY > 0 ) {
1340 while (y < cy + ch) { 1363 while (y < cy + ch) {
1341 p->setPen( SolidLine ); 1364 p->setPen( SolidLine );
1342 p->drawLine(cx,y,cx+cw,y); 1365 p->drawLine(cx,y,cx+cw,y);
1343 y+=lGridSpacingY; 1366 y+=lGridSpacingY;
1344 p->setPen( DotLine ); 1367 p->setPen( DotLine );
1345 p->drawLine(cx,y,cx+cw,y); 1368 p->drawLine(cx,y,cx+cw,y);
1346 y+=lGridSpacingY; 1369 y+=lGridSpacingY;
1347 } 1370 }
1348 p->setPen( SolidLine ); 1371 p->setPen( SolidLine );
1349 } 1372 }
1350 mPixPainter.end() ; 1373 mPixPainter.end() ;
1351} 1374}
1352 1375
1353/* 1376/*
1354 Convert srcollview contents coordinates to agenda grid coordinates. 1377 Convert srcollview contents coordinates to agenda grid coordinates.
1355*/ 1378*/
1356void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) 1379void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
1357{ 1380{
1358 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : 1381 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
1359 x/mGridSpacingX; 1382 x/mGridSpacingX;
1360 gy = y/mGridSpacingY; 1383 gy = y/mGridSpacingY;
1361} 1384}
1362 1385
1363/* 1386/*
1364 Convert agenda grid coordinates to scrollview contents coordinates. 1387 Convert agenda grid coordinates to scrollview contents coordinates.
1365*/ 1388*/
1366void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) 1389void KOAgenda::gridToContents (int gx, int gy, int& x, int& y)
1367{ 1390{
1368 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: 1391 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX:
1369 gx*mGridSpacingX; 1392 gx*mGridSpacingX;
1370 y = gy*mGridSpacingY; 1393 y = gy*mGridSpacingY;
1371} 1394}
1372 1395
1373 1396
1374/* 1397/*
1375 Return Y coordinate corresponding to time. Coordinates are rounded to fit into 1398 Return Y coordinate corresponding to time. Coordinates are rounded to fit into
1376 the grid. 1399 the grid.
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 38bd93a..042a789 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -575,192 +575,210 @@ void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
575 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 575 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
576 paintMe( mSelected ); 576 paintMe( mSelected );
577 repaint( false ); 577 repaint( false );
578} 578}
579 579
580/* 580/*
581 Return height of item in units of agenda cells 581 Return height of item in units of agenda cells
582*/ 582*/
583int KOAgendaItem::cellHeight() 583int KOAgendaItem::cellHeight()
584{ 584{
585 int ret = mCellYBottom - mCellYTop + 1; 585 int ret = mCellYBottom - mCellYTop + 1;
586 if ( ret <= 0 ) { 586 if ( ret <= 0 ) {
587 ret = 1; 587 ret = 1;
588 mCellYBottom = 0; 588 mCellYBottom = 0;
589 mCellYTop = 0; 589 mCellYTop = 0;
590 } 590 }
591 return ret; 591 return ret;
592} 592}
593 593
594/* 594/*
595 Return height of item in units of agenda cells 595 Return height of item in units of agenda cells
596*/ 596*/
597int KOAgendaItem::cellWidth() 597int KOAgendaItem::cellWidth()
598{ 598{
599 return mCellXWidth - mCellX + 1; 599 return mCellXWidth - mCellX + 1;
600} 600}
601 601
602void KOAgendaItem::setItemDate(QDate qd) 602void KOAgendaItem::setItemDate(QDate qd)
603{ 603{
604 mDate = qd; 604 mDate = qd;
605} 605}
606 606
607void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 607void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
608{ 608{
609 mCellX = X; 609 mCellX = X;
610 mCellYTop = YTop; 610 mCellYTop = YTop;
611 mCellYBottom = YBottom; 611 mCellYBottom = YBottom;
612} 612}
613 613
614void KOAgendaItem::setCellXWidth(int xwidth) 614void KOAgendaItem::setCellXWidth(int xwidth)
615{ 615{
616 mCellXWidth = xwidth; 616 mCellXWidth = xwidth;
617} 617}
618 618
619void KOAgendaItem::setCellX(int XLeft, int XRight) 619void KOAgendaItem::setCellX(int XLeft, int XRight)
620{ 620{
621 mCellX = XLeft; 621 mCellX = XLeft;
622 mCellXWidth = XRight; 622 mCellXWidth = XRight;
623} 623}
624 624
625void KOAgendaItem::setCellY(int YTop, int YBottom) 625void KOAgendaItem::setCellY(int YTop, int YBottom)
626{ 626{
627 mCellYTop = YTop; 627 mCellYTop = YTop;
628 mCellYBottom = YBottom; 628 mCellYBottom = YBottom;
629} 629}
630 630
631void KOAgendaItem::setSubCell(int subCell) 631void KOAgendaItem::setSubCell(int subCell)
632{ 632{
633 mSubCell = subCell; 633 mSubCell = subCell;
634} 634}
635 635
636void KOAgendaItem::setSubCells(int subCells) 636void KOAgendaItem::setSubCells(int subCells)
637{ 637{
638 mSubCells = subCells; 638 mSubCells = subCells;
639} 639}
640 640
641void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 641void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
642 KOAgendaItem *last) 642 KOAgendaItem *last)
643{ 643{
644 mFirstMultiItem = first; 644 mFirstMultiItem = first;
645 mNextMultiItem = next; 645 mNextMultiItem = next;
646 mLastMultiItem = last; 646 mLastMultiItem = last;
647} 647}
648 648
649void KOAgendaItem::startMove() 649void KOAgendaItem::startMove()
650{ 650{
651 mStartCellX = mCellX; 651 mStartCellX = mCellX;
652 mStartCellXWidth = mCellXWidth; 652 mStartCellXWidth = mCellXWidth;
653 mStartCellYTop = mCellYTop; 653 mStartCellYTop = mCellYTop;
654 mStartCellYBottom = mCellYBottom; 654 mStartCellYBottom = mCellYBottom;
655} 655}
656 656
657void KOAgendaItem::resetMove() 657void KOAgendaItem::resetMove()
658{ 658{
659 mCellX = mStartCellX; 659 mCellX = mStartCellX;
660 mCellXWidth = mStartCellXWidth; 660 mCellXWidth = mStartCellXWidth;
661 mCellYTop = mStartCellYTop; 661 mCellYTop = mStartCellYTop;
662 mCellYBottom = mStartCellYBottom; 662 mCellYBottom = mStartCellYBottom;
663} 663}
664 664
665void KOAgendaItem::moveRelative(int dx, int dy) 665void KOAgendaItem::moveRelative(int dx, int dy)
666{ 666{
667 int newX = cellX() + dx; 667 int newX = cellX() + dx;
668 int newXWidth = cellXWidth() + dx; 668 int newXWidth = cellXWidth() + dx;
669 int newYTop = cellYTop() + dy; 669 int newYTop = cellYTop() + dy;
670 int newYBottom = cellYBottom() + dy; 670 int newYBottom = cellYBottom() + dy;
671 setCellXY(newX,newYTop,newYBottom); 671 setCellXY(newX,newYTop,newYBottom);
672 setCellXWidth(newXWidth); 672 setCellXWidth(newXWidth);
673} 673}
674 674
675void KOAgendaItem::expandTop(int dy) 675void KOAgendaItem::expandTop(int dy)
676{ 676{
677 int newYTop = cellYTop() + dy; 677 int newYTop = cellYTop() + dy;
678 int newYBottom = cellYBottom(); 678 int newYBottom = cellYBottom();
679 if (newYTop > newYBottom) newYTop = newYBottom; 679 if (newYTop > newYBottom) newYTop = newYBottom;
680 setCellY(newYTop, newYBottom); 680 setCellY(newYTop, newYBottom);
681} 681}
682 682
683void KOAgendaItem::expandBottom(int dy) 683void KOAgendaItem::expandBottom(int dy)
684{ 684{
685 int newYTop = cellYTop(); 685 int newYTop = cellYTop();
686 int newYBottom = cellYBottom() + dy; 686 int newYBottom = cellYBottom() + dy;
687 if (newYBottom < newYTop) newYBottom = newYTop; 687 if (newYBottom < newYTop) newYBottom = newYTop;
688 setCellY(newYTop, newYBottom); 688 setCellY(newYTop, newYBottom);
689} 689}
690 690
691void KOAgendaItem::expandLeft(int dx) 691void KOAgendaItem::expandLeft(int dx)
692{ 692{
693 int newX = cellX() + dx; 693 int newX = cellX() + dx;
694 int newXWidth = cellXWidth(); 694 int newXWidth = cellXWidth();
695 if (newX > newXWidth) newX = newXWidth; 695 if (newX > newXWidth) newX = newXWidth;
696 setCellX(newX,newXWidth); 696 setCellX(newX,newXWidth);
697} 697}
698 698
699void KOAgendaItem::expandRight(int dx) 699void KOAgendaItem::expandRight(int dx)
700{ 700{
701 int newX = cellX(); 701 int newX = cellX();
702 int newXWidth = cellXWidth() + dx; 702 int newXWidth = cellXWidth() + dx;
703 if (newXWidth < newX) newXWidth = newX; 703 if (newXWidth < newX) newXWidth = newX;
704 setCellX(newX,newXWidth); 704 setCellX(newX,newXWidth);
705} 705}
706 706
707QToolTipGroup *KOAgendaItem::toolTipGroup() 707QToolTipGroup *KOAgendaItem::toolTipGroup()
708{ 708{
709 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 709 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
710 return mToolTipGroup; 710 return mToolTipGroup;
711} 711}
712 712
713void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 713void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
714{ 714{
715#ifndef KORG_NODND 715#ifndef KORG_NODND
716 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || 716 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
717 !QTextDrag::canDecode( e ) ) { 717 !QTextDrag::canDecode( e ) ) {
718 e->ignore(); 718 e->ignore();
719 return; 719 return;
720 } 720 }
721 e->accept(); 721 e->accept();
722#endif 722#endif
723} 723}
724 724
725void KOAgendaItem::dropEvent( QDropEvent *e ) 725void KOAgendaItem::dropEvent( QDropEvent *e )
726{ 726{
727#ifndef KORG_NODND 727#ifndef KORG_NODND
728 QString text; 728 QString text;
729 if(QTextDrag::decode(e,text)) 729 if(QTextDrag::decode(e,text))
730 { 730 {
731 kdDebug() << "Dropped : " << text << endl; 731 kdDebug() << "Dropped : " << text << endl;
732 QStringList emails = QStringList::split(",",text); 732 QStringList emails = QStringList::split(",",text);
733 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 733 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
734 kdDebug() << " Email: " << (*it) << endl; 734 kdDebug() << " Email: " << (*it) << endl;
735 int pos = (*it).find("<"); 735 int pos = (*it).find("<");
736 QString name = (*it).left(pos); 736 QString name = (*it).left(pos);
737 QString email = (*it).mid(pos); 737 QString email = (*it).mid(pos);
738 if (!email.isEmpty()) { 738 if (!email.isEmpty()) {
739 mIncidence->addAttendee(new Attendee(name,email)); 739 mIncidence->addAttendee(new Attendee(name,email));
740 } 740 }
741 } 741 }
742 } 742 }
743#endif 743#endif
744} 744}
745 745
746 746
747QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() 747QPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
748{ 748{
749 return mConflictItems; 749 return mConflictItems;
750} 750}
751 751
752void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) 752void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci)
753{ 753{
754 mConflictItems = ci; 754 mConflictItems = ci;
755 KOAgendaItem *item; 755 KOAgendaItem *item;
756 for ( item=mConflictItems.first(); item != 0; 756 for ( item=mConflictItems.first(); item != 0;
757 item=mConflictItems.next() ) { 757 item=mConflictItems.next() ) {
758 item->addConflictItem(this); 758 item->addConflictItem(this);
759 } 759 }
760} 760}
761 761
762void KOAgendaItem::addConflictItem(KOAgendaItem *ci) 762void KOAgendaItem::addConflictItem(KOAgendaItem *ci)
763{ 763{
764 if (mConflictItems.find(ci)<0) 764 if (mConflictItems.find(ci)<0)
765 mConflictItems.append(ci); 765 mConflictItems.append(ci);
766} 766}
767
768bool KOAgendaItem::checkLayout()
769{
770 if ( !mConflictItems.count() )
771 return true;
772 int max = 0;
773 KOAgendaItem *item;
774 for ( item=mConflictItems.first(); item != 0;
775 item=mConflictItems.next() ) {
776 if ( item->subCells() > max )
777 max = item->subCells();
778 }
779 if ( max > subCells() ) {
780 setSubCells( max );
781 return false;
782 }
783 return true;
784}
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index 5b8f420..b4dba79 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -1,161 +1,162 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19#ifndef KOAGENDAITEM_H 19#ifndef KOAGENDAITEM_H
20#define KOAGENDAITEM_H 20#define KOAGENDAITEM_H
21 21
22#include <qframe.h> 22#include <qframe.h>
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qpalette.h> 26#include <qpalette.h>
27 27
28#include <libkcal/incidence.h> 28#include <libkcal/incidence.h>
29 29
30class QToolTipGroup; 30class QToolTipGroup;
31class QDragEnterEvent; 31class QDragEnterEvent;
32class QDropEvent; 32class QDropEvent;
33 33
34using namespace KCal; 34using namespace KCal;
35 35
36/* 36/*
37 The KOAgendaItem has to make sure that it receives all mouse events, which are 37 The KOAgendaItem has to make sure that it receives all mouse events, which are
38 to be used for dragging and resizing. That means it has to be installed as 38 to be used for dragging and resizing. That means it has to be installed as
39 eventfiler for its children, if it has children, and it has to pass mouse 39 eventfiler for its children, if it has children, and it has to pass mouse
40 events from the cildren to itself. See eventFilter(). 40 events from the cildren to itself. See eventFilter().
41*/ 41*/
42class KOAgendaItem : public QWidget 42class KOAgendaItem : public QWidget
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 public: 45 public:
46 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, 46 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0,
47 WFlags f=0 ); 47 WFlags f=0 );
48 ~KOAgendaItem(); 48 ~KOAgendaItem();
49 QString getWhatsThisText(); 49 QString getWhatsThisText();
50 void init ( Incidence *incidence, QDate qd ); 50 void init ( Incidence *incidence, QDate qd );
51 int cellX() { return mCellX; } 51 int cellX() { return mCellX; }
52 int cellXWidth() { return mCellXWidth; } 52 int cellXWidth() { return mCellXWidth; }
53 int cellYTop() { return mCellYTop; } 53 int cellYTop() { return mCellYTop; }
54 int cellYBottom() { return mCellYBottom; } 54 int cellYBottom() { return mCellYBottom; }
55 int cellHeight(); 55 int cellHeight();
56 int cellWidth(); 56 int cellWidth();
57 int subCell() { return mSubCell; } 57 int subCell() { return mSubCell; }
58 int subCells() { return mSubCells; } 58 int subCells() { return mSubCells; }
59 59
60 void setCellXY(int X, int YTop, int YBottom); 60 void setCellXY(int X, int YTop, int YBottom);
61 void setCellY(int YTop, int YBottom); 61 void setCellY(int YTop, int YBottom);
62 void setCellX(int XLeft, int XRight); 62 void setCellX(int XLeft, int XRight);
63 void setCellXWidth(int xwidth); 63 void setCellXWidth(int xwidth);
64 void setSubCell(int subCell); 64 void setSubCell(int subCell);
65 void setSubCells(int subCells); 65 void setSubCells(int subCells);
66 66
67 /** Start movement */ 67 /** Start movement */
68 void startMove(); 68 void startMove();
69 /** Reset to original values */ 69 /** Reset to original values */
70 void resetMove(); 70 void resetMove();
71 71
72 void moveRelative(int dx,int dy); 72 void moveRelative(int dx,int dy);
73 void expandTop(int dy); 73 void expandTop(int dy);
74 void expandBottom(int dy); 74 void expandBottom(int dy);
75 void expandLeft(int dx); 75 void expandLeft(int dx);
76 void expandRight(int dx); 76 void expandRight(int dx);
77 int mLastMoveXPos; 77 int mLastMoveXPos;
78 78
79 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 79 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
80 KOAgendaItem *last); 80 KOAgendaItem *last);
81 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } 81 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; }
82 KOAgendaItem *nextMultiItem() { return mNextMultiItem; } 82 KOAgendaItem *nextMultiItem() { return mNextMultiItem; }
83 KOAgendaItem *lastMultiItem() { return mLastMultiItem; } 83 KOAgendaItem *lastMultiItem() { return mLastMultiItem; }
84 84
85 Incidence *incidence() const { return mIncidence; } 85 Incidence *incidence() const { return mIncidence; }
86 QDate itemDate() { return mDate; } 86 QDate itemDate() { return mDate; }
87 87
88 /** Update the date of this item's occurence (not in the event) */ 88 /** Update the date of this item's occurence (not in the event) */
89 void setItemDate(QDate qd); 89 void setItemDate(QDate qd);
90 90
91 void setText ( const QString & text ) { mDisplayedText = text; } 91 void setText ( const QString & text ) { mDisplayedText = text; }
92 QString text () { return mDisplayedText; } 92 QString text () { return mDisplayedText; }
93 93
94 virtual bool eventFilter ( QObject *, QEvent * ); 94 virtual bool eventFilter ( QObject *, QEvent * );
95 95
96 static QToolTipGroup *toolTipGroup(); 96 static QToolTipGroup *toolTipGroup();
97 97
98 QPtrList<KOAgendaItem> conflictItems(); 98 QPtrList<KOAgendaItem> conflictItems();
99 void setConflictItems(QPtrList<KOAgendaItem>); 99 void setConflictItems(QPtrList<KOAgendaItem>);
100 void addConflictItem(KOAgendaItem *ci); 100 void addConflictItem(KOAgendaItem *ci);
101 void paintMe( bool, QPainter* painter = 0 ); 101 void paintMe( bool, QPainter* painter = 0 );
102 void repaintMe(); 102 void repaintMe();
103 static void resizePixmap( int, int ); 103 static void resizePixmap( int, int );
104 static QPixmap * paintPix(); 104 static QPixmap * paintPix();
105 static QPixmap * paintPixSel(); 105 static QPixmap * paintPixSel();
106 static QPixmap * paintPixAllday(); 106 static QPixmap * paintPixAllday();
107 void updateItem(); 107 void updateItem();
108 void computeText(); 108 void computeText();
109 void recreateIncidence(); 109 void recreateIncidence();
110 bool checkLayout();
110 public slots: 111 public slots:
111 bool updateIcons( QPainter *, bool ); 112 bool updateIcons( QPainter *, bool );
112 void select(bool=true); 113 void select(bool=true);
113 114
114 protected: 115 protected:
115 void dragEnterEvent(QDragEnterEvent *e); 116 void dragEnterEvent(QDragEnterEvent *e);
116 void dropEvent(QDropEvent *e); 117 void dropEvent(QDropEvent *e);
117 void paintEvent ( QPaintEvent * ); 118 void paintEvent ( QPaintEvent * );
118 void resizeEvent ( QResizeEvent *ev ); 119 void resizeEvent ( QResizeEvent *ev );
119 120
120 private: 121 private:
121 bool mAllDay; 122 bool mAllDay;
122 int mCellX; 123 int mCellX;
123 int mCellXWidth; 124 int mCellXWidth;
124 int mCellYTop,mCellYBottom; 125 int mCellYTop,mCellYBottom;
125 int mSubCell; // subcell number of this item 126 int mSubCell; // subcell number of this item
126 int mSubCells; // Total number of subcells in cell of this item 127 int mSubCells; // Total number of subcells in cell of this item
127 int xPaintCoord; 128 int xPaintCoord;
128 int yPaintCoord; 129 int yPaintCoord;
129 int wPaintCoord; 130 int wPaintCoord;
130 int hPaintCoord; 131 int hPaintCoord;
131 // Variables to remember start position 132 // Variables to remember start position
132 int mStartCellX; 133 int mStartCellX;
133 int mStartCellXWidth; 134 int mStartCellXWidth;
134 int mStartCellYTop,mStartCellYBottom; 135 int mStartCellYTop,mStartCellYBottom;
135 int mLastMovePos; 136 int mLastMovePos;
136 137
137 // Multi item pointers 138 // Multi item pointers
138 KOAgendaItem *mFirstMultiItem; 139 KOAgendaItem *mFirstMultiItem;
139 KOAgendaItem *mNextMultiItem; 140 KOAgendaItem *mNextMultiItem;
140 KOAgendaItem *mLastMultiItem; 141 KOAgendaItem *mLastMultiItem;
141 142
142 int mFontPixelSize; 143 int mFontPixelSize;
143 Incidence *mIncidence; // corresponding event or todo 144 Incidence *mIncidence; // corresponding event or todo
144 QDate mDate; //date this events occurs (for recurrence) 145 QDate mDate; //date this events occurs (for recurrence)
145 //void showIcon( QLabel*, int ); 146 //void showIcon( QLabel*, int );
146 //QLabel *mTodoIconLabel; 147 //QLabel *mTodoIconLabel;
147 //QLabel *mItemLabel; 148 //QLabel *mItemLabel;
148 //QWidget *mIconBox; 149 //QWidget *mIconBox;
149 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; 150 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
150 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; 151 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
151 //QLabel *mIconMoreInfo; 152 //QLabel *mIconMoreInfo;
152 static QToolTipGroup *mToolTipGroup; 153 static QToolTipGroup *mToolTipGroup;
153 154
154 QColor mBackgroundColor; 155 QColor mBackgroundColor;
155 QColorGroup mColorGroup; 156 QColorGroup mColorGroup;
156 QString mDisplayedText; 157 QString mDisplayedText;
157 bool mSelected; 158 bool mSelected;
158 QPtrList<KOAgendaItem> mConflictItems; 159 QPtrList<KOAgendaItem> mConflictItems;
159}; 160};
160 161
161#endif // KOAGENDAITEM_H 162#endif // KOAGENDAITEM_H
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp
index 8bada3b..e2c8e6e 100644
--- a/korganizer/koeventviewerdialog.cpp
+++ b/korganizer/koeventviewerdialog.cpp
@@ -1,283 +1,292 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <klocale.h> 20#include <klocale.h>
21 21
22#include <libkcal/event.h> 22#include <libkcal/event.h>
23#include <qtimer.h> 23#include <qtimer.h>
24#include <qpushbutton.h> 24#include <qpushbutton.h>
25 25
26#include "koeventviewer.h" 26#include "koeventviewer.h"
27#include "koprefs.h" 27#include "koprefs.h"
28#include <libkcal/todo.h> 28#include <libkcal/todo.h>
29#include "qapp.h" 29#include "qapp.h"
30 30
31#include "koeventviewerdialog.h" 31#include "koeventviewerdialog.h"
32extern int globalFlagBlockAgenda; 32extern int globalFlagBlockAgenda;
33 33
34KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) 34KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name)
35 : KDialogBase(parent,name, 35 : KDialogBase(parent,name,
36#ifndef DESKTOP_VERSION 36#ifndef DESKTOP_VERSION
37 true , 37 true ,
38#else 38#else
39 false, 39 false,
40#endif 40#endif
41 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) 41 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda"))
42{ 42{
43 sendSignalViewerClosed = true; 43 sendSignalViewerClosed = true;
44 mEventViewer = new KOEventViewer(this); 44 mEventViewer = new KOEventViewer(this);
45 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 45 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
46 setMainWidget(mEventViewer); 46 setMainWidget(mEventViewer);
47 setButtonText(Ok, i18n("Edit") ); 47 setButtonText(Ok, i18n("Edit") );
48 48
49 QObject::connect(findButton( Ok ),SIGNAL(clicked()), 49 QObject::connect(findButton( Ok ),SIGNAL(clicked()),
50 SLOT(editIncidence())); 50 SLOT(editIncidence()));
51 QObject::connect(this,SIGNAL(user1Clicked()), 51 QObject::connect(this,SIGNAL(user1Clicked()),
52 SLOT(showIncidence())); 52 SLOT(showIncidence()));
53 mIncidence = 0; 53 mIncidence = 0;
54 // TODO: Set a sensible size (based on the content?). 54 // TODO: Set a sensible size (based on the content?).
55 //showMaximized(); 55 //showMaximized();
56 //qDebug("++++++++++++KOEventViewerDialog() "); 56 //qDebug("++++++++++++KOEventViewerDialog() ");
57 // if ( KOPrefs::instance()->mCompactDialogs ) { 57 // if ( KOPrefs::instance()->mCompactDialogs ) {
58// setFixedSize( 240,284 ); 58// setFixedSize( 240,284 );
59// move( 0, 15 ); 59// move( 0, 15 );
60// } else { 60// } else {
61// setMinimumSize(300,200); 61// setMinimumSize(300,200);
62// resize(320,300); 62// resize(320,300);
63// } 63// }
64 mSyncMode = false; 64 mSyncMode = false;
65 mSyncResult = 0; 65 mSyncResult = 0;
66 66
67} 67}
68 68
69KOEventViewerDialog::~KOEventViewerDialog() 69KOEventViewerDialog::~KOEventViewerDialog()
70{ 70{
71 //qDebug("-------~KOEventViewerDialog() "); 71 //qDebug("-------~KOEventViewerDialog() ");
72} 72}
73void KOEventViewerDialog::showMe() 73void KOEventViewerDialog::showMe()
74{ 74{
75 75
76#ifdef DESKTOP_VERSION 76#ifdef DESKTOP_VERSION
77 int x,y,w,h;
78 x = geometry().x();
79 y = geometry().y();
80 w = width();
81 h = height();
77 show(); 82 show();
83 setGeometry(x,y,w,h);
78#else 84#else
79 showMaximized(); 85 showMaximized();
80#endif 86#endif
87 raise();
81 setActiveWindow(); 88 setActiveWindow();
82 mEventViewer->setFocus(); 89 mEventViewer->setFocus();
83 90
84} 91}
85void KOEventViewerDialog::setSyncMode( bool b ) 92void KOEventViewerDialog::setSyncMode( bool b )
86{ 93{
87 mSyncMode = b; 94 mSyncMode = b;
88 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); 95 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode );
89 if ( mSyncMode ) { 96 if ( mSyncMode ) {
90 findButton( Close )->setText( i18n("Cancel Sync")); 97 findButton( Close )->setText( i18n("Cancel Sync"));
91 findButton( Ok )->setText( i18n("Remote")); 98 findButton( Ok )->setText( i18n("Remote"));
92 findButton( User1 )->setText( i18n("Local")); 99 findButton( User1 )->setText( i18n("Local"));
93 } else { 100 } else {
94 findButton( Close )->setText( i18n("Close")); 101 findButton( Close )->setText( i18n("Close"));
95 findButton( Ok )->setText( i18n("Edit")); 102 findButton( Ok )->setText( i18n("Edit"));
96 findButton( User1 )->setText( i18n("Agenda")); 103 findButton( User1 )->setText( i18n("Agenda"));
97 } 104 }
98 mEventViewer->setSyncMode( b ); 105 mEventViewer->setSyncMode( b );
99} 106}
100void KOEventViewerDialog::setColorMode( int m ) 107void KOEventViewerDialog::setColorMode( int m )
101{ 108{
102 mEventViewer->setColorMode( m ); 109 mEventViewer->setColorMode( m );
103} 110}
104int KOEventViewerDialog::executeS( bool local ) 111int KOEventViewerDialog::executeS( bool local )
105{ 112{
106 mSyncResult = 3; 113 mSyncResult = 3;
107 if ( local ) 114 if ( local )
108 findButton( User1 )->setFocus(); 115 findButton( User1 )->setFocus();
109 else 116 else
110 findButton( Ok )->setFocus(); 117 findButton( Ok )->setFocus();
111 exec(); 118 exec();
112 return mSyncResult; 119 return mSyncResult;
113} 120}
114 121
115void KOEventViewerDialog::updateConfig() 122void KOEventViewerDialog::updateConfig()
116{ 123{
117 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 124 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
118 125
119} 126}
120void KOEventViewerDialog::setEvent(Event *event) 127void KOEventViewerDialog::setEvent(Event *event)
121{ 128{
122 mEventViewer->setEvent(event); 129 mEventViewer->setEvent(event);
123 mIncidence = event; 130 mIncidence = event;
124 mEventViewer->setFocus(); 131 mEventViewer->setFocus();
125 //findButton( Close )->setFocus(); 132 //findButton( Close )->setFocus();
126 if ( !mSyncMode ) { 133 if ( !mSyncMode ) {
127 findButton( User1 )->setText( i18n("Agenda")); 134 findButton( User1 )->setText( i18n("Agenda"));
128 } 135 }
129} 136}
130void KOEventViewerDialog::setIncidence(Incidence *in ) 137void KOEventViewerDialog::setIncidence(Incidence *in )
131{ 138{
132 if ( in->type() == "Event" ) 139 if ( in->type() == "Event" )
133 setEvent( (Event*) in ); 140 setEvent( (Event*) in );
134 else if ( in->type() =="Todo" ) 141 else if ( in->type() =="Todo" )
135 setTodo( (Todo*) in ); 142 setTodo( (Todo*) in );
136 else if ( in->type() =="Journal" ) 143 else if ( in->type() =="Journal" )
137 setJournal( (Journal*) in ); 144 setJournal( (Journal*) in );
138} 145}
139void KOEventViewerDialog::addIncidence(Incidence *in) 146void KOEventViewerDialog::addIncidence(Incidence *in)
140{ 147{
141 if ( in->type() == "Event" ) 148 if ( in->type() == "Event" )
142 addEvent( (Event*) in ); 149 addEvent( (Event*) in );
143 else if ( in->type() =="Todo" ) 150 else if ( in->type() =="Todo" )
144 mEventViewer->setTodo( (Todo*) in, false ); 151 mEventViewer->setTodo( (Todo*) in, false );
145 else if ( in->type() =="Journal" ) 152 else if ( in->type() =="Journal" )
146 mEventViewer->setJournal( (Journal*) in, false ); 153 mEventViewer->setJournal( (Journal*) in, false );
147 if ( mSyncMode ) { 154 if ( mSyncMode ) {
148 findButton( User1 )->setFocus(); 155 findButton( User1 )->setFocus();
149 setCaption(i18n("Conflict! Please choose entry")); 156 setCaption(i18n("Conflict! Please choose entry"));
150 } 157 }
151} 158}
152 159
153void KOEventViewerDialog::addEvent(Event *event) 160void KOEventViewerDialog::addEvent(Event *event)
154{ 161{
155 mEventViewer->addEvent(event); 162 mEventViewer->addEvent(event);
156 mIncidence = event; 163 mIncidence = event;
157 mEventViewer->setFocus(); 164 mEventViewer->setFocus();
158 //findButton( Close )->setFocus(); 165 //findButton( Close )->setFocus();
159 if ( !mSyncMode ) { 166 if ( !mSyncMode ) {
160 findButton( User1 )->setText( i18n("Agenda")); 167 findButton( User1 )->setText( i18n("Agenda"));
161 } 168 }
162} 169}
163 170
164void KOEventViewerDialog::setTodo(Todo *event) 171void KOEventViewerDialog::setTodo(Todo *event)
165{ 172{
166 mEventViewer->setTodo(event); 173 mEventViewer->setTodo(event);
167 mIncidence = (Incidence*)event; 174 mIncidence = (Incidence*)event;
168 mEventViewer->setFocus(); 175 mEventViewer->setFocus();
169 //findButton( Close )->setFocus(); 176 //findButton( Close )->setFocus();
170 if ( !mSyncMode ) { 177 if ( !mSyncMode ) {
171 findButton( User1 )->setText( i18n("Set complete")); 178 findButton( User1 )->setText( i18n("Set complete"));
172 } 179 }
173} 180}
174void KOEventViewerDialog::setJournal(Journal *j) 181void KOEventViewerDialog::setJournal(Journal *j)
175{ 182{
176 mEventViewer->setJournal(j); 183 mEventViewer->setJournal(j);
177 mIncidence = (Incidence*)j; 184 mIncidence = (Incidence*)j;
178 mEventViewer->setFocus(); 185 mEventViewer->setFocus();
179 //findButton( Close )->setFocus(); 186 //findButton( Close )->setFocus();
180 if ( !mSyncMode ) { 187 if ( !mSyncMode ) {
181 findButton( User1 )->setText( i18n("Agenda")); 188 findButton( User1 )->setText( i18n("Agenda"));
182 } 189 }
183} 190}
184 191
185void KOEventViewerDialog::addText(QString text) 192void KOEventViewerDialog::addText(QString text)
186{ 193{
187 mEventViewer->addText(text); 194 mEventViewer->addText(text);
188 mEventViewer->setFocus(); 195 mEventViewer->setFocus();
189 //findButton( Close )->setFocus(); 196 //findButton( Close )->setFocus();
190} 197}
191void KOEventViewerDialog::editIncidence() 198void KOEventViewerDialog::editIncidence()
192{ 199{
193 sendSignalViewerClosed = false; 200 sendSignalViewerClosed = false;
194 if ( mSyncMode ) { 201 if ( mSyncMode ) {
195 mSyncResult = 2; 202 mSyncResult = 2;
196 accept(); 203 accept();
197 return; 204 return;
198 } 205 }
199 if ( mIncidence ){ 206 if ( mIncidence ){
200#ifndef DESKTOP_VERSION 207#ifndef DESKTOP_VERSION
201 hide(); 208 hide();
202#endif 209#endif
203 emit editIncidence( mIncidence ); 210 emit editIncidence( mIncidence );
204 } 211 }
205} 212}
206void KOEventViewerDialog::showIncidence() 213void KOEventViewerDialog::showIncidence()
207{ 214{
208 sendSignalViewerClosed = false; 215 sendSignalViewerClosed = false;
209 if ( mSyncMode ) { 216 if ( mSyncMode ) {
210 mSyncResult = 1; 217 mSyncResult = 1;
211 accept(); 218 accept();
212 return; 219 return;
213 } 220 }
214 221
215 if ( mIncidence ){ 222 if ( mIncidence ){
216#ifndef DESKTOP_VERSION 223#ifndef DESKTOP_VERSION
217 hide(); 224 hide();
218#endif 225#endif
219 QDate date; 226 QDate date;
220 if ( mIncidence->type() == "Todo" ) { 227 if ( mIncidence->type() == "Todo" ) {
221 /* 228 /*
222 if ( ((Todo*)mIncidence)->hasDueDate() ) 229 if ( ((Todo*)mIncidence)->hasDueDate() )
223 date = ((Todo*)mIncidence)->dtDue().date(); 230 date = ((Todo*)mIncidence)->dtDue().date();
224 else { 231 else {
225 globalFlagBlockAgenda = 2; 232 globalFlagBlockAgenda = 2;
226 emit showAgendaView( false ); 233 emit showAgendaView( false );
227 return; 234 return;
228 } 235 }
229 */ 236 */
230 ((Todo*)mIncidence)->setCompleted( true ); 237 ((Todo*)mIncidence)->setCompleted( true );
231 ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); 238 ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() );
232 hide(); 239 hide();
233 emit todoCompleted(((Todo*)mIncidence)); 240 emit todoCompleted(((Todo*)mIncidence));
234 return; 241 return;
235 242
236 } else 243 } else
237 date = mIncidence->dtStart().date(); 244 date = mIncidence->dtStart().date();
238 globalFlagBlockAgenda = 1; 245 globalFlagBlockAgenda = 1;
239 emit showAgendaView( false ); 246 emit showAgendaView( false );
240 globalFlagBlockAgenda = 2; 247 globalFlagBlockAgenda = 2;
241 emit jumpToTime( date ); 248 emit jumpToTime( date );
242 } 249 }
243} 250}
244void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) 251void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e )
245{ 252{
246 switch ( e->key() ) { 253 switch ( e->key() ) {
247 254
248 case Qt::Key_A : 255 case Qt::Key_A :
249 case Qt::Key_L : 256 case Qt::Key_L :
250 showIncidence(); 257 showIncidence();
251 break; 258 break;
252 case Qt::Key_E : 259 case Qt::Key_E :
253 case Qt::Key_R : 260 case Qt::Key_R :
254 editIncidence(); 261 editIncidence();
255 break; 262 break;
256 case Qt::Key_C: 263 case Qt::Key_C:
257 case Qt::Key_Escape: 264 case Qt::Key_Escape:
258 close(); 265 close();
259 break; 266 break;
260 case Qt::Key_I: 267 case Qt::Key_I:
261 accept(); 268 sendSignalViewerClosed = true;
269 slotViewerClosed();
270 //accept();
262 break; 271 break;
263 default: 272 default:
264 KDialogBase::keyPressEvent ( e ); 273 KDialogBase::keyPressEvent ( e );
265 break; 274 break;
266 } 275 }
267 276
268} 277}
269void KOEventViewerDialog::hideEvent ( QHideEvent * e ) 278void KOEventViewerDialog::hideEvent ( QHideEvent * e )
270{ 279{
271 KDialogBase::hideEvent ( e ); 280 KDialogBase::hideEvent ( e );
272 QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); 281 QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) );
273} 282}
274 283
275void KOEventViewerDialog::slotViewerClosed() 284void KOEventViewerDialog::slotViewerClosed()
276{ 285{
277 if ( sendSignalViewerClosed ) { 286 if ( sendSignalViewerClosed ) {
278 //qDebug("KOEventViewerDialog::hideEvent "); 287 //qDebug("KOEventViewerDialog::hideEvent ");
279 emit signalViewerClosed(); 288 emit signalViewerClosed();
280 } 289 }
281 sendSignalViewerClosed = true; 290 sendSignalViewerClosed = true;
282} 291}
283 292