summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-08-23 12:55:50 (UTC)
committer zautrix <zautrix>2005-08-23 12:55:50 (UTC)
commit72d600e2c3b3405e5f37615a56560811c0cf9a78 (patch) (unidiff)
tree0f3eeb3ae34822149ba8b6d62990725e59a29187 /korganizer
parente34e096c0e1b799904643c753591833f3ff2ab95 (diff)
downloadkdepimpi-72d600e2c3b3405e5f37615a56560811c0cf9a78.zip
kdepimpi-72d600e2c3b3405e5f37615a56560811c0cf9a78.tar.gz
kdepimpi-72d600e2c3b3405e5f37615a56560811c0cf9a78.tar.bz2
kopi load change
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp4
-rw-r--r--korganizer/kotodoview.cpp5
-rw-r--r--korganizer/main.cpp4
-rw-r--r--korganizer/mainwindow.cpp64
-rw-r--r--korganizer/mainwindow.h6
5 files changed, 61 insertions, 22 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index e3b62de..9928b48 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -858,3074 +858,3074 @@ void CalendarView::checkAlarms()
858 QDateTime latest = dt.addSecs ( secs ); 858 QDateTime latest = dt.addSecs ( secs );
859 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 859 qDebug("KO: Last termination on %s ", latest.toString().latin1());
860 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 860 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
861 QPtrList<Incidence> el = mCalendar->rawIncidences(); 861 QPtrList<Incidence> el = mCalendar->rawIncidences();
862 QPtrList<Incidence> al; 862 QPtrList<Incidence> al;
863 Incidence* inL = el.first(); 863 Incidence* inL = el.first();
864 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 864 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
865 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 865 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
866 while ( inL ) { 866 while ( inL ) {
867 bool ok = false; 867 bool ok = false;
868 int offset = 0; 868 int offset = 0;
869 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 869 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
870 if ( ok ) { 870 if ( ok ) {
871 //qDebug("OK %s",next.toString().latin1()); 871 //qDebug("OK %s",next.toString().latin1());
872 if ( next < cur ) { 872 if ( next < cur ) {
873 al.append( inL ); 873 al.append( inL );
874 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 874 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
875 } 875 }
876 } 876 }
877 inL = el.next(); 877 inL = el.next();
878 } 878 }
879 if ( al.count() ) { 879 if ( al.count() ) {
880 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 880 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
881 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 881 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
882 QVBoxLayout* lay = new QVBoxLayout( dia ); 882 QVBoxLayout* lay = new QVBoxLayout( dia );
883 lay->setSpacing( 0 ); 883 lay->setSpacing( 0 );
884 lay->setMargin( 0 ); 884 lay->setMargin( 0 );
885 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 885 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
886 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 886 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
887 lay->addWidget( matb ); 887 lay->addWidget( matb );
888 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 888 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
889 int wid = 210; 889 int wid = 210;
890 int x = QApplication::desktop()->width() - wid - 7; 890 int x = QApplication::desktop()->width() - wid - 7;
891 int y = QApplication::desktop()->height() - wid - 70; 891 int y = QApplication::desktop()->height() - wid - 70;
892 dia->setGeometry ( x,y,wid,wid); 892 dia->setGeometry ( x,y,wid,wid);
893 } else { 893 } else {
894 int si = 220; 894 int si = 220;
895 if ( QApplication::desktop()->width() > 470 ) 895 if ( QApplication::desktop()->width() > 470 )
896 si = 400; 896 si = 400;
897 dia->resize(si,si/2); 897 dia->resize(si,si/2);
898 } 898 }
899 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 899 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
900 dia->show(); 900 dia->show();
901 901
902 } 902 }
903#if 0 903#if 0
904 // for creating timetracker test data 904 // for creating timetracker test data
905 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); 905 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc ");
906 Todo * nt; 906 Todo * nt;
907 mCalendar->close(); 907 mCalendar->close();
908 { 908 {
909 Todo * root1 = new Todo; 909 Todo * root1 = new Todo;
910 mCalendar->addTodo( root1 ); 910 mCalendar->addTodo( root1 );
911 root1->setSummary( "Project1"); 911 root1->setSummary( "Project1");
912 root1->setPriority( 1 ); 912 root1->setPriority( 1 );
913 root1->setCategories( QString( "Cat_Pro1") ); 913 root1->setCategories( QString( "Cat_Pro1") );
914 root1->setDescription( "This is a test description of a root Project" ); 914 root1->setDescription( "This is a test description of a root Project" );
915 root1->setPercentComplete( 20 ); 915 root1->setPercentComplete( 20 );
916 updateView(); 916 updateView();
917 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 917 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
918 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); 918 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) );
919 919
920 nt = new Todo; 920 nt = new Todo;
921 mCalendar->addTodo( nt ); 921 mCalendar->addTodo( nt );
922 nt->setSummary( "Planning Project1"); 922 nt->setSummary( "Planning Project1");
923 nt->setPriority( 1 ); 923 nt->setPriority( 1 );
924 nt->setDescription( "This is a test description of Planning Project1" ); 924 nt->setDescription( "This is a test description of Planning Project1" );
925 nt->setPercentComplete( 20 ); 925 nt->setPercentComplete( 20 );
926 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); 926 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") );
927 927
928 928
929 Todo * sub1 = nt; 929 Todo * sub1 = nt;
930 sub1->setRelatedTo( root1 ); 930 sub1->setRelatedTo( root1 );
931 931
932 nt = new Todo; 932 nt = new Todo;
933 mCalendar->addTodo( nt ); 933 mCalendar->addTodo( nt );
934 nt->setSummary( "Planning Project1: Lutz"); 934 nt->setSummary( "Planning Project1: Lutz");
935 nt->setPriority( 1 ); 935 nt->setPriority( 1 );
936 nt->setDescription( "This todo counts the actual work of a person on a project" ); 936 nt->setDescription( "This todo counts the actual work of a person on a project" );
937 nt->setPercentComplete( 20 ); 937 nt->setPercentComplete( 20 );
938 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); 938 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") );
939 Todo * workLutz11 = nt; 939 Todo * workLutz11 = nt;
940 workLutz11->setRelatedTo( sub1 ); 940 workLutz11->setRelatedTo( sub1 );
941 941
942 nt = new Todo; 942 nt = new Todo;
943 mCalendar->addTodo( nt ); 943 mCalendar->addTodo( nt );
944 nt->setSummary( "Planning Project1: Norbert"); 944 nt->setSummary( "Planning Project1: Norbert");
945 nt->setPriority( 1 ); 945 nt->setPriority( 1 );
946 nt->setDescription( "This todo counts the actual work of a person on a project" ); 946 nt->setDescription( "This todo counts the actual work of a person on a project" );
947 nt->setPercentComplete( 20 ); 947 nt->setPercentComplete( 20 );
948 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); 948 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") );
949 Todo * workNorbert11 = nt; 949 Todo * workNorbert11 = nt;
950 workNorbert11->setRelatedTo( sub1 ); 950 workNorbert11->setRelatedTo( sub1 );
951 951
952 nt = new Todo; 952 nt = new Todo;
953 mCalendar->addTodo( nt ); 953 mCalendar->addTodo( nt );
954 nt->setSummary( "Work on 1"); 954 nt->setSummary( "Work on 1");
955 nt->setPriority( 1 ); 955 nt->setPriority( 1 );
956 nt->setDescription( "This is a test description of Work Project_1" ); 956 nt->setDescription( "This is a test description of Work Project_1" );
957 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); 957 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") );
958 nt->setPercentComplete( 20 ); 958 nt->setPercentComplete( 20 );
959 959
960 Todo * sub2 = nt; 960 Todo * sub2 = nt;
961 sub2->setRelatedTo( root1 ); 961 sub2->setRelatedTo( root1 );
962 962
963 963
964 nt = new Todo; 964 nt = new Todo;
965 mCalendar->addTodo( nt ); 965 mCalendar->addTodo( nt );
966 nt->setSummary( "Work on 1: Lutz"); 966 nt->setSummary( "Work on 1: Lutz");
967 nt->setPriority( 1 ); 967 nt->setPriority( 1 );
968 nt->setDescription( "This todo counts the actual work of a person on a project" ); 968 nt->setDescription( "This todo counts the actual work of a person on a project" );
969 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); 969 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") );
970 nt->setPercentComplete( 20 ); 970 nt->setPercentComplete( 20 );
971 Todo * workLutz12 = nt; 971 Todo * workLutz12 = nt;
972 workLutz12->setRelatedTo( sub2 ); 972 workLutz12->setRelatedTo( sub2 );
973 973
974 nt = new Todo; 974 nt = new Todo;
975 mCalendar->addTodo( nt ); 975 mCalendar->addTodo( nt );
976 nt->setSummary( "Work on 1: Norbert"); 976 nt->setSummary( "Work on 1: Norbert");
977 nt->setPriority( 1 ); 977 nt->setPriority( 1 );
978 nt->setDescription( "This todo counts the actual work of a person on a project" ); 978 nt->setDescription( "This todo counts the actual work of a person on a project" );
979 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); 979 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") );
980 nt->setPercentComplete( 20 ); 980 nt->setPercentComplete( 20 );
981 Todo * workNorbert12 = nt; 981 Todo * workNorbert12 = nt;
982 workNorbert12->setRelatedTo( sub2 ); 982 workNorbert12->setRelatedTo( sub2 );
983 983
984 int secLenRunning = 7200; 984 int secLenRunning = 7200;
985 int secLenPausing = 3600 * 3; 985 int secLenPausing = 3600 * 3;
986 int dayInterval = 1; 986 int dayInterval = 1;
987 //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); 987 //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval );
988 createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); 988 createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 );
989 createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); 989 createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1);
990 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); 990 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3);
991 createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); 991 createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0);
992 createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); 992 createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1);
993 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); 993 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3);
994 createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); 994 createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0);
995 995
996 } 996 }
997 997
998 { 998 {
999 Todo * root1 = new Todo; 999 Todo * root1 = new Todo;
1000 mCalendar->addTodo( root1 ); 1000 mCalendar->addTodo( root1 );
1001 root1->setSummary( "Project2"); 1001 root1->setSummary( "Project2");
1002 root1->setPriority( 1 ); 1002 root1->setPriority( 1 );
1003 root1->setDescription( "This is a test description of a root Project 2" ); 1003 root1->setDescription( "This is a test description of a root Project 2" );
1004 root1->setPercentComplete( 20 ); 1004 root1->setPercentComplete( 20 );
1005 root1->setCategories( QString( "Cat_Pro2") ); 1005 root1->setCategories( QString( "Cat_Pro2") );
1006 updateView(); 1006 updateView();
1007 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 1007 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
1008 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); 1008 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) );
1009 int secLenRunning = 7200; 1009 int secLenRunning = 7200;
1010 int secLenPausing = 3600 * 3; 1010 int secLenPausing = 3600 * 3;
1011 int dayInterval = 1; 1011 int dayInterval = 1;
1012 1012
1013 nt = new Todo; 1013 nt = new Todo;
1014 mCalendar->addTodo( nt ); 1014 mCalendar->addTodo( nt );
1015 nt->setSummary( "Planning Project2"); 1015 nt->setSummary( "Planning Project2");
1016 nt->setPriority( 1 ); 1016 nt->setPriority( 1 );
1017 nt->setDescription( "This is a test description of Planning_Project_2" ); 1017 nt->setDescription( "This is a test description of Planning_Project_2" );
1018 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); 1018 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") );
1019 nt->setPercentComplete( 20 ); 1019 nt->setPercentComplete( 20 );
1020 1020
1021 1021
1022 Todo * sub1 = nt; 1022 Todo * sub1 = nt;
1023 sub1->setRelatedTo( root1 ); 1023 sub1->setRelatedTo( root1 );
1024 1024
1025 nt = new Todo; 1025 nt = new Todo;
1026 mCalendar->addTodo( nt ); 1026 mCalendar->addTodo( nt );
1027 nt->setSummary( "Planning Project2: Lutz"); 1027 nt->setSummary( "Planning Project2: Lutz");
1028 nt->setPriority( 1 ); 1028 nt->setPriority( 1 );
1029 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1029 nt->setDescription( "This todo counts the actual work of a person on a project" );
1030 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); 1030 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") );
1031 nt->setPercentComplete( 20 ); 1031 nt->setPercentComplete( 20 );
1032 Todo * workLutz11 = nt; 1032 Todo * workLutz11 = nt;
1033 workLutz11->setRelatedTo( sub1 ); 1033 workLutz11->setRelatedTo( sub1 );
1034 1034
1035 nt = new Todo; 1035 nt = new Todo;
1036 mCalendar->addTodo( nt ); 1036 mCalendar->addTodo( nt );
1037 nt->setSummary( "Planning Project2: Norbert"); 1037 nt->setSummary( "Planning Project2: Norbert");
1038 nt->setPriority( 1 ); 1038 nt->setPriority( 1 );
1039 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1039 nt->setDescription( "This todo counts the actual work of a person on a project" );
1040 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); 1040 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") );
1041 nt->setPercentComplete( 20 ); 1041 nt->setPercentComplete( 20 );
1042 Todo * workNorbert11 = nt; 1042 Todo * workNorbert11 = nt;
1043 workNorbert11->setRelatedTo( sub1 ); 1043 workNorbert11->setRelatedTo( sub1 );
1044 1044
1045 nt = new Todo; 1045 nt = new Todo;
1046 mCalendar->addTodo( nt ); 1046 mCalendar->addTodo( nt );
1047 nt->setSummary( "Work on 2"); 1047 nt->setSummary( "Work on 2");
1048 nt->setPriority( 1 ); 1048 nt->setPriority( 1 );
1049 nt->setDescription( "This is a test description of Work Project_2" ); 1049 nt->setDescription( "This is a test description of Work Project_2" );
1050 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); 1050 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") );
1051 nt->setPercentComplete( 20 ); 1051 nt->setPercentComplete( 20 );
1052 1052
1053 Todo * sub2 = nt; 1053 Todo * sub2 = nt;
1054 sub2->setRelatedTo( root1 ); 1054 sub2->setRelatedTo( root1 );
1055 1055
1056 1056
1057 nt = new Todo; 1057 nt = new Todo;
1058 mCalendar->addTodo( nt ); 1058 mCalendar->addTodo( nt );
1059 nt->setSummary( "Work on 2: Lutz"); 1059 nt->setSummary( "Work on 2: Lutz");
1060 nt->setPriority( 1 ); 1060 nt->setPriority( 1 );
1061 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1061 nt->setDescription( "This todo counts the actual work of a person on a project" );
1062 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); 1062 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") );
1063 nt->setPercentComplete( 20 ); 1063 nt->setPercentComplete( 20 );
1064 Todo * workLutz12 = nt; 1064 Todo * workLutz12 = nt;
1065 workLutz12->setRelatedTo( sub2 ); 1065 workLutz12->setRelatedTo( sub2 );
1066 1066
1067 nt = new Todo; 1067 nt = new Todo;
1068 mCalendar->addTodo( nt ); 1068 mCalendar->addTodo( nt );
1069 nt->setSummary( "Work on 2: Norbert"); 1069 nt->setSummary( "Work on 2: Norbert");
1070 nt->setPriority( 1 ); 1070 nt->setPriority( 1 );
1071 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1071 nt->setDescription( "This todo counts the actual work of a person on a project" );
1072 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); 1072 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") );
1073 nt->setPercentComplete( 20 ); 1073 nt->setPercentComplete( 20 );
1074 Todo * workNorbert12 = nt; 1074 Todo * workNorbert12 = nt;
1075 workNorbert12->setRelatedTo( sub2 ); 1075 workNorbert12->setRelatedTo( sub2 );
1076 createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); 1076 createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 );
1077 createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); 1077 createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2);
1078 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); 1078 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7);
1079 createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); 1079 createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0);
1080 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); 1080 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1);
1081 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); 1081 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0);
1082 createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); 1082 createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0);
1083 } 1083 }
1084 updateView(); 1084 updateView();
1085#endif 1085#endif
1086 1086
1087} 1087}
1088void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) 1088void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval )
1089{ 1089{
1090 static int ccc = 0; 1090 static int ccc = 0;
1091 ++ccc; 1091 ++ccc;
1092 QDateTime t_start = start; 1092 QDateTime t_start = start;
1093 runT->setPriority( 5 ); 1093 runT->setPriority( 5 );
1094 runT->setPercentComplete( 0 ); 1094 runT->setPercentComplete( 0 );
1095 int count = 0; 1095 int count = 0;
1096 int prio = 5; 1096 int prio = 5;
1097 int complete = 0; 1097 int complete = 0;
1098 while ( t_start < end ) { 1098 while ( t_start < end ) {
1099 ++count; 1099 ++count;
1100 if ( count > ccc ) { 1100 if ( count > ccc ) {
1101 count = 0; 1101 count = 0;
1102 --prio; 1102 --prio;
1103 if ( prio == 0 ) prio = 5; 1103 if ( prio == 0 ) prio = 5;
1104 complete += 20; 1104 complete += 20;
1105 if ( complete > 100 ) complete = 0; 1105 if ( complete > 100 ) complete = 0;
1106 runT->setPriority( prio ); 1106 runT->setPriority( prio );
1107 runT->setPercentComplete( complete ); 1107 runT->setPercentComplete( complete );
1108 } 1108 }
1109 runT->setRunning( true ); 1109 runT->setRunning( true );
1110 runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); 1110 runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) );
1111 if ( dayInterval ) 1111 if ( dayInterval )
1112 t_start = t_start.addDays( dayInterval ); 1112 t_start = t_start.addDays( dayInterval );
1113 else { 1113 else {
1114 t_start = t_start.addSecs( secLenRunning + secLenPausing ); 1114 t_start = t_start.addSecs( secLenRunning + secLenPausing );
1115 } 1115 }
1116 } 1116 }
1117} 1117}
1118 1118
1119void CalendarView::showDay( QDate d ) 1119void CalendarView::showDay( QDate d )
1120{ 1120{
1121 dateNavigator()->blockSignals( true ); 1121 dateNavigator()->blockSignals( true );
1122 dateNavigator()->selectDate( d ); 1122 dateNavigator()->selectDate( d );
1123 dateNavigator()->blockSignals( false ); 1123 dateNavigator()->blockSignals( false );
1124 mViewManager->showDayView(); 1124 mViewManager->showDayView();
1125 //dateNavigator()->selectDate( d ); 1125 //dateNavigator()->selectDate( d );
1126} 1126}
1127void CalendarView::timerAlarm() 1127void CalendarView::timerAlarm()
1128{ 1128{
1129 //qDebug("CalendarView::timerAlarm() "); 1129 //qDebug("CalendarView::timerAlarm() ");
1130 computeAlarm(mAlarmNotification ); 1130 computeAlarm(mAlarmNotification );
1131} 1131}
1132 1132
1133void CalendarView::suspendAlarm() 1133void CalendarView::suspendAlarm()
1134{ 1134{
1135 //qDebug(" CalendarView::suspendAlarm() "); 1135 //qDebug(" CalendarView::suspendAlarm() ");
1136 computeAlarm(mSuspendAlarmNotification ); 1136 computeAlarm(mSuspendAlarmNotification );
1137 1137
1138} 1138}
1139 1139
1140void CalendarView::startAlarm( QString mess , QString filename) 1140void CalendarView::startAlarm( QString mess , QString filename)
1141{ 1141{
1142 1142
1143 topLevelWidget()->showNormal(); 1143 topLevelWidget()->showNormal();
1144 topLevelWidget()->setActiveWindow(); 1144 topLevelWidget()->setActiveWindow();
1145 topLevelWidget()->raise(); 1145 topLevelWidget()->raise();
1146 1146
1147 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 1147 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
1148 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); 1148 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) );
1149 1149
1150} 1150}
1151 1151
1152void CalendarView::checkNextTimerAlarm() 1152void CalendarView::checkNextTimerAlarm()
1153{ 1153{
1154 mCalendar->checkAlarmForIncidence( 0, true ); 1154 mCalendar->checkAlarmForIncidence( 0, true );
1155} 1155}
1156 1156
1157void CalendarView::computeAlarm( QString msg ) 1157void CalendarView::computeAlarm( QString msg )
1158{ 1158{
1159 1159
1160 QString mess = msg; 1160 QString mess = msg;
1161 QString mAlarmMessage = mess.mid( 9 ); 1161 QString mAlarmMessage = mess.mid( 9 );
1162 QString filename = MainWindow::resourcePath(); 1162 QString filename = MainWindow::resourcePath();
1163 filename += "koalarm.wav"; 1163 filename += "koalarm.wav";
1164 QString tempfilename; 1164 QString tempfilename;
1165 if ( mess.left( 13 ) == "suspend_alarm") { 1165 if ( mess.left( 13 ) == "suspend_alarm") {
1166 bool error = false; 1166 bool error = false;
1167 int len = mess.mid( 13 ).find("+++"); 1167 int len = mess.mid( 13 ).find("+++");
1168 if ( len < 2 ) 1168 if ( len < 2 )
1169 error = true; 1169 error = true;
1170 else { 1170 else {
1171 tempfilename = mess.mid( 13, len ); 1171 tempfilename = mess.mid( 13, len );
1172 if ( !QFile::exists( tempfilename ) ) 1172 if ( !QFile::exists( tempfilename ) )
1173 error = true; 1173 error = true;
1174 } 1174 }
1175 if ( ! error ) { 1175 if ( ! error ) {
1176 filename = tempfilename; 1176 filename = tempfilename;
1177 } 1177 }
1178 mAlarmMessage = mess.mid( 13+len+3 ); 1178 mAlarmMessage = mess.mid( 13+len+3 );
1179 //qDebug("suspend file %s ",tempfilename.latin1() ); 1179 //qDebug("suspend file %s ",tempfilename.latin1() );
1180 startAlarm( mAlarmMessage, filename); 1180 startAlarm( mAlarmMessage, filename);
1181 return; 1181 return;
1182 } 1182 }
1183 if ( mess.left( 11 ) == "timer_alarm") { 1183 if ( mess.left( 11 ) == "timer_alarm") {
1184 //mTimerTime = 0; 1184 //mTimerTime = 0;
1185 startAlarm( mess.mid( 11 ), filename ); 1185 startAlarm( mess.mid( 11 ), filename );
1186 return; 1186 return;
1187 } 1187 }
1188 if ( mess.left( 10 ) == "proc_alarm") { 1188 if ( mess.left( 10 ) == "proc_alarm") {
1189 bool error = false; 1189 bool error = false;
1190 int len = mess.mid( 10 ).find("+++"); 1190 int len = mess.mid( 10 ).find("+++");
1191 if ( len < 2 ) 1191 if ( len < 2 )
1192 error = true; 1192 error = true;
1193 else { 1193 else {
1194 tempfilename = mess.mid( 10, len ); 1194 tempfilename = mess.mid( 10, len );
1195 if ( !QFile::exists( tempfilename ) ) 1195 if ( !QFile::exists( tempfilename ) )
1196 error = true; 1196 error = true;
1197 } 1197 }
1198 if ( error ) { 1198 if ( error ) {
1199 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 1199 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
1200 mAlarmMessage += mess.mid( 10+len+3+9 ); 1200 mAlarmMessage += mess.mid( 10+len+3+9 );
1201 } else { 1201 } else {
1202 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 1202 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
1203 //qDebug("-----system command %s ",tempfilename.latin1() ); 1203 //qDebug("-----system command %s ",tempfilename.latin1() );
1204#ifndef _WIN32_ 1204#ifndef _WIN32_
1205 if ( vfork () == 0 ) { 1205 if ( vfork () == 0 ) {
1206 execl ( tempfilename.latin1(), 0 ); 1206 execl ( tempfilename.latin1(), 0 );
1207 return; 1207 return;
1208 } 1208 }
1209#else 1209#else
1210 QProcess* p = new QProcess(); 1210 QProcess* p = new QProcess();
1211 p->addArgument( tempfilename.latin1() ); 1211 p->addArgument( tempfilename.latin1() );
1212 p->start(); 1212 p->start();
1213 return; 1213 return;
1214#endif 1214#endif
1215 1215
1216 return; 1216 return;
1217 } 1217 }
1218 1218
1219 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 1219 //qDebug("+++++++system command %s ",tempfilename.latin1() );
1220 } 1220 }
1221 if ( mess.left( 11 ) == "audio_alarm") { 1221 if ( mess.left( 11 ) == "audio_alarm") {
1222 bool error = false; 1222 bool error = false;
1223 int len = mess.mid( 11 ).find("+++"); 1223 int len = mess.mid( 11 ).find("+++");
1224 if ( len < 2 ) 1224 if ( len < 2 )
1225 error = true; 1225 error = true;
1226 else { 1226 else {
1227 tempfilename = mess.mid( 11, len ); 1227 tempfilename = mess.mid( 11, len );
1228 if ( !QFile::exists( tempfilename ) ) 1228 if ( !QFile::exists( tempfilename ) )
1229 error = true; 1229 error = true;
1230 } 1230 }
1231 if ( ! error ) { 1231 if ( ! error ) {
1232 filename = tempfilename; 1232 filename = tempfilename;
1233 } 1233 }
1234 mAlarmMessage = mess.mid( 11+len+3+9 ); 1234 mAlarmMessage = mess.mid( 11+len+3+9 );
1235 //qDebug("audio file command %s ",tempfilename.latin1() ); 1235 //qDebug("audio file command %s ",tempfilename.latin1() );
1236 } 1236 }
1237 if ( mess.left( 9 ) == "cal_alarm") { 1237 if ( mess.left( 9 ) == "cal_alarm") {
1238 mAlarmMessage = mess.mid( 9 ) ; 1238 mAlarmMessage = mess.mid( 9 ) ;
1239 } 1239 }
1240 1240
1241 startAlarm( mAlarmMessage, filename ); 1241 startAlarm( mAlarmMessage, filename );
1242 1242
1243 1243
1244} 1244}
1245 1245
1246void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 1246void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
1247{ 1247{
1248 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1248 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1249 1249
1250 mSuspendAlarmNotification = noti; 1250 mSuspendAlarmNotification = noti;
1251 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 1251 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
1252 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 1252 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
1253 mSuspendTimer->start( ms , true ); 1253 mSuspendTimer->start( ms , true );
1254#ifdef DESKTOP_VERSION 1254#ifdef DESKTOP_VERSION
1255 if ( QApplication::desktop()->width() < 1024 ) { 1255 if ( QApplication::desktop()->width() < 1024 ) {
1256 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; 1256 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti;
1257 //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); 1257 //qDebug("nextsuspendalarm = \n%s ",mess.latin1() );
1258 QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; 1258 QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm";
1259 QFile file( fn ); 1259 QFile file( fn );
1260 if (!file.open( IO_WriteOnly ) ) { 1260 if (!file.open( IO_WriteOnly ) ) {
1261 qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); 1261 qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1());
1262 } else { 1262 } else {
1263 QTextStream ts( &file ); 1263 QTextStream ts( &file );
1264 ts << mess; 1264 ts << mess;
1265 file.close(); 1265 file.close();
1266 } 1266 }
1267 } 1267 }
1268#endif 1268#endif
1269 1269
1270} 1270}
1271 1271
1272void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 1272void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
1273{ 1273{
1274 mNextAlarmDateTime = qdt; 1274 mNextAlarmDateTime = qdt;
1275 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1275 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1276 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1276 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1277#ifndef DESKTOP_VERSION 1277#ifndef DESKTOP_VERSION
1278 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 1278 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
1279#endif 1279#endif
1280 return; 1280 return;
1281 } 1281 }
1282#ifdef DESKTOP_VERSION 1282#ifdef DESKTOP_VERSION
1283 if ( QApplication::desktop()->width() < 1024 ) { 1283 if ( QApplication::desktop()->width() < 1024 ) {
1284 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; 1284 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti;
1285 //qDebug("nextalarm = \n%s ",mess.latin1() ); 1285 //qDebug("nextalarm = \n%s ",mess.latin1() );
1286 QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; 1286 QString fn = QDir::homeDirPath() + "/.kopi_next_alarm";
1287 QFile file( fn ); 1287 QFile file( fn );
1288 if (!file.open( IO_WriteOnly ) ) { 1288 if (!file.open( IO_WriteOnly ) ) {
1289 qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); 1289 qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1());
1290 } else { 1290 } else {
1291 QTextStream ts( &file ); 1291 QTextStream ts( &file );
1292 ts << mess; 1292 ts << mess;
1293 file.close(); 1293 file.close();
1294 } 1294 }
1295 } 1295 }
1296#endif 1296#endif
1297 int maxSec; 1297 int maxSec;
1298 //maxSec = 5; //testing only 1298 //maxSec = 5; //testing only
1299 maxSec = 86400+3600; // one day+1hour 1299 maxSec = 86400+3600; // one day+1hour
1300 mAlarmNotification = noti; 1300 mAlarmNotification = noti;
1301 int sec = QDateTime::currentDateTime().secsTo( qdt ); 1301 int sec = QDateTime::currentDateTime().secsTo( qdt );
1302 if ( sec > maxSec ) { 1302 if ( sec > maxSec ) {
1303 mRecheckAlarmTimer->start( maxSec * 1000 ); 1303 mRecheckAlarmTimer->start( maxSec * 1000 );
1304 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 1304 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
1305 return; 1305 return;
1306 } else { 1306 } else {
1307 mRecheckAlarmTimer->stop(); 1307 mRecheckAlarmTimer->stop();
1308 } 1308 }
1309 //qDebug("Alarm timer started with secs: %d ", sec); 1309 //qDebug("Alarm timer started with secs: %d ", sec);
1310 mAlarmTimer->start( sec * 1000 , true ); 1310 mAlarmTimer->start( sec * 1000 , true );
1311 1311
1312} 1312}
1313// called by mRecheckAlarmTimer to get next alarm 1313// called by mRecheckAlarmTimer to get next alarm
1314// we need this, because a QTimer has only a max range of 25 days 1314// we need this, because a QTimer has only a max range of 25 days
1315void CalendarView::recheckTimerAlarm() 1315void CalendarView::recheckTimerAlarm()
1316{ 1316{
1317 mAlarmTimer->stop(); 1317 mAlarmTimer->stop();
1318 mRecheckAlarmTimer->stop(); 1318 mRecheckAlarmTimer->stop();
1319 mCalendar->checkAlarmForIncidence( 0, true ); 1319 mCalendar->checkAlarmForIncidence( 0, true );
1320} 1320}
1321#ifndef DESKTOP_VERSION 1321#ifndef DESKTOP_VERSION
1322void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 1322void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
1323#else 1323#else
1324void CalendarView::removeAlarm(const QDateTime &, const QString & ) 1324void CalendarView::removeAlarm(const QDateTime &, const QString & )
1325#endif 1325#endif
1326{ 1326{
1327 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1327 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1328 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1328 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1329#ifndef DESKTOP_VERSION 1329#ifndef DESKTOP_VERSION
1330 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); 1330 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() );
1331#endif 1331#endif
1332 return; 1332 return;
1333 } 1333 }
1334 mAlarmTimer->stop(); 1334 mAlarmTimer->stop();
1335} 1335}
1336void CalendarView::selectWeekNum ( int num ) 1336void CalendarView::selectWeekNum ( int num )
1337{ 1337{
1338 dateNavigator()->blockSignals( true ); 1338 dateNavigator()->blockSignals( true );
1339 dateNavigator()->selectWeek( num ); 1339 dateNavigator()->selectWeek( num );
1340 dateNavigator()->blockSignals( false ); 1340 dateNavigator()->blockSignals( false );
1341 mViewManager->showWeekView(); 1341 mViewManager->showWeekView();
1342} 1342}
1343KOViewManager *CalendarView::viewManager() 1343KOViewManager *CalendarView::viewManager()
1344{ 1344{
1345 return mViewManager; 1345 return mViewManager;
1346} 1346}
1347 1347
1348KODialogManager *CalendarView::dialogManager() 1348KODialogManager *CalendarView::dialogManager()
1349{ 1349{
1350 return mDialogManager; 1350 return mDialogManager;
1351} 1351}
1352 1352
1353QDate CalendarView::startDate() 1353QDate CalendarView::startDate()
1354{ 1354{
1355 DateList dates = mNavigator->selectedDates(); 1355 DateList dates = mNavigator->selectedDates();
1356 1356
1357 return dates.first(); 1357 return dates.first();
1358} 1358}
1359 1359
1360QDate CalendarView::endDate() 1360QDate CalendarView::endDate()
1361{ 1361{
1362 DateList dates = mNavigator->selectedDates(); 1362 DateList dates = mNavigator->selectedDates();
1363 1363
1364 return dates.last(); 1364 return dates.last();
1365} 1365}
1366 1366
1367 1367
1368void CalendarView::createPrinter() 1368void CalendarView::createPrinter()
1369{ 1369{
1370#ifndef KORG_NOPRINTER 1370#ifndef KORG_NOPRINTER
1371 if (!mCalPrinter) { 1371 if (!mCalPrinter) {
1372 mCalPrinter = new CalPrinter(this, mCalendar); 1372 mCalPrinter = new CalPrinter(this, mCalendar);
1373 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 1373 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
1374 } 1374 }
1375#endif 1375#endif
1376} 1376}
1377 1377
1378 1378
1379//KOPrefs::instance()->mWriteBackFile 1379//KOPrefs::instance()->mWriteBackFile
1380//KOPrefs::instance()->mWriteBackExistingOnly 1380//KOPrefs::instance()->mWriteBackExistingOnly
1381 1381
1382// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 1382// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
1383// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 1383// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
1384// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 1384// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
1385// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 1385// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
1386// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 1386// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
1387// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 1387// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
1388 1388
1389int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 1389int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
1390{ 1390{
1391 1391
1392 // 0 equal 1392 // 0 equal
1393 // 1 take local 1393 // 1 take local
1394 // 2 take remote 1394 // 2 take remote
1395 // 3 cancel 1395 // 3 cancel
1396 QDateTime lastSync = mLastCalendarSync; 1396 QDateTime lastSync = mLastCalendarSync;
1397 QDateTime localMod = local->lastModified(); 1397 QDateTime localMod = local->lastModified();
1398 QDateTime remoteMod = remote->lastModified(); 1398 QDateTime remoteMod = remote->lastModified();
1399 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1399 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1400 bool remCh, locCh; 1400 bool remCh, locCh;
1401 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 1401 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
1402 //if ( remCh ) 1402 //if ( remCh )
1403 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 1403 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
1404 locCh = ( localMod > mLastCalendarSync ); 1404 locCh = ( localMod > mLastCalendarSync );
1405 if ( !remCh && ! locCh ) { 1405 if ( !remCh && ! locCh ) {
1406 //qDebug("both not changed "); 1406 //qDebug("both not changed ");
1407 lastSync = localMod.addDays(1); 1407 lastSync = localMod.addDays(1);
1408 if ( mode <= SYNC_PREF_ASK ) 1408 if ( mode <= SYNC_PREF_ASK )
1409 return 0; 1409 return 0;
1410 } else { 1410 } else {
1411 if ( locCh ) { 1411 if ( locCh ) {
1412 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 1412 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
1413 lastSync = localMod.addDays( -1 ); 1413 lastSync = localMod.addDays( -1 );
1414 if ( !remCh ) 1414 if ( !remCh )
1415 remoteMod = ( lastSync.addDays( -1 ) ); 1415 remoteMod = ( lastSync.addDays( -1 ) );
1416 } else { 1416 } else {
1417 //qDebug(" not loc changed "); 1417 //qDebug(" not loc changed ");
1418 lastSync = localMod.addDays( 1 ); 1418 lastSync = localMod.addDays( 1 );
1419 if ( remCh ) 1419 if ( remCh )
1420 remoteMod =( lastSync.addDays( 1 ) ); 1420 remoteMod =( lastSync.addDays( 1 ) );
1421 1421
1422 } 1422 }
1423 } 1423 }
1424 full = true; 1424 full = true;
1425 if ( mode < SYNC_PREF_ASK ) 1425 if ( mode < SYNC_PREF_ASK )
1426 mode = SYNC_PREF_ASK; 1426 mode = SYNC_PREF_ASK;
1427 } else { 1427 } else {
1428 if ( localMod == remoteMod ) 1428 if ( localMod == remoteMod )
1429 // if ( local->revision() == remote->revision() ) 1429 // if ( local->revision() == remote->revision() )
1430 return 0; 1430 return 0;
1431 1431
1432 } 1432 }
1433 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 1433 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
1434 1434
1435 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 1435 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
1436 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 1436 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
1437 //full = true; //debug only 1437 //full = true; //debug only
1438 if ( full ) { 1438 if ( full ) {
1439 bool equ = false; 1439 bool equ = false;
1440 if ( local->typeID() == eventID ) { 1440 if ( local->typeID() == eventID ) {
1441 equ = (*((Event*) local) == *((Event*) remote)); 1441 equ = (*((Event*) local) == *((Event*) remote));
1442 } 1442 }
1443 else if ( local->typeID() == todoID ) 1443 else if ( local->typeID() == todoID )
1444 equ = (*((Todo*) local) == (*(Todo*) remote)); 1444 equ = (*((Todo*) local) == (*(Todo*) remote));
1445 else if ( local->typeID() == journalID ) 1445 else if ( local->typeID() == journalID )
1446 equ = (*((Journal*) local) == *((Journal*) remote)); 1446 equ = (*((Journal*) local) == *((Journal*) remote));
1447 if ( equ ) { 1447 if ( equ ) {
1448 //qDebug("equal "); 1448 //qDebug("equal ");
1449 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1449 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1450 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1450 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1451 } 1451 }
1452 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1452 if ( mode < SYNC_PREF_FORCE_LOCAL )
1453 return 0; 1453 return 0;
1454 1454
1455 }//else //debug only 1455 }//else //debug only
1456 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1456 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1457 } 1457 }
1458 int result; 1458 int result;
1459 bool localIsNew; 1459 bool localIsNew;
1460 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 1460 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
1461 1461
1462 1462
1463 // ************************************************ 1463 // ************************************************
1464 // ************************************************ 1464 // ************************************************
1465 // ************************************************ 1465 // ************************************************
1466 // We may have that lastSync > remoteMod AND lastSync > localMod 1466 // We may have that lastSync > remoteMod AND lastSync > localMod
1467 // BUT remoteMod != localMod 1467 // BUT remoteMod != localMod
1468 1468
1469 1469
1470 if ( full && mode < SYNC_PREF_NEWEST ) 1470 if ( full && mode < SYNC_PREF_NEWEST )
1471 mode = SYNC_PREF_ASK; 1471 mode = SYNC_PREF_ASK;
1472 1472
1473 switch( mode ) { 1473 switch( mode ) {
1474 case SYNC_PREF_LOCAL: 1474 case SYNC_PREF_LOCAL:
1475 if ( lastSync > remoteMod ) 1475 if ( lastSync > remoteMod )
1476 return 1; 1476 return 1;
1477 if ( lastSync > localMod ) 1477 if ( lastSync > localMod )
1478 return 2; 1478 return 2;
1479 return 1; 1479 return 1;
1480 break; 1480 break;
1481 case SYNC_PREF_REMOTE: 1481 case SYNC_PREF_REMOTE:
1482 if ( lastSync > localMod ) 1482 if ( lastSync > localMod )
1483 return 2; 1483 return 2;
1484 if ( lastSync > remoteMod ) 1484 if ( lastSync > remoteMod )
1485 return 1; 1485 return 1;
1486 return 2; 1486 return 2;
1487 break; 1487 break;
1488 case SYNC_PREF_NEWEST: 1488 case SYNC_PREF_NEWEST:
1489 if ( localMod >= remoteMod ) 1489 if ( localMod >= remoteMod )
1490 return 1; 1490 return 1;
1491 else 1491 else
1492 return 2; 1492 return 2;
1493 break; 1493 break;
1494 case SYNC_PREF_ASK: 1494 case SYNC_PREF_ASK:
1495 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1495 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1496 if ( lastSync > remoteMod && lastSync > localMod) 1496 if ( lastSync > remoteMod && lastSync > localMod)
1497 return 0; 1497 return 0;
1498 if ( lastSync > remoteMod ) 1498 if ( lastSync > remoteMod )
1499 return 1; 1499 return 1;
1500 if ( lastSync > localMod ) 1500 if ( lastSync > localMod )
1501 return 2; 1501 return 2;
1502 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1502 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1503 localIsNew = localMod >= remoteMod; 1503 localIsNew = localMod >= remoteMod;
1504 if ( localIsNew ) 1504 if ( localIsNew )
1505 getEventViewerDialog()->setColorMode( 1 ); 1505 getEventViewerDialog()->setColorMode( 1 );
1506 else 1506 else
1507 getEventViewerDialog()->setColorMode( 2 ); 1507 getEventViewerDialog()->setColorMode( 2 );
1508 getEventViewerDialog()->setIncidence(local); 1508 getEventViewerDialog()->setIncidence(local);
1509 if ( localIsNew ) 1509 if ( localIsNew )
1510 getEventViewerDialog()->setColorMode( 2 ); 1510 getEventViewerDialog()->setColorMode( 2 );
1511 else 1511 else
1512 getEventViewerDialog()->setColorMode( 1 ); 1512 getEventViewerDialog()->setColorMode( 1 );
1513 getEventViewerDialog()->addIncidence(remote); 1513 getEventViewerDialog()->addIncidence(remote);
1514 getEventViewerDialog()->setColorMode( 0 ); 1514 getEventViewerDialog()->setColorMode( 0 );
1515 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1515 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1516 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1516 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1517 getEventViewerDialog()->showMe(); 1517 getEventViewerDialog()->showMe();
1518 result = getEventViewerDialog()->executeS( localIsNew ); 1518 result = getEventViewerDialog()->executeS( localIsNew );
1519 return result; 1519 return result;
1520 1520
1521 break; 1521 break;
1522 case SYNC_PREF_FORCE_LOCAL: 1522 case SYNC_PREF_FORCE_LOCAL:
1523 return 1; 1523 return 1;
1524 break; 1524 break;
1525 case SYNC_PREF_FORCE_REMOTE: 1525 case SYNC_PREF_FORCE_REMOTE:
1526 return 2; 1526 return 2;
1527 break; 1527 break;
1528 1528
1529 default: 1529 default:
1530 // SYNC_PREF_TAKE_BOTH not implemented 1530 // SYNC_PREF_TAKE_BOTH not implemented
1531 break; 1531 break;
1532 } 1532 }
1533 return 0; 1533 return 0;
1534} 1534}
1535Event* CalendarView::getLastSyncEvent() 1535Event* CalendarView::getLastSyncEvent()
1536{ 1536{
1537 Event* lse; 1537 Event* lse;
1538 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1538 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1539 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1539 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1540 if (!lse) { 1540 if (!lse) {
1541 lse = new Event(); 1541 lse = new Event();
1542 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1542 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1543 QString sum = ""; 1543 QString sum = "";
1544 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1544 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1545 sum = "E: "; 1545 sum = "E: ";
1546 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1546 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1547 lse->setDtStart( mLastCalendarSync ); 1547 lse->setDtStart( mLastCalendarSync );
1548 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1548 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1549 lse->setCategories( i18n("SyncEvent") ); 1549 lse->setCategories( i18n("SyncEvent") );
1550 lse->setReadOnly( true ); 1550 lse->setReadOnly( true );
1551 mCalendar->addEvent( lse ); 1551 mCalendar->addEvent( lse );
1552 } 1552 }
1553 1553
1554 return lse; 1554 return lse;
1555 1555
1556} 1556}
1557 1557
1558// we check, if the to delete event has a id for a profile 1558// we check, if the to delete event has a id for a profile
1559// if yes, we set this id in the profile to delete 1559// if yes, we set this id in the profile to delete
1560void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1560void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1561{ 1561{
1562 if ( lastSync.count() == 0 ) { 1562 if ( lastSync.count() == 0 ) {
1563 //qDebug(" lastSync.count() == 0"); 1563 //qDebug(" lastSync.count() == 0");
1564 return; 1564 return;
1565 } 1565 }
1566 if ( toDelete->typeID() == journalID ) 1566 if ( toDelete->typeID() == journalID )
1567 return; 1567 return;
1568 1568
1569 Event* eve = lastSync.first(); 1569 Event* eve = lastSync.first();
1570 1570
1571 while ( eve ) { 1571 while ( eve ) {
1572 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1572 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1573 if ( !id.isEmpty() ) { 1573 if ( !id.isEmpty() ) {
1574 QString des = eve->description(); 1574 QString des = eve->description();
1575 QString pref = "e"; 1575 QString pref = "e";
1576 if ( toDelete->typeID() == todoID ) 1576 if ( toDelete->typeID() == todoID )
1577 pref = "t"; 1577 pref = "t";
1578 des += pref+ id + ","; 1578 des += pref+ id + ",";
1579 eve->setReadOnly( false ); 1579 eve->setReadOnly( false );
1580 eve->setDescription( des ); 1580 eve->setDescription( des );
1581 //qDebug("setdes %s ", des.latin1()); 1581 //qDebug("setdes %s ", des.latin1());
1582 eve->setReadOnly( true ); 1582 eve->setReadOnly( true );
1583 } 1583 }
1584 eve = lastSync.next(); 1584 eve = lastSync.next();
1585 } 1585 }
1586 1586
1587} 1587}
1588void CalendarView::checkExternalId( Incidence * inc ) 1588void CalendarView::checkExternalId( Incidence * inc )
1589{ 1589{
1590 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1590 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1591 checkExternSyncEvent( lastSync, inc ); 1591 checkExternSyncEvent( lastSync, inc );
1592 1592
1593} 1593}
1594bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1594bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1595{ 1595{
1596 bool syncOK = true; 1596 bool syncOK = true;
1597 int addedEvent = 0; 1597 int addedEvent = 0;
1598 int addedEventR = 0; 1598 int addedEventR = 0;
1599 int deletedEventR = 0; 1599 int deletedEventR = 0;
1600 int deletedEventL = 0; 1600 int deletedEventL = 0;
1601 int changedLocal = 0; 1601 int changedLocal = 0;
1602 int changedRemote = 0; 1602 int changedRemote = 0;
1603 int filteredIN = 0; 1603 int filteredIN = 0;
1604 int filteredOUT = 0; 1604 int filteredOUT = 0;
1605 //QPtrList<Event> el = local->rawEvents(); 1605 //QPtrList<Event> el = local->rawEvents();
1606 Event* eventR; 1606 Event* eventR;
1607 QString uid; 1607 QString uid;
1608 int take; 1608 int take;
1609 Event* eventRSync; 1609 Event* eventRSync;
1610 Event* eventLSync; 1610 Event* eventLSync;
1611 clearAllViews(); 1611 clearAllViews();
1612 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1612 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1613 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1613 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1614 bool fullDateRange = false; 1614 bool fullDateRange = false;
1615 local->resetTempSyncStat(); 1615 local->resetTempSyncStat();
1616 mLastCalendarSync = QDateTime::currentDateTime(); 1616 mLastCalendarSync = QDateTime::currentDateTime();
1617 if ( mSyncManager->syncWithDesktop() ) { 1617 if ( mSyncManager->syncWithDesktop() ) {
1618 remote->resetPilotStat(1); 1618 remote->resetPilotStat(1);
1619 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1619 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1620 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1620 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1621 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1621 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1622 } else { 1622 } else {
1623 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1623 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1624 } 1624 }
1625 } 1625 }
1626 QDateTime modifiedCalendar = mLastCalendarSync; 1626 QDateTime modifiedCalendar = mLastCalendarSync;
1627 eventLSync = getLastSyncEvent(); 1627 eventLSync = getLastSyncEvent();
1628 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1628 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1629 if ( eventR ) { 1629 if ( eventR ) {
1630 qDebug("last-syncEvent on remote found "); 1630 qDebug("last-syncEvent on remote found ");
1631 eventRSync = (Event*) eventR->clone(); 1631 eventRSync = (Event*) eventR->clone();
1632 remote->deleteEvent(eventR ); 1632 remote->deleteEvent(eventR );
1633 1633
1634 } else { 1634 } else {
1635 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1635 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1636 eventRSync = (Event*)eventLSync->clone(); 1636 eventRSync = (Event*)eventLSync->clone();
1637 } else { 1637 } else {
1638 fullDateRange = true; 1638 fullDateRange = true;
1639 eventRSync = new Event(); 1639 eventRSync = new Event();
1640 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1640 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1641 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1641 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1642 eventRSync->setDtStart( mLastCalendarSync ); 1642 eventRSync->setDtStart( mLastCalendarSync );
1643 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1643 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1644 eventRSync->setCategories( i18n("SyncEvent") ); 1644 eventRSync->setCategories( i18n("SyncEvent") );
1645 } 1645 }
1646 } 1646 }
1647 if ( eventLSync->dtStart() == mLastCalendarSync ) 1647 if ( eventLSync->dtStart() == mLastCalendarSync )
1648 fullDateRange = true; 1648 fullDateRange = true;
1649 1649
1650 if ( ! fullDateRange ) { 1650 if ( ! fullDateRange ) {
1651 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1651 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1652 1652
1653 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1653 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1654 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1654 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1655 fullDateRange = true; 1655 fullDateRange = true;
1656 } 1656 }
1657 } 1657 }
1658 if ( mSyncManager->syncWithDesktop() ) { 1658 if ( mSyncManager->syncWithDesktop() ) {
1659 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1659 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1660 } 1660 }
1661 if ( fullDateRange ) 1661 if ( fullDateRange )
1662 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1662 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1663 else 1663 else
1664 mLastCalendarSync = eventLSync->dtStart(); 1664 mLastCalendarSync = eventLSync->dtStart();
1665 // for resyncing if own file has changed 1665 // for resyncing if own file has changed
1666 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1666 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1667 mLastCalendarSync = loadedFileVersion; 1667 mLastCalendarSync = loadedFileVersion;
1668 //qDebug("setting mLastCalendarSync "); 1668 //qDebug("setting mLastCalendarSync ");
1669 } 1669 }
1670 //qDebug("*************************** "); 1670 //qDebug("*************************** ");
1671 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1671 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1672 QPtrList<Incidence> er = remote->rawIncidences(); 1672 QPtrList<Incidence> er = remote->rawIncidences();
1673 Incidence* inR = er.first(); 1673 Incidence* inR = er.first();
1674 Incidence* inL; 1674 Incidence* inL;
1675 QProgressBar bar( er.count(),0 ); 1675 QProgressBar bar( er.count(),0 );
1676 bar.setCaption (i18n("Syncing - close to abort!") ); 1676 bar.setCaption (i18n("Syncing - close to abort!") );
1677 1677
1678 // ************** setting up filter ************* 1678 // ************** setting up filter *************
1679 CalFilter *filterIN = 0; 1679 CalFilter *filterIN = 0;
1680 CalFilter *filterOUT = 0; 1680 CalFilter *filterOUT = 0;
1681 CalFilter *filter = mFilters.first(); 1681 CalFilter *filter = mFilters.first();
1682 while(filter) { 1682 while(filter) {
1683 if ( filter->name() == mSyncManager->mFilterInCal ) 1683 if ( filter->name() == mSyncManager->mFilterInCal )
1684 filterIN = filter; 1684 filterIN = filter;
1685 if ( filter->name() == mSyncManager->mFilterOutCal ) 1685 if ( filter->name() == mSyncManager->mFilterOutCal )
1686 filterOUT = filter; 1686 filterOUT = filter;
1687 filter = mFilters.next(); 1687 filter = mFilters.next();
1688 } 1688 }
1689 int w = 300; 1689 int w = 300;
1690 if ( QApplication::desktop()->width() < 320 ) 1690 if ( QApplication::desktop()->width() < 320 )
1691 w = 220; 1691 w = 220;
1692 int h = bar.sizeHint().height() ; 1692 int h = bar.sizeHint().height() ;
1693 int dw = QApplication::desktop()->width(); 1693 int dw = QApplication::desktop()->width();
1694 int dh = QApplication::desktop()->height(); 1694 int dh = QApplication::desktop()->height();
1695 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1695 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1696 bar.show(); 1696 bar.show();
1697 int modulo = (er.count()/10)+1; 1697 int modulo = (er.count()/10)+1;
1698 int incCounter = 0; 1698 int incCounter = 0;
1699 while ( inR ) { 1699 while ( inR ) {
1700 if ( ! bar.isVisible() ) 1700 if ( ! bar.isVisible() )
1701 return false; 1701 return false;
1702 if ( incCounter % modulo == 0 ) 1702 if ( incCounter % modulo == 0 )
1703 bar.setProgress( incCounter ); 1703 bar.setProgress( incCounter );
1704 ++incCounter; 1704 ++incCounter;
1705 uid = inR->uid(); 1705 uid = inR->uid();
1706 bool skipIncidence = false; 1706 bool skipIncidence = false;
1707 if ( uid.left(15) == QString("last-syncEvent-") ) 1707 if ( uid.left(15) == QString("last-syncEvent-") )
1708 skipIncidence = true; 1708 skipIncidence = true;
1709 QString idS; 1709 QString idS;
1710 qApp->processEvents(); 1710 qApp->processEvents();
1711 if ( !skipIncidence ) { 1711 if ( !skipIncidence ) {
1712 inL = local->incidenceForUid( uid , false ); 1712 inL = local->incidenceForUid( uid , false );
1713 if ( inL ) { // maybe conflict - same uid in both calendars 1713 if ( inL ) { // maybe conflict - same uid in both calendars
1714 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1714 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1715 //qDebug("take %d %s ", take, inL->summary().latin1()); 1715 //qDebug("take %d %s ", take, inL->summary().latin1());
1716 if ( take == 3 ) 1716 if ( take == 3 )
1717 return false; 1717 return false;
1718 if ( take == 1 ) {// take local ********************** 1718 if ( take == 1 ) {// take local **********************
1719 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1719 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1720 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1720 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1721 else 1721 else
1722 idS = inR->IDStr(); 1722 idS = inR->IDStr();
1723 int calID = inR->calID(); 1723 int calID = inR->calID();
1724 remote->deleteIncidence( inR ); 1724 remote->deleteIncidence( inR );
1725 inR = inL->clone(); 1725 inR = inL->clone();
1726 inR->setCalID( calID ); 1726 inR->setCalID( calID );
1727 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1727 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1728 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1728 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1729 inR->setIDStr( idS ); 1729 inR->setIDStr( idS );
1730 remote->addIncidence( inR ); 1730 remote->addIncidence( inR );
1731 if ( mSyncManager->syncWithDesktop() ) 1731 if ( mSyncManager->syncWithDesktop() )
1732 inR->setPilotId( 2 ); 1732 inR->setPilotId( 2 );
1733 ++changedRemote; 1733 ++changedRemote;
1734 } else {// take remote ********************** 1734 } else {// take remote **********************
1735 if ( !inL->isReadOnly() ) { 1735 if ( !inL->isReadOnly() ) {
1736 idS = inL->IDStr(); 1736 idS = inL->IDStr();
1737 int pid = inL->pilotId(); 1737 int pid = inL->pilotId();
1738 int calID = inL->calID(); 1738 int calID = inL->calID();
1739 local->deleteIncidence( inL ); 1739 local->deleteIncidence( inL );
1740 inL = inR->clone(); 1740 inL = inR->clone();
1741 inL->setCalID( calID ); 1741 inL->setCalID( calID );
1742 if ( mSyncManager->syncWithDesktop() ) 1742 if ( mSyncManager->syncWithDesktop() )
1743 inL->setPilotId( pid ); 1743 inL->setPilotId( pid );
1744 inL->setIDStr( idS ); 1744 inL->setIDStr( idS );
1745 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1745 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1746 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1746 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1747 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1747 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1748 } 1748 }
1749 local->addIncidence( inL ); 1749 local->addIncidence( inL );
1750 ++changedLocal; 1750 ++changedLocal;
1751 } 1751 }
1752 } 1752 }
1753 } 1753 }
1754 } else { // no conflict ********** add or delete remote 1754 } else { // no conflict ********** add or delete remote
1755 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1755 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1756 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1756 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1757 QString des = eventLSync->description(); 1757 QString des = eventLSync->description();
1758 QString pref = "e"; 1758 QString pref = "e";
1759 if ( inR->typeID() == todoID ) 1759 if ( inR->typeID() == todoID )
1760 pref = "t"; 1760 pref = "t";
1761 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1761 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1762 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1762 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1763 //remote->deleteIncidence( inR ); 1763 //remote->deleteIncidence( inR );
1764 ++deletedEventR; 1764 ++deletedEventR;
1765 } else { 1765 } else {
1766 inR->setLastModified( modifiedCalendar ); 1766 inR->setLastModified( modifiedCalendar );
1767 inL = inR->clone(); 1767 inL = inR->clone();
1768 inL->setIDStr( ":" ); 1768 inL->setIDStr( ":" );
1769 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1769 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1770 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1770 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1771 1771
1772 inL->setCalID( 0 );// add to default cal 1772 inL->setCalID( 0 );// add to default cal
1773 local->addIncidence( inL ); 1773 local->addIncidence( inL );
1774 ++addedEvent; 1774 ++addedEvent;
1775 1775
1776 } 1776 }
1777 } else { 1777 } else {
1778 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1778 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1779 inR->setLastModified( modifiedCalendar ); 1779 inR->setLastModified( modifiedCalendar );
1780 inL = inR->clone(); 1780 inL = inR->clone();
1781 inL->setIDStr( ":" ); 1781 inL->setIDStr( ":" );
1782 inL->setCalID( 0 );// add to default cal 1782 inL->setCalID( 0 );// add to default cal
1783 local->addIncidence( inL ); 1783 local->addIncidence( inL );
1784 ++addedEvent; 1784 ++addedEvent;
1785 1785
1786 } else { 1786 } else {
1787 checkExternSyncEvent(eventRSyncSharp, inR); 1787 checkExternSyncEvent(eventRSyncSharp, inR);
1788 remote->deleteIncidence( inR ); 1788 remote->deleteIncidence( inR );
1789 ++deletedEventR; 1789 ++deletedEventR;
1790 } 1790 }
1791 } 1791 }
1792 } else { 1792 } else {
1793 ++filteredIN; 1793 ++filteredIN;
1794 } 1794 }
1795 } 1795 }
1796 } 1796 }
1797 inR = er.next(); 1797 inR = er.next();
1798 } 1798 }
1799 QPtrList<Incidence> el = local->rawIncidences(); 1799 QPtrList<Incidence> el = local->rawIncidences();
1800 inL = el.first(); 1800 inL = el.first();
1801 modulo = (el.count()/10)+1; 1801 modulo = (el.count()/10)+1;
1802 bar.setCaption (i18n("Add / remove events") ); 1802 bar.setCaption (i18n("Add / remove events") );
1803 bar.setTotalSteps ( el.count() ) ; 1803 bar.setTotalSteps ( el.count() ) ;
1804 bar.show(); 1804 bar.show();
1805 incCounter = 0; 1805 incCounter = 0;
1806 1806
1807 while ( inL ) { 1807 while ( inL ) {
1808 1808
1809 qApp->processEvents(); 1809 qApp->processEvents();
1810 if ( ! bar.isVisible() ) 1810 if ( ! bar.isVisible() )
1811 return false; 1811 return false;
1812 if ( incCounter % modulo == 0 ) 1812 if ( incCounter % modulo == 0 )
1813 bar.setProgress( incCounter ); 1813 bar.setProgress( incCounter );
1814 ++incCounter; 1814 ++incCounter;
1815 uid = inL->uid(); 1815 uid = inL->uid();
1816 bool skipIncidence = false; 1816 bool skipIncidence = false;
1817 if ( uid.left(15) == QString("last-syncEvent-") ) 1817 if ( uid.left(15) == QString("last-syncEvent-") )
1818 skipIncidence = true; 1818 skipIncidence = true;
1819 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1819 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1820 skipIncidence = true; 1820 skipIncidence = true;
1821 if ( !skipIncidence ) { 1821 if ( !skipIncidence ) {
1822 inR = remote->incidenceForUid( uid , true ); 1822 inR = remote->incidenceForUid( uid , true );
1823 if ( ! inR ) { 1823 if ( ! inR ) {
1824 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1824 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1825 // no conflict ********** add or delete local 1825 // no conflict ********** add or delete local
1826 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1826 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1827 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1827 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1828 checkExternSyncEvent(eventLSyncSharp, inL); 1828 checkExternSyncEvent(eventLSyncSharp, inL);
1829 local->deleteIncidence( inL ); 1829 local->deleteIncidence( inL );
1830 ++deletedEventL; 1830 ++deletedEventL;
1831 } else { 1831 } else {
1832 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1832 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1833 inL->removeID(mCurrentSyncDevice ); 1833 inL->removeID(mCurrentSyncDevice );
1834 ++addedEventR; 1834 ++addedEventR;
1835 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1835 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1836 inL->setLastModified( modifiedCalendar ); 1836 inL->setLastModified( modifiedCalendar );
1837 inR = inL->clone(); 1837 inR = inL->clone();
1838 inR->setIDStr( ":" ); 1838 inR->setIDStr( ":" );
1839 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1839 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1840 inR->setCalID( 0 );// add to default cal 1840 inR->setCalID( 0 );// add to default cal
1841 remote->addIncidence( inR ); 1841 remote->addIncidence( inR );
1842 } 1842 }
1843 } 1843 }
1844 } else { 1844 } else {
1845 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1845 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1846 checkExternSyncEvent(eventLSyncSharp, inL); 1846 checkExternSyncEvent(eventLSyncSharp, inL);
1847 local->deleteIncidence( inL ); 1847 local->deleteIncidence( inL );
1848 ++deletedEventL; 1848 ++deletedEventL;
1849 } else { 1849 } else {
1850 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1850 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1851 ++addedEventR; 1851 ++addedEventR;
1852 inL->setLastModified( modifiedCalendar ); 1852 inL->setLastModified( modifiedCalendar );
1853 inR = inL->clone(); 1853 inR = inL->clone();
1854 inR->setIDStr( ":" ); 1854 inR->setIDStr( ":" );
1855 inR->setCalID( 0 );// add to default cal 1855 inR->setCalID( 0 );// add to default cal
1856 remote->addIncidence( inR ); 1856 remote->addIncidence( inR );
1857 } 1857 }
1858 } 1858 }
1859 } 1859 }
1860 } else { 1860 } else {
1861 ++filteredOUT; 1861 ++filteredOUT;
1862 } 1862 }
1863 } 1863 }
1864 } 1864 }
1865 inL = el.next(); 1865 inL = el.next();
1866 } 1866 }
1867 int delFut = 0; 1867 int delFut = 0;
1868 int remRem = 0; 1868 int remRem = 0;
1869 if ( mSyncManager->mWriteBackInFuture ) { 1869 if ( mSyncManager->mWriteBackInFuture ) {
1870 er = remote->rawIncidences(); 1870 er = remote->rawIncidences();
1871 remRem = er.count(); 1871 remRem = er.count();
1872 inR = er.first(); 1872 inR = er.first();
1873 QDateTime dt; 1873 QDateTime dt;
1874 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1874 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1875 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1875 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1876 while ( inR ) { 1876 while ( inR ) {
1877 if ( inR->typeID() == todoID ) { 1877 if ( inR->typeID() == todoID ) {
1878 Todo * t = (Todo*)inR; 1878 Todo * t = (Todo*)inR;
1879 if ( t->hasDueDate() ) 1879 if ( t->hasDueDate() )
1880 dt = t->dtDue(); 1880 dt = t->dtDue();
1881 else 1881 else
1882 dt = cur.addSecs( 62 ); 1882 dt = cur.addSecs( 62 );
1883 } 1883 }
1884 else if (inR->typeID() == eventID ) { 1884 else if (inR->typeID() == eventID ) {
1885 bool ok; 1885 bool ok;
1886 dt = inR->getNextOccurence( cur, &ok ); 1886 dt = inR->getNextOccurence( cur, &ok );
1887 if ( !ok ) 1887 if ( !ok )
1888 dt = cur.addSecs( -62 ); 1888 dt = cur.addSecs( -62 );
1889 } 1889 }
1890 else 1890 else
1891 dt = inR->dtStart(); 1891 dt = inR->dtStart();
1892 if ( dt < cur || dt > end ) { 1892 if ( dt < cur || dt > end ) {
1893 remote->deleteIncidence( inR ); 1893 remote->deleteIncidence( inR );
1894 ++delFut; 1894 ++delFut;
1895 } 1895 }
1896 inR = er.next(); 1896 inR = er.next();
1897 } 1897 }
1898 } 1898 }
1899 bar.hide(); 1899 bar.hide();
1900 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1900 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1901 eventLSync->setReadOnly( false ); 1901 eventLSync->setReadOnly( false );
1902 eventLSync->setDtStart( mLastCalendarSync ); 1902 eventLSync->setDtStart( mLastCalendarSync );
1903 eventRSync->setDtStart( mLastCalendarSync ); 1903 eventRSync->setDtStart( mLastCalendarSync );
1904 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1904 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1905 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1905 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1906 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1906 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1907 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1907 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1908 eventLSync->setReadOnly( true ); 1908 eventLSync->setReadOnly( true );
1909 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1909 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1910 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1910 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1911 remote->addEvent( eventRSync ); 1911 remote->addEvent( eventRSync );
1912 else 1912 else
1913 delete eventRSync; 1913 delete eventRSync;
1914 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1914 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1915 QString mes; 1915 QString mes;
1916 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1916 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1917 QString delmess; 1917 QString delmess;
1918 if ( delFut ) { 1918 if ( delFut ) {
1919 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1919 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1920 mes += delmess; 1920 mes += delmess;
1921 } 1921 }
1922 mes = i18n("Local calendar changed!\n") +mes; 1922 mes = i18n("Local calendar changed!\n") +mes;
1923 mCalendar->checkAlarmForIncidence( 0, true ); 1923 mCalendar->checkAlarmForIncidence( 0, true );
1924 qDebug( mes ); 1924 qDebug( mes );
1925 if ( mSyncManager->mShowSyncSummary ) { 1925 if ( mSyncManager->mShowSyncSummary ) {
1926 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1926 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1927 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1927 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1928 qDebug("KO: WB cancelled "); 1928 qDebug("KO: WB cancelled ");
1929 mSyncManager->mWriteBackFile = false; 1929 mSyncManager->mWriteBackFile = false;
1930 return syncOK; 1930 return syncOK;
1931 } 1931 }
1932 } 1932 }
1933 return syncOK; 1933 return syncOK;
1934} 1934}
1935 1935
1936void CalendarView::setSyncDevice( QString s ) 1936void CalendarView::setSyncDevice( QString s )
1937{ 1937{
1938 mCurrentSyncDevice= s; 1938 mCurrentSyncDevice= s;
1939} 1939}
1940void CalendarView::setSyncName( QString s ) 1940void CalendarView::setSyncName( QString s )
1941{ 1941{
1942 mCurrentSyncName= s; 1942 mCurrentSyncName= s;
1943} 1943}
1944bool CalendarView::syncCalendar(QString filename, int mode) 1944bool CalendarView::syncCalendar(QString filename, int mode)
1945{ 1945{
1946 //qDebug("syncCalendar %s ", filename.latin1()); 1946 //qDebug("syncCalendar %s ", filename.latin1());
1947 mGlobalSyncMode = SYNC_MODE_NORMAL; 1947 mGlobalSyncMode = SYNC_MODE_NORMAL;
1948 CalendarLocal* calendar = new CalendarLocal(); 1948 CalendarLocal* calendar = new CalendarLocal();
1949 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1949 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1950 FileStorage* storage = new FileStorage( calendar ); 1950 FileStorage* storage = new FileStorage( calendar );
1951 bool syncOK = false; 1951 bool syncOK = false;
1952 storage->setFileName( filename ); 1952 storage->setFileName( filename );
1953 // qDebug("loading ... "); 1953 // qDebug("loading ... ");
1954 if ( storage->load() ) { 1954 if ( storage->load() ) {
1955 getEventViewerDialog()->setSyncMode( true ); 1955 getEventViewerDialog()->setSyncMode( true );
1956 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1956 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1957 getEventViewerDialog()->setSyncMode( false ); 1957 getEventViewerDialog()->setSyncMode( false );
1958 if ( syncOK ) { 1958 if ( syncOK ) {
1959 if ( mSyncManager->mWriteBackFile ) 1959 if ( mSyncManager->mWriteBackFile )
1960 { 1960 {
1961 storage->setSaveFormat( new ICalFormat() ); 1961 storage->setSaveFormat( new ICalFormat() );
1962 storage->save(); 1962 storage->save();
1963 } 1963 }
1964 } 1964 }
1965 setModified( true ); 1965 setModified( true );
1966 } 1966 }
1967 delete storage; 1967 delete storage;
1968 delete calendar; 1968 delete calendar;
1969 if ( syncOK ) 1969 if ( syncOK )
1970 updateView(); 1970 updateView();
1971 return syncOK; 1971 return syncOK;
1972} 1972}
1973 1973
1974void CalendarView::syncExternal( int mode ) 1974void CalendarView::syncExternal( int mode )
1975{ 1975{
1976 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1976 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1977 1977
1978 qApp->processEvents(); 1978 qApp->processEvents();
1979 CalendarLocal* calendar = new CalendarLocal(); 1979 CalendarLocal* calendar = new CalendarLocal();
1980 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1980 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1981 bool syncOK = false; 1981 bool syncOK = false;
1982 bool loadSuccess = false; 1982 bool loadSuccess = false;
1983 PhoneFormat* phoneFormat = 0; 1983 PhoneFormat* phoneFormat = 0;
1984 emit tempDisableBR(true); 1984 emit tempDisableBR(true);
1985#ifndef DESKTOP_VERSION 1985#ifndef DESKTOP_VERSION
1986 SharpFormat* sharpFormat = 0; 1986 SharpFormat* sharpFormat = 0;
1987 if ( mode == 0 ) { // sharp 1987 if ( mode == 0 ) { // sharp
1988 sharpFormat = new SharpFormat () ; 1988 sharpFormat = new SharpFormat () ;
1989 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1989 loadSuccess = sharpFormat->load( calendar, mCalendar );
1990 1990
1991 } else 1991 } else
1992#endif 1992#endif
1993 if ( mode == 1 ) { // phone 1993 if ( mode == 1 ) { // phone
1994 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1994 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1995 mSyncManager->mPhoneDevice, 1995 mSyncManager->mPhoneDevice,
1996 mSyncManager->mPhoneConnection, 1996 mSyncManager->mPhoneConnection,
1997 mSyncManager->mPhoneModel); 1997 mSyncManager->mPhoneModel);
1998 loadSuccess = phoneFormat->load( calendar,mCalendar); 1998 loadSuccess = phoneFormat->load( calendar,mCalendar);
1999 1999
2000 } else { 2000 } else {
2001 emit tempDisableBR(false); 2001 emit tempDisableBR(false);
2002 return; 2002 return;
2003 } 2003 }
2004 if ( loadSuccess ) { 2004 if ( loadSuccess ) {
2005 getEventViewerDialog()->setSyncMode( true ); 2005 getEventViewerDialog()->setSyncMode( true );
2006 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2006 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2007 getEventViewerDialog()->setSyncMode( false ); 2007 getEventViewerDialog()->setSyncMode( false );
2008 qApp->processEvents(); 2008 qApp->processEvents();
2009 if ( syncOK ) { 2009 if ( syncOK ) {
2010 if ( mSyncManager->mWriteBackFile ) 2010 if ( mSyncManager->mWriteBackFile )
2011 { 2011 {
2012 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 2012 QPtrList<Incidence> iL = mCalendar->rawIncidences();
2013 Incidence* inc = iL.first(); 2013 Incidence* inc = iL.first();
2014 if ( phoneFormat ) { 2014 if ( phoneFormat ) {
2015 while ( inc ) { 2015 while ( inc ) {
2016 inc->removeID(mCurrentSyncDevice); 2016 inc->removeID(mCurrentSyncDevice);
2017 inc = iL.next(); 2017 inc = iL.next();
2018 } 2018 }
2019 } 2019 }
2020#ifndef DESKTOP_VERSION 2020#ifndef DESKTOP_VERSION
2021 if ( sharpFormat ) 2021 if ( sharpFormat )
2022 sharpFormat->save(calendar); 2022 sharpFormat->save(calendar);
2023#endif 2023#endif
2024 if ( phoneFormat ) 2024 if ( phoneFormat )
2025 phoneFormat->save(calendar); 2025 phoneFormat->save(calendar);
2026 iL = calendar->rawIncidences(); 2026 iL = calendar->rawIncidences();
2027 inc = iL.first(); 2027 inc = iL.first();
2028 Incidence* loc; 2028 Incidence* loc;
2029 while ( inc ) { 2029 while ( inc ) {
2030 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 2030 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
2031 loc = mCalendar->incidence(inc->uid() ); 2031 loc = mCalendar->incidence(inc->uid() );
2032 if ( loc ) { 2032 if ( loc ) {
2033 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 2033 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
2034 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 2034 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
2035 } 2035 }
2036 } 2036 }
2037 inc = iL.next(); 2037 inc = iL.next();
2038 } 2038 }
2039 Incidence* lse = getLastSyncEvent(); 2039 Incidence* lse = getLastSyncEvent();
2040 if ( lse ) { 2040 if ( lse ) {
2041 lse->setReadOnly( false ); 2041 lse->setReadOnly( false );
2042 lse->setDescription( "" ); 2042 lse->setDescription( "" );
2043 lse->setReadOnly( true ); 2043 lse->setReadOnly( true );
2044 } 2044 }
2045 } 2045 }
2046 } else { 2046 } else {
2047 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 2047 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
2048 } 2048 }
2049 setModified( true ); 2049 setModified( true );
2050 } else { 2050 } else {
2051 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 2051 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
2052 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 2052 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
2053 question, i18n("Ok")) ; 2053 question, i18n("Ok")) ;
2054 2054
2055 } 2055 }
2056 delete calendar; 2056 delete calendar;
2057 updateView(); 2057 updateView();
2058 emit tempDisableBR(false); 2058 emit tempDisableBR(false);
2059 return ;//syncOK; 2059 return ;//syncOK;
2060 2060
2061} 2061}
2062 2062
2063bool CalendarView::importBday() 2063bool CalendarView::importBday()
2064{ 2064{
2065#ifndef KORG_NOKABC 2065#ifndef KORG_NOKABC
2066 2066
2067#ifdef DESKTOP_VERSION 2067#ifdef DESKTOP_VERSION
2068 int curCal = mCalendar->defaultCalendar(); 2068 int curCal = mCalendar->defaultCalendar();
2069 int bd = mCalEditView->getBirtdayID(); 2069 int bd = mCalEditView->getBirtdayID();
2070 if ( bd == 0 ) 2070 if ( bd == 0 )
2071 return false; 2071 return false;
2072 mCalendar->setDefaultCalendar( bd ); 2072 mCalendar->setDefaultCalendar( bd );
2073 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 2073 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
2074 KABC::AddressBook::Iterator it; 2074 KABC::AddressBook::Iterator it;
2075 int count = 0; 2075 int count = 0;
2076 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2076 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2077 ++count; 2077 ++count;
2078 } 2078 }
2079 QProgressBar bar(count,0 ); 2079 QProgressBar bar(count,0 );
2080 int w = 300; 2080 int w = 300;
2081 if ( QApplication::desktop()->width() < 320 ) 2081 if ( QApplication::desktop()->width() < 320 )
2082 w = 220; 2082 w = 220;
2083 int h = bar.sizeHint().height() ; 2083 int h = bar.sizeHint().height() ;
2084 int dw = QApplication::desktop()->width(); 2084 int dw = QApplication::desktop()->width();
2085 int dh = QApplication::desktop()->height(); 2085 int dh = QApplication::desktop()->height();
2086 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2086 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2087 bar.show(); 2087 bar.show();
2088 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 2088 bar.setCaption (i18n("Reading addressbook - close to abort!") );
2089 qApp->processEvents(); 2089 qApp->processEvents();
2090 count = 0; 2090 count = 0;
2091 int addCount = 0; 2091 int addCount = 0;
2092 KCal::Attendee* a = 0; 2092 KCal::Attendee* a = 0;
2093 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2093 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2094 if ( ! bar.isVisible() ) 2094 if ( ! bar.isVisible() )
2095 return false; 2095 return false;
2096 bar.setProgress( count++ ); 2096 bar.setProgress( count++ );
2097 qApp->processEvents(); 2097 qApp->processEvents();
2098 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 2098 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
2099 if ( (*it).birthday().date().isValid() ){ 2099 if ( (*it).birthday().date().isValid() ){
2100 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2100 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2101 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 2101 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
2102 ++addCount; 2102 ++addCount;
2103 } 2103 }
2104 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 2104 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
2105 if ( anni.isValid() ){ 2105 if ( anni.isValid() ){
2106 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2106 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2107 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 2107 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
2108 ++addCount; 2108 ++addCount;
2109 } 2109 }
2110 } 2110 }
2111 mCalendar->setDefaultCalendar( curCal ); 2111 mCalendar->setDefaultCalendar( curCal );
2112 updateView(); 2112 updateView();
2113 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2113 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2114#else //DESKTOP_VERSION 2114#else //DESKTOP_VERSION
2115 2115
2116 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 2116 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
2117 // the result should now arrive through method insertBirthdays 2117 // the result should now arrive through method insertBirthdays
2118 2118
2119#endif //DESKTOP_VERSION 2119#endif //DESKTOP_VERSION
2120 2120
2121#endif //KORG_NOKABC 2121#endif //KORG_NOKABC
2122 2122
2123 2123
2124 return true; 2124 return true;
2125} 2125}
2126 2126
2127// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 2127// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
2128void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 2128void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
2129 const QStringList& anniversaryList, const QStringList& realNameList, 2129 const QStringList& anniversaryList, const QStringList& realNameList,
2130 const QStringList& emailList, const QStringList& assembledNameList, 2130 const QStringList& emailList, const QStringList& assembledNameList,
2131 const QStringList& uidList) 2131 const QStringList& uidList)
2132{ 2132{
2133 2133
2134 //qDebug("KO::CalendarView::insertBirthdays"); 2134 //qDebug("KO::CalendarView::insertBirthdays");
2135 if (uid == this->name()) 2135 if (uid == this->name())
2136 { 2136 {
2137 int curCal = mCalendar->defaultCalendar(); 2137 int curCal = mCalendar->defaultCalendar();
2138 int bd = mCalEditView->getBirtdayID(); 2138 int bd = mCalEditView->getBirtdayID();
2139 if ( bd == 0 ) 2139 if ( bd == 0 )
2140 return; 2140 return;
2141 mCalendar->setDefaultCalendar( bd ); 2141 mCalendar->setDefaultCalendar( bd );
2142 2142
2143 2143
2144 int count = birthdayList.count(); 2144 int count = birthdayList.count();
2145 int addCount = 0; 2145 int addCount = 0;
2146 KCal::Attendee* a = 0; 2146 KCal::Attendee* a = 0;
2147 2147
2148 //qDebug("CalView 1 %i", count); 2148 //qDebug("CalView 1 %i", count);
2149 2149
2150 QProgressBar bar(count,0 ); 2150 QProgressBar bar(count,0 );
2151 int w = 300; 2151 int w = 300;
2152 if ( QApplication::desktop()->width() < 320 ) 2152 if ( QApplication::desktop()->width() < 320 )
2153 w = 220; 2153 w = 220;
2154 int h = bar.sizeHint().height() ; 2154 int h = bar.sizeHint().height() ;
2155 int dw = QApplication::desktop()->width(); 2155 int dw = QApplication::desktop()->width();
2156 int dh = QApplication::desktop()->height(); 2156 int dh = QApplication::desktop()->height();
2157 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2157 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2158 bar.show(); 2158 bar.show();
2159 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 2159 bar.setCaption (i18n("inserting birthdays - close to abort!") );
2160 qApp->processEvents(); 2160 qApp->processEvents();
2161 2161
2162 QDate birthday; 2162 QDate birthday;
2163 QDate anniversary; 2163 QDate anniversary;
2164 QString realName; 2164 QString realName;
2165 QString email; 2165 QString email;
2166 QString assembledName; 2166 QString assembledName;
2167 QString uid; 2167 QString uid;
2168 bool ok = true; 2168 bool ok = true;
2169 for ( int i = 0; i < count; i++) 2169 for ( int i = 0; i < count; i++)
2170 { 2170 {
2171 if ( ! bar.isVisible() ) 2171 if ( ! bar.isVisible() )
2172 return; 2172 return;
2173 bar.setProgress( i ); 2173 bar.setProgress( i );
2174 qApp->processEvents(); 2174 qApp->processEvents();
2175 2175
2176 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 2176 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
2177 if (!ok) { 2177 if (!ok) {
2178 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 2178 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
2179 } 2179 }
2180 2180
2181 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 2181 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
2182 if (!ok) { 2182 if (!ok) {
2183 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 2183 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
2184 } 2184 }
2185 realName = realNameList[i]; 2185 realName = realNameList[i];
2186 email = emailList[i]; 2186 email = emailList[i];
2187 assembledName = assembledNameList[i]; 2187 assembledName = assembledNameList[i];
2188 uid = uidList[i]; 2188 uid = uidList[i];
2189 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 2189 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
2190 2190
2191 if ( birthday.isValid() ){ 2191 if ( birthday.isValid() ){
2192 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2192 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2193 KCal::Attendee::ReqParticipant,uid) ; 2193 KCal::Attendee::ReqParticipant,uid) ;
2194 if ( addAnniversary( birthday, assembledName, a, true ) ) 2194 if ( addAnniversary( birthday, assembledName, a, true ) )
2195 ++addCount; 2195 ++addCount;
2196 } 2196 }
2197 2197
2198 if ( anniversary.isValid() ){ 2198 if ( anniversary.isValid() ){
2199 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2199 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2200 KCal::Attendee::ReqParticipant,uid) ; 2200 KCal::Attendee::ReqParticipant,uid) ;
2201 if ( addAnniversary( anniversary, assembledName, a, false ) ) 2201 if ( addAnniversary( anniversary, assembledName, a, false ) )
2202 ++addCount; 2202 ++addCount;
2203 } 2203 }
2204 } 2204 }
2205 2205
2206 mCalendar->setDefaultCalendar( curCal ); 2206 mCalendar->setDefaultCalendar( curCal );
2207 updateView(); 2207 updateView();
2208 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2208 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2209 2209
2210 } 2210 }
2211 2211
2212} 2212}
2213 2213
2214 2214
2215 2215
2216bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 2216bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
2217{ 2217{
2218 //qDebug("addAnni "); 2218 //qDebug("addAnni ");
2219 Event * ev = new Event(); 2219 Event * ev = new Event();
2220 ev->setOrganizer(KOPrefs::instance()->email()); 2220 ev->setOrganizer(KOPrefs::instance()->email());
2221 if ( a ) { 2221 if ( a ) {
2222 ev->addAttendee( a ); 2222 ev->addAttendee( a );
2223 } 2223 }
2224 QString kind; 2224 QString kind;
2225 if ( birthday ) { 2225 if ( birthday ) {
2226 kind = i18n( "Birthday" ); 2226 kind = i18n( "Birthday" );
2227 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 2227 ev->setSummary( name + " (" + QString::number(date.year()) +")");
2228 } 2228 }
2229 else { 2229 else {
2230 kind = i18n( "Anniversary" ); 2230 kind = i18n( "Anniversary" );
2231 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 2231 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
2232 } 2232 }
2233 ev->setCategories( kind ); 2233 ev->setCategories( kind );
2234 ev->setDtStart( QDateTime(date) ); 2234 ev->setDtStart( QDateTime(date) );
2235 ev->setDtEnd( QDateTime(date) ); 2235 ev->setDtEnd( QDateTime(date) );
2236 ev->setFloats( true ); 2236 ev->setFloats( true );
2237 Recurrence * rec = ev->recurrence(); 2237 Recurrence * rec = ev->recurrence();
2238 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 2238 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
2239 rec->addYearlyNum( date.month() ); 2239 rec->addYearlyNum( date.month() );
2240 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 2240 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
2241 delete ev; 2241 delete ev;
2242 return false; 2242 return false;
2243 } 2243 }
2244 return true; 2244 return true;
2245 2245
2246} 2246}
2247bool CalendarView::importQtopia( const QString &categories, 2247bool CalendarView::importQtopia( const QString &categories,
2248 const QString &datebook, 2248 const QString &datebook,
2249 const QString &todolist ) 2249 const QString &todolist )
2250{ 2250{
2251 2251
2252 QtopiaFormat qtopiaFormat; 2252 QtopiaFormat qtopiaFormat;
2253 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2253 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2254 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 2254 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
2255 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 2255 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
2256 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 2256 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
2257 2257
2258 updateView(); 2258 updateView();
2259 return true; 2259 return true;
2260 2260
2261#if 0 2261#if 0
2262 mGlobalSyncMode = SYNC_MODE_QTOPIA; 2262 mGlobalSyncMode = SYNC_MODE_QTOPIA;
2263 mCurrentSyncDevice = "qtopia-XML"; 2263 mCurrentSyncDevice = "qtopia-XML";
2264 if ( mSyncManager->mAskForPreferences ) 2264 if ( mSyncManager->mAskForPreferences )
2265 edit_sync_options(); 2265 edit_sync_options();
2266 qApp->processEvents(); 2266 qApp->processEvents();
2267 CalendarLocal* calendar = new CalendarLocal(); 2267 CalendarLocal* calendar = new CalendarLocal();
2268 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2268 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2269 bool syncOK = false; 2269 bool syncOK = false;
2270 QtopiaFormat qtopiaFormat; 2270 QtopiaFormat qtopiaFormat;
2271 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2271 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2272 bool loadOk = true; 2272 bool loadOk = true;
2273 if ( !categories.isEmpty() ) 2273 if ( !categories.isEmpty() )
2274 loadOk = qtopiaFormat.load( calendar, categories ); 2274 loadOk = qtopiaFormat.load( calendar, categories );
2275 if ( loadOk && !datebook.isEmpty() ) 2275 if ( loadOk && !datebook.isEmpty() )
2276 loadOk = qtopiaFormat.load( calendar, datebook ); 2276 loadOk = qtopiaFormat.load( calendar, datebook );
2277 if ( loadOk && !todolist.isEmpty() ) 2277 if ( loadOk && !todolist.isEmpty() )
2278 loadOk = qtopiaFormat.load( calendar, todolist ); 2278 loadOk = qtopiaFormat.load( calendar, todolist );
2279 2279
2280 if ( loadOk ) { 2280 if ( loadOk ) {
2281 getEventViewerDialog()->setSyncMode( true ); 2281 getEventViewerDialog()->setSyncMode( true );
2282 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2282 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2283 getEventViewerDialog()->setSyncMode( false ); 2283 getEventViewerDialog()->setSyncMode( false );
2284 qApp->processEvents(); 2284 qApp->processEvents();
2285 if ( syncOK ) { 2285 if ( syncOK ) {
2286 if ( mSyncManager->mWriteBackFile ) 2286 if ( mSyncManager->mWriteBackFile )
2287 { 2287 {
2288 // write back XML file 2288 // write back XML file
2289 2289
2290 } 2290 }
2291 setModified( true ); 2291 setModified( true );
2292 } 2292 }
2293 } else { 2293 } else {
2294 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 2294 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
2295 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 2295 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
2296 question, i18n("Ok")) ; 2296 question, i18n("Ok")) ;
2297 } 2297 }
2298 delete calendar; 2298 delete calendar;
2299 updateView(); 2299 updateView();
2300 return syncOK; 2300 return syncOK;
2301 2301
2302 2302
2303#endif 2303#endif
2304 2304
2305} 2305}
2306 2306
2307void CalendarView::setSyncEventsReadOnly() 2307void CalendarView::setSyncEventsReadOnly()
2308{ 2308{
2309 mCalendar->setSyncEventsReadOnly(); 2309 mCalendar->setSyncEventsReadOnly();
2310} 2310}
2311 2311
2312bool CalendarView::loadCalendars() 2312bool CalendarView::loadCalendars()
2313{ 2313{
2314 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2314 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2315 KopiCalendarFile * cal = calendars.first(); 2315 KopiCalendarFile * cal = calendars.first();
2316 mCalendar->setDefaultCalendar( 1 ); 2316 mCalendar->setDefaultCalendar( 1 );
2317 openCalendar( MainWindow::defaultFileName(), false ); 2317 openCalendar( MainWindow::defaultFileName(), false );
2318 cal = calendars.next(); 2318 cal = calendars.next();
2319 while ( cal ) { 2319 while ( cal ) {
2320 addCalendar( cal ); 2320 addCalendar( cal );
2321 cal = calendars.next(); 2321 cal = calendars.next();
2322 } 2322 }
2323 restoreCalendarSettings(); 2323 restoreCalendarSettings();
2324 return true; 2324 return true;
2325} 2325}
2326bool CalendarView::restoreCalendarSettings() 2326bool CalendarView::restoreCalendarSettings()
2327{ 2327{
2328 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2328 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2329 KopiCalendarFile * cal = calendars.first(); 2329 KopiCalendarFile * cal = calendars.first();
2330 while ( cal ) { 2330 while ( cal ) {
2331 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 2331 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
2332 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 2332 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
2333 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 2333 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
2334 if ( cal->isStandard ) 2334 if ( cal->isStandard )
2335 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2335 mCalendar->setDefaultCalendar( cal->mCalNumber );
2336 cal = calendars.next(); 2336 cal = calendars.next();
2337 } 2337 }
2338 setSyncEventsReadOnly(); 2338 setSyncEventsReadOnly();
2339 mCalendar->reInitAlarmSettings(); 2339 mCalendar->reInitAlarmSettings();
2340 updateUnmanagedViews(); 2340 updateUnmanagedViews();
2341 updateView(); 2341 updateView();
2342 return true; 2342 return true;
2343} 2343}
2344void CalendarView::addCalendarId( int id ) 2344void CalendarView::addCalendarId( int id )
2345{ 2345{
2346 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 2346 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
2347 if ( cal ) 2347 if ( cal )
2348 addCalendar( cal ); 2348 addCalendar( cal );
2349} 2349}
2350bool CalendarView::addCalendar( KopiCalendarFile * cal ) 2350bool CalendarView::addCalendar( KopiCalendarFile * cal )
2351{ 2351{
2352 cal->mErrorOnLoad = false; 2352 cal->mErrorOnLoad = false;
2353 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 2353 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
2354 cal->mLoadDt = QDateTime::currentDateTime(); 2354 cal->mLoadDt = QDateTime::currentDateTime();
2355 return true; 2355 return true;
2356 } 2356 }
2357 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); 2357 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() );
2358 cal->mErrorOnLoad = true; 2358 cal->mErrorOnLoad = true;
2359 return false; 2359 return false;
2360} 2360}
2361bool CalendarView::openCalendar(QString filename, bool merge) 2361bool CalendarView::openCalendar(QString filename, bool merge)
2362{ 2362{
2363 2363
2364 if (filename.isEmpty()) { 2364 if (filename.isEmpty()) {
2365 return false; 2365 return false;
2366 } 2366 }
2367 2367
2368 if (!QFile::exists(filename)) { 2368 if (!QFile::exists(filename)) {
2369 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 2369 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
2370 return false; 2370 return false;
2371 } 2371 }
2372 2372
2373 globalFlagBlockAgenda = 1; 2373 globalFlagBlockAgenda = 1;
2374 clearAllViews(); 2374 clearAllViews();
2375 if (!merge) { 2375 if (!merge) {
2376 mViewManager->setDocumentId( filename ); 2376 mViewManager->setDocumentId( filename );
2377 mCalendar->close(); 2377 mCalendar->close();
2378 } 2378 }
2379 mStorage->setFileName( filename ); 2379 mStorage->setFileName( filename );
2380 2380
2381 if ( mStorage->load() ) { 2381 if ( mStorage->load() ) {
2382 if ( merge ) ;//setModified( true ); 2382 if ( merge ) ;//setModified( true );
2383 else { 2383 else {
2384 //setModified( true ); 2384 //setModified( true );
2385 mViewManager->setDocumentId( filename ); 2385 mViewManager->setDocumentId( filename );
2386 mDialogManager->setDocumentId( filename ); 2386 mDialogManager->setDocumentId( filename );
2387 mTodoList->setDocumentId( filename ); 2387 mTodoList->setDocumentId( filename );
2388 } 2388 }
2389 globalFlagBlockAgenda = 2; 2389 globalFlagBlockAgenda = 2;
2390 // if ( getLastSyncEvent() ) 2390 // if ( getLastSyncEvent() )
2391 // getLastSyncEvent()->setReadOnly( true ); 2391 // getLastSyncEvent()->setReadOnly( true );
2392 mCalendar->reInitAlarmSettings(); 2392 mCalendar->reInitAlarmSettings();
2393 setSyncEventsReadOnly(); 2393 setSyncEventsReadOnly();
2394 updateUnmanagedViews(); 2394 //updateUnmanagedViews();
2395 updateView(); 2395 //updateView();
2396 if ( filename != MainWindow::defaultFileName() ) { 2396 if ( filename != MainWindow::defaultFileName() ) {
2397 saveCalendar( MainWindow::defaultFileName() ); 2397 saveCalendar( MainWindow::defaultFileName() );
2398 } else { 2398 } else {
2399 QFileInfo finf ( MainWindow::defaultFileName()); 2399 QFileInfo finf ( MainWindow::defaultFileName());
2400 if ( finf.exists() ) { 2400 if ( finf.exists() ) {
2401 setLoadedFileVersion( finf.lastModified () ); 2401 setLoadedFileVersion( finf.lastModified () );
2402 } 2402 }
2403 } 2403 }
2404 return true; 2404 return true;
2405 } else { 2405 } else {
2406 // while failing to load, the calendar object could 2406 // while failing to load, the calendar object could
2407 // have become partially populated. Clear it out. 2407 // have become partially populated. Clear it out.
2408 if ( !merge ) { 2408 if ( !merge ) {
2409 mCalendar->close(); 2409 mCalendar->close();
2410 mViewManager->setDocumentId( filename ); 2410 mViewManager->setDocumentId( filename );
2411 mDialogManager->setDocumentId( filename ); 2411 mDialogManager->setDocumentId( filename );
2412 mTodoList->setDocumentId( filename ); 2412 mTodoList->setDocumentId( filename );
2413 } 2413 }
2414 2414
2415 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 2415 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
2416 2416
2417 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 2417 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
2418 globalFlagBlockAgenda = 2; 2418 globalFlagBlockAgenda = 2;
2419 mCalendar->reInitAlarmSettings(); 2419 mCalendar->reInitAlarmSettings();
2420 setSyncEventsReadOnly(); 2420 setSyncEventsReadOnly();
2421 updateUnmanagedViews(); 2421 updateUnmanagedViews();
2422 updateView(); 2422 updateView();
2423 } 2423 }
2424 return false; 2424 return false;
2425} 2425}
2426void CalendarView::mergeFile( QString fn ) 2426void CalendarView::mergeFile( QString fn )
2427{ 2427{
2428 clearAllViews(); 2428 clearAllViews();
2429 mCalendar->mergeCalendarFile( fn ); 2429 mCalendar->mergeCalendarFile( fn );
2430 mCalendar->reInitAlarmSettings(); 2430 mCalendar->reInitAlarmSettings();
2431 setSyncEventsReadOnly(); 2431 setSyncEventsReadOnly();
2432 updateUnmanagedViews(); 2432 updateUnmanagedViews();
2433 updateView(); 2433 updateView();
2434} 2434}
2435void CalendarView::showOpenError() 2435void CalendarView::showOpenError()
2436{ 2436{
2437 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2437 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2438} 2438}
2439void CalendarView::setLoadedFileVersion(QDateTime dt) 2439void CalendarView::setLoadedFileVersion(QDateTime dt)
2440{ 2440{
2441 loadedFileVersion = dt; 2441 loadedFileVersion = dt;
2442} 2442}
2443bool CalendarView::checkFileChanged(QString fn) 2443bool CalendarView::checkFileChanged(QString fn)
2444{ 2444{
2445 QFileInfo finf ( fn ); 2445 QFileInfo finf ( fn );
2446 if ( !finf.exists() ) 2446 if ( !finf.exists() )
2447 return true; 2447 return true;
2448 QDateTime dt = finf.lastModified (); 2448 QDateTime dt = finf.lastModified ();
2449 if ( dt <= loadedFileVersion ) 2449 if ( dt <= loadedFileVersion )
2450 return false; 2450 return false;
2451 return true; 2451 return true;
2452 2452
2453} 2453}
2454void CalendarView::watchSavedFile() 2454void CalendarView::watchSavedFile()
2455{ 2455{
2456 QFileInfo finf ( MainWindow::defaultFileName()); 2456 QFileInfo finf ( MainWindow::defaultFileName());
2457 if ( !finf.exists() ) 2457 if ( !finf.exists() )
2458 return; 2458 return;
2459 QDateTime dt = finf.lastModified (); 2459 QDateTime dt = finf.lastModified ();
2460 if ( dt < loadedFileVersion ) { 2460 if ( dt < loadedFileVersion ) {
2461 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2461 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2462 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2462 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2463 return; 2463 return;
2464 } 2464 }
2465 loadedFileVersion = dt; 2465 loadedFileVersion = dt;
2466} 2466}
2467bool CalendarView::checkAllFileVersions() 2467bool CalendarView::checkAllFileVersions()
2468{ 2468{
2469 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2469 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2470 KopiCalendarFile * cal = calendars.first(); 2470 KopiCalendarFile * cal = calendars.first();
2471 mCalendar->setDefaultCalendar( 1 ); 2471 mCalendar->setDefaultCalendar( 1 );
2472 mCalendar->setDefaultCalendarEnabledOnly(); 2472 mCalendar->setDefaultCalendarEnabledOnly();
2473 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2473 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2474 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2474 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2475 restoreCalendarSettings(); 2475 restoreCalendarSettings();
2476 return false; 2476 return false;
2477 } 2477 }
2478 } 2478 }
2479 cal = calendars.next(); 2479 cal = calendars.next();
2480 QDateTime storeTemp = loadedFileVersion; 2480 QDateTime storeTemp = loadedFileVersion;
2481 while ( cal ) { 2481 while ( cal ) {
2482 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2482 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2483 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2483 mCalendar->setDefaultCalendar( cal->mCalNumber );
2484 mCalendar->setDefaultCalendarEnabledOnly(); 2484 mCalendar->setDefaultCalendarEnabledOnly();
2485 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2485 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2486 if ( !checkFileVersion(cal->mFileName )) { 2486 if ( !checkFileVersion(cal->mFileName )) {
2487 loadedFileVersion = storeTemp; 2487 loadedFileVersion = storeTemp;
2488 restoreCalendarSettings(); 2488 restoreCalendarSettings();
2489 return false; 2489 return false;
2490 } 2490 }
2491 } 2491 }
2492 cal = calendars.next(); 2492 cal = calendars.next();
2493 } 2493 }
2494 loadedFileVersion = storeTemp; 2494 loadedFileVersion = storeTemp;
2495 return true; 2495 return true;
2496} 2496}
2497bool CalendarView::checkFileVersion(QString fn) 2497bool CalendarView::checkFileVersion(QString fn)
2498{ 2498{
2499 QFileInfo finf ( fn ); 2499 QFileInfo finf ( fn );
2500 if ( !finf.exists() ) 2500 if ( !finf.exists() )
2501 return true; 2501 return true;
2502 QDateTime dt = finf.lastModified (); 2502 QDateTime dt = finf.lastModified ();
2503 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2503 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2504 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2504 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2505 if ( dt <= loadedFileVersion ) 2505 if ( dt <= loadedFileVersion )
2506 return true; 2506 return true;
2507 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2507 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2508 i18n("KO/Pi Warning"),i18n("Overwrite"), 2508 i18n("KO/Pi Warning"),i18n("Overwrite"),
2509 i18n("Sync+save")); 2509 i18n("Sync+save"));
2510 2510
2511 if ( km == KMessageBox::Cancel ) 2511 if ( km == KMessageBox::Cancel )
2512 return false; 2512 return false;
2513 if ( km == KMessageBox::Yes ) 2513 if ( km == KMessageBox::Yes )
2514 return true; 2514 return true;
2515 2515
2516 setSyncDevice("deleteaftersync" ); 2516 setSyncDevice("deleteaftersync" );
2517 mSyncManager->mAskForPreferences = true; 2517 mSyncManager->mAskForPreferences = true;
2518 mSyncManager->mSyncAlgoPrefs = 3; 2518 mSyncManager->mSyncAlgoPrefs = 3;
2519 mSyncManager->mWriteBackFile = false; 2519 mSyncManager->mWriteBackFile = false;
2520 mSyncManager->mWriteBackExistingOnly = false; 2520 mSyncManager->mWriteBackExistingOnly = false;
2521 mSyncManager->mShowSyncSummary = false; 2521 mSyncManager->mShowSyncSummary = false;
2522 syncCalendar( fn, 3 ); 2522 syncCalendar( fn, 3 );
2523 Event * e = getLastSyncEvent(); 2523 Event * e = getLastSyncEvent();
2524 if ( e ) 2524 if ( e )
2525 mCalendar->deleteEvent( e ); 2525 mCalendar->deleteEvent( e );
2526 return true; 2526 return true;
2527} 2527}
2528bool CalendarView::saveCalendars() 2528bool CalendarView::saveCalendars()
2529{ 2529{
2530 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2530 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2531 KopiCalendarFile * cal = calendars.first(); 2531 KopiCalendarFile * cal = calendars.first();
2532 mCalendar->setDefaultCalendar( 1 ); 2532 mCalendar->setDefaultCalendar( 1 );
2533 mCalendar->setDefaultCalendarEnabledOnly(); 2533 mCalendar->setDefaultCalendarEnabledOnly();
2534 QString saveError; 2534 QString saveError;
2535 if ( !saveCalendar( MainWindow::defaultFileName() ) ) 2535 if ( !saveCalendar( MainWindow::defaultFileName() ) )
2536 saveError = cal->mName +"\n"; 2536 saveError = cal->mName +"\n";
2537 cal = calendars.next(); 2537 cal = calendars.next();
2538 while ( cal ) { 2538 while ( cal ) {
2539 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2539 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2540 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2540 mCalendar->setDefaultCalendar( cal->mCalNumber );
2541 mCalendar->setDefaultCalendarEnabledOnly(); 2541 mCalendar->setDefaultCalendarEnabledOnly();
2542 if ( saveCalendar( cal->mFileName ) ) 2542 if ( saveCalendar( cal->mFileName ) )
2543 cal->mLoadDt = QDateTime::currentDateTime(); 2543 cal->mLoadDt = QDateTime::currentDateTime();
2544 else 2544 else
2545 saveError += cal->mName + "\n"; 2545 saveError += cal->mName + "\n";
2546 } 2546 }
2547 cal = calendars.next(); 2547 cal = calendars.next();
2548 } 2548 }
2549 restoreCalendarSettings(); 2549 restoreCalendarSettings();
2550 if ( !saveError.isEmpty() ) { 2550 if ( !saveError.isEmpty() ) {
2551 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; 2551 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError;
2552 KMessageBox::error(this, saveError, i18n("Error saving data")); 2552 KMessageBox::error(this, saveError, i18n("Error saving data"));
2553 return false; 2553 return false;
2554 } 2554 }
2555 return true; 2555 return true;
2556} 2556}
2557bool CalendarView::saveCalendar( QString filename ) 2557bool CalendarView::saveCalendar( QString filename )
2558{ 2558{
2559 2559
2560 // Store back all unsaved data into calendar object 2560 // Store back all unsaved data into calendar object
2561 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2561 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2562 if ( mViewManager->currentView() ) 2562 if ( mViewManager->currentView() )
2563 mViewManager->currentView()->flushView(); 2563 mViewManager->currentView()->flushView();
2564 2564
2565 2565
2566 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2566 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2567 mStorage->setSaveFormat( new ICalFormat() ); 2567 mStorage->setSaveFormat( new ICalFormat() );
2568 mStorage->setFileName( filename ); 2568 mStorage->setFileName( filename );
2569 bool success; 2569 bool success;
2570 success = mStorage->save(); 2570 success = mStorage->save();
2571 if ( !success ) { 2571 if ( !success ) {
2572 return false; 2572 return false;
2573 } 2573 }
2574 if ( filename == MainWindow::defaultFileName() ) { 2574 if ( filename == MainWindow::defaultFileName() ) {
2575 setLoadedFileVersion( lfv ); 2575 setLoadedFileVersion( lfv );
2576 watchSavedFile(); 2576 watchSavedFile();
2577 } 2577 }
2578 return true; 2578 return true;
2579} 2579}
2580 2580
2581void CalendarView::closeCalendar() 2581void CalendarView::closeCalendar()
2582{ 2582{
2583 2583
2584 // child windows no longer valid 2584 // child windows no longer valid
2585 clearAllViews(); 2585 clearAllViews();
2586 emit closingDown(); 2586 emit closingDown();
2587 2587
2588 mCalendar->close(); 2588 mCalendar->close();
2589 setModified(false); 2589 setModified(false);
2590 updateView(); 2590 updateView();
2591} 2591}
2592 2592
2593void CalendarView::archiveCalendar() 2593void CalendarView::archiveCalendar()
2594{ 2594{
2595 mDialogManager->showArchiveDialog(); 2595 mDialogManager->showArchiveDialog();
2596} 2596}
2597 2597
2598 2598
2599void CalendarView::readSettings() 2599void CalendarView::readSettings()
2600{ 2600{
2601 2601
2602 2602
2603 // mViewManager->showAgendaView(); 2603 // mViewManager->showAgendaView();
2604 QString str; 2604 QString str;
2605 //qDebug("CalendarView::readSettings() "); 2605 //qDebug("CalendarView::readSettings() ");
2606 // read settings from the KConfig, supplying reasonable 2606 // read settings from the KConfig, supplying reasonable
2607 // defaults where none are to be found 2607 // defaults where none are to be found
2608 KConfig *config = KOGlobals::config(); 2608 KConfig *config = KOGlobals::config();
2609#ifndef KORG_NOSPLITTER 2609#ifndef KORG_NOSPLITTER
2610 config->setGroup("KOrganizer Geometry"); 2610 config->setGroup("KOrganizer Geometry");
2611 2611
2612 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2612 QValueList<int> sizes = config->readIntListEntry("Separator1");
2613 if (sizes.count() != 2) { 2613 if (sizes.count() != 2) {
2614 sizes << mDateNavigator->minimumSizeHint().width(); 2614 sizes << mDateNavigator->minimumSizeHint().width();
2615 sizes << 300; 2615 sizes << 300;
2616 } 2616 }
2617 mPanner->setSizes(sizes); 2617 mPanner->setSizes(sizes);
2618 2618
2619 sizes = config->readIntListEntry("Separator2"); 2619 sizes = config->readIntListEntry("Separator2");
2620 if ( ( mResourceView && sizes.count() == 4 ) || 2620 if ( ( mResourceView && sizes.count() == 4 ) ||
2621 ( !mResourceView && sizes.count() == 3 ) ) { 2621 ( !mResourceView && sizes.count() == 3 ) ) {
2622 mLeftSplitter->setSizes(sizes); 2622 mLeftSplitter->setSizes(sizes);
2623 } 2623 }
2624#endif 2624#endif
2625 globalFlagBlockAgenda = 1; 2625 globalFlagBlockAgenda = 1;
2626 mViewManager->showAgendaView(); 2626 mViewManager->showAgendaView();
2627 //mViewManager->readSettings( config ); 2627 //mViewManager->readSettings( config );
2628 mTodoList->restoreLayout(config,QString("Todo Layout")); 2628 mTodoList->restoreLayout(config,QString("Todo Layout"));
2629 readFilterSettings(config); 2629 readFilterSettings(config);
2630 2630
2631#ifdef DESKTOP_VERSION 2631#ifdef DESKTOP_VERSION
2632 config->setGroup("WidgetLayout"); 2632 config->setGroup("WidgetLayout");
2633 QStringList list; 2633 QStringList list;
2634 list = config->readListEntry("MainLayout"); 2634 list = config->readListEntry("MainLayout");
2635 int x,y,w,h; 2635 int x,y,w,h;
2636 if ( ! list.isEmpty() ) { 2636 if ( ! list.isEmpty() ) {
2637 x = list[0].toInt(); 2637 x = list[0].toInt();
2638 y = list[1].toInt(); 2638 y = list[1].toInt();
2639 w = list[2].toInt(); 2639 w = list[2].toInt();
2640 h = list[3].toInt(); 2640 h = list[3].toInt();
2641 KApplication::testCoords( &x,&y,&w,&h ); 2641 KApplication::testCoords( &x,&y,&w,&h );
2642 topLevelWidget()->setGeometry(x,y,w,h); 2642 topLevelWidget()->setGeometry(x,y,w,h);
2643 2643
2644 } else { 2644 } else {
2645 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2645 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2646 } 2646 }
2647 list = config->readListEntry("EditEventLayout"); 2647 list = config->readListEntry("EditEventLayout");
2648 if ( ! list.isEmpty() ) { 2648 if ( ! list.isEmpty() ) {
2649 x = list[0].toInt(); 2649 x = list[0].toInt();
2650 y = list[1].toInt(); 2650 y = list[1].toInt();
2651 w = list[2].toInt(); 2651 w = list[2].toInt();
2652 h = list[3].toInt(); 2652 h = list[3].toInt();
2653 KApplication::testCoords( &x,&y,&w,&h ); 2653 KApplication::testCoords( &x,&y,&w,&h );
2654 mEventEditor->setGeometry(x,y,w,h); 2654 mEventEditor->setGeometry(x,y,w,h);
2655 2655
2656 } 2656 }
2657 list = config->readListEntry("EditTodoLayout"); 2657 list = config->readListEntry("EditTodoLayout");
2658 if ( ! list.isEmpty() ) { 2658 if ( ! list.isEmpty() ) {
2659 x = list[0].toInt(); 2659 x = list[0].toInt();
2660 y = list[1].toInt(); 2660 y = list[1].toInt();
2661 w = list[2].toInt(); 2661 w = list[2].toInt();
2662 h = list[3].toInt(); 2662 h = list[3].toInt();
2663 KApplication::testCoords( &x,&y,&w,&h ); 2663 KApplication::testCoords( &x,&y,&w,&h );
2664 mTodoEditor->setGeometry(x,y,w,h); 2664 mTodoEditor->setGeometry(x,y,w,h);
2665 2665
2666 } 2666 }
2667 list = config->readListEntry("ViewerLayout"); 2667 list = config->readListEntry("ViewerLayout");
2668 if ( ! list.isEmpty() ) { 2668 if ( ! list.isEmpty() ) {
2669 x = list[0].toInt(); 2669 x = list[0].toInt();
2670 y = list[1].toInt(); 2670 y = list[1].toInt();
2671 w = list[2].toInt(); 2671 w = list[2].toInt();
2672 h = list[3].toInt(); 2672 h = list[3].toInt();
2673 KApplication::testCoords( &x,&y,&w,&h ); 2673 KApplication::testCoords( &x,&y,&w,&h );
2674 getEventViewerDialog()->setGeometry(x,y,w,h); 2674 getEventViewerDialog()->setGeometry(x,y,w,h);
2675 } 2675 }
2676#endif 2676#endif
2677 config->setGroup( "Views" ); 2677 config->setGroup( "Views" );
2678 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2678 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2679 2679
2680 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2680 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2681 2681
2682 int resetval = 0; 2682 int resetval = 0;
2683 int maxVal = 0; 2683 int maxVal = 0;
2684 if (sizes.count() != 3) { 2684 if (sizes.count() != 3) {
2685 if ( KOPrefs::instance()->mVerticalScreen ) { 2685 if ( KOPrefs::instance()->mVerticalScreen ) {
2686 resetval = mDateNavigator->sizeHint().width()+2; 2686 resetval = mDateNavigator->sizeHint().width()+2;
2687 } else { 2687 } else {
2688 resetval = mDateNavigator->sizeHint().height()+2; 2688 resetval = mDateNavigator->sizeHint().height()+2;
2689 } 2689 }
2690 } 2690 }
2691 if ( resetval ) { 2691 if ( resetval ) {
2692 sizes.clear(); 2692 sizes.clear();
2693 if ( KOPrefs::instance()->mVerticalScreen ) { 2693 if ( KOPrefs::instance()->mVerticalScreen ) {
2694 maxVal = QApplication::desktop()->width() -10; 2694 maxVal = QApplication::desktop()->width() -10;
2695 } else { 2695 } else {
2696 maxVal = QApplication::desktop()->height()-10; 2696 maxVal = QApplication::desktop()->height()-10;
2697 } 2697 }
2698 sizes << resetval; 2698 sizes << resetval;
2699 if ( maxVal < resetval + resetval) 2699 if ( maxVal < resetval + resetval)
2700 resetval = maxVal - resetval; 2700 resetval = maxVal - resetval;
2701 sizes << resetval; 2701 sizes << resetval;
2702 sizes << 100; 2702 sizes << 100;
2703 } 2703 }
2704 mLeftFrame->setSizes(sizes); 2704 mLeftFrame->setSizes(sizes);
2705 sizes = config->readIntListEntry("Main Splitter Frame"); 2705 sizes = config->readIntListEntry("Main Splitter Frame");
2706 resetval = 0; 2706 resetval = 0;
2707 maxVal = 0; 2707 maxVal = 0;
2708 if (sizes.count() != 2) { 2708 if (sizes.count() != 2) {
2709 if ( !KOPrefs::instance()->mVerticalScreen ) { 2709 if ( !KOPrefs::instance()->mVerticalScreen ) {
2710 resetval = mDateNavigator->sizeHint().width()+2; 2710 resetval = mDateNavigator->sizeHint().width()+2;
2711 } else { 2711 } else {
2712 resetval = mDateNavigator->sizeHint().height()+2; 2712 resetval = mDateNavigator->sizeHint().height()+2;
2713 } 2713 }
2714 } 2714 }
2715 if ( resetval ) { 2715 if ( resetval ) {
2716 sizes.clear(); 2716 sizes.clear();
2717 if ( !KOPrefs::instance()->mVerticalScreen ) { 2717 if ( !KOPrefs::instance()->mVerticalScreen ) {
2718 maxVal = QApplication::desktop()->width() -10; 2718 maxVal = QApplication::desktop()->width() -10;
2719 } else { 2719 } else {
2720 maxVal = QApplication::desktop()->height()-10; 2720 maxVal = QApplication::desktop()->height()-10;
2721 } 2721 }
2722 sizes << resetval; 2722 sizes << resetval;
2723 if ( maxVal < resetval + resetval) 2723 if ( maxVal < resetval + resetval)
2724 resetval = maxVal - resetval; 2724 resetval = maxVal - resetval;
2725 sizes << resetval; 2725 sizes << resetval;
2726 } 2726 }
2727 mMainFrame->setSizes(sizes); 2727 mMainFrame->setSizes(sizes);
2728 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2728 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2729 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2729 else if ( dateCount == 7 ) mNavigator->selectWeek();
2730 else mNavigator->selectDates( dateCount ); 2730 else mNavigator->selectDates( dateCount );
2731 // mViewManager->readSettings( config ); 2731 // mViewManager->readSettings( config );
2732 updateConfig(); 2732 updateConfig();
2733 globalFlagBlockAgenda = 2; 2733 globalFlagBlockAgenda = 2;
2734 mViewManager->readSettings( config ); 2734 mViewManager->readSettings( config );
2735 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2735 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2736} 2736}
2737 2737
2738void CalendarView::checkSuspendAlarm() 2738void CalendarView::checkSuspendAlarm()
2739{ 2739{
2740 if ( mSuspendTimer->isActive() ) { 2740 if ( mSuspendTimer->isActive() ) {
2741 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2741 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2742 } 2742 }
2743} 2743}
2744void CalendarView::writeSettings() 2744void CalendarView::writeSettings()
2745{ 2745{
2746 // kdDebug() << "CalendarView::writeSettings" << endl; 2746 // kdDebug() << "CalendarView::writeSettings" << endl;
2747 2747
2748 KConfig *config = KOGlobals::config(); 2748 KConfig *config = KOGlobals::config();
2749 2749
2750 mViewManager->writeSettings( config ); 2750 mViewManager->writeSettings( config );
2751 mTodoList->saveLayout(config,QString("Todo Layout")); 2751 mTodoList->saveLayout(config,QString("Todo Layout"));
2752 mDialogManager->writeSettings( config ); 2752 mDialogManager->writeSettings( config );
2753 //KOPrefs::instance()->usrWriteConfig(); 2753 //KOPrefs::instance()->usrWriteConfig();
2754 KOPrefs::instance()->writeConfig(); 2754 KOPrefs::instance()->writeConfig();
2755 2755
2756 writeFilterSettings(config); 2756 writeFilterSettings(config);
2757 config->setGroup( "AppRun" ); 2757 config->setGroup( "AppRun" );
2758 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2758 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2759 int days = dt.daysTo( QDate::currentDate() ); 2759 int days = dt.daysTo( QDate::currentDate() );
2760 dt = dt.addDays( days ); 2760 dt = dt.addDays( days );
2761 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2761 int secs = dt.secsTo( QDateTime::currentDateTime() );
2762 config->writeEntry( "LatestProgramStopDays", days ); 2762 config->writeEntry( "LatestProgramStopDays", days );
2763 config->writeEntry( "LatestProgramStopSecs", secs ); 2763 config->writeEntry( "LatestProgramStopSecs", secs );
2764 //qDebug("KO: Writing stop time: %d ", secs); 2764 //qDebug("KO: Writing stop time: %d ", secs);
2765 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2765 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2766 //QDateTime latest = dt.addSecs ( secs ); 2766 //QDateTime latest = dt.addSecs ( secs );
2767 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2767 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2768 config->setGroup( "Views" ); 2768 config->setGroup( "Views" );
2769 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2769 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2770 2770
2771#if 0 2771#if 0
2772 qDebug("********************* "); 2772 qDebug("********************* ");
2773 qDebug("Testcode secsto "); 2773 qDebug("Testcode secsto ");
2774 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2774 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2775 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2775 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2776 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2776 int secsto = dt_nodaylight.secsTo( dt_daylight );
2777 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2777 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2778 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2778 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2779 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2779 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2780 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2780 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2781 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2781 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2782 qDebug("********************* testcode end"); 2782 qDebug("********************* testcode end");
2783 2783
2784#endif 2784#endif
2785 2785
2786 QValueList<int> listINT = mLeftFrame->sizes(); 2786 QValueList<int> listINT = mLeftFrame->sizes();
2787 config->writeEntry("Left Splitter Frame",listINT); 2787 config->writeEntry("Left Splitter Frame",listINT);
2788 QValueList<int> listINT2 = mMainFrame->sizes(); 2788 QValueList<int> listINT2 = mMainFrame->sizes();
2789 config->writeEntry("Main Splitter Frame",listINT2); 2789 config->writeEntry("Main Splitter Frame",listINT2);
2790#ifdef DESKTOP_VERSION 2790#ifdef DESKTOP_VERSION
2791 config->setGroup("WidgetLayout"); 2791 config->setGroup("WidgetLayout");
2792 QStringList list ;//= config->readListEntry("MainLayout"); 2792 QStringList list ;//= config->readListEntry("MainLayout");
2793 int x,y,w,h; 2793 int x,y,w,h;
2794 QWidget* wid; 2794 QWidget* wid;
2795 wid = topLevelWidget(); 2795 wid = topLevelWidget();
2796 x = wid->geometry().x(); 2796 x = wid->geometry().x();
2797 y = wid->geometry().y(); 2797 y = wid->geometry().y();
2798 w = wid->width(); 2798 w = wid->width();
2799 h = wid->height(); 2799 h = wid->height();
2800 list.clear(); 2800 list.clear();
2801 list << QString::number( x ); 2801 list << QString::number( x );
2802 list << QString::number( y ); 2802 list << QString::number( y );
2803 list << QString::number( w ); 2803 list << QString::number( w );
2804 list << QString::number( h ); 2804 list << QString::number( h );
2805 config->writeEntry("MainLayout",list ); 2805 config->writeEntry("MainLayout",list );
2806 2806
2807 wid = mEventEditor; 2807 wid = mEventEditor;
2808 x = wid->geometry().x(); 2808 x = wid->geometry().x();
2809 y = wid->geometry().y(); 2809 y = wid->geometry().y();
2810 w = wid->width(); 2810 w = wid->width();
2811 h = wid->height(); 2811 h = wid->height();
2812 list.clear(); 2812 list.clear();
2813 list << QString::number( x ); 2813 list << QString::number( x );
2814 list << QString::number( y ); 2814 list << QString::number( y );
2815 list << QString::number( w ); 2815 list << QString::number( w );
2816 list << QString::number( h ); 2816 list << QString::number( h );
2817 config->writeEntry("EditEventLayout",list ); 2817 config->writeEntry("EditEventLayout",list );
2818 2818
2819 wid = mTodoEditor; 2819 wid = mTodoEditor;
2820 x = wid->geometry().x(); 2820 x = wid->geometry().x();
2821 y = wid->geometry().y(); 2821 y = wid->geometry().y();
2822 w = wid->width(); 2822 w = wid->width();
2823 h = wid->height(); 2823 h = wid->height();
2824 list.clear(); 2824 list.clear();
2825 list << QString::number( x ); 2825 list << QString::number( x );
2826 list << QString::number( y ); 2826 list << QString::number( y );
2827 list << QString::number( w ); 2827 list << QString::number( w );
2828 list << QString::number( h ); 2828 list << QString::number( h );
2829 config->writeEntry("EditTodoLayout",list ); 2829 config->writeEntry("EditTodoLayout",list );
2830 wid = getEventViewerDialog(); 2830 wid = getEventViewerDialog();
2831 x = wid->geometry().x(); 2831 x = wid->geometry().x();
2832 y = wid->geometry().y(); 2832 y = wid->geometry().y();
2833 w = wid->width(); 2833 w = wid->width();
2834 h = wid->height(); 2834 h = wid->height();
2835 list.clear(); 2835 list.clear();
2836 list << QString::number( x ); 2836 list << QString::number( x );
2837 list << QString::number( y ); 2837 list << QString::number( y );
2838 list << QString::number( w ); 2838 list << QString::number( w );
2839 list << QString::number( h ); 2839 list << QString::number( h );
2840 config->writeEntry("ViewerLayout",list ); 2840 config->writeEntry("ViewerLayout",list );
2841 wid = mDialogManager->getSearchDialog(); 2841 wid = mDialogManager->getSearchDialog();
2842 if ( wid ) { 2842 if ( wid ) {
2843 x = wid->geometry().x(); 2843 x = wid->geometry().x();
2844 y = wid->geometry().y(); 2844 y = wid->geometry().y();
2845 w = wid->width(); 2845 w = wid->width();
2846 h = wid->height(); 2846 h = wid->height();
2847 list.clear(); 2847 list.clear();
2848 list << QString::number( x ); 2848 list << QString::number( x );
2849 list << QString::number( y ); 2849 list << QString::number( y );
2850 list << QString::number( w ); 2850 list << QString::number( w );
2851 list << QString::number( h ); 2851 list << QString::number( h );
2852 config->writeEntry("SearchLayout",list ); 2852 config->writeEntry("SearchLayout",list );
2853 } 2853 }
2854#endif 2854#endif
2855 2855
2856 2856
2857 config->sync(); 2857 config->sync();
2858} 2858}
2859 2859
2860void CalendarView::readFilterSettings(KConfig *config) 2860void CalendarView::readFilterSettings(KConfig *config)
2861{ 2861{
2862 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2862 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2863 2863
2864 mFilters.clear(); 2864 mFilters.clear();
2865 2865
2866 config->setGroup("General"); 2866 config->setGroup("General");
2867 QStringList filterList = config->readListEntry("CalendarFilters"); 2867 QStringList filterList = config->readListEntry("CalendarFilters");
2868 2868
2869 QStringList::ConstIterator it = filterList.begin(); 2869 QStringList::ConstIterator it = filterList.begin();
2870 QStringList::ConstIterator end = filterList.end(); 2870 QStringList::ConstIterator end = filterList.end();
2871 while(it != end) { 2871 while(it != end) {
2872 // kdDebug() << " filter: " << (*it) << endl; 2872 // kdDebug() << " filter: " << (*it) << endl;
2873 2873
2874 CalFilter *filter; 2874 CalFilter *filter;
2875 filter = new CalFilter(*it); 2875 filter = new CalFilter(*it);
2876 config->setGroup("Filter_" + (*it).utf8()); 2876 config->setGroup("Filter_" + (*it).utf8());
2877 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2877 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2878 filter->setCriteria(config->readNumEntry("Criteria",0)); 2878 filter->setCriteria(config->readNumEntry("Criteria",0));
2879 filter->setCategoryList(config->readListEntry("CategoryList")); 2879 filter->setCategoryList(config->readListEntry("CategoryList"));
2880 mFilters.append(filter); 2880 mFilters.append(filter);
2881 2881
2882 ++it; 2882 ++it;
2883 } 2883 }
2884 2884
2885 if (mFilters.count() == 0) { 2885 if (mFilters.count() == 0) {
2886 CalFilter *filter = new CalFilter(i18n("Default")); 2886 CalFilter *filter = new CalFilter(i18n("Default"));
2887 mFilters.append(filter); 2887 mFilters.append(filter);
2888 } 2888 }
2889 mFilterView->updateFilters(); 2889 mFilterView->updateFilters();
2890 config->setGroup("FilterView"); 2890 config->setGroup("FilterView");
2891 2891
2892 mFilterView->blockSignals(true); 2892 mFilterView->blockSignals(true);
2893 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2893 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2894 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2894 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2895 mFilterView->blockSignals(false); 2895 mFilterView->blockSignals(false);
2896 // We do it manually to avoid it being done twice by the above calls 2896 // We do it manually to avoid it being done twice by the above calls
2897 updateFilter(); 2897 updateFilter();
2898} 2898}
2899 2899
2900void CalendarView::writeFilterSettings(KConfig *config) 2900void CalendarView::writeFilterSettings(KConfig *config)
2901{ 2901{
2902 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2902 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2903 2903
2904 QStringList filterList; 2904 QStringList filterList;
2905 2905
2906 CalFilter *filter = mFilters.first(); 2906 CalFilter *filter = mFilters.first();
2907 while(filter) { 2907 while(filter) {
2908 // kdDebug() << " fn: " << filter->name() << endl; 2908 // kdDebug() << " fn: " << filter->name() << endl;
2909 filterList << filter->name(); 2909 filterList << filter->name();
2910 config->setGroup("Filter_" + filter->name().utf8()); 2910 config->setGroup("Filter_" + filter->name().utf8());
2911 config->writeEntry("Criteria",filter->criteria()); 2911 config->writeEntry("Criteria",filter->criteria());
2912 config->writeEntry("CategoryList",filter->categoryList()); 2912 config->writeEntry("CategoryList",filter->categoryList());
2913 filter = mFilters.next(); 2913 filter = mFilters.next();
2914 } 2914 }
2915 config->setGroup("General"); 2915 config->setGroup("General");
2916 config->writeEntry("CalendarFilters",filterList); 2916 config->writeEntry("CalendarFilters",filterList);
2917 2917
2918 config->setGroup("FilterView"); 2918 config->setGroup("FilterView");
2919 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2919 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2920 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2920 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2921} 2921}
2922 2922
2923 2923
2924void CalendarView::goToday() 2924void CalendarView::goToday()
2925{ 2925{
2926 if ( mViewManager->currentView()->isMonthView() ) 2926 if ( mViewManager->currentView()->isMonthView() )
2927 mNavigator->selectTodayMonth(); 2927 mNavigator->selectTodayMonth();
2928 else 2928 else
2929 mNavigator->selectToday(); 2929 mNavigator->selectToday();
2930} 2930}
2931 2931
2932void CalendarView::goNext() 2932void CalendarView::goNext()
2933{ 2933{
2934 mNavigator->selectNext(); 2934 mNavigator->selectNext();
2935} 2935}
2936 2936
2937void CalendarView::goPrevious() 2937void CalendarView::goPrevious()
2938{ 2938{
2939 mNavigator->selectPrevious(); 2939 mNavigator->selectPrevious();
2940} 2940}
2941void CalendarView::goNextMonth() 2941void CalendarView::goNextMonth()
2942{ 2942{
2943 mNavigator->selectNextMonth(); 2943 mNavigator->selectNextMonth();
2944} 2944}
2945 2945
2946void CalendarView::goPreviousMonth() 2946void CalendarView::goPreviousMonth()
2947{ 2947{
2948 mNavigator->selectPreviousMonth(); 2948 mNavigator->selectPreviousMonth();
2949} 2949}
2950 2950
2951void CalendarView::updateConfig() 2951void CalendarView::updateConfig()
2952{ 2952{
2953 if ( KOPrefs::instance()->mUseAppColors ) 2953 if ( KOPrefs::instance()->mUseAppColors )
2954 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2954 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2955 emit configChanged(); 2955 emit configChanged();
2956 mTodoList->updateConfig(); 2956 mTodoList->updateConfig();
2957 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2957 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2958 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2958 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2959 // To make the "fill window" configurations work 2959 // To make the "fill window" configurations work
2960 //mViewManager->raiseCurrentView(); 2960 //mViewManager->raiseCurrentView();
2961} 2961}
2962 2962
2963 2963
2964void CalendarView::eventChanged(Event *event) 2964void CalendarView::eventChanged(Event *event)
2965{ 2965{
2966 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2966 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2967 //updateUnmanagedViews(); 2967 //updateUnmanagedViews();
2968} 2968}
2969 2969
2970void CalendarView::eventAdded(Event *event) 2970void CalendarView::eventAdded(Event *event)
2971{ 2971{
2972 changeEventDisplay(event,KOGlobals::EVENTADDED); 2972 changeEventDisplay(event,KOGlobals::EVENTADDED);
2973} 2973}
2974 2974
2975void CalendarView::eventToBeDeleted(Event *) 2975void CalendarView::eventToBeDeleted(Event *)
2976{ 2976{
2977 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2977 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2978} 2978}
2979 2979
2980void CalendarView::eventDeleted() 2980void CalendarView::eventDeleted()
2981{ 2981{
2982 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2982 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2983} 2983}
2984void CalendarView::changeTodoDisplay(Todo *which, int action) 2984void CalendarView::changeTodoDisplay(Todo *which, int action)
2985{ 2985{
2986 changeIncidenceDisplay((Incidence *)which, action); 2986 changeIncidenceDisplay((Incidence *)which, action);
2987 mDateNavigator->updateView(); //LR 2987 mDateNavigator->updateView(); //LR
2988 //mDialogManager->updateSearchDialog(); 2988 //mDialogManager->updateSearchDialog();
2989 2989
2990 if (which) { 2990 if (which) {
2991 mViewManager->updateWNview(); 2991 mViewManager->updateWNview();
2992 //mTodoList->updateView(); 2992 //mTodoList->updateView();
2993 } 2993 }
2994 2994
2995} 2995}
2996 2996
2997void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2997void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2998{ 2998{
2999 updateUnmanagedViews(); 2999 updateUnmanagedViews();
3000 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 3000 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
3001 if ( action == KOGlobals::EVENTDELETED ) { //delete 3001 if ( action == KOGlobals::EVENTDELETED ) { //delete
3002 mCalendar->checkAlarmForIncidence( 0, true ); 3002 mCalendar->checkAlarmForIncidence( 0, true );
3003 if ( mEventViewerDialog ) 3003 if ( mEventViewerDialog )
3004 mEventViewerDialog->hide(); 3004 mEventViewerDialog->hide();
3005 } 3005 }
3006 else 3006 else
3007 mCalendar->checkAlarmForIncidence( which , false ); 3007 mCalendar->checkAlarmForIncidence( which , false );
3008} 3008}
3009 3009
3010// most of the changeEventDisplays() right now just call the view's 3010// most of the changeEventDisplays() right now just call the view's
3011// total update mode, but they SHOULD be recoded to be more refresh-efficient. 3011// total update mode, but they SHOULD be recoded to be more refresh-efficient.
3012void CalendarView::changeEventDisplay(Event *which, int action) 3012void CalendarView::changeEventDisplay(Event *which, int action)
3013{ 3013{
3014 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 3014 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
3015 changeIncidenceDisplay((Incidence *)which, action); 3015 changeIncidenceDisplay((Incidence *)which, action);
3016 static bool clearallviews = false; 3016 static bool clearallviews = false;
3017 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 3017 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
3018 if ( clearallviews ) { 3018 if ( clearallviews ) {
3019 clearAllViews(); 3019 clearAllViews();
3020 clearallviews = false; 3020 clearallviews = false;
3021 } 3021 }
3022 return; 3022 return;
3023 } 3023 }
3024 clearallviews = true; 3024 clearallviews = true;
3025 mDateNavigator->updateView(); 3025 mDateNavigator->updateView();
3026 //mDialogManager->updateSearchDialog(); 3026 //mDialogManager->updateSearchDialog();
3027 if (which) { 3027 if (which) {
3028 // If there is an event view visible update the display 3028 // If there is an event view visible update the display
3029 mViewManager->currentView()->changeEventDisplay(which,action); 3029 mViewManager->currentView()->changeEventDisplay(which,action);
3030 // TODO: check, if update needed 3030 // TODO: check, if update needed
3031 // if (which->getTodoStatus()) { 3031 // if (which->getTodoStatus()) {
3032 mTodoList->updateView(); 3032 mTodoList->updateView();
3033 if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { 3033 if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) {
3034 mConflictingEvent = which ; 3034 mConflictingEvent = which ;
3035 int time = 1000; 3035 int time = 1000;
3036#ifdef DESKTOP_VERSION 3036#ifdef DESKTOP_VERSION
3037 time = 500; 3037 time = 500;
3038#endif 3038#endif
3039 bool checkC = false; 3039 bool checkC = false;
3040 if ( mConflictingEvent->doesFloat() ) { 3040 if ( mConflictingEvent->doesFloat() ) {
3041 checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay 3041 checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay
3042 || KOPrefs::instance()->mCheckConflictsAllDayNonAD; 3042 || KOPrefs::instance()->mCheckConflictsAllDayNonAD;
3043 } else { 3043 } else {
3044 checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay 3044 checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay
3045 || KOPrefs::instance()->mCheckConflictsNonADNonAD; 3045 || KOPrefs::instance()->mCheckConflictsNonADNonAD;
3046 } 3046 }
3047 if ( checkC ) 3047 if ( checkC )
3048 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); 3048 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) );
3049 } 3049 }
3050 // } 3050 // }
3051 } else { 3051 } else {
3052 mViewManager->currentView()->updateView(); 3052 mViewManager->currentView()->updateView();
3053 } 3053 }
3054} 3054}
3055void CalendarView::checkConflictForEvent() 3055void CalendarView::checkConflictForEvent()
3056{ 3056{
3057 3057
3058 if (!KOPrefs::instance()->mConfirm) 3058 if (!KOPrefs::instance()->mConfirm)
3059 return; 3059 return;
3060 if ( ! mConflictingEvent ) return; 3060 if ( ! mConflictingEvent ) return;
3061 Event * conflictingEvent = mConflictingEvent; 3061 Event * conflictingEvent = mConflictingEvent;
3062 mConflictingEvent = 0; 3062 mConflictingEvent = 0;
3063 QDateTime current = QDateTime::currentDateTime(); 3063 QDateTime current = QDateTime::currentDateTime();
3064 if ( ! conflictingEvent->matchTime( &current, 0 ) ) { 3064 if ( ! conflictingEvent->matchTime( &current, 0 ) ) {
3065 return; 3065 return;
3066 } 3066 }
3067 CalFilter *filterIN = 0; 3067 CalFilter *filterIN = 0;
3068 CalFilter *filterALL = 0; 3068 CalFilter *filterALL = 0;
3069 CalFilter *filter = mFilters.first(); 3069 CalFilter *filter = mFilters.first();
3070 while(filter) { 3070 while(filter) {
3071 if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) 3071 if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem)
3072 filterIN = filter; 3072 filterIN = filter;
3073 if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) 3073 if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem )
3074 filterALL = filter; 3074 filterALL = filter;
3075 filter = mFilters.next(); 3075 filter = mFilters.next();
3076 } 3076 }
3077 if ( filterIN ) { 3077 if ( filterIN ) {
3078 if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { 3078 if ( !filterIN->filterCalendarItem( conflictingEvent ) ) {
3079 return; 3079 return;
3080 } 3080 }
3081 } 3081 }
3082 QPtrList<Event> testlist = mCalendar->events(); 3082 QPtrList<Event> testlist = mCalendar->events();
3083 Event * test = testlist.first(); 3083 Event * test = testlist.first();
3084 QDateTime conflict; 3084 QDateTime conflict;
3085 QDateTime retVal; 3085 QDateTime retVal;
3086 bool found = false; 3086 bool found = false;
3087 Event * cE = 0; 3087 Event * cE = 0;
3088 bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; 3088 bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay;
3089 bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; 3089 bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD;
3090 if ( !conflictingEvent->doesFloat() ) { 3090 if ( !conflictingEvent->doesFloat() ) {
3091 chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; 3091 chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay;
3092 chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; 3092 chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD;
3093 } 3093 }
3094 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 3094 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
3095 while ( test ) { 3095 while ( test ) {
3096 qApp->processEvents(); 3096 qApp->processEvents();
3097 bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); 3097 bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad );
3098 if ( !skip ) { 3098 if ( !skip ) {
3099 if ( filterALL ) { 3099 if ( filterALL ) {
3100 if ( !filterALL->filterCalendarItem( test ) ) { 3100 if ( !filterALL->filterCalendarItem( test ) ) {
3101 skip = true; 3101 skip = true;
3102 } 3102 }
3103 } 3103 }
3104 if ( !skip ) { 3104 if ( !skip ) {
3105 if ( found ) 3105 if ( found )
3106 skip = !test->matchTime( &current, &conflict ); 3106 skip = !test->matchTime( &current, &conflict );
3107 else 3107 else
3108 skip = !test->matchTime( &current, 0 ); 3108 skip = !test->matchTime( &current, 0 );
3109 if ( !skip ) { 3109 if ( !skip ) {
3110 if ( conflictingEvent->isOverlapping ( test, &retVal, &current ) ) { 3110 if ( conflictingEvent->isOverlapping ( test, &retVal, &current ) ) {
3111 if ( ! found ) { 3111 if ( ! found ) {
3112 conflict = retVal; 3112 conflict = retVal;
3113 cE = test; 3113 cE = test;
3114 } else { 3114 } else {
3115 if ( retVal < conflict ) { 3115 if ( retVal < conflict ) {
3116 conflict = retVal; 3116 conflict = retVal;
3117 cE = test; 3117 cE = test;
3118 } 3118 }
3119 } 3119 }
3120 found = true; 3120 found = true;
3121 } 3121 }
3122 } 3122 }
3123 } 3123 }
3124 } 3124 }
3125 test = testlist.next(); 3125 test = testlist.next();
3126 } 3126 }
3127 topLevelWidget()->setCaption( i18n("KO/Pi") ); 3127 topLevelWidget()->setCaption( i18n("KO/Pi") );
3128 if ( found ) { 3128 if ( found ) {
3129 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; 3129 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ;
3130 qApp->processEvents(); 3130 qApp->processEvents();
3131 int km = KMessageBox::warningContinueCancel(this,mess, 3131 int km = KMessageBox::warningContinueCancel(this,mess,
3132 i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); 3132 i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!"));
3133 if ( km != KMessageBox::Continue ) { 3133 if ( km != KMessageBox::Continue ) {
3134 return; 3134 return;
3135 } 3135 }
3136 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 3136 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
3137 mViewManager->showDayView(); 3137 mViewManager->showDayView();
3138 mNavigator->slotDaySelect( conflict.date() ); 3138 mNavigator->slotDaySelect( conflict.date() );
3139 int hour = conflict.time().hour(); 3139 int hour = conflict.time().hour();
3140 mViewManager->agendaView()->setStartHour( hour ); 3140 mViewManager->agendaView()->setStartHour( hour );
3141 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); 3141 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
3142 } else 3142 } else
3143 topLevelWidget()->setCaption( i18n("No conflict found") ); 3143 topLevelWidget()->setCaption( i18n("No conflict found") );
3144 return; 3144 return;
3145 3145
3146} 3146}
3147 3147
3148void CalendarView::updateTodoViews() 3148void CalendarView::updateTodoViews()
3149{ 3149{
3150 mTodoList->updateView(); 3150 mTodoList->updateView();
3151 mViewManager->currentView()->updateView(); 3151 mViewManager->currentView()->updateView();
3152 3152
3153} 3153}
3154 3154
3155 3155
3156 3156
3157void CalendarView::clearAllViews() 3157void CalendarView::clearAllViews()
3158{ 3158{
3159 mTodoList->clearList(); 3159 mTodoList->clearList();
3160 mViewManager->clearAllViews(); 3160 mViewManager->clearAllViews();
3161 SearchDialog * sd = mDialogManager->getSearchDialog(); 3161 SearchDialog * sd = mDialogManager->getSearchDialog();
3162 if ( sd ) { 3162 if ( sd ) {
3163 KOListView* kol = sd->listview(); 3163 KOListView* kol = sd->listview();
3164 if ( kol ) 3164 if ( kol )
3165 kol->clearList(); 3165 kol->clearList();
3166 } 3166 }
3167} 3167}
3168void CalendarView::updateView() 3168void CalendarView::updateView()
3169{ 3169{
3170 static bool clearallviews = false; 3170 static bool clearallviews = false;
3171 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 3171 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
3172 if ( clearallviews ) { 3172 if ( clearallviews ) {
3173 clearAllViews(); 3173 clearAllViews();
3174 clearallviews = false; 3174 clearallviews = false;
3175 } 3175 }
3176 return; 3176 return;
3177 } 3177 }
3178 clearallviews = true; 3178 clearallviews = true;
3179 DateList tmpList = mNavigator->selectedDates(); 3179 DateList tmpList = mNavigator->selectedDates();
3180 3180
3181 if ( KOPrefs::instance()->mHideNonStartedTodos ) 3181 if ( KOPrefs::instance()->mHideNonStartedTodos )
3182 mTodoList->updateView(); 3182 mTodoList->updateView();
3183 // We assume that the navigator only selects consecutive days. 3183 // We assume that the navigator only selects consecutive days.
3184 updateView( tmpList.first(), tmpList.last() ); 3184 updateView( tmpList.first(), tmpList.last() );
3185} 3185}
3186 3186
3187void CalendarView::updateUnmanagedViews() 3187void CalendarView::updateUnmanagedViews()
3188{ 3188{
3189 mDateNavigator->updateDayMatrix(); 3189 mDateNavigator->updateDayMatrix();
3190} 3190}
3191 3191
3192int CalendarView::msgItemDelete(const QString name) 3192int CalendarView::msgItemDelete(const QString name)
3193{ 3193{
3194 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 3194 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
3195 i18n("This item will be\npermanently deleted."), 3195 i18n("This item will be\npermanently deleted."),
3196 i18n("KO/Pi Confirmation"),i18n("Delete")); 3196 i18n("KO/Pi Confirmation"),i18n("Delete"));
3197} 3197}
3198 3198
3199 3199
3200void CalendarView::edit_cut() 3200void CalendarView::edit_cut()
3201{ 3201{
3202 Event *anEvent=0; 3202 Event *anEvent=0;
3203 3203
3204 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3204 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3205 3205
3206 if (mViewManager->currentView()->isEventView()) { 3206 if (mViewManager->currentView()->isEventView()) {
3207 if ( incidence && incidence->typeID() == eventID ) { 3207 if ( incidence && incidence->typeID() == eventID ) {
3208 anEvent = static_cast<Event *>(incidence); 3208 anEvent = static_cast<Event *>(incidence);
3209 } 3209 }
3210 } 3210 }
3211 3211
3212 if (!anEvent) { 3212 if (!anEvent) {
3213 KNotifyClient::beep(); 3213 KNotifyClient::beep();
3214 return; 3214 return;
3215 } 3215 }
3216 DndFactory factory( mCalendar ); 3216 DndFactory factory( mCalendar );
3217 factory.cutIncidence(anEvent); 3217 factory.cutIncidence(anEvent);
3218 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3218 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3219} 3219}
3220 3220
3221void CalendarView::edit_copy() 3221void CalendarView::edit_copy()
3222{ 3222{
3223 Event *anEvent=0; 3223 Event *anEvent=0;
3224 3224
3225 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3225 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3226 3226
3227 if (mViewManager->currentView()->isEventView()) { 3227 if (mViewManager->currentView()->isEventView()) {
3228 if ( incidence && incidence->typeID() == eventID ) { 3228 if ( incidence && incidence->typeID() == eventID ) {
3229 anEvent = static_cast<Event *>(incidence); 3229 anEvent = static_cast<Event *>(incidence);
3230 } 3230 }
3231 } 3231 }
3232 3232
3233 if (!anEvent) { 3233 if (!anEvent) {
3234 KNotifyClient::beep(); 3234 KNotifyClient::beep();
3235 return; 3235 return;
3236 } 3236 }
3237 DndFactory factory( mCalendar ); 3237 DndFactory factory( mCalendar );
3238 factory.copyIncidence(anEvent); 3238 factory.copyIncidence(anEvent);
3239} 3239}
3240 3240
3241void CalendarView::edit_paste() 3241void CalendarView::edit_paste()
3242{ 3242{
3243 QDate date = mNavigator->selectedDates().first(); 3243 QDate date = mNavigator->selectedDates().first();
3244 3244
3245 DndFactory factory( mCalendar ); 3245 DndFactory factory( mCalendar );
3246 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 3246 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
3247 3247
3248 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 3248 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
3249} 3249}
3250void CalendarView::edit_global_options() 3250void CalendarView::edit_global_options()
3251{ 3251{
3252 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 3252 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
3253 emit save(); 3253 emit save();
3254 emit saveStopTimer(); 3254 emit saveStopTimer();
3255 mDialogManager->showGlobalOptionsDialog(); 3255 mDialogManager->showGlobalOptionsDialog();
3256 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 3256 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
3257 emit saveStopTimer(); 3257 emit saveStopTimer();
3258 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 3258 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
3259 i18n("Timezone settings"),i18n("Reload"))) { 3259 i18n("Timezone settings"),i18n("Reload"))) {
3260 qDebug("KO: TZ reload cancelled "); 3260 qDebug("KO: TZ reload cancelled ");
3261 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3261 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
3262 return; 3262 return;
3263 } 3263 }
3264 qDebug("KO: Timezone change "); 3264 qDebug("KO: Timezone change ");
3265 loadCalendars(); 3265 loadCalendars();
3266 setModified(true); 3266 setModified(true);
3267 } 3267 }
3268 else 3268 else
3269 qDebug("KO: No tz change "); 3269 qDebug("KO: No tz change ");
3270} 3270}
3271void CalendarView::edit_options() 3271void CalendarView::edit_options()
3272{ 3272{
3273 mDialogManager->showOptionsDialog(); 3273 mDialogManager->showOptionsDialog();
3274} 3274}
3275 3275
3276 3276
3277void CalendarView::slotSelectPickerDate( QDate d) 3277void CalendarView::slotSelectPickerDate( QDate d)
3278{ 3278{
3279 mDateFrame->hide(); 3279 mDateFrame->hide();
3280 if ( mDatePickerMode == 1 ) { 3280 if ( mDatePickerMode == 1 ) {
3281 mNavigator->slotDaySelect( d ); 3281 mNavigator->slotDaySelect( d );
3282 } else if ( mDatePickerMode == 2 ) { 3282 } else if ( mDatePickerMode == 2 ) {
3283 if ( mMoveIncidence->typeID() == todoID ) { 3283 if ( mMoveIncidence->typeID() == todoID ) {
3284 Todo * to = (Todo *) mMoveIncidence; 3284 Todo * to = (Todo *) mMoveIncidence;
3285 QTime tim; 3285 QTime tim;
3286 int len = 0; 3286 int len = 0;
3287 if ( to->hasStartDate() && to->hasDueDate() ) 3287 if ( to->hasStartDate() && to->hasDueDate() )
3288 len = to->dtStart().secsTo( to->dtDue()); 3288 len = to->dtStart().secsTo( to->dtDue());
3289 if ( to->hasDueDate() ) 3289 if ( to->hasDueDate() )
3290 tim = to->dtDue().time(); 3290 tim = to->dtDue().time();
3291 else { 3291 else {
3292 tim = QTime ( 0,0,0 ); 3292 tim = QTime ( 0,0,0 );
3293 to->setFloats( true ); 3293 to->setFloats( true );
3294 to->setHasDueDate( true ); 3294 to->setHasDueDate( true );
3295 } 3295 }
3296 QDateTime dt ( d,tim ); 3296 QDateTime dt ( d,tim );
3297 to->setDtDue( dt ); 3297 to->setDtDue( dt );
3298 3298
3299 if ( to->hasStartDate() ) { 3299 if ( to->hasStartDate() ) {
3300 if ( len>0 ) 3300 if ( len>0 )
3301 to->setDtStart(to->dtDue().addSecs( -len )); 3301 to->setDtStart(to->dtDue().addSecs( -len ));
3302 else 3302 else
3303 if (to->dtStart() > to->dtDue() ) 3303 if (to->dtStart() > to->dtDue() )
3304 to->setDtStart(to->dtDue().addDays( -3 )); 3304 to->setDtStart(to->dtDue().addDays( -3 ));
3305 } 3305 }
3306 3306
3307 todoChanged( to ); 3307 todoChanged( to );
3308 } else if ( mMoveIncidence->typeID() == eventID ) { 3308 } else if ( mMoveIncidence->typeID() == eventID ) {
3309 if ( mMoveIncidence->doesRecur() ) { 3309 if ( mMoveIncidence->doesRecur() ) {
3310#if 0 3310#if 0
3311 // PENDING implement this 3311 // PENDING implement this
3312 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 3312 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
3313 mCalendar()->addIncidence( newInc ); 3313 mCalendar()->addIncidence( newInc );
3314 if ( mMoveIncidence->typeID() == todoID ) 3314 if ( mMoveIncidence->typeID() == todoID )
3315 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 3315 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
3316 else 3316 else
3317 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 3317 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
3318 mMoveIncidence = newInc; 3318 mMoveIncidence = newInc;
3319 3319
3320#endif 3320#endif
3321 } 3321 }
3322 QTime tim = mMoveIncidence->dtStart().time(); 3322 QTime tim = mMoveIncidence->dtStart().time();
3323 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 3323 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
3324 QDateTime dt ( d,tim ); 3324 QDateTime dt ( d,tim );
3325 mMoveIncidence->setDtStart( dt ); 3325 mMoveIncidence->setDtStart( dt );
3326 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 3326 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
3327 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 3327 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
3328 } else if ( mMoveIncidence->typeID() == journalID ) { 3328 } else if ( mMoveIncidence->typeID() == journalID ) {
3329 QTime tim = mMoveIncidence->dtStart().time(); 3329 QTime tim = mMoveIncidence->dtStart().time();
3330 QDateTime dt ( d,tim ); 3330 QDateTime dt ( d,tim );
3331 mMoveIncidence->setDtStart( dt ); 3331 mMoveIncidence->setDtStart( dt );
3332 updateView(); 3332 updateView();
3333 } 3333 }
3334 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 3334 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
3335 } 3335 }
3336} 3336}
3337 3337
3338void CalendarView::removeCategories() 3338void CalendarView::removeCategories()
3339{ 3339{
3340 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3340 QPtrList<Incidence> incList = mCalendar->rawIncidences();
3341 QStringList catList = KOPrefs::instance()->mCustomCategories; 3341 QStringList catList = KOPrefs::instance()->mCustomCategories;
3342 QStringList catIncList; 3342 QStringList catIncList;
3343 QStringList newCatList; 3343 QStringList newCatList;
3344 Incidence* inc = incList.first(); 3344 Incidence* inc = incList.first();
3345 uint i; 3345 uint i;
3346 while ( inc ) { 3346 while ( inc ) {
3347 newCatList.clear(); 3347 newCatList.clear();
3348 catIncList = inc->categories() ; 3348 catIncList = inc->categories() ;
3349 for( i = 0; i< catIncList.count(); ++i ) { 3349 for( i = 0; i< catIncList.count(); ++i ) {
3350 if ( catList.contains (catIncList[i])) 3350 if ( catList.contains (catIncList[i]))
3351 newCatList.append( catIncList[i] ); 3351 newCatList.append( catIncList[i] );
3352 } 3352 }
3353 newCatList.sort(); 3353 newCatList.sort();
3354 inc->setCategories( newCatList.join(",") ); 3354 inc->setCategories( newCatList.join(",") );
3355 inc = incList.next(); 3355 inc = incList.next();
3356 } 3356 }
3357} 3357}
3358 3358
3359int CalendarView::addCategories() 3359int CalendarView::addCategories()
3360{ 3360{
3361 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3361 QPtrList<Incidence> incList = mCalendar->rawIncidences();
3362 QStringList catList = KOPrefs::instance()->mCustomCategories; 3362 QStringList catList = KOPrefs::instance()->mCustomCategories;
3363 QStringList catIncList; 3363 QStringList catIncList;
3364 Incidence* inc = incList.first(); 3364 Incidence* inc = incList.first();
3365 uint i; 3365 uint i;
3366 int count = 0; 3366 int count = 0;
3367 while ( inc ) { 3367 while ( inc ) {
3368 catIncList = inc->categories() ; 3368 catIncList = inc->categories() ;
3369 for( i = 0; i< catIncList.count(); ++i ) { 3369 for( i = 0; i< catIncList.count(); ++i ) {
3370 if ( !catList.contains (catIncList[i])) { 3370 if ( !catList.contains (catIncList[i])) {
3371 catList.append( catIncList[i] ); 3371 catList.append( catIncList[i] );
3372 //qDebug("add cat %s ", catIncList[i].latin1()); 3372 //qDebug("add cat %s ", catIncList[i].latin1());
3373 ++count; 3373 ++count;
3374 } 3374 }
3375 } 3375 }
3376 inc = incList.next(); 3376 inc = incList.next();
3377 } 3377 }
3378 catList.sort(); 3378 catList.sort();
3379 KOPrefs::instance()->mCustomCategories = catList; 3379 KOPrefs::instance()->mCustomCategories = catList;
3380 return count; 3380 return count;
3381} 3381}
3382 3382
3383void CalendarView::editCategories() 3383void CalendarView::editCategories()
3384{ 3384{
3385 qDebug("CalendarView::editCategories() "); 3385 qDebug("CalendarView::editCategories() ");
3386 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); 3386 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this );
3387 ced.exec(); 3387 ced.exec();
3388} 3388}
3389void CalendarView::manageCategories() 3389void CalendarView::manageCategories()
3390{ 3390{
3391 KOCatPrefs* cp = new KOCatPrefs(); 3391 KOCatPrefs* cp = new KOCatPrefs();
3392 cp->show(); 3392 cp->show();
3393 int w =cp->sizeHint().width() ; 3393 int w =cp->sizeHint().width() ;
3394 int h = cp->sizeHint().height() ; 3394 int h = cp->sizeHint().height() ;
3395 int dw = QApplication::desktop()->width(); 3395 int dw = QApplication::desktop()->width();
3396 int dh = QApplication::desktop()->height(); 3396 int dh = QApplication::desktop()->height();
3397 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 3397 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
3398 if ( !cp->exec() ) { 3398 if ( !cp->exec() ) {
3399 delete cp; 3399 delete cp;
3400 return; 3400 return;
3401 } 3401 }
3402 int count = 0; 3402 int count = 0;
3403 if ( cp->addCat() ) { 3403 if ( cp->addCat() ) {
3404 count = addCategories(); 3404 count = addCategories();
3405 if ( count ) { 3405 if ( count ) {
3406 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 3406 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
3407 writeSettings(); 3407 writeSettings();
3408 } else 3408 } else
3409 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 3409 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
3410 } else { 3410 } else {
3411 removeCategories(); 3411 removeCategories();
3412 updateView(); 3412 updateView();
3413 } 3413 }
3414 delete cp; 3414 delete cp;
3415} 3415}
3416 3416
3417void CalendarView::beamIncidence(Incidence * Inc) 3417void CalendarView::beamIncidence(Incidence * Inc)
3418{ 3418{
3419 QPtrList<Incidence> delSel ; 3419 QPtrList<Incidence> delSel ;
3420 delSel.append(Inc); 3420 delSel.append(Inc);
3421 beamIncidenceList( delSel ); 3421 beamIncidenceList( delSel );
3422} 3422}
3423void CalendarView::beamCalendar() 3423void CalendarView::beamCalendar()
3424{ 3424{
3425 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 3425 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
3426 //qDebug("beamCalendar() "); 3426 //qDebug("beamCalendar() ");
3427 beamIncidenceList( delSel ); 3427 beamIncidenceList( delSel );
3428} 3428}
3429void CalendarView::beamFilteredCalendar() 3429void CalendarView::beamFilteredCalendar()
3430{ 3430{
3431 QPtrList<Incidence> delSel = mCalendar->incidences(); 3431 QPtrList<Incidence> delSel = mCalendar->incidences();
3432 //qDebug("beamFilteredCalendar() "); 3432 //qDebug("beamFilteredCalendar() ");
3433 beamIncidenceList( delSel ); 3433 beamIncidenceList( delSel );
3434} 3434}
3435void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 3435void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
3436{ 3436{
3437 3437
3438 KOBeamPrefs beamDialog; 3438 KOBeamPrefs beamDialog;
3439 if ( beamDialog.exec () == QDialog::Rejected ) 3439 if ( beamDialog.exec () == QDialog::Rejected )
3440 return; 3440 return;
3441#ifdef DESKTOP_VERSION 3441#ifdef DESKTOP_VERSION
3442 QString fn = locateLocal( "tmp", "kopibeamfile" ); 3442 QString fn = locateLocal( "tmp", "kopibeamfile" );
3443#else 3443#else
3444 QString fn = "/tmp/kopibeamfile"; 3444 QString fn = "/tmp/kopibeamfile";
3445#endif 3445#endif
3446 QString mes; 3446 QString mes;
3447 bool createbup = true; 3447 bool createbup = true;
3448 if ( createbup ) { 3448 if ( createbup ) {
3449 QString description = "\n"; 3449 QString description = "\n";
3450 CalendarLocal* cal = new CalendarLocal(); 3450 CalendarLocal* cal = new CalendarLocal();
3451 if ( beamDialog.beamLocal() ) 3451 if ( beamDialog.beamLocal() )
3452 cal->setLocalTime(); 3452 cal->setLocalTime();
3453 else 3453 else
3454 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3454 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
3455 Incidence *incidence = delSel.first(); 3455 Incidence *incidence = delSel.first();
3456 bool addText = false; 3456 bool addText = false;
3457 if ( delSel.count() < 10 ) 3457 if ( delSel.count() < 10 )
3458 addText = true; 3458 addText = true;
3459 else { 3459 else {
3460 description.sprintf(i18n(" %d items?"),delSel.count() ); 3460 description.sprintf(i18n(" %d items?"),delSel.count() );
3461 } 3461 }
3462 while ( incidence ) { 3462 while ( incidence ) {
3463 Incidence *in = incidence->clone(); 3463 Incidence *in = incidence->clone();
3464 if ( ! in->summary().isEmpty() ) { 3464 if ( ! in->summary().isEmpty() ) {
3465 in->setDescription(""); 3465 in->setDescription("");
3466 } else { 3466 } else {
3467 in->setSummary( in->description().left(20)); 3467 in->setSummary( in->description().left(20));
3468 in->setDescription(""); 3468 in->setDescription("");
3469 } 3469 }
3470 if ( addText ) 3470 if ( addText )
3471 description += in->summary() + "\n"; 3471 description += in->summary() + "\n";
3472 cal->addIncidence( in ); 3472 cal->addIncidence( in );
3473 incidence = delSel.next(); 3473 incidence = delSel.next();
3474 } 3474 }
3475 if ( beamDialog.beamVcal() ) { 3475 if ( beamDialog.beamVcal() ) {
3476 fn += ".vcs"; 3476 fn += ".vcs";
3477 FileStorage storage( cal, fn, new VCalFormat ); 3477 FileStorage storage( cal, fn, new VCalFormat );
3478 storage.save(); 3478 storage.save();
3479 } else { 3479 } else {
3480 fn += ".ics"; 3480 fn += ".ics";
3481 FileStorage storage( cal, fn, new ICalFormat( ) ); 3481 FileStorage storage( cal, fn, new ICalFormat( ) );
3482 storage.save(); 3482 storage.save();
3483 } 3483 }
3484 delete cal; 3484 delete cal;
3485 mes = i18n("KO/Pi: Ready for beaming"); 3485 mes = i18n("KO/Pi: Ready for beaming");
3486 topLevelWidget()->setCaption(mes); 3486 topLevelWidget()->setCaption(mes);
3487 KApplication::convert2latin1( fn ); 3487 KApplication::convert2latin1( fn );
3488#ifndef DESKTOP_VERSION 3488#ifndef DESKTOP_VERSION
3489 Ir *ir = new Ir( this ); 3489 Ir *ir = new Ir( this );
3490 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 3490 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
3491 ir->send( fn, description, "text/x-vCalendar" ); 3491 ir->send( fn, description, "text/x-vCalendar" );
3492#endif 3492#endif
3493 } 3493 }
3494} 3494}
3495 3495
3496#ifndef DESKTOP_VERSION 3496#ifndef DESKTOP_VERSION
3497void CalendarView::beamDone( Ir *ir ) 3497void CalendarView::beamDone( Ir *ir )
3498{ 3498{
3499 delete ir; 3499 delete ir;
3500 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 3500 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
3501 topLevelWidget()->raise(); 3501 topLevelWidget()->raise();
3502} 3502}
3503#else 3503#else
3504void CalendarView::beamDone( Ir *){;} 3504void CalendarView::beamDone( Ir *){;}
3505#endif 3505#endif
3506void CalendarView::moveIncidence(Incidence * inc ) 3506void CalendarView::moveIncidence(Incidence * inc )
3507{ 3507{
3508 if ( !inc ) return; 3508 if ( !inc ) return;
3509 showDatePickerPopup(); 3509 showDatePickerPopup();
3510 mDatePickerMode = 2; 3510 mDatePickerMode = 2;
3511 mMoveIncidence = inc ; 3511 mMoveIncidence = inc ;
3512 QDate da; 3512 QDate da;
3513 if ( mMoveIncidence->typeID() == todoID ) { 3513 if ( mMoveIncidence->typeID() == todoID ) {
3514 Todo * to = (Todo *) mMoveIncidence; 3514 Todo * to = (Todo *) mMoveIncidence;
3515 if ( to->hasDueDate() ) 3515 if ( to->hasDueDate() )
3516 da = to->dtDue().date(); 3516 da = to->dtDue().date();
3517 else 3517 else
3518 da = QDate::currentDate(); 3518 da = QDate::currentDate();
3519 } else { 3519 } else {
3520 da = mMoveIncidence->dtStart().date(); 3520 da = mMoveIncidence->dtStart().date();
3521 } 3521 }
3522 //PENDING set date for recurring incidence to date of recurrence 3522 //PENDING set date for recurring incidence to date of recurrence
3523 //mMoveIncidenceOldDate; 3523 //mMoveIncidenceOldDate;
3524 mDatePicker->setDate( da ); 3524 mDatePicker->setDate( da );
3525} 3525}
3526void CalendarView::showDatePickerPopup() 3526void CalendarView::showDatePickerPopup()
3527{ 3527{
3528 if ( mDateFrame->isVisible() ) 3528 if ( mDateFrame->isVisible() )
3529 mDateFrame->hide(); 3529 mDateFrame->hide();
3530 else { 3530 else {
3531 int offX = 0, offY = 0; 3531 int offX = 0, offY = 0;
3532#ifdef DESKTOP_VERSION 3532#ifdef DESKTOP_VERSION
3533 int w =mDatePicker->sizeHint().width() ; 3533 int w =mDatePicker->sizeHint().width() ;
3534 int h = mDatePicker->sizeHint().height() ; 3534 int h = mDatePicker->sizeHint().height() ;
3535 int dw = topLevelWidget()->width(); 3535 int dw = topLevelWidget()->width();
3536 int dh = topLevelWidget()->height(); 3536 int dh = topLevelWidget()->height();
3537 offX = topLevelWidget()->x(); 3537 offX = topLevelWidget()->x();
3538 offY = topLevelWidget()->y(); 3538 offY = topLevelWidget()->y();
3539#else 3539#else
3540 int w =mDatePicker->sizeHint().width() ; 3540 int w =mDatePicker->sizeHint().width() ;
3541 int h = mDatePicker->sizeHint().height() ; 3541 int h = mDatePicker->sizeHint().height() ;
3542 int dw = QApplication::desktop()->width(); 3542 int dw = QApplication::desktop()->width();
3543 int dh = QApplication::desktop()->height(); 3543 int dh = QApplication::desktop()->height();
3544#endif 3544#endif
3545 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 3545 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
3546 mDateFrame->show(); 3546 mDateFrame->show();
3547 } 3547 }
3548} 3548}
3549void CalendarView::showDatePicker( ) 3549void CalendarView::showDatePicker( )
3550{ 3550{
3551 showDatePickerPopup(); 3551 showDatePickerPopup();
3552 mDatePickerMode = 1; 3552 mDatePickerMode = 1;
3553 mDatePicker->setDate( mNavigator->selectedDates().first() ); 3553 mDatePicker->setDate( mNavigator->selectedDates().first() );
3554} 3554}
3555 3555
3556void CalendarView::showEventEditor() 3556void CalendarView::showEventEditor()
3557{ 3557{
3558#ifdef DESKTOP_VERSION 3558#ifdef DESKTOP_VERSION
3559 int x,y,w,h; 3559 int x,y,w,h;
3560 x = mEventEditor->geometry().x(); 3560 x = mEventEditor->geometry().x();
3561 y = mEventEditor->geometry().y(); 3561 y = mEventEditor->geometry().y();
3562 w = mEventEditor->width(); 3562 w = mEventEditor->width();
3563 h = mEventEditor->height(); 3563 h = mEventEditor->height();
3564 mEventEditor->show(); 3564 mEventEditor->show();
3565 mEventEditor->setGeometry(x,y,w,h); 3565 mEventEditor->setGeometry(x,y,w,h);
3566#else 3566#else
3567 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 3567 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
3568 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3568 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3569 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 3569 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
3570 qApp->processEvents(); 3570 qApp->processEvents();
3571 delete mEventEditor; 3571 delete mEventEditor;
3572 mEventEditor = mDialogManager->getEventEditor(); 3572 mEventEditor = mDialogManager->getEventEditor();
3573 topLevelWidget()->setCaption( i18n("") ); 3573 topLevelWidget()->setCaption( i18n("") );
3574 } 3574 }
3575 mEventEditor->showMaximized(); 3575 mEventEditor->showMaximized();
3576#endif 3576#endif
3577} 3577}
3578void CalendarView::showTodoEditor() 3578void CalendarView::showTodoEditor()
3579{ 3579{
3580#ifdef DESKTOP_VERSION 3580#ifdef DESKTOP_VERSION
3581 int x,y,w,h; 3581 int x,y,w,h;
3582 x = mTodoEditor->geometry().x(); 3582 x = mTodoEditor->geometry().x();
3583 y = mTodoEditor->geometry().y(); 3583 y = mTodoEditor->geometry().y();
3584 w = mTodoEditor->width(); 3584 w = mTodoEditor->width();
3585 h = mTodoEditor->height(); 3585 h = mTodoEditor->height();
3586 mTodoEditor->show(); 3586 mTodoEditor->show();
3587 mTodoEditor->setGeometry(x,y,w,h); 3587 mTodoEditor->setGeometry(x,y,w,h);
3588#else 3588#else
3589 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 3589 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
3590 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3590 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3591 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 3591 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
3592 qApp->processEvents(); 3592 qApp->processEvents();
3593 delete mTodoEditor; 3593 delete mTodoEditor;
3594 mTodoEditor = mDialogManager->getTodoEditor(); 3594 mTodoEditor = mDialogManager->getTodoEditor();
3595 topLevelWidget()->setCaption( i18n("") ); 3595 topLevelWidget()->setCaption( i18n("") );
3596 } 3596 }
3597 mTodoEditor->showMaximized(); 3597 mTodoEditor->showMaximized();
3598#endif 3598#endif
3599} 3599}
3600 3600
3601void CalendarView::cloneIncidence() 3601void CalendarView::cloneIncidence()
3602{ 3602{
3603 Incidence *incidence = currentSelection(); 3603 Incidence *incidence = currentSelection();
3604 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3604 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3605 if ( incidence ) { 3605 if ( incidence ) {
3606 cloneIncidence(incidence); 3606 cloneIncidence(incidence);
3607 } 3607 }
3608} 3608}
3609void CalendarView::moveIncidence() 3609void CalendarView::moveIncidence()
3610{ 3610{
3611 Incidence *incidence = currentSelection(); 3611 Incidence *incidence = currentSelection();
3612 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3612 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3613 if ( incidence ) { 3613 if ( incidence ) {
3614 moveIncidence(incidence); 3614 moveIncidence(incidence);
3615 } 3615 }
3616} 3616}
3617void CalendarView::beamIncidence() 3617void CalendarView::beamIncidence()
3618{ 3618{
3619 Incidence *incidence = currentSelection(); 3619 Incidence *incidence = currentSelection();
3620 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3620 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3621 if ( incidence ) { 3621 if ( incidence ) {
3622 beamIncidence(incidence); 3622 beamIncidence(incidence);
3623 } 3623 }
3624} 3624}
3625void CalendarView::toggleCancelIncidence() 3625void CalendarView::toggleCancelIncidence()
3626{ 3626{
3627 Incidence *incidence = currentSelection(); 3627 Incidence *incidence = currentSelection();
3628 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3628 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3629 if ( incidence ) { 3629 if ( incidence ) {
3630 cancelIncidence(incidence); 3630 cancelIncidence(incidence);
3631 } 3631 }
3632} 3632}
3633 3633
3634 3634
3635void CalendarView::cancelIncidence(Incidence * inc ) 3635void CalendarView::cancelIncidence(Incidence * inc )
3636{ 3636{
3637 inc->setCancelled( ! inc->cancelled() ); 3637 inc->setCancelled( ! inc->cancelled() );
3638 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 3638 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
3639 updateView(); 3639 updateView();
3640} 3640}
3641void CalendarView::cloneIncidence(Incidence * orgInc ) 3641void CalendarView::cloneIncidence(Incidence * orgInc )
3642{ 3642{
3643 Incidence * newInc = orgInc->clone(); 3643 Incidence * newInc = orgInc->clone();
3644 newInc->recreate(); 3644 newInc->recreate();
3645 3645
3646 if ( newInc->typeID() == todoID ) { 3646 if ( newInc->typeID() == todoID ) {
3647 Todo* t = (Todo*) newInc; 3647 Todo* t = (Todo*) newInc;
3648 bool cloneSub = false; 3648 bool cloneSub = false;
3649 if ( orgInc->relations().count() ) { 3649 if ( orgInc->relations().count() ) {
3650 int result = KMessageBox::warningYesNoCancel(this, 3650 int result = KMessageBox::warningYesNoCancel(this,
3651 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), 3651 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ),
3652 i18n("Todo has subtodos"), 3652 i18n("Todo has subtodos"),
3653 i18n("Yes"), 3653 i18n("Yes"),
3654 i18n("No")); 3654 i18n("No"));
3655 3655
3656 if ( result == KMessageBox::Cancel ) { 3656 if ( result == KMessageBox::Cancel ) {
3657 delete t; 3657 delete t;
3658 return; 3658 return;
3659 } 3659 }
3660 if (result == KMessageBox::Yes) cloneSub = true; 3660 if (result == KMessageBox::Yes) cloneSub = true;
3661 } 3661 }
3662 showTodoEditor(); 3662 showTodoEditor();
3663 mTodoEditor->editTodo( t ); 3663 mTodoEditor->editTodo( t );
3664 if ( mTodoEditor->exec() ) { 3664 if ( mTodoEditor->exec() ) {
3665 if ( cloneSub ) { 3665 if ( cloneSub ) {
3666 orgInc->cloneRelations( t ); 3666 orgInc->cloneRelations( t );
3667 mCalendar->addIncidenceBranch( t ); 3667 mCalendar->addIncidenceBranch( t );
3668 updateView(); 3668 updateView();
3669 3669
3670 } else { 3670 } else {
3671 mCalendar->addTodo( t ); 3671 mCalendar->addTodo( t );
3672 updateView(); 3672 updateView();
3673 } 3673 }
3674 } else { 3674 } else {
3675 delete t; 3675 delete t;
3676 } 3676 }
3677 } 3677 }
3678 else if ( newInc->typeID() == eventID ) { 3678 else if ( newInc->typeID() == eventID ) {
3679 Event* e = (Event*) newInc; 3679 Event* e = (Event*) newInc;
3680 showEventEditor(); 3680 showEventEditor();
3681 mEventEditor->editEvent( e ); 3681 mEventEditor->editEvent( e );
3682 if ( mEventEditor->exec() ) { 3682 if ( mEventEditor->exec() ) {
3683 mCalendar->addEvent( e ); 3683 mCalendar->addEvent( e );
3684 updateView(); 3684 updateView();
3685 } else { 3685 } else {
3686 delete e; 3686 delete e;
3687 } 3687 }
3688 } else if ( newInc->typeID() == journalID ) { 3688 } else if ( newInc->typeID() == journalID ) {
3689 mCalendar->addJournal( (Journal*) newInc ); 3689 mCalendar->addJournal( (Journal*) newInc );
3690 editJournal( (Journal*) newInc ); 3690 editJournal( (Journal*) newInc );
3691 } 3691 }
3692 setActiveWindow(); 3692 setActiveWindow();
3693} 3693}
3694 3694
3695void CalendarView::newEvent() 3695void CalendarView::newEvent()
3696{ 3696{
3697 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3697 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
3698 KOAgendaView *aView = mViewManager->agendaView(); 3698 KOAgendaView *aView = mViewManager->agendaView();
3699 if (aView) { 3699 if (aView) {
3700 if (aView->selectionStart().isValid()) { 3700 if (aView->selectionStart().isValid()) {
3701 if (aView->selectedIsAllDay()) { 3701 if (aView->selectedIsAllDay()) {
3702 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3702 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
3703 } else { 3703 } else {
3704 newEvent(aView->selectionStart(),aView->selectionEnd()); 3704 newEvent(aView->selectionStart(),aView->selectionEnd());
3705 } 3705 }
3706 return; 3706 return;
3707 } 3707 }
3708 } 3708 }
3709 3709
3710 QDate date = mNavigator->selectedDates().first(); 3710 QDate date = mNavigator->selectedDates().first();
3711#if 0 3711#if 0
3712 QDateTime current = QDateTime::currentDateTime(); 3712 QDateTime current = QDateTime::currentDateTime();
3713 if ( date <= current.date() ) { 3713 if ( date <= current.date() ) {
3714 int hour = current.time().hour() +1; 3714 int hour = current.time().hour() +1;
3715 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3715 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3716 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3716 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3717 } else 3717 } else
3718#endif 3718#endif
3719 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3719 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3720 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3720 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3721 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3721 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3722} 3722}
3723 3723
3724void CalendarView::newEvent(QDateTime fh) 3724void CalendarView::newEvent(QDateTime fh)
3725{ 3725{
3726 newEvent(fh, 3726 newEvent(fh,
3727 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3727 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3728} 3728}
3729 3729
3730void CalendarView::newEvent(QDate dt) 3730void CalendarView::newEvent(QDate dt)
3731{ 3731{
3732 newEvent(QDateTime(dt, QTime(0,0,0)), 3732 newEvent(QDateTime(dt, QTime(0,0,0)),
3733 QDateTime(dt, QTime(0,0,0)), true); 3733 QDateTime(dt, QTime(0,0,0)), true);
3734} 3734}
3735void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3735void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3736{ 3736{
3737 newEvent(fromHint, toHint, false); 3737 newEvent(fromHint, toHint, false);
3738} 3738}
3739void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3739void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3740{ 3740{
3741 3741
3742 showEventEditor(); 3742 showEventEditor();
3743 mEventEditor->newEvent(fromHint,toHint,allDay); 3743 mEventEditor->newEvent(fromHint,toHint,allDay);
3744 if ( mFilterView->filtersEnabled() ) { 3744 if ( mFilterView->filtersEnabled() ) {
3745 CalFilter *filter = mFilterView->selectedFilter(); 3745 CalFilter *filter = mFilterView->selectedFilter();
3746 if (filter && filter->showCategories()) { 3746 if (filter && filter->showCategories()) {
3747 mEventEditor->setCategories(filter->categoryList().join(",") ); 3747 mEventEditor->setCategories(filter->categoryList().join(",") );
3748 } 3748 }
3749 if ( filter ) 3749 if ( filter )
3750 mEventEditor->setSecrecy( filter->getSecrecy() ); 3750 mEventEditor->setSecrecy( filter->getSecrecy() );
3751 } 3751 }
3752 mEventEditor->exec(); 3752 mEventEditor->exec();
3753 setActiveWindow(); 3753 setActiveWindow();
3754} 3754}
3755void CalendarView::todoAdded(Todo * t) 3755void CalendarView::todoAdded(Todo * t)
3756{ 3756{
3757 3757
3758 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3758 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3759 updateTodoViews(); 3759 updateTodoViews();
3760} 3760}
3761void CalendarView::todoChanged(Todo * t) 3761void CalendarView::todoChanged(Todo * t)
3762{ 3762{
3763 emit todoModified( t, 4 ); 3763 emit todoModified( t, 4 );
3764 // updateTodoViews(); 3764 // updateTodoViews();
3765} 3765}
3766void CalendarView::todoToBeDeleted(Todo *) 3766void CalendarView::todoToBeDeleted(Todo *)
3767{ 3767{
3768 //qDebug("todoToBeDeleted(Todo *) "); 3768 //qDebug("todoToBeDeleted(Todo *) ");
3769 updateTodoViews(); 3769 updateTodoViews();
3770} 3770}
3771void CalendarView::todoDeleted() 3771void CalendarView::todoDeleted()
3772{ 3772{
3773 //qDebug(" todoDeleted()"); 3773 //qDebug(" todoDeleted()");
3774 updateTodoViews(); 3774 updateTodoViews();
3775} 3775}
3776 3776
3777 3777
3778void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3778void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3779{ 3779{
3780 showTodoEditor(); 3780 showTodoEditor();
3781 mTodoEditor->newTodo(dt,0,allday); 3781 mTodoEditor->newTodo(dt,0,allday);
3782 if ( mFilterView->filtersEnabled() ) { 3782 if ( mFilterView->filtersEnabled() ) {
3783 CalFilter *filter = mFilterView->selectedFilter(); 3783 CalFilter *filter = mFilterView->selectedFilter();
3784 if (filter && filter->showCategories()) { 3784 if (filter && filter->showCategories()) {
3785 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3785 mTodoEditor->setCategories(filter->categoryList().join(",") );
3786 } 3786 }
3787 if ( filter ) 3787 if ( filter )
3788 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3788 mTodoEditor->setSecrecy( filter->getSecrecy() );
3789 } 3789 }
3790 mTodoEditor->exec(); 3790 mTodoEditor->exec();
3791 setActiveWindow(); 3791 setActiveWindow();
3792} 3792}
3793 3793
3794void CalendarView::newTodo() 3794void CalendarView::newTodo()
3795{ 3795{
3796 newTodoDateTime( QDateTime(),true ); 3796 newTodoDateTime( QDateTime(),true );
3797} 3797}
3798 3798
3799void CalendarView::newSubTodo() 3799void CalendarView::newSubTodo()
3800{ 3800{
3801 Todo *todo = selectedTodo(); 3801 Todo *todo = selectedTodo();
3802 if ( todo ) newSubTodo( todo ); 3802 if ( todo ) newSubTodo( todo );
3803} 3803}
3804 3804
3805void CalendarView::newSubTodo(Todo *parentEvent) 3805void CalendarView::newSubTodo(Todo *parentEvent)
3806{ 3806{
3807 3807
3808 showTodoEditor(); 3808 showTodoEditor();
3809 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3809 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3810 mTodoEditor->exec(); 3810 mTodoEditor->exec();
3811 setActiveWindow(); 3811 setActiveWindow();
3812} 3812}
3813 3813
3814void CalendarView::newFloatingEvent() 3814void CalendarView::newFloatingEvent()
3815{ 3815{
3816 DateList tmpList = mNavigator->selectedDates(); 3816 DateList tmpList = mNavigator->selectedDates();
3817 QDate date = tmpList.first(); 3817 QDate date = tmpList.first();
3818 3818
3819 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3819 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3820 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3820 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3821} 3821}
3822 3822
3823 3823
3824void CalendarView::editEvent( Event *event ) 3824void CalendarView::editEvent( Event *event )
3825{ 3825{
3826 3826
3827 if ( !event ) return; 3827 if ( !event ) return;
3828 if ( event->isReadOnly() ) { 3828 if ( event->isReadOnly() ) {
3829 showEvent( event ); 3829 showEvent( event );
3830 return; 3830 return;
3831 } 3831 }
3832 showEventEditor(); 3832 showEventEditor();
3833 mEventEditor->editEvent( event , mFlagEditDescription); 3833 mEventEditor->editEvent( event , mFlagEditDescription);
3834 mEventEditor->exec(); 3834 mEventEditor->exec();
3835 setActiveWindow(); 3835 setActiveWindow();
3836 3836
3837} 3837}
3838void CalendarView::editJournal( Journal *jour ) 3838void CalendarView::editJournal( Journal *jour )
3839{ 3839{
3840 if ( !jour ) return; 3840 if ( !jour ) return;
3841 mDialogManager->hideSearchDialog(); 3841 mDialogManager->hideSearchDialog();
3842 mViewManager->showJournalView(); 3842 mViewManager->showJournalView();
3843 mNavigator->slotDaySelect( jour->dtStart().date() ); 3843 mNavigator->slotDaySelect( jour->dtStart().date() );
3844} 3844}
3845void CalendarView::editTodo( Todo *todo ) 3845void CalendarView::editTodo( Todo *todo )
3846{ 3846{
3847 if ( !todo ) return; 3847 if ( !todo ) return;
3848 3848
3849 if ( todo->isReadOnly() ) { 3849 if ( todo->isReadOnly() ) {
3850 showTodo( todo ); 3850 showTodo( todo );
3851 return; 3851 return;
3852 } 3852 }
3853 showTodoEditor(); 3853 showTodoEditor();
3854 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3854 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3855 mTodoEditor->exec(); 3855 mTodoEditor->exec();
3856 setActiveWindow(); 3856 setActiveWindow();
3857 3857
3858} 3858}
3859 3859
3860KOEventViewerDialog* CalendarView::getEventViewerDialog() 3860KOEventViewerDialog* CalendarView::getEventViewerDialog()
3861{ 3861{
3862 if ( !mEventViewerDialog ) { 3862 if ( !mEventViewerDialog ) {
3863 mEventViewerDialog = new KOEventViewerDialog(0); 3863 mEventViewerDialog = new KOEventViewerDialog(0);
3864 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3864 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3865 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3865 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3866 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3866 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3867 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3867 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3868 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3868 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3869 viewManager(), SLOT( showAgendaView( bool ) ) ); 3869 viewManager(), SLOT( showAgendaView( bool ) ) );
3870 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3870 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3871 this, SLOT( slotViewerClosed() ) ); 3871 this, SLOT( slotViewerClosed() ) );
3872 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3872 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3873 this, SLOT( todoChanged(Todo *) ) ); 3873 this, SLOT( todoChanged(Todo *) ) );
3874 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 3874 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
3875 mEventViewerDialog->resize( 640, 480 ); 3875 mEventViewerDialog->resize( 640, 480 );
3876 3876
3877 } 3877 }
3878 return mEventViewerDialog; 3878 return mEventViewerDialog;
3879} 3879}
3880void CalendarView::showEvent(Event *event) 3880void CalendarView::showEvent(Event *event)
3881{ 3881{
3882 getEventViewerDialog()->setEvent(event); 3882 getEventViewerDialog()->setEvent(event);
3883 getEventViewerDialog()->showMe(); 3883 getEventViewerDialog()->showMe();
3884} 3884}
3885 3885
3886void CalendarView::showTodo(Todo *event) 3886void CalendarView::showTodo(Todo *event)
3887{ 3887{
3888 getEventViewerDialog()->setTodo(event); 3888 getEventViewerDialog()->setTodo(event);
3889 getEventViewerDialog()->showMe(); 3889 getEventViewerDialog()->showMe();
3890} 3890}
3891void CalendarView::showJournal( Journal *jour ) 3891void CalendarView::showJournal( Journal *jour )
3892{ 3892{
3893 getEventViewerDialog()->setJournal(jour); 3893 getEventViewerDialog()->setJournal(jour);
3894 getEventViewerDialog()->showMe(); 3894 getEventViewerDialog()->showMe();
3895 3895
3896} 3896}
3897// void CalendarView::todoModified (Todo *event, int changed) 3897// void CalendarView::todoModified (Todo *event, int changed)
3898// { 3898// {
3899// // if (mDialogList.find (event) != mDialogList.end ()) { 3899// // if (mDialogList.find (event) != mDialogList.end ()) {
3900// // kdDebug() << "Todo modified and open" << endl; 3900// // kdDebug() << "Todo modified and open" << endl;
3901// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3901// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3902// // temp->modified (changed); 3902// // temp->modified (changed);
3903 3903
3904// // } 3904// // }
3905 3905
3906// mViewManager->updateView(); 3906// mViewManager->updateView();
3907// } 3907// }
3908 3908
3909void CalendarView::appointment_show() 3909void CalendarView::appointment_show()
3910{ 3910{
3911 Event *anEvent = 0; 3911 Event *anEvent = 0;
3912 3912
3913 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3913 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3914 3914
3915 if (mViewManager->currentView()->isEventView()) { 3915 if (mViewManager->currentView()->isEventView()) {
3916 if ( incidence && incidence->typeID() == eventID ) { 3916 if ( incidence && incidence->typeID() == eventID ) {
3917 anEvent = static_cast<Event *>(incidence); 3917 anEvent = static_cast<Event *>(incidence);
3918 } 3918 }
3919 } 3919 }
3920 3920
3921 if (!anEvent) { 3921 if (!anEvent) {
3922 KNotifyClient::beep(); 3922 KNotifyClient::beep();
3923 return; 3923 return;
3924 } 3924 }
3925 3925
3926 showEvent(anEvent); 3926 showEvent(anEvent);
3927} 3927}
3928 3928
3929void CalendarView::appointment_edit() 3929void CalendarView::appointment_edit()
3930{ 3930{
3931 Event *anEvent = 0; 3931 Event *anEvent = 0;
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 17248dc..07bfdbf 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,1750 +1,1755 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qheader.h> 25#include <qheader.h>
26#include <qcursor.h> 26#include <qcursor.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31 31
32#include <qinputdialog.h> 32#include <qinputdialog.h>
33 33
34#include <qvbox.h> 34#include <qvbox.h>
35#include <kdebug.h> 35#include <kdebug.h>
36#include "koprefs.h" 36#include "koprefs.h"
37#include <klocale.h> 37#include <klocale.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kdateedit.h> 39#include <kdateedit.h>
40#include "ktimeedit.h" 40#include "ktimeedit.h"
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kmessagebox.h> 42#include <kmessagebox.h>
43 43
44#include <libkcal/icaldrag.h> 44#include <libkcal/icaldrag.h>
45#include <libkcal/vcaldrag.h> 45#include <libkcal/vcaldrag.h>
46#include <libkcal/calfilter.h> 46#include <libkcal/calfilter.h>
47#include <libkcal/dndfactory.h> 47#include <libkcal/dndfactory.h>
48#include <libkcal/calendarresources.h> 48#include <libkcal/calendarresources.h>
49#include <libkcal/resourcecalendar.h> 49#include <libkcal/resourcecalendar.h>
50#include <kresources/resourceselectdialog.h> 50#include <kresources/resourceselectdialog.h>
51#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
52#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
53#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
54#else 54#else
55#include <qapplication.h> 55#include <qapplication.h>
56#endif 56#endif
57#ifndef KORG_NOPRINTER 57#ifndef KORG_NOPRINTER
58#include "calprinter.h" 58#include "calprinter.h"
59#endif 59#endif
60#include "docprefs.h" 60#include "docprefs.h"
61 61
62#include "kotodoview.h" 62#include "kotodoview.h"
63using namespace KOrg; 63using namespace KOrg;
64 64
65 65
66KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : 66KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) :
67 QDialog( parent, name, true ) 67 QDialog( parent, name, true )
68{ 68{
69 mStopAll = true; 69 mStopAll = true;
70 setCaption( i18n("Start todo") ); 70 setCaption( i18n("Start todo") );
71 QVBoxLayout* lay = new QVBoxLayout( this ); 71 QVBoxLayout* lay = new QVBoxLayout( this );
72 lay->setSpacing( 3 ); 72 lay->setSpacing( 3 );
73 lay->setMargin( 3 ); 73 lay->setMargin( 3 );
74 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); 74 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this );
75 lay->addWidget( lab ); 75 lay->addWidget( lab );
76 lab->setAlignment( AlignCenter ); 76 lab->setAlignment( AlignCenter );
77 77
78 QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); 78 QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this );
79 lay->addWidget( ok ); 79 lay->addWidget( ok );
80 ok->setDefault( true ); 80 ok->setDefault( true );
81 QPushButton * start = new QPushButton( i18n("Start todo"), this ); 81 QPushButton * start = new QPushButton( i18n("Start todo"), this );
82 lay->addWidget( start ); 82 lay->addWidget( start );
83 QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); 83 QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this );
84 lay->addWidget( cancel ); 84 lay->addWidget( cancel );
85 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 85 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
86 connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); 86 connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) );
87 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 87 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
88 resize( sizeHint() ); 88 resize( sizeHint() );
89 89
90} 90}
91void KOStartTodoPrefs::doStop() 91void KOStartTodoPrefs::doStop()
92{ 92{
93 mStopAll = false; 93 mStopAll = false;
94 accept(); 94 accept();
95} 95}
96KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : 96KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) :
97 QDialog( parent, name, true ) 97 QDialog( parent, name, true )
98{ 98{
99 mTodo = todo; 99 mTodo = todo;
100 setCaption( i18n("Stop todo") ); 100 setCaption( i18n("Stop todo") );
101 QVBoxLayout* lay = new QVBoxLayout( this ); 101 QVBoxLayout* lay = new QVBoxLayout( this );
102 lay->setSpacing( 3 ); 102 lay->setSpacing( 3 );
103 lay->setMargin( 3 ); 103 lay->setMargin( 3 );
104 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); 104 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this );
105 lay->addWidget( lab ); 105 lay->addWidget( lab );
106 lab->setAlignment( AlignHCenter ); 106 lab->setAlignment( AlignHCenter );
107 lab = new QLabel( i18n("Additional Comment:"), this ); 107 lab = new QLabel( i18n("Additional Comment:"), this );
108 lay->addWidget( lab ); 108 lay->addWidget( lab );
109 mComment = new QLineEdit( this ); 109 mComment = new QLineEdit( this );
110 lay->addWidget( mComment ); 110 lay->addWidget( mComment );
111 QHBox * start = new QHBox ( this ); 111 QHBox * start = new QHBox ( this );
112 lay->addWidget( start ); 112 lay->addWidget( start );
113 lab = new QLabel( i18n("Start:"), start ); 113 lab = new QLabel( i18n("Start:"), start );
114 QHBox * end = new QHBox ( this ); 114 QHBox * end = new QHBox ( this );
115 lay->addWidget( end ); 115 lay->addWidget( end );
116 lab = new QLabel( i18n("End:"), end ); 116 lab = new QLabel( i18n("End:"), end );
117 sde = new KDateEdit( start ); 117 sde = new KDateEdit( start );
118 ste = new KOTimeEdit( start ); 118 ste = new KOTimeEdit( start );
119 connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); 119 connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) );
120 ede = new KDateEdit( end ); 120 ede = new KDateEdit( end );
121 ete = new KOTimeEdit(end ); 121 ete = new KOTimeEdit(end );
122 connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); 122 connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) );
123 sde->setDate( mTodo->runStart().date() ); 123 sde->setDate( mTodo->runStart().date() );
124 ste->setTime( mTodo->runStart().time() ); 124 ste->setTime( mTodo->runStart().time() );
125 ede->setDate( QDate::currentDate()); 125 ede->setDate( QDate::currentDate());
126 ete->setTime( QTime::currentTime() ); 126 ete->setTime( QTime::currentTime() );
127 QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); 127 QPushButton * ok = new QPushButton( i18n("Stop and save"), this );
128 lay->addWidget( ok ); 128 lay->addWidget( ok );
129 ok->setDefault( true ); 129 ok->setDefault( true );
130 QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); 130 QPushButton * cancel = new QPushButton( i18n("Continue running"), this );
131 lay->addWidget( cancel ); 131 lay->addWidget( cancel );
132 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 132 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
133 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 133 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
134 ok = new QPushButton( i18n("Stop - do not save"), this ); 134 ok = new QPushButton( i18n("Stop - do not save"), this );
135 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); 135 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) );
136 lay->addWidget( ok ); 136 lay->addWidget( ok );
137 if (QApplication::desktop()->width() < 320 ) 137 if (QApplication::desktop()->width() < 320 )
138 resize( 240, sizeHint().height() ); 138 resize( 240, sizeHint().height() );
139 else 139 else
140 resize( 320, sizeHint().height() ); 140 resize( 320, sizeHint().height() );
141 141
142} 142}
143 143
144void KOStopTodoPrefs::accept() 144void KOStopTodoPrefs::accept()
145{ 145{
146 QDateTime start = QDateTime( sde->date(), ste->getTime() ); 146 QDateTime start = QDateTime( sde->date(), ste->getTime() );
147 QDateTime stop = QDateTime( ede->date(), ete->getTime() ); 147 QDateTime stop = QDateTime( ede->date(), ete->getTime() );
148 if ( start > stop ) { 148 if ( start > stop ) {
149 KMessageBox::sorry(this, 149 KMessageBox::sorry(this,
150 i18n("The start time is\nafter the end time!"), 150 i18n("The start time is\nafter the end time!"),
151 i18n("Time mismatch!")); 151 i18n("Time mismatch!"));
152 return; 152 return;
153 } 153 }
154 mTodo->saveRunningInfo( mComment->text(), start, stop ); 154 mTodo->saveRunningInfo( mComment->text(), start, stop );
155 QDialog::accept(); 155 QDialog::accept();
156} 156}
157void KOStopTodoPrefs::doNotSave() 157void KOStopTodoPrefs::doNotSave()
158{ 158{
159 int result = KMessageBox::warningContinueCancel(this, 159 int result = KMessageBox::warningContinueCancel(this,
160 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); 160 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") );
161 if (result != KMessageBox::Continue) return; 161 if (result != KMessageBox::Continue) return;
162 mTodo->stopRunning(); 162 mTodo->stopRunning();
163 QDialog::accept(); 163 QDialog::accept();
164} 164}
165 165
166 166
167class KOTodoViewWhatsThis :public QWhatsThis 167class KOTodoViewWhatsThis :public QWhatsThis
168{ 168{
169public: 169public:
170 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 170 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
171 171
172protected: 172protected:
173 virtual QString text( const QPoint& p) 173 virtual QString text( const QPoint& p)
174 { 174 {
175 return _view->getWhatsThisText(p) ; 175 return _view->getWhatsThisText(p) ;
176 } 176 }
177private: 177private:
178 QWidget* _wid; 178 QWidget* _wid;
179 KOTodoView * _view; 179 KOTodoView * _view;
180}; 180};
181 181
182KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 182KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
183 const char *name) : 183 const char *name) :
184 KListView(parent,name) 184 KListView(parent,name)
185{ 185{
186 mName = QString ( name ); 186 mName = QString ( name );
187 mCalendar = calendar; 187 mCalendar = calendar;
188#ifndef DESKTOP_VERSION 188#ifndef DESKTOP_VERSION
189 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 189 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
190#endif 190#endif
191 mOldCurrent = 0; 191 mOldCurrent = 0;
192 mMousePressed = false; 192 mMousePressed = false;
193 193
194 setAcceptDrops(true); 194 setAcceptDrops(true);
195 viewport()->setAcceptDrops(true); 195 viewport()->setAcceptDrops(true);
196 int size = 16; 196 int size = 16;
197 if (qApp->desktop()->width() < 300 ) 197 if (qApp->desktop()->width() < 300 )
198 size = 12; 198 size = 12;
199 setTreeStepSize( size + 6 ); 199 setTreeStepSize( size + 6 );
200 200
201} 201}
202 202
203void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 203void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
204{ 204{
205#ifndef KORG_NODND 205#ifndef KORG_NODND
206// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 206// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
207 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 207 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
208 !QTextDrag::canDecode( e ) ) { 208 !QTextDrag::canDecode( e ) ) {
209 e->ignore(); 209 e->ignore();
210 return; 210 return;
211 } 211 }
212 212
213 mOldCurrent = currentItem(); 213 mOldCurrent = currentItem();
214#endif 214#endif
215} 215}
216 216
217 217
218void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 218void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
219{ 219{
220#ifndef KORG_NODND 220#ifndef KORG_NODND
221// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 221// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
222 222
223 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 223 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
224 !QTextDrag::canDecode( e ) ) { 224 !QTextDrag::canDecode( e ) ) {
225 e->ignore(); 225 e->ignore();
226 return; 226 return;
227 } 227 }
228 228
229 e->accept(); 229 e->accept();
230#endif 230#endif
231} 231}
232 232
233void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 233void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
234{ 234{
235#ifndef KORG_NODND 235#ifndef KORG_NODND
236// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 236// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
237 237
238 setCurrentItem(mOldCurrent); 238 setCurrentItem(mOldCurrent);
239 setSelected(mOldCurrent,true); 239 setSelected(mOldCurrent,true);
240#endif 240#endif
241} 241}
242 242
243void KOTodoListView::contentsDropEvent(QDropEvent *e) 243void KOTodoListView::contentsDropEvent(QDropEvent *e)
244{ 244{
245#ifndef KORG_NODND 245#ifndef KORG_NODND
246// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 246// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
247 247
248 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 248 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
249 !QTextDrag::canDecode( e ) ) { 249 !QTextDrag::canDecode( e ) ) {
250 e->ignore(); 250 e->ignore();
251 return; 251 return;
252 } 252 }
253 253
254 DndFactory factory( mCalendar ); 254 DndFactory factory( mCalendar );
255 Todo *todo = factory.createDropTodo(e); 255 Todo *todo = factory.createDropTodo(e);
256 256
257 if (todo) { 257 if (todo) {
258 e->acceptAction(); 258 e->acceptAction();
259 259
260 KOTodoViewItem *destination = 260 KOTodoViewItem *destination =
261 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 261 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
262 Todo *destinationEvent = 0; 262 Todo *destinationEvent = 0;
263 if (destination) destinationEvent = destination->todo(); 263 if (destination) destinationEvent = destination->todo();
264 264
265 Todo *existingTodo = mCalendar->todo(todo->uid()); 265 Todo *existingTodo = mCalendar->todo(todo->uid());
266 266
267 if(existingTodo) { 267 if(existingTodo) {
268 Incidence *to = destinationEvent; 268 Incidence *to = destinationEvent;
269 while(to) { 269 while(to) {
270 if (to->uid() == todo->uid()) { 270 if (to->uid() == todo->uid()) {
271 KMessageBox::sorry(this, 271 KMessageBox::sorry(this,
272 i18n("Cannot move Todo to itself\nor a child of itself"), 272 i18n("Cannot move Todo to itself\nor a child of itself"),
273 i18n("Drop Todo")); 273 i18n("Drop Todo"));
274 delete todo; 274 delete todo;
275 return; 275 return;
276 } 276 }
277 to = to->relatedTo(); 277 to = to->relatedTo();
278 } 278 }
279 internalDrop = true; 279 internalDrop = true;
280 if ( destinationEvent ) 280 if ( destinationEvent )
281 reparentTodoSignal( destinationEvent, existingTodo ); 281 reparentTodoSignal( destinationEvent, existingTodo );
282 else 282 else
283 unparentTodoSignal(existingTodo); 283 unparentTodoSignal(existingTodo);
284 delete todo; 284 delete todo;
285 } else { 285 } else {
286 mCalendar->addTodo(todo); 286 mCalendar->addTodo(todo);
287 emit todoDropped(todo, KOGlobals::EVENTADDED); 287 emit todoDropped(todo, KOGlobals::EVENTADDED);
288 if ( destinationEvent ) 288 if ( destinationEvent )
289 reparentTodoSignal( destinationEvent, todo ); 289 reparentTodoSignal( destinationEvent, todo );
290 } 290 }
291 } 291 }
292 else { 292 else {
293 QString text; 293 QString text;
294 if (QTextDrag::decode(e,text)) { 294 if (QTextDrag::decode(e,text)) {
295 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 295 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
296 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 296 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
297 qDebug("Dropped : " + text); 297 qDebug("Dropped : " + text);
298 QStringList emails = QStringList::split(",",text); 298 QStringList emails = QStringList::split(",",text);
299 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 299 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
300 int pos = (*it).find("<"); 300 int pos = (*it).find("<");
301 QString name = (*it).left(pos); 301 QString name = (*it).left(pos);
302 QString email = (*it).mid(pos); 302 QString email = (*it).mid(pos);
303 if (!email.isEmpty() && todoi) { 303 if (!email.isEmpty() && todoi) {
304 todoi->todo()->addAttendee(new Attendee(name,email)); 304 todoi->todo()->addAttendee(new Attendee(name,email));
305 } 305 }
306 } 306 }
307 } 307 }
308 else { 308 else {
309 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 309 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
310 e->ignore(); 310 e->ignore();
311 } 311 }
312 } 312 }
313#endif 313#endif
314} 314}
315void KOTodoListView::wheelEvent (QWheelEvent *e) 315void KOTodoListView::wheelEvent (QWheelEvent *e)
316{ 316{
317 QListView::wheelEvent (e); 317 QListView::wheelEvent (e);
318} 318}
319 319
320void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 320void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
321{ 321{
322 322
323 QPoint p(contentsToViewport(e->pos())); 323 QPoint p(contentsToViewport(e->pos()));
324 QListViewItem *i = itemAt(p); 324 QListViewItem *i = itemAt(p);
325 bool rootClicked = true; 325 bool rootClicked = true;
326 if (i) { 326 if (i) {
327 // if the user clicked into the root decoration of the item, don't 327 // if the user clicked into the root decoration of the item, don't
328 // try to start a drag! 328 // try to start a drag!
329 int X = p.x(); 329 int X = p.x();
330 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); 330 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
331 if (X > header()->sectionPos(0) + 331 if (X > header()->sectionPos(0) +
332 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 332 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
333 itemMargin() +i->height()|| 333 itemMargin() +i->height()||
334 X < header()->sectionPos(0)) { 334 X < header()->sectionPos(0)) {
335 rootClicked = false; 335 rootClicked = false;
336 } 336 }
337 } else { 337 } else {
338 rootClicked = false; 338 rootClicked = false;
339 } 339 }
340#ifndef KORG_NODND 340#ifndef KORG_NODND
341 mMousePressed = false; 341 mMousePressed = false;
342 if (! rootClicked && !( e->button() == RightButton) ) { 342 if (! rootClicked && !( e->button() == RightButton) ) {
343 mPressPos = e->pos(); 343 mPressPos = e->pos();
344 mMousePressed = true; 344 mMousePressed = true;
345 } else { 345 } else {
346 mMousePressed = false; 346 mMousePressed = false;
347 } 347 }
348#endif 348#endif
349 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); 349 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
350#ifndef DESKTOP_VERSION 350#ifndef DESKTOP_VERSION
351 if (!( e->button() == RightButton && rootClicked) ) 351 if (!( e->button() == RightButton && rootClicked) )
352 QListView::contentsMousePressEvent(e); 352 QListView::contentsMousePressEvent(e);
353#else 353#else
354 QListView::contentsMousePressEvent(e); 354 QListView::contentsMousePressEvent(e);
355#endif 355#endif
356} 356}
357void KOTodoListView::paintEvent(QPaintEvent* e) 357void KOTodoListView::paintEvent(QPaintEvent* e)
358{ 358{
359 emit paintNeeded(); 359 emit paintNeeded();
360 QListView::paintEvent( e); 360 QListView::paintEvent( e);
361} 361}
362void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 362void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
363{ 363{
364 364
365#ifndef KORG_NODND 365#ifndef KORG_NODND
366 //QListView::contentsMouseMoveEvent(e); 366 //QListView::contentsMouseMoveEvent(e);
367 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 367 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
368 QApplication::startDragDistance()*3) { 368 QApplication::startDragDistance()*3) {
369 mMousePressed = false; 369 mMousePressed = false;
370 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 370 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
371 if (item) { 371 if (item) {
372 DndFactory factory( mCalendar ); 372 DndFactory factory( mCalendar );
373 ICalDrag *vd = factory.createDrag( 373 ICalDrag *vd = factory.createDrag(
374 ((KOTodoViewItem *)item)->todo(),viewport()); 374 ((KOTodoViewItem *)item)->todo(),viewport());
375 internalDrop = false; 375 internalDrop = false;
376 // we cannot do any senseful here, because the DnD is still broken in Qt 376 // we cannot do any senseful here, because the DnD is still broken in Qt
377 if (vd->drag()) { 377 if (vd->drag()) {
378 if ( !internalDrop ) { 378 if ( !internalDrop ) {
379 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 379 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
380 qDebug("Dnd: External move: Delete drag source "); 380 qDebug("Dnd: External move: Delete drag source ");
381 } else 381 } else
382 qDebug("Dnd: Internal move "); 382 qDebug("Dnd: Internal move ");
383 383
384 } else { 384 } else {
385 if ( !internalDrop ) { 385 if ( !internalDrop ) {
386 qDebug("Dnd: External Copy"); 386 qDebug("Dnd: External Copy");
387 } else 387 } else
388 qDebug("DnD: Internal copy: Copy pending"); 388 qDebug("DnD: Internal copy: Copy pending");
389 } 389 }
390 } 390 }
391 } 391 }
392#endif 392#endif
393} 393}
394void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) 394void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
395{ 395{
396 if ( !e->isAutoRepeat() ) { 396 if ( !e->isAutoRepeat() ) {
397 mFlagKeyPressed = false; 397 mFlagKeyPressed = false;
398 } 398 }
399} 399}
400 400
401 401
402void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 402void KOTodoListView::keyPressEvent ( QKeyEvent * e )
403{ 403{
404 qApp->processEvents(); 404 qApp->processEvents();
405 if ( !isVisible() ) { 405 if ( !isVisible() ) {
406 e->ignore(); 406 e->ignore();
407 return; 407 return;
408 } 408 }
409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
410 e->ignore(); 410 e->ignore();
411 // qDebug(" ignore %d",e->isAutoRepeat() ); 411 // qDebug(" ignore %d",e->isAutoRepeat() );
412 return; 412 return;
413 } 413 }
414 if (! e->isAutoRepeat() ) 414 if (! e->isAutoRepeat() )
415 mFlagKeyPressed = true; 415 mFlagKeyPressed = true;
416 QListViewItem* cn; 416 QListViewItem* cn;
417 if ( (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && mName != "todolistsmall") { 417 if ( (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && mName != "todolistsmall") {
418 cn = currentItem(); 418 cn = currentItem();
419 if ( cn ) { 419 if ( cn ) {
420 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 420 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
421 if ( ci ){ 421 if ( ci ){
422 if ( e->state() == ShiftButton ) 422 if ( e->state() == ShiftButton )
423 ci->setOn( false ); 423 ci->setOn( false );
424 else 424 else
425 ci->setOn( true ); 425 ci->setOn( true );
426 cn = cn->itemBelow(); 426 cn = cn->itemBelow();
427 if ( cn ) { 427 if ( cn ) {
428 setCurrentItem ( cn ); 428 setCurrentItem ( cn );
429 ensureItemVisible ( cn ); 429 ensureItemVisible ( cn );
430 } 430 }
431 431
432 } 432 }
433 } 433 }
434 434
435 e->accept(); 435 e->accept();
436 return; 436 return;
437 } 437 }
438 438
439 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 439 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
440 switch ( e->key() ) { 440 switch ( e->key() ) {
441 case Qt::Key_Down: 441 case Qt::Key_Down:
442 case Qt::Key_Up: 442 case Qt::Key_Up:
443 QListView::keyPressEvent ( e ); 443 QListView::keyPressEvent ( e );
444 e->accept(); 444 e->accept();
445 break; 445 break;
446 case Qt::Key_Left: 446 case Qt::Key_Left:
447 case Qt::Key_Right: 447 case Qt::Key_Right:
448 QListView::keyPressEvent ( e ); 448 QListView::keyPressEvent ( e );
449 e->accept(); 449 e->accept();
450 return; 450 return;
451 break; 451 break;
452 default: 452 default:
453 e->ignore(); 453 e->ignore();
454 break; 454 break;
455 } 455 }
456 return; 456 return;
457 } 457 }
458 e->ignore(); 458 e->ignore();
459} 459}
460void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 460void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
461{ 461{
462 QListView::contentsMouseReleaseEvent(e); 462 QListView::contentsMouseReleaseEvent(e);
463 mMousePressed = false; 463 mMousePressed = false;
464} 464}
465 465
466void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 466void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
467{ 467{
468 if (!e) return; 468 if (!e) return;
469 469
470 QPoint vp = contentsToViewport(e->pos()); 470 QPoint vp = contentsToViewport(e->pos());
471 471
472 QListViewItem *item = itemAt(vp); 472 QListViewItem *item = itemAt(vp);
473 473
474 emit double_Clicked(item); 474 emit double_Clicked(item);
475 if (!item) return; 475 if (!item) return;
476 476
477 emit doubleClicked(item,vp,0); 477 emit doubleClicked(item,vp,0);
478} 478}
479 479
480///////////////////////////////////////////////////////////////////////////// 480/////////////////////////////////////////////////////////////////////////////
481 481
482KOQuickTodo::KOQuickTodo(QWidget *parent) : 482KOQuickTodo::KOQuickTodo(QWidget *parent) :
483 QLineEdit(parent) 483 QLineEdit(parent)
484{ 484{
485 setText(i18n("Click to add new Todo")); 485 setText(i18n("Click to add new Todo"));
486 setFocusPolicy ( QWidget::ClickFocus ); 486 setFocusPolicy ( QWidget::ClickFocus );
487} 487}
488 488
489void KOQuickTodo::focusInEvent(QFocusEvent *ev) 489void KOQuickTodo::focusInEvent(QFocusEvent *ev)
490{ 490{
491 if ( text()==i18n("Click to add new Todo") ) 491 if ( text()==i18n("Click to add new Todo") )
492 setText(""); 492 setText("");
493 QLineEdit::focusInEvent(ev); 493 QLineEdit::focusInEvent(ev);
494} 494}
495 495
496void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 496void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
497{ 497{
498 setText(i18n("Click to add new Todo")); 498 setText(i18n("Click to add new Todo"));
499 QLineEdit::focusOutEvent(ev); 499 QLineEdit::focusOutEvent(ev);
500} 500}
501 501
502///////////////////////////////////////////////////////////////////////////// 502/////////////////////////////////////////////////////////////////////////////
503 503
504KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 504KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
505 KOrg::BaseView(calendar,parent,name) 505 KOrg::BaseView(calendar,parent,name)
506{ 506{
507
508 mCurItem = 0;
509 mCurItemRootParent = 0;
510 mCurItemParent = 0;
511 mCurItemAbove = 0;
507 mActiveItem = 0; 512 mActiveItem = 0;
508 mCategoryPopupMenu = 0; 513 mCategoryPopupMenu = 0;
509 mPendingUpdateBeforeRepaint = false; 514 mPendingUpdateBeforeRepaint = false;
510 isFlatDisplay = false; 515 isFlatDisplay = false;
511 mNavigator = 0; 516 mNavigator = 0;
512 QBoxLayout *topLayout = new QVBoxLayout(this); 517 QBoxLayout *topLayout = new QVBoxLayout(this);
513 mName = QString ( name ); 518 mName = QString ( name );
514 mBlockUpdate = false; 519 mBlockUpdate = false;
515 mQuickBar = new QWidget( this ); 520 mQuickBar = new QWidget( this );
516 topLayout->addWidget(mQuickBar); 521 topLayout->addWidget(mQuickBar);
517 522
518 mQuickAdd = new KOQuickTodo(mQuickBar); 523 mQuickAdd = new KOQuickTodo(mQuickBar);
519 QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); 524 QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar);
520 quickLayout->addWidget( mQuickAdd ); 525 quickLayout->addWidget( mQuickAdd );
521 mNewSubBut = new QPushButton( "sub",mQuickBar ); 526 mNewSubBut = new QPushButton( "sub",mQuickBar );
522 QPushButton * s_done = new QPushButton( "D",mQuickBar ); 527 QPushButton * s_done = new QPushButton( "D",mQuickBar );
523 QPushButton * s_run = new QPushButton( "R",mQuickBar ); 528 QPushButton * s_run = new QPushButton( "R",mQuickBar );
524 QPushButton * allopen = new QPushButton( "O",mQuickBar ); 529 QPushButton * allopen = new QPushButton( "O",mQuickBar );
525 QPushButton * allclose = new QPushButton( "C",mQuickBar ); 530 QPushButton * allclose = new QPushButton( "C",mQuickBar );
526 QPushButton * flat = new QPushButton( "F",mQuickBar ); 531 QPushButton * flat = new QPushButton( "F",mQuickBar );
527 532
528 int fixwid = mQuickAdd->sizeHint().height(); 533 int fixwid = mQuickAdd->sizeHint().height();
529 int fixhei = fixwid; 534 int fixhei = fixwid;
530 if ( QApplication::desktop()->width() > 800 ) 535 if ( QApplication::desktop()->width() > 800 )
531 fixwid = (fixwid*3)/2; 536 fixwid = (fixwid*3)/2;
532 connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); 537 connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat()));
533 connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); 538 connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen()));
534 connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); 539 connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose()));
535 s_done->setPixmap( SmallIcon("greenhook16")); 540 s_done->setPixmap( SmallIcon("greenhook16"));
536 connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); 541 connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted()));
537 s_run->setPixmap( SmallIcon("ko16old")); 542 s_run->setPixmap( SmallIcon("ko16old"));
538 connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); 543 connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning()));
539 544
540 connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); 545 connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo()));
541 546
542 mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); 547 mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() );
543 mNewSubBut->setEnabled( false ); 548 mNewSubBut->setEnabled( false );
544 flat->setFixedWidth( fixwid ); 549 flat->setFixedWidth( fixwid );
545 s_done->setFixedWidth( fixwid ); 550 s_done->setFixedWidth( fixwid );
546 allopen->setFixedWidth( fixwid ); 551 allopen->setFixedWidth( fixwid );
547 allclose->setFixedWidth( fixwid ); 552 allclose->setFixedWidth( fixwid );
548 s_run->setFixedWidth( fixwid ); 553 s_run->setFixedWidth( fixwid );
549 554
550 flat->setFixedHeight(fixhei ); 555 flat->setFixedHeight(fixhei );
551 s_done->setFixedHeight(fixhei ); 556 s_done->setFixedHeight(fixhei );
552 allopen->setFixedHeight(fixhei ); 557 allopen->setFixedHeight(fixhei );
553 allclose->setFixedHeight(fixhei ); 558 allclose->setFixedHeight(fixhei );
554 s_run->setFixedHeight(fixhei ); 559 s_run->setFixedHeight(fixhei );
555 mNewSubBut->setFixedHeight(fixhei ); 560 mNewSubBut->setFixedHeight(fixhei );
556 561
557 flat->setFocusPolicy( NoFocus ); 562 flat->setFocusPolicy( NoFocus );
558 s_done->setFocusPolicy( NoFocus ); 563 s_done->setFocusPolicy( NoFocus );
559 allopen->setFocusPolicy( NoFocus ); 564 allopen->setFocusPolicy( NoFocus );
560 allclose->setFocusPolicy( NoFocus ); 565 allclose->setFocusPolicy( NoFocus );
561 s_run->setFocusPolicy( NoFocus ); 566 s_run->setFocusPolicy( NoFocus );
562 mNewSubBut->setFocusPolicy( NoFocus ); 567 mNewSubBut->setFocusPolicy( NoFocus );
563 568
564 QWhatsThis::add( flat, i18n("Click this button to display all todos in a <b>flat</b> hierarchy" ) ); 569 QWhatsThis::add( flat, i18n("Click this button to display all todos in a <b>flat</b> hierarchy" ) );
565 QWhatsThis::add( allopen, i18n("Click this button to display all todos <b>openend</b>" ) ); 570 QWhatsThis::add( allopen, i18n("Click this button to display all todos <b>openend</b>" ) );
566 QWhatsThis::add( allclose, i18n("Click this button to display all todos <b>closed</b>" ) ); 571 QWhatsThis::add( allclose, i18n("Click this button to display all todos <b>closed</b>" ) );
567 QWhatsThis::add( s_run, i18n("Click this button to toggle show/hide <b>running</b> todos" ) ); 572 QWhatsThis::add( s_run, i18n("Click this button to toggle show/hide <b>running</b> todos" ) );
568 QWhatsThis::add( mNewSubBut, i18n("Click this button to add a new subtodo to the currently selected todo" ) ); 573 QWhatsThis::add( mNewSubBut, i18n("Click this button to add a new subtodo to the currently selected todo" ) );
569 QWhatsThis::add( s_done, i18n("Click this button to toggle show/hide <b>completed</b> todos" ) ); 574 QWhatsThis::add( s_done, i18n("Click this button to toggle show/hide <b>completed</b> todos" ) );
570 575
571 quickLayout->addWidget( mNewSubBut ); 576 quickLayout->addWidget( mNewSubBut );
572 quickLayout->addWidget( s_done ); 577 quickLayout->addWidget( s_done );
573 quickLayout->addWidget( s_run ); 578 quickLayout->addWidget( s_run );
574 quickLayout->addWidget( allopen ); 579 quickLayout->addWidget( allopen );
575 quickLayout->addWidget( allclose ); 580 quickLayout->addWidget( allclose );
576 quickLayout->addWidget( flat ); 581 quickLayout->addWidget( flat );
577 582
578 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); 583 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide();
579 584
580 mTodoListView = new KOTodoListView(calendar,this, name ); 585 mTodoListView = new KOTodoListView(calendar,this, name );
581 topLayout->addWidget(mTodoListView); 586 topLayout->addWidget(mTodoListView);
582 //mTodoListView->header()->setMaximumHeight(30); 587 //mTodoListView->header()->setMaximumHeight(30);
583 mTodoListView->setRootIsDecorated(true); 588 mTodoListView->setRootIsDecorated(true);
584 mTodoListView->setAllColumnsShowFocus(true); 589 mTodoListView->setAllColumnsShowFocus(true);
585 590
586 mTodoListView->setShowSortIndicator(true); 591 mTodoListView->setShowSortIndicator(true);
587 592
588 mTodoListView->addColumn(i18n("Todo")); 593 mTodoListView->addColumn(i18n("Todo"));
589 mTodoListView->addColumn(i18n("Prio")); 594 mTodoListView->addColumn(i18n("Prio"));
590 mTodoListView->setColumnAlignment(1,AlignHCenter); 595 mTodoListView->setColumnAlignment(1,AlignHCenter);
591 mTodoListView->addColumn(i18n("Complete")); 596 mTodoListView->addColumn(i18n("Complete"));
592 mTodoListView->setColumnAlignment(2,AlignCenter); 597 mTodoListView->setColumnAlignment(2,AlignCenter);
593 598
594 mTodoListView->addColumn(i18n("Due Date")); 599 mTodoListView->addColumn(i18n("Due Date"));
595 mTodoListView->setColumnAlignment(3,AlignLeft); 600 mTodoListView->setColumnAlignment(3,AlignLeft);
596 mTodoListView->addColumn(i18n("Due Time")); 601 mTodoListView->addColumn(i18n("Due Time"));
597 mTodoListView->setColumnAlignment(4,AlignHCenter); 602 mTodoListView->setColumnAlignment(4,AlignHCenter);
598 603
599 mTodoListView->addColumn(i18n("Start Date")); 604 mTodoListView->addColumn(i18n("Start Date"));
600 mTodoListView->setColumnAlignment(5,AlignLeft); 605 mTodoListView->setColumnAlignment(5,AlignLeft);
601 mTodoListView->addColumn(i18n("Start Time")); 606 mTodoListView->addColumn(i18n("Start Time"));
602 mTodoListView->setColumnAlignment(6,AlignHCenter); 607 mTodoListView->setColumnAlignment(6,AlignHCenter);
603 608
604 //mTodoListView->addColumn(i18n("Cancelled")); 609 //mTodoListView->addColumn(i18n("Cancelled"));
605 mTodoListView->addColumn(i18n("Categories")); 610 mTodoListView->addColumn(i18n("Categories"));
606 mTodoListView->addColumn(i18n("Calendar")); 611 mTodoListView->addColumn(i18n("Calendar"));
607 mTodoListView->addColumn(i18n("Last Modified")); 612 mTodoListView->addColumn(i18n("Last Modified"));
608 mTodoListView->addColumn(i18n("Created")); 613 mTodoListView->addColumn(i18n("Created"));
609 mTodoListView->addColumn(i18n("Last Modified Sub")); 614 mTodoListView->addColumn(i18n("Last Modified Sub"));
610#if 0 615#if 0
611 mTodoListView->addColumn(i18n("Sort Id")); 616 mTodoListView->addColumn(i18n("Sort Id"));
612 mTodoListView->setColumnAlignment(4,AlignHCenter); 617 mTodoListView->setColumnAlignment(4,AlignHCenter);
613#endif 618#endif
614 619
615 mTodoListView->setMinimumHeight( 60 ); 620 mTodoListView->setMinimumHeight( 60 );
616 mTodoListView->setItemsRenameable( true ); 621 mTodoListView->setItemsRenameable( true );
617 mTodoListView->setRenameable( 0 ); 622 mTodoListView->setRenameable( 0 );
618 mTodoListView->setColumnWidth( 0, 120 ); 623 mTodoListView->setColumnWidth( 0, 120 );
619 int iii = 0; 624 int iii = 0;
620 for ( iii = 0; iii< 12 ; ++iii ) 625 for ( iii = 0; iii< 12 ; ++iii )
621 mTodoListView->setColumnWidthMode( iii, QListView::Manual ); 626 mTodoListView->setColumnWidthMode( iii, QListView::Manual );
622 627
623 628
624 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); 629 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this);
625 630
626 mPriorityPopupMenu = new QPopupMenu(this); 631 mPriorityPopupMenu = new QPopupMenu(this);
627 for (int i = 1; i <= 5; i++) { 632 for (int i = 1; i <= 5; i++) {
628 QString label = QString ("%1").arg (i); 633 QString label = QString ("%1").arg (i);
629 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 634 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
630 } 635 }
631 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 636 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
632 637
633 mPercentageCompletedPopupMenu = new QPopupMenu(this); 638 mPercentageCompletedPopupMenu = new QPopupMenu(this);
634 for (int i = 0; i <= 100; i+=20) { 639 for (int i = 0; i <= 100; i+=20) {
635 QString label = QString ("%1 %").arg (i); 640 QString label = QString ("%1 %").arg (i);
636 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 641 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
637 } 642 }
638 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 643 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
639 644
640 645
641 mCategoryPopupMenu = new QPopupMenu (this); 646 mCategoryPopupMenu = new QPopupMenu (this);
642 mCategoryPopupMenu->setCheckable (true); 647 mCategoryPopupMenu->setCheckable (true);
643 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 648 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
644 connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); 649 connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ()));
645 650
646 mCalPopupMenu = new QPopupMenu (this); 651 mCalPopupMenu = new QPopupMenu (this);
647 mCalPopupMenu->setCheckable (true); 652 mCalPopupMenu->setCheckable (true);
648 connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); 653 connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int)));
649 connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); 654 connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ()));
650 655
651 656
652 657
653 658
654 mItemPopupMenu = new QPopupMenu(this); 659 mItemPopupMenu = new QPopupMenu(this);
655 mItemPopupMenu->insertItem(i18n("Show"), this, 660 mItemPopupMenu->insertItem(i18n("Show"), this,
656 SLOT (showTodo())); 661 SLOT (showTodo()));
657 mItemPopupMenu->insertItem(i18n("Edit..."), this, 662 mItemPopupMenu->insertItem(i18n("Edit..."), this,
658 SLOT (editTodo())); 663 SLOT (editTodo()));
659 mItemPopupMenu->insertItem( i18n("Delete..."), this, 664 mItemPopupMenu->insertItem( i18n("Delete..."), this,
660 SLOT (deleteTodo())); 665 SLOT (deleteTodo()));
661 mItemPopupMenu->insertItem( i18n("Clone..."), this, 666 mItemPopupMenu->insertItem( i18n("Clone..."), this,
662 SLOT (cloneTodo())); 667 SLOT (cloneTodo()));
663 mItemPopupMenu->insertItem( i18n("Move..."), this, 668 mItemPopupMenu->insertItem( i18n("Move..."), this,
664 SLOT (moveTodo())); 669 SLOT (moveTodo()));
665#ifndef DESKTOP_VERSION 670#ifndef DESKTOP_VERSION
666 mItemPopupMenu->insertItem( i18n("Beam..."), this, 671 mItemPopupMenu->insertItem( i18n("Beam..."), this,
667 SLOT (beamTodo())); 672 SLOT (beamTodo()));
668#endif 673#endif
669 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 674 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
670 SLOT (cancelTodo())); 675 SLOT (cancelTodo()));
671 mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); 676 mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu);
672 mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); 677 mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu);
673 mItemPopupMenu->insertSeparator(); 678 mItemPopupMenu->insertSeparator();
674 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, 679 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
675 SLOT (toggleRunningItem())); 680 SLOT (toggleRunningItem()));
676 mItemPopupMenu->insertSeparator(); 681 mItemPopupMenu->insertSeparator();
677 /* 682 /*
678 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 683 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
679 SLOT (newTodo())); 684 SLOT (newTodo()));
680 */ 685 */
681 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 686 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
682 SLOT (newSubTodo())); 687 SLOT (newSubTodo()));
683 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 688 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
684 SLOT (unparentTodo()),0,21); 689 SLOT (unparentTodo()),0,21);
685 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 690 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
686 SLOT (reparentTodo()),0,22); 691 SLOT (reparentTodo()),0,22);
687 mItemPopupMenu->insertSeparator(); 692 mItemPopupMenu->insertSeparator();
688#if 0 693#if 0
689 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), 694 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."),
690 this, SLOT( purgeCompleted() ) ); 695 this, SLOT( purgeCompleted() ) );
691 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 696 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
692 this, SLOT( toggleCompleted() ),0, 33 ); 697 this, SLOT( toggleCompleted() ),0, 33 );
693 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 698 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
694 this, SLOT( toggleQuickTodo() ),0, 34 ); 699 this, SLOT( toggleQuickTodo() ),0, 34 );
695 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 700 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
696 this, SLOT( toggleRunning() ),0, 35 ); 701 this, SLOT( toggleRunning() ),0, 35 );
697 702
698#endif 703#endif
699 mPopupMenu = new QPopupMenu(this); 704 mPopupMenu = new QPopupMenu(this);
700 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 705 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
701 SLOT (newTodo()),0,1); 706 SLOT (newTodo()),0,1);
702 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), 707 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."),
703 this, SLOT(purgeCompleted()),0,2); 708 this, SLOT(purgeCompleted()),0,2);
704 mPopupMenu->insertItem(i18n("Show Completed"), 709 mPopupMenu->insertItem(i18n("Show Completed"),
705 this, SLOT( toggleCompleted() ),0,3 ); 710 this, SLOT( toggleCompleted() ),0,3 );
706 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 711 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
707 this, SLOT( toggleRunning() ),0,5 ); 712 this, SLOT( toggleRunning() ),0,5 );
708 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 713 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
709 this, SLOT( setAllOpen() ),0,6 ); 714 this, SLOT( setAllOpen() ),0,6 );
710 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 715 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
711 this, SLOT( setAllClose() ),0,7 ); 716 this, SLOT( setAllClose() ),0,7 );
712 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 717 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
713 this, SLOT( setAllFlat() ),0,8 ); 718 this, SLOT( setAllFlat() ),0,8 );
714 mPopupMenu->insertSeparator(); 719 mPopupMenu->insertSeparator();
715 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 720 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
716 this, SLOT( toggleQuickTodo() ),0,4 ); 721 this, SLOT( toggleQuickTodo() ),0,4 );
717 mDocPrefs = new DocPrefs( name ); 722 mDocPrefs = new DocPrefs( name );
718 723
719 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 724 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
720 mPopupMenu->setCheckable( true ); 725 mPopupMenu->setCheckable( true );
721 mItemPopupMenu->setCheckable( true ); 726 mItemPopupMenu->setCheckable( true );
722 727
723 728
724 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 729 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
725 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 730 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
726 731
727 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 732 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
728 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 733 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
729 734
730 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 735 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
731 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 736 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
732 737
733 738
734 // Double clicking conflicts with opening/closing the subtree 739 // Double clicking conflicts with opening/closing the subtree
735 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 740 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
736 SLOT( editItem( QListViewItem *) ) ); 741 SLOT( editItem( QListViewItem *) ) );
737 /* 742 /*
738 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 743 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
739 const QPoint &,int ) ), 744 const QPoint &,int ) ),
740 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 745 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
741 */ 746 */
742 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 747 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
743 const QPoint &,int ) ), 748 const QPoint &,int ) ),
744 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 749 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
745 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 750 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
746 SLOT( itemClicked( QListViewItem * ) ) ); 751 SLOT( itemClicked( QListViewItem * ) ) );
747 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 752 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
748 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 753 SLOT( itemDoubleClicked( QListViewItem * ) ) );
749 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 754 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
750 SLOT( updateView() ) ); 755 SLOT( updateView() ) );
751 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 756 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
752 SLOT( todoModified(Todo *, int) ) ); 757 SLOT( todoModified(Todo *, int) ) );
753 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 758 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
754 SLOT( itemStateChanged( QListViewItem * ) ) ); 759 SLOT( itemStateChanged( QListViewItem * ) ) );
755 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 760 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
756 SLOT( itemStateChanged( QListViewItem * ) ) ); 761 SLOT( itemStateChanged( QListViewItem * ) ) );
757 connect( mTodoListView, SIGNAL( paintNeeded() ), 762 connect( mTodoListView, SIGNAL( paintNeeded() ),
758 SLOT( paintNeeded()) ); 763 SLOT( paintNeeded()) );
759 764
760#if 0 765#if 0
761 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 766 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
762 SLOT(selectionChanged(QListViewItem *))); 767 SLOT(selectionChanged(QListViewItem *)));
763 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 768 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
764 SLOT(selectionChanged(QListViewItem *))); 769 SLOT(selectionChanged(QListViewItem *)));
765 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 770 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
766 SLOT(selectionChanged(QListViewItem *))); 771 SLOT(selectionChanged(QListViewItem *)));
767#endif 772#endif
768 773
769 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 774 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
770 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 775 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
771 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 776 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
772 777
773 connect( mTodoListView, SIGNAL(selectionChanged() ), 778 connect( mTodoListView, SIGNAL(selectionChanged() ),
774 SLOT( processSelectionChange() ) ); 779 SLOT( processSelectionChange() ) );
775 connect( mQuickAdd, SIGNAL( returnPressed () ), 780 connect( mQuickAdd, SIGNAL( returnPressed () ),
776 SLOT( addQuickTodo() ) ); 781 SLOT( addQuickTodo() ) );
777 782
778} 783}
779 784
780KOTodoView::~KOTodoView() 785KOTodoView::~KOTodoView()
781{ 786{
782 787
783#if QT_VERSION >= 0x030000 788#if QT_VERSION >= 0x030000
784 789
785#else 790#else
786 delete mKOTodoViewWhatsThis; 791 delete mKOTodoViewWhatsThis;
787#endif 792#endif
788 793
789 delete mDocPrefs; 794 delete mDocPrefs;
790} 795}
791QString KOTodoView::getWhatsThisText(QPoint p) 796QString KOTodoView::getWhatsThisText(QPoint p)
792{ 797{
793 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 798 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
794 if ( item ) 799 if ( item )
795 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 800 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
796 KOPrefs::instance()->mWTshowDetails, 801 KOPrefs::instance()->mWTshowDetails,
797 KOPrefs::instance()->mWTshowCreated, 802 KOPrefs::instance()->mWTshowCreated,
798 KOPrefs::instance()->mWTshowChanged); 803 KOPrefs::instance()->mWTshowChanged);
799 return i18n("That is the todo view" ); 804 return i18n("That is the todo view" );
800 805
801} 806}
802 807
803void KOTodoView::jumpToDate () 808void KOTodoView::jumpToDate ()
804{ 809{
805 // if (mActiveItem) { 810 // if (mActiveItem) {
806// mActiveItem->todo()); 811// mActiveItem->todo());
807// if ( mActiveItem->todo()->hasDueDate() ) 812// if ( mActiveItem->todo()->hasDueDate() )
808// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 813// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
809} 814}
810void KOTodoView::paintNeeded() 815void KOTodoView::paintNeeded()
811{ 816{
812 if ( mPendingUpdateBeforeRepaint ) { 817 if ( mPendingUpdateBeforeRepaint ) {
813 updateView(); 818 updateView();
814 mPendingUpdateBeforeRepaint = false; 819 mPendingUpdateBeforeRepaint = false;
815 } 820 }
816} 821}
817void KOTodoView::paintEvent(QPaintEvent * pevent) 822void KOTodoView::paintEvent(QPaintEvent * pevent)
818{ 823{
819 if ( mPendingUpdateBeforeRepaint ) { 824 if ( mPendingUpdateBeforeRepaint ) {
820 updateView(); 825 updateView();
821 mPendingUpdateBeforeRepaint = false; 826 mPendingUpdateBeforeRepaint = false;
822 } 827 }
823 KOrg::BaseView::paintEvent( pevent); 828 KOrg::BaseView::paintEvent( pevent);
824} 829}
825 830
826void KOTodoView::clearList( bool saveCurrentItem ) // default true 831void KOTodoView::clearList( bool saveCurrentItem ) // default true
827{ 832{
828 if ( mTodoListView->childCount() ) { 833 if ( mTodoListView->childCount() ) {
829 if ( saveCurrentItem ) 834 if ( saveCurrentItem )
830 storeCurrentItem(); 835 storeCurrentItem();
831 mTodoListView->clear(); 836 mTodoListView->clear();
832 mTodoMap.clear(); 837 mTodoMap.clear();
833 } 838 }
834} 839}
835void KOTodoView::updateView() 840void KOTodoView::updateView()
836{ 841{
837 mActiveItem = 0; 842 mActiveItem = 0;
838 pendingSubtodo = 0; 843 pendingSubtodo = 0;
839 if ( mBlockUpdate ) { 844 if ( mBlockUpdate ) {
840 return; 845 return;
841 } 846 }
842 if ( !isVisible() ) { 847 if ( !isVisible() ) {
843 clearList (); 848 clearList ();
844 mPendingUpdateBeforeRepaint = true; 849 mPendingUpdateBeforeRepaint = true;
845 return; 850 return;
846 } 851 }
847 //qDebug("KOTodoView::updateView() %x", this); 852 //qDebug("KOTodoView::updateView() %x", this);
848 if ( isFlatDisplay ) { 853 if ( isFlatDisplay ) {
849 displayAllFlat(); 854 displayAllFlat();
850 return; 855 return;
851 } 856 }
852 //qDebug("update "); 857 //qDebug("update ");
853// kdDebug() << "KOTodoView::updateView()" << endl; 858// kdDebug() << "KOTodoView::updateView()" << endl;
854 QFont fo = KOPrefs::instance()->mTodoViewFont; 859 QFont fo = KOPrefs::instance()->mTodoViewFont;
855 860
856 clearList (); 861 clearList ();
857 862
858 if ( mName == "todolistsmall" ) { 863 if ( mName == "todolistsmall" ) {
859 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 864 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
860 int ps = fo.pointSize() -2; 865 int ps = fo.pointSize() -2;
861 if ( ps > 12 ) 866 if ( ps > 12 )
862 ps -= 2; 867 ps -= 2;
863 fo.setPointSize( ps ); 868 fo.setPointSize( ps );
864 } 869 }
865 } 870 }
866 871
867 mTodoListView->setFont( fo ); 872 mTodoListView->setFont( fo );
868 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 873 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
869 //mTodoListView->header()->setMaximumHeight(fm.height()); 874 //mTodoListView->header()->setMaximumHeight(fm.height());
870 QPtrList<Todo> todoList = calendar()->todos(); 875 QPtrList<Todo> todoList = calendar()->todos();
871 876
872/* 877/*
873 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 878 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
874 Event *t; 879 Event *t;
875 for(t = todoList.first(); t; t = todoList.next()) { 880 for(t = todoList.first(); t; t = todoList.next()) {
876 kdDebug() << " " << t->getSummary() << endl; 881 kdDebug() << " " << t->getSummary() << endl;
877 882
878 if (t->getRelatedTo()) { 883 if (t->getRelatedTo()) {
879 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 884 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
880 } 885 }
881 886
882 QPtrList<Event> l = t->getRelations(); 887 QPtrList<Event> l = t->getRelations();
883 Event *c; 888 Event *c;
884 for(c=l.first();c;c=l.next()) { 889 for(c=l.first();c;c=l.next()) {
885 kdDebug() << " - relation: " << c->getSummary() << endl; 890 kdDebug() << " - relation: " << c->getSummary() << endl;
886 } 891 }
887 } 892 }
888*/ 893*/
889 894
890 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 895 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
891 // specific order of events. That means that we have to generate parent items 896 // specific order of events. That means that we have to generate parent items
892 // recursively for proper hierarchical display of Todos. 897 // recursively for proper hierarchical display of Todos.
893 Todo *todo; 898 Todo *todo;
894 todo = todoList.first();// todo; todo = todoList.next()) { 899 todo = todoList.first();// todo; todo = todoList.next()) {
895 while ( todo ) { 900 while ( todo ) {
896 bool next = true; 901 bool next = true;
897 // qDebug("todo %s ", todo->summary().latin1()); 902 // qDebug("todo %s ", todo->summary().latin1());
898 Incidence *incidence = todo->relatedTo(); 903 Incidence *incidence = todo->relatedTo();
899 while ( incidence ) { 904 while ( incidence ) {
900 if ( incidence->typeID() == todoID ) { 905 if ( incidence->typeID() == todoID ) {
901 //qDebug("related %s ",incidence->summary().latin1() ); 906 //qDebug("related %s ",incidence->summary().latin1() );
902 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { 907 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) {
903 //qDebug("related not found "); 908 //qDebug("related not found ");
904 todoList.remove( ); 909 todoList.remove( );
905 todo = todoList.current(); 910 todo = todoList.current();
906 next = false; 911 next = false;
907 incidence = 0; 912 incidence = 0;
908 913
909 } else { 914 } else {
910 //qDebug("related found "); 915 //qDebug("related found ");
911 incidence = incidence->relatedTo(); 916 incidence = incidence->relatedTo();
912 } 917 }
913 } else 918 } else
914 incidence = 0; 919 incidence = 0;
915 } 920 }
916 if ( next ) 921 if ( next )
917 todo = todoList.next(); 922 todo = todoList.next();
918 } 923 }
919 924
920 for(todo = todoList.first(); todo; todo = todoList.next()) { 925 for(todo = todoList.first(); todo; todo = todoList.next()) {
921 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 926 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
922 { 927 {
923 insertTodoItem(todo); 928 insertTodoItem(todo);
924 } 929 }
925 } 930 }
926 // Restore opened/closed state 931 // Restore opened/closed state
927 mTodoListView->blockSignals( true ); 932 mTodoListView->blockSignals( true );
928 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 933 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
929 mTodoListView->blockSignals( false ); 934 mTodoListView->blockSignals( false );
930 resetCurrentItem(); 935 resetCurrentItem();
931} 936}
932 937
933void KOTodoView::storeCurrentItem() 938void KOTodoView::storeCurrentItem()
934{ 939{
935 mCurItem = 0; 940 mCurItem = 0;
936 mCurItemRootParent = 0; 941 mCurItemRootParent = 0;
937 mCurItemParent = 0; 942 mCurItemParent = 0;
938 mCurItemAbove = 0; 943 mCurItemAbove = 0;
939 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 944 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
940 if (mActiveItem) { 945 if (mActiveItem) {
941 mCurItem = mActiveItem->todo(); 946 mCurItem = mActiveItem->todo();
942 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 947 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
943 if ( activeItemAbove ) 948 if ( activeItemAbove )
944 mCurItemAbove = activeItemAbove->todo(); 949 mCurItemAbove = activeItemAbove->todo();
945 mCurItemRootParent = mCurItem; 950 mCurItemRootParent = mCurItem;
946 mCurItemParent = mCurItemRootParent->relatedTo(); 951 mCurItemParent = mCurItemRootParent->relatedTo();
947 while ( mCurItemRootParent->relatedTo() != 0 ) 952 while ( mCurItemRootParent->relatedTo() != 0 )
948 mCurItemRootParent = mCurItemRootParent->relatedTo(); 953 mCurItemRootParent = mCurItemRootParent->relatedTo();
949 } 954 }
950 mActiveItem = 0; 955 mActiveItem = 0;
951} 956}
952 957
953void KOTodoView::resetCurrentItem() 958void KOTodoView::resetCurrentItem()
954{ 959{
955 //mTodoListView->setFocus(); 960 //mTodoListView->setFocus();
956 KOTodoViewItem* foundItem = 0; 961 KOTodoViewItem* foundItem = 0;
957 KOTodoViewItem* foundItemRoot = 0; 962 KOTodoViewItem* foundItemRoot = 0;
958 KOTodoViewItem* foundItemParent = 0; 963 KOTodoViewItem* foundItemParent = 0;
959 KOTodoViewItem* foundItemAbove = 0; 964 KOTodoViewItem* foundItemAbove = 0;
960 if ( mTodoListView->firstChild () ) { 965 if ( mTodoListView->firstChild () ) {
961 if ( mCurItem ) { 966 if ( mCurItem ) {
962 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); 967 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
963 while ( item ) { 968 while ( item ) {
964 if ( item->todo() == mCurItem ) { 969 if ( item->todo() == mCurItem ) {
965 foundItem = item; 970 foundItem = item;
966 break; 971 break;
967 } else if ( item->todo() == mCurItemAbove ) { 972 } else if ( item->todo() == mCurItemAbove ) {
968 foundItemAbove = item; 973 foundItemAbove = item;
969 974
970 } 975 }
971 if ( item->todo() == mCurItemRootParent ) { 976 if ( item->todo() == mCurItemRootParent ) {
972 foundItemRoot = item; 977 foundItemRoot = item;
973 } 978 }
974 if ( item->todo() == mCurItemParent ) { 979 if ( item->todo() == mCurItemParent ) {
975 foundItemParent = item; 980 foundItemParent = item;
976 } 981 }
977 item = (KOTodoViewItem*)item->itemBelow(); 982 item = (KOTodoViewItem*)item->itemBelow();
978 } 983 }
979 if ( ! foundItem ) { 984 if ( ! foundItem ) {
980 if ( foundItemParent ) { 985 if ( foundItemParent ) {
981 foundItem = foundItemParent; 986 foundItem = foundItemParent;
982 } else { 987 } else {
983 if ( foundItemRoot ) 988 if ( foundItemRoot )
984 foundItem = foundItemRoot; 989 foundItem = foundItemRoot;
985 else 990 else
986 foundItem = foundItemAbove; 991 foundItem = foundItemAbove;
987 } 992 }
988 } 993 }
989 } 994 }
990 if ( foundItem ) { 995 if ( foundItem ) {
991 mTodoListView->setSelected ( foundItem, true ); 996 mTodoListView->setSelected ( foundItem, true );
992 mTodoListView->setCurrentItem( foundItem ); 997 mTodoListView->setCurrentItem( foundItem );
993 mTodoListView->ensureItemVisible( foundItem ); 998 mTodoListView->ensureItemVisible( foundItem );
994 } else { 999 } else {
995 if ( mTodoListView->firstChild () ) { 1000 if ( mTodoListView->firstChild () ) {
996 mTodoListView->setSelected ( mTodoListView->firstChild (), true ); 1001 mTodoListView->setSelected ( mTodoListView->firstChild (), true );
997 mTodoListView->setCurrentItem( mTodoListView->firstChild () ); 1002 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
998 } 1003 }
999 } 1004 }
1000 } 1005 }
1001 processSelectionChange(); 1006 processSelectionChange();
1002 if ( mName != "todolistsmall" ) 1007 if ( mName != "todolistsmall" )
1003 QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); 1008 QTimer::singleShot( 100, this, SLOT ( resetFocusToList() ));
1004} 1009}
1005void KOTodoView::resetFocusToList() 1010void KOTodoView::resetFocusToList()
1006{ 1011{
1007 topLevelWidget()->setActiveWindow(); 1012 topLevelWidget()->setActiveWindow();
1008 mTodoListView->setFocus(); 1013 mTodoListView->setFocus();
1009} 1014}
1010//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 1015//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
1011bool KOTodoView::checkTodo( Todo * todo ) 1016bool KOTodoView::checkTodo( Todo * todo )
1012{ 1017{
1013 1018
1014 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 1019 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
1015 return false; 1020 return false;
1016 if ( !todo->isCompleted() ) { 1021 if ( !todo->isCompleted() ) {
1017 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 1022 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
1018 return true; 1023 return true;
1019 } 1024 }
1020 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 1025 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
1021 if ( todo->hasStartDate() ) 1026 if ( todo->hasStartDate() )
1022 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 1027 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
1023 return false; 1028 return false;
1024 if ( todo->hasDueDate() ) 1029 if ( todo->hasDueDate() )
1025 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 1030 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
1026 return false; 1031 return false;
1027 } 1032 }
1028 return true; 1033 return true;
1029} 1034}
1030 1035
1031void KOTodoView::restoreItemState( QListViewItem *item ) 1036void KOTodoView::restoreItemState( QListViewItem *item )
1032{ 1037{
1033 pendingSubtodo = 0; 1038 pendingSubtodo = 0;
1034 while( item ) { 1039 while( item ) {
1035 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1040 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1036 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 1041 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
1037 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 1042 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
1038 item = item->nextSibling(); 1043 item = item->nextSibling();
1039 } 1044 }
1040} 1045}
1041 1046
1042 1047
1043QMap<Todo *,KOTodoViewItem *>::ConstIterator 1048QMap<Todo *,KOTodoViewItem *>::ConstIterator
1044KOTodoView::insertTodoItem(Todo *todo) 1049KOTodoView::insertTodoItem(Todo *todo)
1045{ 1050{
1046 1051
1047 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 1052 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
1048 // TODO: Check, if dynmaic cast is necessary 1053 // TODO: Check, if dynmaic cast is necessary
1049 1054
1050 pendingSubtodo = 0; 1055 pendingSubtodo = 0;
1051 Incidence *incidence = todo->relatedTo(); 1056 Incidence *incidence = todo->relatedTo();
1052 while ( incidence && !incidence->calEnabled() ) 1057 while ( incidence && !incidence->calEnabled() )
1053 incidence = incidence->relatedTo(); 1058 incidence = incidence->relatedTo();
1054 if (incidence && incidence->typeID() == todoID ) { 1059 if (incidence && incidence->typeID() == todoID ) {
1055 Todo *relatedTodo = static_cast<Todo *>(incidence); 1060 Todo *relatedTodo = static_cast<Todo *>(incidence);
1056 1061
1057 // kdDebug() << " has Related" << endl; 1062 // kdDebug() << " has Related" << endl;
1058 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1063 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1059 itemIterator = mTodoMap.find(relatedTodo); 1064 itemIterator = mTodoMap.find(relatedTodo);
1060 if (itemIterator == mTodoMap.end()) { 1065 if (itemIterator == mTodoMap.end()) {
1061 // kdDebug() << " related not yet in list" << endl; 1066 // kdDebug() << " related not yet in list" << endl;
1062 itemIterator = insertTodoItem (relatedTodo); 1067 itemIterator = insertTodoItem (relatedTodo);
1063 } 1068 }
1064 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 1069 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
1065 // and one into the map. Sure finding is more easy but why? -zecke 1070 // and one into the map. Sure finding is more easy but why? -zecke
1066 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 1071 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
1067 return mTodoMap.insert(todo,todoItem); 1072 return mTodoMap.insert(todo,todoItem);
1068 } else { 1073 } else {
1069 // kdDebug() << " no Related" << endl; 1074 // kdDebug() << " no Related" << endl;
1070 // see above -zecke 1075 // see above -zecke
1071 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1076 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1072 return mTodoMap.insert(todo,todoItem); 1077 return mTodoMap.insert(todo,todoItem);
1073 } 1078 }
1074} 1079}
1075 1080
1076 1081
1077void KOTodoView::updateConfig() 1082void KOTodoView::updateConfig()
1078{ 1083{
1079 updateView(); 1084 updateView();
1080 mTodoListView->repaintContents(); 1085 mTodoListView->repaintContents();
1081} 1086}
1082 1087
1083QPtrList<Incidence> KOTodoView::selectedIncidences() 1088QPtrList<Incidence> KOTodoView::selectedIncidences()
1084{ 1089{
1085 QPtrList<Incidence> selected; 1090 QPtrList<Incidence> selected;
1086 1091
1087 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 1092 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
1088// if (!item) item = mActiveItem; 1093// if (!item) item = mActiveItem;
1089 if (item) selected.append(item->todo()); 1094 if (item) selected.append(item->todo());
1090 1095
1091 return selected; 1096 return selected;
1092} 1097}
1093 1098
1094QPtrList<Todo> KOTodoView::selectedTodos() 1099QPtrList<Todo> KOTodoView::selectedTodos()
1095{ 1100{
1096 QPtrList<Todo> selected; 1101 QPtrList<Todo> selected;
1097 1102
1098 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 1103 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
1099// if (!item) item = mActiveItem; 1104// if (!item) item = mActiveItem;
1100 if (item) selected.append(item->todo()); 1105 if (item) selected.append(item->todo());
1101 1106
1102 return selected; 1107 return selected;
1103} 1108}
1104 1109
1105void KOTodoView::changeEventDisplay(Event *, int) 1110void KOTodoView::changeEventDisplay(Event *, int)
1106{ 1111{
1107 updateView(); 1112 updateView();
1108} 1113}
1109 1114
1110void KOTodoView::showDates(const QDate &, const QDate &) 1115void KOTodoView::showDates(const QDate &, const QDate &)
1111{ 1116{
1112} 1117}
1113 1118
1114void KOTodoView::showEvents(QPtrList<Event>) 1119void KOTodoView::showEvents(QPtrList<Event>)
1115{ 1120{
1116 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 1121 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
1117} 1122}
1118 1123
1119void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1124void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1120 const QDate &td) 1125 const QDate &td)
1121{ 1126{
1122#ifndef KORG_NOPRINTER 1127#ifndef KORG_NOPRINTER
1123 calPrinter->preview(CalPrinter::Todolist, fd, td); 1128 calPrinter->preview(CalPrinter::Todolist, fd, td);
1124#endif 1129#endif
1125} 1130}
1126 1131
1127void KOTodoView::editItem(QListViewItem *item ) 1132void KOTodoView::editItem(QListViewItem *item )
1128{ 1133{
1129 if ( item ) 1134 if ( item )
1130 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 1135 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
1131} 1136}
1132 1137
1133void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 1138void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
1134{ 1139{
1135 if ( item ) 1140 if ( item )
1136 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 1141 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
1137} 1142}
1138 1143
1139void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 1144void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
1140{ 1145{
1141 pendingSubtodo = 0; 1146 pendingSubtodo = 0;
1142 mActiveItem = (KOTodoViewItem *)item; 1147 mActiveItem = (KOTodoViewItem *)item;
1143 if (item) { 1148 if (item) {
1144 switch (column){ 1149 switch (column){
1145 case 1: 1150 case 1:
1146 mPriorityPopupMenu->popup(QCursor::pos ()); break; 1151 mPriorityPopupMenu->popup(QCursor::pos ()); break;
1147 case 2: 1152 case 2:
1148 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 1153 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
1149 case 3: 1154 case 3:
1150 moveTodo(); 1155 moveTodo();
1151 break; 1156 break;
1152 case 7: 1157 case 7:
1153 mCategoryPopupMenu->popup(QCursor::pos ()); break; 1158 mCategoryPopupMenu->popup(QCursor::pos ()); break;
1154 case 8: 1159 case 8:
1155 mCalPopupMenu->popup(QCursor::pos ()); break; 1160 mCalPopupMenu->popup(QCursor::pos ()); break;
1156 default: 1161 default:
1157 mItemPopupMenu->popup(QCursor::pos()); 1162 mItemPopupMenu->popup(QCursor::pos());
1158 } 1163 }
1159 } else mPopupMenu->popup(QCursor::pos()); 1164 } else mPopupMenu->popup(QCursor::pos());
1160} 1165}
1161void KOTodoView::newTodo() 1166void KOTodoView::newTodo()
1162{ 1167{
1163 emit newTodoSignal(); 1168 emit newTodoSignal();
1164} 1169}
1165 1170
1166void KOTodoView::newSubTodo() 1171void KOTodoView::newSubTodo()
1167{ 1172{
1168 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1173 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1169 if (mActiveItem) { 1174 if (mActiveItem) {
1170 if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) { 1175 if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) {
1171 addQuickTodoPar( mActiveItem->todo()); 1176 addQuickTodoPar( mActiveItem->todo());
1172 } else 1177 } else
1173 emit newSubTodoSignal(mActiveItem->todo()); 1178 emit newSubTodoSignal(mActiveItem->todo());
1174 } 1179 }
1175} 1180}
1176void KOTodoView::unparentTodo() 1181void KOTodoView::unparentTodo()
1177{ 1182{
1178 if (mActiveItem) { 1183 if (mActiveItem) {
1179 emit unparentTodoSignal(mActiveItem->todo()); 1184 emit unparentTodoSignal(mActiveItem->todo());
1180 } 1185 }
1181} 1186}
1182 1187
1183void KOTodoView::reparentTodo() 1188void KOTodoView::reparentTodo()
1184{ 1189{
1185 if (mActiveItem) { 1190 if (mActiveItem) {
1186 topLevelWidget()->setCaption(i18n("Click on new parent item")); 1191 topLevelWidget()->setCaption(i18n("Click on new parent item"));
1187 pendingSubtodo = mActiveItem; 1192 pendingSubtodo = mActiveItem;
1188 } 1193 }
1189} 1194}
1190void KOTodoView::editTodo() 1195void KOTodoView::editTodo()
1191{ 1196{
1192 if (mActiveItem) { 1197 if (mActiveItem) {
1193 emit editTodoSignal(mActiveItem->todo()); 1198 emit editTodoSignal(mActiveItem->todo());
1194 } 1199 }
1195} 1200}
1196void KOTodoView::cloneTodo() 1201void KOTodoView::cloneTodo()
1197{ 1202{
1198 if (mActiveItem) { 1203 if (mActiveItem) {
1199 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 1204 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
1200 } 1205 }
1201} 1206}
1202void KOTodoView::cancelTodo() 1207void KOTodoView::cancelTodo()
1203{ 1208{
1204 if (mActiveItem) { 1209 if (mActiveItem) {
1205 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 1210 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
1206 } 1211 }
1207} 1212}
1208void KOTodoView::moveTodo() 1213void KOTodoView::moveTodo()
1209{ 1214{
1210 if (mActiveItem) { 1215 if (mActiveItem) {
1211 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 1216 emit moveTodoSignal((Incidence*)mActiveItem->todo());
1212 } 1217 }
1213} 1218}
1214void KOTodoView::beamTodo() 1219void KOTodoView::beamTodo()
1215{ 1220{
1216 if (mActiveItem) { 1221 if (mActiveItem) {
1217 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 1222 emit beamTodoSignal((Incidence*)mActiveItem->todo());
1218 } 1223 }
1219} 1224}
1220 1225
1221 1226
1222void KOTodoView::showTodo() 1227void KOTodoView::showTodo()
1223{ 1228{
1224 if (mActiveItem) { 1229 if (mActiveItem) {
1225 emit showTodoSignal(mActiveItem->todo()); 1230 emit showTodoSignal(mActiveItem->todo());
1226 } 1231 }
1227} 1232}
1228 1233
1229void KOTodoView::deleteTodo() 1234void KOTodoView::deleteTodo()
1230{ 1235{
1231 if (mActiveItem) { 1236 if (mActiveItem) {
1232 emit deleteTodoSignal(mActiveItem->todo()); 1237 emit deleteTodoSignal(mActiveItem->todo());
1233 } 1238 }
1234} 1239}
1235 1240
1236void KOTodoView::setNewPriority(int index) 1241void KOTodoView::setNewPriority(int index)
1237{ 1242{
1238 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1243 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1239 mActiveItem->todo()->setPriority(mPriority[index]); 1244 mActiveItem->todo()->setPriority(mPriority[index]);
1240 mActiveItem->construct(); 1245 mActiveItem->construct();
1241 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1246 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
1242 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1247 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1243 } 1248 }
1244 processSelectionChange(); 1249 processSelectionChange();
1245} 1250}
1246 1251
1247void KOTodoView::setNewPercentage(int index) 1252void KOTodoView::setNewPercentage(int index)
1248{ 1253{
1249 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1254 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1250 1255
1251 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1256 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
1252 mActiveItem->setOn( true ); 1257 mActiveItem->setOn( true );
1253 processSelectionChange(); 1258 processSelectionChange();
1254 return; 1259 return;
1255 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1260 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1256 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1261 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1257 if ( par && par->isOn() ) 1262 if ( par && par->isOn() )
1258 par->setOn( false ); 1263 par->setOn( false );
1259 } 1264 }
1260 if (mPercentage[index] == 100) { 1265 if (mPercentage[index] == 100) {
1261 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1266 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1262 } else { 1267 } else {
1263 mActiveItem->todo()->setCompleted(false); 1268 mActiveItem->todo()->setCompleted(false);
1264 } 1269 }
1265 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1270 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1266 mActiveItem->construct(); 1271 mActiveItem->construct();
1267 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1272 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1268 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1273 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1269 } 1274 }
1270 processSelectionChange(); 1275 processSelectionChange();
1271} 1276}
1272 1277
1273void KOTodoView::fillCategories () 1278void KOTodoView::fillCategories ()
1274{ 1279{
1275 mCategoryPopupMenu->clear(); 1280 mCategoryPopupMenu->clear();
1276 if ( ! mActiveItem ) return; 1281 if ( ! mActiveItem ) return;
1277 QStringList checkedCategories = mActiveItem->todo()->categories (); 1282 QStringList checkedCategories = mActiveItem->todo()->categories ();
1278 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1283 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1279 it != KOPrefs::instance()->mCustomCategories.end (); 1284 it != KOPrefs::instance()->mCustomCategories.end ();
1280 ++it) { 1285 ++it) {
1281 int index = mCategoryPopupMenu->insertItem (*it); 1286 int index = mCategoryPopupMenu->insertItem (*it);
1282 mCategory[index] = *it; 1287 mCategory[index] = *it;
1283 if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); 1288 if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true);
1284 } 1289 }
1285} 1290}
1286void KOTodoView::fillCal () 1291void KOTodoView::fillCal ()
1287{ 1292{
1288 mCalPopupMenu->clear(); 1293 mCalPopupMenu->clear();
1289 if (!mActiveItem) return; 1294 if (!mActiveItem) return;
1290 bool readO = mActiveItem->todo()->isReadOnly(); 1295 bool readO = mActiveItem->todo()->isReadOnly();
1291 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 1296 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
1292 while ( kkf ) { 1297 while ( kkf ) {
1293 int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); 1298 int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber);
1294 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) 1299 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO )
1295 mCalPopupMenu->setItemEnabled( index, false ); 1300 mCalPopupMenu->setItemEnabled( index, false );
1296 mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); 1301 mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID());
1297 kkf = KOPrefs::instance()->mCalendars.next(); 1302 kkf = KOPrefs::instance()->mCalendars.next();
1298 } 1303 }
1299} 1304}
1300void KOTodoView::changedCal (int index ) 1305void KOTodoView::changedCal (int index )
1301{ 1306{
1302 if (!mActiveItem) return; 1307 if (!mActiveItem) return;
1303 mActiveItem->todo()->setCalID( index ); 1308 mActiveItem->todo()->setCalID( index );
1304 mActiveItem->construct(); 1309 mActiveItem->construct();
1305} 1310}
1306void KOTodoView::changedCategories(int index) 1311void KOTodoView::changedCategories(int index)
1307{ 1312{
1308 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1313 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1309 QStringList categories = mActiveItem->todo()->categories (); 1314 QStringList categories = mActiveItem->todo()->categories ();
1310 QString colcat = categories.first(); 1315 QString colcat = categories.first();
1311 if (categories.find (mCategory[index]) != categories.end ()) 1316 if (categories.find (mCategory[index]) != categories.end ())
1312 categories.remove (mCategory[index]); 1317 categories.remove (mCategory[index]);
1313 else 1318 else
1314 categories.insert (categories.end(), mCategory[index]); 1319 categories.insert (categories.end(), mCategory[index]);
1315 categories.sort (); 1320 categories.sort ();
1316 if ( !colcat.isEmpty() ) { 1321 if ( !colcat.isEmpty() ) {
1317 if ( categories.find ( colcat ) != categories.end () ) { 1322 if ( categories.find ( colcat ) != categories.end () ) {
1318 categories.remove( colcat ); 1323 categories.remove( colcat );
1319 categories.prepend( colcat ); 1324 categories.prepend( colcat );
1320 } 1325 }
1321 } 1326 }
1322 mActiveItem->todo()->setCategories (categories); 1327 mActiveItem->todo()->setCategories (categories);
1323 mActiveItem->construct(); 1328 mActiveItem->construct();
1324 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1329 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1325 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1330 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1326 } 1331 }
1327} 1332}
1328void KOTodoView::itemDoubleClicked(QListViewItem *item) 1333void KOTodoView::itemDoubleClicked(QListViewItem *item)
1329{ 1334{
1330 if ( pendingSubtodo != 0 ) { 1335 if ( pendingSubtodo != 0 ) {
1331 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1336 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1332 } 1337 }
1333 pendingSubtodo = 0; 1338 pendingSubtodo = 0;
1334 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1339 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1335 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); 1340 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
1336 //qDebug("ROW %d ", row); 1341 //qDebug("ROW %d ", row);
1337 if (!item) { 1342 if (!item) {
1338 newTodo(); 1343 newTodo();
1339 return; 1344 return;
1340 } else { 1345 } else {
1341 if ( row == 1 ) { 1346 if ( row == 1 ) {
1342 mActiveItem = (KOTodoViewItem *) item; 1347 mActiveItem = (KOTodoViewItem *) item;
1343 newSubTodo(); 1348 newSubTodo();
1344 return; 1349 return;
1345 } 1350 }
1346 if ( row == 5 || row == 6 || row == 2) { 1351 if ( row == 5 || row == 6 || row == 2) {
1347 mActiveItem = (KOTodoViewItem *) item; 1352 mActiveItem = (KOTodoViewItem *) item;
1348 Todo * t = mActiveItem->todo(); 1353 Todo * t = mActiveItem->todo();
1349 if ( t->isRunning() ) { 1354 if ( t->isRunning() ) {
1350 if ( t->runTime() < 15) { 1355 if ( t->runTime() < 15) {
1351 t->stopRunning(); 1356 t->stopRunning();
1352 mActiveItem->construct(); 1357 mActiveItem->construct();
1353 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); 1358 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!"));
1354 return; 1359 return;
1355 } 1360 }
1356 else 1361 else
1357 toggleRunningItem(); 1362 toggleRunningItem();
1358 return; 1363 return;
1359 } else { 1364 } else {
1360 t->setRunning( true ); 1365 t->setRunning( true );
1361 mActiveItem->construct(); 1366 mActiveItem->construct();
1362 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); 1367 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!"));
1363 return; 1368 return;
1364 } 1369 }
1365 } 1370 }
1366 } 1371 }
1367 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1372 if ( KOPrefs::instance()->mEditOnDoubleClick )
1368 editItem( item ); 1373 editItem( item );
1369 else 1374 else
1370 showItem( item , QPoint(), 0 ); 1375 showItem( item , QPoint(), 0 );
1371} 1376}
1372void KOTodoView::toggleRunningItem() 1377void KOTodoView::toggleRunningItem()
1373{ 1378{
1374 // qDebug("KOTodoView::toggleRunning() "); 1379 // qDebug("KOTodoView::toggleRunning() ");
1375 if ( ! mActiveItem ) 1380 if ( ! mActiveItem )
1376 return; 1381 return;
1377 Todo * t = mActiveItem->todo(); 1382 Todo * t = mActiveItem->todo();
1378 if ( t->isRunning() ) { 1383 if ( t->isRunning() ) {
1379 KOStopTodoPrefs tp ( t, this ); 1384 KOStopTodoPrefs tp ( t, this );
1380 if (QApplication::desktop()->width() <= 800 ){ 1385 if (QApplication::desktop()->width() <= 800 ){
1381 int wid = tp.width(); 1386 int wid = tp.width();
1382 int hei = tp.height(); 1387 int hei = tp.height();
1383 int xx = (QApplication::desktop()->width()-wid)/2; 1388 int xx = (QApplication::desktop()->width()-wid)/2;
1384 int yy = (QApplication::desktop()->height()-hei)/2; 1389 int yy = (QApplication::desktop()->height()-hei)/2;
1385 tp.setGeometry( xx,yy,wid,hei ); 1390 tp.setGeometry( xx,yy,wid,hei );
1386 } 1391 }
1387 tp.exec(); 1392 tp.exec();
1388 updateTodo ( t, KOGlobals::EVENTEDITED ); 1393 updateTodo ( t, KOGlobals::EVENTEDITED );
1389 } else { 1394 } else {
1390 KOStartTodoPrefs tp ( t->summary(), this ); 1395 KOStartTodoPrefs tp ( t->summary(), this );
1391 if (QApplication::desktop()->width() <= 800 ){ 1396 if (QApplication::desktop()->width() <= 800 ){
1392 int wid = tp.width(); 1397 int wid = tp.width();
1393 int hei = tp.height(); 1398 int hei = tp.height();
1394 int xx = (QApplication::desktop()->width()-wid)/2; 1399 int xx = (QApplication::desktop()->width()-wid)/2;
1395 int yy = (QApplication::desktop()->height()-hei)/2; 1400 int yy = (QApplication::desktop()->height()-hei)/2;
1396 tp.setGeometry( xx,yy,wid,hei ); 1401 tp.setGeometry( xx,yy,wid,hei );
1397 } 1402 }
1398 if ( !tp.exec() ) return; 1403 if ( !tp.exec() ) return;
1399 if ( tp.stopAll() ) { 1404 if ( tp.stopAll() ) {
1400 mCalendar->stopAllTodos(); 1405 mCalendar->stopAllTodos();
1401 t->setRunning( true ); 1406 t->setRunning( true );
1402 updateView(); 1407 updateView();
1403 } else { 1408 } else {
1404 t->setRunning( true ); 1409 t->setRunning( true );
1405 updateTodo ( t, KOGlobals::EVENTEDITED ); 1410 updateTodo ( t, KOGlobals::EVENTEDITED );
1406 } 1411 }
1407 } 1412 }
1408} 1413}
1409 1414
1410void KOTodoView::itemClicked(QListViewItem *item) 1415void KOTodoView::itemClicked(QListViewItem *item)
1411{ 1416{
1412 //qDebug("KOTodoView::itemClicked %d", item); 1417 //qDebug("KOTodoView::itemClicked %d", item);
1413 if (!item) { 1418 if (!item) {
1414 if ( pendingSubtodo != 0 ) { 1419 if ( pendingSubtodo != 0 ) {
1415 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1420 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1416 } 1421 }
1417 pendingSubtodo = 0; 1422 pendingSubtodo = 0;
1418 return; 1423 return;
1419 } 1424 }
1420 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1425 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1421 if ( pendingSubtodo != 0 ) { 1426 if ( pendingSubtodo != 0 ) {
1422 bool allowReparent = true; 1427 bool allowReparent = true;
1423 QListViewItem *par = item; 1428 QListViewItem *par = item;
1424 while ( par ) { 1429 while ( par ) {
1425 if ( par == pendingSubtodo ) { 1430 if ( par == pendingSubtodo ) {
1426 allowReparent = false; 1431 allowReparent = false;
1427 break; 1432 break;
1428 } 1433 }
1429 par = par->parent(); 1434 par = par->parent();
1430 } 1435 }
1431 if ( !allowReparent ) { 1436 if ( !allowReparent ) {
1432 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1437 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1433 pendingSubtodo = 0; 1438 pendingSubtodo = 0;
1434 } else { 1439 } else {
1435 Todo* newParent = todoItem->todo(); 1440 Todo* newParent = todoItem->todo();
1436 Todo* newSub = pendingSubtodo->todo(); 1441 Todo* newSub = pendingSubtodo->todo();
1437 pendingSubtodo = 0; 1442 pendingSubtodo = 0;
1438 emit reparentTodoSignal( newParent,newSub ); 1443 emit reparentTodoSignal( newParent,newSub );
1439 return; 1444 return;
1440 } 1445 }
1441 } 1446 }
1442 1447
1443} 1448}
1444 1449
1445void KOTodoView::setDocumentId( const QString &id ) 1450void KOTodoView::setDocumentId( const QString &id )
1446{ 1451{
1447 1452
1448 mDocPrefs->setDoc( id ); 1453 mDocPrefs->setDoc( id );
1449} 1454}
1450 1455
1451void KOTodoView::itemStateChanged( QListViewItem *item ) 1456void KOTodoView::itemStateChanged( QListViewItem *item )
1452{ 1457{
1453 if (!item) return; 1458 if (!item) return;
1454 1459
1455 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1460 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1456 1461
1457// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1462// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1458 1463
1459 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1464 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1460} 1465}
1461 1466
1462void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1467void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1463{ 1468{
1464 mTodoListView->saveLayout(config,group); 1469 mTodoListView->saveLayout(config,group);
1465} 1470}
1466 1471
1467void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1472void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1468{ 1473{
1469 mTodoListView->restoreLayout(config,group); 1474 mTodoListView->restoreLayout(config,group);
1470} 1475}
1471 1476
1472void KOTodoView::processSelectionChange() 1477void KOTodoView::processSelectionChange()
1473{ 1478{
1474// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1479// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1475 1480
1476 KOTodoViewItem *item = 1481 KOTodoViewItem *item =
1477 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1482 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1478 1483
1479 if ( !item ) { 1484 if ( !item ) {
1480 emit incidenceSelected( 0 ); 1485 emit incidenceSelected( 0 );
1481 mNewSubBut->setEnabled( false ); 1486 mNewSubBut->setEnabled( false );
1482 } else { 1487 } else {
1483 emit incidenceSelected( item->todo() ); 1488 emit incidenceSelected( item->todo() );
1484 mNewSubBut->setEnabled( true ); 1489 mNewSubBut->setEnabled( true );
1485 } 1490 }
1486} 1491}
1487 1492
1488void KOTodoView::modified(bool b) 1493void KOTodoView::modified(bool b)
1489{ 1494{
1490 emit isModified(b); 1495 emit isModified(b);
1491} 1496}
1492void KOTodoView::setTodoModified( Todo* todo ) 1497void KOTodoView::setTodoModified( Todo* todo )
1493{ 1498{
1494 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1499 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1495} 1500}
1496void KOTodoView::clearSelection() 1501void KOTodoView::clearSelection()
1497{ 1502{
1498 mTodoListView->selectAll( false ); 1503 mTodoListView->selectAll( false );
1499} 1504}
1500void KOTodoView::setAllOpen() 1505void KOTodoView::setAllOpen()
1501{ 1506{
1502 if ( isFlatDisplay ) { 1507 if ( isFlatDisplay ) {
1503 isFlatDisplay = false; 1508 isFlatDisplay = false;
1504 mPopupMenu->setItemChecked( 8,false ); 1509 mPopupMenu->setItemChecked( 8,false );
1505 updateView(); 1510 updateView();
1506 } else { 1511 } else {
1507 storeCurrentItem(); 1512 storeCurrentItem();
1508 } 1513 }
1509 setOpen(mTodoListView->firstChild(), true); 1514 setOpen(mTodoListView->firstChild(), true);
1510 resetCurrentItem(); 1515 resetCurrentItem();
1511} 1516}
1512void KOTodoView::setAllClose() 1517void KOTodoView::setAllClose()
1513{ 1518{
1514 if ( isFlatDisplay ) { 1519 if ( isFlatDisplay ) {
1515 isFlatDisplay = false; 1520 isFlatDisplay = false;
1516 mPopupMenu->setItemChecked( 8,false ); 1521 mPopupMenu->setItemChecked( 8,false );
1517 updateView(); 1522 updateView();
1518 } else { 1523 } else {
1519 storeCurrentItem(); 1524 storeCurrentItem();
1520 } 1525 }
1521 setOpen(mTodoListView->firstChild(), false); 1526 setOpen(mTodoListView->firstChild(), false);
1522 resetCurrentItem(); 1527 resetCurrentItem();
1523} 1528}
1524void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1529void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1525{ 1530{
1526 1531
1527 while ( item ) { 1532 while ( item ) {
1528 setOpen( item->firstChild(), setOpenI ); 1533 setOpen( item->firstChild(), setOpenI );
1529 item->setOpen( setOpenI ); 1534 item->setOpen( setOpenI );
1530 item = item->nextSibling(); 1535 item = item->nextSibling();
1531 } 1536 }
1532} 1537}
1533 1538
1534void KOTodoView::displayAllFlat() 1539void KOTodoView::displayAllFlat()
1535{ 1540{
1536 1541
1537 mActiveItem = 0; 1542 mActiveItem = 0;
1538 pendingSubtodo = 0; 1543 pendingSubtodo = 0;
1539 if ( mBlockUpdate ) { 1544 if ( mBlockUpdate ) {
1540 return; 1545 return;
1541 } 1546 }
1542 clearList (); 1547 clearList ();
1543 mPopupMenu->setItemChecked( 8,true ); 1548 mPopupMenu->setItemChecked( 8,true );
1544 isFlatDisplay = true; 1549 isFlatDisplay = true;
1545 QPtrList<Todo> todoList = calendar()->todos(); 1550 QPtrList<Todo> todoList = calendar()->todos();
1546 Todo *todo; 1551 Todo *todo;
1547 for(todo = todoList.first(); todo; todo = todoList.next()) { 1552 for(todo = todoList.first(); todo; todo = todoList.next()) {
1548 if ( checkTodo( todo ) ) { 1553 if ( checkTodo( todo ) ) {
1549 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1554 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1550 mTodoMap.insert(todo,todoItem); 1555 mTodoMap.insert(todo,todoItem);
1551 } 1556 }
1552 } 1557 }
1553 resetCurrentItem(); 1558 resetCurrentItem();
1554} 1559}
1555 1560
1556void KOTodoView::setAllFlat() 1561void KOTodoView::setAllFlat()
1557{ 1562{
1558 if ( isFlatDisplay ) { 1563 if ( isFlatDisplay ) {
1559 isFlatDisplay = false; 1564 isFlatDisplay = false;
1560 mPopupMenu->setItemChecked( 8,false ); 1565 mPopupMenu->setItemChecked( 8,false );
1561 updateView(); 1566 updateView();
1562 return; 1567 return;
1563 } 1568 }
1564 displayAllFlat(); 1569 displayAllFlat();
1565} 1570}
1566 1571
1567void KOTodoView::purgeCompleted() 1572void KOTodoView::purgeCompleted()
1568{ 1573{
1569 emit purgeCompletedSignal(); 1574 emit purgeCompletedSignal();
1570 1575
1571} 1576}
1572void KOTodoView::toggleQuickTodo() 1577void KOTodoView::toggleQuickTodo()
1573{ 1578{
1574 if ( mQuickBar->isVisible() ) { 1579 if ( mQuickBar->isVisible() ) {
1575 mQuickBar->hide(); 1580 mQuickBar->hide();
1576 KOPrefs::instance()->mEnableQuickTodo = false; 1581 KOPrefs::instance()->mEnableQuickTodo = false;
1577 } 1582 }
1578 else { 1583 else {
1579 mQuickBar->show(); 1584 mQuickBar->show();
1580 KOPrefs::instance()->mEnableQuickTodo = true; 1585 KOPrefs::instance()->mEnableQuickTodo = true;
1581 } 1586 }
1582 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1587 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1583 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1588 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1584} 1589}
1585 1590
1586void KOTodoView::toggleRunning() 1591void KOTodoView::toggleRunning()
1587{ 1592{
1588 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1593 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1589 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1594 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1590 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1595 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1591 updateView(); 1596 updateView();
1592 if ( KOPrefs::instance()->mHideNonStartedTodos ) 1597 if ( KOPrefs::instance()->mHideNonStartedTodos )
1593 topLevelWidget()->setCaption(i18n("Hide not Running")); 1598 topLevelWidget()->setCaption(i18n("Hide not Running"));
1594 else 1599 else
1595 topLevelWidget()->setCaption(i18n("Show not Running")); 1600 topLevelWidget()->setCaption(i18n("Show not Running"));
1596} 1601}
1597 1602
1598void KOTodoView::toggleCompleted() 1603void KOTodoView::toggleCompleted()
1599{ 1604{
1600 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1605 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1601 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1606 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1602 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1607 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1603 updateView(); 1608 updateView();
1604 if ( KOPrefs::instance()->mShowCompletedTodo ) 1609 if ( KOPrefs::instance()->mShowCompletedTodo )
1605 topLevelWidget()->setCaption(i18n("Show Completed")); 1610 topLevelWidget()->setCaption(i18n("Show Completed"));
1606 else 1611 else
1607 topLevelWidget()->setCaption(i18n("Hide Completed")); 1612 topLevelWidget()->setCaption(i18n("Hide Completed"));
1608} 1613}
1609 1614
1610void KOTodoView::addQuickTodo() 1615void KOTodoView::addQuickTodo()
1611{ 1616{
1612 addQuickTodoPar( 0 ); 1617 addQuickTodoPar( 0 );
1613} 1618}
1614void KOTodoView::addQuickTodoPar( Todo * parentTodo) 1619void KOTodoView::addQuickTodoPar( Todo * parentTodo)
1615{ 1620{
1616 Todo *todo = new Todo(); 1621 Todo *todo = new Todo();
1617 todo->setSummary(mQuickAdd->text()); 1622 todo->setSummary(mQuickAdd->text());
1618 todo->setOrganizer(KOPrefs::instance()->email()); 1623 todo->setOrganizer(KOPrefs::instance()->email());
1619 if ( parentTodo ) { 1624 if ( parentTodo ) {
1620 todo->setRelatedTo(parentTodo); 1625 todo->setRelatedTo(parentTodo);
1621 1626
1622 todo->setCategories (parentTodo->categoriesStr ()); 1627 todo->setCategories (parentTodo->categoriesStr ());
1623 todo->setSecrecy (parentTodo->secrecy ()); 1628 todo->setSecrecy (parentTodo->secrecy ());
1624 if ( parentTodo->priority() < 3 ) 1629 if ( parentTodo->priority() < 3 )
1625 todo->setPriority( parentTodo->priority() ); 1630 todo->setPriority( parentTodo->priority() );
1626 todo->setCalID( parentTodo->calID() ); 1631 todo->setCalID( parentTodo->calID() );
1627 } else { 1632 } else {
1628 CalFilter * cf = mCalendar->filter(); 1633 CalFilter * cf = mCalendar->filter();
1629 if ( cf ) { 1634 if ( cf ) {
1630 if ( cf->isEnabled()&& cf->showCategories()) { 1635 if ( cf->isEnabled()&& cf->showCategories()) {
1631 todo->setCategories(cf->categoryList()); 1636 todo->setCategories(cf->categoryList());
1632 } 1637 }
1633 if ( cf->isEnabled() ) 1638 if ( cf->isEnabled() )
1634 todo->setSecrecy( cf->getSecrecy()); 1639 todo->setSecrecy( cf->getSecrecy());
1635 } 1640 }
1636 } 1641 }
1637 mCalendar->addTodo(todo); 1642 mCalendar->addTodo(todo);
1638 mQuickAdd->setText(""); 1643 mQuickAdd->setText("");
1639 todoModified (todo, KOGlobals::EVENTADDED ); 1644 todoModified (todo, KOGlobals::EVENTADDED );
1640 updateView(); 1645 updateView();
1641 1646
1642} 1647}
1643void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1648void KOTodoView::keyPressEvent ( QKeyEvent * e )
1644{ 1649{
1645 // e->ignore(); 1650 // e->ignore();
1646 //return; 1651 //return;
1647 if ( !isVisible() ) { 1652 if ( !isVisible() ) {
1648 e->ignore(); 1653 e->ignore();
1649 return; 1654 return;
1650 } 1655 }
1651 switch ( e->key() ) { 1656 switch ( e->key() ) {
1652 case Qt::Key_Down: 1657 case Qt::Key_Down:
1653 case Qt::Key_Up: 1658 case Qt::Key_Up:
1654 // KOrg::BaseView::keyPressEvent ( e ); 1659 // KOrg::BaseView::keyPressEvent ( e );
1655 e->ignore(); 1660 e->ignore();
1656 break; 1661 break;
1657 1662
1658 case Qt::Key_Q: 1663 case Qt::Key_Q:
1659 1664
1660 1665
1661 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { 1666 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) {
1662 e->ignore(); 1667 e->ignore();
1663 break; 1668 break;
1664 } 1669 }
1665 toggleQuickTodo(); 1670 toggleQuickTodo();
1666 break; 1671 break;
1667 case Qt::Key_U: 1672 case Qt::Key_U:
1668 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1673 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1669 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1674 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1670 unparentTodo(); 1675 unparentTodo();
1671 e->accept(); 1676 e->accept();
1672 } else 1677 } else
1673 e->ignore(); 1678 e->ignore();
1674 break; 1679 break;
1675 case Qt::Key_S: 1680 case Qt::Key_S:
1676 if ( e->state() == Qt::ControlButton ) { 1681 if ( e->state() == Qt::ControlButton ) {
1677 e->ignore(); 1682 e->ignore();
1678 break; 1683 break;
1679 } 1684 }
1680 if ( e->state() == Qt::ShiftButton ) { 1685 if ( e->state() == Qt::ShiftButton ) {
1681 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1686 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1682 reparentTodo(); 1687 reparentTodo();
1683 e->accept(); 1688 e->accept();
1684 } else 1689 } else
1685 e->ignore(); 1690 e->ignore();
1686 break; 1691 break;
1687 case Qt::Key_P: 1692 case Qt::Key_P:
1688 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1693 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1689 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1694 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1690 if ( pendingSubtodo ) 1695 if ( pendingSubtodo )
1691 itemClicked(mActiveItem); 1696 itemClicked(mActiveItem);
1692 e->accept(); 1697 e->accept();
1693 } else 1698 } else
1694 e->ignore(); 1699 e->ignore();
1695 break; 1700 break;
1696 case Qt::Key_Escape: 1701 case Qt::Key_Escape:
1697 if ( pendingSubtodo ) { 1702 if ( pendingSubtodo ) {
1698 itemClicked(0); 1703 itemClicked(0);
1699 e->accept(); 1704 e->accept();
1700 } else 1705 } else
1701 e->ignore(); 1706 e->ignore();
1702 break; 1707 break;
1703 default: 1708 default:
1704 e->ignore(); 1709 e->ignore();
1705 } 1710 }
1706 1711
1707 if ( true ) { 1712 if ( true ) {
1708 if ( e->key() == Qt::Key_I ) { 1713 if ( e->key() == Qt::Key_I ) {
1709 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1714 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1710 if ( cn ) { 1715 if ( cn ) {
1711 mActiveItem = cn; 1716 mActiveItem = cn;
1712 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1717 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1713 if ( ci ){ 1718 if ( ci ){
1714 showTodo(); 1719 showTodo();
1715 cn = (KOTodoViewItem*)cn->itemBelow(); 1720 cn = (KOTodoViewItem*)cn->itemBelow();
1716 if ( cn ) { 1721 if ( cn ) {
1717 mTodoListView->setCurrentItem ( cn ); 1722 mTodoListView->setCurrentItem ( cn );
1718 mTodoListView->ensureItemVisible ( cn ); 1723 mTodoListView->ensureItemVisible ( cn );
1719 } 1724 }
1720 1725
1721 } 1726 }
1722 } 1727 }
1723 e->accept(); 1728 e->accept();
1724 } 1729 }
1725 } 1730 }
1726} 1731}
1727 1732
1728void KOTodoView::updateTodo( Todo * t, int type ) 1733void KOTodoView::updateTodo( Todo * t, int type )
1729{ 1734{
1730 if ( mBlockUpdate ) 1735 if ( mBlockUpdate )
1731 return; 1736 return;
1732 1737
1733 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1738 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1734 itemIterator = mTodoMap.find(t); 1739 itemIterator = mTodoMap.find(t);
1735 if (itemIterator != mTodoMap.end()) { 1740 if (itemIterator != mTodoMap.end()) {
1736 (*itemIterator)->construct(); 1741 (*itemIterator)->construct();
1737 } else { 1742 } else {
1738 if ( type == KOGlobals::EVENTADDED ) { 1743 if ( type == KOGlobals::EVENTADDED ) {
1739 insertTodoItem( t ); 1744 insertTodoItem( t );
1740 } 1745 }
1741 } 1746 }
1742 1747
1743} 1748}
1744 1749
1745void KOTodoView::todoModified(Todo * t , int p ) 1750void KOTodoView::todoModified(Todo * t , int p )
1746{ 1751{
1747 mBlockUpdate = true; 1752 mBlockUpdate = true;
1748 emit todoModifiedSignal ( t, p ); 1753 emit todoModifiedSignal ( t, p );
1749 mBlockUpdate = false; 1754 mBlockUpdate = false;
1750} 1755}
diff --git a/korganizer/main.cpp b/korganizer/main.cpp
index c9d1345..6339370 100644
--- a/korganizer/main.cpp
+++ b/korganizer/main.cpp
@@ -1,115 +1,115 @@
1 1
2 2
3#ifndef DESKTOP_VERSION 3#ifndef DESKTOP_VERSION
4#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
5#include <qcopchannel_qws.h> 5#include <qcopchannel_qws.h>
6#include <qpe/global.h> 6#include <qpe/global.h>
7#include <stdlib.h> 7#include <stdlib.h>
8#else 8#else
9#include <qapplication.h> 9#include <qapplication.h>
10#include <qstring.h> 10#include <qstring.h>
11#include <qwindowsstyle.h> 11#include <qwindowsstyle.h>
12#include <qplatinumstyle.h> 12#include <qplatinumstyle.h>
13#include <qsgistyle.h> 13#include <qsgistyle.h>
14#include <stdlib.h> 14#include <stdlib.h>
15#endif 15#endif
16#include <qtextcodec.h> 16#include <qtextcodec.h>
17 17
18#include <qdir.h> 18#include <qdir.h>
19#include <kstandarddirs.h> 19#include <kstandarddirs.h>
20#include <kglobal.h> 20#include <kglobal.h>
21#include <stdio.h> 21#include <stdio.h>
22#include "mainwindow.h" 22#include "mainwindow.h"
23#include <libkdepim/kpimglobalprefs.h> 23#include <libkdepim/kpimglobalprefs.h>
24void dumpMissing(); 24void dumpMissing();
25 25
26 26
27int main( int argc, char **argv ) 27int main( int argc, char **argv )
28{ 28{
29#ifndef DESKTOP_VERSION 29#ifndef DESKTOP_VERSION
30 QPEApplication a( argc, argv ); 30 QPEApplication a( argc, argv );
31 a.setKeepRunning (); 31 a.setKeepRunning ();
32#else 32#else
33 QApplication a( argc, argv ); 33 QApplication a( argc, argv );
34 QApplication::setStyle( new QPlatinumStyle ()); 34 QApplication::setStyle( new QPlatinumStyle ());
35#ifdef _WIN32_ 35#ifdef _WIN32_
36 QString hdir ( getenv( "HOME") ); 36 QString hdir ( getenv( "HOME") );
37 if ( hdir.isEmpty() ) { 37 if ( hdir.isEmpty() ) {
38 QString hd ("C:/" ); 38 QString hd ("C:/" );
39 //QMessageBox::information(0,"hh",QDir::homeDirPath()+" xx" +hd ); 39 //QMessageBox::information(0,"hh",QDir::homeDirPath()+" xx" +hd );
40 if ( QDir::homeDirPath().lower() == hd.lower() ) { 40 if ( QDir::homeDirPath().lower() == hd.lower() ) {
41 _putenv( "HOME=C:"); 41 _putenv( "HOME=C:");
42 //QMessageBox::information(0,"hh",QString ( getenv( "HOME") ) ); 42 //QMessageBox::information(0,"hh",QString ( getenv( "HOME") ) );
43 } 43 }
44 } else { 44 } else {
45 QDir app_dir; 45 QDir app_dir;
46 if ( !app_dir.exists(hdir) ) 46 if ( !app_dir.exists(hdir) )
47 app_dir.mkdir (hdir); 47 app_dir.mkdir (hdir);
48 } 48 }
49#endif 49#endif
50#endif 50#endif
51 bool exitHelp = false; 51 bool exitHelp = false;
52 if ( argc > 1 ) { 52 if ( argc > 1 ) {
53 QString command = argv[1]; 53 QString command = argv[1];
54 if ( command == "-help" ){ 54 if ( command == "-help" ){
55 printf("KO/Pi command line commands:\n"); 55 printf("KO/Pi command line commands:\n");
56 printf(" no command: Start KO/Pi in usual way\n"); 56 printf(" no command: Start KO/Pi in usual way\n");
57 printf(" -help: This output\n"); 57 printf(" -help: This output\n");
58 printf("Next Option: Open or Show after start:\n"); 58 printf("Next Option: Open or Show after start:\n");
59 printf(" -newTodo: New Todo dialog\n"); 59 printf(" -newTodo: New Todo dialog\n");
60 printf(" -newEvent: New Event dialog\n"); 60 printf(" -newEvent: New Event dialog\n");
61 printf(" -showList: List view\n"); 61 printf(" -showList: List view\n");
62 printf(" -showDay: Day view\n"); 62 printf(" -showDay: Day view\n");
63 printf(" -showWWeek: Work Week view\n"); 63 printf(" -showWWeek: Work Week view\n");
64 printf(" -showWeek: Week view\n"); 64 printf(" -showWeek: Week view\n");
65 printf(" -showTodo: Todo view\n"); 65 printf(" -showTodo: Todo view\n");
66 printf(" -showJournal: Journal view\n"); 66 printf(" -showJournal: Journal view\n");
67 printf(" -showKO: Next Days view\n"); 67 printf(" -showKO: Next Days view\n");
68 printf(" -showWNext: What's Next view\n"); 68 printf(" -showWNext: What's Next view\n");
69 printf(" -showNextXView: Next X View\n"); 69 printf(" -showNextXView: Next X View\n");
70 printf(" -new[Y] and -show[X] may be used togehther\n"); 70 printf(" -new[Y] and -show[X] may be used togehther\n");
71 printf(" KO/Pi is exiting now. Bye!\n"); 71 printf(" KO/Pi is exiting now. Bye!\n");
72 exitHelp = true; 72 exitHelp = true;
73 } 73 }
74 } 74 }
75 if ( ! exitHelp ) { 75 if ( ! exitHelp ) {
76 KGlobal::setAppName( "korganizer" ); 76 KGlobal::setAppName( "korganizer" );
77 QString fileName ; 77 QString fileName ;
78#ifndef DESKTOP_VERSION 78#ifndef DESKTOP_VERSION
79 fileName = getenv("QPEDIR"); 79 fileName = getenv("QPEDIR");
80 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); 80 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/");
81#else 81#else
82 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; 82 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/";
83 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 83 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
84#endif 84#endif
85 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer"))); 85 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer")));
86 86
87 QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont ); 87 QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont );
88 KPimGlobalPrefs::instance()->setGlobalConfig(); 88 KPimGlobalPrefs::instance()->setGlobalConfig();
89 MainWindow m; 89 MainWindow m;
90#ifndef DESKTOP_VERSION 90#ifndef DESKTOP_VERSION
91 91
92 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); 92 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(receiveStart( const QCString&, const QByteArray& )));
93 a.showMainWidget(&m ); 93 a.showMainWidget(&m );
94#else 94#else
95 a.setMainWidget(&m ); 95 a.setMainWidget(&m );
96 m.show(); 96 m.show();
97 //m.resize( 800, 600 ); 97 //m.resize( 800, 600 );
98 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 98 //QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
99#endif 99#endif
100 if ( argc > 1 ) { 100 if ( argc > 1 ) {
101 QCString command = argv[1]; 101 QCString command = argv[1];
102 if ( argc > 2 ) 102 if ( argc > 2 )
103 command += argv[2]; 103 command += argv[2];
104 qApp->processEvents(); 104 qApp->processEvents();
105 m.recieve(command, QByteArray() ); 105 m.recieve(command, QByteArray() );
106 106
107 } 107 }
108 108
109 a.exec(); 109 a.exec();
110 dumpMissing(); 110 dumpMissing();
111 111
112 KPimGlobalPrefs::instance()->writeConfig(); 112 KPimGlobalPrefs::instance()->writeConfig();
113 } 113 }
114 qDebug("KO: Bye! "); 114 qDebug("KO: Bye! ");
115} 115}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 9ae393d..8c72d89 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2688 +1,2716 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpetoolbar.h> 24#include <qpe/qpetoolbar.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qtopia/alarmserver.h> 27#include <qtopia/alarmserver.h>
28#include <qtopia/qcopenvelope_qws.h> 28#include <qtopia/qcopenvelope_qws.h>
29#include <unistd.h> // for sleep 29#include <unistd.h> // for sleep
30#else 30#else
31#include <qtoolbar.h> 31#include <qtoolbar.h>
32#include <qapplication.h> 32#include <qapplication.h>
33//#include <resource.h> 33//#include <resource.h>
34 34
35#endif 35#endif
36#include <libkcal/calendarlocal.h> 36#include <libkcal/calendarlocal.h>
37#include <libkcal/todo.h> 37#include <libkcal/todo.h>
38#include <libkcal/phoneformat.h> 38#include <libkcal/phoneformat.h>
39#include <libkdepim/ksyncprofile.h> 39#include <libkdepim/ksyncprofile.h>
40#include <libkdepim/phoneaccess.h> 40#include <libkdepim/phoneaccess.h>
41#include <libkcal/kincidenceformatter.h> 41#include <libkcal/kincidenceformatter.h>
42#include <libkdepim/kpimglobalprefs.h> 42#include <libkdepim/kpimglobalprefs.h>
43 43
44#include "calendarview.h" 44#include "calendarview.h"
45#include "koviewmanager.h" 45#include "koviewmanager.h"
46#include "datenavigator.h" 46#include "datenavigator.h"
47#include "koagendaview.h" 47#include "koagendaview.h"
48#include "kojournalview.h" 48#include "kojournalview.h"
49#include "koagenda.h" 49#include "koagenda.h"
50#include "kodialogmanager.h" 50#include "kodialogmanager.h"
51#include "kdialogbase.h" 51#include "kdialogbase.h"
52#include "kapplication.h" 52#include "kapplication.h"
53#include "kofilterview.h" 53#include "kofilterview.h"
54#include "kstandarddirs.h" 54#include "kstandarddirs.h"
55#include "koprefs.h" 55#include "koprefs.h"
56#include "kfiledialog.h" 56#include "kfiledialog.h"
57#include "koglobals.h" 57#include "koglobals.h"
58#include "kglobal.h" 58#include "kglobal.h"
59#include "ktoolbar.h" 59#include "ktoolbar.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "externalapphandler.h" 62#include "externalapphandler.h"
63#include <kglobalsettings.h> 63#include <kglobalsettings.h>
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#ifdef _OL_IMPORT_ 69#ifdef _OL_IMPORT_
70#include "koimportoldialog.h" 70#include "koimportoldialog.h"
71#endif 71#endif
72#endif 72#endif
73#include "mainwindow.h" 73#include "mainwindow.h"
74 74
75 75
76class KOex2phonePrefs : public QDialog 76class KOex2phonePrefs : public QDialog
77{ 77{
78 public: 78 public:
79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
80 QDialog( parent, name, true ) 80 QDialog( parent, name, true )
81 { 81 {
82 setCaption( i18n("Export to phone options") ); 82 setCaption( i18n("Export to phone options") );
83 QVBoxLayout* lay = new QVBoxLayout( this ); 83 QVBoxLayout* lay = new QVBoxLayout( this );
84 lay->setSpacing( 3 ); 84 lay->setSpacing( 3 );
85 lay->setMargin( 3 ); 85 lay->setMargin( 3 );
86 QLabel *lab; 86 QLabel *lab;
87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
88 lab->setAlignment (AlignHCenter ); 88 lab->setAlignment (AlignHCenter );
89 QHBox* temphb; 89 QHBox* temphb;
90 temphb = new QHBox( this ); 90 temphb = new QHBox( this );
91 new QLabel( i18n("I/O device: "), temphb ); 91 new QLabel( i18n("I/O device: "), temphb );
92 mPhoneDevice = new QLineEdit( temphb); 92 mPhoneDevice = new QLineEdit( temphb);
93 lay->addWidget( temphb ); 93 lay->addWidget( temphb );
94 temphb = new QHBox( this ); 94 temphb = new QHBox( this );
95 new QLabel( i18n("Connection: "), temphb ); 95 new QLabel( i18n("Connection: "), temphb );
96 mPhoneConnection = new QLineEdit( temphb); 96 mPhoneConnection = new QLineEdit( temphb);
97 lay->addWidget( temphb ); 97 lay->addWidget( temphb );
98 temphb = new QHBox( this ); 98 temphb = new QHBox( this );
99 new QLabel( i18n("Model(opt.): "), temphb ); 99 new QLabel( i18n("Model(opt.): "), temphb );
100 mPhoneModel = new QLineEdit( temphb); 100 mPhoneModel = new QLineEdit( temphb);
101 lay->addWidget( temphb ); 101 lay->addWidget( temphb );
102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
103 mWriteBackFuture->setChecked( true ); 103 mWriteBackFuture->setChecked( true );
104 lay->addWidget( mWriteBackFuture ); 104 lay->addWidget( mWriteBackFuture );
105 temphb = new QHBox( this ); 105 temphb = new QHBox( this );
106 new QLabel( i18n("Max. weeks in future: ") , temphb ); 106 new QLabel( i18n("Max. weeks in future: ") , temphb );
107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
108 mWriteBackFutureWeeks->setValue( 8 ); 108 mWriteBackFutureWeeks->setValue( 8 );
109 lay->addWidget( temphb ); 109 lay->addWidget( temphb );
110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
111 lab->setAlignment (AlignHCenter ); 111 lab->setAlignment (AlignHCenter );
112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
113 lay->addWidget( ok ); 113 lay->addWidget( ok );
114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
115 lay->addWidget( cancel ); 115 lay->addWidget( cancel );
116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
118 resize( 220, 240 ); 118 resize( 220, 240 );
119 qApp->processEvents(); 119 qApp->processEvents();
120 int dw = QApplication::desktop()->width(); 120 int dw = QApplication::desktop()->width();
121 int dh = QApplication::desktop()->height(); 121 int dh = QApplication::desktop()->height();
122 move( (dw-width())/2, (dh - height() )/2 ); 122 move( (dw-width())/2, (dh - height() )/2 );
123 } 123 }
124 124
125public: 125public:
126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
127 QCheckBox* mWriteBackFuture; 127 QCheckBox* mWriteBackFuture;
128 QSpinBox* mWriteBackFutureWeeks; 128 QSpinBox* mWriteBackFutureWeeks;
129}; 129};
130 130
131QPixmap* sgListViewCompletedPix[6]; 131QPixmap* sgListViewCompletedPix[6];
132QPixmap* sgListViewJournalPix; 132QPixmap* sgListViewJournalPix;
133 133
134 134
135int globalFlagBlockStartup; 135int globalFlagBlockStartup;
136MainWindow::MainWindow( QWidget *parent, const char *name ) : 136MainWindow::MainWindow( QWidget *parent, const char *name ) :
137 QMainWindow( parent, name ) 137 QMainWindow( parent, name )
138{ 138{
139 sgListViewCompletedPix[5] = &listviewPix; 139 sgListViewCompletedPix[5] = &listviewPix;
140 sgListViewCompletedPix[0] = &listviewPix0; 140 sgListViewCompletedPix[0] = &listviewPix0;
141 sgListViewCompletedPix[1] = &listviewPix20; 141 sgListViewCompletedPix[1] = &listviewPix20;
142 sgListViewCompletedPix[2] = &listviewPix40; 142 sgListViewCompletedPix[2] = &listviewPix40;
143 sgListViewCompletedPix[3] = &listviewPix60; 143 sgListViewCompletedPix[3] = &listviewPix60;
144 sgListViewCompletedPix[4] = &listviewPix80; 144 sgListViewCompletedPix[4] = &listviewPix80;
145 //int size = 12; 145 //int size = 12;
146 { 146 {
147 sgListViewCompletedPix[5]->resize( 11, 11 ); 147 sgListViewCompletedPix[5]->resize( 11, 11 );
148 sgListViewCompletedPix[5]->fill( Qt::white ); 148 sgListViewCompletedPix[5]->fill( Qt::white );
149 QPainter p ( sgListViewCompletedPix[5] ); 149 QPainter p ( sgListViewCompletedPix[5] );
150 p.drawRect( 0,0,11,11); 150 p.drawRect( 0,0,11,11);
151 p.drawLine ( 2, 5, 4 , 7 ) ; 151 p.drawLine ( 2, 5, 4 , 7 ) ;
152 p.drawLine ( 4 , 7 , 8, 3) ; 152 p.drawLine ( 4 , 7 , 8, 3) ;
153 int iii = 0; 153 int iii = 0;
154 for ( iii = 0; iii < 5; ++iii ) { 154 for ( iii = 0; iii < 5; ++iii ) {
155 sgListViewCompletedPix[iii]->resize( 11, 11 ); 155 sgListViewCompletedPix[iii]->resize( 11, 11 );
156 sgListViewCompletedPix[iii]->fill( Qt::white ); 156 sgListViewCompletedPix[iii]->fill( Qt::white );
157 QPainter p ( sgListViewCompletedPix[iii] ); 157 QPainter p ( sgListViewCompletedPix[iii] );
158 p.drawRect( 0,0,11,11); 158 p.drawRect( 0,0,11,11);
159 if ( iii ) 159 if ( iii )
160 p.fillRect( 1,1,iii*2,9,Qt::gray ); 160 p.fillRect( 1,1,iii*2,9,Qt::gray );
161 } 161 }
162 sgListViewJournalPix = &journalPix; 162 sgListViewJournalPix = &journalPix;
163 sgListViewJournalPix->resize( 11, 11 ); 163 sgListViewJournalPix->resize( 11, 11 );
164 sgListViewJournalPix->fill( Qt::white ); 164 sgListViewJournalPix->fill( Qt::white );
165 { 165 {
166 QPainter p ( sgListViewJournalPix ); 166 QPainter p ( sgListViewJournalPix );
167 p.drawRect( 0,0,11,11); 167 p.drawRect( 0,0,11,11);
168 p.drawLine( 2,3,5,3); 168 p.drawLine( 2,3,5,3);
169 p.drawLine( 2,5,8,5); 169 p.drawLine( 2,5,8,5);
170 p.drawLine( 2,7,6,7); 170 p.drawLine( 2,7,6,7);
171 } 171 }
172 } 172 }
173 mClosed = false; 173 mClosed = false;
174 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 174 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
175 QString confFile = locateLocal("config","korganizerrc"); 175 QString confFile = locateLocal("config","korganizerrc");
176 QFileInfo finf ( confFile ); 176 QFileInfo finf ( confFile );
177 bool showWarning = !finf.exists(); 177 bool showWarning = !finf.exists();
178 setIcon(SmallIcon( "ko24" ) ); 178 setIcon(SmallIcon( "ko24" ) );
179 mBlockAtStartup = true; 179 mBlockAtStartup = true;
180 mFlagKeyPressed = false; 180 mFlagKeyPressed = false;
181 setCaption("KO/Pi"); 181 setCaption("KO/Pi");
182 KOPrefs *p = KOPrefs::instance(); 182 KOPrefs *p = KOPrefs::instance();
183 //KPimGlobalPrefs::instance()->setGlobalConfig(); 183 //KPimGlobalPrefs::instance()->setGlobalConfig();
184 p->mCurrentDisplayedView = 0; 184 p->mCurrentDisplayedView = 0;
185 if ( p->mHourSize > 22 ) 185 if ( p->mHourSize > 22 )
186 p->mHourSize = 22; 186 p->mHourSize = 22;
187 QMainWindow::ToolBarDock tbd; 187 QMainWindow::ToolBarDock tbd;
188 if ( p->mToolBarHor ) { 188 if ( p->mToolBarHor ) {
189 if ( p->mToolBarUp ) 189 if ( p->mToolBarUp )
190 tbd = Bottom; 190 tbd = Bottom;
191 else 191 else
192 tbd = Top; 192 tbd = Top;
193 } 193 }
194 else { 194 else {
195 if ( p->mToolBarUp ) 195 if ( p->mToolBarUp )
196 tbd = Right; 196 tbd = Right;
197 else 197 else
198 tbd = Left; 198 tbd = Left;
199 } 199 }
200 if ( KOPrefs::instance()->mUseAppColors ) 200 if ( KOPrefs::instance()->mUseAppColors )
201 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 201 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
202 globalFlagBlockStartup = 1; 202 globalFlagBlockStartup = 1;
203 iconToolBar = new QPEToolBar( this ); 203 iconToolBar = new QPEToolBar( this );
204 addToolBar (iconToolBar , tbd ); 204 addToolBar (iconToolBar , tbd );
205 205
206#ifdef DESKTOP_VERSION 206#ifdef DESKTOP_VERSION
207 if ( KOPrefs::instance()->mShowIconFilter ) 207 if ( KOPrefs::instance()->mShowIconFilter )
208#else 208#else
209 if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) ) 209 if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) )
210#endif 210#endif
211 211
212{ 212{
213 if ( p->mToolBarHorF ) { 213 if ( p->mToolBarHorF ) {
214 if ( p->mToolBarUpF ) 214 if ( p->mToolBarUpF )
215 tbd = Bottom; 215 tbd = Bottom;
216 else 216 else
217 tbd = Top; 217 tbd = Top;
218 } 218 }
219 else { 219 else {
220 if ( p->mToolBarUpF ) 220 if ( p->mToolBarUpF )
221 tbd = Right; 221 tbd = Right;
222 else 222 else
223 tbd = Left; 223 tbd = Left;
224 } 224 }
225 filterToolBar = new QPEToolBar ( this ); 225 filterToolBar = new QPEToolBar ( this );
226 filterMenubar = new KMenuBar( 0 ); 226 filterMenubar = new KMenuBar( 0 );
227 QFontMetrics fm ( filterMenubar->font() ); 227 QFontMetrics fm ( filterMenubar->font() );
228#ifndef DESKTOP_VERSION 228#ifndef DESKTOP_VERSION
229 filterToolBar->setFocusPolicy( NoFocus ); 229 filterToolBar->setFocusPolicy( NoFocus );
230 filterMenubar->setFocusPolicy( NoFocus ); 230 filterMenubar->setFocusPolicy( NoFocus );
231#endif 231#endif
232 filterPopupMenu = new QPopupMenu( this ); 232 filterPopupMenu = new QPopupMenu( this );
233 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 233 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
234 QString addTest = "A"; 234 QString addTest = "A";
235 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); 235 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) );
236#ifdef DESKTOP_VERSION 236#ifdef DESKTOP_VERSION
237 addTest = "AAAAAABBBCCCx"; 237 addTest = "AAAAAABBBCCCx";
238#else 238#else
239 addTest = "AAAAAx"; 239 addTest = "AAAAAx";
240#endif 240#endif
241 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); 241 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) );
242 addToolBar (filterToolBar , tbd ); 242 addToolBar (filterToolBar , tbd );
243 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 243 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
244 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 244 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
245 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 245 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
246 filterToolBar->hide(); 246 filterToolBar->hide();
247 } else { 247 } else {
248 filterToolBar = 0; 248 filterToolBar = 0;
249 filterMenubar = 0; 249 filterMenubar = 0;
250 filterPopupMenu = 0; 250 filterPopupMenu = 0;
251 } 251 }
252 if ( p->mShowIconOnetoolbar ) { 252 if ( p->mShowIconOnetoolbar ) {
253 viewToolBar = iconToolBar ; 253 viewToolBar = iconToolBar ;
254 navigatorToolBar = iconToolBar ; 254 navigatorToolBar = iconToolBar ;
255 } else { 255 } else {
256#ifndef DESKTOP_VERSION 256#ifndef DESKTOP_VERSION
257 setToolBarsMovable( false ); 257 setToolBarsMovable( false );
258#endif 258#endif
259 if ( p->mToolBarHorV ) { 259 if ( p->mToolBarHorV ) {
260 if ( p->mToolBarUpV ) 260 if ( p->mToolBarUpV )
261 tbd = Bottom; 261 tbd = Bottom;
262 else 262 else
263 tbd = Top; 263 tbd = Top;
264 } 264 }
265 else { 265 else {
266 if ( p->mToolBarUpV ) 266 if ( p->mToolBarUpV )
267 tbd = Right; 267 tbd = Right;
268 else 268 else
269 tbd = Left; 269 tbd = Left;
270 } 270 }
271 viewToolBar = new QPEToolBar( this ); 271 viewToolBar = new QPEToolBar( this );
272 addToolBar (viewToolBar , tbd ); 272 addToolBar (viewToolBar , tbd );
273 if ( p->mToolBarHorN ) { 273 if ( p->mToolBarHorN ) {
274 if ( p->mToolBarUpN ) 274 if ( p->mToolBarUpN )
275 tbd = Bottom; 275 tbd = Bottom;
276 else 276 else
277 tbd = Top; 277 tbd = Top;
278 } 278 }
279 else { 279 else {
280 if ( p->mToolBarUpN ) 280 if ( p->mToolBarUpN )
281 tbd = Right; 281 tbd = Right;
282 else 282 else
283 tbd = Left; 283 tbd = Left;
284 } 284 }
285 navigatorToolBar = new QPEToolBar( this ); 285 navigatorToolBar = new QPEToolBar( this );
286 addToolBar (navigatorToolBar , tbd ); 286 addToolBar (navigatorToolBar , tbd );
287 } 287 }
288 288
289 289
290 290
291 mCalendarModifiedFlag = false; 291 mCalendarModifiedFlag = false;
292 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 292 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
293 splash->setAlignment ( AlignCenter ); 293 splash->setAlignment ( AlignCenter );
294 setCentralWidget( splash ); 294 setCentralWidget( splash );
295#ifndef DESKTOP_VERSION 295#ifndef DESKTOP_VERSION
296 showMaximized(); 296 showMaximized();
297#endif 297#endif
298 298
299 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 299 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
300 setDefaultPreferences(); 300 setDefaultPreferences();
301 mCalendar = new CalendarLocal(); 301 mCalendar = new CalendarLocal();
302 mView = new CalendarView( mCalendar, this,"mCalendar " ); 302 mView = new CalendarView( mCalendar, this,"mCalendar " );
303 mView->hide(); 303 mView->hide();
304 //mView->resize(splash->size() ); 304 //mView->resize(splash->size() );
305 initActions(); 305 initActions();
306 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 306 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
307 mSyncManager->setBlockSave(false); 307 mSyncManager->setBlockSave(false);
308 mView->setSyncManager(mSyncManager); 308 mView->setSyncManager(mSyncManager);
309#ifndef DESKTOP_VERSION 309#ifndef DESKTOP_VERSION
310 iconToolBar->show(); 310 iconToolBar->show();
311 qApp->processEvents(); 311 qApp->processEvents();
312#endif 312#endif
313 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 313 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
314 int vh = height() ; 314 int vh = height() ;
315 int vw = width(); 315 int vw = width();
316 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 316 //qDebug("Toolbar hei %d ",iconToolBar->height() );
317 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 317 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
318 vh -= iconToolBar->height(); 318 vh -= iconToolBar->height();
319 } else { 319 } else {
320 vw -= iconToolBar->height(); 320 vw -= iconToolBar->height();
321 } 321 }
322 //mView->setMaximumSize( splash->size() ); 322 //mView->setMaximumSize( splash->size() );
323 //mView->resize( splash->size() ); 323 //mView->resize( splash->size() );
324 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 324 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
325 mView->readSettings(); 325 mView->readSettings();
326 bool newFile = false; 326 bool newFile = false;
327 if( !QFile::exists( defaultFileName() ) ) { 327 if( !QFile::exists( defaultFileName() ) ) {
328 QFileInfo finfo ( defaultFileName() ); 328 QFileInfo finfo ( defaultFileName() );
329 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 329 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
330 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 330 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
331 finfo.setFile( oldFile ); 331 finfo.setFile( oldFile );
332 if (finfo.exists() ) { 332 if (finfo.exists() ) {
333 KMessageBox::information( this, message); 333 KMessageBox::information( this, message);
334 mView->openCalendar( oldFile ); 334 mView->openCalendar( oldFile );
335 qApp->processEvents(); 335 qApp->processEvents();
336 } else { 336 } else {
337 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 337 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
338 finfo.setFile( oldFile ); 338 finfo.setFile( oldFile );
339 if (finfo.exists() ) { 339 if (finfo.exists() ) {
340 KMessageBox::information( this, message); 340 KMessageBox::information( this, message);
341 mView->openCalendar( oldFile ); 341 mView->openCalendar( oldFile );
342 qApp->processEvents(); 342 qApp->processEvents();
343 } 343 }
344 } 344 }
345 mView->saveCalendar( defaultFileName() ); 345 mView->saveCalendar( defaultFileName() );
346 newFile = true; 346 newFile = true;
347 } 347 }
348 348
349 QTime neededSaveTime = QDateTime::currentDateTime().time(); 349 //QTime neededSaveTime = QDateTime::currentDateTime().time();
350 mView->loadCalendars(); 350 //mView->loadCalendars();
351 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 351 //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
352 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 352 //qDebug("KO: Calendar loading time: %d ms",msNeeded );
353 353
354 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 354 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
355 KOPrefs::instance()->setAllDefaults(); 355 KOPrefs::instance()->setAllDefaults();
356 } 356 }
357 processIncidenceSelection( 0 );
358 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
359 SLOT( processIncidenceSelection( Incidence * ) ) );
360 connect( mView, SIGNAL( modifiedChanged( bool ) ),
361 SLOT( slotModifiedChanged( bool ) ) );
362 357
363 358
364 connect( mView, SIGNAL( tempDisableBR(bool) ), 359 connect( mView, SIGNAL( tempDisableBR(bool) ),
365 SLOT( disableBR(bool) ) ); 360 SLOT( disableBR(bool) ) );
366 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 361 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
367 mView->setModified( false );
368 mBlockAtStartup = false;
369 mView->setModified( false );
370 setCentralWidget( mView ); 362 setCentralWidget( mView );
371 globalFlagBlockStartup = 0; 363 globalFlagBlockStartup = 0;
372 mView->show(); 364 mView->show();
373 delete splash; 365 delete splash;
374 if ( newFile ) 366 if ( newFile )
375 mView->updateConfig(); 367 mView->updateConfig();
376 // qApp->processEvents(); 368 // qApp->processEvents();
377 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 369 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
378 //fillSyncMenu(); 370 //fillSyncMenu();
379 371
380 372
381 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 373 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
382 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
383 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 374 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
384 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 375 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
385 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 376 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
386 mSyncManager->setDefaultFileName( sentSyncFile()); 377 mSyncManager->setDefaultFileName( sentSyncFile());
387 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 378 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
388 mSyncManager->fillSyncMenu(); 379 mSyncManager->fillSyncMenu();
389 380
390 381
391 382
392 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 383 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
393 if ( showWarning ) { 384 if ( showWarning ) {
394 KMessageBox::information( this, 385 KMessageBox::information( this,
395 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 386 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
396 qApp->processEvents(); 387 qApp->processEvents();
397 mView->dialogManager()->showSyncOptions(); 388 mView->dialogManager()->showSyncOptions();
398 } 389 }
399 390
400 //US listen for result adressed from Ka/Pi 391 //US listen for result adressed from Ka/Pi
401#ifndef DESKTOP_VERSION 392
402 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
403#endif
404#ifndef DESKTOP_VERSION 393#ifndef DESKTOP_VERSION
405 infrared = 0; 394 infrared = 0;
406#endif 395#endif
407 updateFilterToolbar(); 396 updateFilterToolbar();
408 updateWeek( mView->startDate() ); 397 updateWeek( mView->startDate() );
409 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 398 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
410 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 399 SLOT( updateWeekNum( const KCal::DateList & ) ) );
411 mBRdisabled = false; 400 mBRdisabled = false;
412 //toggleBeamReceive(); 401 //toggleBeamReceive();
413 402
414 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); 403 setCaption(i18n("Loading calendar files ... please wait" ));
404 QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() ));
415} 405}
416MainWindow::~MainWindow() 406MainWindow::~MainWindow()
417{ 407{
418 //qDebug("MainWindow::~MainWindow() "); 408 //qDebug("MainWindow::~MainWindow() ");
419 //save toolbar location 409 //save toolbar location
420 delete mCalendar; 410 delete mCalendar;
421 delete mSyncManager; 411 delete mSyncManager;
422#ifndef DESKTOP_VERSION 412#ifndef DESKTOP_VERSION
423 if ( infrared ) 413 if ( infrared )
424 delete infrared; 414 delete infrared;
425#endif 415#endif
426 416
427 417
428} 418}
419
420void MainWindow::loadDataAfterStart()
421{
422
423 qDebug("KO: Start loading files..." );
424 QTime neededSaveTime = QDateTime::currentDateTime().time();
425 mView->loadCalendars();
426 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
427 qDebug("KO: Calendar loading time: %d ms",msNeeded );
428 //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
429 mView->setModified( false );
430 mBlockAtStartup = false;
431 mView->setModified( false );
432 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
433 processIncidenceSelection( 0 );
434 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
435 SLOT( processIncidenceSelection( Incidence * ) ) );
436 connect( mView, SIGNAL( modifiedChanged( bool ) ),
437 SLOT( slotModifiedChanged( bool ) ) );
438
439#ifndef DESKTOP_VERSION
440 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
441 connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& )));
442 disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& )));
443 if ( !mCStringMess.isEmpty() )
444 recieve( mCStringMess, mByteData );
445#endif
446
447
448 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
449}
450
429void MainWindow::slotResetFocus() 451void MainWindow::slotResetFocus()
430{ 452{
431 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); 453 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar);
432 mFocusLoop = 3; 454 mFocusLoop = 3;
433 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 455 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
434} 456}
435void MainWindow::slotResetFocusLoop() 457void MainWindow::slotResetFocusLoop()
436{ 458{
437 --mFocusLoop; 459 --mFocusLoop;
438 QWidget* fw = mView->viewManager()->currentView(); 460 QWidget* fw = mView->viewManager()->currentView();
439 if ( fw ) { 461 if ( fw ) {
440 //qDebug("loop "); 462 //qDebug("loop ");
441 fw->setFocus(); 463 fw->setFocus();
442 if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) 464 if ( qApp->focusWidget() != fw && mFocusLoop > 0 )
443 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 465 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
444 } 466 }
445 467
446} 468}
447void MainWindow::disableBR(bool b) 469void MainWindow::disableBR(bool b)
448{ 470{
449#ifndef DESKTOP_VERSION 471#ifndef DESKTOP_VERSION
450 if ( b ) { 472 if ( b ) {
451 if ( infrared ) { 473 if ( infrared ) {
452 toggleBeamReceive(); 474 toggleBeamReceive();
453 mBRdisabled = true; 475 mBRdisabled = true;
454 } 476 }
455 mBRdisabled = true; 477 mBRdisabled = true;
456 } else { 478 } else {
457 if ( mBRdisabled ) { 479 if ( mBRdisabled ) {
458 mBRdisabled = false; 480 mBRdisabled = false;
459 //makes no sense,because other cal ap is probably running 481 //makes no sense,because other cal ap is probably running
460 // toggleBeamReceive(); 482 // toggleBeamReceive();
461 } 483 }
462 } 484 }
463#endif 485#endif
464 486
465} 487}
466bool MainWindow::beamReceiveEnabled() 488bool MainWindow::beamReceiveEnabled()
467{ 489{
468#ifndef DESKTOP_VERSION 490#ifndef DESKTOP_VERSION
469 return ( infrared != 0 ); 491 return ( infrared != 0 );
470#endif 492#endif
471 return false; 493 return false;
472} 494}
473 495
474void MainWindow::toggleBeamReceive() 496void MainWindow::toggleBeamReceive()
475{ 497{
476 if ( mBRdisabled ) 498 if ( mBRdisabled )
477 return; 499 return;
478#ifndef DESKTOP_VERSION 500#ifndef DESKTOP_VERSION
479 if ( infrared ) { 501 if ( infrared ) {
480 qDebug("KO: Disable BeamReceive "); 502 qDebug("KO: Disable BeamReceive ");
481 delete infrared; 503 delete infrared;
482 infrared = 0; 504 infrared = 0;
483 brAction->setOn(false); 505 brAction->setOn(false);
484 return; 506 return;
485 } 507 }
486 qDebug("KO: Enable BeamReceive "); 508 qDebug("KO: Enable BeamReceive ");
487 brAction->setOn(true); 509 brAction->setOn(true);
488 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 510 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
489 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 511 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
490#endif 512#endif
491} 513}
492void MainWindow::showMaximized () 514void MainWindow::showMaximized ()
493{ 515{
494#ifndef DESKTOP_VERSION 516#ifndef DESKTOP_VERSION
495 if ( ! globalFlagBlockStartup ) 517 if ( ! globalFlagBlockStartup )
496 if ( mClosed ) 518 if ( mClosed )
497 mView->goToday(); 519 mView->goToday();
498#endif 520#endif
499 QWidget::showMaximized () ; 521 QWidget::showMaximized () ;
500 mClosed = false; 522 mClosed = false;
501} 523}
502void MainWindow::closeEvent( QCloseEvent* ce ) 524void MainWindow::closeEvent( QCloseEvent* ce )
503{ 525{
504 526
505 527
506 528
507 if ( ! KOPrefs::instance()->mAskForQuit ) { 529 if ( ! KOPrefs::instance()->mAskForQuit ) {
508 saveOnClose(); 530 saveOnClose();
509 if ( mCalendarModifiedFlag ) { 531 if ( mCalendarModifiedFlag ) {
510 ce->ignore(); 532 ce->ignore();
511 return; 533 return;
512 } 534 }
513 mClosed = true; 535 mClosed = true;
514 ce->accept(); 536 ce->accept();
515 return; 537 return;
516 538
517 } 539 }
518 540
519 switch( QMessageBox::information( this, "KO/Pi", 541 switch( QMessageBox::information( this, "KO/Pi",
520 i18n("Do you really want\nto close KO/Pi?"), 542 i18n("Do you really want\nto close KO/Pi?"),
521 i18n("Close"), i18n("No"), 543 i18n("Close"), i18n("No"),
522 0, 0 ) ) { 544 0, 0 ) ) {
523 case 0: 545 case 0:
524 saveOnClose(); 546 saveOnClose();
525 if ( mCalendarModifiedFlag ) { 547 if ( mCalendarModifiedFlag ) {
526 ce->ignore(); 548 ce->ignore();
527 return; 549 return;
528 } 550 }
529 mClosed = true; 551 mClosed = true;
530 ce->accept(); 552 ce->accept();
531 break; 553 break;
532 case 1: 554 case 1:
533 ce->ignore(); 555 ce->ignore();
534 break; 556 break;
535 case 2: 557 case 2:
536 558
537 default: 559 default:
538 break; 560 break;
539 } 561 }
540 562
541 563
542} 564}
543 565void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data )
566{
567 qDebug("KO: QCOP start message received: %s ", cmsg.data() );
568 mCStringMess = cmsg;
569 mByteData = data;
570}
544void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 571void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
545{ 572{
546 QDataStream stream( data, IO_ReadOnly ); 573 QDataStream stream( data, IO_ReadOnly );
547 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 574 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
548 //QString datamess; 575 //QString datamess;
549 //qDebug("message "); 576 //qDebug("message ");
550 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 577 qDebug("KO: QCOP message received: %s ", cmsg.data() );
551 578
552 if ( cmsg == "setDocument(QString)" ) { 579 if ( cmsg == "setDocument(QString)" ) {
553 QDataStream stream( data, IO_ReadOnly ); 580 QDataStream stream( data, IO_ReadOnly );
554 QString fileName; 581 QString fileName;
555 stream >> fileName; 582 stream >> fileName;
556 //qDebug("filename %s ", fileName.latin1()); 583 //qDebug("filename %s ", fileName.latin1());
557 showMaximized(); 584 showMaximized();
558 raise(); 585 raise();
559 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 586 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
560 mSyncManager->slotSyncMenu( 1002 ); 587 mSyncManager->slotSyncMenu( 1002 );
561 return; 588 return;
562 } 589 }
563 590
564 if ( cmsg == "-writeFile" ) { 591 if ( cmsg == "-writeFile" ) {
565 // I made from the "-writeFile" an "-writeAlarm" 592 // I made from the "-writeFile" an "-writeAlarm"
566 mView->viewManager()->showWhatsNextView(); 593 mView->viewManager()->showWhatsNextView();
567 mCalendar->checkAlarmForIncidence( 0, true); 594 mCalendar->checkAlarmForIncidence( 0, true);
568 showMaximized(); 595 showMaximized();
569 raise(); 596 raise();
570 return; 597 return;
571 598
572 } 599 }
573 if ( cmsg == "-writeFileSilent" ) { 600 if ( cmsg == "-writeFileSilent" ) {
574 // I made from the "-writeFile" an "-writeAlarm" 601 // I made from the "-writeFile" an "-writeAlarm"
575 // mView->viewManager()->showWhatsNextView(); 602 // mView->viewManager()->showWhatsNextView();
576 mCalendar->checkAlarmForIncidence( 0, true); 603 mCalendar->checkAlarmForIncidence( 0, true);
577 //showMaximized(); 604 //showMaximized();
578 //raise(); 605 //raise();
579 hide(); 606 hide();
580 return; 607 return;
581 } 608 }
582 if ( cmsg == "-newCountdown" ) { 609 if ( cmsg == "-newCountdown" ) {
583 qDebug("newCountdown "); 610 qDebug("newCountdown ");
584 611
585 } 612 }
586 QString msg ; 613 QString msg ;
587 QString allmsg = cmsg; 614 QString allmsg = cmsg;
588 while ( allmsg.length() > 0 ) { 615 while ( allmsg.length() > 0 ) {
589 int nextC = allmsg.find( "-", 1 ); 616 int nextC = allmsg.find( "-", 1 );
590 if ( nextC == -1 ) { 617 if ( nextC == -1 ) {
591 msg = allmsg; 618 msg = allmsg;
592 allmsg = ""; 619 allmsg = "";
593 } else{ 620 } else{
594 msg = allmsg.left( nextC ); 621 msg = allmsg.left( nextC );
595 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 622 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
596 } 623 }
597 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 624 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
598 if ( msg == "-newEvent" ) { 625 if ( msg == "-newEvent" ) {
599 QTimer::singleShot( 0, mView, SLOT ( newEvent())); 626 QTimer::singleShot( 0, mView, SLOT ( newEvent()));
600 } 627 }
601 if ( msg == "-newTodo" ) { 628 if ( msg == "-newTodo" ) {
602 QTimer::singleShot( 0, mView, SLOT ( newTodo())); 629 QTimer::singleShot( 0, mView, SLOT ( newTodo()));
603 } 630 }
604 if ( msg == "-showWN" ) { 631 if ( msg == "-showWN" ) {
605 mView->viewManager()->showWhatsNextView(); 632 mView->viewManager()->showWhatsNextView();
606 } 633 }
607 if ( msg == "-showTodo" ) { 634 if ( msg == "-showTodo" ) {
608 mView->viewManager()->showTodoView(); 635 mView->viewManager()->showTodoView();
609 } 636 }
610 if ( msg == "-showList" ) { 637 if ( msg == "-showList" ) {
611 mView->viewManager()->showListView(); 638 mView->viewManager()->showListView();
612 } 639 }
613 else if ( msg == "-showDay" ) { 640 else if ( msg == "-showDay" ) {
614 mView->viewManager()->showDayView(); 641 mView->viewManager()->showDayView();
615 } 642 }
616 else if ( msg == "-showWWeek" ) { 643 else if ( msg == "-showWWeek" ) {
617 mView->viewManager()->showWorkWeekView(); 644 mView->viewManager()->showWorkWeekView();
618 } 645 }
619 else if ( msg == "-ringSync" ) { 646 else if ( msg == "-ringSync" ) {
620 QTimer::singleShot( 0, this, SLOT (startMultiSync())); 647 QTimer::singleShot( 0, this, SLOT (startMultiSync()));
621 } 648 }
622 else if ( msg == "-showWeek" ) { 649 else if ( msg == "-showWeek" ) {
623 mView->viewManager()->showWeekView(); 650 mView->viewManager()->showWeekView();
624 } 651 }
625 else if ( msg == "-showTodo" ) { 652 else if ( msg == "-showTodo" ) {
626 mView->viewManager()->showTodoView(); 653 mView->viewManager()->showTodoView();
627 } 654 }
628 else if ( msg == "-showJournal" ) { 655 else if ( msg == "-showJournal" ) {
629 mView->dateNavigator()->selectDates( 1 ); 656 mView->dateNavigator()->selectDates( 1 );
630 mView->dateNavigator()->selectToday(); 657 mView->dateNavigator()->selectToday();
631 mView->viewManager()->showJournalView(); 658 mView->viewManager()->showJournalView();
632 } 659 }
633 else if ( msg == "-showKO" ) { 660 else if ( msg == "-showKO" ) {
634 mView->viewManager()->showNextXView(); 661 mView->viewManager()->showNextXView();
635 } 662 }
636 else if ( msg == "-showWNext" ) { 663 else if ( msg == "-showWNext" ) {
637 mView->viewManager()->showWhatsNextView(); 664 mView->viewManager()->showWhatsNextView();
638 } 665 }
639 else if ( msg == "nextView()" ) { 666 else if ( msg == "nextView()" ) {
640 mView->viewManager()->showNextView(); 667 mView->viewManager()->showNextView();
641 } 668 }
642 else if ( msg == "-showNextXView" ) { 669 else if ( msg == "-showNextXView" ) {
643 mView->viewManager()->showNextXView(); 670 mView->viewManager()->showNextXView();
644 } 671 }
645 672
646 673
647 } 674 }
648 675
649 showMaximized(); 676 showMaximized();
650 raise(); 677 raise();
651} 678}
652void MainWindow::startMultiSync() 679void MainWindow::startMultiSync()
653{ 680{
654 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 681 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
655 if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), 682 if ( QMessageBox::information( this, i18n("KDE-Pim Sync"),
656 question, 683 question,
657 i18n("Yes"), i18n("No"), 684 i18n("Yes"), i18n("No"),
658 0, 0 ) != 0 ) { 685 0, 0 ) != 0 ) {
659 setCaption(i18n("Aborted! Nothing synced!")); 686 setCaption(i18n("Aborted! Nothing synced!"));
660 return; 687 return;
661 } 688 }
662 mSyncManager->multiSync( false ); 689 mSyncManager->multiSync( false );
663#ifndef DESKTOP_VERSION 690#ifndef DESKTOP_VERSION
664 QCopEnvelope e("QPE/Application/kapi", "doRingSync"); 691 QCopEnvelope e("QPE/Application/kapi", "doRingSync");
665#endif 692#endif
666} 693}
667QPixmap MainWindow::loadPixmap( QString name ) 694QPixmap MainWindow::loadPixmap( QString name )
668{ 695{
669 return SmallIcon( name ); 696 return SmallIcon( name );
670 697
671} 698}
672void MainWindow::setUsesBigPixmaps ( bool b ) 699void MainWindow::setUsesBigPixmaps ( bool b )
673{ 700{
674 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); 701 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b);
675 if ( b ) 702 if ( b )
676 qDebug("KO: BigPixmaps are not supported "); 703 qDebug("KO: BigPixmaps are not supported ");
677} 704}
678void MainWindow::initActions() 705void MainWindow::initActions()
679{ 706{
680 //KOPrefs::instance()->mShowFullMenu 707 //KOPrefs::instance()->mShowFullMenu
681 iconToolBar->clear(); 708 iconToolBar->clear();
682 KOPrefs *p = KOPrefs::instance(); 709 KOPrefs *p = KOPrefs::instance();
683 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 710 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
684 711
685 QPopupMenu *viewMenu = new QPopupMenu( this ); 712 QPopupMenu *viewMenu = new QPopupMenu( this );
686 QPopupMenu *actionMenu = new QPopupMenu( this ); 713 QPopupMenu *actionMenu = new QPopupMenu( this );
687 mCurrentItemMenu = new QPopupMenu ( this ); 714 mCurrentItemMenu = new QPopupMenu ( this );
688 QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); 715 QPopupMenu *nextConflictMenu = new QPopupMenu ( this );
689 QPopupMenu *importMenu = new QPopupMenu( this ); 716 QPopupMenu *importMenu = new QPopupMenu( this );
690 QPopupMenu *importMenu_X = new QPopupMenu( this ); 717 QPopupMenu *importMenu_X = new QPopupMenu( this );
691 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 718 QPopupMenu *exportMenu_X = new QPopupMenu( this );
692 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 719 QPopupMenu *beamMenu_X = new QPopupMenu( this );
693 selectFilterMenu = new QPopupMenu( this ); 720 selectFilterMenu = new QPopupMenu( this );
694 selectFilterMenu->setCheckable( true ); 721 selectFilterMenu->setCheckable( true );
695 syncMenu = new QPopupMenu( this ); 722 syncMenu = new QPopupMenu( this );
696 configureAgendaMenu = new QPopupMenu( this ); 723 configureAgendaMenu = new QPopupMenu( this );
697 configureToolBarMenu = new QPopupMenu( this ); 724 configureToolBarMenu = new QPopupMenu( this );
698 QPopupMenu *helpMenu = new QPopupMenu( this ); 725 QPopupMenu *helpMenu = new QPopupMenu( this );
699 QIconSet icon; 726 QIconSet icon;
700 int pixWid = 22, pixHei = 22; 727 int pixWid = 22, pixHei = 22;
701 QString pathString = ""; 728 QString pathString = "";
702 if ( !p->mToolBarMiniIcons ) { 729 if ( !p->mToolBarMiniIcons ) {
703 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { 730 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) {
704 pathString += "icons16/"; 731 pathString += "icons16/";
705 pixWid = 18; pixHei = 16; 732 pixWid = 18; pixHei = 16;
706 } 733 }
707 } else { 734 } else {
708 pathString += "iconsmini/"; 735 pathString += "iconsmini/";
709 pixWid = 18; pixHei = 16; 736 pixWid = 18; pixHei = 16;
710 } 737 }
711 738
712 if ( KOPrefs::instance()->mShowFullMenu ) { 739 if ( KOPrefs::instance()->mShowFullMenu ) {
713 menuBar1 = new KMenuBar( this );//menuBar(); 740 menuBar1 = new KMenuBar( this );//menuBar();
714 //setMenuBar( menuBar1 ); 741 //setMenuBar( menuBar1 );
715 menuBar1->show(); 742 menuBar1->show();
716 menuBar1->insertItem( i18n("File"), importMenu ); 743 menuBar1->insertItem( i18n("File"), importMenu );
717 menuBar1->insertItem( i18n("View"), viewMenu ); 744 menuBar1->insertItem( i18n("View"), viewMenu );
718 menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); 745 menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu );
719 menuBar1->insertItem( i18n("Action"), actionMenu ); 746 menuBar1->insertItem( i18n("Action"), actionMenu );
720#ifdef DESKTOP_VERSION 747#ifdef DESKTOP_VERSION
721 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 748 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
722 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 749 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
723#else 750#else
724 menuBar1->insertItem( i18n("Sync"), syncMenu ); 751 menuBar1->insertItem( i18n("Sync"), syncMenu );
725 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 752 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
726#endif 753#endif
727 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 754 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
728 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 755 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
729 menuBar1->insertItem( i18n("Help"), helpMenu ); 756 menuBar1->insertItem( i18n("Help"), helpMenu );
730 } else { 757 } else {
731 menuBar1 = new KMenuBar( iconToolBar ); 758 menuBar1 = new KMenuBar( iconToolBar );
732 QPopupMenu *menuBar = new QPopupMenu( this ); 759 QPopupMenu *menuBar = new QPopupMenu( this );
733 icon = loadPixmap( pathString + "z_menu" ); 760 icon = loadPixmap( pathString + "z_menu" );
734 menuBar1->insertItem( icon.pixmap(), menuBar); 761 menuBar1->insertItem( icon.pixmap(), menuBar);
735 //menuBar1->insertItem( i18n("ME"), menuBar); 762 //menuBar1->insertItem( i18n("ME"), menuBar);
736 menuBar->insertItem( i18n("File"), importMenu ); 763 menuBar->insertItem( i18n("File"), importMenu );
737 menuBar->insertItem( i18n("View"), viewMenu ); 764 menuBar->insertItem( i18n("View"), viewMenu );
738 menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); 765 menuBar->insertItem( i18n("Edit"), mCurrentItemMenu );
739 menuBar->insertItem( i18n("Action"), actionMenu ); 766 menuBar->insertItem( i18n("Action"), actionMenu );
740 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 767 menuBar->insertItem( i18n("Synchronize"), syncMenu );
741 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 768 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
742 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 769 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
743 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 770 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
744 menuBar->insertItem( i18n("Help"), helpMenu ); 771 menuBar->insertItem( i18n("Help"), helpMenu );
745 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 772 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
746 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 773 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
747 connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) ); 774 connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) );
748 } 775 }
749 connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); 776 connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) );
750 //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); 777 //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) );
751 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 778 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
752 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 779 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
753 780
754 781
755 mWeekBgColor = iconToolBar->backgroundColor(); 782 mWeekBgColor = iconToolBar->backgroundColor();
756 mWeekPixmap.resize( pixWid , pixHei ); 783 mWeekPixmap.resize( pixWid , pixHei );
757 mWeekPixmap.fill( mWeekBgColor ); 784 mWeekPixmap.fill( mWeekBgColor );
758 icon = mWeekPixmap; 785 icon = mWeekPixmap;
759 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 786 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
760 if ( p-> mShowIconWeekNum ) 787 if ( p-> mShowIconWeekNum )
761 mWeekAction->addTo( iconToolBar ); 788 mWeekAction->addTo( iconToolBar );
762 mWeekFont = font(); 789 mWeekFont = font();
763 790
764 int fontPoint = mWeekFont.pointSize(); 791 int fontPoint = mWeekFont.pointSize();
765 QFontMetrics f( mWeekFont ); 792 QFontMetrics f( mWeekFont );
766 int fontWid = f.width( "30" ); 793 int fontWid = f.width( "30" );
767 while ( fontWid > pixWid ) { 794 while ( fontWid > pixWid ) {
768 --fontPoint; 795 --fontPoint;
769 mWeekFont.setPointSize( fontPoint ); 796 mWeekFont.setPointSize( fontPoint );
770 QFontMetrics f( mWeekFont ); 797 QFontMetrics f( mWeekFont );
771 fontWid = f.width( "30" ); 798 fontWid = f.width( "30" );
772 //qDebug("dec-- "); 799 //qDebug("dec-- ");
773 } 800 }
774 801
775 connect( mWeekAction, SIGNAL( activated() ), 802 connect( mWeekAction, SIGNAL( activated() ),
776 this, SLOT( weekAction() ) ); 803 this, SLOT( weekAction() ) );
777 804
778 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 805 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
779 if ( p->mShowIconFilterview ) { 806 if ( p->mShowIconFilterview ) {
780 icon = loadPixmap( pathString + "filter" ); 807 icon = loadPixmap( pathString + "filter" );
781 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); 808 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this );
782 connect( actionFilterMenuTB, SIGNAL( activated() ), 809 connect( actionFilterMenuTB, SIGNAL( activated() ),
783 this, SLOT( fillFilterMenuTB() ) ); 810 this, SLOT( fillFilterMenuTB() ) );
784 actionFilterMenuTB->addTo( iconToolBar ); 811 actionFilterMenuTB->addTo( iconToolBar );
785 selectFilterMenuTB = new QPopupMenu( this ); 812 selectFilterMenuTB = new QPopupMenu( this );
786 selectFilterMenuTB->setCheckable( true ); 813 selectFilterMenuTB->setCheckable( true );
787 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 814 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
788 } 815 }
789 816
790 //#endif 817 //#endif
791 // ****************** 818 // ******************
792 QAction *action; 819 QAction *action;
793 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 820 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
794 configureToolBarMenu->setCheckable( true ); 821 configureToolBarMenu->setCheckable( true );
795 822
796 823
797 configureAgendaMenu->setCheckable( true ); 824 configureAgendaMenu->setCheckable( true );
798 int iii ; 825 int iii ;
799 for ( iii = 1;iii<= 10 ;++iii ){ 826 for ( iii = 1;iii<= 10 ;++iii ){
800 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 827 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
801 } 828 }
802 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 829 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
803 830
804 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 831 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
805 this, SLOT( showConfigureAgenda( ) ) ); 832 this, SLOT( showConfigureAgenda( ) ) );
806 icon = loadPixmap( pathString + "today" ); 833 icon = loadPixmap( pathString + "today" );
807 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 834 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
808 today_action->addTo( actionMenu ); 835 today_action->addTo( actionMenu );
809 connect( today_action, SIGNAL( activated() ), 836 connect( today_action, SIGNAL( activated() ),
810 mView, SLOT( goToday() ) ); 837 mView, SLOT( goToday() ) );
811 838
812 icon = loadPixmap( pathString + "picker" ); 839 icon = loadPixmap( pathString + "picker" );
813 QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); 840 QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this );
814 dPickerAction->addTo( actionMenu ); 841 dPickerAction->addTo( actionMenu );
815 connect( dPickerAction, SIGNAL( activated() ), 842 connect( dPickerAction, SIGNAL( activated() ),
816 mView, SLOT( showDatePicker() ) ); 843 mView, SLOT( showDatePicker() ) );
817 844
818 icon = loadPixmap( pathString + "search" ); 845 icon = loadPixmap( pathString + "search" );
819 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 846 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
820 search_action->addTo( actionMenu ); 847 search_action->addTo( actionMenu );
821 connect( search_action, SIGNAL( activated() ), 848 connect( search_action, SIGNAL( activated() ),
822 mView->dialogManager(), SLOT( showSearchDialog() ) ); 849 mView->dialogManager(), SLOT( showSearchDialog() ) );
823 actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu ); 850 actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu );
824 851
825 action = new QAction( "Undo Delete", i18n("All events"), 0, this ); 852 action = new QAction( "Undo Delete", i18n("All events"), 0, this );
826 action->addTo( nextConflictMenu ); 853 action->addTo( nextConflictMenu );
827 connect( action, SIGNAL( activated() ), 854 connect( action, SIGNAL( activated() ),
828 mView, SLOT( conflictAll() ) ); 855 mView, SLOT( conflictAll() ) );
829 856
830 action = new QAction( "Undo Delete", i18n("Allday events"), 0, this ); 857 action = new QAction( "Undo Delete", i18n("Allday events"), 0, this );
831 action->addTo( nextConflictMenu ); 858 action->addTo( nextConflictMenu );
832 connect( action, SIGNAL( activated() ), 859 connect( action, SIGNAL( activated() ),
833 mView, SLOT( conflictAllday() ) ); 860 mView, SLOT( conflictAllday() ) );
834 861
835 action = new QAction( "Undo Delete", i18n("Events with time"), 0, this ); 862 action = new QAction( "Undo Delete", i18n("Events with time"), 0, this );
836 action->addTo( nextConflictMenu ); 863 action->addTo( nextConflictMenu );
837 connect( action, SIGNAL( activated() ), 864 connect( action, SIGNAL( activated() ),
838 mView, SLOT( conflictNotAll() ) ); 865 mView, SLOT( conflictNotAll() ) );
839 866
840 actionMenu->insertSeparator(); 867 actionMenu->insertSeparator();
841 868
842 icon = loadPixmap( pathString + "newevent" ); 869 icon = loadPixmap( pathString + "newevent" );
843 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 870 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
844 ne_action->addTo( mCurrentItemMenu ); 871 ne_action->addTo( mCurrentItemMenu );
845 connect( ne_action, SIGNAL( activated() ), 872 connect( ne_action, SIGNAL( activated() ),
846 mView, SLOT( newEvent() ) ); 873 mView, SLOT( newEvent() ) );
847 icon = loadPixmap( pathString + "newtodo" ); 874 icon = loadPixmap( pathString + "newtodo" );
848 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 875 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
849 nt_action->addTo( mCurrentItemMenu ); 876 nt_action->addTo( mCurrentItemMenu );
850 connect( nt_action, SIGNAL( activated() ), 877 connect( nt_action, SIGNAL( activated() ),
851 mView, SLOT( newTodo() ) ); 878 mView, SLOT( newTodo() ) );
852 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 879 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
853 this ); 880 this );
854 mNewSubTodoAction->addTo( mCurrentItemMenu ); 881 mNewSubTodoAction->addTo( mCurrentItemMenu );
855 connect( mNewSubTodoAction, SIGNAL( activated() ), 882 connect( mNewSubTodoAction, SIGNAL( activated() ),
856 mView, SLOT( newSubTodo() ) ); 883 mView, SLOT( newSubTodo() ) );
857 884
858 mCurrentItemMenu->insertSeparator(); 885 mCurrentItemMenu->insertSeparator();
859 icon = loadPixmap( pathString + "newevent" ); 886 icon = loadPixmap( pathString + "newevent" );
860 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 887 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
861 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); 888 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 );
862 configureToolBarMenu->insertSeparator(); 889 configureToolBarMenu->insertSeparator();
863 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); 890 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 );
864 configureToolBarMenu->insertSeparator(); 891 configureToolBarMenu->insertSeparator();
865 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 892 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
866 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 893 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
867 icon = loadPixmap( pathString + "newtodo" ); 894 icon = loadPixmap( pathString + "newtodo" );
868 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 895 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
869 896
870 //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); 897 //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu);
871 mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); 898 mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this );
872 mShowAction->addTo( mCurrentItemMenu ); 899 mShowAction->addTo( mCurrentItemMenu );
873 connect( mShowAction, SIGNAL( activated() ), 900 connect( mShowAction, SIGNAL( activated() ),
874 mView, SLOT( showIncidence() ) ); 901 mView, SLOT( showIncidence() ) );
875 902
876 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 903 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
877 mEditAction->addTo( mCurrentItemMenu ); 904 mEditAction->addTo( mCurrentItemMenu );
878 connect( mEditAction, SIGNAL( activated() ), 905 connect( mEditAction, SIGNAL( activated() ),
879 mView, SLOT( editIncidence() ) ); 906 mView, SLOT( editIncidence() ) );
880 907
881 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 908 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
882 mDeleteAction->addTo( mCurrentItemMenu ); 909 mDeleteAction->addTo( mCurrentItemMenu );
883 connect( mDeleteAction, SIGNAL( activated() ), 910 connect( mDeleteAction, SIGNAL( activated() ),
884 mView, SLOT( deleteIncidence() ) ); 911 mView, SLOT( deleteIncidence() ) );
885 912
886 913
887 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 914 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
888 mCloneAction->addTo( mCurrentItemMenu ); 915 mCloneAction->addTo( mCurrentItemMenu );
889 connect( mCloneAction, SIGNAL( activated() ), 916 connect( mCloneAction, SIGNAL( activated() ),
890 mView, SLOT( cloneIncidence() ) ); 917 mView, SLOT( cloneIncidence() ) );
891 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 918 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
892 mMoveAction->addTo( mCurrentItemMenu ); 919 mMoveAction->addTo( mCurrentItemMenu );
893 connect( mMoveAction, SIGNAL( activated() ), 920 connect( mMoveAction, SIGNAL( activated() ),
894 mView, SLOT( moveIncidence() ) ); 921 mView, SLOT( moveIncidence() ) );
895#ifndef DESKTOP_VERSION 922#ifndef DESKTOP_VERSION
896 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 923 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
897 mBeamAction->addTo(mCurrentItemMenu ); 924 mBeamAction->addTo(mCurrentItemMenu );
898 connect( mBeamAction, SIGNAL( activated() ), 925 connect( mBeamAction, SIGNAL( activated() ),
899 mView, SLOT( beamIncidence() ) ); 926 mView, SLOT( beamIncidence() ) );
900#endif 927#endif
901 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 928 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
902 mCancelAction->addTo( mCurrentItemMenu ); 929 mCancelAction->addTo( mCurrentItemMenu );
903 connect( mCancelAction, SIGNAL( activated() ), 930 connect( mCancelAction, SIGNAL( activated() ),
904 mView, SLOT( toggleCancelIncidence() ) ); 931 mView, SLOT( toggleCancelIncidence() ) );
905 932
906 933
907 mCurrentItemMenu->insertSeparator(); 934 mCurrentItemMenu->insertSeparator();
908 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 935 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
909 action->addTo( mCurrentItemMenu ); 936 action->addTo( mCurrentItemMenu );
910 connect( action, SIGNAL( activated() ), 937 connect( action, SIGNAL( activated() ),
911 mView, SLOT( undo_delete() ) ); 938 mView, SLOT( undo_delete() ) );
912 939
913 // *********************** 940 // ***********************
914 if ( KOPrefs::instance()->mVerticalScreen ) { 941 if ( KOPrefs::instance()->mVerticalScreen ) {
915 icon = SmallIcon( "1updownarrow" ); 942 icon = SmallIcon( "1updownarrow" );
916 } else { 943 } else {
917 icon = SmallIcon("1leftrightarrow" ); 944 icon = SmallIcon("1leftrightarrow" );
918 } 945 }
919 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); 946 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 );
920 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); 947 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this );
921 FSaction->addTo( viewMenu ); 948 FSaction->addTo( viewMenu );
922 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); 949 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() ));
923 950
924 951
925 icon = loadPixmap( pathString + "filter" ); 952 icon = loadPixmap( pathString + "filter" );
926 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); 953 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 );
927 icon = loadPixmap( pathString + "configure" ); 954 icon = loadPixmap( pathString + "configure" );
928 action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); 955 action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this );
929 action->addTo( viewMenu ); 956 action->addTo( viewMenu );
930 connect( action, SIGNAL( activated() ), 957 connect( action, SIGNAL( activated() ),
931 mView, SLOT( toggleFilter() ) ); 958 mView, SLOT( toggleFilter() ) );
932 mToggleFilter = action; 959 mToggleFilter = action;
933 icon = loadPixmap( pathString + "navi" ); 960 icon = loadPixmap( pathString + "navi" );
934 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); 961 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 );
935 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 962 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
936 action->addTo( viewMenu ); 963 action->addTo( viewMenu );
937 connect( action, SIGNAL( activated() ), 964 connect( action, SIGNAL( activated() ),
938 mView, SLOT( toggleDateNavigatorWidget() ) ); 965 mView, SLOT( toggleDateNavigatorWidget() ) );
939 mToggleNav = action ; 966 mToggleNav = action ;
940 icon = loadPixmap( pathString + "allday" ); 967 icon = loadPixmap( pathString + "allday" );
941 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); 968 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 );
942 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 969 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
943 action->addTo( viewMenu ); 970 action->addTo( viewMenu );
944 connect( action, SIGNAL( activated() ), 971 connect( action, SIGNAL( activated() ),
945 mView, SLOT( toggleAllDaySize() ) ); 972 mView, SLOT( toggleAllDaySize() ) );
946 mToggleAllday = action; 973 mToggleAllday = action;
947 974
948 975
949 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 976 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
950 mToggleNav, SLOT( setEnabled ( bool ) ) ); 977 mToggleNav, SLOT( setEnabled ( bool ) ) );
951 //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 978 //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
952 // mToggleFilter, SLOT( setEnabled ( bool ) ) ); 979 // mToggleFilter, SLOT( setEnabled ( bool ) ) );
953 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 980 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
954 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 981 mToggleAllday, SLOT( setEnabled ( bool ) ) );
955 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 982 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
956 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); 983 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) );
957 984
958 985
959 dPickerAction->addTo( iconToolBar ); 986 dPickerAction->addTo( iconToolBar );
960 viewMenu->insertSeparator(); 987 viewMenu->insertSeparator();
961 988
962 if ( p-> mShowIconToggleFull ) 989 if ( p-> mShowIconToggleFull )
963 FSaction->addTo( iconToolBar ); 990 FSaction->addTo( iconToolBar );
964 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); 991 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar );
965 992
966 //******************** 993 //********************
967 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); 994 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar );
968 995
969 996
970 icon = loadPixmap( pathString + "whatsnext" ); 997 icon = loadPixmap( pathString + "whatsnext" );
971 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); 998 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 );
972 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 999 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
973 whatsnext_action->addTo( viewMenu ); 1000 whatsnext_action->addTo( viewMenu );
974 connect( whatsnext_action, SIGNAL( activated() ), 1001 connect( whatsnext_action, SIGNAL( activated() ),
975 mView->viewManager(), SLOT( showWhatsNextView() ) ); 1002 mView->viewManager(), SLOT( showWhatsNextView() ) );
976 1003
977 icon = loadPixmap( pathString + "xdays" ); 1004 icon = loadPixmap( pathString + "xdays" );
978 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); 1005 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 );
979 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 1006 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
980 xdays_action->addTo( viewMenu ); 1007 xdays_action->addTo( viewMenu );
981 connect( xdays_action, SIGNAL( activated() ), 1008 connect( xdays_action, SIGNAL( activated() ),
982 mView->viewManager(), SLOT( showNextXView() ) ); 1009 mView->viewManager(), SLOT( showNextXView() ) );
983 1010
984 1011
985 icon = loadPixmap( pathString + "journal" ); 1012 icon = loadPixmap( pathString + "journal" );
986 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 1013 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
987 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 1014 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
988 viewjournal_action->addTo( viewMenu ); 1015 viewjournal_action->addTo( viewMenu );
989 connect( viewjournal_action, SIGNAL( activated() ), 1016 connect( viewjournal_action, SIGNAL( activated() ),
990 mView->viewManager(), SLOT( showJournalView() ) ); 1017 mView->viewManager(), SLOT( showJournalView() ) );
991 1018
992 1019
993 icon = loadPixmap( pathString + "day" ); 1020 icon = loadPixmap( pathString + "day" );
994 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 1021 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
995 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 1022 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
996 day1_action->addTo( viewMenu ); 1023 day1_action->addTo( viewMenu );
997 // action->addTo( toolBar ); 1024 // action->addTo( toolBar );
998 connect( day1_action, SIGNAL( activated() ), 1025 connect( day1_action, SIGNAL( activated() ),
999 mView->viewManager(), SLOT( showDayView() ) ); 1026 mView->viewManager(), SLOT( showDayView() ) );
1000 1027
1001 icon = loadPixmap( pathString + "workweek" ); 1028 icon = loadPixmap( pathString + "workweek" );
1002 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 1029 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
1003 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 1030 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
1004 day5_action->addTo( viewMenu ); 1031 day5_action->addTo( viewMenu );
1005 connect( day5_action, SIGNAL( activated() ), 1032 connect( day5_action, SIGNAL( activated() ),
1006 mView->viewManager(), SLOT( showWorkWeekView() ) ); 1033 mView->viewManager(), SLOT( showWorkWeekView() ) );
1007 1034
1008 icon = loadPixmap( pathString + "week" ); 1035 icon = loadPixmap( pathString + "week" );
1009 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 1036 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
1010 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 1037 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
1011 day7_action->addTo( viewMenu ); 1038 day7_action->addTo( viewMenu );
1012 connect( day7_action, SIGNAL( activated() ), 1039 connect( day7_action, SIGNAL( activated() ),
1013 mView->viewManager(), SLOT( showWeekView() ) ); 1040 mView->viewManager(), SLOT( showWeekView() ) );
1014 1041
1015 icon = loadPixmap( pathString + "workweek2" ); 1042 icon = loadPixmap( pathString + "workweek2" );
1016 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 1043 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
1017 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 1044 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
1018 day6_action->addTo( viewMenu ); 1045 day6_action->addTo( viewMenu );
1019 connect( day6_action, SIGNAL( activated() ), 1046 connect( day6_action, SIGNAL( activated() ),
1020 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 1047 mView->viewManager(), SLOT( showMonthViewWeek() ) );
1021 1048
1022 icon = loadPixmap( pathString + "month" ); 1049 icon = loadPixmap( pathString + "month" );
1023 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 1050 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
1024 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 1051 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
1025 month_action->addTo( viewMenu ); 1052 month_action->addTo( viewMenu );
1026 connect( month_action, SIGNAL( activated() ), 1053 connect( month_action, SIGNAL( activated() ),
1027 mView->viewManager(), SLOT( showMonthView() ) ); 1054 mView->viewManager(), SLOT( showMonthView() ) );
1028 1055
1029 icon = loadPixmap( pathString + "list" ); 1056 icon = loadPixmap( pathString + "list" );
1030 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 1057 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
1031 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 1058 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
1032 showlist_action->addTo( viewMenu ); 1059 showlist_action->addTo( viewMenu );
1033 connect( showlist_action, SIGNAL( activated() ), 1060 connect( showlist_action, SIGNAL( activated() ),
1034 mView->viewManager(), SLOT( showListView() ) ); 1061 mView->viewManager(), SLOT( showListView() ) );
1035 1062
1036 icon = loadPixmap( pathString + "todo" ); 1063 icon = loadPixmap( pathString + "todo" );
1037 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 1064 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
1038 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 1065 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
1039 todoview_action->addTo( viewMenu ); 1066 todoview_action->addTo( viewMenu );
1040 connect( todoview_action, SIGNAL( activated() ), 1067 connect( todoview_action, SIGNAL( activated() ),
1041 mView->viewManager(), SLOT( showTodoView() ) ); 1068 mView->viewManager(), SLOT( showTodoView() ) );
1042 1069
1043 1070
1044 1071
1045#if 0 1072#if 0
1046 action = new QAction( "view_timespan", "Time Span", 0, this ); 1073 action = new QAction( "view_timespan", "Time Span", 0, this );
1047 action->addTo( viewMenu ); 1074 action->addTo( viewMenu );
1048 connect( action, SIGNAL( activated() ), 1075 connect( action, SIGNAL( activated() ),
1049 mView->viewManager(), SLOT( showTimeSpanView() ) ); 1076 mView->viewManager(), SLOT( showTimeSpanView() ) );
1050#endif 1077#endif
1051 1078
1052 1079
1053 1080
1054 action = new QAction( "purge_completed", i18n("Purge Completed..."), 0, 1081 action = new QAction( "purge_completed", i18n("Purge Completed..."), 0,
1055 this ); 1082 this );
1056 action->addTo( actionMenu ); 1083 action->addTo( actionMenu );
1057 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 1084 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
1058 1085
1059 1086
1060 icon = loadPixmap( pathString + "search" ); 1087 icon = loadPixmap( pathString + "search" );
1061 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); 1088 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5);
1062 1089
1063 1090
1064 1091
1065 actionMenu->insertSeparator(); 1092 actionMenu->insertSeparator();
1066 action = new QAction( "manage cat", i18n("Edit category list..."), 0, 1093 action = new QAction( "manage cat", i18n("Edit category list..."), 0,
1067 this ); 1094 this );
1068 action->addTo( actionMenu ); 1095 action->addTo( actionMenu );
1069 connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) ); 1096 connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) );
1070 1097
1071 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 1098 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
1072 this ); 1099 this );
1073 action->addTo( actionMenu ); 1100 action->addTo( actionMenu );
1074 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 1101 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
1075 1102
1076 1103
1077 actionMenu->insertSeparator(); 1104 actionMenu->insertSeparator();
1078 icon = loadPixmap( pathString + "configure" ); 1105 icon = loadPixmap( pathString + "configure" );
1079 action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this ); 1106 action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this );
1080 action->addTo( actionMenu ); 1107 action->addTo( actionMenu );
1081 connect( action, SIGNAL( activated() ), 1108 connect( action, SIGNAL( activated() ),
1082 mView, SLOT( edit_options() ) ); 1109 mView, SLOT( edit_options() ) );
1083 action = new QAction( i18n("Configure"),icon, i18n("Configure Calendar Files..."), 0, this ); 1110 action = new QAction( i18n("Configure"),icon, i18n("Configure Calendar Files..."), 0, this );
1084 action->addTo( actionMenu ); 1111 action->addTo( actionMenu );
1085 connect( action, SIGNAL( activated() ), 1112 connect( action, SIGNAL( activated() ),
1086 this, SLOT( calHint() ) ); 1113 this, SLOT( calHint() ) );
1087 action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this ); 1114 action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this );
1088 action->addTo( actionMenu ); 1115 action->addTo( actionMenu );
1089 connect( action, SIGNAL( activated() ), 1116 connect( action, SIGNAL( activated() ),
1090 mView, SLOT( edit_global_options() ) ); 1117 mView, SLOT( edit_global_options() ) );
1091 if ( KOPrefs::instance()->mShowFullMenu ) { 1118 if ( KOPrefs::instance()->mShowFullMenu ) {
1092 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 1119 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
1093 1120
1094 } 1121 }
1095 // actionMenu->insertSeparator(); 1122 // actionMenu->insertSeparator();
1096 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 1123 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
1097 this ); 1124 this );
1098 action->addTo( importMenu_X ); 1125 action->addTo( importMenu_X );
1099 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 1126 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
1100 action = new QAction( "import_quick", i18n("Import last file"), 0, 1127 action = new QAction( "import_quick", i18n("Import last file"), 0,
1101 this ); 1128 this );
1102 action->addTo( importMenu_X ); 1129 action->addTo( importMenu_X );
1103 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 1130 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
1104 importMenu_X->insertSeparator(); 1131 importMenu_X->insertSeparator();
1105 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 1132 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
1106 this ); 1133 this );
1107 action->addTo( importMenu_X ); 1134 action->addTo( importMenu_X );
1108 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 1135 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
1109 //#ifndef DESKTOP_VERSION 1136 //#ifndef DESKTOP_VERSION
1110 importMenu_X->insertSeparator(); 1137 importMenu_X->insertSeparator();
1111 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 1138 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
1112 this ); 1139 this );
1113 action->addTo( importMenu_X ); 1140 action->addTo( importMenu_X );
1114 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 1141 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
1115 //#else 1142 //#else
1116#ifdef _OL_IMPORT_ 1143#ifdef _OL_IMPORT_
1117 importMenu_X->insertSeparator(); 1144 importMenu_X->insertSeparator();
1118 action = new QAction( "import_ol", i18n("Import from OL"), 0, 1145 action = new QAction( "import_ol", i18n("Import from OL"), 0,
1119 this ); 1146 this );
1120 action->addTo( importMenu_X ); 1147 action->addTo( importMenu_X );
1121 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 1148 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
1122#endif 1149#endif
1123 //#endif 1150 //#endif
1124 1151
1125 //importMenu->insertSeparator(); 1152 //importMenu->insertSeparator();
1126#if 0 1153#if 0
1127 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 1154 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
1128 this ); 1155 this );
1129 action->addTo( importMenu ); 1156 action->addTo( importMenu );
1130 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 1157 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
1131#endif 1158#endif
1132 action = new QAction( "save_cal", i18n("Save Backup..."), 0, 1159 action = new QAction( "save_cal", i18n("Save Backup..."), 0,
1133 this ); 1160 this );
1134 action->addTo( importMenu ); 1161 action->addTo( importMenu );
1135 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 1162 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
1136 importMenu->insertSeparator(); 1163 importMenu->insertSeparator();
1137 importMenu->insertItem( i18n("Import"), importMenu_X ); 1164 importMenu->insertItem( i18n("Import"), importMenu_X );
1138 //importMenu->insertSeparator(); 1165 //importMenu->insertSeparator();
1139 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 1166 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
1140 this ); 1167 this );
1141 action->addTo( exportMenu_X ); 1168 action->addTo( exportMenu_X );
1142 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 1169 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
1143 1170
1144 1171
1145 //LR 1172 //LR
1146 QPopupMenu *ex2phone = new QPopupMenu( this ); 1173 QPopupMenu *ex2phone = new QPopupMenu( this );
1147 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1174 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1148 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1175 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1149 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 1176 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
1150 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 1177 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
1151 1178
1152 importMenu->insertItem( i18n("Export"), exportMenu_X ); 1179 importMenu->insertItem( i18n("Export"), exportMenu_X );
1153 mPrintSelAction = 0; 1180 mPrintSelAction = 0;
1154#ifndef DESKTOP_VERSION 1181#ifndef DESKTOP_VERSION
1155 //importMenu->insertSeparator(); 1182 //importMenu->insertSeparator();
1156 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 1183 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
1157 this ); 1184 this );
1158 brAction->addTo( beamMenu_X ); 1185 brAction->addTo( beamMenu_X );
1159 brAction->setToggleAction (true ) ; 1186 brAction->setToggleAction (true ) ;
1160 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 1187 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
1161 1188
1162 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 1189 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
1163 this ); 1190 this );
1164 action->addTo( beamMenu_X ); 1191 action->addTo( beamMenu_X );
1165 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 1192 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
1166 1193
1167 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 1194 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
1168 this ); 1195 this );
1169 action->addTo( beamMenu_X ); 1196 action->addTo( beamMenu_X );
1170 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 1197 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
1171 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 1198 importMenu->insertItem( i18n("Beam"), beamMenu_X );
1172#else 1199#else
1173 //importMenu->insertSeparator(); 1200 //importMenu->insertSeparator();
1174 icon = loadPixmap( pathString + "print" ); 1201 icon = loadPixmap( pathString + "print" );
1175 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 1202 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
1176 action->addTo( beamMenu_X ); 1203 action->addTo( beamMenu_X );
1177 connect( action, SIGNAL( activated() ), 1204 connect( action, SIGNAL( activated() ),
1178 this, SLOT( printCal() ) ); 1205 this, SLOT( printCal() ) );
1179 1206
1180 icon = loadPixmap( pathString + "week" ); 1207 icon = loadPixmap( pathString + "week" );
1181 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 1208 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
1182 action->addTo( beamMenu_X ); 1209 action->addTo( beamMenu_X );
1183 connect( action, SIGNAL( activated() ), 1210 connect( action, SIGNAL( activated() ),
1184 this, SLOT( printSel() ) ); 1211 this, SLOT( printSel() ) );
1185 icon = loadPixmap( pathString + "whatsnext" ); 1212 icon = loadPixmap( pathString + "whatsnext" );
1186 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 1213 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
1187 action->addTo( beamMenu_X ); 1214 action->addTo( beamMenu_X );
1188 connect( action, SIGNAL( activated() ), 1215 connect( action, SIGNAL( activated() ),
1189 mView->viewManager(), SLOT( slotprintWNV() ) ); 1216 mView->viewManager(), SLOT( slotprintWNV() ) );
1190 1217
1191 1218
1192 icon = loadPixmap( pathString + "list" ); 1219 icon = loadPixmap( pathString + "list" );
1193 action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this ); 1220 action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this );
1194 action->addTo( beamMenu_X ); 1221 action->addTo( beamMenu_X );
1195 connect( action, SIGNAL( activated() ), 1222 connect( action, SIGNAL( activated() ),
1196 this, SLOT( printListView() ) ); 1223 this, SLOT( printListView() ) );
1197 1224
1198 icon = loadPixmap( pathString + "newevent" ); 1225 icon = loadPixmap( pathString + "newevent" );
1199 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); 1226 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this );
1200 action->addTo( beamMenu_X ); 1227 action->addTo( beamMenu_X );
1201 connect( action, SIGNAL( activated() ), 1228 connect( action, SIGNAL( activated() ),
1202 mView, SLOT( slotprintSelInc() ) ); 1229 mView, SLOT( slotprintSelInc() ) );
1203 mPrintSelAction = action; 1230 mPrintSelAction = action;
1204 importMenu->insertItem( i18n("Print"), beamMenu_X ); 1231 importMenu->insertItem( i18n("Print"), beamMenu_X );
1205#endif 1232#endif
1206 1233
1207 importMenu->insertSeparator(); 1234 importMenu->insertSeparator();
1208 action = new QAction( "beam all", i18n("Save"), 0, 1235 action = new QAction( "beam all", i18n("Save"), 0,
1209 this ); 1236 this );
1210 action->addTo( importMenu ); 1237 action->addTo( importMenu );
1211 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 1238 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
1212 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 1239 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
1213 this ); 1240 this );
1214 action->addTo( importMenu ); 1241 action->addTo( importMenu );
1215 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 1242 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
1216 1243
1217 //menuBar->insertItem( "Configure",configureMenu ); 1244 //menuBar->insertItem( "Configure",configureMenu );
1218 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 1245 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
1219 icon = loadPixmap( "korganizer/korganizer" ); 1246 icon = loadPixmap( "korganizer/korganizer" );
1220 1247
1221 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 1248 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
1222 action->addTo( helpMenu ); 1249 action->addTo( helpMenu );
1223 connect( action, SIGNAL( activated() ), 1250 connect( action, SIGNAL( activated() ),
1224 SLOT( whatsNew() ) ); 1251 SLOT( whatsNew() ) );
1225 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 1252 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
1226 action->addTo( helpMenu ); 1253 action->addTo( helpMenu );
1227 connect( action, SIGNAL( activated() ), 1254 connect( action, SIGNAL( activated() ),
1228 SLOT( features() ) ); 1255 SLOT( features() ) );
1229 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 1256 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
1230 action->addTo( helpMenu ); 1257 action->addTo( helpMenu );
1231 connect( action, SIGNAL( activated() ), 1258 connect( action, SIGNAL( activated() ),
1232 SLOT( keyBindings() ) ); 1259 SLOT( keyBindings() ) );
1233 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); 1260 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this );
1234 action->addTo( helpMenu ); 1261 action->addTo( helpMenu );
1235 connect( action, SIGNAL( activated() ), 1262 connect( action, SIGNAL( activated() ),
1236 SLOT( storagehowto() ) ); 1263 SLOT( storagehowto() ) );
1237 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); 1264 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this );
1238 action->addTo( helpMenu ); 1265 action->addTo( helpMenu );
1239 connect( action, SIGNAL( activated() ), 1266 connect( action, SIGNAL( activated() ),
1240 SLOT( timetrackinghowto() ) ); 1267 SLOT( timetrackinghowto() ) );
1241 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 1268 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
1242 action->addTo( helpMenu ); 1269 action->addTo( helpMenu );
1243 connect( action, SIGNAL( activated() ), 1270 connect( action, SIGNAL( activated() ),
1244 SLOT( synchowto() ) ); 1271 SLOT( synchowto() ) );
1245 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 1272 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
1246 action->addTo( helpMenu ); 1273 action->addTo( helpMenu );
1247 connect( action, SIGNAL( activated() ), 1274 connect( action, SIGNAL( activated() ),
1248 SLOT( kdesynchowto() ) ); 1275 SLOT( kdesynchowto() ) );
1249 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 1276 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
1250 action->addTo( helpMenu ); 1277 action->addTo( helpMenu );
1251 connect( action, SIGNAL( activated() ), 1278 connect( action, SIGNAL( activated() ),
1252 SLOT( multisynchowto() ) ); 1279 SLOT( multisynchowto() ) );
1253 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 1280 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
1254 action->addTo( helpMenu ); 1281 action->addTo( helpMenu );
1255 connect( action, SIGNAL( activated() ), 1282 connect( action, SIGNAL( activated() ),
1256 SLOT( aboutAutoSaving() ) ); 1283 SLOT( aboutAutoSaving() ) );
1257 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 1284 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
1258 action->addTo( helpMenu ); 1285 action->addTo( helpMenu );
1259 connect( action, SIGNAL( activated() ), 1286 connect( action, SIGNAL( activated() ),
1260 SLOT( aboutKnownBugs() ) ); 1287 SLOT( aboutKnownBugs() ) );
1261 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 1288 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
1262 action->addTo( helpMenu ); 1289 action->addTo( helpMenu );
1263 connect( action, SIGNAL( activated() ), 1290 connect( action, SIGNAL( activated() ),
1264 SLOT( usertrans() ) ); 1291 SLOT( usertrans() ) );
1265 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 1292 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
1266 action->addTo( helpMenu ); 1293 action->addTo( helpMenu );
1267 connect( action, SIGNAL( activated() ), 1294 connect( action, SIGNAL( activated() ),
1268 SLOT( faq() ) ); 1295 SLOT( faq() ) );
1269 action = new QAction( "licence", i18n("Licence..."), 0, this ); 1296 action = new QAction( "licence", i18n("Licence..."), 0, this );
1270 action->addTo( helpMenu ); 1297 action->addTo( helpMenu );
1271 connect( action, SIGNAL( activated() ), 1298 connect( action, SIGNAL( activated() ),
1272 SLOT( licence() ) ); 1299 SLOT( licence() ) );
1273 action = new QAction( "about", i18n("About..."), 0, this ); 1300 action = new QAction( "about", i18n("About..."), 0, this );
1274 action->addTo( helpMenu ); 1301 action->addTo( helpMenu );
1275 connect( action, SIGNAL( activated() ), 1302 connect( action, SIGNAL( activated() ),
1276 SLOT( about() ) ); 1303 SLOT( about() ) );
1277 //menuBar->insertSeparator(); 1304 //menuBar->insertSeparator();
1278 1305
1279 // ****************************************************** 1306 // ******************************************************
1280 // menubar icons 1307 // menubar icons
1281 1308
1282 1309
1283 1310
1284 //menuBar->insertItem( iconToolBar ); 1311 //menuBar->insertItem( iconToolBar );
1285 //xdays_action 1312 //xdays_action
1286 if (p-> mShowIconNewEvent) 1313 if (p-> mShowIconNewEvent)
1287 ne_action->addTo( iconToolBar ); 1314 ne_action->addTo( iconToolBar );
1288 if (p->mShowIconNewTodo ) 1315 if (p->mShowIconNewTodo )
1289 nt_action->addTo( iconToolBar ); 1316 nt_action->addTo( iconToolBar );
1290 if (p-> mShowIconSearch) 1317 if (p-> mShowIconSearch)
1291 search_action->addTo( iconToolBar ); 1318 search_action->addTo( iconToolBar );
1292 if (p-> mShowIconWhatsThis) 1319 if (p-> mShowIconWhatsThis)
1293 QWhatsThis::whatsThisButton ( iconToolBar ); 1320 QWhatsThis::whatsThisButton ( iconToolBar );
1294 if (p-> mShowIconNext) 1321 if (p-> mShowIconNext)
1295 whatsnext_action->addTo( viewToolBar ); 1322 whatsnext_action->addTo( viewToolBar );
1296 if (p-> mShowIconNextDays) 1323 if (p-> mShowIconNextDays)
1297 xdays_action->addTo( viewToolBar ); 1324 xdays_action->addTo( viewToolBar );
1298 if (p-> mShowIconJournal) 1325 if (p-> mShowIconJournal)
1299 viewjournal_action->addTo( viewToolBar ); 1326 viewjournal_action->addTo( viewToolBar );
1300 if (p-> mShowIconDay1) 1327 if (p-> mShowIconDay1)
1301 day1_action->addTo( viewToolBar ); 1328 day1_action->addTo( viewToolBar );
1302 if (p-> mShowIconDay5) 1329 if (p-> mShowIconDay5)
1303 day5_action->addTo( viewToolBar ); 1330 day5_action->addTo( viewToolBar );
1304 if (p-> mShowIconDay7) 1331 if (p-> mShowIconDay7)
1305 day7_action->addTo( viewToolBar ); 1332 day7_action->addTo( viewToolBar );
1306 if (p-> mShowIconDay6) 1333 if (p-> mShowIconDay6)
1307 day6_action->addTo( viewToolBar ); 1334 day6_action->addTo( viewToolBar );
1308 if (p-> mShowIconMonth) 1335 if (p-> mShowIconMonth)
1309 month_action->addTo( viewToolBar ); 1336 month_action->addTo( viewToolBar );
1310 if (p-> mShowIconList) 1337 if (p-> mShowIconList)
1311 showlist_action->addTo( viewToolBar ); 1338 showlist_action->addTo( viewToolBar );
1312 if (p-> mShowIconTodoview) 1339 if (p-> mShowIconTodoview)
1313 todoview_action->addTo( viewToolBar ); 1340 todoview_action->addTo( viewToolBar );
1314 1341
1315 icon = loadPixmap( pathString + "2leftarrowB" ); 1342 icon = loadPixmap( pathString + "2leftarrowB" );
1316 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1343 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1317 if (p-> mShowIconBackFast) { 1344 if (p-> mShowIconBackFast) {
1318 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1345 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1319 connect( action, SIGNAL( activated() ), 1346 connect( action, SIGNAL( activated() ),
1320 mView, SLOT( goPreviousMonth() ) ); 1347 mView, SLOT( goPreviousMonth() ) );
1321 action->addTo( navigatorToolBar ); 1348 action->addTo( navigatorToolBar );
1322 } 1349 }
1323 icon = loadPixmap( pathString + "1leftarrowB" ); 1350 icon = loadPixmap( pathString + "1leftarrowB" );
1324 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1351 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1325 if (p-> mShowIconBack) { 1352 if (p-> mShowIconBack) {
1326 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1353 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1327 connect( action, SIGNAL( activated() ), 1354 connect( action, SIGNAL( activated() ),
1328 mView, SLOT( goPrevious() ) ); 1355 mView, SLOT( goPrevious() ) );
1329 action->addTo( navigatorToolBar ); 1356 action->addTo( navigatorToolBar );
1330 } 1357 }
1331 icon = loadPixmap( pathString + "today" ); 1358 icon = loadPixmap( pathString + "today" );
1332 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1359 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1333 if (p-> mShowIconToday) 1360 if (p-> mShowIconToday)
1334 today_action->addTo( navigatorToolBar ); 1361 today_action->addTo( navigatorToolBar );
1335 icon = loadPixmap( pathString + "1rightarrowB" ); 1362 icon = loadPixmap( pathString + "1rightarrowB" );
1336 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1363 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1337 if (p-> mShowIconForward) { 1364 if (p-> mShowIconForward) {
1338 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1365 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1339 connect( action, SIGNAL( activated() ), 1366 connect( action, SIGNAL( activated() ),
1340 mView, SLOT( goNext() ) ); 1367 mView, SLOT( goNext() ) );
1341 action->addTo( navigatorToolBar ); 1368 action->addTo( navigatorToolBar );
1342 } 1369 }
1343 icon = loadPixmap( pathString + "2rightarrowB" ); 1370 icon = loadPixmap( pathString + "2rightarrowB" );
1344 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1371 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1345 if (p-> mShowIconForwardFast) { 1372 if (p-> mShowIconForwardFast) {
1346 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1373 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1347 connect( action, SIGNAL( activated() ), 1374 connect( action, SIGNAL( activated() ),
1348 mView, SLOT( goNextMonth() ) ); 1375 mView, SLOT( goNextMonth() ) );
1349 action->addTo( navigatorToolBar ); 1376 action->addTo( navigatorToolBar );
1350 } 1377 }
1351 1378
1352 1379
1353 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); 1380 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6);
1354 1381
1355 1382
1356 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); 1383 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true);
1357 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); 1384 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true);
1358 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); 1385 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true);
1359 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); 1386 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true);
1360 1387
1361 if (p-> mShowIconNewEvent) 1388 if (p-> mShowIconNewEvent)
1362 configureToolBarMenu->setItemChecked( 10, true ); 1389 configureToolBarMenu->setItemChecked( 10, true );
1363 if (p->mShowIconNewTodo ) 1390 if (p->mShowIconNewTodo )
1364 configureToolBarMenu->setItemChecked( 20, true ); 1391 configureToolBarMenu->setItemChecked( 20, true );
1365 if (p-> mShowIconSearch) 1392 if (p-> mShowIconSearch)
1366 configureToolBarMenu->setItemChecked( 120, true ); 1393 configureToolBarMenu->setItemChecked( 120, true );
1367 if (p-> mShowIconList) 1394 if (p-> mShowIconList)
1368 configureToolBarMenu->setItemChecked( 30, true ); 1395 configureToolBarMenu->setItemChecked( 30, true );
1369 if (p-> mShowIconDay1) 1396 if (p-> mShowIconDay1)
1370 configureToolBarMenu->setItemChecked( 40, true ); 1397 configureToolBarMenu->setItemChecked( 40, true );
1371 if (p-> mShowIconDay5) 1398 if (p-> mShowIconDay5)
1372 configureToolBarMenu->setItemChecked( 50, true ); 1399 configureToolBarMenu->setItemChecked( 50, true );
1373 if (p-> mShowIconDay6) 1400 if (p-> mShowIconDay6)
1374 configureToolBarMenu->setItemChecked( 75, true ); 1401 configureToolBarMenu->setItemChecked( 75, true );
1375 if (p-> mShowIconDay7) 1402 if (p-> mShowIconDay7)
1376 configureToolBarMenu->setItemChecked( 60, true ); 1403 configureToolBarMenu->setItemChecked( 60, true );
1377 if (p-> mShowIconMonth) 1404 if (p-> mShowIconMonth)
1378 configureToolBarMenu->setItemChecked( 70, true ); 1405 configureToolBarMenu->setItemChecked( 70, true );
1379 if (p-> mShowIconTodoview) 1406 if (p-> mShowIconTodoview)
1380 configureToolBarMenu->setItemChecked( 80, true ); 1407 configureToolBarMenu->setItemChecked( 80, true );
1381 if (p-> mShowIconBackFast) 1408 if (p-> mShowIconBackFast)
1382 configureToolBarMenu->setItemChecked( 200, true ); 1409 configureToolBarMenu->setItemChecked( 200, true );
1383 if (p-> mShowIconBack) 1410 if (p-> mShowIconBack)
1384 configureToolBarMenu->setItemChecked( 210, true ); 1411 configureToolBarMenu->setItemChecked( 210, true );
1385 if (p-> mShowIconToday) 1412 if (p-> mShowIconToday)
1386 configureToolBarMenu->setItemChecked( 130, true ); 1413 configureToolBarMenu->setItemChecked( 130, true );
1387 if (p-> mShowIconForward) 1414 if (p-> mShowIconForward)
1388 configureToolBarMenu->setItemChecked( 220, true ); 1415 configureToolBarMenu->setItemChecked( 220, true );
1389 if (p-> mShowIconForwardFast) 1416 if (p-> mShowIconForwardFast)
1390 configureToolBarMenu->setItemChecked( 230, true ); 1417 configureToolBarMenu->setItemChecked( 230, true );
1391 if (p-> mShowIconNextDays) 1418 if (p-> mShowIconNextDays)
1392 configureToolBarMenu->setItemChecked( 100, true ); 1419 configureToolBarMenu->setItemChecked( 100, true );
1393 if (p-> mShowIconNext) 1420 if (p-> mShowIconNext)
1394 configureToolBarMenu->setItemChecked( 110, true ); 1421 configureToolBarMenu->setItemChecked( 110, true );
1395 if (p-> mShowIconJournal) 1422 if (p-> mShowIconJournal)
1396 configureToolBarMenu->setItemChecked( 90, true ); 1423 configureToolBarMenu->setItemChecked( 90, true );
1397 if (p-> mShowIconWhatsThis) 1424 if (p-> mShowIconWhatsThis)
1398 configureToolBarMenu->setItemChecked( 300, true ); 1425 configureToolBarMenu->setItemChecked( 300, true );
1399 if (p-> mShowIconWeekNum) 1426 if (p-> mShowIconWeekNum)
1400 configureToolBarMenu->setItemChecked( 400, true ); 1427 configureToolBarMenu->setItemChecked( 400, true );
1401 if (!p-> mShowIconStretch) { 1428 if (!p-> mShowIconStretch) {
1402 QLabel* dummy = new QLabel( iconToolBar ); 1429 QLabel* dummy = new QLabel( iconToolBar );
1403 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1430 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1404 dummy->setMinimumWidth( 0 ); 1431 dummy->setMinimumWidth( 0 );
1405 iconToolBar->setStretchableWidget ( dummy ) ; 1432 iconToolBar->setStretchableWidget ( dummy ) ;
1406 } 1433 }
1407 else { 1434 else {
1408 iconToolBar->setHorizontalStretchable (true ); 1435 iconToolBar->setHorizontalStretchable (true );
1409 viewToolBar->setHorizontalStretchable (true ); 1436 viewToolBar->setHorizontalStretchable (true );
1410 navigatorToolBar->setHorizontalStretchable (true ); 1437 navigatorToolBar->setHorizontalStretchable (true );
1411 iconToolBar->setVerticalStretchable (true ); 1438 iconToolBar->setVerticalStretchable (true );
1412 viewToolBar->setVerticalStretchable (true ); 1439 viewToolBar->setVerticalStretchable (true );
1413 navigatorToolBar->setVerticalStretchable (true ); 1440 navigatorToolBar->setVerticalStretchable (true );
1414 configureToolBarMenu->setItemChecked( 5, true ); 1441 configureToolBarMenu->setItemChecked( 5, true );
1415 } 1442 }
1416 if (p-> mShowIconFilter) 1443 if (p-> mShowIconFilter)
1417 configureToolBarMenu->setItemChecked( 7, true ); 1444 configureToolBarMenu->setItemChecked( 7, true );
1418 if (p-> mShowIconOnetoolbar) 1445 if (p-> mShowIconOnetoolbar)
1419 configureToolBarMenu->setItemChecked( 6, true ); 1446 configureToolBarMenu->setItemChecked( 6, true );
1420 1447
1421 1448
1422 if ( filterMenubar ) { 1449 if ( filterMenubar ) {
1423 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); 1450 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) );
1424 connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) ); 1451 connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) );
1425 } 1452 }
1426 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1453 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1427 configureAgenda( p->mHourSize ); 1454 configureAgenda( p->mHourSize );
1428 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1455 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1429} 1456}
1430void MainWindow::calHint() 1457void MainWindow::calHint()
1431{ 1458{
1432 QString message = i18n("You can use and display <b>more than one</b> calendar file in KO/Pi. A calendar file is called a <b>resource</b>. To add a calendar or change calendar settings please use menu: <b>View -> Toggle Resource View</b>."); 1459 QString message = i18n("You can use and display <b>more than one</b> calendar file in KO/Pi. A calendar file is called a <b>resource</b>. To add a calendar or change calendar settings please use menu: <b>View -> Toggle Resource View</b>.");
1433 1460
1434 KMessageBox::information( this, message); 1461 KMessageBox::information( this, message);
1435} 1462}
1436void MainWindow::exportToPhone( int mode ) 1463void MainWindow::exportToPhone( int mode )
1437{ 1464{
1438 1465
1439 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1466 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1440 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1467 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1441 KOex2phonePrefs ex2phone; 1468 KOex2phonePrefs ex2phone;
1442 1469
1443 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1470 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1444 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1471 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1445 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1472 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1446 if ( mode == 1 ) 1473 if ( mode == 1 )
1447 ex2phone.setCaption(i18n("Export complete calendar")); 1474 ex2phone.setCaption(i18n("Export complete calendar"));
1448 if ( mode == 2 ) 1475 if ( mode == 2 )
1449 ex2phone.setCaption(i18n("Export filtered calendar")); 1476 ex2phone.setCaption(i18n("Export filtered calendar"));
1450 1477
1451 if ( !ex2phone.exec() ) { 1478 if ( !ex2phone.exec() ) {
1452 return; 1479 return;
1453 } 1480 }
1454 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1481 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1455 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1482 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1456 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1483 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1457 1484
1458 int inFuture = 0; 1485 int inFuture = 0;
1459 if ( ex2phone.mWriteBackFuture->isChecked() ) 1486 if ( ex2phone.mWriteBackFuture->isChecked() )
1460 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1487 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1461 QPtrList<Incidence> delSel; 1488 QPtrList<Incidence> delSel;
1462 if ( mode == 1 ) 1489 if ( mode == 1 )
1463 delSel = mCalendar->rawIncidences(); 1490 delSel = mCalendar->rawIncidences();
1464 if ( mode == 2 ) 1491 if ( mode == 2 )
1465 delSel = mCalendar->incidences(); 1492 delSel = mCalendar->incidences();
1466 CalendarLocal* cal = new CalendarLocal(); 1493 CalendarLocal* cal = new CalendarLocal();
1467 cal->setLocalTime(); 1494 cal->setLocalTime();
1468 Incidence *incidence = delSel.first(); 1495 Incidence *incidence = delSel.first();
1469 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1496 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1470 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1497 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1471 while ( incidence ) { 1498 while ( incidence ) {
1472 if ( incidence->typeID() != journalID ) { 1499 if ( incidence->typeID() != journalID ) {
1473 bool add = true; 1500 bool add = true;
1474 if ( inFuture ) { 1501 if ( inFuture ) {
1475 QDateTime dt; 1502 QDateTime dt;
1476 if ( incidence->typeID() == todoID ) { 1503 if ( incidence->typeID() == todoID ) {
1477 Todo * t = (Todo*)incidence; 1504 Todo * t = (Todo*)incidence;
1478 if ( t->hasDueDate() ) 1505 if ( t->hasDueDate() )
1479 dt = t->dtDue(); 1506 dt = t->dtDue();
1480 else 1507 else
1481 dt = cur.addSecs( 62 ); 1508 dt = cur.addSecs( 62 );
1482 } 1509 }
1483 else { 1510 else {
1484 bool ok; 1511 bool ok;
1485 dt = incidence->getNextOccurence( cur, &ok ); 1512 dt = incidence->getNextOccurence( cur, &ok );
1486 if ( !ok ) 1513 if ( !ok )
1487 dt = cur.addSecs( -62 ); 1514 dt = cur.addSecs( -62 );
1488 } 1515 }
1489 if ( dt < cur || dt > end ) { 1516 if ( dt < cur || dt > end ) {
1490 add = false; 1517 add = false;
1491 } 1518 }
1492 } 1519 }
1493 if ( add ) { 1520 if ( add ) {
1494 Incidence *in = incidence->clone(); 1521 Incidence *in = incidence->clone();
1495 cal->addIncidence( in ); 1522 cal->addIncidence( in );
1496 } 1523 }
1497 } 1524 }
1498 incidence = delSel.next(); 1525 incidence = delSel.next();
1499 } 1526 }
1500 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1527 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1501 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1528 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1502 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1529 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1503 1530
1504 setCaption( i18n("Writing to phone...")); 1531 setCaption( i18n("Writing to phone..."));
1505 if ( PhoneFormat::writeToPhone( cal ) ) 1532 if ( PhoneFormat::writeToPhone( cal ) )
1506 setCaption( i18n("Export to phone successful!")); 1533 setCaption( i18n("Export to phone successful!"));
1507 else 1534 else
1508 setCaption( i18n("Error exporting to phone!")); 1535 setCaption( i18n("Error exporting to phone!"));
1509 delete cal; 1536 delete cal;
1510} 1537}
1511 1538
1512 1539
1513void MainWindow::setDefaultPreferences() 1540void MainWindow::setDefaultPreferences()
1514{ 1541{
1515 KOPrefs *p = KOPrefs::instance(); 1542 KOPrefs *p = KOPrefs::instance();
1516 1543
1517 p->mCompactDialogs = true; 1544 p->mCompactDialogs = true;
1518 p->mConfirm = true; 1545 p->mConfirm = true;
1519 // p->mEnableQuickTodo = false; 1546 // p->mEnableQuickTodo = false;
1520 1547
1521} 1548}
1522 1549
1523QString MainWindow::resourcePath() 1550QString MainWindow::resourcePath()
1524{ 1551{
1525 return KGlobal::iconLoader()->iconPath(); 1552 return KGlobal::iconLoader()->iconPath();
1526} 1553}
1527 1554
1528void MainWindow::displayText( QString text ,QString cap ) 1555void MainWindow::displayText( QString text ,QString cap )
1529{ 1556{
1530 QDialog dia( this, "name", true ); ; 1557 QDialog dia( this, "name", true ); ;
1531 dia.setCaption( cap ); 1558 dia.setCaption( cap );
1532 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1559 QVBoxLayout* lay = new QVBoxLayout( &dia );
1533 lay->setSpacing( 3 ); 1560 lay->setSpacing( 3 );
1534 lay->setMargin( 3 ); 1561 lay->setMargin( 3 );
1535 QTextBrowser tb ( &dia ); 1562 QTextBrowser tb ( &dia );
1536 lay->addWidget( &tb ); 1563 lay->addWidget( &tb );
1537 tb.setText( text ); 1564 tb.setText( text );
1538#ifdef DESKTOP_VERSION 1565#ifdef DESKTOP_VERSION
1539 dia.resize( 640, 480); 1566 dia.resize( 640, 480);
1540#else 1567#else
1541 dia.showMaximized(); 1568 dia.showMaximized();
1542#endif 1569#endif
1543 dia.exec(); 1570 dia.exec();
1544} 1571}
1545 1572
1546void MainWindow::features() 1573void MainWindow::features()
1547{ 1574{
1548 1575
1549 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1576 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1550} 1577}
1551 1578
1552void MainWindow::usertrans() 1579void MainWindow::usertrans()
1553{ 1580{
1554 1581
1555 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1582 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1556} 1583}
1557 1584
1558void MainWindow::storagehowto() 1585void MainWindow::storagehowto()
1559{ 1586{
1560 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 1587 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
1561} 1588}
1562void MainWindow::timetrackinghowto() 1589void MainWindow::timetrackinghowto()
1563{ 1590{
1564 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); 1591 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" );
1565} 1592}
1566void MainWindow::kdesynchowto() 1593void MainWindow::kdesynchowto()
1567{ 1594{
1568 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1595 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1569} 1596}
1570void MainWindow::multisynchowto() 1597void MainWindow::multisynchowto()
1571{ 1598{
1572 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1599 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1573} 1600}
1574void MainWindow::synchowto() 1601void MainWindow::synchowto()
1575{ 1602{
1576 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1603 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1577} 1604}
1578void MainWindow::faq() 1605void MainWindow::faq()
1579{ 1606{
1580 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1607 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1581 1608
1582} 1609}
1583void MainWindow::whatsNew() 1610void MainWindow::whatsNew()
1584{ 1611{
1585 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1612 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1586 1613
1587} 1614}
1588void MainWindow::licence() 1615void MainWindow::licence()
1589{ 1616{
1590 KApplication::showLicence(); 1617 KApplication::showLicence();
1591 1618
1592} 1619}
1593void MainWindow::about() 1620void MainWindow::about()
1594{ 1621{
1595 QString version; 1622 QString version;
1596#include <../version> 1623#include <../version>
1597 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1624 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1598 i18n("KOrganizer/Platform-independent\n") + 1625 i18n("KOrganizer/Platform-independent\n") +
1599 "(KO/Pi) " + version + " - " + 1626 "(KO/Pi) " + version + " - " +
1600 1627
1601#ifdef DESKTOP_VERSION 1628#ifdef DESKTOP_VERSION
1602 i18n("Desktop Edition\n") + 1629 i18n("Desktop Edition\n") +
1603#else 1630#else
1604 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1631 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1605#endif 1632#endif
1606 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1633 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1607} 1634}
1608void MainWindow::keyBindings() 1635void MainWindow::keyBindings()
1609{ 1636{
1610 QString cap = i18n("KO/Pi Keys + Colors"); 1637 QString cap = i18n("KO/Pi Keys + Colors");
1611 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1638 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1612 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1639 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1613 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + 1640 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") +
1614 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + 1641 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") +
1615 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1642 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1616 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1643 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1617 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ 1644 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+
1618 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1645 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1619 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1646 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1620 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ 1647 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+
1621 i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+ 1648 i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+
1622 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1649 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1623 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1650 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1624 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1651 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1625 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1652 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1626 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1653 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1627 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1654 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1628 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ 1655 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+
1629 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1656 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1630 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1657 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1631 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1658 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1632 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1659 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1633 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1660 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1634 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1661 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1635 i18n("<p><h3>In agenda view:</h3></p>\n") + 1662 i18n("<p><h3>In agenda view:</h3></p>\n") +
1636 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1663 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1637 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1664 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1638 i18n("<p><h3>In todo view:</h3></p>\n") + 1665 i18n("<p><h3>In todo view:</h3></p>\n") +
1639 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1666 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1640 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1667 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1641 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1668 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1642 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1669 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1643 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1670 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1644 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1671 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1645 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1672 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1646 i18n("<p><h3>In list view:</h3></p>\n") + 1673 i18n("<p><h3>In list view:</h3></p>\n") +
1647 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1674 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1648 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1675 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1649 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1676 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1650 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1677 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1651 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1678 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1652 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1679 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1653 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1680 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1654 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1681 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1655 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1682 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1656 i18n("<p><b>E</b>: Edit item</p>\n") + 1683 i18n("<p><b>E</b>: Edit item</p>\n") +
1657 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1684 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1658 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1685 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1659 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1686 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1660 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1687 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1661 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1688 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1662 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1689 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1663 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1690 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1664 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1691 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1665 i18n("<p><b>White</b>: Item readonly</p>\n"); 1692 i18n("<p><b>White</b>: Item readonly</p>\n");
1666 displayText( text, cap); 1693 displayText( text, cap);
1667} 1694}
1668void MainWindow::aboutAutoSaving() 1695void MainWindow::aboutAutoSaving()
1669{ 1696{
1670 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); 1697 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
1671 1698
1672 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1699 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1673 1700
1674} 1701}
1675void MainWindow::aboutKnownBugs() 1702void MainWindow::aboutKnownBugs()
1676{ 1703{
1677 QMessageBox* msg; 1704 QMessageBox* msg;
1678 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1705 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1679 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1706 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1680 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1707 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1681 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1708 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1682 i18n("\nor report them in the bugtracker on\n") + 1709 i18n("\nor report them in the bugtracker on\n") +
1683 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1710 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1684 QMessageBox::NoIcon, 1711 QMessageBox::NoIcon,
1685 QMessageBox::Ok, 1712 QMessageBox::Ok,
1686 QMessageBox::NoButton, 1713 QMessageBox::NoButton,
1687 QMessageBox::NoButton); 1714 QMessageBox::NoButton);
1688 msg->exec(); 1715 msg->exec();
1689 delete msg; 1716 delete msg;
1690 1717
1691} 1718}
1692 1719
1693QString MainWindow::defaultFileName() 1720QString MainWindow::defaultFileName()
1694{ 1721{
1695 return QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); 1722 return QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) );
1696} 1723}
1697QString MainWindow::syncFileName() 1724QString MainWindow::syncFileName()
1698{ 1725{
1699#ifdef DESKTOP_VERSION 1726#ifdef DESKTOP_VERSION
1700 return QDir::convertSeparators( locateLocal( "tmp", "synccalendar.ics" ) ); 1727 return QDir::convertSeparators( locateLocal( "tmp", "synccalendar.ics" ) );
1701#else 1728#else
1702 return QString( "/tmp/synccalendar.ics" ); 1729 return QString( "/tmp/synccalendar.ics" );
1703#endif 1730#endif
1704} 1731}
1705#include "koglobals.h" 1732#include "koglobals.h"
1706#include <kcalendarsystem.h> 1733#include <kcalendarsystem.h>
1707void MainWindow::updateWeek(QDate seda) 1734void MainWindow::updateWeek(QDate seda)
1708{ 1735{
1709 int weekNum = KGlobal::locale()->weekNum ( seda ); 1736 int weekNum = KGlobal::locale()->weekNum ( seda );
1710 mWeekPixmap.fill( mWeekBgColor ); 1737 mWeekPixmap.fill( mWeekBgColor );
1711 QPainter p ( &mWeekPixmap ); 1738 QPainter p ( &mWeekPixmap );
1712 p.setFont( mWeekFont ); 1739 p.setFont( mWeekFont );
1713 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1740 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1714 p.end(); 1741 p.end();
1715 QIconSet icon3 ( mWeekPixmap ); 1742 QIconSet icon3 ( mWeekPixmap );
1716 mWeekAction->setIconSet ( icon3 ); 1743 mWeekAction->setIconSet ( icon3 );
1717 1744
1718} 1745}
1719void MainWindow::updateWeekNum(const DateList &selectedDates) 1746void MainWindow::updateWeekNum(const DateList &selectedDates)
1720{ 1747{
1721 updateWeek( selectedDates.first() ); 1748 updateWeek( selectedDates.first() );
1722} 1749}
1723void MainWindow::processIncidenceSelection( Incidence *incidence ) 1750void MainWindow::processIncidenceSelection( Incidence *incidence )
1724{ 1751{
1725 if ( !incidence ) { 1752 if ( !incidence ) {
1726 mShowAction->setMenuText( i18n("Show") ); 1753 mShowAction->setMenuText( i18n("Show") );
1727 enableIncidenceActions( false ); 1754 enableIncidenceActions( false );
1728 mNewSubTodoAction->setEnabled( false ); 1755 mNewSubTodoAction->setEnabled( false );
1729 setCaptionToDates(); 1756 setCaptionToDates();
1730 return; 1757 return;
1731 } 1758 }
1732 QString startString = ""; 1759 QString startString = "";
1733 if ( incidence->typeID() != todoID ) { 1760 if ( incidence->typeID() != todoID ) {
1734 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1761 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1735 if ( incidence->doesFloat() ) { 1762 if ( incidence->doesFloat() ) {
1736 startString += ": "+incidence->dtStartDateStr( true ); 1763 startString += ": "+incidence->dtStartDateStr( true );
1737 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1764 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1738 } else { 1765 } else {
1739 startString = ": "+incidence->dtStartStr(true); 1766 startString = ": "+incidence->dtStartStr(true);
1740 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1767 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1741 } 1768 }
1742 } else { 1769 } else {
1743 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1770 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1744 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1771 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1745 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1772 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1746 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1773 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1747 bool ok; 1774 bool ok;
1748 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1775 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1749 if ( ok ) { 1776 if ( ok ) {
1750 int years = noc.date().year() - incidence->dtStart().date().year(); 1777 int years = noc.date().year() - incidence->dtStart().date().year();
1751 startString += i18n(" (%1 y.)"). arg( years ); 1778 startString += i18n(" (%1 y.)"). arg( years );
1752 } 1779 }
1753 } 1780 }
1754 else 1781 else
1755 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1782 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1756 } 1783 }
1757 } 1784 }
1758 else { 1785 else {
1759 if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) 1786 if ( (( KCal::Todo*)incidence)->percentComplete() == 100 )
1760 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); 1787 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) );
1761 else 1788 else
1762 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1789 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1763 } 1790 }
1764 if ( !incidence->location().isEmpty() ) 1791 if ( !incidence->location().isEmpty() )
1765 startString += " (" +incidence->location()+")"; 1792 startString += " (" +incidence->location()+")";
1766 setCaption( incidence->summary()+startString); 1793 setCaption( incidence->summary()+startString);
1767 enableIncidenceActions( true ); 1794 enableIncidenceActions( true );
1768 if ( incidence->typeID() == eventID ) { 1795 if ( incidence->typeID() == eventID ) {
1769 mShowAction->setMenuText( i18n("Show Event") ); 1796 mShowAction->setMenuText( i18n("Show Event") );
1770 mNewSubTodoAction->setEnabled( false ); 1797 mNewSubTodoAction->setEnabled( false );
1771 } else if ( incidence->typeID() == todoID ) { 1798 } else if ( incidence->typeID() == todoID ) {
1772 mShowAction->setMenuText( i18n("Show Todo") ); 1799 mShowAction->setMenuText( i18n("Show Todo") );
1773 mNewSubTodoAction->setEnabled( true ); 1800 mNewSubTodoAction->setEnabled( true );
1774 } else { 1801 } else {
1775 mShowAction->setMenuText( i18n("Show") ); 1802 mShowAction->setMenuText( i18n("Show") );
1776 mNewSubTodoAction->setEnabled( false ); 1803 mNewSubTodoAction->setEnabled( false );
1777 } 1804 }
1778#ifdef DESKTOP_VERSION 1805#ifdef DESKTOP_VERSION
1779 static QPixmap jP = SmallIcon( "journal" ); 1806 static QPixmap jP = SmallIcon( "journal" );
1780 static QPixmap eP = SmallIcon( "newevent" ); 1807 static QPixmap eP = SmallIcon( "newevent" );
1781 static QPixmap tP = SmallIcon( "newtodo" ); 1808 static QPixmap tP = SmallIcon( "newtodo" );
1782 QIconSet icon; 1809 QIconSet icon;
1783 if ( incidence->typeID() == todoID ) 1810 if ( incidence->typeID() == todoID )
1784 icon = QIconSet ( tP ); 1811 icon = QIconSet ( tP );
1785 else if ( incidence->typeID() == eventID ) 1812 else if ( incidence->typeID() == eventID )
1786 icon = QIconSet ( eP ); 1813 icon = QIconSet ( eP );
1787 else if ( incidence->typeID() == journalID ) 1814 else if ( incidence->typeID() == journalID )
1788 icon = QIconSet ( jP ); 1815 icon = QIconSet ( jP );
1789 mPrintSelAction->setIconSet ( icon ); 1816 mPrintSelAction->setIconSet ( icon );
1790#endif 1817#endif
1791} 1818}
1792 1819
1793void MainWindow::enableIncidenceActions( bool enabled ) 1820void MainWindow::enableIncidenceActions( bool enabled )
1794{ 1821{
1795 mShowAction->setEnabled( enabled ); 1822 mShowAction->setEnabled( enabled );
1796 mEditAction->setEnabled( enabled ); 1823 mEditAction->setEnabled( enabled );
1797 mDeleteAction->setEnabled( enabled ); 1824 mDeleteAction->setEnabled( enabled );
1798 1825
1799 mCloneAction->setEnabled( enabled ); 1826 mCloneAction->setEnabled( enabled );
1800 mMoveAction->setEnabled( enabled ); 1827 mMoveAction->setEnabled( enabled );
1801#ifndef DESKTOP_VERSION 1828#ifndef DESKTOP_VERSION
1802 mBeamAction->setEnabled( enabled ); 1829 mBeamAction->setEnabled( enabled );
1803#else 1830#else
1804 mPrintSelAction->setEnabled( enabled ); 1831 mPrintSelAction->setEnabled( enabled );
1805#endif 1832#endif
1806 mCancelAction->setEnabled( enabled ); 1833 mCancelAction->setEnabled( enabled );
1807} 1834}
1808 1835
1809void MainWindow::importOL() 1836void MainWindow::importOL()
1810{ 1837{
1811#ifdef _OL_IMPORT_ 1838#ifdef _OL_IMPORT_
1812 mView->clearAllViews(); 1839 mView->clearAllViews();
1813 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1840 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1814 id->exec(); 1841 id->exec();
1815 delete id; 1842 delete id;
1816 mView->calendar()->checkAlarmForIncidence( 0, true ); 1843 mView->calendar()->checkAlarmForIncidence( 0, true );
1817 mView->updateView(); 1844 mView->updateView();
1818#endif 1845#endif
1819} 1846}
1820void MainWindow::importBday() 1847void MainWindow::importBday()
1821{ 1848{
1822 int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), 1849 int result = QMessageBox::warning( this, i18n("KO/Pi import information!"),
1823 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1850 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1824 i18n("Import!"), i18n("Cancel"), 0, 1851 i18n("Import!"), i18n("Cancel"), 0,
1825 0, 1 ); 1852 0, 1 );
1826 if ( result == 0 ) { 1853 if ( result == 0 ) {
1827 mView->importBday(); 1854 mView->importBday();
1828 1855
1829 } 1856 }
1830 1857
1831 1858
1832} 1859}
1833void MainWindow::importQtopia() 1860void MainWindow::importQtopia()
1834{ 1861{
1835 //#ifndef DESKTOP_VERSION 1862 //#ifndef DESKTOP_VERSION
1836 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); 1863 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing");
1837#ifdef DESKTOP_VERSION 1864#ifdef DESKTOP_VERSION
1838 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1865 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1839#endif 1866#endif
1840 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1867 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1841 i18n("Import!"), i18n("Cancel"), 0, 1868 i18n("Import!"), i18n("Cancel"), 0,
1842 0, 1 ); 1869 0, 1 );
1843 if ( result == 0 ) { 1870 if ( result == 0 ) {
1844#ifndef DESKTOP_VERSION 1871#ifndef DESKTOP_VERSION
1845 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1872 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1846 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1873 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1847 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1874 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1848#else 1875#else
1849 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1876 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1850 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1877 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1851 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1878 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1852#endif 1879#endif
1853 mView->importQtopia( categories, datebook, todolist ); 1880 mView->importQtopia( categories, datebook, todolist );
1854 } 1881 }
1855 mView->calendar()->reInitAlarmSettings(); 1882 mView->calendar()->reInitAlarmSettings();
1856#if 0 1883#if 0
1857 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1884 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1858 i18n("Not supported \non desktop!\n"), 1885 i18n("Not supported \non desktop!\n"),
1859 i18n("Ok"), i18n("Cancel"), 0, 1886 i18n("Ok"), i18n("Cancel"), 0,
1860 0, 1 ); 1887 0, 1 );
1861 1888
1862#endif 1889#endif
1863} 1890}
1864 1891
1865void MainWindow::saveOnClose() 1892void MainWindow::saveOnClose()
1866{ 1893{
1867 KOPrefs *p = KOPrefs::instance(); 1894 KOPrefs *p = KOPrefs::instance();
1868 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1895 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1869 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1896 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1870 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1897 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1871 if ( filterToolBar ) { 1898 if ( filterToolBar ) {
1872 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1899 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1873 } 1900 }
1874#ifdef DESKTOP_VERSION 1901#ifdef DESKTOP_VERSION
1875 1902
1876 QPoint myP; 1903 QPoint myP;
1877 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1904 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1878 if ( p->mToolBarHor ) 1905 if ( p->mToolBarHor )
1879 p->mToolBarUp = myP.y() > height()/2; 1906 p->mToolBarUp = myP.y() > height()/2;
1880 else 1907 else
1881 p->mToolBarUp = myP.x() > width()/2; 1908 p->mToolBarUp = myP.x() > width()/2;
1882 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1909 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1883 if ( p->mToolBarHorV ) 1910 if ( p->mToolBarHorV )
1884 p->mToolBarUpV = myP.y() > height()/2; 1911 p->mToolBarUpV = myP.y() > height()/2;
1885 else 1912 else
1886 p->mToolBarUpV = myP.x() > width()/2 ; 1913 p->mToolBarUpV = myP.x() > width()/2 ;
1887 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1914 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1888 if ( p->mToolBarHorN ) 1915 if ( p->mToolBarHorN )
1889 p->mToolBarUpN = myP.y() > height()/2; 1916 p->mToolBarUpN = myP.y() > height()/2;
1890 else 1917 else
1891 p->mToolBarUpN = myP.x() > width()/2 ; 1918 p->mToolBarUpN = myP.x() > width()/2 ;
1892 if ( filterToolBar ) { 1919 if ( filterToolBar ) {
1893 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1920 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1894 if ( p->mToolBarHorF ) 1921 if ( p->mToolBarHorF )
1895 p->mToolBarUpF = myP.y() > height()/2; 1922 p->mToolBarUpF = myP.y() > height()/2;
1896 else 1923 else
1897 p->mToolBarUpF = myP.x() > width()/2 ; 1924 p->mToolBarUpF = myP.x() > width()/2 ;
1898 } 1925 }
1899#else 1926#else
1900 if ( p->mToolBarHor ) 1927 if ( p->mToolBarHor )
1901 p->mToolBarUp = iconToolBar->y() > height()/2; 1928 p->mToolBarUp = iconToolBar->y() > height()/2;
1902 else 1929 else
1903 p->mToolBarUp = iconToolBar->x() > width()/2; 1930 p->mToolBarUp = iconToolBar->x() > width()/2;
1904 if ( p->mToolBarHorV ) 1931 if ( p->mToolBarHorV )
1905 p->mToolBarUpV = viewToolBar->y() > height()/2; 1932 p->mToolBarUpV = viewToolBar->y() > height()/2;
1906 else 1933 else
1907 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1934 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1908 1935
1909 if ( p->mToolBarHorN ) 1936 if ( p->mToolBarHorN )
1910 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1937 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1911 else 1938 else
1912 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1939 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1913 if ( filterToolBar ) { 1940 if ( filterToolBar ) {
1914 if ( p->mToolBarHorF ) 1941 if ( p->mToolBarHorF )
1915 p->mToolBarUpF = filterToolBar->y() > height()/2; 1942 p->mToolBarUpF = filterToolBar->y() > height()/2;
1916 else 1943 else
1917 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1944 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1918 } 1945 }
1919#endif 1946#endif
1920 save(); 1947 save();
1921 mView->writeSettings(); 1948 mView->writeSettings();
1922 mView->checkSuspendAlarm(); 1949 mView->checkSuspendAlarm();
1923} 1950}
1924void MainWindow::slotModifiedChanged( bool ) 1951void MainWindow::slotModifiedChanged( bool )
1925{ 1952{
1926 if ( mBlockAtStartup ) 1953 if ( mBlockAtStartup )
1927 return; 1954 return;
1928 1955
1929 int msec; 1956 int msec;
1930 if ( mCalendarModifiedFlag ) { 1957 if ( mCalendarModifiedFlag ) {
1931 //qDebug(" MainWindow timer is running "); 1958 //qDebug(" MainWindow timer is running ");
1932 return; 1959 return;
1933 } 1960 }
1934 // we store the changes after 1 minute, 1961 // we store the changes after 1 minute,
1935 // and for safety reasons after 10 minutes again 1962 // and for safety reasons after 10 minutes again
1936 if ( !mSyncManager->blockSave() ) 1963 if ( !mSyncManager->blockSave() )
1937 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1964 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1938 else 1965 else
1939 msec = 1000 * 600; 1966 msec = 1000 * 600;
1940 mSaveTimer.start( msec, true ); // 1 minute 1967 mSaveTimer.start( msec, true ); // 1 minute
1941 qDebug("KO: Saving File in %d secs!", msec/1000); 1968 qDebug("KO: Saving File in %d secs!", msec/1000);
1942 mCalendarModifiedFlag = true; 1969 mCalendarModifiedFlag = true;
1943} 1970}
1944void MainWindow::saveStopTimer() 1971void MainWindow::saveStopTimer()
1945{ 1972{
1946 mSaveTimer.stop(); 1973 mSaveTimer.stop();
1947} 1974}
1948void MainWindow::backupAllFiles() 1975void MainWindow::backupAllFiles()
1949{ 1976{
1950 QDate reference ( 2000,1,1); 1977 QDate reference ( 2000,1,1);
1951 int daysTo = reference.daysTo ( QDate::currentDate() ); 1978 int daysTo = reference.daysTo ( QDate::currentDate() );
1952 setCaption(i18n("Creating backup ... please wait ..." )); 1979 setCaption(i18n("Creating backup ... please wait ..." ));
1953 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1980 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1954 // we need the file path, the backup dir and the number of bups as param 1981 // we need the file path, the backup dir and the number of bups as param
1955 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1982 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1956 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1983 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1957 bupDir = KGlobalSettings::backupDataDir(); 1984 bupDir = KGlobalSettings::backupDataDir();
1958 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1985 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1959 if ( retval == 0 ) { 1986 if ( retval == 0 ) {
1960 setCaption(i18n("Backup cancelled" )); 1987 setCaption(i18n("Backup cancelled" ));
1961 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1988 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1962 // retval == 0 : backup skipped for today, try again tomorrow 1989 // retval == 0 : backup skipped for today, try again tomorrow
1963 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1990 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1964 } else if ( retval == 1 ){ 1991 } else if ( retval == 1 ){
1965 qDebug("KO: Backup created."); 1992 qDebug("KO: Backup created.");
1966 // backup ok 1993 // backup ok
1967 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1994 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1968 KopiCalendarFile * cal = calendars.first(); 1995 KopiCalendarFile * cal = calendars.first();
1969 cal = calendars.next(); 1996 cal = calendars.next();
1970 while ( cal ) { 1997 while ( cal ) {
1971 if ( !cal->mErrorOnLoad ) { 1998 if ( !cal->mErrorOnLoad ) {
1972 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1999 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1973 } 2000 }
1974 cal = calendars.next(); 2001 cal = calendars.next();
1975 } 2002 }
1976 KOPrefs::instance()->mLastBackupDate = daysTo; 2003 KOPrefs::instance()->mLastBackupDate = daysTo;
1977 setCaption(i18n("Backup succesfully finished" )); 2004 setCaption(i18n("Backup succesfully finished" ));
1978 } else if ( retval == 2 ){ 2005 } else if ( retval == 2 ){
1979 setCaption(i18n("Backup globally disabled" )); 2006 setCaption(i18n("Backup globally disabled" ));
1980 qDebug("KO: Backup globally cancelled."); 2007 qDebug("KO: Backup globally cancelled.");
1981 // backup globally cancelled 2008 // backup globally cancelled
1982 KPimGlobalPrefs::instance()->mBackupEnabled = false; 2009 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1983 } 2010 }
1984 // retval == 3: do nothing, try again later 2011 // retval == 3: do nothing, try again later
1985} 2012}
1986void MainWindow::save() 2013void MainWindow::save()
1987{ 2014{
1988 2015
1989 if ( mView->viewManager()->journalView() ) 2016 if ( mView->viewManager()->journalView() )
1990 mView->viewManager()->journalView()->checkModified(); 2017 mView->viewManager()->journalView()->checkModified();
1991 if ( !mCalendarModifiedFlag ) { 2018 if ( !mCalendarModifiedFlag ) {
1992 qDebug("KO: Calendar not modified. Nothing saved."); 2019 qDebug("KO: Calendar not modified. Nothing saved.");
1993 return; 2020 return;
1994 } 2021 }
1995 if ( mSyncManager->blockSave() ) { 2022 if ( mSyncManager->blockSave() ) {
1996 slotModifiedChanged( true ); 2023 slotModifiedChanged( true );
1997 return; 2024 return;
1998 } 2025 }
1999 mSyncManager->setBlockSave(true); 2026 mSyncManager->setBlockSave(true);
2000 if ( mView->checkAllFileVersions() ) { 2027 if ( mView->checkAllFileVersions() ) {
2001 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 2028 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
2002 QDate reference ( 2000,1,1); 2029 QDate reference ( 2000,1,1);
2003 int daysTo = reference.daysTo ( QDate::currentDate() ); 2030 int daysTo = reference.daysTo ( QDate::currentDate() );
2004 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 2031 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
2005 backupAllFiles(); 2032 backupAllFiles();
2006 } 2033 }
2007 ; // KPimGlobalPrefs::instance()->mLastBackupDate 2034 ; // KPimGlobalPrefs::instance()->mLastBackupDate
2008 } 2035 }
2009 QTime neededSaveTime = QDateTime::currentDateTime().time(); 2036 QTime neededSaveTime = QDateTime::currentDateTime().time();
2010 if ( !isMinimized () ) 2037 if ( !isMinimized () )
2011 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 2038 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
2012 qDebug("KO: Start saving data to file!"); 2039 qDebug("KO: Start saving data to file!");
2013 if ( mView->saveCalendars() ) 2040 if ( mView->saveCalendars() )
2014 mCalendarModifiedFlag = false; 2041 mCalendarModifiedFlag = false;
2015 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 2042 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
2016 qDebug("KO: Needed %d ms for saving.",msNeeded ); 2043 qDebug("KO: Needed %d ms for saving.",msNeeded );
2017 QString savemes; 2044 QString savemes;
2018 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 2045 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
2019 if ( !isMinimized () ) 2046 if ( !isMinimized () )
2020 setCaption(savemes); 2047 setCaption(savemes);
2021 else 2048 else
2022 qDebug(savemes); 2049 qDebug(savemes);
2023 } else { 2050 } else {
2024 setCaption(i18n("Saving cancelled!")); 2051 setCaption(i18n("Saving cancelled!"));
2025 mCalendarModifiedFlag = false; 2052 mCalendarModifiedFlag = false;
2026 slotModifiedChanged( true ); 2053 slotModifiedChanged( true );
2027 } 2054 }
2028 mSyncManager->setBlockSave( false ); 2055 mSyncManager->setBlockSave( false );
2029} 2056}
2030 2057
2031void MainWindow::keyReleaseEvent ( QKeyEvent * e) 2058void MainWindow::keyReleaseEvent ( QKeyEvent * e)
2032{ 2059{
2033 if ( !e->isAutoRepeat() ) { 2060 if ( !e->isAutoRepeat() ) {
2034 mFlagKeyPressed = false; 2061 mFlagKeyPressed = false;
2035 } 2062 }
2036} 2063}
2037void MainWindow::keyPressEvent ( QKeyEvent * e ) 2064void MainWindow::keyPressEvent ( QKeyEvent * e )
2038{ 2065{
2039 qApp->processEvents(); 2066 qApp->processEvents();
2040 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 2067 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
2041 e->ignore(); 2068 e->ignore();
2042 // qDebug(" ignore %d",e->isAutoRepeat() ); 2069 // qDebug(" ignore %d",e->isAutoRepeat() );
2043 return; 2070 return;
2044 } 2071 }
2045 if (! e->isAutoRepeat() ) 2072 if (! e->isAutoRepeat() )
2046 mFlagKeyPressed = true; 2073 mFlagKeyPressed = true;
2047 KOPrefs *p = KOPrefs::instance(); 2074 KOPrefs *p = KOPrefs::instance();
2048 bool showSelectedDates = false; 2075 bool showSelectedDates = false;
2049 int size; 2076 int size;
2050 int pro = 0; 2077 int pro = 0;
2051 //qDebug("MainWindow::keyPressEvent "); 2078 //qDebug("MainWindow::keyPressEvent ");
2052 switch ( e->key() ) { 2079 switch ( e->key() ) {
2053 case Qt::Key_Right: 2080 case Qt::Key_Right:
2054 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2081 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2055 mView->goNextMonth(); 2082 mView->goNextMonth();
2056 else 2083 else
2057 mView->goNext(); 2084 mView->goNext();
2058 showSelectedDates = true; 2085 showSelectedDates = true;
2059 break; 2086 break;
2060 case Qt::Key_Left: 2087 case Qt::Key_Left:
2061 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2088 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2062 mView->goPreviousMonth(); 2089 mView->goPreviousMonth();
2063 else 2090 else
2064 mView->goPrevious(); 2091 mView->goPrevious();
2065 showSelectedDates = true; 2092 showSelectedDates = true;
2066 break; 2093 break;
2067 case Qt::Key_Down: 2094 case Qt::Key_Down:
2068 mView->viewManager()->agendaView()->scrollOneHourDown(); 2095 mView->viewManager()->agendaView()->scrollOneHourDown();
2069 break; 2096 break;
2070 case Qt::Key_Up: 2097 case Qt::Key_Up:
2071 mView->viewManager()->agendaView()->scrollOneHourUp(); 2098 mView->viewManager()->agendaView()->scrollOneHourUp();
2072 break; 2099 break;
2073 case Qt::Key_K: 2100 case Qt::Key_K:
2074 mView->viewManager()->showMonthViewWeek(); 2101 mView->viewManager()->showMonthViewWeek();
2075 break; 2102 break;
2076 case Qt::Key_I: 2103 case Qt::Key_I:
2077 mView->showIncidence(); 2104 mView->showIncidence();
2078 break; 2105 break;
2079 case Qt::Key_Delete: 2106 case Qt::Key_Delete:
2080 case Qt::Key_Backspace: 2107 case Qt::Key_Backspace:
2081 mView->deleteIncidence(); 2108 mView->deleteIncidence();
2082 break; 2109 break;
2083 case Qt::Key_D: 2110 case Qt::Key_D:
2084 mView->viewManager()->showDayView(); 2111 mView->viewManager()->showDayView();
2085 showSelectedDates = true; 2112 showSelectedDates = true;
2086 break; 2113 break;
2087 case Qt::Key_O: 2114 case Qt::Key_O:
2088 mView->toggleFilerEnabled( ); 2115 mView->toggleFilerEnabled( );
2089 break; 2116 break;
2090 case Qt::Key_0: 2117 case Qt::Key_0:
2091 case Qt::Key_1: 2118 case Qt::Key_1:
2092 case Qt::Key_2: 2119 case Qt::Key_2:
2093 case Qt::Key_3: 2120 case Qt::Key_3:
2094 case Qt::Key_4: 2121 case Qt::Key_4:
2095 case Qt::Key_5: 2122 case Qt::Key_5:
2096 case Qt::Key_6: 2123 case Qt::Key_6:
2097 case Qt::Key_7: 2124 case Qt::Key_7:
2098 case Qt::Key_8: 2125 case Qt::Key_8:
2099 case Qt::Key_9: 2126 case Qt::Key_9:
2100 pro = e->key()-48; 2127 pro = e->key()-48;
2101 if ( pro == 0 ) 2128 if ( pro == 0 )
2102 pro = 10; 2129 pro = 10;
2103 if ( e->state() == Qt::ControlButton) 2130 if ( e->state() == Qt::ControlButton)
2104 pro += 10; 2131 pro += 10;
2105 break; 2132 break;
2106 case Qt::Key_M: 2133 case Qt::Key_M:
2107 mView->viewManager()->showMonthView(); 2134 mView->viewManager()->showMonthView();
2108 showSelectedDates = true; 2135 showSelectedDates = true;
2109 break; 2136 break;
2110 case Qt::Key_Insert: 2137 case Qt::Key_Insert:
2111 mView->newEvent(); 2138 mView->newEvent();
2112 break; 2139 break;
2113 case Qt::Key_S : 2140 case Qt::Key_S :
2114 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2141 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2115 mView->newSubTodo(); 2142 mView->newSubTodo();
2116 else 2143 else
2117 mView->dialogManager()->showSearchDialog(); 2144 mView->dialogManager()->showSearchDialog();
2118 break; 2145 break;
2119 case Qt::Key_Y : 2146 case Qt::Key_Y :
2120 case Qt::Key_Z : 2147 case Qt::Key_Z :
2121 mView->viewManager()->showWorkWeekView(); 2148 mView->viewManager()->showWorkWeekView();
2122 showSelectedDates = true; 2149 showSelectedDates = true;
2123 break; 2150 break;
2124 case Qt::Key_U : 2151 case Qt::Key_U :
2125 mView->viewManager()->showWeekView(); 2152 mView->viewManager()->showWeekView();
2126 showSelectedDates = true; 2153 showSelectedDates = true;
2127 break; 2154 break;
2128 case Qt::Key_H : 2155 case Qt::Key_H :
2129 keyBindings(); 2156 keyBindings();
2130 break; 2157 break;
2131 case Qt::Key_W: 2158 case Qt::Key_W:
2132 mView->viewManager()->showWhatsNextView(); 2159 mView->viewManager()->showWhatsNextView();
2133 break; 2160 break;
2134 case Qt::Key_L: 2161 case Qt::Key_L:
2135 mView->viewManager()->showListView(); 2162 mView->viewManager()->showListView();
2136 break; 2163 break;
2137 case Qt::Key_N: 2164 case Qt::Key_N:
2138 mView->viewManager()->showNextView(); 2165 mView->viewManager()->showNextView();
2139 break; 2166 break;
2140 case Qt::Key_V: 2167 case Qt::Key_V:
2141 mView->viewManager()->showTodoView(); 2168 mView->viewManager()->showTodoView();
2142 break; 2169 break;
2143 case Qt::Key_C: 2170 case Qt::Key_C:
2144 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 2171 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
2145 break; 2172 break;
2146 case Qt::Key_P: 2173 case Qt::Key_P:
2147 mView->showDatePicker( ); 2174 mView->showDatePicker( );
2148 break; 2175 break;
2149 case Qt::Key_F: 2176 case Qt::Key_F:
2150 mView->editFilters(); 2177 mView->editFilters();
2151 break; 2178 break;
2152 case Qt::Key_R: 2179 case Qt::Key_R:
2153 mView->toggleFilter(); 2180 mView->toggleFilter();
2154 break; 2181 break;
2155 case Qt::Key_X: 2182 case Qt::Key_X:
2156 if ( e->state() == Qt::ControlButton ) 2183 if ( e->state() == Qt::ControlButton )
2157 mView->toggleDateNavigatorWidget(); 2184 mView->toggleDateNavigatorWidget();
2158 else { 2185 else {
2159 mView->viewManager()->showNextXView(); 2186 mView->viewManager()->showNextXView();
2160 showSelectedDates = true; 2187 showSelectedDates = true;
2161 } 2188 }
2162 break; 2189 break;
2163 case Qt::Key_Space: 2190 case Qt::Key_Space:
2164 mView->toggleExpand(); 2191 mView->toggleExpand();
2165 break; 2192 break;
2166 case Qt::Key_A: 2193 case Qt::Key_A:
2167 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 2194 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
2168 mView->showNextAlarms(); 2195 mView->showNextAlarms();
2169 else 2196 else
2170 mView->toggleAllDaySize(); 2197 mView->toggleAllDaySize();
2171 break; 2198 break;
2172 case Qt::Key_T: 2199 case Qt::Key_T:
2173 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2200 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2174 mView->newTodo(); 2201 mView->newTodo();
2175 else { 2202 else {
2176 mView->goToday(); 2203 mView->goToday();
2177 showSelectedDates = true; 2204 showSelectedDates = true;
2178 } 2205 }
2179 break; 2206 break;
2180 case Qt::Key_Q: 2207 case Qt::Key_Q:
2181 if ( e->state() == Qt::ControlButton ) 2208 if ( e->state() == Qt::ControlButton )
2182 mView->conflictNotAll(); 2209 mView->conflictNotAll();
2183 else if ( e->state() == Qt::ShiftButton ) 2210 else if ( e->state() == Qt::ShiftButton )
2184 mView->conflictAllday(); 2211 mView->conflictAllday();
2185 else 2212 else
2186 mView->conflictAll(); 2213 mView->conflictAll();
2187 break; 2214 break;
2188 case Qt::Key_J: 2215 case Qt::Key_J:
2189 mView->viewManager()->showJournalView(); 2216 mView->viewManager()->showJournalView();
2190 break; 2217 break;
2191 case Qt::Key_B: 2218 case Qt::Key_B:
2192 mView->editIncidenceDescription();; 2219 mView->editIncidenceDescription();;
2193 break; 2220 break;
2194 // case Qt::Key_Return: 2221 // case Qt::Key_Return:
2195 case Qt::Key_E: 2222 case Qt::Key_E:
2196 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2223 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2197 mView->newEvent(); 2224 mView->newEvent();
2198 else 2225 else
2199 mView->editIncidence(); 2226 mView->editIncidence();
2200 break; 2227 break;
2201 case Qt::Key_Plus: 2228 case Qt::Key_Plus:
2202 size = p->mHourSize +2; 2229 size = p->mHourSize +2;
2203 if ( size <= 22 ) 2230 if ( size <= 22 )
2204 configureAgenda( size ); 2231 configureAgenda( size );
2205 break; 2232 break;
2206 case Qt::Key_Minus: 2233 case Qt::Key_Minus:
2207 size = p->mHourSize - 2; 2234 size = p->mHourSize - 2;
2208 if ( size >= 4 ) 2235 if ( size >= 4 )
2209 configureAgenda( size ); 2236 configureAgenda( size );
2210 break; 2237 break;
2211 2238
2212 2239
2213 default: 2240 default:
2214 e->ignore(); 2241 e->ignore();
2215 } 2242 }
2216 if ( pro > 0 ) { 2243 if ( pro > 0 ) {
2217 selectFilter( pro+1 ); 2244 selectFilter( pro+1 );
2218 } 2245 }
2219 if ( showSelectedDates ) { 2246 if ( showSelectedDates ) {
2220 ;// setCaptionToDates(); 2247 ;// setCaptionToDates();
2221 } 2248 }
2222 2249
2223} 2250}
2224void MainWindow::fillFilterMenuTB() 2251void MainWindow::fillFilterMenuTB()
2225{ 2252{
2226 selectFilterMenuTB->clear(); 2253 selectFilterMenuTB->clear();
2227 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); 2254 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 );
2228 selectFilterMenuTB->insertSeparator(); 2255 selectFilterMenuTB->insertSeparator();
2229 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); 2256 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 );
2230 2257
2231 selectFilterMenuTB->insertSeparator(); 2258 selectFilterMenuTB->insertSeparator();
2232 QPtrList<CalFilter> fili = mView->filters(); 2259 QPtrList<CalFilter> fili = mView->filters();
2233 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2260 CalFilter *curfilter = mView->filterView()->selectedFilter();
2234 CalFilter *filter = fili.first(); 2261 CalFilter *filter = fili.first();
2235 int iii = 2; 2262 int iii = 2;
2236 bool checkitem = mView->filterView()->filtersEnabled(); 2263 bool checkitem = mView->filterView()->filtersEnabled();
2237 while(filter) { 2264 while(filter) {
2238 selectFilterMenuTB->insertItem( filter->name(), iii ); 2265 selectFilterMenuTB->insertItem( filter->name(), iii );
2239 if ( filter == curfilter) 2266 if ( filter == curfilter)
2240 selectFilterMenuTB->setItemChecked( iii, checkitem ); 2267 selectFilterMenuTB->setItemChecked( iii, checkitem );
2241 filter = fili.next(); 2268 filter = fili.next();
2242 ++iii; 2269 ++iii;
2243 } 2270 }
2244 if ( !checkitem ) 2271 if ( !checkitem )
2245 selectFilterMenuTB->setItemChecked( 1, true ); 2272 selectFilterMenuTB->setItemChecked( 1, true );
2246 2273
2247 int x = 0; 2274 int x = 0;
2248 int y = iconToolBar->height(); 2275 int y = iconToolBar->height();
2249 int dX = 0; 2276 int dX = 0;
2250 int dY = 0; 2277 int dY = 0;
2251 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2278 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2252 if ( iconToolBar->y() > height()/2 ) { 2279 if ( iconToolBar->y() > height()/2 ) {
2253 dY = selectFilterMenuTB->sizeHint().height()+8; 2280 dY = selectFilterMenuTB->sizeHint().height()+8;
2254 y = 0; 2281 y = 0;
2255 } 2282 }
2256 } else { 2283 } else {
2257 if ( iconToolBar->x() > width()/2 ) { // right side 2284 if ( iconToolBar->x() > width()/2 ) { // right side
2258 x=0; 2285 x=0;
2259 dX= selectFilterMenuTB->sizeHint().width()+8; 2286 dX= selectFilterMenuTB->sizeHint().width()+8;
2260 y = 0; 2287 y = 0;
2261 } else { 2288 } else {
2262 x= iconToolBar->width(); 2289 x= iconToolBar->width();
2263 y = 0; 2290 y = 0;
2264 } 2291 }
2265 } 2292 }
2266 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2293 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2267 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); 2294 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)));
2268} 2295}
2269void MainWindow::fillFilterMenu() 2296void MainWindow::fillFilterMenu()
2270{ 2297{
2271 selectFilterMenu->clear(); 2298 selectFilterMenu->clear();
2272 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 2299 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
2273 selectFilterMenu->insertSeparator(); 2300 selectFilterMenu->insertSeparator();
2274 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); 2301 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 );
2275 2302
2276 selectFilterMenu->insertSeparator(); 2303 selectFilterMenu->insertSeparator();
2277 QPtrList<CalFilter> fili = mView->filters(); 2304 QPtrList<CalFilter> fili = mView->filters();
2278 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2305 CalFilter *curfilter = mView->filterView()->selectedFilter();
2279 CalFilter *filter = fili.first(); 2306 CalFilter *filter = fili.first();
2280 int iii = 2; 2307 int iii = 2;
2281 bool checkitem = mView->filterView()->filtersEnabled(); 2308 bool checkitem = mView->filterView()->filtersEnabled();
2282 while(filter) { 2309 while(filter) {
2283 selectFilterMenu->insertItem( filter->name(), iii ); 2310 selectFilterMenu->insertItem( filter->name(), iii );
2284 if ( filter == curfilter) 2311 if ( filter == curfilter)
2285 selectFilterMenu->setItemChecked( iii, checkitem ); 2312 selectFilterMenu->setItemChecked( iii, checkitem );
2286 filter = fili.next(); 2313 filter = fili.next();
2287 ++iii; 2314 ++iii;
2288 } 2315 }
2289 if ( !checkitem ) 2316 if ( !checkitem )
2290 selectFilterMenu->setItemChecked( 1, true ); 2317 selectFilterMenu->setItemChecked( 1, true );
2291} 2318}
2292void MainWindow::fillFilterMenuPopup() 2319void MainWindow::fillFilterMenuPopup()
2293{ 2320{
2294 filterPopupMenu->clear(); 2321 filterPopupMenu->clear();
2295 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); 2322 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 );
2296 2323
2297 filterPopupMenu->insertSeparator(); 2324 filterPopupMenu->insertSeparator();
2298 QPtrList<CalFilter> fili = mView->filters(); 2325 QPtrList<CalFilter> fili = mView->filters();
2299 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2326 CalFilter *curfilter = mView->filterView()->selectedFilter();
2300 CalFilter *filter = fili.first(); 2327 CalFilter *filter = fili.first();
2301 int iii = 1; 2328 int iii = 1;
2302 bool checkitem = mView->filterView()->filtersEnabled(); 2329 bool checkitem = mView->filterView()->filtersEnabled();
2303 while(filter) { 2330 while(filter) {
2304 filterPopupMenu->insertItem( filter->name(), iii ); 2331 filterPopupMenu->insertItem( filter->name(), iii );
2305 if ( filter == curfilter) 2332 if ( filter == curfilter)
2306 filterPopupMenu->setItemChecked( iii, checkitem ); 2333 filterPopupMenu->setItemChecked( iii, checkitem );
2307 filter = fili.next(); 2334 filter = fili.next();
2308 ++iii; 2335 ++iii;
2309 } 2336 }
2310 if ( !checkitem ) 2337 if ( !checkitem )
2311 filterPopupMenu->setItemChecked( 0, true ); 2338 filterPopupMenu->setItemChecked( 0, true );
2312} 2339}
2313void MainWindow::selectFilter( int fil ) 2340void MainWindow::selectFilter( int fil )
2314{ 2341{
2315 2342
2316 if ( fil == 0 ) { 2343 if ( fil == 0 ) {
2317 mView->editFilters( ); 2344 mView->editFilters( );
2318 } else if ( fil == 1 ){ 2345 } else if ( fil == 1 ){
2319 if ( mView->filterView()->filtersEnabled() ) 2346 if ( mView->filterView()->filtersEnabled() )
2320 mView->toggleFilerEnabled( ); 2347 mView->toggleFilerEnabled( );
2321 } else { 2348 } else {
2322 if ( !mView->filterView()->filtersEnabled() ) { 2349 if ( !mView->filterView()->filtersEnabled() ) {
2323 mView->filterView()->blockSignals( true ); 2350 mView->filterView()->blockSignals( true );
2324 mView->toggleFilerEnabled( ); 2351 mView->toggleFilerEnabled( );
2325 mView->filterView()->blockSignals( false ); 2352 mView->filterView()->blockSignals( false );
2326 } 2353 }
2327 mView->selectFilter( fil-2 ); 2354 mView->selectFilter( fil-2 );
2328 } 2355 }
2329} 2356}
2330void MainWindow::updateFilterToolbar() 2357void MainWindow::updateFilterToolbar()
2331{ 2358{
2332 if ( filterMenubar ) { 2359 if ( filterMenubar ) {
2333 if ( !mView->filterView()->filtersEnabled() ) { 2360 if ( !mView->filterView()->filtersEnabled() ) {
2334 filterMenubar->changeItem( 0, i18n("No Filter") ); 2361 filterMenubar->changeItem( 0, i18n("No Filter") );
2335 } else { 2362 } else {
2336 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2363 CalFilter *curfilter = mView->filterView()->selectedFilter();
2337 if ( curfilter ) { 2364 if ( curfilter ) {
2338 QString name = curfilter->name(); 2365 QString name = curfilter->name();
2339 if ( name.length() > 12 ) 2366 if ( name.length() > 12 )
2340 name = name.left(10)+"..."; 2367 name = name.left(10)+"...";
2341 filterMenubar->changeItem( 0, name ); 2368 filterMenubar->changeItem( 0, name );
2342 } 2369 }
2343 } 2370 }
2344 } 2371 }
2345} 2372}
2346void MainWindow::selectFilterPopup( int fil ) 2373void MainWindow::selectFilterPopup( int fil )
2347{ 2374{
2348 selectFilter( fil + 1 ); 2375 selectFilter( fil + 1 );
2349 2376
2350} 2377}
2351void MainWindow::configureToolBar( int item ) 2378void MainWindow::configureToolBar( int item )
2352{ 2379{
2353 2380
2354 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 2381 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
2355 KOPrefs *p = KOPrefs::instance(); 2382 KOPrefs *p = KOPrefs::instance();
2356 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 2383 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
2357 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); 2384 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 );
2358 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); 2385 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 );
2359 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 2386 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
2360 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 2387 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
2361 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); 2388 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 );
2362 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); 2389 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 );
2363 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); 2390 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 );
2364 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); 2391 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 );
2365 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 2392 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
2366 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 2393 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
2367 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 2394 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
2368 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 2395 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
2369 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 2396 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
2370 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 2397 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
2371 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 2398 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
2372 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 2399 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
2373 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 2400 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
2374 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 2401 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
2375 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 2402 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
2376 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 2403 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
2377 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 2404 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
2378 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 2405 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
2379 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 2406 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
2380 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 2407 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
2381 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 2408 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
2382 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 2409 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
2383 // initActions(); 2410 // initActions();
2384 setCaption ( i18n("Toolbar changes needs a restart!") ); 2411 setCaption ( i18n("Toolbar changes needs a restart!") );
2385} 2412}
2386void MainWindow::setCaption ( const QString & c ) 2413void MainWindow::setCaption ( const QString & c )
2387{ 2414{
2388 QString cap = c; 2415 QString cap = c;
2389 cap.replace( QRegExp("\n"), " " ); 2416 cap.replace( QRegExp("\n"), " " );
2390 cap = cap.stripWhiteSpace(); 2417 cap = cap.stripWhiteSpace();
2391 if ( cap.isEmpty() ) 2418 if ( cap.isEmpty() )
2392 cap = "KO/Pi"; 2419 cap = "KO/Pi";
2393 QWidget::setCaption( cap ); 2420 QWidget::setCaption( cap );
2394} 2421}
2395void MainWindow::setCaptionToDates() 2422void MainWindow::setCaptionToDates()
2396{ 2423{
2397 QString selDates; 2424 QString selDates;
2398 QDate date = mView->startDate(); 2425 QDate date = mView->startDate();
2399 if ( ! date.isValid() ) { 2426 if ( ! date.isValid() ) {
2400 setCaption(""); 2427 setCaption("");
2401 return; 2428 return;
2402 } 2429 }
2403 selDates = KGlobal::locale()->formatDate( date, true); 2430 selDates = KGlobal::locale()->formatDate( date, true);
2404 if (mView->startDate() < mView->endDate() ) 2431 if (mView->startDate() < mView->endDate() )
2405 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 2432 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
2406 else { 2433 else {
2407 QString addString; 2434 QString addString;
2408 if ( date == QDateTime::currentDateTime().date() ) 2435 if ( date == QDateTime::currentDateTime().date() )
2409 addString = i18n("Today"); 2436 addString = i18n("Today");
2410 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 2437 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
2411 addString = i18n("Tomorrow"); 2438 addString = i18n("Tomorrow");
2412 if ( !addString.isEmpty() ) 2439 if ( !addString.isEmpty() )
2413 selDates = addString+", "+selDates ; 2440 selDates = addString+", "+selDates ;
2414 } 2441 }
2415 setCaption( i18n("Dates: ") + selDates ); 2442 setCaption( i18n("Dates: ") + selDates );
2416 2443
2417} 2444}
2418void MainWindow::showConfigureAgenda( ) 2445void MainWindow::showConfigureAgenda( )
2419{ 2446{
2420 int iii; 2447 int iii;
2421 for ( iii = 1;iii<= 10 ;++iii ){ 2448 for ( iii = 1;iii<= 10 ;++iii ){
2422 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 2449 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
2423 } 2450 }
2424 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 2451 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
2425} 2452}
2426void MainWindow::configureAgenda( int item ) 2453void MainWindow::configureAgenda( int item )
2427{ 2454{
2428 if ( KOPrefs::instance()->mHourSize == item ) 2455 if ( KOPrefs::instance()->mHourSize == item )
2429 return; 2456 return;
2430 KOPrefs::instance()->mHourSize=item; 2457 KOPrefs::instance()->mHourSize=item;
2431 mView->viewManager()->agendaView()->updateConfig(); 2458 mView->viewManager()->agendaView()->updateConfig();
2432} 2459}
2433 2460
2434void MainWindow::saveCalendar() 2461void MainWindow::saveCalendar()
2435{ 2462{
2436 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 2463 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
2437 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 2464 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
2438 bupDir = KGlobalSettings::backupDataDir(); 2465 bupDir = KGlobalSettings::backupDataDir();
2439 bupDir = KGlobal::formatMessage ( bupDir, 0 ); 2466 bupDir = KGlobal::formatMessage ( bupDir, 0 );
2440 QString bupHint; 2467 QString bupHint;
2441 if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) 2468 if ( !KPimGlobalPrefs::instance()->mBackupEnabled )
2442 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); 2469 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)");
2443 if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; 2470 if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return;
2444 bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; 2471 bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled;
2445 KPimGlobalPrefs::instance()->mBackupEnabled = false; 2472 KPimGlobalPrefs::instance()->mBackupEnabled = false;
2446 save(); 2473 save();
2447 KPimGlobalPrefs::instance()->mBackupEnabled = enabled; 2474 KPimGlobalPrefs::instance()->mBackupEnabled = enabled;
2448 backupAllFiles(); 2475 backupAllFiles();
2449} 2476}
2450void MainWindow::loadCalendar() 2477void MainWindow::loadCalendar()
2451{ 2478{
2452 2479
2453 2480
2454#if 0 2481#if 0
2455 QString fn = KOPrefs::instance()->mLastLoadFile; 2482 QString fn = KOPrefs::instance()->mLastLoadFile;
2456 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 2483 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
2457 2484
2458 if ( fn == "" ) 2485 if ( fn == "" )
2459 return; 2486 return;
2460 QFileInfo info; 2487 QFileInfo info;
2461 info.setFile( fn ); 2488 info.setFile( fn );
2462 QString mess; 2489 QString mess;
2463 bool loadbup = true; 2490 bool loadbup = true;
2464 if ( info. exists() ) { 2491 if ( info. exists() ) {
2465 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2492 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2466 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 2493 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
2467 mess, 2494 mess,
2468 i18n("Load!"), i18n("Cancel"), 0, 2495 i18n("Load!"), i18n("Cancel"), 0,
2469 0, 1 ); 2496 0, 1 );
2470 if ( result != 0 ) { 2497 if ( result != 0 ) {
2471 loadbup = false; 2498 loadbup = false;
2472 } 2499 }
2473 } else { 2500 } else {
2474 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2501 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2475 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2502 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2476 0, 1 ); 2503 0, 1 );
2477 2504
2478 return; 2505 return;
2479 } 2506 }
2480 if ( loadbup ) { 2507 if ( loadbup ) {
2481 mView->openCalendar( fn ); 2508 mView->openCalendar( fn );
2482 KOPrefs::instance()->mLastLoadFile = fn; 2509 KOPrefs::instance()->mLastLoadFile = fn;
2483 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2510 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2484 setCaption(mess); 2511 setCaption(mess);
2485 } 2512 }
2486#endif 2513#endif
2487 2514
2488} 2515}
2489void MainWindow::quickImportIcal() 2516void MainWindow::quickImportIcal()
2490{ 2517{
2491 importFile( KOPrefs::instance()->mLastImportFile, false ); 2518 importFile( KOPrefs::instance()->mLastImportFile, false );
2492} 2519}
2493void MainWindow::importFile( QString fn, bool quick ) 2520void MainWindow::importFile( QString fn, bool quick )
2494{ 2521{
2495 QFileInfo info; 2522 QFileInfo info;
2496 info.setFile( fn ); 2523 info.setFile( fn );
2497 QString mess; 2524 QString mess;
2498 if ( !info. exists() ) { 2525 if ( !info. exists() ) {
2499 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 2526 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
2500 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2527 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2501 mess ); 2528 mess );
2502 return; 2529 return;
2503 } 2530 }
2504 int result = 0; 2531 int result = 0;
2505 if ( !quick ) { 2532 if ( !quick ) {
2506 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2533 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2507 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2534 result = QMessageBox::warning( this, "KO/Pi: Warning!",
2508 mess, 2535 mess,
2509 "Import", "Cancel", 0, 2536 "Import", "Cancel", 0,
2510 0, 1 ); 2537 0, 1 );
2511 } 2538 }
2512 if ( result == 0 ) { 2539 if ( result == 0 ) {
2513 if ( mView->openCalendar( fn, true )) { 2540 if ( mView->openCalendar( fn, true )) {
2514 KOPrefs::instance()->mLastImportFile = fn; 2541 KOPrefs::instance()->mLastImportFile = fn;
2515 setCaption(i18n("Imported file successfully")); 2542 setCaption(i18n("Imported file successfully"));
2516 } else { 2543 } else {
2517 setCaption(i18n("Error importing file")); 2544 setCaption(i18n("Error importing file"));
2518 } 2545 }
2546 mView->updateView();
2519 } 2547 }
2520} 2548}
2521 2549
2522void MainWindow::importIcal() 2550void MainWindow::importIcal()
2523{ 2551{
2524 2552
2525 QString fn =KOPrefs::instance()->mLastImportFile; 2553 QString fn =KOPrefs::instance()->mLastImportFile;
2526 2554
2527 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2555 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2528 if ( fn == "" ) 2556 if ( fn == "" )
2529 return; 2557 return;
2530 importFile( fn, true ); 2558 importFile( fn, true );
2531 2559
2532} 2560}
2533 2561
2534void MainWindow::exportVCalendar() 2562void MainWindow::exportVCalendar()
2535{ 2563{
2536 QString fn = KOPrefs::instance()->mLastVcalFile; 2564 QString fn = KOPrefs::instance()->mLastVcalFile;
2537 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2565 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2538 if ( fn == "" ) 2566 if ( fn == "" )
2539 return; 2567 return;
2540 QFileInfo info; 2568 QFileInfo info;
2541 info.setFile( fn ); 2569 info.setFile( fn );
2542 QString mes; 2570 QString mes;
2543 bool createbup = true; 2571 bool createbup = true;
2544 if ( info. exists() ) { 2572 if ( info. exists() ) {
2545 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2573 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2546 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2574 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2547 i18n("Overwrite!"), i18n("Cancel"), 0, 2575 i18n("Overwrite!"), i18n("Cancel"), 0,
2548 0, 1 ); 2576 0, 1 );
2549 if ( result != 0 ) { 2577 if ( result != 0 ) {
2550 createbup = false; 2578 createbup = false;
2551 } 2579 }
2552 } 2580 }
2553 if ( createbup ) { 2581 if ( createbup ) {
2554 if ( mView->exportVCalendar( fn ) ) { 2582 if ( mView->exportVCalendar( fn ) ) {
2555 KOPrefs::instance()->mLastVcalFile = fn; 2583 KOPrefs::instance()->mLastVcalFile = fn;
2556 if ( fn.length() > 20 ) 2584 if ( fn.length() > 20 )
2557 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2585 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2558 else 2586 else
2559 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2587 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2560 setCaption(mes); 2588 setCaption(mes);
2561 } 2589 }
2562 } 2590 }
2563 2591
2564} 2592}
2565QString MainWindow::sentSyncFile() 2593QString MainWindow::sentSyncFile()
2566{ 2594{
2567#ifdef DESKTOP_VERSION 2595#ifdef DESKTOP_VERSION
2568 return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); 2596 return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) );
2569#else 2597#else
2570 return QString( "/tmp/copysynccal.ics" ); 2598 return QString( "/tmp/copysynccal.ics" );
2571#endif 2599#endif
2572} 2600}
2573 2601
2574void MainWindow::syncFileRequest() 2602void MainWindow::syncFileRequest()
2575{ 2603{
2576 while ( mSyncManager->blockSave() ) { 2604 while ( mSyncManager->blockSave() ) {
2577 qApp->processEvents(); 2605 qApp->processEvents();
2578 } 2606 }
2579 mSyncManager->setBlockSave(true); 2607 mSyncManager->setBlockSave(true);
2580 2608
2581 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2609 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2582 mSyncManager->slotSyncMenu( 999 ); 2610 mSyncManager->slotSyncMenu( 999 );
2583 } 2611 }
2584 2612
2585 setCaption(i18n("Saving Data to temp file ..." )); 2613 setCaption(i18n("Saving Data to temp file ..." ));
2586 mView->saveCalendar( sentSyncFile() ); 2614 mView->saveCalendar( sentSyncFile() );
2587 setCaption(i18n("Data saved to temp file!" )); 2615 setCaption(i18n("Data saved to temp file!" ));
2588 mSyncManager->setBlockSave( false ); 2616 mSyncManager->setBlockSave( false );
2589 2617
2590} 2618}
2591void MainWindow::getFile( bool success ) 2619void MainWindow::getFile( bool success )
2592{ 2620{
2593 if ( ! success ) { 2621 if ( ! success ) {
2594 setCaption( i18n("Error receiving file. Nothing changed!") ); 2622 setCaption( i18n("Error receiving file. Nothing changed!") );
2595 return; 2623 return;
2596 } 2624 }
2597 mView->mergeFile( sentSyncFile() ); 2625 mView->mergeFile( sentSyncFile() );
2598 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2626 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2599 mSyncManager->slotSyncMenu( 999 ); 2627 mSyncManager->slotSyncMenu( 999 );
2600 } 2628 }
2601 setCaption( i18n("Pi-Sync successful!") ); 2629 setCaption( i18n("Pi-Sync successful!") );
2602} 2630}
2603void MainWindow::printListView() 2631void MainWindow::printListView()
2604{ 2632{
2605 2633
2606 QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); 2634 QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items.");
2607 2635
2608 KMessageBox::information( this, message); 2636 KMessageBox::information( this, message);
2609} 2637}
2610void MainWindow::printSel( ) 2638void MainWindow::printSel( )
2611{ 2639{
2612 mView->viewManager()->agendaView()->agenda()->printSelection(); 2640 mView->viewManager()->agendaView()->agenda()->printSelection();
2613} 2641}
2614 2642
2615void MainWindow::printCal() 2643void MainWindow::printCal()
2616{ 2644{
2617 mView->print();//mCp->showDialog(); 2645 mView->print();//mCp->showDialog();
2618} 2646}
2619 2647
2620 2648
2621#include "libkdepim/kdatepicker.h" 2649#include "libkdepim/kdatepicker.h"
2622#include <kdatetbl.h> 2650#include <kdatetbl.h>
2623 2651
2624void MainWindow::weekAction() 2652void MainWindow::weekAction()
2625{ 2653{
2626 int month; 2654 int month;
2627 KPopupFrame* popup = new KPopupFrame(this); 2655 KPopupFrame* popup = new KPopupFrame(this);
2628 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2656 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2629 // ----- 2657 // -----
2630 picker->resize(picker->sizeHint()); 2658 picker->resize(picker->sizeHint());
2631 popup->setMainWidget(picker); 2659 popup->setMainWidget(picker);
2632 picker->setFocus(); 2660 picker->setFocus();
2633 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2661 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2634 int x = 0; 2662 int x = 0;
2635 int y = iconToolBar->height(); 2663 int y = iconToolBar->height();
2636 int dX = 0; 2664 int dX = 0;
2637 int dY = 0; 2665 int dY = 0;
2638 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2666 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2639 if ( iconToolBar->y() > height()/2 ) { 2667 if ( iconToolBar->y() > height()/2 ) {
2640 dY = picker->sizeHint().height()+8; 2668 dY = picker->sizeHint().height()+8;
2641 y = 0; 2669 y = 0;
2642 } 2670 }
2643 } else { 2671 } else {
2644 if ( iconToolBar->x() > width()/2 ) { // right side 2672 if ( iconToolBar->x() > width()/2 ) { // right side
2645 x=0; 2673 x=0;
2646 dX= picker->sizeHint().width()+8; 2674 dX= picker->sizeHint().width()+8;
2647 y = 0; 2675 y = 0;
2648 } else { 2676 } else {
2649 x= iconToolBar->width(); 2677 x= iconToolBar->width();
2650 y = 0; 2678 y = 0;
2651 } 2679 }
2652 } 2680 }
2653 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2681 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2654 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2682 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2655 { 2683 {
2656 month = picker->getResult(); 2684 month = picker->getResult();
2657 emit selectWeek ( month ); 2685 emit selectWeek ( month );
2658 //qDebug("weekSelected %d ", month); 2686 //qDebug("weekSelected %d ", month);
2659 } 2687 }
2660 delete popup; 2688 delete popup;
2661} 2689}
2662 2690
2663void MainWindow::hideEvent ( QHideEvent * ) 2691void MainWindow::hideEvent ( QHideEvent * )
2664{ 2692{
2665 QString message; 2693 QString message;
2666 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2694 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2667 if ( nextA.isValid() ) { 2695 if ( nextA.isValid() ) {
2668 QString sum = mCalendar->nextSummary(); 2696 QString sum = mCalendar->nextSummary();
2669 2697
2670 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); 2698 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false));
2671 setCaption( message ); 2699 setCaption( message );
2672 } 2700 }
2673} 2701}
2674 2702
2675void MainWindow::resizeEvent( QResizeEvent* e) 2703void MainWindow::resizeEvent( QResizeEvent* e)
2676{ 2704{
2677#ifndef DESKTOP_VERSION 2705#ifndef DESKTOP_VERSION
2678 if ( filterToolBar ) { 2706 if ( filterToolBar ) {
2679 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { 2707 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) {
2680 if (QApplication::desktop()->width() > QApplication::desktop()->height() ) 2708 if (QApplication::desktop()->width() > QApplication::desktop()->height() )
2681 filterToolBar->hide(); 2709 filterToolBar->hide();
2682 else 2710 else
2683 filterToolBar->show(); 2711 filterToolBar->show();
2684 } 2712 }
2685 } 2713 }
2686#endif 2714#endif
2687 QMainWindow::resizeEvent( e); 2715 QMainWindow::resizeEvent( e);
2688} 2716}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 7d3d492..fdcf7c4 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,178 +1,184 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qmenubar.h> 8#include <qmenubar.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qregexp.h> 10#include <qregexp.h>
11 11
12#include <libkcal/incidence.h> 12#include <libkcal/incidence.h>
13#include <ksyncmanager.h> 13#include <ksyncmanager.h>
14#include <kpopupmenu.h> 14#include <kpopupmenu.h>
15#ifndef DESKTOP_VERSION 15#ifndef DESKTOP_VERSION
16#include <qcopchannel_qws.h> 16#include <qcopchannel_qws.h>
17#endif 17#endif
18class QAction; 18class QAction;
19class CalendarView; 19class CalendarView;
20class KSyncProfile; 20class KSyncProfile;
21#ifdef DESKTOP_VERSION 21#ifdef DESKTOP_VERSION
22 22
23#define QPEToolBar QToolBar 23#define QPEToolBar QToolBar
24#endif 24#endif
25class QPEToolBar; 25class QPEToolBar;
26 26
27 27
28namespace KCal { 28namespace KCal {
29class CalendarLocal; 29class CalendarLocal;
30} 30}
31 31
32using namespace KCal; 32using namespace KCal;
33 33
34class MainWindow : public QMainWindow 34class MainWindow : public QMainWindow
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 public: 37 public:
38 MainWindow( QWidget *parent = 0, const char *name = 0 ); 38 MainWindow( QWidget *parent = 0, const char *name = 0 );
39 ~MainWindow(); 39 ~MainWindow();
40 bool beamReceiveEnabled(); 40 bool beamReceiveEnabled();
41 static QString defaultFileName(); 41 static QString defaultFileName();
42 static QString syncFileName(); 42 static QString syncFileName();
43 static QString resourcePath(); 43 static QString resourcePath();
44 public slots: 44 public slots:
45 void setUsesBigPixmaps ( bool ); 45 void setUsesBigPixmaps ( bool );
46 void setCaption ( const QString & ); 46 void setCaption ( const QString & );
47 void updateWeekNum(const KCal::DateList &); 47 void updateWeekNum(const KCal::DateList &);
48 void updateWeek(QDate); 48 void updateWeek(QDate);
49 void updateFilterToolbar(); 49 void updateFilterToolbar();
50 virtual void showMaximized (); 50 virtual void showMaximized ();
51 void configureAgenda( int ); 51 void configureAgenda( int );
52 void recieve( const QCString& msg, const QByteArray& data ); 52 void recieve( const QCString& msg, const QByteArray& data );
53 void receiveStart( const QCString& msg, const QByteArray& data );
53 protected slots: 54 protected slots:
55 void loadDataAfterStart();
54 void calHint(); 56 void calHint();
55 void startMultiSync(); 57 void startMultiSync();
56 void setCaptionToDates(); 58 void setCaptionToDates();
57 void weekAction(); 59 void weekAction();
58 void about(); 60 void about();
59 void licence(); 61 void licence();
60 void faq(); 62 void faq();
61 void usertrans(); 63 void usertrans();
62 void features(); 64 void features();
63 void synchowto(); 65 void synchowto();
64 void storagehowto(); 66 void storagehowto();
65 void timetrackinghowto(); 67 void timetrackinghowto();
66 void kdesynchowto(); 68 void kdesynchowto();
67 void multisynchowto(); 69 void multisynchowto();
68 void whatsNew(); 70 void whatsNew();
69 void keyBindings(); 71 void keyBindings();
70 void aboutAutoSaving();; 72 void aboutAutoSaving();;
71 void aboutKnownBugs(); 73 void aboutKnownBugs();
72 74
73 void processIncidenceSelection( Incidence * ); 75 void processIncidenceSelection( Incidence * );
74 76
75 void importQtopia(); 77 void importQtopia();
76 void importBday(); 78 void importBday();
77 void importOL(); 79 void importOL();
78 void importIcal(); 80 void importIcal();
79 void importFile( QString, bool ); 81 void importFile( QString, bool );
80 void quickImportIcal(); 82 void quickImportIcal();
81 83
82 void slotModifiedChanged( bool ); 84 void slotModifiedChanged( bool );
83 85
84 void save(); 86 void save();
85 void backupAllFiles(); 87 void backupAllFiles();
86 void saveStopTimer(); 88 void saveStopTimer();
87 void configureToolBar( int ); 89 void configureToolBar( int );
88 void printSel(); 90 void printSel();
89 void printCal(); 91 void printCal();
90 void printListView(); 92 void printListView();
91 void saveCalendar(); 93 void saveCalendar();
92 void loadCalendar(); 94 void loadCalendar();
93 void exportVCalendar(); 95 void exportVCalendar();
94 void fillFilterMenu(); 96 void fillFilterMenu();
95 void fillFilterMenuTB(); 97 void fillFilterMenuTB();
96 void selectFilter( int ); 98 void selectFilter( int );
97 void fillFilterMenuPopup(); 99 void fillFilterMenuPopup();
98 void selectFilterPopup( int ); 100 void selectFilterPopup( int );
99 void exportToPhone( int ); 101 void exportToPhone( int );
100 void toggleBeamReceive(); 102 void toggleBeamReceive();
101 void disableBR(bool); 103 void disableBR(bool);
102 signals: 104 signals:
103 void selectWeek ( int ); 105 void selectWeek ( int );
104 private slots: 106 private slots:
105 void slotResetFocus(); 107 void slotResetFocus();
106 void slotResetFocusLoop(); 108 void slotResetFocusLoop();
107 void showConfigureAgenda(); 109 void showConfigureAgenda();
108 void getFile( bool ); 110 void getFile( bool );
109 void syncFileRequest(); 111 void syncFileRequest();
110 112
111 protected: 113 protected:
112 int mFocusLoop; 114 int mFocusLoop;
113 void hideEvent ( QHideEvent * ); 115 void hideEvent ( QHideEvent * );
114 QString sentSyncFile(); 116 QString sentSyncFile();
115 void displayText( QString, QString); 117 void displayText( QString, QString);
116 void enableIncidenceActions( bool ); 118 void enableIncidenceActions( bool );
117 119
118 private: 120 private:
121
122 QCString mCStringMess;
123 QByteArray mByteData;
124
119 //void setMenuBar( QMenuBar * ); 125 //void setMenuBar( QMenuBar * );
120 bool mBRdisabled; 126 bool mBRdisabled;
121#ifndef DESKTOP_VERSION 127#ifndef DESKTOP_VERSION
122 QCopChannel* infrared; 128 QCopChannel* infrared;
123#endif 129#endif
124 QAction* brAction; 130 QAction* brAction;
125 KSyncManager* mSyncManager; 131 KSyncManager* mSyncManager;
126 bool mClosed; 132 bool mClosed;
127 void saveOnClose(); 133 void saveOnClose();
128 bool mFlagKeyPressed; 134 bool mFlagKeyPressed;
129 bool mBlockAtStartup; 135 bool mBlockAtStartup;
130 KMenuBar *menuBar1; 136 KMenuBar *menuBar1;
131 QPEToolBar *iconToolBar; 137 QPEToolBar *iconToolBar;
132 QPEToolBar *viewToolBar; 138 QPEToolBar *viewToolBar;
133 QPEToolBar *navigatorToolBar; 139 QPEToolBar *navigatorToolBar;
134 QPEToolBar *filterToolBar; 140 QPEToolBar *filterToolBar;
135 KMenuBar *filterMenubar; 141 KMenuBar *filterMenubar;
136 QPopupMenu * filterPopupMenu; 142 QPopupMenu * filterPopupMenu;
137 QPopupMenu * mCurrentItemMenu; 143 QPopupMenu * mCurrentItemMenu;
138 void initActions(); 144 void initActions();
139 void setDefaultPreferences(); 145 void setDefaultPreferences();
140 void resizeEvent( QResizeEvent* e); 146 void resizeEvent( QResizeEvent* e);
141 void keyPressEvent ( QKeyEvent * ) ; 147 void keyPressEvent ( QKeyEvent * ) ;
142 void keyReleaseEvent ( QKeyEvent * ) ; 148 void keyReleaseEvent ( QKeyEvent * ) ;
143 QPopupMenu *configureToolBarMenu; 149 QPopupMenu *configureToolBarMenu;
144 QPopupMenu *selectFilterMenu; 150 QPopupMenu *selectFilterMenu;
145 QPopupMenu *selectFilterMenuTB; 151 QPopupMenu *selectFilterMenuTB;
146 QPopupMenu *configureAgendaMenu, *syncMenu; 152 QPopupMenu *configureAgendaMenu, *syncMenu;
147 CalendarLocal *mCalendar; 153 CalendarLocal *mCalendar;
148 CalendarView *mView; 154 CalendarView *mView;
149 QAction *mNewSubTodoAction; 155 QAction *mNewSubTodoAction;
150 QAction *mWeekAction; 156 QAction *mWeekAction;
151 QFont mWeekFont; 157 QFont mWeekFont;
152 QPixmap mWeekPixmap; 158 QPixmap mWeekPixmap;
153 QColor mWeekBgColor; 159 QColor mWeekBgColor;
154 160
155 QAction *mShowAction; 161 QAction *mShowAction;
156 QAction *mEditAction; 162 QAction *mEditAction;
157 QAction *mDeleteAction; 163 QAction *mDeleteAction;
158 QAction *mCloneAction; 164 QAction *mCloneAction;
159 QAction *mMoveAction; 165 QAction *mMoveAction;
160 QAction *mBeamAction; 166 QAction *mBeamAction;
161 QAction *mCancelAction; 167 QAction *mCancelAction;
162 QAction *mPrintSelAction; 168 QAction *mPrintSelAction;
163 169
164 QAction *mToggleNav; 170 QAction *mToggleNav;
165 QAction *mToggleFilter; 171 QAction *mToggleFilter;
166 QAction *mToggleAllday; 172 QAction *mToggleAllday;
167 QAction *actionFilterMenuTB; 173 QAction *actionFilterMenuTB;
168 174
169 void closeEvent( QCloseEvent* ce ); 175 void closeEvent( QCloseEvent* ce );
170 QTimer mSaveTimer; 176 QTimer mSaveTimer;
171 //bool mBlockSaveFlag; 177 //bool mBlockSaveFlag;
172 bool mCalendarModifiedFlag; 178 bool mCalendarModifiedFlag;
173 QPixmap loadPixmap( QString ); 179 QPixmap loadPixmap( QString );
174 QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; 180 QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix;
175}; 181};
176 182
177 183
178#endif 184#endif