summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebook.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp46
1 files changed, 38 insertions, 8 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index b7e89b0..10a9b59 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -219,24 +219,28 @@ void DateBook::receive( const QCString &msg, const QByteArray &data )
219 if ( dayAction->isOn() ) 219 if ( dayAction->isOn() )
220 viewDay(); 220 viewDay();
221 else if ( weekAction->isOn() ) 221 else if ( weekAction->isOn() )
222 viewWeek(); 222 viewWeek();
223 else if ( monthAction->isOn() ) 223 else if ( monthAction->isOn() )
224 viewMonth(); 224 viewMonth();
225 } 225 }
226 else if (msg == "editEvent(int)") { 226 else if (msg == "editEvent(int)") {
227 int uid; 227 int uid;
228 stream >> uid; 228 stream >> uid;
229 Event e=db->eventByUID(uid); 229 Event e=db->eventByUID(uid);
230 editEvent(e); 230 editEvent(e);
231 }else if (msg == "viewDefault(QDate)"){
232 QDate day;
233 stream >> day;
234 viewDefault(day);
231 } 235 }
232} 236}
233 237
234DateBook::~DateBook() 238DateBook::~DateBook()
235{ 239{
236} 240}
237 241
238void DateBook::slotSettings() 242void DateBook::slotSettings()
239{ 243{
240 DateBookSettings frmSettings( ampm, this ); 244 DateBookSettings frmSettings( ampm, this );
241 frmSettings.setStartTime( startTime ); 245 frmSettings.setStartTime( startTime );
242 frmSettings.setAlarmPreset( aPreset, presetTime ); 246 frmSettings.setAlarmPreset( aPreset, presetTime );
@@ -427,27 +431,37 @@ void DateBook::duplicateEvent( const Event &e )
427 vb->addWidget( sv ); 431 vb->addWidget( sv );
428 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); 432 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
429 entry->timezone->setEnabled( FALSE ); 433 entry->timezone->setEnabled( FALSE );
430 sv->addChild( entry ); 434 sv->addChild( entry );
431 435
432#if defined(Q_WS_QWS) || defined(_WS_QWS_) 436#if defined(Q_WS_QWS) || defined(_WS_QWS_)
433 editDlg.showMaximized(); 437 editDlg.showMaximized();
434#endif 438#endif
435 while (editDlg.exec() ) { 439 while (editDlg.exec() ) {
436 Event newEv = entry->event(); 440 Event newEv = entry->event();
437 QString error = checkEvent(newEv); 441 QString error = checkEvent(newEv);
438 if (!error.isNull()) { 442 if (!error.isNull()) {
439 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) 443 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0)
440 continue; 444 continue;
441 } 445 }
446 /*
447 * The problem:
448 * DateBookDB does remove repeating events not by uid but by the time
449 * the recurrence was created
450 * so we need to update that time as well
451 */
452 Event::RepeatPattern rp = newEv.repeatPattern();
453 rp.createTime = ::time( NULL );
454 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern...
455
442 db->addEvent(newEv); 456 db->addEvent(newEv);
443 emit newEvent(); 457 emit newEvent();
444 break; 458 break;
445 } 459 }
446} 460}
447 461
448void DateBook::editEvent( const Event &e ) 462void DateBook::editEvent( const Event &e )
449{ 463{
450 if (syncing) { 464 if (syncing) {
451 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 465 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
452 return; 466 return;
453 } 467 }
@@ -467,25 +481,25 @@ void DateBook::editEvent( const Event &e )
467 sv->addChild( entry ); 481 sv->addChild( entry );
468 482
469#if defined(Q_WS_QWS) || defined(_WS_QWS_) 483#if defined(Q_WS_QWS) || defined(_WS_QWS_)
470 editDlg.showMaximized(); 484 editDlg.showMaximized();
471#endif 485#endif
472 while (editDlg.exec() ) { 486 while (editDlg.exec() ) {
473 Event newEv = entry->event(); 487 Event newEv = entry->event();
474 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 488 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
475 break; 489 break;
476 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 490 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
477 QString error = checkEvent(newEv); 491 QString error = checkEvent(newEv);
478 if (!error.isNull()) { 492 if (!error.isNull()) {
479 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) continue; 493 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue;
480 } 494 }
481 db->editEvent(e, newEv); 495 db->editEvent(e, newEv);
482 emit newEvent(); 496 emit newEvent();
483 break; 497 break;
484 } 498 }
485} 499}
486 500
487void DateBook::removeEvent( const Event &e ) 501void DateBook::removeEvent( const Event &e )
488{ 502{
489 if (syncing) { 503 if (syncing) {
490 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 504 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
491 return; 505 return;
@@ -510,26 +524,26 @@ void DateBook::addEvent( const Event &e )
510 524
511void DateBook::showDay( int year, int month, int day ) 525void DateBook::showDay( int year, int month, int day )
512{ 526{
513 QDate d(year, month, day); 527 QDate d(year, month, day);
514 view(DAY,d); 528 view(DAY,d);
515} 529}
516 530
517void DateBook::initDay() 531void DateBook::initDay()
518{ 532{
519 if ( !dayView ) { 533 if ( !dayView ) {
520 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 534 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
521 views->addWidget( dayView, DAY ); 535 views->addWidget( dayView, DAY );
522 dayView->setStartViewTime( startTime );
523 dayView->setJumpToCurTime( bJumpToCurTime ); 536 dayView->setJumpToCurTime( bJumpToCurTime );
537 dayView->setStartViewTime( startTime );
524 dayView->setRowStyle( rowStyle ); 538 dayView->setRowStyle( rowStyle );
525 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); 539 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) );
526 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); 540 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) );
527 connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); 541 connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) );
528 connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); 542 connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) );
529 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); 543 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) );
530 connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) ); 544 connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) );
531 connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) ); 545 connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) );
532 } 546 }
533} 547}
534 548
535void DateBook::initWeek() 549void DateBook::initWeek()
@@ -688,50 +702,66 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data)
688 vb->addWidget( cmdOk ); 702 vb->addWidget( cmdOk );
689 703
690#if defined(Q_WS_QWS) || defined(_WS_QWS_) 704#if defined(Q_WS_QWS) || defined(_WS_QWS_)
691 dlg.showMaximized(); 705 dlg.showMaximized();
692#endif 706#endif
693 needShow = dlg.exec(); 707 needShow = dlg.exec();
694 708
695 if ( bSound ) 709 if ( bSound )
696 killTimer( stopTimer ); 710 killTimer( stopTimer );
697 } 711 }
698 } 712 }
699 } else if ( msg == "nextView()" ) { 713 } else if ( msg == "nextView()" ) {
714 needShow = true;
700 if ( !qApp-> activeWindow ( )) { 715 if ( !qApp-> activeWindow ( )) {
701 needShow = TRUE; 716 needShow = TRUE;
702 } else { 717 } else {
703 QWidget* cur = views->visibleWidget(); 718 QWidget* cur = views->visibleWidget();
704 if ( cur ) { 719 if ( cur ) {
705 if ( cur == dayView ) 720 if ( cur == dayView )
706 viewWeek(); 721 viewWeek();
707 else if ( cur == weekView ) 722 else if ( cur == weekView )
708 viewWeekLst(); 723 viewWeekLst();
709 else if ( cur == weekLstView ) 724 else if ( cur == weekLstView )
710 viewMonth(); 725 viewMonth();
711 else if ( cur == monthView ) 726 else if ( cur == monthView )
712 viewDay(); 727 viewDay();
713 needShow = TRUE; 728 needShow = TRUE;
714 } 729 }
715 } 730 }
731 } else if (msg == "editEvent(int)") {
732 /* simple copy from receive */
733 QDataStream stream(data,IO_ReadOnly);
734 int uid;
735 stream >> uid;
736 Event e=db->eventByUID(uid);
737 editEvent(e);
738 } else if (msg == "viewDefault(QDate)"){
739 /* simple copy from receive */
740 QDataStream stream(data,IO_ReadOnly);
741 QDate day;
742 stream >> day;
743 viewDefault(day);
744 needShow = true;
716 } 745 }
746
717 if ( needShow ) { 747 if ( needShow ) {
718#if defined(Q_WS_QWS) || defined(_WS_QWS_) 748#if defined(Q_WS_QWS) || defined(_WS_QWS_)
719 showMaximized(); 749 // showMaximized();
720#else 750#else
721 show(); 751 // show();
722#endif 752#endif
723 raise(); 753 // raise();
724 QPEApplication::setKeepRunning(); 754 QPEApplication::setKeepRunning();
725 setActiveWindow(); 755 // setActiveWindow();
726 } 756 }
727} 757}
728 758
729void DateBook::reload() 759void DateBook::reload()
730{ 760{
731 db->reload(); 761 db->reload();
732 if ( dayAction->isOn() ) viewDay(); 762 if ( dayAction->isOn() ) viewDay();
733 else if ( weekAction->isOn() ) viewWeek(); 763 else if ( weekAction->isOn() ) viewWeek();
734 else if ( monthAction->isOn() ) viewMonth(); 764 else if ( monthAction->isOn() ) viewMonth();
735 syncing = FALSE; 765 syncing = FALSE;
736} 766}
737 767
@@ -908,25 +938,25 @@ void DateBook::beamEvent( const Event &e )
908} 938}
909 939
910void DateBook::beamDone( Ir *ir ) 940void DateBook::beamDone( Ir *ir )
911{ 941{
912 delete ir; 942 delete ir;
913 unlink( beamfile ); 943 unlink( beamfile );
914} 944}
915 945
916void DateBook::slotFind() 946void DateBook::slotFind()
917{ 947{
918 // move it to the day view... 948 // move it to the day view...
919 viewDay(); 949 viewDay();
920 FindDialog frmFind( "Calendar", this ); 950 FindDialog frmFind( "Calendar", this ); // no tr needed
921 frmFind.setUseDate( true ); 951 frmFind.setUseDate( true );
922 frmFind.setDate( currentDate() ); 952 frmFind.setDate( currentDate() );
923 QObject::connect( &frmFind, 953 QObject::connect( &frmFind,
924 SIGNAL(signalFindClicked(const QString&, const QDate&, 954 SIGNAL(signalFindClicked(const QString&, const QDate&,
925 bool, bool, int)), 955 bool, bool, int)),
926 this, 956 this,
927 SLOT(slotDoFind(const QString&, const QDate&, 957 SLOT(slotDoFind(const QString&, const QDate&,
928 bool, bool, int)) ); 958 bool, bool, int)) );
929 QObject::connect( this, 959 QObject::connect( this,
930 SIGNAL(signalNotFound()), 960 SIGNAL(signalNotFound()),
931 &frmFind, 961 &frmFind,
932 SLOT(slotNotFound()) ); 962 SLOT(slotNotFound()) );