Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 0a47bb8..a18a5b4 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -470,192 +470,195 @@ void DateBook::editEvent( const Event &e ) | |||
470 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid | 470 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid |
471 | QString error = checkEvent(newEv); | 471 | QString error = checkEvent(newEv); |
472 | if (!error.isNull()) { | 472 | if (!error.isNull()) { |
473 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; | 473 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; |
474 | } | 474 | } |
475 | db->editEvent(e, newEv); | 475 | db->editEvent(e, newEv); |
476 | emit newEvent(); | 476 | emit newEvent(); |
477 | break; | 477 | break; |
478 | } | 478 | } |
479 | } | 479 | } |
480 | 480 | ||
481 | void DateBook::removeEvent( const Event &e ) | 481 | void DateBook::removeEvent( const Event &e ) |
482 | { | 482 | { |
483 | if (syncing) { | 483 | if (syncing) { |
484 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 484 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
485 | return; | 485 | return; |
486 | } | 486 | } |
487 | 487 | ||
488 | QString strName = e.description(); | 488 | QString strName = e.description(); |
489 | 489 | ||
490 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) | 490 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) |
491 | return; | 491 | return; |
492 | 492 | ||
493 | db->removeEvent( e ); | 493 | db->removeEvent( e ); |
494 | if ( views->visibleWidget() == dayView && dayView ) | 494 | if ( views->visibleWidget() == dayView && dayView ) |
495 | dayView->redraw(); | 495 | dayView->redraw(); |
496 | 496 | ||
497 | } | 497 | } |
498 | 498 | ||
499 | void DateBook::addEvent( const Event &e ) | 499 | void DateBook::addEvent( const Event &e ) |
500 | { | 500 | { |
501 | QDate d = e.start().date(); | 501 | QDate d = e.start().date(); |
502 | initDay(); | 502 | initDay(); |
503 | dayView->setDate( d ); | 503 | dayView->setDate( d ); |
504 | } | 504 | } |
505 | 505 | ||
506 | void DateBook::showDay( int year, int month, int day ) | 506 | void DateBook::showDay( int year, int month, int day ) |
507 | { | 507 | { |
508 | QDate d(year, month, day); | 508 | QDate d(year, month, day); |
509 | view(DAY,d); | 509 | view(DAY,d); |
510 | } | 510 | } |
511 | 511 | ||
512 | void DateBook::initDay() | 512 | void DateBook::initDay() |
513 | { | 513 | { |
514 | if ( !dayView ) { | 514 | if ( !dayView ) { |
515 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); | 515 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); |
516 | views->addWidget( dayView, DAY ); | 516 | views->addWidget( dayView, DAY ); |
517 | dayView->setJumpToCurTime( bJumpToCurTime ); | 517 | dayView->setJumpToCurTime( bJumpToCurTime ); |
518 | dayView->setStartViewTime( startTime ); | 518 | dayView->setStartViewTime( startTime ); |
519 | dayView->setRowStyle( rowStyle ); | 519 | dayView->setRowStyle( rowStyle ); |
520 | connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); | 520 | connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); |
521 | connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); | 521 | connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); |
522 | connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) ); | 522 | connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) ); |
523 | connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); | 523 | connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); |
524 | connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) ); | 524 | connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) ); |
525 | connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); | 525 | connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); |
526 | connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) ); | 526 | connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) ); |
527 | } | 527 | } |
528 | } | 528 | } |
529 | 529 | ||
530 | void DateBook::initWeek() | 530 | void DateBook::initWeek() |
531 | { | 531 | { |
532 | if ( !weekView ) { | 532 | if ( !weekView ) { |
533 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); | 533 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); |
534 | weekView->setStartViewTime( startTime ); | 534 | weekView->setStartViewTime( startTime ); |
535 | views->addWidget( weekView, WEEK ); | 535 | views->addWidget( weekView, WEEK ); |
536 | connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); | 536 | connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); |
537 | connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); | 537 | connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); |
538 | } | 538 | } |
539 | 539 | ||
540 | //But also get it right: the year that we display can be different | 540 | //But also get it right: the year that we display can be different |
541 | //from the year of the current date. So, first find the year | 541 | //from the year of the current date. So, first find the year |
542 | //number of the current week. | 542 | //number of the current week. |
543 | int yearNumber, totWeeks; | 543 | int yearNumber, totWeeks; |
544 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); | 544 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); |
545 | 545 | ||
546 | QDate d = QDate( yearNumber, 12, 31 ); | 546 | QDate d = QDate( yearNumber, 12, 31 ); |
547 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 547 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
548 | 548 | ||
549 | while ( totWeeks == 1 ) { | 549 | while ( totWeeks == 1 ) { |
550 | d = d.addDays( -1 ); | 550 | d = d.addDays( -1 ); |
551 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 551 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | void DateBook::initWeekLst() { | 555 | void DateBook::initWeekLst() { |
556 | if ( !weekLstView ) { | 556 | if ( !weekLstView ) { |
557 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); | 557 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); |
558 | views->addWidget( weekLstView, WEEKLST ); | 558 | views->addWidget( weekLstView, WEEKLST ); |
559 | 559 | ||
560 | //weekLstView->setStartViewTime( startTime ); | 560 | //weekLstView->setStartViewTime( startTime ); |
561 | connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); | 561 | connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); |
562 | connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ), | 562 | connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ), |
563 | this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) ); | 563 | this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) ); |
564 | connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); | 564 | connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); |
565 | connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); | 565 | connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); |
566 | connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); | ||
567 | connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); | ||
568 | connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); | ||
566 | } | 569 | } |
567 | } | 570 | } |
568 | 571 | ||
569 | 572 | ||
570 | void DateBook::initMonth() | 573 | void DateBook::initMonth() |
571 | { | 574 | { |
572 | if ( !monthView ) { | 575 | if ( !monthView ) { |
573 | monthView = new DateBookMonth( views, "month view", FALSE, db ); | 576 | monthView = new DateBookMonth( views, "month view", FALSE, db ); |
574 | views->addWidget( monthView, MONTH ); | 577 | views->addWidget( monthView, MONTH ); |
575 | connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); | 578 | connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); |
576 | connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); | 579 | connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); |
577 | qApp->processEvents(); | 580 | qApp->processEvents(); |
578 | } | 581 | } |
579 | } | 582 | } |
580 | 583 | ||
581 | void DateBook::loadSettings() | 584 | void DateBook::loadSettings() |
582 | { | 585 | { |
583 | Config qpeconfig( "qpe" ); | 586 | Config qpeconfig( "qpe" ); |
584 | qpeconfig.setGroup("Time"); | 587 | qpeconfig.setGroup("Time"); |
585 | ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); | 588 | ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); |
586 | onMonday = qpeconfig.readBoolEntry( "MONDAY" ); | 589 | onMonday = qpeconfig.readBoolEntry( "MONDAY" ); |
587 | 590 | ||
588 | Config config("DateBook"); | 591 | Config config("DateBook"); |
589 | config.setGroup("Main"); | 592 | config.setGroup("Main"); |
590 | startTime = config.readNumEntry("startviewtime", 8); | 593 | startTime = config.readNumEntry("startviewtime", 8); |
591 | aPreset = config.readBoolEntry("alarmpreset"); | 594 | aPreset = config.readBoolEntry("alarmpreset"); |
592 | presetTime = config.readNumEntry("presettime"); | 595 | presetTime = config.readNumEntry("presettime"); |
593 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); | 596 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); |
594 | rowStyle = config.readNumEntry("rowstyle"); | 597 | rowStyle = config.readNumEntry("rowstyle"); |
595 | defaultView = config.readNumEntry("defaultview",DAY); | 598 | defaultView = config.readNumEntry("defaultview",DAY); |
596 | weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); | 599 | weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); |
597 | 600 | ||
598 | defaultLocation=config.readEntry("defaultLocation"); | 601 | defaultLocation=config.readEntry("defaultLocation"); |
599 | QString tmpString=config.readEntry("defaultCategories"); | 602 | QString tmpString=config.readEntry("defaultCategories"); |
600 | QStringList tmpStringList=QStringList::split(",",tmpString); | 603 | QStringList tmpStringList=QStringList::split(",",tmpString); |
601 | defaultCategories.truncate(0); | 604 | defaultCategories.truncate(0); |
602 | 605 | ||
603 | for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { | 606 | for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { |
604 | defaultCategories.resize(defaultCategories.count()+1); | 607 | defaultCategories.resize(defaultCategories.count()+1); |
605 | defaultCategories[defaultCategories.count()-1]=(*i).toInt(); | 608 | defaultCategories[defaultCategories.count()-1]=(*i).toInt(); |
606 | } | 609 | } |
607 | } | 610 | } |
608 | 611 | ||
609 | void DateBook::saveSettings() | 612 | void DateBook::saveSettings() |
610 | { | 613 | { |
611 | Config config( "qpe" ); | 614 | Config config( "qpe" ); |
612 | Config configDB( "DateBook" ); | 615 | Config configDB( "DateBook" ); |
613 | configDB.setGroup( "Main" ); | 616 | configDB.setGroup( "Main" ); |
614 | configDB.writeEntry("startviewtime",startTime); | 617 | configDB.writeEntry("startviewtime",startTime); |
615 | configDB.writeEntry("alarmpreset",aPreset); | 618 | configDB.writeEntry("alarmpreset",aPreset); |
616 | configDB.writeEntry("presettime",presetTime); | 619 | configDB.writeEntry("presettime",presetTime); |
617 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); | 620 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); |
618 | configDB.writeEntry("rowstyle", rowStyle); | 621 | configDB.writeEntry("rowstyle", rowStyle); |
619 | configDB.writeEntry("defaultview",defaultView); | 622 | configDB.writeEntry("defaultview",defaultView); |
620 | configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); | 623 | configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); |
621 | 624 | ||
622 | configDB.writeEntry("defaultLocation",defaultLocation); | 625 | configDB.writeEntry("defaultLocation",defaultLocation); |
623 | QStringList tmpStringList; | 626 | QStringList tmpStringList; |
624 | for( uint i=0; i<defaultCategories.count(); i++) { | 627 | for( uint i=0; i<defaultCategories.count(); i++) { |
625 | tmpStringList << QString::number(defaultCategories[i]); | 628 | tmpStringList << QString::number(defaultCategories[i]); |
626 | } | 629 | } |
627 | configDB.writeEntry("defaultCategories",tmpStringList.join(",")); | 630 | configDB.writeEntry("defaultCategories",tmpStringList.join(",")); |
628 | } | 631 | } |
629 | 632 | ||
630 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) | 633 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) |
631 | { | 634 | { |
632 | bool needShow = FALSE; | 635 | bool needShow = FALSE; |
633 | if ( msg == "alarm(QDateTime,int)" ) { | 636 | if ( msg == "alarm(QDateTime,int)" ) { |
634 | QDataStream ds(data,IO_ReadOnly); | 637 | QDataStream ds(data,IO_ReadOnly); |
635 | QDateTime when; int warn; | 638 | QDateTime when; int warn; |
636 | ds >> when >> warn; | 639 | ds >> when >> warn; |
637 | 640 | ||
638 | // check to make it's okay to continue, | 641 | // check to make it's okay to continue, |
639 | // this is the case that the time was set ahead, and | 642 | // this is the case that the time was set ahead, and |
640 | // we are forced given a stale alarm... | 643 | // we are forced given a stale alarm... |
641 | QDateTime current = QDateTime::currentDateTime(); | 644 | QDateTime current = QDateTime::currentDateTime(); |
642 | if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) | 645 | if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) |
643 | return; | 646 | return; |
644 | 647 | ||
645 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); | 648 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); |
646 | if ( list.count() > 0 ) { | 649 | if ( list.count() > 0 ) { |
647 | QString msg; | 650 | QString msg; |
648 | bool bSound = FALSE; | 651 | bool bSound = FALSE; |
649 | int stopTimer = 0; | 652 | int stopTimer = 0; |
650 | bool found = FALSE; | 653 | bool found = FALSE; |
651 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { | 654 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { |
652 | if ( (*it).event().hasAlarm() ) { | 655 | if ( (*it).event().hasAlarm() ) { |
653 | found = TRUE; | 656 | found = TRUE; |
654 | msg += "<CENTER><B>" + (*it).description() + "</B>" | 657 | msg += "<CENTER><B>" + (*it).description() + "</B>" |
655 | + "<BR>" + (*it).location() + "<BR>" | 658 | + "<BR>" + (*it).location() + "<BR>" |
656 | + TimeString::dateString((*it).event().start(),ampm) | 659 | + TimeString::dateString((*it).event().start(),ampm) |
657 | + (warn | 660 | + (warn |
658 | ? tr(" (in " + QString::number(warn) | 661 | ? tr(" (in " + QString::number(warn) |
659 | + tr(" minutes)")) | 662 | + tr(" minutes)")) |
660 | : QString("")) | 663 | : QString("")) |
661 | + "<BR>" | 664 | + "<BR>" |