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.cpp98
1 files changed, 48 insertions, 50 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index fc189bd..0613f2c 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -19,53 +19,51 @@
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = General Public License along with 21  -_. . .   )=.  = General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include <unistd.h> 29#include <unistd.h>
30 30
31#include <opie2/opimrecurrence.h>
32#include <opie2/opimnotifymanager.h>
33#include <opie2/otodoaccessvcal.h>
34#include <opie2/oapplicationfactory.h>
35
36#include <qpe/applnk.h>
37#include <qpe/config.h>
38#include <qpe/ir.h>
39#include <qpe/resource.h>
40#include <qpe/qpemessagebox.h>
41#include <qpe/alarmserver.h>
42#include <qpe/timestring.h>
43#include <qpe/qpeapplication.h>
44
31#include <qmenubar.h> 45#include <qmenubar.h>
32#include <qmessagebox.h> 46#include <qmessagebox.h>
33#include <qtoolbar.h> 47#include <qtoolbar.h>
34#include <qpopupmenu.h> 48#include <qpopupmenu.h>
35#include <qpushbutton.h> 49#include <qpushbutton.h>
36#include <qwidgetstack.h> 50#include <qwidgetstack.h>
37#include <qaction.h> 51#include <qaction.h>
38#include <qtimer.h> 52#include <qtimer.h>
39#include <qvbox.h> 53#include <qvbox.h>
40#include <qlayout.h> 54#include <qlayout.h>
41#include <qlineedit.h> 55#include <qlineedit.h>
42#include <qwhatsthis.h> 56#include <qwhatsthis.h>
43 57
44#include <qpe/applnk.h>
45#include <qpe/config.h>
46#include <qpe/ir.h>
47#include <qpe/resource.h>
48#include <qpe/qpemessagebox.h>
49#include <qpe/alarmserver.h>
50#include <qpe/timestring.h>
51#include <qpe/qpeapplication.h>
52
53#include <opie/orecur.h>
54#include <opie/opimnotifymanager.h>
55#include <opie/otodoaccessvcal.h>
56#include <opie/owidgetstack.h>
57
58#include <opie/oapplicationfactory.h>
59
60#include "quickeditimpl.h" 58#include "quickeditimpl.h"
61#include "todotemplatemanager.h" 59#include "todotemplatemanager.h"
62#include "templateeditor.h" 60#include "templateeditor.h"
63#include "tableview.h" 61#include "tableview.h"
64 62
65#include "textviewshow.h" 63#include "textviewshow.h"
66#include "todoeditor.h" 64#include "todoeditor.h"
67#include "mainwindow.h" 65#include "mainwindow.h"
68 66
69OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) 67OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> )
70 68
71using namespace Todo; 69using namespace Todo;
@@ -301,56 +299,56 @@ QPopupMenu* MainWindow::contextMenu( int , bool recur ) {
301 return menu; 299 return menu;
302} 300}
303QPopupMenu* MainWindow::options() { 301QPopupMenu* MainWindow::options() {
304 qWarning("Options"); 302 qWarning("Options");
305 return m_options; 303 return m_options;
306} 304}
307QPopupMenu* MainWindow::edit() { 305QPopupMenu* MainWindow::edit() {
308 return m_edit; 306 return m_edit;
309} 307}
310QToolBar* MainWindow::toolbar() { 308QToolBar* MainWindow::toolbar() {
311 return m_tool; 309 return m_tool;
312} 310}
313OTodoAccess::List MainWindow::list()const { 311OPimTodoAccess::List MainWindow::list()const {
314 return m_todoMgr.list(); 312 return m_todoMgr.list();
315} 313}
316OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 314OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
317 int cat = 0; 315 int cat = 0;
318 if ( m_curCat != QWidget::tr("All Categories") ) 316 if ( m_curCat != QWidget::tr("All Categories") )
319 cat = currentCatId(); 317 cat = currentCatId();
320 if ( m_curCat == QWidget::tr("Unfiled") ) 318 if ( m_curCat == QWidget::tr("Unfiled") )
321 cat = -1; 319 cat = -1;
322 320
323 qWarning(" Category %d %s", cat, m_curCat.latin1() ); 321 qWarning(" Category %d %s", cat, m_curCat.latin1() );
324 322
325 int filter = 1; 323 int filter = 1;
326 324
327 if (!m_completed ) 325 if (!m_completed )
328 filter |= 4; 326 filter |= 4;
329 if (m_overdue) 327 if (m_overdue)
330 filter |= 2; 328 filter |= 2;
331 329
332 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 330 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
333} 331}
334OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 332OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
335 int cat = 0; 333 int cat = 0;
336 if ( m_curCat != QWidget::tr("All Categories") ) 334 if ( m_curCat != QWidget::tr("All Categories") )
337 cat = currentCatId(); 335 cat = currentCatId();
338 336
339 if ( m_curCat == QWidget::tr("Unfiled") ) 337 if ( m_curCat == QWidget::tr("Unfiled") )
340 cat = -1; 338 cat = -1;
341 339
342 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 340 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
343} 341}
344OTodo MainWindow::event( int uid ) { 342OPimTodo MainWindow::event( int uid ) {
345 return m_todoMgr.event( uid ); 343 return m_todoMgr.event( uid );
346} 344}
347bool MainWindow::isSyncing()const { 345bool MainWindow::isSyncing()const {
348 return m_syncing; 346 return m_syncing;
349} 347}
350TemplateManager* MainWindow::templateManager() { 348TemplateManager* MainWindow::templateManager() {
351 return m_tempManager; 349 return m_tempManager;
352} 350}
353Editor* MainWindow::currentEditor() { 351Editor* MainWindow::currentEditor() {
354 return m_curEdit; 352 return m_curEdit;
355} 353}
356TodoShow* MainWindow::currentShow() { 354TodoShow* MainWindow::currentShow() {
@@ -424,86 +422,86 @@ void MainWindow::populateTemplates() {
424 * slotNewFromTemplate 422 * slotNewFromTemplate
425 * We use the edit widget to do 423 * We use the edit widget to do
426 * the config but we setUid(1) 424 * the config but we setUid(1)
427 * to get a new uid 425 * to get a new uid
428 */ 426 */
429/* 427/*
430 * first we get the name of the template 428 * first we get the name of the template
431 * then we will use the TemplateManager 429 * then we will use the TemplateManager
432 */ 430 */
433void MainWindow::slotNewFromTemplate( int id ) { 431void MainWindow::slotNewFromTemplate( int id ) {
434 QString name = m_template->text( id ); 432 QString name = m_template->text( id );
435 433
436 OTodo event = templateManager()->templateEvent( name ); 434 OPimTodo event = templateManager()->templateEvent( name );
437 event = currentEditor()->edit(this, 435 event = currentEditor()->edit(this,
438 event ); 436 event );
439 437
440 if ( currentEditor()->accepted() ) { 438 if ( currentEditor()->accepted() ) {
441 /* assign new todo */ 439 /* assign new todo */
442 event.setUid( 1 ); 440 event.setUid( 1 );
443 handleAlarms( OTodo(), event ); 441 handleAlarms( OPimTodo(), event );
444 m_todoMgr.add( event ); 442 m_todoMgr.add( event );
445 currentView()->addEvent( event ); 443 currentView()->addEvent( event );
446 444
447 populateCategories(); 445 populateCategories();
448 } 446 }
449 raiseCurrentView(); 447 raiseCurrentView();
450} 448}
451void MainWindow::slotNew() { 449void MainWindow::slotNew() {
452 create(); 450 create();
453} 451}
454void MainWindow::slotDuplicate() { 452void MainWindow::slotDuplicate() {
455 if(m_syncing) { 453 if(m_syncing) {
456 QMessageBox::warning(this, QWidget::tr("Todo"), 454 QMessageBox::warning(this, QWidget::tr("Todo"),
457 QWidget::tr("Data can not be edited, currently syncing")); 455 QWidget::tr("Data can not be edited, currently syncing"));
458 return; 456 return;
459 } 457 }
460 OTodo ev = m_todoMgr.event( currentView()->current() ); 458 OPimTodo ev = m_todoMgr.event( currentView()->current() );
461 /* let's generate a new uid */ 459 /* let's generate a new uid */
462 ev.setUid(1); 460 ev.setUid(1);
463 m_todoMgr.add( ev ); 461 m_todoMgr.add( ev );
464 462
465 currentView()->addEvent( ev ); 463 currentView()->addEvent( ev );
466 raiseCurrentView(); 464 raiseCurrentView();
467} 465}
468void MainWindow::slotDelete() { 466void MainWindow::slotDelete() {
469 if (!currentView()->current() ) 467 if (!currentView()->current() )
470 return; 468 return;
471 469
472 if(m_syncing) { 470 if(m_syncing) {
473 QMessageBox::warning(this, QWidget::tr("Todo"), 471 QMessageBox::warning(this, QWidget::tr("Todo"),
474 QWidget::tr("Data can not be edited, currently syncing")); 472 QWidget::tr("Data can not be edited, currently syncing"));
475 return; 473 return;
476 } 474 }
477 QString strName = currentView()->currentRepresentation(); 475 QString strName = currentView()->currentRepresentation();
478 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) 476 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) )
479 return; 477 return;
480 478
481 handleAlarms( m_todoMgr.event( currentView()->current() ), OTodo() ); 479 handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() );
482 m_todoMgr.remove( currentView()->current() ); 480 m_todoMgr.remove( currentView()->current() );
483 currentView()->removeEvent( currentView()->current() ); 481 currentView()->removeEvent( currentView()->current() );
484 raiseCurrentView(); 482 raiseCurrentView();
485} 483}
486void MainWindow::slotDelete(int uid ) { 484void MainWindow::slotDelete(int uid ) {
487 if( uid == 0 ) return; 485 if( uid == 0 ) return;
488 if(m_syncing) { 486 if(m_syncing) {
489 QMessageBox::warning(this, QWidget::tr("Todo"), 487 QMessageBox::warning(this, QWidget::tr("Todo"),
490 QWidget::tr("Data can not be edited, currently syncing")); 488 QWidget::tr("Data can not be edited, currently syncing"));
491 return; 489 return;
492 } 490 }
493 OTodo to = m_todoMgr.event(uid); 491 OPimTodo to = m_todoMgr.event(uid);
494 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) 492 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) )
495 return; 493 return;
496 494
497 handleAlarms(to, OTodo() ); 495 handleAlarms(to, OPimTodo() );
498 m_todoMgr.remove( to.uid() ); 496 m_todoMgr.remove( to.uid() );
499 currentView()->removeEvent( to.uid() ); 497 currentView()->removeEvent( to.uid() );
500 raiseCurrentView(); 498 raiseCurrentView();
501} 499}
502void MainWindow::slotDeleteAll() { 500void MainWindow::slotDeleteAll() {
503 if(m_syncing) { 501 if(m_syncing) {
504 QMessageBox::warning(this, QWidget::tr("Todo"), 502 QMessageBox::warning(this, QWidget::tr("Todo"),
505 QWidget::tr("Data can not be edited, currently syncing")); 503 QWidget::tr("Data can not be edited, currently syncing"));
506 return; 504 return;
507 } 505 }
508 506
509 507
@@ -588,38 +586,38 @@ void MainWindow::setDocument( const QString& fi) {
588 receiveFile(fi ); 586 receiveFile(fi );
589} 587}
590 588
591static const char *beamfile = "/tmp/opie-todo.vcs"; 589static const char *beamfile = "/tmp/opie-todo.vcs";
592void MainWindow::slotBeam() { 590void MainWindow::slotBeam() {
593 beam( currentView()->current() ); 591 beam( currentView()->current() );
594} 592}
595void MainWindow::beamDone( Ir* ir) { 593void MainWindow::beamDone( Ir* ir) {
596 delete ir; 594 delete ir;
597 ::unlink( beamfile ); 595 ::unlink( beamfile );
598} 596}
599void MainWindow::receiveFile( const QString& filename ) { 597void MainWindow::receiveFile( const QString& filename ) {
600 OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); 598 OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename );
601 599
602 OTodoAccess acc( cal ); 600 OPimTodoAccess acc( cal );
603 acc.load(); 601 acc.load();
604 OTodoAccess::List list = acc.allRecords(); 602 OPimTodoAccess::List list = acc.allRecords();
605 603
606 if (list.count()){ 604 if (list.count()){
607 605
608 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); 606 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
609 607
610 if ( QMessageBox::information(this, QWidget::tr("New Tasks"), 608 if ( QMessageBox::information(this, QWidget::tr("New Tasks"),
611 message, QMessageBox::Ok, 609 message, QMessageBox::Ok,
612 QMessageBox::Cancel ) == QMessageBox::Ok ) { 610 QMessageBox::Cancel ) == QMessageBox::Ok ) {
613 OTodoAccess::List::Iterator it; 611 OPimTodoAccess::List::Iterator it;
614 for ( it = list.begin(); it != list.end(); ++it ) 612 for ( it = list.begin(); it != list.end(); ++it )
615 m_todoMgr.add( (*it) ); 613 m_todoMgr.add( (*it) );
616 614
617 currentView()->updateView(); 615 currentView()->updateView();
618 } 616 }
619 } 617 }
620} 618}
621 619
622void MainWindow::slotFlush() { 620void MainWindow::slotFlush() {
623 m_syncing = TRUE; 621 m_syncing = TRUE;
624 m_todoMgr.save(); 622 m_todoMgr.save();
625} 623}
@@ -699,99 +697,99 @@ void MainWindow::slotShowPrev() {
699 int l = currentView()->prev(); 697 int l = currentView()->prev();
700 if (l!=0) 698 if (l!=0)
701 slotShow(l); 699 slotShow(l);
702} 700}
703void MainWindow::slotEdit( int uid ) { 701void MainWindow::slotEdit( int uid ) {
704 if (uid == 0 ) return; 702 if (uid == 0 ) return;
705 if(m_syncing) { 703 if(m_syncing) {
706 QMessageBox::warning(this, QWidget::tr("Todo"), 704 QMessageBox::warning(this, QWidget::tr("Todo"),
707 QWidget::tr("Data can't be edited, currently syncing")); 705 QWidget::tr("Data can't be edited, currently syncing"));
708 return; 706 return;
709 } 707 }
710 708
711 OTodo old_todo = m_todoMgr.event( uid ); 709 OPimTodo old_todo = m_todoMgr.event( uid );
712 710
713 OTodo todo = currentEditor()->edit(this, old_todo ); 711 OPimTodo todo = currentEditor()->edit(this, old_todo );
714 712
715 /* if completed */ 713 /* if completed */
716 if ( currentEditor()->accepted() ) { 714 if ( currentEditor()->accepted() ) {
717 handleAlarms( old_todo, todo ); 715 handleAlarms( old_todo, todo );
718 m_todoMgr.update( todo.uid(), todo ); 716 m_todoMgr.update( todo.uid(), todo );
719 currentView()->replaceEvent( todo ); 717 currentView()->replaceEvent( todo );
720 /* a Category might have changed */ 718 /* a Category might have changed */
721 populateCategories(); 719 populateCategories();
722 } 720 }
723 721
724 raiseCurrentView(); 722 raiseCurrentView();
725} 723}
726/* 724/*
727void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 725void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
728 m_todoMgr.update( uid, ev ); 726 m_todoMgr.update( uid, ev );
729} 727}
730*/ 728*/
731void MainWindow::updateTodo( const OTodo& ev) { 729void MainWindow::updateTodo( const OPimTodo& ev) {
732 m_todoMgr.update( ev.uid() , ev ); 730 m_todoMgr.update( ev.uid() , ev );
733} 731}
734/* The view changed it's configuration 732/* The view changed it's configuration
735 * update the view menu 733 * update the view menu
736 */ 734 */
737void MainWindow::slotUpdate3( QWidget* ) { 735void MainWindow::slotUpdate3( QWidget* ) {
738 736
739} 737}
740void MainWindow::updateList() { 738void MainWindow::updateList() {
741 m_todoMgr.updateList(); 739 m_todoMgr.updateList();
742} 740}
743void MainWindow::setReadAhead( uint count ) { 741void MainWindow::setReadAhead( uint count ) {
744 if (m_todoMgr.todoDB() ) 742 if (m_todoMgr.todoDB() )
745 m_todoMgr.todoDB()->setReadAhead( count ); 743 m_todoMgr.todoDB()->setReadAhead( count );
746} 744}
747void MainWindow::slotQuickEntered() { 745void MainWindow::slotQuickEntered() {
748 qWarning("entered"); 746 qWarning("entered");
749 OTodo todo = quickEditor()->todo(); 747 OPimTodo todo = quickEditor()->todo();
750 if (todo.isEmpty() ) 748 if (todo.isEmpty() )
751 return; 749 return;
752 750
753 m_todoMgr.add( todo ); 751 m_todoMgr.add( todo );
754 currentView()->addEvent( todo ); 752 currentView()->addEvent( todo );
755 raiseCurrentView(); 753 raiseCurrentView();
756} 754}
757QuickEditBase* MainWindow::quickEditor() { 755QuickEditBase* MainWindow::quickEditor() {
758 return m_curQuick; 756 return m_curQuick;
759} 757}
760void MainWindow::slotComplete( int uid ) { 758void MainWindow::slotComplete( int uid ) {
761 slotComplete( event(uid) ); 759 slotComplete( event(uid) );
762} 760}
763void MainWindow::slotComplete( const OTodo& todo ) { 761void MainWindow::slotComplete( const OPimTodo& todo ) {
764 OTodo to = todo; 762 OPimTodo to = todo;
765 to.setCompleted( !to.isCompleted() ); 763 to.setCompleted( !to.isCompleted() );
766 to.setCompletedDate( QDate::currentDate() ); 764 to.setCompletedDate( QDate::currentDate() );
767 765
768 /* 766 /*
769 * if the item does recur 767 * if the item does recur
770 * we need to spin it off 768 * we need to spin it off
771 * and update the items duedate to the next 769 * and update the items duedate to the next
772 * possible recurrance of this item... 770 * possible recurrance of this item...
773 * the spinned off one will loose the 771 * the spinned off one will loose the
774 * recurrence. 772 * recurrence.
775 * We calculate the difference between the old due date and the 773 * We calculate the difference between the old due date and the
776 * new one and add this diff to start, completed and alarm dates 774 * new one and add this diff to start, completed and alarm dates
777 * -zecke 775 * -zecke
778 */ 776 */
779 if ( to.hasRecurrence() && to.isCompleted() ) { 777 if ( to.hasRecurrence() && to.isCompleted() ) {
780 OTodo to2( to ); 778 OPimTodo to2( to );
781 779
782 /* the spinned off one won't recur anymore */ 780 /* the spinned off one won't recur anymore */
783 to.setRecurrence( ORecur() ); 781 to.setRecurrence( OPimRecurrence() );
784 782
785 ORecur rec = to2.recurrence(); 783 OPimRecurrence rec = to2.recurrence();
786 rec.setStart( to.dueDate() ); 784 rec.setStart( to.dueDate() );
787 to2.setRecurrence( rec ); 785 to2.setRecurrence( rec );
788 /* 786 /*
789 * if there is a next occurence 787 * if there is a next occurence
790 * from the duedate of the last recurrance 788 * from the duedate of the last recurrance
791 */ 789 */
792 QDate date; 790 QDate date;
793 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { 791 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) {
794 int dayDiff = to.dueDate().daysTo( date ); 792 int dayDiff = to.dueDate().daysTo( date );
795 qWarning("day diff is %d", dayDiff ); 793 qWarning("day diff is %d", dayDiff );
796 QDate inval; 794 QDate inval;
797 /* generate a new uid for the old record */ 795 /* generate a new uid for the old record */
@@ -816,25 +814,25 @@ void MainWindow::slotComplete( const OTodo& todo ) {
816 /* now the alarms */ 814 /* now the alarms */
817 if (to2.hasNotifiers() ) { 815 if (to2.hasNotifiers() ) {
818 OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); 816 OPimNotifyManager::Alarms _als = to2.notifiers().alarms();
819 OPimNotifyManager::Alarms als; 817 OPimNotifyManager::Alarms als;
820 818
821 /* for every alarm move the day */ 819 /* for every alarm move the day */
822 for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { 820 for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) {
823 OPimAlarm al = (*it); 821 OPimAlarm al = (*it);
824 al.setDateTime( al.dateTime().addDays( dayDiff ) ); 822 al.setDateTime( al.dateTime().addDays( dayDiff ) );
825 als.append( al ); 823 als.append( al );
826 } 824 }
827 to2.notifiers().setAlarms( als ); 825 to2.notifiers().setAlarms( als );
828 handleAlarms( OTodo(), todo ); 826 handleAlarms( OPimTodo(), todo );
829 } 827 }
830 to2.setCompletedDate( inval ); 828 to2.setCompletedDate( inval );
831 to2.setCompleted( false ); 829 to2.setCompleted( false );
832 830
833 updateTodo( to2 ); 831 updateTodo( to2 );
834 }else 832 }else
835 updateTodo( to ); 833 updateTodo( to );
836 }else 834 }else
837 updateTodo( to ); 835 updateTodo( to );
838 836
839 currentView()->updateView(); 837 currentView()->updateView();
840 raiseCurrentView(); 838 raiseCurrentView();
@@ -846,86 +844,86 @@ void MainWindow::reload() {
846 slotReload(); 844 slotReload();
847} 845}
848int MainWindow::create() { 846int MainWindow::create() {
849 int uid = 0; 847 int uid = 0;
850 if(m_syncing) { 848 if(m_syncing) {
851 QMessageBox::warning(this, QWidget::tr("Todo"), 849 QMessageBox::warning(this, QWidget::tr("Todo"),
852 QWidget::tr("Data can not be edited, currently syncing")); 850 QWidget::tr("Data can not be edited, currently syncing"));
853 return uid; 851 return uid;
854 } 852 }
855 m_todoMgr.load(); 853 m_todoMgr.load();
856 854
857 855
858 OTodo todo = currentEditor()->newTodo( currentCatId(), 856 OPimTodo todo = currentEditor()->newTodo( currentCatId(),
859 this ); 857 this );
860 858
861 if ( currentEditor()->accepted() ) { 859 if ( currentEditor()->accepted() ) {
862 //todo.assignUid(); 860 //todo.assignUid();
863 uid = todo.uid(); 861 uid = todo.uid();
864 handleAlarms( OTodo(), todo ); 862 handleAlarms( OPimTodo(), todo );
865 m_todoMgr.add( todo ); 863 m_todoMgr.add( todo );
866 currentView()->addEvent( todo ); 864 currentView()->addEvent( todo );
867 865
868 866
869 // I'm afraid we must call this every time now, otherwise 867 // I'm afraid we must call this every time now, otherwise
870 // spend expensive time comparing all these strings... 868 // spend expensive time comparing all these strings...
871 // but only call if we changed something -zecke 869 // but only call if we changed something -zecke
872 populateCategories(); 870 populateCategories();
873 } 871 }
874 raiseCurrentView( ); 872 raiseCurrentView( );
875 873
876 return uid; 874 return uid;
877} 875}
878/* delete it silently... */ 876/* delete it silently... */
879bool MainWindow::remove( int uid ) { 877bool MainWindow::remove( int uid ) {
880 if (m_syncing) return false; 878 if (m_syncing) return false;
881 879
882 /* argh need to get the whole OEvent... to disable alarms -zecke */ 880 /* argh need to get the whole OEvent... to disable alarms -zecke */
883 handleAlarms( OTodo(), m_todoMgr.event( uid ) ); 881 handleAlarms( OPimTodo(), m_todoMgr.event( uid ) );
884 882
885 return m_todoMgr.remove( uid ); 883 return m_todoMgr.remove( uid );
886} 884}
887void MainWindow::beam( int uid) { 885void MainWindow::beam( int uid) {
888 if( uid == 0 ) return; 886 if( uid == 0 ) return;
889 887
890 ::unlink( beamfile ); 888 ::unlink( beamfile );
891 m_todoMgr.load(); 889 m_todoMgr.load();
892 890
893 OTodo todo = event( uid ); 891 OPimTodo todo = event( uid );
894 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); 892 OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(QString::fromLatin1(beamfile) );
895 OTodoAccess acc( cal ); 893 OPimTodoAccess acc( cal );
896 acc.load(); 894 acc.load();
897 acc.add( todo ); 895 acc.add( todo );
898 acc.save(); 896 acc.save();
899 Ir* ir = new Ir(this ); 897 Ir* ir = new Ir(this );
900 connect(ir, SIGNAL(done(Ir*) ), 898 connect(ir, SIGNAL(done(Ir*) ),
901 this, SLOT(beamDone(Ir*) ) ); 899 this, SLOT(beamDone(Ir*) ) );
902 ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); 900 ir->send(beamfile, todo.summary(), "text/x-vCalendar" );
903} 901}
904void MainWindow::show( int uid ) { 902void MainWindow::show( int uid ) {
905 m_todoMgr.load(); // might not be loaded yet 903 m_todoMgr.load(); // might not be loaded yet
906 m_showing = true; 904 m_showing = true;
907 slotShow( uid ); 905 slotShow( uid );
908 raise(); 906 raise();
909 QPEApplication::setKeepRunning(); 907 QPEApplication::setKeepRunning();
910} 908}
911void MainWindow::edit( int uid ) { 909void MainWindow::edit( int uid ) {
912 m_todoMgr.load(); 910 m_todoMgr.load();
913 slotEdit( uid ); 911 slotEdit( uid );
914} 912}
915void MainWindow::add( const OPimRecord& rec) { 913void MainWindow::add( const OPimRecord& rec) {
916 if ( rec.rtti() != OTodo::rtti() ) return; 914 if ( rec.rtti() != OPimTodo::rtti() ) return;
917 m_todoMgr.load(); // might not be loaded 915 m_todoMgr.load(); // might not be loaded
918 916
919 const OTodo& todo = static_cast<const OTodo&>(rec); 917 const OPimTodo& todo = static_cast<const OPimTodo&>(rec);
920 918
921 m_todoMgr.add(todo ); 919 m_todoMgr.add(todo );
922 currentView()->addEvent( todo ); 920 currentView()->addEvent( todo );
923 921
924 922
925 // I'm afraid we must call this every time now, otherwise 923 // I'm afraid we must call this every time now, otherwise
926 // spend expensive time comparing all these strings... 924 // spend expensive time comparing all these strings...
927 // but only call if we changed something -zecke 925 // but only call if we changed something -zecke
928 populateCategories(); 926 populateCategories();
929} 927}
930void MainWindow::slotReturnFromView() { 928void MainWindow::slotReturnFromView() {
931 m_showing = false; 929 m_showing = false;
@@ -960,25 +958,25 @@ namespace {
960 } 958 }
961 959
962 } 960 }
963 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { 961 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
964 OPimNotifyManager::Alarms::ConstIterator it; 962 OPimNotifyManager::Alarms::ConstIterator it;
965 for ( it = als.begin(); it != als.end(); ++it ) { 963 for ( it = als.begin(); it != als.end(); ++it ) {
966 qWarning("Removinf alarm for %s", (*it).dateTime().toString().latin1() ); 964 qWarning("Removinf alarm for %s", (*it).dateTime().toString().latin1() );
967 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); 965 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
968 } 966 }
969 } 967 }
970} 968}
971 969
972void MainWindow::handleAlarms( const OTodo& oldTodo, const OTodo& newTodo) { 970void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) {
973 /* 971 /*
974 * if oldTodo is not empty and has notifiers we need to find the deleted ones 972 * if oldTodo is not empty and has notifiers we need to find the deleted ones
975 */ 973 */
976 if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { 974 if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) {
977 OPimNotifyManager::Alarms removed; 975 OPimNotifyManager::Alarms removed;
978 OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); 976 OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms();
979 if (!newTodo.hasNotifiers() ) 977 if (!newTodo.hasNotifiers() )
980 removed = oldAls; 978 removed = oldAls;
981 else 979 else
982 removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); 980 removed = findNonMatching( oldAls, newTodo.notifiers().alarms() );
983 981
984 removeAlarms( removed, oldTodo.uid() ); 982 removeAlarms( removed, oldTodo.uid() );
@@ -988,25 +986,25 @@ void MainWindow::handleAlarms( const OTodo& oldTodo, const OTodo& newTodo) {
988 if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) 986 if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() )
989 added = newTodo.notifiers().alarms(); 987 added = newTodo.notifiers().alarms();
990 else 988 else
991 added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); 989 added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() );
992 990
993 addAlarms( added, newTodo.uid() ); 991 addAlarms( added, newTodo.uid() );
994 } 992 }
995} 993}
996/* we might have not loaded the db */ 994/* we might have not loaded the db */
997void MainWindow::doAlarm( const QDateTime& dt, int uid ) { 995void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
998 m_todoMgr.load(); 996 m_todoMgr.load();
999 997
1000 OTodo todo = m_todoMgr.event( uid ); 998 OPimTodo todo = m_todoMgr.event( uid );
1001 if (!todo.hasNotifiers() ) return; 999 if (!todo.hasNotifiers() ) return;
1002 1000
1003 /* 1001 /*
1004 * let's find the right alarm and find out if silent 1002 * let's find the right alarm and find out if silent
1005 * then show a richtext widget 1003 * then show a richtext widget
1006 */ 1004 */
1007 bool loud = false; 1005 bool loud = false;
1008 OPimNotifyManager::Alarms als = todo.notifiers().alarms(); 1006 OPimNotifyManager::Alarms als = todo.notifiers().alarms();
1009 OPimNotifyManager::Alarms::Iterator it; 1007 OPimNotifyManager::Alarms::Iterator it;
1010 for ( it = als.begin(); it != als.end(); ++it ) { 1008 for ( it = als.begin(); it != als.end(); ++it ) {
1011 if ( (*it).dateTime() == dt ) { 1009 if ( (*it).dateTime() == dt ) {
1012 loud = ( (*it).sound() == OPimAlarm::Loud ); 1010 loud = ( (*it).sound() == OPimAlarm::Loud );