summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
authorzautrix <zautrix>2004-07-03 16:49:55 (UTC)
committer zautrix <zautrix>2004-07-03 16:49:55 (UTC)
commit1da48d95d970233f0d1ea9a7fba5c98cfcf24798 (patch) (unidiff)
treeae690b33cbe50291a610842e24de33f9d766f2f2 /korganizer/calendarview.cpp
parente3b89230f065c48c84b48c88edb6eb088374c487 (diff)
downloadkdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.zip
kdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.tar.gz
kdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.tar.bz2
Alarm Bugfix. Added connection to KM. Cleaned up main.
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index bf98ad4..c3c3d47 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -410,135 +410,142 @@ void CalendarView::init()
410 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 410 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
411 this, SLOT ( moveIncidence( Incidence * ) ) ); 411 this, SLOT ( moveIncidence( Incidence * ) ) );
412 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 412 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
413 this, SLOT ( beamIncidence( Incidence * ) ) ); 413 this, SLOT ( beamIncidence( Incidence * ) ) );
414 414
415 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 415 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
416 this, SLOT ( todo_unsub( Todo * ) ) ); 416 this, SLOT ( todo_unsub( Todo * ) ) );
417 417
418 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 418 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
419 SLOT( updateTodo( Todo *, int ) ) ); 419 SLOT( updateTodo( Todo *, int ) ) );
420 connect( this, SIGNAL( todoModified( Todo *, int )), this, 420 connect( this, SIGNAL( todoModified( Todo *, int )), this,
421 SLOT( changeTodoDisplay( Todo *, int ) ) ); 421 SLOT( changeTodoDisplay( Todo *, int ) ) );
422 422
423 423
424 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 424 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
425 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 425 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
426 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 426 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
427 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 427 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
428 428
429 429
430 430
431 431
432 432
433 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 433 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
434 SLOT(checkClipboard())); 434 SLOT(checkClipboard()));
435 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 435 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
436 SLOT( processTodoListSelection( Incidence * ) ) ); 436 SLOT( processTodoListSelection( Incidence * ) ) );
437 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 437 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
438 438
439 // kdDebug() << "CalendarView::CalendarView() done" << endl; 439 // kdDebug() << "CalendarView::CalendarView() done" << endl;
440 440
441 mDateFrame = new QVBox(0,0,WType_Popup); 441 mDateFrame = new QVBox(0,0,WType_Popup);
442 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 442 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
443 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 443 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
444 mDateFrame->setLineWidth(3); 444 mDateFrame->setLineWidth(3);
445 mDateFrame->hide(); 445 mDateFrame->hide();
446 mDateFrame->setCaption( i18n( "Pick a date to display")); 446 mDateFrame->setCaption( i18n( "Pick a date to display"));
447 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 447 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
448 448
449 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 449 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
450 450
451 mEventEditor = mDialogManager->getEventEditor(); 451 mEventEditor = mDialogManager->getEventEditor();
452 mTodoEditor = mDialogManager->getTodoEditor(); 452 mTodoEditor = mDialogManager->getTodoEditor();
453 453
454 mFlagEditDescription = false; 454 mFlagEditDescription = false;
455 455
456 mSuspendTimer = new QTimer( this ); 456 mSuspendTimer = new QTimer( this );
457 mAlarmTimer = new QTimer( this ); 457 mAlarmTimer = new QTimer( this );
458 mRecheckAlarmTimer = new QTimer( this );
459 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
458 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 460 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
459 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 461 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
460 mAlarmDialog = new AlarmDialog( this ); 462 mAlarmDialog = new AlarmDialog( this );
461 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 463 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
462 mAlarmDialog->setServerNotification( false ); 464 mAlarmDialog->setServerNotification( false );
463 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 465 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
464} 466}
465 467
466 468
467CalendarView::~CalendarView() 469CalendarView::~CalendarView()
468{ 470{
469 // kdDebug() << "~CalendarView()" << endl; 471 // kdDebug() << "~CalendarView()" << endl;
470 //qDebug("CalendarView::~CalendarView() "); 472 //qDebug("CalendarView::~CalendarView() ");
471 delete mDialogManager; 473 delete mDialogManager;
472 delete mViewManager; 474 delete mViewManager;
473 delete mStorage; 475 delete mStorage;
474 delete mDateFrame ; 476 delete mDateFrame ;
475 delete beamDialog; 477 delete beamDialog;
476 //kdDebug() << "~CalendarView() done" << endl; 478 //kdDebug() << "~CalendarView() done" << endl;
477} 479}
478void CalendarView::timerAlarm() 480void CalendarView::timerAlarm()
479{ 481{
480 //qDebug("CalendarView::timerAlarm() "); 482 //qDebug("CalendarView::timerAlarm() ");
481 computeAlarm(mAlarmNotification ); 483 computeAlarm(mAlarmNotification );
482} 484}
483 485
484void CalendarView::suspendAlarm() 486void CalendarView::suspendAlarm()
485{ 487{
486 //qDebug(" CalendarView::suspendAlarm() "); 488 //qDebug(" CalendarView::suspendAlarm() ");
487 computeAlarm(mSuspendAlarmNotification ); 489 computeAlarm(mSuspendAlarmNotification );
488 490
489} 491}
490 492
491void CalendarView::startAlarm( QString mess , QString filename) 493void CalendarView::startAlarm( QString mess , QString filename)
492{ 494{
493 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 495 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
496 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
494 497
495} 498}
496 499
500void CalendarView::checkNextTimerAlarm()
501{
502 mCalendar->checkAlarmForIncidence( 0, true );
503}
497 504
498void CalendarView::computeAlarm( QString msg ) 505void CalendarView::computeAlarm( QString msg )
499{ 506{
500 507
501 QString mess = msg; 508 QString mess = msg;
502 QString mAlarmMessage = mess.mid( 9 ); 509 QString mAlarmMessage = mess.mid( 9 );
503 QString filename = MainWindow::resourcePath(); 510 QString filename = MainWindow::resourcePath();
504 filename += "koalarm.wav"; 511 filename += "koalarm.wav";
505 QString tempfilename; 512 QString tempfilename;
506 if ( mess.left( 13 ) == "suspend_alarm") { 513 if ( mess.left( 13 ) == "suspend_alarm") {
507 bool error = false; 514 bool error = false;
508 int len = mess.mid( 13 ).find("+++"); 515 int len = mess.mid( 13 ).find("+++");
509 if ( len < 2 ) 516 if ( len < 2 )
510 error = true; 517 error = true;
511 else { 518 else {
512 tempfilename = mess.mid( 13, len ); 519 tempfilename = mess.mid( 13, len );
513 if ( !QFile::exists( tempfilename ) ) 520 if ( !QFile::exists( tempfilename ) )
514 error = true; 521 error = true;
515 } 522 }
516 if ( ! error ) { 523 if ( ! error ) {
517 filename = tempfilename; 524 filename = tempfilename;
518 } 525 }
519 mAlarmMessage = mess.mid( 13+len+3 ); 526 mAlarmMessage = mess.mid( 13+len+3 );
520 //qDebug("suspend file %s ",tempfilename.latin1() ); 527 //qDebug("suspend file %s ",tempfilename.latin1() );
521 startAlarm( mAlarmMessage, filename); 528 startAlarm( mAlarmMessage, filename);
522 return; 529 return;
523 } 530 }
524 if ( mess.left( 11 ) == "timer_alarm") { 531 if ( mess.left( 11 ) == "timer_alarm") {
525 //mTimerTime = 0; 532 //mTimerTime = 0;
526 startAlarm( mess.mid( 11 ), filename ); 533 startAlarm( mess.mid( 11 ), filename );
527 return; 534 return;
528 } 535 }
529 if ( mess.left( 10 ) == "proc_alarm") { 536 if ( mess.left( 10 ) == "proc_alarm") {
530 bool error = false; 537 bool error = false;
531 int len = mess.mid( 10 ).find("+++"); 538 int len = mess.mid( 10 ).find("+++");
532 if ( len < 2 ) 539 if ( len < 2 )
533 error = true; 540 error = true;
534 else { 541 else {
535 tempfilename = mess.mid( 10, len ); 542 tempfilename = mess.mid( 10, len );
536 if ( !QFile::exists( tempfilename ) ) 543 if ( !QFile::exists( tempfilename ) )
537 error = true; 544 error = true;
538 } 545 }
539 if ( error ) { 546 if ( error ) {
540 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 547 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
541 mAlarmMessage += mess.mid( 10+len+3+9 ); 548 mAlarmMessage += mess.mid( 10+len+3+9 );
542 } else { 549 } else {
543 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 550 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
544 //qDebug("-----system command %s ",tempfilename.latin1() ); 551 //qDebug("-----system command %s ",tempfilename.latin1() );
@@ -559,102 +566,120 @@ void CalendarView::computeAlarm( QString msg )
559 566
560 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 567 //qDebug("+++++++system command %s ",tempfilename.latin1() );
561 } 568 }
562 if ( mess.left( 11 ) == "audio_alarm") { 569 if ( mess.left( 11 ) == "audio_alarm") {
563 bool error = false; 570 bool error = false;
564 int len = mess.mid( 11 ).find("+++"); 571 int len = mess.mid( 11 ).find("+++");
565 if ( len < 2 ) 572 if ( len < 2 )
566 error = true; 573 error = true;
567 else { 574 else {
568 tempfilename = mess.mid( 11, len ); 575 tempfilename = mess.mid( 11, len );
569 if ( !QFile::exists( tempfilename ) ) 576 if ( !QFile::exists( tempfilename ) )
570 error = true; 577 error = true;
571 } 578 }
572 if ( ! error ) { 579 if ( ! error ) {
573 filename = tempfilename; 580 filename = tempfilename;
574 } 581 }
575 mAlarmMessage = mess.mid( 11+len+3+9 ); 582 mAlarmMessage = mess.mid( 11+len+3+9 );
576 //qDebug("audio file command %s ",tempfilename.latin1() ); 583 //qDebug("audio file command %s ",tempfilename.latin1() );
577 } 584 }
578 if ( mess.left( 9 ) == "cal_alarm") { 585 if ( mess.left( 9 ) == "cal_alarm") {
579 mAlarmMessage = mess.mid( 9 ) ; 586 mAlarmMessage = mess.mid( 9 ) ;
580 } 587 }
581 588
582 startAlarm( mAlarmMessage, filename ); 589 startAlarm( mAlarmMessage, filename );
583 590
584 591
585} 592}
586 593
587void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 594void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
588{ 595{
589 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 596 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
590 597
591 mSuspendAlarmNotification = noti; 598 mSuspendAlarmNotification = noti;
592 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 599 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
593 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 600 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
594 mSuspendTimer->start( ms , true ); 601 mSuspendTimer->start( ms , true );
595 602
596} 603}
597 604
598void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 605void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
599{ 606{
600 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 607 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
601 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 608 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
602#ifndef DESKTOP_VERSION 609#ifndef DESKTOP_VERSION
603 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 610 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
604#endif 611#endif
605 return; 612 return;
606 } 613 }
614 int maxSec;
615 //maxSec = 5; //testing only
616 maxSec = 86400+3600; // one day+1hour
607 mAlarmNotification = noti; 617 mAlarmNotification = noti;
608 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 618 int sec = QDateTime::currentDateTime().secsTo( qdt );
609 //qDebug("Alarm timer started with secs: %d ", ms/1000); 619 if ( sec > maxSec ) {
610 mAlarmTimer->start( ms , true ); 620 mRecheckAlarmTimer->start( maxSec * 1000 );
621 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
622 return;
623 } else {
624 mRecheckAlarmTimer->stop();
625 }
626 //qDebug("Alarm timer started with secs: %d ", sec);
627 mAlarmTimer->start( sec *1000 , true );
611 628
612} 629}
630// called by mRecheckAlarmTimer to get next alarm
631// we need this, because a QTimer has only a max range of 25 days
632void CalendarView::recheckTimerAlarm()
633{
634 mAlarmTimer->stop();
635 mRecheckAlarmTimer->stop();
636 mCalendar->checkAlarmForIncidence( 0, true );
637}
613void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 638void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
614{ 639{
615 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 640 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
616 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 641 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
617#ifndef DESKTOP_VERSION 642#ifndef DESKTOP_VERSION
618 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 643 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
619#endif 644#endif
620 return; 645 return;
621 } 646 }
622 mAlarmTimer->stop(); 647 mAlarmTimer->stop();
623} 648}
624void CalendarView::selectWeekNum ( int num ) 649void CalendarView::selectWeekNum ( int num )
625{ 650{
626 dateNavigator()->selectWeek( num ); 651 dateNavigator()->selectWeek( num );
627 mViewManager->showWeekView(); 652 mViewManager->showWeekView();
628} 653}
629KOViewManager *CalendarView::viewManager() 654KOViewManager *CalendarView::viewManager()
630{ 655{
631 return mViewManager; 656 return mViewManager;
632} 657}
633 658
634KODialogManager *CalendarView::dialogManager() 659KODialogManager *CalendarView::dialogManager()
635{ 660{
636 return mDialogManager; 661 return mDialogManager;
637} 662}
638 663
639QDate CalendarView::startDate() 664QDate CalendarView::startDate()
640{ 665{
641 DateList dates = mNavigator->selectedDates(); 666 DateList dates = mNavigator->selectedDates();
642 667
643 return dates.first(); 668 return dates.first();
644} 669}
645 670
646QDate CalendarView::endDate() 671QDate CalendarView::endDate()
647{ 672{
648 DateList dates = mNavigator->selectedDates(); 673 DateList dates = mNavigator->selectedDates();
649 674
650 return dates.last(); 675 return dates.last();
651} 676}
652 677
653 678
654void CalendarView::createPrinter() 679void CalendarView::createPrinter()
655{ 680{
656#ifndef KORG_NOPRINTER 681#ifndef KORG_NOPRINTER
657 if (!mCalPrinter) { 682 if (!mCalPrinter) {
658 mCalPrinter = new CalPrinter(this, mCalendar); 683 mCalPrinter = new CalPrinter(this, mCalendar);
659 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 684 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
660 } 685 }