summaryrefslogtreecommitdiff
path: root/core/pim/todo/mainwindow.cpp
Unidiff
Diffstat (limited to 'core/pim/todo/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp136
1 files changed, 110 insertions, 26 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 5119ae0..6725951 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -73,2 +73,3 @@ MainWindow::MainWindow( QWidget* parent,
73 m_syncing = false; 73 m_syncing = false;
74 m_showing = false;
74 m_counter = 0; 75 m_counter = 0;
@@ -163,2 +164,3 @@ void MainWindow::initActions() {
163 164
165#if 0
164 // Options menu 166 // Options menu
@@ -170,3 +172,5 @@ void MainWindow::initActions() {
170 172
173
171 m_options->insertSeparator(); 174 m_options->insertSeparator();
175#endif
172 176
@@ -354,2 +358,3 @@ void MainWindow::closeEvent( QCloseEvent* e ) {
354 if (m_stack->visibleWidget() == currentShow()->widget() ) { 358 if (m_stack->visibleWidget() == currentShow()->widget() ) {
359 m_showing = false;
355 raiseCurrentView(); 360 raiseCurrentView();
@@ -411,3 +416,3 @@ void MainWindow::populateTemplates() {
411 * We use the edit widget to do 416 * We use the edit widget to do
412 * the config but we setUid(-1) 417 * the config but we setUid(1)
413 * to get a new uid 418 * to get a new uid
@@ -427,5 +432,6 @@ void MainWindow::slotNewFromTemplate( int id ) {
427 /* assign new todo */ 432 /* assign new todo */
428 event.setUid( -1 ); 433 event.setUid( 1 );
429 currentView()->addEvent( event ); 434 handleAlarms( OTodo(), event );
430 m_todoMgr.add( event ); 435 m_todoMgr.add( event );
436 currentView()->addEvent( event );
431 437
@@ -433,2 +439,3 @@ void MainWindow::slotNewFromTemplate( int id ) {
433 } 439 }
440 raiseCurrentView();
434} 441}
@@ -440,3 +447,3 @@ void MainWindow::slotDuplicate() {
440 QMessageBox::warning(this, QWidget::tr("Todo"), 447 QMessageBox::warning(this, QWidget::tr("Todo"),
441 QWidget::tr("Can not edit data, currently syncing")); 448 QWidget::tr("Data can not be edited, currently syncing"));
442 return; 449 return;
@@ -445,3 +452,3 @@ void MainWindow::slotDuplicate() {
445 /* let's generate a new uid */ 452 /* let's generate a new uid */
446 ev.setUid(-1); 453 ev.setUid(1);
447 m_todoMgr.add( ev ); 454 m_todoMgr.add( ev );
@@ -457,3 +464,3 @@ void MainWindow::slotDelete() {
457 QMessageBox::warning(this, QWidget::tr("Todo"), 464 QMessageBox::warning(this, QWidget::tr("Todo"),
458 QWidget::tr("Can not edit data, currently syncing")); 465 QWidget::tr("Data can not be edited, currently syncing"));
459 return; 466 return;
@@ -464,3 +471,3 @@ void MainWindow::slotDelete() {
464 471
465 handleAlarms( OTodo(), m_todoMgr.event( currentView()->current() ) ); 472 handleAlarms( m_todoMgr.event( currentView()->current() ), OTodo() );
466 m_todoMgr.remove( currentView()->current() ); 473 m_todoMgr.remove( currentView()->current() );
@@ -469,2 +476,18 @@ void MainWindow::slotDelete() {
469} 476}
477void MainWindow::slotDelete(int uid ) {
478 if( uid == 0 ) return;
479 if(m_syncing) {
480 QMessageBox::warning(this, QWidget::tr("Todo"),
481 QWidget::tr("Data can not be edited, currently syncing"));
482 return;
483 }
484 OTodo to = m_todoMgr.event(uid);
485 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) )
486 return;
487
488 handleAlarms(to, OTodo() );
489 m_todoMgr.remove( to.uid() );
490 currentView()->removeEvent( to.uid() );
491 raiseCurrentView();
492}
470void MainWindow::slotDeleteAll() { 493void MainWindow::slotDeleteAll() {
@@ -472,3 +495,3 @@ void MainWindow::slotDeleteAll() {
472 QMessageBox::warning(this, QWidget::tr("Todo"), 495 QMessageBox::warning(this, QWidget::tr("Todo"),
473 QWidget::tr("Can not edit data, currently syncing")); 496 QWidget::tr("Data can not be edited, currently syncing"));
474 return; 497 return;
@@ -488,3 +511,3 @@ void MainWindow::slotDeleteCompleted() {
488 QMessageBox::warning(this, QWidget::tr("Todo"), 511 QMessageBox::warning(this, QWidget::tr("Todo"),
489 QWidget::tr("Can not edit data, currently syncing")); 512 QWidget::tr("Data can not be edited, currently syncing"));
490 return; 513 return;
@@ -568,2 +591,3 @@ void MainWindow::receiveFile( const QString& filename ) {
568 OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); 591 OTodoAccessVCal* cal = new OTodoAccessVCal(filename );
592
569 OTodoAccess acc( cal ); 593 OTodoAccess acc( cal );
@@ -572,12 +596,15 @@ void MainWindow::receiveFile( const QString& filename ) {
572 596
573 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); 597 if (list.count()){
574 598
575 if ( QMessageBox::information(this, QWidget::tr("New Tasks"), 599 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
576 message, QMessageBox::Ok,
577 QMessageBox::Cancel ) == QMessageBox::Ok ) {
578 OTodoAccess::List::Iterator it;
579 for ( it = list.begin(); it != list.end(); ++it )
580 m_todoMgr.add( (*it) );
581 600
582 currentView()->updateView(); 601 if ( QMessageBox::information(this, QWidget::tr("New Tasks"),
602 message, QMessageBox::Ok,
603 QMessageBox::Cancel ) == QMessageBox::Ok ) {
604 OTodoAccess::List::Iterator it;
605 for ( it = list.begin(); it != list.end(); ++it )
606 m_todoMgr.add( (*it) );
607
608 currentView()->updateView();
609 }
583 } 610 }
@@ -636,2 +663,9 @@ ViewBase* MainWindow::currentView() {
636void MainWindow::raiseCurrentView() { 663void MainWindow::raiseCurrentView() {
664 // due QPE/Application/todolist show(int)
665 // we might not have the populateCategories slot called once
666 // we would show the otodo but then imediately switch to the currentView
667 // if we're initially showing we shouldn't raise the table
668 // in returnFromView we fix up m_showing
669 if (m_showing ) return;
670
637 m_stack->raiseWidget( m_curView->widget() ); 671 m_stack->raiseWidget( m_curView->widget() );
@@ -644,2 +678,3 @@ void MainWindow::slotShowDue(bool ov) {
644void MainWindow::slotShow( int uid ) { 678void MainWindow::slotShow( int uid ) {
679 if ( uid == 0 ) return;
645 qWarning("slotShow"); 680 qWarning("slotShow");
@@ -648,7 +683,17 @@ void MainWindow::slotShow( int uid ) {
648} 683}
684void MainWindow::slotShowNext() {
685 int l = currentView()->next();
686 if (l!=0)
687 slotShow(l);
688}
689void MainWindow::slotShowPrev() {
690 int l = currentView()->prev();
691 if (l!=0)
692 slotShow(l);
693}
649void MainWindow::slotEdit( int uid ) { 694void MainWindow::slotEdit( int uid ) {
650 if (uid == 1 ) return; 695 if (uid == 0 ) return;
651 if(m_syncing) { 696 if(m_syncing) {
652 QMessageBox::warning(this, QWidget::tr("Todo"), 697 QMessageBox::warning(this, QWidget::tr("Todo"),
653 QWidget::tr("Can not edit data, currently syncing")); 698 QWidget::tr("Data can't be edited, currently syncing"));
654 return; 699 return;
@@ -662,3 +707,2 @@ void MainWindow::slotEdit( int uid ) {
662 if ( currentEditor()->accepted() ) { 707 if ( currentEditor()->accepted() ) {
663 qWarning("Replacing now" );
664 handleAlarms( old_todo, todo ); 708 handleAlarms( old_todo, todo );
@@ -720,2 +764,6 @@ void MainWindow::slotComplete( const OTodo& todo ) {
720 * the spinned off one will loose the 764 * the spinned off one will loose the
765 * recurrence.
766 * We calculate the difference between the old due date and the
767 * new one and add this diff to start, completed and alarm dates
768 * -zecke
721 */ 769 */
@@ -736,2 +784,4 @@ void MainWindow::slotComplete( const OTodo& todo ) {
736 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { 784 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) {
785 int dayDiff = to.dueDate().daysTo( date );
786 qWarning("day diff is %d", dayDiff );
737 QDate inval; 787 QDate inval;
@@ -749,5 +799,26 @@ void MainWindow::slotComplete( const OTodo& todo ) {
749 to2.setDueDate( date ); 799 to2.setDueDate( date );
750 to2.setStartDate( inval ); 800 rec.setStart( date );
801 to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week
802
803 /* move start date */
804 if (to2.hasStartDate() )
805 to2.setStartDate( to2.startDate().addDays( dayDiff ) );
806
807 /* now the alarms */
808 if (to2.hasNotifiers() ) {
809 OPimNotifyManager::Alarms _als = to2.notifiers().alarms();
810 OPimNotifyManager::Alarms als;
811
812 /* for every alarm move the day */
813 for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) {
814 OPimAlarm al = (*it);
815 al.setDateTime( al.dateTime().addDays( dayDiff ) );
816 als.append( al );
817 }
818 to2.notifiers().setAlarms( als );
819 handleAlarms( OTodo(), todo );
820 }
751 to2.setCompletedDate( inval ); 821 to2.setCompletedDate( inval );
752 to2.setCompleted( false ); 822 to2.setCompleted( false );
823
753 updateTodo( to2 ); 824 updateTodo( to2 );
@@ -771,5 +842,6 @@ int MainWindow::create() {
771 QMessageBox::warning(this, QWidget::tr("Todo"), 842 QMessageBox::warning(this, QWidget::tr("Todo"),
772 QWidget::tr("Can not edit data, currently syncing")); 843 QWidget::tr("Data can not be edited, currently syncing"));
773 return uid; 844 return uid;
774 } 845 }
846 m_todoMgr.load();
775 847
@@ -806,3 +878,7 @@ bool MainWindow::remove( int uid ) {
806void MainWindow::beam( int uid) { 878void MainWindow::beam( int uid) {
879 if( uid == 0 ) return;
880
807 ::unlink( beamfile ); 881 ::unlink( beamfile );
882 m_todoMgr.load();
883
808 OTodo todo = event( uid ); 884 OTodo todo = event( uid );
@@ -819,5 +895,10 @@ void MainWindow::beam( int uid) {
819void MainWindow::show( int uid ) { 895void MainWindow::show( int uid ) {
896 m_todoMgr.load(); // might not be loaded yet
897 m_showing = true;
820 slotShow( uid ); 898 slotShow( uid );
899 raise();
900 QPEApplication::setKeepRunning();
821} 901}
822void MainWindow::edit( int uid ) { 902void MainWindow::edit( int uid ) {
903 m_todoMgr.load();
823 slotEdit( uid ); 904 slotEdit( uid );
@@ -826,2 +907,3 @@ void MainWindow::add( const OPimRecord& rec) {
826 if ( rec.rtti() != OTodo::rtti() ) return; 907 if ( rec.rtti() != OTodo::rtti() ) return;
908 m_todoMgr.load(); // might not be loaded
827 909
@@ -839,2 +921,3 @@ void MainWindow::add( const OPimRecord& rec) {
839void MainWindow::slotReturnFromView() { 921void MainWindow::slotReturnFromView() {
922 m_showing = false;
840 raiseCurrentView(); 923 raiseCurrentView();
@@ -934,3 +1017,3 @@ void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
934 1017
935 QString text = tr("<h1>Alarm at %0</h1><br>").arg( TimeString::dateString( dt ) ); 1018 QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) );
936 text += todo.toRichText(); 1019 text += todo.toRichText();
@@ -945,6 +1028,6 @@ void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
945 if (needToStay) { 1028 if (needToStay) {
946 showMaximized(); 1029// showMaximized();
947 raise(); 1030// raise();
948 QPEApplication::setKeepRunning(); 1031 QPEApplication::setKeepRunning();
949 setActiveWindow(); 1032// setActiveWindow();
950 } 1033 }
@@ -952 +1035,2 @@ void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
952} 1035}
1036