summaryrefslogtreecommitdiff
authoreilers <eilers>2004-04-28 09:23:28 (UTC)
committer eilers <eilers>2004-04-28 09:23:28 (UTC)
commit8af6d533817ddc490c9d19344c7f0fa83239831e (patch) (unidiff)
treee25fcc93a4949f32e389aad8212051c093108b1a
parent134b7accd6bdc8fbc160a42f7c52c585e73f4add (diff)
downloadopie-8af6d533817ddc490c9d19344c7f0fa83239831e.zip
opie-8af6d533817ddc490c9d19344c7f0fa83239831e.tar.gz
opie-8af6d533817ddc490c9d19344c7f0fa83239831e.tar.bz2
Removed static cast which is not working with the new modifications of
the opie-pim api
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 924fde1..2002e87 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -785,257 +785,258 @@ void MainWindow::slotComplete( const OPimTodo& todo ) {
785 /* 785 /*
786 * if there is a next occurence 786 * if there is a next occurence
787 * from the duedate of the last recurrance 787 * from the duedate of the last recurrance
788 */ 788 */
789 QDate date; 789 QDate date;
790 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { 790 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) {
791 int dayDiff = to.dueDate().daysTo( date ); 791 int dayDiff = to.dueDate().daysTo( date );
792 owarn << "day diff is " << dayDiff << oendl; 792 owarn << "day diff is " << dayDiff << oendl;
793 QDate inval; 793 QDate inval;
794 /* generate a new uid for the old record */ 794 /* generate a new uid for the old record */
795 to.setUid( 1 ); 795 to.setUid( 1 );
796 796
797 /* add the old one cause it has a new UID here cause it was spin off */ 797 /* add the old one cause it has a new UID here cause it was spin off */
798 m_todoMgr.add( to ); 798 m_todoMgr.add( to );
799 799
800 /* 800 /*
801 * update the due date 801 * update the due date
802 * start date 802 * start date
803 * and complete date 803 * and complete date
804 */ 804 */
805 to2.setDueDate( date ); 805 to2.setDueDate( date );
806 rec.setStart( date ); 806 rec.setStart( date );
807 to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week 807 to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week
808 808
809 /* move start date */ 809 /* move start date */
810 if (to2.hasStartDate() ) 810 if (to2.hasStartDate() )
811 to2.setStartDate( to2.startDate().addDays( dayDiff ) ); 811 to2.setStartDate( to2.startDate().addDays( dayDiff ) );
812 812
813 /* now the alarms */ 813 /* now the alarms */
814 if (to2.hasNotifiers() ) { 814 if (to2.hasNotifiers() ) {
815 OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); 815 OPimNotifyManager::Alarms _als = to2.notifiers().alarms();
816 OPimNotifyManager::Alarms als; 816 OPimNotifyManager::Alarms als;
817 817
818 /* for every alarm move the day */ 818 /* for every alarm move the day */
819 for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { 819 for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) {
820 OPimAlarm al = (*it); 820 OPimAlarm al = (*it);
821 al.setDateTime( al.dateTime().addDays( dayDiff ) ); 821 al.setDateTime( al.dateTime().addDays( dayDiff ) );
822 als.append( al ); 822 als.append( al );
823 } 823 }
824 to2.notifiers().setAlarms( als ); 824 to2.notifiers().setAlarms( als );
825 handleAlarms( OPimTodo(), todo ); 825 handleAlarms( OPimTodo(), todo );
826 } 826 }
827 to2.setCompletedDate( inval ); 827 to2.setCompletedDate( inval );
828 to2.setCompleted( false ); 828 to2.setCompleted( false );
829 829
830 updateTodo( to2 ); 830 updateTodo( to2 );
831 }else 831 }else
832 updateTodo( to ); 832 updateTodo( to );
833 }else 833 }else
834 updateTodo( to ); 834 updateTodo( to );
835 835
836 currentView()->updateView(); 836 currentView()->updateView();
837 raiseCurrentView(); 837 raiseCurrentView();
838} 838}
839void MainWindow::flush() { 839void MainWindow::flush() {
840 slotFlush(); 840 slotFlush();
841} 841}
842void MainWindow::reload() { 842void MainWindow::reload() {
843 slotReload(); 843 slotReload();
844} 844}
845int MainWindow::create() { 845int MainWindow::create() {
846 int uid = 0; 846 int uid = 0;
847 if(m_syncing) { 847 if(m_syncing) {
848 QMessageBox::warning(this, QWidget::tr("Todo"), 848 QMessageBox::warning(this, QWidget::tr("Todo"),
849 QWidget::tr("Data can not be edited, currently syncing")); 849 QWidget::tr("Data can not be edited, currently syncing"));
850 return uid; 850 return uid;
851 } 851 }
852 m_todoMgr.load(); 852 m_todoMgr.load();
853 853
854 854
855 OPimTodo todo = currentEditor()->newTodo( currentCatId(), 855 OPimTodo todo = currentEditor()->newTodo( currentCatId(),
856 this ); 856 this );
857 857
858 if ( currentEditor()->accepted() ) { 858 if ( currentEditor()->accepted() ) {
859 //todo.assignUid(); 859 //todo.assignUid();
860 uid = todo.uid(); 860 uid = todo.uid();
861 handleAlarms( OPimTodo(), todo ); 861 handleAlarms( OPimTodo(), todo );
862 m_todoMgr.add( todo ); 862 m_todoMgr.add( todo );
863 currentView()->addEvent( todo ); 863 currentView()->addEvent( todo );
864 864
865 865
866 // I'm afraid we must call this every time now, otherwise 866 // I'm afraid we must call this every time now, otherwise
867 // spend expensive time comparing all these strings... 867 // spend expensive time comparing all these strings...
868 // but only call if we changed something -zecke 868 // but only call if we changed something -zecke
869 populateCategories(); 869 populateCategories();
870 } 870 }
871 raiseCurrentView( ); 871 raiseCurrentView( );
872 872
873 return uid; 873 return uid;
874} 874}
875/* delete it silently... */ 875/* delete it silently... */
876bool MainWindow::remove( int uid ) { 876bool MainWindow::remove( int uid ) {
877 if (m_syncing) return false; 877 if (m_syncing) return false;
878 878
879 /* argh need to get the whole OEvent... to disable alarms -zecke */ 879 /* argh need to get the whole OEvent... to disable alarms -zecke */
880 handleAlarms( OPimTodo(), m_todoMgr.event( uid ) ); 880 handleAlarms( OPimTodo(), m_todoMgr.event( uid ) );
881 881
882 return m_todoMgr.remove( uid ); 882 return m_todoMgr.remove( uid );
883} 883}
884void MainWindow::beam( int uid) { 884void MainWindow::beam( int uid) {
885 if( uid == 0 ) return; 885 if( uid == 0 ) return;
886 886
887 ::unlink( beamfile ); 887 ::unlink( beamfile );
888 m_todoMgr.load(); 888 m_todoMgr.load();
889 889
890 OPimTodo todo = event( uid ); 890 OPimTodo todo = event( uid );
891 OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(QString::fromLatin1(beamfile) ); 891 OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(QString::fromLatin1(beamfile) );
892 OPimTodoAccess acc( cal ); 892 OPimTodoAccess acc( cal );
893 acc.load(); 893 acc.load();
894 acc.add( todo ); 894 acc.add( todo );
895 acc.save(); 895 acc.save();
896 Ir* ir = new Ir(this ); 896 Ir* ir = new Ir(this );
897 connect(ir, SIGNAL(done(Ir*) ), 897 connect(ir, SIGNAL(done(Ir*) ),
898 this, SLOT(beamDone(Ir*) ) ); 898 this, SLOT(beamDone(Ir*) ) );
899 ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); 899 ir->send(beamfile, todo.summary(), "text/x-vCalendar" );
900} 900}
901void MainWindow::show( int uid ) { 901void MainWindow::show( int uid ) {
902 m_todoMgr.load(); // might not be loaded yet 902 m_todoMgr.load(); // might not be loaded yet
903 m_showing = true; 903 m_showing = true;
904 slotShow( uid ); 904 slotShow( uid );
905 raise(); 905 raise();
906 QPEApplication::setKeepRunning(); 906 QPEApplication::setKeepRunning();
907} 907}
908void MainWindow::edit( int uid ) { 908void MainWindow::edit( int uid ) {
909 m_todoMgr.load(); 909 m_todoMgr.load();
910 slotEdit( uid ); 910 slotEdit( uid );
911} 911}
912void MainWindow::add( const OPimRecord& rec) { 912void MainWindow::add( const OPimRecord& rec) {
913 if ( rec.rtti() != OPimTodo::rtti() ) return; 913 OPimTodo test;
914 if ( rec.rtti() != test.rtti() ) return;
914 m_todoMgr.load(); // might not be loaded 915 m_todoMgr.load(); // might not be loaded
915 916
916 const OPimTodo& todo = static_cast<const OPimTodo&>(rec); 917 const OPimTodo& todo = static_cast<const OPimTodo&>(rec);
917 918
918 m_todoMgr.add(todo ); 919 m_todoMgr.add(todo );
919 currentView()->addEvent( todo ); 920 currentView()->addEvent( todo );
920 921
921 922
922 // I'm afraid we must call this every time now, otherwise 923 // I'm afraid we must call this every time now, otherwise
923 // spend expensive time comparing all these strings... 924 // spend expensive time comparing all these strings...
924 // but only call if we changed something -zecke 925 // but only call if we changed something -zecke
925 populateCategories(); 926 populateCategories();
926} 927}
927void MainWindow::slotReturnFromView() { 928void MainWindow::slotReturnFromView() {
928 m_showing = false; 929 m_showing = false;
929 raiseCurrentView(); 930 raiseCurrentView();
930} 931}
931 932
932namespace { 933namespace {
933 OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls, 934 OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls,
934 const OPimNotifyManager::Alarms& newAls ) { 935 const OPimNotifyManager::Alarms& newAls ) {
935 OPimNotifyManager::Alarms nonMatching; 936 OPimNotifyManager::Alarms nonMatching;
936 OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin(); 937 OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin();
937 OPimNotifyManager::Alarms::ConstIterator newIt; 938 OPimNotifyManager::Alarms::ConstIterator newIt;
938 for ( ; oldIt != oldAls.end(); ++oldIt ) { 939 for ( ; oldIt != oldAls.end(); ++oldIt ) {
939 bool found = false; 940 bool found = false;
940 QDateTime oldDt = (*oldIt).dateTime(); 941 QDateTime oldDt = (*oldIt).dateTime();
941 for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) { 942 for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) {
942 if ( oldDt == (*newIt).dateTime() ) { 943 if ( oldDt == (*newIt).dateTime() ) {
943 found = true; 944 found = true;
944 break; 945 break;
945 } 946 }
946 } 947 }
947 if (!found) 948 if (!found)
948 nonMatching.append( (*oldIt) ); 949 nonMatching.append( (*oldIt) );
949 } 950 }
950 return nonMatching; 951 return nonMatching;
951 } 952 }
952 void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { 953 void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
953 OPimNotifyManager::Alarms::ConstIterator it; 954 OPimNotifyManager::Alarms::ConstIterator it;
954 for ( it = als.begin(); it != als.end(); ++it ) { 955 for ( it = als.begin(); it != als.end(); ++it ) {
955 owarn << "Adding alarm for " << (*it).dateTime().toString() << oendl; 956 owarn << "Adding alarm for " << (*it).dateTime().toString() << oendl;
956 AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); 957 AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
957 } 958 }
958 959
959 } 960 }
960 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { 961 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
961 OPimNotifyManager::Alarms::ConstIterator it; 962 OPimNotifyManager::Alarms::ConstIterator it;
962 for ( it = als.begin(); it != als.end(); ++it ) { 963 for ( it = als.begin(); it != als.end(); ++it ) {
963 owarn << "Removinf alarm for " << (*it).dateTime().toString() << oendl; 964 owarn << "Removinf alarm for " << (*it).dateTime().toString() << oendl;
964 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); 965 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
965 } 966 }
966 } 967 }
967} 968}
968 969
969void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) { 970void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) {
970 /* 971 /*
971 * 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
972 */ 973 */
973 if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { 974 if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) {
974 OPimNotifyManager::Alarms removed; 975 OPimNotifyManager::Alarms removed;
975 OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); 976 OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms();
976 if (!newTodo.hasNotifiers() ) 977 if (!newTodo.hasNotifiers() )
977 removed = oldAls; 978 removed = oldAls;
978 else 979 else
979 removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); 980 removed = findNonMatching( oldAls, newTodo.notifiers().alarms() );
980 981
981 removeAlarms( removed, oldTodo.uid() ); 982 removeAlarms( removed, oldTodo.uid() );
982 } 983 }
983 if ( newTodo.hasNotifiers() ) { 984 if ( newTodo.hasNotifiers() ) {
984 OPimNotifyManager::Alarms added; 985 OPimNotifyManager::Alarms added;
985 if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) 986 if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() )
986 added = newTodo.notifiers().alarms(); 987 added = newTodo.notifiers().alarms();
987 else 988 else
988 added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); 989 added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() );
989 990
990 addAlarms( added, newTodo.uid() ); 991 addAlarms( added, newTodo.uid() );
991 } 992 }
992} 993}
993/* we might have not loaded the db */ 994/* we might have not loaded the db */
994void MainWindow::doAlarm( const QDateTime& dt, int uid ) { 995void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
995 m_todoMgr.load(); 996 m_todoMgr.load();
996 997
997 OPimTodo todo = m_todoMgr.event( uid ); 998 OPimTodo todo = m_todoMgr.event( uid );
998 if (!todo.hasNotifiers() ) return; 999 if (!todo.hasNotifiers() ) return;
999 1000
1000 /* 1001 /*
1001 * let's find the right alarm and find out if silent 1002 * let's find the right alarm and find out if silent
1002 * then show a richtext widget 1003 * then show a richtext widget
1003 */ 1004 */
1004 bool loud = false; 1005 bool loud = false;
1005 OPimNotifyManager::Alarms als = todo.notifiers().alarms(); 1006 OPimNotifyManager::Alarms als = todo.notifiers().alarms();
1006 OPimNotifyManager::Alarms::Iterator it; 1007 OPimNotifyManager::Alarms::Iterator it;
1007 for ( it = als.begin(); it != als.end(); ++it ) { 1008 for ( it = als.begin(); it != als.end(); ++it ) {
1008 if ( (*it).dateTime() == dt ) { 1009 if ( (*it).dateTime() == dt ) {
1009 loud = ( (*it).sound() == OPimAlarm::Loud ); 1010 loud = ( (*it).sound() == OPimAlarm::Loud );
1010 break; 1011 break;
1011 } 1012 }
1012 } 1013 }
1013 if (loud) 1014 if (loud)
1014 startAlarm(); 1015 startAlarm();
1015 1016
1016 QDialog dlg(this, 0, TRUE ); 1017 QDialog dlg(this, 0, TRUE );
1017 QVBoxLayout* lay = new QVBoxLayout( &dlg ); 1018 QVBoxLayout* lay = new QVBoxLayout( &dlg );
1018 QTextView* view = new QTextView( &dlg ); 1019 QTextView* view = new QTextView( &dlg );
1019 lay->addWidget( view ); 1020 lay->addWidget( view );
1020 QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg ); 1021 QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg );
1021 connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) ); 1022 connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) );
1022 lay->addWidget( btnOk ); 1023 lay->addWidget( btnOk );
1023 1024
1024 QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) ); 1025 QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) );
1025 text += todo.toRichText(); 1026 text += todo.toRichText();
1026 view->setText( text ); 1027 view->setText( text );
1027 1028
1028 bool needToStay = QPEApplication::execDialog( &dlg ); 1029 bool needToStay = QPEApplication::execDialog( &dlg );
1029 1030
1030 if (loud) 1031 if (loud)
1031 killAlarm(); 1032 killAlarm();
1032 1033
1033 if (needToStay) { 1034 if (needToStay) {
1034// showMaximized(); 1035// showMaximized();
1035// raise(); 1036// raise();
1036 QPEApplication::setKeepRunning(); 1037 QPEApplication::setKeepRunning();
1037// setActiveWindow(); 1038// setActiveWindow();
1038 } 1039 }
1039 1040
1040} 1041}
1041 1042