-rw-r--r-- | korganizer/calendarview.cpp | 19 | ||||
-rw-r--r-- | korganizer/calendarview.h | 2 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 10 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 |
4 files changed, 28 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 31e103d..8965d3b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -957,2049 +957,2048 @@ void CalendarView::checkAlarms() | |||
957 | mCalendar->addTodo( nt ); | 957 | mCalendar->addTodo( nt ); |
958 | nt->setSummary( "Work on 1"); | 958 | nt->setSummary( "Work on 1"); |
959 | nt->setPriority( 1 ); | 959 | nt->setPriority( 1 ); |
960 | nt->setDescription( "This is a test description of Work Project_1" ); | 960 | nt->setDescription( "This is a test description of Work Project_1" ); |
961 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); | 961 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); |
962 | nt->setPercentComplete( 20 ); | 962 | nt->setPercentComplete( 20 ); |
963 | 963 | ||
964 | Todo * sub2 = nt; | 964 | Todo * sub2 = nt; |
965 | sub2->setRelatedTo( root1 ); | 965 | sub2->setRelatedTo( root1 ); |
966 | 966 | ||
967 | 967 | ||
968 | nt = new Todo; | 968 | nt = new Todo; |
969 | mCalendar->addTodo( nt ); | 969 | mCalendar->addTodo( nt ); |
970 | nt->setSummary( "Work on 1: Lutz"); | 970 | nt->setSummary( "Work on 1: Lutz"); |
971 | nt->setPriority( 1 ); | 971 | nt->setPriority( 1 ); |
972 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 972 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
973 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); | 973 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); |
974 | nt->setPercentComplete( 20 ); | 974 | nt->setPercentComplete( 20 ); |
975 | Todo * workLutz12 = nt; | 975 | Todo * workLutz12 = nt; |
976 | workLutz12->setRelatedTo( sub2 ); | 976 | workLutz12->setRelatedTo( sub2 ); |
977 | 977 | ||
978 | nt = new Todo; | 978 | nt = new Todo; |
979 | mCalendar->addTodo( nt ); | 979 | mCalendar->addTodo( nt ); |
980 | nt->setSummary( "Work on 1: Norbert"); | 980 | nt->setSummary( "Work on 1: Norbert"); |
981 | nt->setPriority( 1 ); | 981 | nt->setPriority( 1 ); |
982 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 982 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
983 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); | 983 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); |
984 | nt->setPercentComplete( 20 ); | 984 | nt->setPercentComplete( 20 ); |
985 | Todo * workNorbert12 = nt; | 985 | Todo * workNorbert12 = nt; |
986 | workNorbert12->setRelatedTo( sub2 ); | 986 | workNorbert12->setRelatedTo( sub2 ); |
987 | 987 | ||
988 | int secLenRunning = 7200; | 988 | int secLenRunning = 7200; |
989 | int secLenPausing = 3600 * 3; | 989 | int secLenPausing = 3600 * 3; |
990 | int dayInterval = 1; | 990 | int dayInterval = 1; |
991 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); | 991 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); |
992 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); | 992 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); |
993 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); | 993 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); |
994 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); | 994 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); |
995 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); | 995 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); |
996 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); | 996 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); |
997 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); | 997 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); |
998 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); | 998 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); |
999 | 999 | ||
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | { | 1002 | { |
1003 | Todo * root1 = new Todo; | 1003 | Todo * root1 = new Todo; |
1004 | mCalendar->addTodo( root1 ); | 1004 | mCalendar->addTodo( root1 ); |
1005 | root1->setSummary( "Project2"); | 1005 | root1->setSummary( "Project2"); |
1006 | root1->setPriority( 1 ); | 1006 | root1->setPriority( 1 ); |
1007 | root1->setDescription( "This is a test description of a root Project 2" ); | 1007 | root1->setDescription( "This is a test description of a root Project 2" ); |
1008 | root1->setPercentComplete( 20 ); | 1008 | root1->setPercentComplete( 20 ); |
1009 | root1->setCategories( QString( "Cat_Pro2") ); | 1009 | root1->setCategories( QString( "Cat_Pro2") ); |
1010 | updateView(); | 1010 | updateView(); |
1011 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 1011 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
1012 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); | 1012 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); |
1013 | int secLenRunning = 7200; | 1013 | int secLenRunning = 7200; |
1014 | int secLenPausing = 3600 * 3; | 1014 | int secLenPausing = 3600 * 3; |
1015 | int dayInterval = 1; | 1015 | int dayInterval = 1; |
1016 | 1016 | ||
1017 | nt = new Todo; | 1017 | nt = new Todo; |
1018 | mCalendar->addTodo( nt ); | 1018 | mCalendar->addTodo( nt ); |
1019 | nt->setSummary( "Planning Project2"); | 1019 | nt->setSummary( "Planning Project2"); |
1020 | nt->setPriority( 1 ); | 1020 | nt->setPriority( 1 ); |
1021 | nt->setDescription( "This is a test description of Planning_Project_2" ); | 1021 | nt->setDescription( "This is a test description of Planning_Project_2" ); |
1022 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); | 1022 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); |
1023 | nt->setPercentComplete( 20 ); | 1023 | nt->setPercentComplete( 20 ); |
1024 | 1024 | ||
1025 | 1025 | ||
1026 | Todo * sub1 = nt; | 1026 | Todo * sub1 = nt; |
1027 | sub1->setRelatedTo( root1 ); | 1027 | sub1->setRelatedTo( root1 ); |
1028 | 1028 | ||
1029 | nt = new Todo; | 1029 | nt = new Todo; |
1030 | mCalendar->addTodo( nt ); | 1030 | mCalendar->addTodo( nt ); |
1031 | nt->setSummary( "Planning Project2: Lutz"); | 1031 | nt->setSummary( "Planning Project2: Lutz"); |
1032 | nt->setPriority( 1 ); | 1032 | nt->setPriority( 1 ); |
1033 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1033 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1034 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); | 1034 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); |
1035 | nt->setPercentComplete( 20 ); | 1035 | nt->setPercentComplete( 20 ); |
1036 | Todo * workLutz11 = nt; | 1036 | Todo * workLutz11 = nt; |
1037 | workLutz11->setRelatedTo( sub1 ); | 1037 | workLutz11->setRelatedTo( sub1 ); |
1038 | 1038 | ||
1039 | nt = new Todo; | 1039 | nt = new Todo; |
1040 | mCalendar->addTodo( nt ); | 1040 | mCalendar->addTodo( nt ); |
1041 | nt->setSummary( "Planning Project2: Norbert"); | 1041 | nt->setSummary( "Planning Project2: Norbert"); |
1042 | nt->setPriority( 1 ); | 1042 | nt->setPriority( 1 ); |
1043 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1043 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1044 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); | 1044 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); |
1045 | nt->setPercentComplete( 20 ); | 1045 | nt->setPercentComplete( 20 ); |
1046 | Todo * workNorbert11 = nt; | 1046 | Todo * workNorbert11 = nt; |
1047 | workNorbert11->setRelatedTo( sub1 ); | 1047 | workNorbert11->setRelatedTo( sub1 ); |
1048 | 1048 | ||
1049 | nt = new Todo; | 1049 | nt = new Todo; |
1050 | mCalendar->addTodo( nt ); | 1050 | mCalendar->addTodo( nt ); |
1051 | nt->setSummary( "Work on 2"); | 1051 | nt->setSummary( "Work on 2"); |
1052 | nt->setPriority( 1 ); | 1052 | nt->setPriority( 1 ); |
1053 | nt->setDescription( "This is a test description of Work Project_2" ); | 1053 | nt->setDescription( "This is a test description of Work Project_2" ); |
1054 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); | 1054 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); |
1055 | nt->setPercentComplete( 20 ); | 1055 | nt->setPercentComplete( 20 ); |
1056 | 1056 | ||
1057 | Todo * sub2 = nt; | 1057 | Todo * sub2 = nt; |
1058 | sub2->setRelatedTo( root1 ); | 1058 | sub2->setRelatedTo( root1 ); |
1059 | 1059 | ||
1060 | 1060 | ||
1061 | nt = new Todo; | 1061 | nt = new Todo; |
1062 | mCalendar->addTodo( nt ); | 1062 | mCalendar->addTodo( nt ); |
1063 | nt->setSummary( "Work on 2: Lutz"); | 1063 | nt->setSummary( "Work on 2: Lutz"); |
1064 | nt->setPriority( 1 ); | 1064 | nt->setPriority( 1 ); |
1065 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1065 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1066 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); | 1066 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); |
1067 | nt->setPercentComplete( 20 ); | 1067 | nt->setPercentComplete( 20 ); |
1068 | Todo * workLutz12 = nt; | 1068 | Todo * workLutz12 = nt; |
1069 | workLutz12->setRelatedTo( sub2 ); | 1069 | workLutz12->setRelatedTo( sub2 ); |
1070 | 1070 | ||
1071 | nt = new Todo; | 1071 | nt = new Todo; |
1072 | mCalendar->addTodo( nt ); | 1072 | mCalendar->addTodo( nt ); |
1073 | nt->setSummary( "Work on 2: Norbert"); | 1073 | nt->setSummary( "Work on 2: Norbert"); |
1074 | nt->setPriority( 1 ); | 1074 | nt->setPriority( 1 ); |
1075 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1075 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1076 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); | 1076 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); |
1077 | nt->setPercentComplete( 20 ); | 1077 | nt->setPercentComplete( 20 ); |
1078 | Todo * workNorbert12 = nt; | 1078 | Todo * workNorbert12 = nt; |
1079 | workNorbert12->setRelatedTo( sub2 ); | 1079 | workNorbert12->setRelatedTo( sub2 ); |
1080 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); | 1080 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); |
1081 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); | 1081 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); |
1082 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); | 1082 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); |
1083 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); | 1083 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); |
1084 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); | 1084 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); |
1085 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); | 1085 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); |
1086 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); | 1086 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); |
1087 | } | 1087 | } |
1088 | updateView(); | 1088 | updateView(); |
1089 | #endif | 1089 | #endif |
1090 | 1090 | ||
1091 | } | 1091 | } |
1092 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) | 1092 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) |
1093 | { | 1093 | { |
1094 | static int ccc = 0; | 1094 | static int ccc = 0; |
1095 | ++ccc; | 1095 | ++ccc; |
1096 | QDateTime t_start = start; | 1096 | QDateTime t_start = start; |
1097 | runT->setPriority( 5 ); | 1097 | runT->setPriority( 5 ); |
1098 | runT->setPercentComplete( 0 ); | 1098 | runT->setPercentComplete( 0 ); |
1099 | int count = 0; | 1099 | int count = 0; |
1100 | int prio = 5; | 1100 | int prio = 5; |
1101 | int complete = 0; | 1101 | int complete = 0; |
1102 | while ( t_start < end ) { | 1102 | while ( t_start < end ) { |
1103 | ++count; | 1103 | ++count; |
1104 | if ( count > ccc ) { | 1104 | if ( count > ccc ) { |
1105 | count = 0; | 1105 | count = 0; |
1106 | --prio; | 1106 | --prio; |
1107 | if ( prio == 0 ) prio = 5; | 1107 | if ( prio == 0 ) prio = 5; |
1108 | complete += 20; | 1108 | complete += 20; |
1109 | if ( complete > 100 ) complete = 0; | 1109 | if ( complete > 100 ) complete = 0; |
1110 | runT->setPriority( prio ); | 1110 | runT->setPriority( prio ); |
1111 | runT->setPercentComplete( complete ); | 1111 | runT->setPercentComplete( complete ); |
1112 | } | 1112 | } |
1113 | runT->setRunning( true ); | 1113 | runT->setRunning( true ); |
1114 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); | 1114 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); |
1115 | if ( dayInterval ) | 1115 | if ( dayInterval ) |
1116 | t_start = t_start.addDays( dayInterval ); | 1116 | t_start = t_start.addDays( dayInterval ); |
1117 | else { | 1117 | else { |
1118 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); | 1118 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); |
1119 | } | 1119 | } |
1120 | } | 1120 | } |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | void CalendarView::showDay( QDate d ) | 1123 | void CalendarView::showDay( QDate d ) |
1124 | { | 1124 | { |
1125 | dateNavigator()->blockSignals( true ); | 1125 | dateNavigator()->blockSignals( true ); |
1126 | dateNavigator()->selectDate( d ); | 1126 | dateNavigator()->selectDate( d ); |
1127 | dateNavigator()->blockSignals( false ); | 1127 | dateNavigator()->blockSignals( false ); |
1128 | mViewManager->showDayView(); | 1128 | mViewManager->showDayView(); |
1129 | //dateNavigator()->selectDate( d ); | 1129 | //dateNavigator()->selectDate( d ); |
1130 | } | 1130 | } |
1131 | void CalendarView::timerAlarm() | 1131 | void CalendarView::timerAlarm() |
1132 | { | 1132 | { |
1133 | //qDebug("CalendarView::timerAlarm() "); | 1133 | //qDebug("CalendarView::timerAlarm() "); |
1134 | computeAlarm(mAlarmNotification ); | 1134 | computeAlarm(mAlarmNotification ); |
1135 | } | 1135 | } |
1136 | 1136 | ||
1137 | void CalendarView::suspendAlarm() | 1137 | void CalendarView::suspendAlarm() |
1138 | { | 1138 | { |
1139 | //qDebug(" CalendarView::suspendAlarm() "); | 1139 | //qDebug(" CalendarView::suspendAlarm() "); |
1140 | computeAlarm(mSuspendAlarmNotification ); | 1140 | computeAlarm(mSuspendAlarmNotification ); |
1141 | 1141 | ||
1142 | } | 1142 | } |
1143 | 1143 | ||
1144 | void CalendarView::startAlarm( QString mess , QString filename) | 1144 | void CalendarView::startAlarm( QString mess , QString filename) |
1145 | { | 1145 | { |
1146 | 1146 | ||
1147 | topLevelWidget()->showNormal(); | 1147 | topLevelWidget()->showNormal(); |
1148 | topLevelWidget()->setActiveWindow(); | 1148 | topLevelWidget()->setActiveWindow(); |
1149 | topLevelWidget()->raise(); | 1149 | topLevelWidget()->raise(); |
1150 | 1150 | ||
1151 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 1151 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
1152 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 1152 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
1153 | 1153 | ||
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | void CalendarView::checkNextTimerAlarm() | 1156 | void CalendarView::checkNextTimerAlarm() |
1157 | { | 1157 | { |
1158 | mCalendar->checkAlarmForIncidence( 0, true ); | 1158 | mCalendar->checkAlarmForIncidence( 0, true ); |
1159 | } | 1159 | } |
1160 | 1160 | ||
1161 | void CalendarView::computeAlarm( QString msg ) | 1161 | void CalendarView::computeAlarm( QString msg ) |
1162 | { | 1162 | { |
1163 | 1163 | ||
1164 | QString mess = msg; | 1164 | QString mess = msg; |
1165 | QString mAlarmMessage = mess.mid( 9 ); | 1165 | QString mAlarmMessage = mess.mid( 9 ); |
1166 | QString filename = MainWindow::resourcePath(); | 1166 | QString filename = MainWindow::resourcePath(); |
1167 | filename += "koalarm.wav"; | 1167 | filename += "koalarm.wav"; |
1168 | QString tempfilename; | 1168 | QString tempfilename; |
1169 | if ( mess.left( 13 ) == "suspend_alarm") { | 1169 | if ( mess.left( 13 ) == "suspend_alarm") { |
1170 | bool error = false; | 1170 | bool error = false; |
1171 | int len = mess.mid( 13 ).find("+++"); | 1171 | int len = mess.mid( 13 ).find("+++"); |
1172 | if ( len < 2 ) | 1172 | if ( len < 2 ) |
1173 | error = true; | 1173 | error = true; |
1174 | else { | 1174 | else { |
1175 | tempfilename = mess.mid( 13, len ); | 1175 | tempfilename = mess.mid( 13, len ); |
1176 | if ( !QFile::exists( tempfilename ) ) | 1176 | if ( !QFile::exists( tempfilename ) ) |
1177 | error = true; | 1177 | error = true; |
1178 | } | 1178 | } |
1179 | if ( ! error ) { | 1179 | if ( ! error ) { |
1180 | filename = tempfilename; | 1180 | filename = tempfilename; |
1181 | } | 1181 | } |
1182 | mAlarmMessage = mess.mid( 13+len+3 ); | 1182 | mAlarmMessage = mess.mid( 13+len+3 ); |
1183 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 1183 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
1184 | startAlarm( mAlarmMessage, filename); | 1184 | startAlarm( mAlarmMessage, filename); |
1185 | return; | 1185 | return; |
1186 | } | 1186 | } |
1187 | if ( mess.left( 11 ) == "timer_alarm") { | 1187 | if ( mess.left( 11 ) == "timer_alarm") { |
1188 | //mTimerTime = 0; | 1188 | //mTimerTime = 0; |
1189 | startAlarm( mess.mid( 11 ), filename ); | 1189 | startAlarm( mess.mid( 11 ), filename ); |
1190 | return; | 1190 | return; |
1191 | } | 1191 | } |
1192 | if ( mess.left( 10 ) == "proc_alarm") { | 1192 | if ( mess.left( 10 ) == "proc_alarm") { |
1193 | bool error = false; | 1193 | bool error = false; |
1194 | int len = mess.mid( 10 ).find("+++"); | 1194 | int len = mess.mid( 10 ).find("+++"); |
1195 | if ( len < 2 ) | 1195 | if ( len < 2 ) |
1196 | error = true; | 1196 | error = true; |
1197 | else { | 1197 | else { |
1198 | tempfilename = mess.mid( 10, len ); | 1198 | tempfilename = mess.mid( 10, len ); |
1199 | if ( !QFile::exists( tempfilename ) ) | 1199 | if ( !QFile::exists( tempfilename ) ) |
1200 | error = true; | 1200 | error = true; |
1201 | } | 1201 | } |
1202 | if ( error ) { | 1202 | if ( error ) { |
1203 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 1203 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
1204 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 1204 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
1205 | } else { | 1205 | } else { |
1206 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 1206 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
1207 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 1207 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
1208 | #ifndef _WIN32_ | 1208 | #ifndef _WIN32_ |
1209 | if ( vfork () == 0 ) { | 1209 | if ( vfork () == 0 ) { |
1210 | execl ( tempfilename.latin1(), 0 ); | 1210 | execl ( tempfilename.latin1(), 0 ); |
1211 | return; | 1211 | return; |
1212 | } | 1212 | } |
1213 | #else | 1213 | #else |
1214 | QProcess* p = new QProcess(); | 1214 | QProcess* p = new QProcess(); |
1215 | p->addArgument( tempfilename.latin1() ); | 1215 | p->addArgument( tempfilename.latin1() ); |
1216 | p->start(); | 1216 | p->start(); |
1217 | return; | 1217 | return; |
1218 | #endif | 1218 | #endif |
1219 | 1219 | ||
1220 | return; | 1220 | return; |
1221 | } | 1221 | } |
1222 | 1222 | ||
1223 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1223 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1224 | } | 1224 | } |
1225 | if ( mess.left( 11 ) == "audio_alarm") { | 1225 | if ( mess.left( 11 ) == "audio_alarm") { |
1226 | bool error = false; | 1226 | bool error = false; |
1227 | int len = mess.mid( 11 ).find("+++"); | 1227 | int len = mess.mid( 11 ).find("+++"); |
1228 | if ( len < 2 ) | 1228 | if ( len < 2 ) |
1229 | error = true; | 1229 | error = true; |
1230 | else { | 1230 | else { |
1231 | tempfilename = mess.mid( 11, len ); | 1231 | tempfilename = mess.mid( 11, len ); |
1232 | if ( !QFile::exists( tempfilename ) ) | 1232 | if ( !QFile::exists( tempfilename ) ) |
1233 | error = true; | 1233 | error = true; |
1234 | } | 1234 | } |
1235 | if ( ! error ) { | 1235 | if ( ! error ) { |
1236 | filename = tempfilename; | 1236 | filename = tempfilename; |
1237 | } | 1237 | } |
1238 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1238 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1239 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1239 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1240 | } | 1240 | } |
1241 | if ( mess.left( 9 ) == "cal_alarm") { | 1241 | if ( mess.left( 9 ) == "cal_alarm") { |
1242 | mAlarmMessage = mess.mid( 9 ) ; | 1242 | mAlarmMessage = mess.mid( 9 ) ; |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | startAlarm( mAlarmMessage, filename ); | 1245 | startAlarm( mAlarmMessage, filename ); |
1246 | 1246 | ||
1247 | 1247 | ||
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1250 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1251 | { | 1251 | { |
1252 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1252 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1253 | 1253 | ||
1254 | mSuspendAlarmNotification = noti; | 1254 | mSuspendAlarmNotification = noti; |
1255 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1255 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1256 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1256 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1257 | mSuspendTimer->start( ms , true ); | 1257 | mSuspendTimer->start( ms , true ); |
1258 | #ifdef DESKTOP_VERSION | 1258 | #ifdef DESKTOP_VERSION |
1259 | if ( QApplication::desktop()->width() < 1024 ) { | 1259 | if ( QApplication::desktop()->width() < 1024 ) { |
1260 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1260 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1261 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); | 1261 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); |
1262 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; | 1262 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; |
1263 | QFile file( fn ); | 1263 | QFile file( fn ); |
1264 | if (!file.open( IO_WriteOnly ) ) { | 1264 | if (!file.open( IO_WriteOnly ) ) { |
1265 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1265 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1266 | } else { | 1266 | } else { |
1267 | QTextStream ts( &file ); | 1267 | QTextStream ts( &file ); |
1268 | ts << mess; | 1268 | ts << mess; |
1269 | file.close(); | 1269 | file.close(); |
1270 | } | 1270 | } |
1271 | } | 1271 | } |
1272 | #endif | 1272 | #endif |
1273 | 1273 | ||
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1276 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1277 | { | 1277 | { |
1278 | mNextAlarmDateTime = qdt; | 1278 | mNextAlarmDateTime = qdt; |
1279 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1279 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1280 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1280 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1281 | #ifndef DESKTOP_VERSION | 1281 | #ifndef DESKTOP_VERSION |
1282 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1282 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1283 | #endif | 1283 | #endif |
1284 | return; | 1284 | return; |
1285 | } | 1285 | } |
1286 | #ifdef DESKTOP_VERSION | 1286 | #ifdef DESKTOP_VERSION |
1287 | if ( QApplication::desktop()->width() < 1024 ) { | 1287 | if ( QApplication::desktop()->width() < 1024 ) { |
1288 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1288 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1289 | //qDebug("nextalarm = \n%s ",mess.latin1() ); | 1289 | //qDebug("nextalarm = \n%s ",mess.latin1() ); |
1290 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; | 1290 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; |
1291 | QFile file( fn ); | 1291 | QFile file( fn ); |
1292 | if (!file.open( IO_WriteOnly ) ) { | 1292 | if (!file.open( IO_WriteOnly ) ) { |
1293 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1293 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1294 | } else { | 1294 | } else { |
1295 | QTextStream ts( &file ); | 1295 | QTextStream ts( &file ); |
1296 | ts << mess; | 1296 | ts << mess; |
1297 | file.close(); | 1297 | file.close(); |
1298 | } | 1298 | } |
1299 | } | 1299 | } |
1300 | #endif | 1300 | #endif |
1301 | int maxSec; | 1301 | int maxSec; |
1302 | //maxSec = 5; //testing only | 1302 | //maxSec = 5; //testing only |
1303 | maxSec = 86400+3600; // one day+1hour | 1303 | maxSec = 86400+3600; // one day+1hour |
1304 | mAlarmNotification = noti; | 1304 | mAlarmNotification = noti; |
1305 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1305 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1306 | if ( sec > maxSec ) { | 1306 | if ( sec > maxSec ) { |
1307 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1307 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1308 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1308 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1309 | return; | 1309 | return; |
1310 | } else { | 1310 | } else { |
1311 | mRecheckAlarmTimer->stop(); | 1311 | mRecheckAlarmTimer->stop(); |
1312 | } | 1312 | } |
1313 | //qDebug("Alarm timer started with secs: %d ", sec); | 1313 | //qDebug("Alarm timer started with secs: %d ", sec); |
1314 | mAlarmTimer->start( sec * 1000 , true ); | 1314 | mAlarmTimer->start( sec * 1000 , true ); |
1315 | 1315 | ||
1316 | } | 1316 | } |
1317 | // called by mRecheckAlarmTimer to get next alarm | 1317 | // called by mRecheckAlarmTimer to get next alarm |
1318 | // we need this, because a QTimer has only a max range of 25 days | 1318 | // we need this, because a QTimer has only a max range of 25 days |
1319 | void CalendarView::recheckTimerAlarm() | 1319 | void CalendarView::recheckTimerAlarm() |
1320 | { | 1320 | { |
1321 | mAlarmTimer->stop(); | 1321 | mAlarmTimer->stop(); |
1322 | mRecheckAlarmTimer->stop(); | 1322 | mRecheckAlarmTimer->stop(); |
1323 | mCalendar->checkAlarmForIncidence( 0, true ); | 1323 | mCalendar->checkAlarmForIncidence( 0, true ); |
1324 | } | 1324 | } |
1325 | #ifndef DESKTOP_VERSION | 1325 | #ifndef DESKTOP_VERSION |
1326 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1326 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1327 | #else | 1327 | #else |
1328 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1328 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1329 | #endif | 1329 | #endif |
1330 | { | 1330 | { |
1331 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1331 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1332 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1332 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1333 | #ifndef DESKTOP_VERSION | 1333 | #ifndef DESKTOP_VERSION |
1334 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1334 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1335 | #endif | 1335 | #endif |
1336 | return; | 1336 | return; |
1337 | } | 1337 | } |
1338 | mAlarmTimer->stop(); | 1338 | mAlarmTimer->stop(); |
1339 | } | 1339 | } |
1340 | void CalendarView::selectWeekNum ( int num ) | 1340 | void CalendarView::selectWeekNum ( int num ) |
1341 | { | 1341 | { |
1342 | dateNavigator()->blockSignals( true ); | 1342 | dateNavigator()->blockSignals( true ); |
1343 | dateNavigator()->selectWeek( num ); | 1343 | dateNavigator()->selectWeek( num ); |
1344 | dateNavigator()->blockSignals( false ); | 1344 | dateNavigator()->blockSignals( false ); |
1345 | mViewManager->showWeekView(); | 1345 | mViewManager->showWeekView(); |
1346 | } | 1346 | } |
1347 | KOViewManager *CalendarView::viewManager() | 1347 | KOViewManager *CalendarView::viewManager() |
1348 | { | 1348 | { |
1349 | return mViewManager; | 1349 | return mViewManager; |
1350 | } | 1350 | } |
1351 | 1351 | ||
1352 | KODialogManager *CalendarView::dialogManager() | 1352 | KODialogManager *CalendarView::dialogManager() |
1353 | { | 1353 | { |
1354 | return mDialogManager; | 1354 | return mDialogManager; |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | QDate CalendarView::startDate() | 1357 | QDate CalendarView::startDate() |
1358 | { | 1358 | { |
1359 | DateList dates = mNavigator->selectedDates(); | 1359 | DateList dates = mNavigator->selectedDates(); |
1360 | 1360 | ||
1361 | return dates.first(); | 1361 | return dates.first(); |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | QDate CalendarView::endDate() | 1364 | QDate CalendarView::endDate() |
1365 | { | 1365 | { |
1366 | DateList dates = mNavigator->selectedDates(); | 1366 | DateList dates = mNavigator->selectedDates(); |
1367 | 1367 | ||
1368 | return dates.last(); | 1368 | return dates.last(); |
1369 | } | 1369 | } |
1370 | 1370 | ||
1371 | 1371 | ||
1372 | void CalendarView::createPrinter() | 1372 | void CalendarView::createPrinter() |
1373 | { | 1373 | { |
1374 | #ifndef KORG_NOPRINTER | 1374 | #ifndef KORG_NOPRINTER |
1375 | if (!mCalPrinter) { | 1375 | if (!mCalPrinter) { |
1376 | mCalPrinter = new CalPrinter(this, mCalendar); | 1376 | mCalPrinter = new CalPrinter(this, mCalendar); |
1377 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1377 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1378 | } | 1378 | } |
1379 | #endif | 1379 | #endif |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | 1382 | ||
1383 | //KOPrefs::instance()->mWriteBackFile | 1383 | //KOPrefs::instance()->mWriteBackFile |
1384 | //KOPrefs::instance()->mWriteBackExistingOnly | 1384 | //KOPrefs::instance()->mWriteBackExistingOnly |
1385 | 1385 | ||
1386 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1386 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1387 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1387 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1388 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1388 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1389 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1389 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1390 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1390 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1391 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1391 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1392 | 1392 | ||
1393 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1393 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1394 | { | 1394 | { |
1395 | 1395 | ||
1396 | // 0 equal | 1396 | // 0 equal |
1397 | // 1 take local | 1397 | // 1 take local |
1398 | // 2 take remote | 1398 | // 2 take remote |
1399 | // 3 cancel | 1399 | // 3 cancel |
1400 | QDateTime lastSync = mLastCalendarSync; | 1400 | QDateTime lastSync = mLastCalendarSync; |
1401 | QDateTime localMod = local->lastModified(); | 1401 | QDateTime localMod = local->lastModified(); |
1402 | QDateTime remoteMod = remote->lastModified(); | 1402 | QDateTime remoteMod = remote->lastModified(); |
1403 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1403 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1404 | bool remCh, locCh; | 1404 | bool remCh, locCh; |
1405 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1405 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1406 | //if ( remCh ) | 1406 | //if ( remCh ) |
1407 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1407 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1408 | locCh = ( localMod > mLastCalendarSync ); | 1408 | locCh = ( localMod > mLastCalendarSync ); |
1409 | if ( !remCh && ! locCh ) { | 1409 | if ( !remCh && ! locCh ) { |
1410 | //qDebug("both not changed "); | 1410 | //qDebug("both not changed "); |
1411 | lastSync = localMod.addDays(1); | 1411 | lastSync = localMod.addDays(1); |
1412 | if ( mode <= SYNC_PREF_ASK ) | 1412 | if ( mode <= SYNC_PREF_ASK ) |
1413 | return 0; | 1413 | return 0; |
1414 | } else { | 1414 | } else { |
1415 | if ( locCh ) { | 1415 | if ( locCh ) { |
1416 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1416 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1417 | lastSync = localMod.addDays( -1 ); | 1417 | lastSync = localMod.addDays( -1 ); |
1418 | if ( !remCh ) | 1418 | if ( !remCh ) |
1419 | remoteMod = ( lastSync.addDays( -1 ) ); | 1419 | remoteMod = ( lastSync.addDays( -1 ) ); |
1420 | } else { | 1420 | } else { |
1421 | //qDebug(" not loc changed "); | 1421 | //qDebug(" not loc changed "); |
1422 | lastSync = localMod.addDays( 1 ); | 1422 | lastSync = localMod.addDays( 1 ); |
1423 | if ( remCh ) | 1423 | if ( remCh ) |
1424 | remoteMod =( lastSync.addDays( 1 ) ); | 1424 | remoteMod =( lastSync.addDays( 1 ) ); |
1425 | 1425 | ||
1426 | } | 1426 | } |
1427 | } | 1427 | } |
1428 | full = true; | 1428 | full = true; |
1429 | if ( mode < SYNC_PREF_ASK ) | 1429 | if ( mode < SYNC_PREF_ASK ) |
1430 | mode = SYNC_PREF_ASK; | 1430 | mode = SYNC_PREF_ASK; |
1431 | } else { | 1431 | } else { |
1432 | if ( localMod == remoteMod ) | 1432 | if ( localMod == remoteMod ) |
1433 | // if ( local->revision() == remote->revision() ) | 1433 | // if ( local->revision() == remote->revision() ) |
1434 | return 0; | 1434 | return 0; |
1435 | 1435 | ||
1436 | } | 1436 | } |
1437 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1437 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1438 | 1438 | ||
1439 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1439 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1440 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1440 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1441 | //full = true; //debug only | 1441 | //full = true; //debug only |
1442 | if ( full ) { | 1442 | if ( full ) { |
1443 | bool equ = false; | 1443 | bool equ = false; |
1444 | if ( local->typeID() == eventID ) { | 1444 | if ( local->typeID() == eventID ) { |
1445 | equ = (*((Event*) local) == *((Event*) remote)); | 1445 | equ = (*((Event*) local) == *((Event*) remote)); |
1446 | } | 1446 | } |
1447 | else if ( local->typeID() == todoID ) | 1447 | else if ( local->typeID() == todoID ) |
1448 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1448 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1449 | else if ( local->typeID() == journalID ) | 1449 | else if ( local->typeID() == journalID ) |
1450 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1450 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1451 | if ( equ ) { | 1451 | if ( equ ) { |
1452 | //qDebug("equal "); | 1452 | //qDebug("equal "); |
1453 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1453 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1454 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1454 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1455 | } | 1455 | } |
1456 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1456 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1457 | return 0; | 1457 | return 0; |
1458 | 1458 | ||
1459 | }//else //debug only | 1459 | }//else //debug only |
1460 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1460 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1461 | } | 1461 | } |
1462 | int result; | 1462 | int result; |
1463 | bool localIsNew; | 1463 | bool localIsNew; |
1464 | //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() ); | 1464 | //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() ); |
1465 | 1465 | ||
1466 | 1466 | ||
1467 | // ************************************************ | 1467 | // ************************************************ |
1468 | // ************************************************ | 1468 | // ************************************************ |
1469 | // ************************************************ | 1469 | // ************************************************ |
1470 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1470 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1471 | // BUT remoteMod != localMod | 1471 | // BUT remoteMod != localMod |
1472 | 1472 | ||
1473 | 1473 | ||
1474 | if ( full && mode < SYNC_PREF_NEWEST ) | 1474 | if ( full && mode < SYNC_PREF_NEWEST ) |
1475 | mode = SYNC_PREF_ASK; | 1475 | mode = SYNC_PREF_ASK; |
1476 | 1476 | ||
1477 | switch( mode ) { | 1477 | switch( mode ) { |
1478 | case SYNC_PREF_LOCAL: | 1478 | case SYNC_PREF_LOCAL: |
1479 | if ( lastSync > remoteMod ) | 1479 | if ( lastSync > remoteMod ) |
1480 | return 1; | 1480 | return 1; |
1481 | if ( lastSync > localMod ) | 1481 | if ( lastSync > localMod ) |
1482 | return 2; | 1482 | return 2; |
1483 | return 1; | 1483 | return 1; |
1484 | break; | 1484 | break; |
1485 | case SYNC_PREF_REMOTE: | 1485 | case SYNC_PREF_REMOTE: |
1486 | if ( lastSync > localMod ) | 1486 | if ( lastSync > localMod ) |
1487 | return 2; | 1487 | return 2; |
1488 | if ( lastSync > remoteMod ) | 1488 | if ( lastSync > remoteMod ) |
1489 | return 1; | 1489 | return 1; |
1490 | return 2; | 1490 | return 2; |
1491 | break; | 1491 | break; |
1492 | case SYNC_PREF_NEWEST: | 1492 | case SYNC_PREF_NEWEST: |
1493 | if ( localMod >= remoteMod ) | 1493 | if ( localMod >= remoteMod ) |
1494 | return 1; | 1494 | return 1; |
1495 | else | 1495 | else |
1496 | return 2; | 1496 | return 2; |
1497 | break; | 1497 | break; |
1498 | case SYNC_PREF_ASK: | 1498 | case SYNC_PREF_ASK: |
1499 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1499 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1500 | if ( lastSync > remoteMod && lastSync > localMod) | 1500 | if ( lastSync > remoteMod && lastSync > localMod) |
1501 | return 0; | 1501 | return 0; |
1502 | if ( lastSync > remoteMod ) | 1502 | if ( lastSync > remoteMod ) |
1503 | return 1; | 1503 | return 1; |
1504 | if ( lastSync > localMod ) | 1504 | if ( lastSync > localMod ) |
1505 | return 2; | 1505 | return 2; |
1506 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1506 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1507 | localIsNew = localMod >= remoteMod; | 1507 | localIsNew = localMod >= remoteMod; |
1508 | if ( localIsNew ) | 1508 | if ( localIsNew ) |
1509 | getEventViewerDialog()->setColorMode( 1 ); | 1509 | getEventViewerDialog()->setColorMode( 1 ); |
1510 | else | 1510 | else |
1511 | getEventViewerDialog()->setColorMode( 2 ); | 1511 | getEventViewerDialog()->setColorMode( 2 ); |
1512 | getEventViewerDialog()->setIncidence(local); | 1512 | getEventViewerDialog()->setIncidence(local); |
1513 | if ( localIsNew ) | 1513 | if ( localIsNew ) |
1514 | getEventViewerDialog()->setColorMode( 2 ); | 1514 | getEventViewerDialog()->setColorMode( 2 ); |
1515 | else | 1515 | else |
1516 | getEventViewerDialog()->setColorMode( 1 ); | 1516 | getEventViewerDialog()->setColorMode( 1 ); |
1517 | getEventViewerDialog()->addIncidence(remote); | 1517 | getEventViewerDialog()->addIncidence(remote); |
1518 | getEventViewerDialog()->setColorMode( 0 ); | 1518 | getEventViewerDialog()->setColorMode( 0 ); |
1519 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1519 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1520 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1520 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1521 | getEventViewerDialog()->showMe(); | 1521 | getEventViewerDialog()->showMe(); |
1522 | result = getEventViewerDialog()->executeS( localIsNew ); | 1522 | result = getEventViewerDialog()->executeS( localIsNew ); |
1523 | return result; | 1523 | return result; |
1524 | 1524 | ||
1525 | break; | 1525 | break; |
1526 | case SYNC_PREF_FORCE_LOCAL: | 1526 | case SYNC_PREF_FORCE_LOCAL: |
1527 | return 1; | 1527 | return 1; |
1528 | break; | 1528 | break; |
1529 | case SYNC_PREF_FORCE_REMOTE: | 1529 | case SYNC_PREF_FORCE_REMOTE: |
1530 | return 2; | 1530 | return 2; |
1531 | break; | 1531 | break; |
1532 | 1532 | ||
1533 | default: | 1533 | default: |
1534 | // SYNC_PREF_TAKE_BOTH not implemented | 1534 | // SYNC_PREF_TAKE_BOTH not implemented |
1535 | break; | 1535 | break; |
1536 | } | 1536 | } |
1537 | return 0; | 1537 | return 0; |
1538 | } | 1538 | } |
1539 | Event* CalendarView::getLastSyncEvent() | 1539 | Event* CalendarView::getLastSyncEvent() |
1540 | { | 1540 | { |
1541 | Event* lse; | 1541 | Event* lse; |
1542 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1542 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1543 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1543 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1544 | if (!lse) { | 1544 | if (!lse) { |
1545 | lse = new Event(); | 1545 | lse = new Event(); |
1546 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1546 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1547 | QString sum = ""; | 1547 | QString sum = ""; |
1548 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1548 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1549 | sum = "E: "; | 1549 | sum = "E: "; |
1550 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1550 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1551 | lse->setDtStart( mLastCalendarSync ); | 1551 | lse->setDtStart( mLastCalendarSync ); |
1552 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1552 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1553 | lse->setCategories( i18n("SyncEvent") ); | 1553 | lse->setCategories( i18n("SyncEvent") ); |
1554 | lse->setReadOnly( true ); | 1554 | lse->setReadOnly( true ); |
1555 | mCalendar->addEvent( lse ); | 1555 | mCalendar->addEvent( lse ); |
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | return lse; | 1558 | return lse; |
1559 | 1559 | ||
1560 | } | 1560 | } |
1561 | 1561 | ||
1562 | // we check, if the to delete event has a id for a profile | 1562 | // we check, if the to delete event has a id for a profile |
1563 | // if yes, we set this id in the profile to delete | 1563 | // if yes, we set this id in the profile to delete |
1564 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1564 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1565 | { | 1565 | { |
1566 | if ( lastSync.count() == 0 ) { | 1566 | if ( lastSync.count() == 0 ) { |
1567 | //qDebug(" lastSync.count() == 0"); | 1567 | //qDebug(" lastSync.count() == 0"); |
1568 | return; | 1568 | return; |
1569 | } | 1569 | } |
1570 | if ( toDelete->typeID() == journalID ) | 1570 | if ( toDelete->typeID() == journalID ) |
1571 | return; | 1571 | return; |
1572 | 1572 | ||
1573 | Event* eve = lastSync.first(); | 1573 | Event* eve = lastSync.first(); |
1574 | 1574 | ||
1575 | while ( eve ) { | 1575 | while ( eve ) { |
1576 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1576 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1577 | if ( !id.isEmpty() ) { | 1577 | if ( !id.isEmpty() ) { |
1578 | QString des = eve->description(); | 1578 | QString des = eve->description(); |
1579 | QString pref = "e"; | 1579 | QString pref = "e"; |
1580 | if ( toDelete->typeID() == todoID ) | 1580 | if ( toDelete->typeID() == todoID ) |
1581 | pref = "t"; | 1581 | pref = "t"; |
1582 | des += pref+ id + ","; | 1582 | des += pref+ id + ","; |
1583 | eve->setReadOnly( false ); | 1583 | eve->setReadOnly( false ); |
1584 | eve->setDescription( des ); | 1584 | eve->setDescription( des ); |
1585 | //qDebug("setdes %s ", des.latin1()); | 1585 | //qDebug("setdes %s ", des.latin1()); |
1586 | eve->setReadOnly( true ); | 1586 | eve->setReadOnly( true ); |
1587 | } | 1587 | } |
1588 | eve = lastSync.next(); | 1588 | eve = lastSync.next(); |
1589 | } | 1589 | } |
1590 | 1590 | ||
1591 | } | 1591 | } |
1592 | void CalendarView::checkExternalId( Incidence * inc ) | 1592 | void CalendarView::checkExternalId( Incidence * inc ) |
1593 | { | 1593 | { |
1594 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1594 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1595 | checkExternSyncEvent( lastSync, inc ); | 1595 | checkExternSyncEvent( lastSync, inc ); |
1596 | 1596 | ||
1597 | } | 1597 | } |
1598 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1598 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1599 | { | 1599 | { |
1600 | bool syncOK = true; | 1600 | bool syncOK = true; |
1601 | int addedEvent = 0; | 1601 | int addedEvent = 0; |
1602 | int addedEventR = 0; | 1602 | int addedEventR = 0; |
1603 | int deletedEventR = 0; | 1603 | int deletedEventR = 0; |
1604 | int deletedEventL = 0; | 1604 | int deletedEventL = 0; |
1605 | int changedLocal = 0; | 1605 | int changedLocal = 0; |
1606 | int changedRemote = 0; | 1606 | int changedRemote = 0; |
1607 | int filteredIN = 0; | 1607 | int filteredIN = 0; |
1608 | int filteredOUT = 0; | 1608 | int filteredOUT = 0; |
1609 | //QPtrList<Event> el = local->rawEvents(); | 1609 | //QPtrList<Event> el = local->rawEvents(); |
1610 | Event* eventR; | 1610 | Event* eventR; |
1611 | QString uid; | 1611 | QString uid; |
1612 | int take; | 1612 | int take; |
1613 | Event* eventRSync; | 1613 | Event* eventRSync; |
1614 | Event* eventLSync; | 1614 | Event* eventLSync; |
1615 | clearAllViews(); | 1615 | clearAllViews(); |
1616 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1616 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1617 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1617 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1618 | bool fullDateRange = false; | 1618 | bool fullDateRange = false; |
1619 | local->resetTempSyncStat(); | 1619 | local->resetTempSyncStat(); |
1620 | mLastCalendarSync = QDateTime::currentDateTime(); | 1620 | mLastCalendarSync = QDateTime::currentDateTime(); |
1621 | if ( mSyncManager->syncWithDesktop() ) { | 1621 | if ( mSyncManager->syncWithDesktop() ) { |
1622 | remote->resetPilotStat(1); | 1622 | remote->resetPilotStat(1); |
1623 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1623 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1624 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1624 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1625 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1625 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1626 | } else { | 1626 | } else { |
1627 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1627 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1628 | } | 1628 | } |
1629 | } | 1629 | } |
1630 | QDateTime modifiedCalendar = mLastCalendarSync; | 1630 | QDateTime modifiedCalendar = mLastCalendarSync; |
1631 | eventLSync = getLastSyncEvent(); | 1631 | eventLSync = getLastSyncEvent(); |
1632 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1632 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1633 | if ( eventR ) { | 1633 | if ( eventR ) { |
1634 | qDebug("last-syncEvent on remote found "); | 1634 | qDebug("last-syncEvent on remote found "); |
1635 | eventRSync = (Event*) eventR->clone(); | 1635 | eventRSync = (Event*) eventR->clone(); |
1636 | remote->deleteEvent(eventR ); | 1636 | remote->deleteEvent(eventR ); |
1637 | 1637 | ||
1638 | } else { | 1638 | } else { |
1639 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1639 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1640 | eventRSync = (Event*)eventLSync->clone(); | 1640 | eventRSync = (Event*)eventLSync->clone(); |
1641 | } else { | 1641 | } else { |
1642 | fullDateRange = true; | 1642 | fullDateRange = true; |
1643 | eventRSync = new Event(); | 1643 | eventRSync = new Event(); |
1644 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1644 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1645 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1645 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1646 | eventRSync->setDtStart( mLastCalendarSync ); | 1646 | eventRSync->setDtStart( mLastCalendarSync ); |
1647 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1647 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1648 | eventRSync->setCategories( i18n("SyncEvent") ); | 1648 | eventRSync->setCategories( i18n("SyncEvent") ); |
1649 | } | 1649 | } |
1650 | } | 1650 | } |
1651 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1651 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1652 | fullDateRange = true; | 1652 | fullDateRange = true; |
1653 | 1653 | ||
1654 | if ( ! fullDateRange ) { | 1654 | if ( ! fullDateRange ) { |
1655 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1655 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1656 | 1656 | ||
1657 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1657 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1658 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1658 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1659 | fullDateRange = true; | 1659 | fullDateRange = true; |
1660 | } | 1660 | } |
1661 | } | 1661 | } |
1662 | if ( mSyncManager->syncWithDesktop() ) { | 1662 | if ( mSyncManager->syncWithDesktop() ) { |
1663 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1663 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1664 | } | 1664 | } |
1665 | if ( fullDateRange ) | 1665 | if ( fullDateRange ) |
1666 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1666 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1667 | else | 1667 | else |
1668 | mLastCalendarSync = eventLSync->dtStart(); | 1668 | mLastCalendarSync = eventLSync->dtStart(); |
1669 | // for resyncing if own file has changed | 1669 | // for resyncing if own file has changed |
1670 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1670 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1671 | mLastCalendarSync = loadedFileVersion; | 1671 | mLastCalendarSync = loadedFileVersion; |
1672 | //qDebug("setting mLastCalendarSync "); | 1672 | //qDebug("setting mLastCalendarSync "); |
1673 | } | 1673 | } |
1674 | //qDebug("*************************** "); | 1674 | //qDebug("*************************** "); |
1675 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1675 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1676 | QPtrList<Incidence> er = remote->rawIncidences(); | 1676 | QPtrList<Incidence> er = remote->rawIncidences(); |
1677 | Incidence* inR = er.first(); | 1677 | Incidence* inR = er.first(); |
1678 | Incidence* inL; | 1678 | Incidence* inL; |
1679 | QProgressBar bar( er.count(),0 ); | 1679 | QProgressBar bar( er.count(),0 ); |
1680 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1680 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1681 | 1681 | ||
1682 | // ************** setting up filter ************* | 1682 | // ************** setting up filter ************* |
1683 | CalFilter *filterIN = 0; | 1683 | CalFilter *filterIN = 0; |
1684 | CalFilter *filterOUT = 0; | 1684 | CalFilter *filterOUT = 0; |
1685 | CalFilter *filter = mFilters.first(); | 1685 | CalFilter *filter = mFilters.first(); |
1686 | while(filter) { | 1686 | while(filter) { |
1687 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1687 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1688 | filterIN = filter; | 1688 | filterIN = filter; |
1689 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1689 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1690 | filterOUT = filter; | 1690 | filterOUT = filter; |
1691 | filter = mFilters.next(); | 1691 | filter = mFilters.next(); |
1692 | } | 1692 | } |
1693 | int w = 300; | 1693 | int w = 300; |
1694 | if ( QApplication::desktop()->width() < 320 ) | 1694 | if ( QApplication::desktop()->width() < 320 ) |
1695 | w = 220; | 1695 | w = 220; |
1696 | int h = bar.sizeHint().height() ; | 1696 | int h = bar.sizeHint().height() ; |
1697 | int dw = QApplication::desktop()->width(); | 1697 | int dw = QApplication::desktop()->width(); |
1698 | int dh = QApplication::desktop()->height(); | 1698 | int dh = QApplication::desktop()->height(); |
1699 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1699 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1700 | bar.show(); | 1700 | bar.show(); |
1701 | int modulo = (er.count()/10)+1; | 1701 | int modulo = (er.count()/10)+1; |
1702 | int incCounter = 0; | 1702 | int incCounter = 0; |
1703 | while ( inR ) { | 1703 | while ( inR ) { |
1704 | if ( ! bar.isVisible() ) | 1704 | if ( ! bar.isVisible() ) |
1705 | return false; | 1705 | return false; |
1706 | if ( incCounter % modulo == 0 ) | 1706 | if ( incCounter % modulo == 0 ) |
1707 | bar.setProgress( incCounter ); | 1707 | bar.setProgress( incCounter ); |
1708 | ++incCounter; | 1708 | ++incCounter; |
1709 | uid = inR->uid(); | 1709 | uid = inR->uid(); |
1710 | bool skipIncidence = false; | 1710 | bool skipIncidence = false; |
1711 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1711 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1712 | skipIncidence = true; | 1712 | skipIncidence = true; |
1713 | QString idS; | 1713 | QString idS; |
1714 | qApp->processEvents(); | 1714 | qApp->processEvents(); |
1715 | if ( !skipIncidence ) { | 1715 | if ( !skipIncidence ) { |
1716 | inL = local->incidenceForUid( uid , false ); | 1716 | inL = local->incidenceForUid( uid , false ); |
1717 | if ( inL ) { // maybe conflict - same uid in both calendars | 1717 | if ( inL ) { // maybe conflict - same uid in both calendars |
1718 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1718 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1719 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1719 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1720 | if ( take == 3 ) | 1720 | if ( take == 3 ) |
1721 | return false; | 1721 | return false; |
1722 | if ( take == 1 ) {// take local ********************** | 1722 | if ( take == 1 ) {// take local ********************** |
1723 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1723 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1724 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1724 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1725 | else | 1725 | else |
1726 | idS = inR->IDStr(); | 1726 | idS = inR->IDStr(); |
1727 | int calID = inR->calID(); | 1727 | int calID = inR->calID(); |
1728 | remote->deleteIncidence( inR ); | 1728 | remote->deleteIncidence( inR ); |
1729 | inR = inL->clone(); | 1729 | inR = inL->clone(); |
1730 | inR->setCalID( calID ); | 1730 | inR->setCalID( calID ); |
1731 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1731 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1732 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1732 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1733 | inR->setIDStr( idS ); | 1733 | inR->setIDStr( idS ); |
1734 | remote->addIncidence( inR ); | 1734 | remote->addIncidence( inR ); |
1735 | if ( mSyncManager->syncWithDesktop() ) | 1735 | if ( mSyncManager->syncWithDesktop() ) |
1736 | inR->setPilotId( 2 ); | 1736 | inR->setPilotId( 2 ); |
1737 | ++changedRemote; | 1737 | ++changedRemote; |
1738 | } else {// take remote ********************** | 1738 | } else {// take remote ********************** |
1739 | if ( !inL->isReadOnly() ) { | 1739 | if ( !inL->isReadOnly() ) { |
1740 | idS = inL->IDStr(); | 1740 | idS = inL->IDStr(); |
1741 | int pid = inL->pilotId(); | 1741 | int pid = inL->pilotId(); |
1742 | int calID = inL->calID(); | 1742 | int calID = inL->calID(); |
1743 | local->deleteIncidence( inL ); | 1743 | local->deleteIncidence( inL ); |
1744 | inL = inR->clone(); | 1744 | inL = inR->clone(); |
1745 | inL->setCalID( calID ); | 1745 | inL->setCalID( calID ); |
1746 | if ( mSyncManager->syncWithDesktop() ) | 1746 | if ( mSyncManager->syncWithDesktop() ) |
1747 | inL->setPilotId( pid ); | 1747 | inL->setPilotId( pid ); |
1748 | inL->setIDStr( idS ); | 1748 | inL->setIDStr( idS ); |
1749 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1749 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1750 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1750 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1751 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1751 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1752 | } | 1752 | } |
1753 | local->addIncidence( inL ); | 1753 | local->addIncidence( inL ); |
1754 | ++changedLocal; | 1754 | ++changedLocal; |
1755 | } | 1755 | } |
1756 | } | 1756 | } |
1757 | } | 1757 | } |
1758 | } else { // no conflict ********** add or delete remote | 1758 | } else { // no conflict ********** add or delete remote |
1759 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1759 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1760 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1760 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1761 | QString des = eventLSync->description(); | 1761 | QString des = eventLSync->description(); |
1762 | QString pref = "e"; | 1762 | QString pref = "e"; |
1763 | if ( inR->typeID() == todoID ) | 1763 | if ( inR->typeID() == todoID ) |
1764 | pref = "t"; | 1764 | pref = "t"; |
1765 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1765 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1766 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1766 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1767 | //remote->deleteIncidence( inR ); | 1767 | //remote->deleteIncidence( inR ); |
1768 | ++deletedEventR; | 1768 | ++deletedEventR; |
1769 | } else { | 1769 | } else { |
1770 | inR->setLastModified( modifiedCalendar ); | 1770 | inR->setLastModified( modifiedCalendar ); |
1771 | inL = inR->clone(); | 1771 | inL = inR->clone(); |
1772 | inL->setIDStr( ":" ); | 1772 | inL->setIDStr( ":" ); |
1773 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1773 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1774 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1774 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1775 | 1775 | ||
1776 | inL->setCalID( 0 );// add to default cal | 1776 | inL->setCalID( 0 );// add to default cal |
1777 | local->addIncidence( inL ); | 1777 | local->addIncidence( inL ); |
1778 | ++addedEvent; | 1778 | ++addedEvent; |
1779 | 1779 | ||
1780 | } | 1780 | } |
1781 | } else { | 1781 | } else { |
1782 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1782 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1783 | inR->setLastModified( modifiedCalendar ); | 1783 | inR->setLastModified( modifiedCalendar ); |
1784 | inL = inR->clone(); | 1784 | inL = inR->clone(); |
1785 | inL->setIDStr( ":" ); | 1785 | inL->setIDStr( ":" ); |
1786 | inL->setCalID( 0 );// add to default cal | 1786 | inL->setCalID( 0 );// add to default cal |
1787 | local->addIncidence( inL ); | 1787 | local->addIncidence( inL ); |
1788 | ++addedEvent; | 1788 | ++addedEvent; |
1789 | 1789 | ||
1790 | } else { | 1790 | } else { |
1791 | checkExternSyncEvent(eventRSyncSharp, inR); | 1791 | checkExternSyncEvent(eventRSyncSharp, inR); |
1792 | remote->deleteIncidence( inR ); | 1792 | remote->deleteIncidence( inR ); |
1793 | ++deletedEventR; | 1793 | ++deletedEventR; |
1794 | } | 1794 | } |
1795 | } | 1795 | } |
1796 | } else { | 1796 | } else { |
1797 | ++filteredIN; | 1797 | ++filteredIN; |
1798 | } | 1798 | } |
1799 | } | 1799 | } |
1800 | } | 1800 | } |
1801 | inR = er.next(); | 1801 | inR = er.next(); |
1802 | } | 1802 | } |
1803 | QPtrList<Incidence> el = local->rawIncidences(); | 1803 | QPtrList<Incidence> el = local->rawIncidences(); |
1804 | inL = el.first(); | 1804 | inL = el.first(); |
1805 | modulo = (el.count()/10)+1; | 1805 | modulo = (el.count()/10)+1; |
1806 | bar.setCaption (i18n("Add / remove events") ); | 1806 | bar.setCaption (i18n("Add / remove events") ); |
1807 | bar.setTotalSteps ( el.count() ) ; | 1807 | bar.setTotalSteps ( el.count() ) ; |
1808 | bar.show(); | 1808 | bar.show(); |
1809 | incCounter = 0; | 1809 | incCounter = 0; |
1810 | 1810 | ||
1811 | while ( inL ) { | 1811 | while ( inL ) { |
1812 | 1812 | ||
1813 | qApp->processEvents(); | 1813 | qApp->processEvents(); |
1814 | if ( ! bar.isVisible() ) | 1814 | if ( ! bar.isVisible() ) |
1815 | return false; | 1815 | return false; |
1816 | if ( incCounter % modulo == 0 ) | 1816 | if ( incCounter % modulo == 0 ) |
1817 | bar.setProgress( incCounter ); | 1817 | bar.setProgress( incCounter ); |
1818 | ++incCounter; | 1818 | ++incCounter; |
1819 | uid = inL->uid(); | 1819 | uid = inL->uid(); |
1820 | bool skipIncidence = false; | 1820 | bool skipIncidence = false; |
1821 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1821 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1822 | skipIncidence = true; | 1822 | skipIncidence = true; |
1823 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1823 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1824 | skipIncidence = true; | 1824 | skipIncidence = true; |
1825 | if ( !skipIncidence ) { | 1825 | if ( !skipIncidence ) { |
1826 | inR = remote->incidenceForUid( uid , true ); | 1826 | inR = remote->incidenceForUid( uid , true ); |
1827 | if ( ! inR ) { | 1827 | if ( ! inR ) { |
1828 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1828 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1829 | // no conflict ********** add or delete local | 1829 | // no conflict ********** add or delete local |
1830 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1830 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1831 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1831 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1832 | checkExternSyncEvent(eventLSyncSharp, inL); | 1832 | checkExternSyncEvent(eventLSyncSharp, inL); |
1833 | local->deleteIncidence( inL ); | 1833 | local->deleteIncidence( inL ); |
1834 | ++deletedEventL; | 1834 | ++deletedEventL; |
1835 | } else { | 1835 | } else { |
1836 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1836 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1837 | inL->removeID(mCurrentSyncDevice ); | 1837 | inL->removeID(mCurrentSyncDevice ); |
1838 | ++addedEventR; | 1838 | ++addedEventR; |
1839 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1839 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1840 | inL->setLastModified( modifiedCalendar ); | 1840 | inL->setLastModified( modifiedCalendar ); |
1841 | inR = inL->clone(); | 1841 | inR = inL->clone(); |
1842 | inR->setIDStr( ":" ); | 1842 | inR->setIDStr( ":" ); |
1843 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1843 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1844 | inR->setCalID( 0 );// add to default cal | 1844 | inR->setCalID( 0 );// add to default cal |
1845 | remote->addIncidence( inR ); | 1845 | remote->addIncidence( inR ); |
1846 | } | 1846 | } |
1847 | } | 1847 | } |
1848 | } else { | 1848 | } else { |
1849 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1849 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1850 | checkExternSyncEvent(eventLSyncSharp, inL); | 1850 | checkExternSyncEvent(eventLSyncSharp, inL); |
1851 | local->deleteIncidence( inL ); | 1851 | local->deleteIncidence( inL ); |
1852 | ++deletedEventL; | 1852 | ++deletedEventL; |
1853 | } else { | 1853 | } else { |
1854 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1854 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1855 | ++addedEventR; | 1855 | ++addedEventR; |
1856 | inL->setLastModified( modifiedCalendar ); | 1856 | inL->setLastModified( modifiedCalendar ); |
1857 | inR = inL->clone(); | 1857 | inR = inL->clone(); |
1858 | inR->setIDStr( ":" ); | 1858 | inR->setIDStr( ":" ); |
1859 | inR->setCalID( 0 );// add to default cal | 1859 | inR->setCalID( 0 );// add to default cal |
1860 | remote->addIncidence( inR ); | 1860 | remote->addIncidence( inR ); |
1861 | } | 1861 | } |
1862 | } | 1862 | } |
1863 | } | 1863 | } |
1864 | } else { | 1864 | } else { |
1865 | ++filteredOUT; | 1865 | ++filteredOUT; |
1866 | } | 1866 | } |
1867 | } | 1867 | } |
1868 | } | 1868 | } |
1869 | inL = el.next(); | 1869 | inL = el.next(); |
1870 | } | 1870 | } |
1871 | int delFut = 0; | 1871 | int delFut = 0; |
1872 | int remRem = 0; | 1872 | int remRem = 0; |
1873 | if ( mSyncManager->mWriteBackInFuture ) { | 1873 | if ( mSyncManager->mWriteBackInFuture ) { |
1874 | er = remote->rawIncidences(); | 1874 | er = remote->rawIncidences(); |
1875 | remRem = er.count(); | 1875 | remRem = er.count(); |
1876 | inR = er.first(); | 1876 | inR = er.first(); |
1877 | QDateTime dt; | 1877 | QDateTime dt; |
1878 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1878 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1879 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1879 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1880 | while ( inR ) { | 1880 | while ( inR ) { |
1881 | if ( inR->typeID() == todoID ) { | 1881 | if ( inR->typeID() == todoID ) { |
1882 | Todo * t = (Todo*)inR; | 1882 | Todo * t = (Todo*)inR; |
1883 | if ( t->hasDueDate() ) | 1883 | if ( t->hasDueDate() ) |
1884 | dt = t->dtDue(); | 1884 | dt = t->dtDue(); |
1885 | else | 1885 | else |
1886 | dt = cur.addSecs( 62 ); | 1886 | dt = cur.addSecs( 62 ); |
1887 | } | 1887 | } |
1888 | else if (inR->typeID() == eventID ) { | 1888 | else if (inR->typeID() == eventID ) { |
1889 | bool ok; | 1889 | bool ok; |
1890 | dt = inR->getNextOccurence( cur, &ok ); | 1890 | dt = inR->getNextOccurence( cur, &ok ); |
1891 | if ( !ok ) | 1891 | if ( !ok ) |
1892 | dt = cur.addSecs( -62 ); | 1892 | dt = cur.addSecs( -62 ); |
1893 | } | 1893 | } |
1894 | else | 1894 | else |
1895 | dt = inR->dtStart(); | 1895 | dt = inR->dtStart(); |
1896 | if ( dt < cur || dt > end ) { | 1896 | if ( dt < cur || dt > end ) { |
1897 | remote->deleteIncidence( inR ); | 1897 | remote->deleteIncidence( inR ); |
1898 | ++delFut; | 1898 | ++delFut; |
1899 | } | 1899 | } |
1900 | inR = er.next(); | 1900 | inR = er.next(); |
1901 | } | 1901 | } |
1902 | } | 1902 | } |
1903 | bar.hide(); | 1903 | bar.hide(); |
1904 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1904 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1905 | eventLSync->setReadOnly( false ); | 1905 | eventLSync->setReadOnly( false ); |
1906 | eventLSync->setDtStart( mLastCalendarSync ); | 1906 | eventLSync->setDtStart( mLastCalendarSync ); |
1907 | eventRSync->setDtStart( mLastCalendarSync ); | 1907 | eventRSync->setDtStart( mLastCalendarSync ); |
1908 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1908 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1909 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1909 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1910 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1910 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1911 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1911 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1912 | eventLSync->setReadOnly( true ); | 1912 | eventLSync->setReadOnly( true ); |
1913 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1913 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1914 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1914 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1915 | remote->addEvent( eventRSync ); | 1915 | remote->addEvent( eventRSync ); |
1916 | else | 1916 | else |
1917 | delete eventRSync; | 1917 | delete eventRSync; |
1918 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1918 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1919 | QString mes; | 1919 | QString mes; |
1920 | 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 ); | 1920 | 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 ); |
1921 | QString delmess; | 1921 | QString delmess; |
1922 | if ( delFut ) { | 1922 | if ( delFut ) { |
1923 | 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); | 1923 | 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); |
1924 | mes += delmess; | 1924 | mes += delmess; |
1925 | } | 1925 | } |
1926 | mes = i18n("Local calendar changed!\n") +mes; | 1926 | mes = i18n("Local calendar changed!\n") +mes; |
1927 | mCalendar->checkAlarmForIncidence( 0, true ); | 1927 | mCalendar->checkAlarmForIncidence( 0, true ); |
1928 | qDebug( mes ); | 1928 | qDebug( mes ); |
1929 | if ( mSyncManager->mShowSyncSummary ) { | 1929 | if ( mSyncManager->mShowSyncSummary ) { |
1930 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1930 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1931 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1931 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1932 | qDebug("KO: WB cancelled "); | 1932 | qDebug("KO: WB cancelled "); |
1933 | mSyncManager->mWriteBackFile = false; | 1933 | mSyncManager->mWriteBackFile = false; |
1934 | return syncOK; | 1934 | return syncOK; |
1935 | } | 1935 | } |
1936 | } | 1936 | } |
1937 | return syncOK; | 1937 | return syncOK; |
1938 | } | 1938 | } |
1939 | 1939 | ||
1940 | void CalendarView::setSyncDevice( QString s ) | 1940 | void CalendarView::setSyncDevice( QString s ) |
1941 | { | 1941 | { |
1942 | mCurrentSyncDevice= s; | 1942 | mCurrentSyncDevice= s; |
1943 | } | 1943 | } |
1944 | void CalendarView::setSyncName( QString s ) | 1944 | void CalendarView::setSyncName( QString s ) |
1945 | { | 1945 | { |
1946 | mCurrentSyncName= s; | 1946 | mCurrentSyncName= s; |
1947 | } | 1947 | } |
1948 | bool CalendarView::syncCalendar(QString filename, int mode) | 1948 | bool CalendarView::syncCalendar(QString filename, int mode) |
1949 | { | 1949 | { |
1950 | //qDebug("syncCalendar %s ", filename.latin1()); | 1950 | //qDebug("syncCalendar %s ", filename.latin1()); |
1951 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1951 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1952 | CalendarLocal* calendar = new CalendarLocal(); | 1952 | CalendarLocal* calendar = new CalendarLocal(); |
1953 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1953 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1954 | FileStorage* storage = new FileStorage( calendar ); | 1954 | FileStorage* storage = new FileStorage( calendar ); |
1955 | bool syncOK = false; | 1955 | bool syncOK = false; |
1956 | storage->setFileName( filename ); | 1956 | storage->setFileName( filename ); |
1957 | // qDebug("loading ... "); | 1957 | // qDebug("loading ... "); |
1958 | if ( storage->load() ) { | 1958 | if ( storage->load() ) { |
1959 | getEventViewerDialog()->setSyncMode( true ); | 1959 | getEventViewerDialog()->setSyncMode( true ); |
1960 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1960 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1961 | getEventViewerDialog()->setSyncMode( false ); | 1961 | getEventViewerDialog()->setSyncMode( false ); |
1962 | if ( syncOK ) { | 1962 | if ( syncOK ) { |
1963 | if ( mSyncManager->mWriteBackFile ) | 1963 | if ( mSyncManager->mWriteBackFile ) |
1964 | { | 1964 | { |
1965 | storage->setSaveFormat( new ICalFormat() ); | 1965 | storage->setSaveFormat( new ICalFormat() ); |
1966 | storage->save(); | 1966 | storage->save(); |
1967 | } | 1967 | } |
1968 | } | 1968 | } |
1969 | setModified( true ); | 1969 | setModified( true ); |
1970 | } | 1970 | } |
1971 | delete storage; | 1971 | delete storage; |
1972 | delete calendar; | 1972 | delete calendar; |
1973 | if ( syncOK ) | 1973 | if ( syncOK ) |
1974 | updateView(); | 1974 | updateView(); |
1975 | return syncOK; | 1975 | return syncOK; |
1976 | } | 1976 | } |
1977 | 1977 | ||
1978 | void CalendarView::syncExternal( int mode ) | 1978 | void CalendarView::syncExternal( int mode ) |
1979 | { | 1979 | { |
1980 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1980 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1981 | |||
1982 | qApp->processEvents(); | 1981 | qApp->processEvents(); |
1983 | CalendarLocal* calendar = new CalendarLocal(); | 1982 | CalendarLocal* calendar = new CalendarLocal(); |
1984 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1983 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1985 | bool syncOK = false; | 1984 | bool syncOK = false; |
1986 | bool loadSuccess = false; | 1985 | bool loadSuccess = false; |
1987 | PhoneFormat* phoneFormat = 0; | 1986 | PhoneFormat* phoneFormat = 0; |
1988 | emit tempDisableBR(true); | 1987 | emit tempDisableBR(true); |
1989 | #ifndef DESKTOP_VERSION | 1988 | #ifndef DESKTOP_VERSION |
1990 | SharpFormat* sharpFormat = 0; | 1989 | SharpFormat* sharpFormat = 0; |
1991 | if ( mode == 0 ) { // sharp | 1990 | if ( mode == 0 ) { // sharp |
1992 | sharpFormat = new SharpFormat () ; | 1991 | sharpFormat = new SharpFormat () ; |
1993 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1992 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1994 | 1993 | ||
1995 | } else | 1994 | } else |
1996 | #endif | 1995 | #endif |
1997 | if ( mode == 1 ) { // phone | 1996 | if ( mode == 1 ) { // phone |
1998 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1997 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1999 | mSyncManager->mPhoneDevice, | 1998 | mSyncManager->mPhoneDevice, |
2000 | mSyncManager->mPhoneConnection, | 1999 | mSyncManager->mPhoneConnection, |
2001 | mSyncManager->mPhoneModel); | 2000 | mSyncManager->mPhoneModel); |
2002 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 2001 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
2003 | 2002 | ||
2004 | } else { | 2003 | } else { |
2005 | emit tempDisableBR(false); | 2004 | emit tempDisableBR(false); |
2006 | return; | 2005 | return; |
2007 | } | 2006 | } |
2008 | if ( loadSuccess ) { | 2007 | if ( loadSuccess ) { |
2009 | getEventViewerDialog()->setSyncMode( true ); | 2008 | getEventViewerDialog()->setSyncMode( true ); |
2010 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2009 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2011 | getEventViewerDialog()->setSyncMode( false ); | 2010 | getEventViewerDialog()->setSyncMode( false ); |
2012 | qApp->processEvents(); | 2011 | qApp->processEvents(); |
2013 | if ( syncOK ) { | 2012 | if ( syncOK ) { |
2014 | if ( mSyncManager->mWriteBackFile ) | 2013 | if ( mSyncManager->mWriteBackFile ) |
2015 | { | 2014 | { |
2016 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 2015 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
2017 | Incidence* inc = iL.first(); | 2016 | Incidence* inc = iL.first(); |
2018 | if ( phoneFormat ) { | 2017 | if ( phoneFormat ) { |
2019 | while ( inc ) { | 2018 | while ( inc ) { |
2020 | inc->removeID(mCurrentSyncDevice); | 2019 | inc->removeID(mCurrentSyncDevice); |
2021 | inc = iL.next(); | 2020 | inc = iL.next(); |
2022 | } | 2021 | } |
2023 | } | 2022 | } |
2024 | #ifndef DESKTOP_VERSION | 2023 | #ifndef DESKTOP_VERSION |
2025 | if ( sharpFormat ) | 2024 | if ( sharpFormat ) |
2026 | sharpFormat->save(calendar); | 2025 | sharpFormat->save(calendar); |
2027 | #endif | 2026 | #endif |
2028 | if ( phoneFormat ) | 2027 | if ( phoneFormat ) |
2029 | phoneFormat->save(calendar); | 2028 | phoneFormat->save(calendar); |
2030 | iL = calendar->rawIncidences(); | 2029 | iL = calendar->rawIncidences(); |
2031 | inc = iL.first(); | 2030 | inc = iL.first(); |
2032 | Incidence* loc; | 2031 | Incidence* loc; |
2033 | while ( inc ) { | 2032 | while ( inc ) { |
2034 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 2033 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
2035 | loc = mCalendar->incidence(inc->uid() ); | 2034 | loc = mCalendar->incidence(inc->uid() ); |
2036 | if ( loc ) { | 2035 | if ( loc ) { |
2037 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 2036 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
2038 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 2037 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
2039 | } | 2038 | } |
2040 | } | 2039 | } |
2041 | inc = iL.next(); | 2040 | inc = iL.next(); |
2042 | } | 2041 | } |
2043 | Incidence* lse = getLastSyncEvent(); | 2042 | Incidence* lse = getLastSyncEvent(); |
2044 | if ( lse ) { | 2043 | if ( lse ) { |
2045 | lse->setReadOnly( false ); | 2044 | lse->setReadOnly( false ); |
2046 | lse->setDescription( "" ); | 2045 | lse->setDescription( "" ); |
2047 | lse->setReadOnly( true ); | 2046 | lse->setReadOnly( true ); |
2048 | } | 2047 | } |
2049 | } | 2048 | } |
2050 | } else { | 2049 | } else { |
2051 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 2050 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
2052 | } | 2051 | } |
2053 | setModified( true ); | 2052 | setModified( true ); |
2054 | } else { | 2053 | } else { |
2055 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 2054 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
2056 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 2055 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
2057 | question, i18n("Ok")) ; | 2056 | question, i18n("Ok")) ; |
2058 | 2057 | ||
2059 | } | 2058 | } |
2060 | delete calendar; | 2059 | delete calendar; |
2061 | updateView(); | 2060 | updateView(); |
2062 | emit tempDisableBR(false); | 2061 | emit tempDisableBR(false); |
2063 | return ;//syncOK; | 2062 | return ;//syncOK; |
2064 | 2063 | ||
2065 | } | 2064 | } |
2066 | 2065 | ||
2067 | bool CalendarView::importBday() | 2066 | bool CalendarView::importBday() |
2068 | { | 2067 | { |
2069 | #ifndef KORG_NOKABC | 2068 | #ifndef KORG_NOKABC |
2070 | 2069 | ||
2071 | #ifdef DESKTOP_VERSION | 2070 | #ifdef DESKTOP_VERSION |
2072 | int curCal = mCalendar->defaultCalendar(); | 2071 | int curCal = mCalendar->defaultCalendar(); |
2073 | int bd = mCalEditView->getBirtdayID(); | 2072 | int bd = mCalEditView->getBirtdayID(); |
2074 | if ( bd == 0 ) | 2073 | if ( bd == 0 ) |
2075 | return false; | 2074 | return false; |
2076 | mCalendar->setDefaultCalendar( bd ); | 2075 | mCalendar->setDefaultCalendar( bd ); |
2077 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 2076 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
2078 | KABC::AddressBook::Iterator it; | 2077 | KABC::AddressBook::Iterator it; |
2079 | int count = 0; | 2078 | int count = 0; |
2080 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2079 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2081 | ++count; | 2080 | ++count; |
2082 | } | 2081 | } |
2083 | QProgressBar bar(count,0 ); | 2082 | QProgressBar bar(count,0 ); |
2084 | int w = 300; | 2083 | int w = 300; |
2085 | if ( QApplication::desktop()->width() < 320 ) | 2084 | if ( QApplication::desktop()->width() < 320 ) |
2086 | w = 220; | 2085 | w = 220; |
2087 | int h = bar.sizeHint().height() ; | 2086 | int h = bar.sizeHint().height() ; |
2088 | int dw = QApplication::desktop()->width(); | 2087 | int dw = QApplication::desktop()->width(); |
2089 | int dh = QApplication::desktop()->height(); | 2088 | int dh = QApplication::desktop()->height(); |
2090 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2089 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2091 | bar.show(); | 2090 | bar.show(); |
2092 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 2091 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
2093 | qApp->processEvents(); | 2092 | qApp->processEvents(); |
2094 | count = 0; | 2093 | count = 0; |
2095 | int addCount = 0; | 2094 | int addCount = 0; |
2096 | KCal::Attendee* a = 0; | 2095 | KCal::Attendee* a = 0; |
2097 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2096 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2098 | if ( ! bar.isVisible() ) | 2097 | if ( ! bar.isVisible() ) |
2099 | return false; | 2098 | return false; |
2100 | bar.setProgress( count++ ); | 2099 | bar.setProgress( count++ ); |
2101 | qApp->processEvents(); | 2100 | qApp->processEvents(); |
2102 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 2101 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
2103 | if ( (*it).birthday().date().isValid() ){ | 2102 | if ( (*it).birthday().date().isValid() ){ |
2104 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2103 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2105 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 2104 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
2106 | ++addCount; | 2105 | ++addCount; |
2107 | } | 2106 | } |
2108 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 2107 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
2109 | if ( anni.isValid() ){ | 2108 | if ( anni.isValid() ){ |
2110 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2109 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2111 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 2110 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
2112 | ++addCount; | 2111 | ++addCount; |
2113 | } | 2112 | } |
2114 | } | 2113 | } |
2115 | mCalendar->setDefaultCalendar( curCal ); | 2114 | mCalendar->setDefaultCalendar( curCal ); |
2116 | updateView(); | 2115 | updateView(); |
2117 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2116 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2118 | #else //DESKTOP_VERSION | 2117 | #else //DESKTOP_VERSION |
2119 | 2118 | ||
2120 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 2119 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
2121 | // the result should now arrive through method insertBirthdays | 2120 | // the result should now arrive through method insertBirthdays |
2122 | 2121 | ||
2123 | #endif //DESKTOP_VERSION | 2122 | #endif //DESKTOP_VERSION |
2124 | 2123 | ||
2125 | #endif //KORG_NOKABC | 2124 | #endif //KORG_NOKABC |
2126 | 2125 | ||
2127 | 2126 | ||
2128 | return true; | 2127 | return true; |
2129 | } | 2128 | } |
2130 | 2129 | ||
2131 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 2130 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
2132 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 2131 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
2133 | const QStringList& anniversaryList, const QStringList& realNameList, | 2132 | const QStringList& anniversaryList, const QStringList& realNameList, |
2134 | const QStringList& emailList, const QStringList& assembledNameList, | 2133 | const QStringList& emailList, const QStringList& assembledNameList, |
2135 | const QStringList& uidList) | 2134 | const QStringList& uidList) |
2136 | { | 2135 | { |
2137 | 2136 | ||
2138 | //qDebug("KO::CalendarView::insertBirthdays"); | 2137 | //qDebug("KO::CalendarView::insertBirthdays"); |
2139 | if (uid == this->name()) | 2138 | if (uid == this->name()) |
2140 | { | 2139 | { |
2141 | int curCal = mCalendar->defaultCalendar(); | 2140 | int curCal = mCalendar->defaultCalendar(); |
2142 | int bd = mCalEditView->getBirtdayID(); | 2141 | int bd = mCalEditView->getBirtdayID(); |
2143 | if ( bd == 0 ) | 2142 | if ( bd == 0 ) |
2144 | return; | 2143 | return; |
2145 | mCalendar->setDefaultCalendar( bd ); | 2144 | mCalendar->setDefaultCalendar( bd ); |
2146 | 2145 | ||
2147 | 2146 | ||
2148 | int count = birthdayList.count(); | 2147 | int count = birthdayList.count(); |
2149 | int addCount = 0; | 2148 | int addCount = 0; |
2150 | KCal::Attendee* a = 0; | 2149 | KCal::Attendee* a = 0; |
2151 | 2150 | ||
2152 | //qDebug("CalView 1 %i", count); | 2151 | //qDebug("CalView 1 %i", count); |
2153 | 2152 | ||
2154 | QProgressBar bar(count,0 ); | 2153 | QProgressBar bar(count,0 ); |
2155 | int w = 300; | 2154 | int w = 300; |
2156 | if ( QApplication::desktop()->width() < 320 ) | 2155 | if ( QApplication::desktop()->width() < 320 ) |
2157 | w = 220; | 2156 | w = 220; |
2158 | int h = bar.sizeHint().height() ; | 2157 | int h = bar.sizeHint().height() ; |
2159 | int dw = QApplication::desktop()->width(); | 2158 | int dw = QApplication::desktop()->width(); |
2160 | int dh = QApplication::desktop()->height(); | 2159 | int dh = QApplication::desktop()->height(); |
2161 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2160 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2162 | bar.show(); | 2161 | bar.show(); |
2163 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 2162 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
2164 | qApp->processEvents(); | 2163 | qApp->processEvents(); |
2165 | 2164 | ||
2166 | QDate birthday; | 2165 | QDate birthday; |
2167 | QDate anniversary; | 2166 | QDate anniversary; |
2168 | QString realName; | 2167 | QString realName; |
2169 | QString email; | 2168 | QString email; |
2170 | QString assembledName; | 2169 | QString assembledName; |
2171 | QString uid; | 2170 | QString uid; |
2172 | bool ok = true; | 2171 | bool ok = true; |
2173 | for ( int i = 0; i < count; i++) | 2172 | for ( int i = 0; i < count; i++) |
2174 | { | 2173 | { |
2175 | if ( ! bar.isVisible() ) | 2174 | if ( ! bar.isVisible() ) |
2176 | return; | 2175 | return; |
2177 | bar.setProgress( i ); | 2176 | bar.setProgress( i ); |
2178 | qApp->processEvents(); | 2177 | qApp->processEvents(); |
2179 | 2178 | ||
2180 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 2179 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
2181 | if (!ok) { | 2180 | if (!ok) { |
2182 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 2181 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
2183 | } | 2182 | } |
2184 | 2183 | ||
2185 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 2184 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
2186 | if (!ok) { | 2185 | if (!ok) { |
2187 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 2186 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
2188 | } | 2187 | } |
2189 | realName = realNameList[i]; | 2188 | realName = realNameList[i]; |
2190 | email = emailList[i]; | 2189 | email = emailList[i]; |
2191 | assembledName = assembledNameList[i]; | 2190 | assembledName = assembledNameList[i]; |
2192 | uid = uidList[i]; | 2191 | uid = uidList[i]; |
2193 | //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() ); | 2192 | //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() ); |
2194 | 2193 | ||
2195 | if ( birthday.isValid() ){ | 2194 | if ( birthday.isValid() ){ |
2196 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2195 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2197 | KCal::Attendee::ReqParticipant,uid) ; | 2196 | KCal::Attendee::ReqParticipant,uid) ; |
2198 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 2197 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
2199 | ++addCount; | 2198 | ++addCount; |
2200 | } | 2199 | } |
2201 | 2200 | ||
2202 | if ( anniversary.isValid() ){ | 2201 | if ( anniversary.isValid() ){ |
2203 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2202 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2204 | KCal::Attendee::ReqParticipant,uid) ; | 2203 | KCal::Attendee::ReqParticipant,uid) ; |
2205 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 2204 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
2206 | ++addCount; | 2205 | ++addCount; |
2207 | } | 2206 | } |
2208 | } | 2207 | } |
2209 | 2208 | ||
2210 | mCalendar->setDefaultCalendar( curCal ); | 2209 | mCalendar->setDefaultCalendar( curCal ); |
2211 | updateView(); | 2210 | updateView(); |
2212 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2211 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2213 | 2212 | ||
2214 | } | 2213 | } |
2215 | 2214 | ||
2216 | } | 2215 | } |
2217 | 2216 | ||
2218 | 2217 | ||
2219 | 2218 | ||
2220 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 2219 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
2221 | { | 2220 | { |
2222 | //qDebug("addAnni "); | 2221 | //qDebug("addAnni "); |
2223 | Event * ev = new Event(); | 2222 | Event * ev = new Event(); |
2224 | ev->setOrganizer(KOPrefs::instance()->email()); | 2223 | ev->setOrganizer(KOPrefs::instance()->email()); |
2225 | if ( a ) { | 2224 | if ( a ) { |
2226 | ev->addAttendee( a ); | 2225 | ev->addAttendee( a ); |
2227 | } | 2226 | } |
2228 | QString kind; | 2227 | QString kind; |
2229 | if ( birthday ) { | 2228 | if ( birthday ) { |
2230 | kind = i18n( "Birthday" ); | 2229 | kind = i18n( "Birthday" ); |
2231 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 2230 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
2232 | } | 2231 | } |
2233 | else { | 2232 | else { |
2234 | kind = i18n( "Anniversary" ); | 2233 | kind = i18n( "Anniversary" ); |
2235 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 2234 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
2236 | } | 2235 | } |
2237 | ev->setCategories( kind ); | 2236 | ev->setCategories( kind ); |
2238 | ev->setDtStart( QDateTime(date) ); | 2237 | ev->setDtStart( QDateTime(date) ); |
2239 | ev->setDtEnd( QDateTime(date) ); | 2238 | ev->setDtEnd( QDateTime(date) ); |
2240 | ev->setFloats( true ); | 2239 | ev->setFloats( true ); |
2241 | Recurrence * rec = ev->recurrence(); | 2240 | Recurrence * rec = ev->recurrence(); |
2242 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 2241 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
2243 | rec->addYearlyNum( date.month() ); | 2242 | rec->addYearlyNum( date.month() ); |
2244 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 2243 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
2245 | delete ev; | 2244 | delete ev; |
2246 | return false; | 2245 | return false; |
2247 | } | 2246 | } |
2248 | return true; | 2247 | return true; |
2249 | 2248 | ||
2250 | } | 2249 | } |
2251 | bool CalendarView::importQtopia( const QString &categories, | 2250 | bool CalendarView::importQtopia( const QString &categories, |
2252 | const QString &datebook, | 2251 | const QString &datebook, |
2253 | const QString &todolist ) | 2252 | const QString &todolist ) |
2254 | { | 2253 | { |
2255 | 2254 | ||
2256 | QtopiaFormat qtopiaFormat; | 2255 | QtopiaFormat qtopiaFormat; |
2257 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2256 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2258 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 2257 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2259 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 2258 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2260 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 2259 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2261 | 2260 | ||
2262 | updateView(); | 2261 | updateView(); |
2263 | return true; | 2262 | return true; |
2264 | 2263 | ||
2265 | #if 0 | 2264 | #if 0 |
2266 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 2265 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2267 | mCurrentSyncDevice = "qtopia-XML"; | 2266 | mCurrentSyncDevice = "qtopia-XML"; |
2268 | if ( mSyncManager->mAskForPreferences ) | 2267 | if ( mSyncManager->mAskForPreferences ) |
2269 | edit_sync_options(); | 2268 | edit_sync_options(); |
2270 | qApp->processEvents(); | 2269 | qApp->processEvents(); |
2271 | CalendarLocal* calendar = new CalendarLocal(); | 2270 | CalendarLocal* calendar = new CalendarLocal(); |
2272 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2271 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2273 | bool syncOK = false; | 2272 | bool syncOK = false; |
2274 | QtopiaFormat qtopiaFormat; | 2273 | QtopiaFormat qtopiaFormat; |
2275 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2274 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2276 | bool loadOk = true; | 2275 | bool loadOk = true; |
2277 | if ( !categories.isEmpty() ) | 2276 | if ( !categories.isEmpty() ) |
2278 | loadOk = qtopiaFormat.load( calendar, categories ); | 2277 | loadOk = qtopiaFormat.load( calendar, categories ); |
2279 | if ( loadOk && !datebook.isEmpty() ) | 2278 | if ( loadOk && !datebook.isEmpty() ) |
2280 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2279 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2281 | if ( loadOk && !todolist.isEmpty() ) | 2280 | if ( loadOk && !todolist.isEmpty() ) |
2282 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2281 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2283 | 2282 | ||
2284 | if ( loadOk ) { | 2283 | if ( loadOk ) { |
2285 | getEventViewerDialog()->setSyncMode( true ); | 2284 | getEventViewerDialog()->setSyncMode( true ); |
2286 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2285 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2287 | getEventViewerDialog()->setSyncMode( false ); | 2286 | getEventViewerDialog()->setSyncMode( false ); |
2288 | qApp->processEvents(); | 2287 | qApp->processEvents(); |
2289 | if ( syncOK ) { | 2288 | if ( syncOK ) { |
2290 | if ( mSyncManager->mWriteBackFile ) | 2289 | if ( mSyncManager->mWriteBackFile ) |
2291 | { | 2290 | { |
2292 | // write back XML file | 2291 | // write back XML file |
2293 | 2292 | ||
2294 | } | 2293 | } |
2295 | setModified( true ); | 2294 | setModified( true ); |
2296 | } | 2295 | } |
2297 | } else { | 2296 | } else { |
2298 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2297 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2299 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2298 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2300 | question, i18n("Ok")) ; | 2299 | question, i18n("Ok")) ; |
2301 | } | 2300 | } |
2302 | delete calendar; | 2301 | delete calendar; |
2303 | updateView(); | 2302 | updateView(); |
2304 | return syncOK; | 2303 | return syncOK; |
2305 | 2304 | ||
2306 | 2305 | ||
2307 | #endif | 2306 | #endif |
2308 | 2307 | ||
2309 | } | 2308 | } |
2310 | 2309 | ||
2311 | void CalendarView::setSyncEventsReadOnly() | 2310 | void CalendarView::setSyncEventsReadOnly() |
2312 | { | 2311 | { |
2313 | mCalendar->setSyncEventsReadOnly(); | 2312 | mCalendar->setSyncEventsReadOnly(); |
2314 | } | 2313 | } |
2315 | 2314 | ||
2316 | bool CalendarView::loadCalendars() | 2315 | bool CalendarView::loadCalendars() |
2317 | { | 2316 | { |
2318 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2317 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2319 | KopiCalendarFile * cal = calendars.first(); | 2318 | KopiCalendarFile * cal = calendars.first(); |
2320 | mCalendar->setDefaultCalendar( 1 ); | 2319 | mCalendar->setDefaultCalendar( 1 ); |
2321 | openCalendar( MainWindow::defaultFileName(), false ); | 2320 | openCalendar( MainWindow::defaultFileName(), false ); |
2322 | cal = calendars.next(); | 2321 | cal = calendars.next(); |
2323 | while ( cal ) { | 2322 | while ( cal ) { |
2324 | addCalendar( cal ); | 2323 | addCalendar( cal ); |
2325 | cal = calendars.next(); | 2324 | cal = calendars.next(); |
2326 | } | 2325 | } |
2327 | restoreCalendarSettings(); | 2326 | restoreCalendarSettings(); |
2328 | return true; | 2327 | return true; |
2329 | } | 2328 | } |
2330 | bool CalendarView::restoreCalendarSettings() | 2329 | bool CalendarView::restoreCalendarSettings() |
2331 | { | 2330 | { |
2332 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2331 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2333 | KopiCalendarFile * cal = calendars.first(); | 2332 | KopiCalendarFile * cal = calendars.first(); |
2334 | while ( cal ) { | 2333 | while ( cal ) { |
2335 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2334 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2336 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2335 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2337 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2336 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2338 | if ( cal->isStandard ) | 2337 | if ( cal->isStandard ) |
2339 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2338 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2340 | cal = calendars.next(); | 2339 | cal = calendars.next(); |
2341 | } | 2340 | } |
2342 | setSyncEventsReadOnly(); | 2341 | setSyncEventsReadOnly(); |
2343 | mCalendar->reInitAlarmSettings(); | 2342 | mCalendar->reInitAlarmSettings(); |
2344 | updateUnmanagedViews(); | 2343 | updateUnmanagedViews(); |
2345 | updateView(); | 2344 | updateView(); |
2346 | return true; | 2345 | return true; |
2347 | } | 2346 | } |
2348 | void CalendarView::addCalendarId( int id ) | 2347 | void CalendarView::addCalendarId( int id ) |
2349 | { | 2348 | { |
2350 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2349 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2351 | if ( cal ) | 2350 | if ( cal ) |
2352 | addCalendar( cal ); | 2351 | addCalendar( cal ); |
2353 | } | 2352 | } |
2354 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2353 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2355 | { | 2354 | { |
2356 | cal->mErrorOnLoad = false; | 2355 | cal->mErrorOnLoad = false; |
2357 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2356 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2358 | cal->mLoadDt = QDateTime::currentDateTime(); | 2357 | cal->mLoadDt = QDateTime::currentDateTime(); |
2359 | return true; | 2358 | return true; |
2360 | } | 2359 | } |
2361 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2360 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2362 | cal->mErrorOnLoad = true; | 2361 | cal->mErrorOnLoad = true; |
2363 | return false; | 2362 | return false; |
2364 | } | 2363 | } |
2365 | bool CalendarView::openCalendar(QString filename, bool merge) | 2364 | bool CalendarView::openCalendar(QString filename, bool merge) |
2366 | { | 2365 | { |
2367 | 2366 | ||
2368 | if (filename.isEmpty()) { | 2367 | if (filename.isEmpty()) { |
2369 | return false; | 2368 | return false; |
2370 | } | 2369 | } |
2371 | 2370 | ||
2372 | if (!QFile::exists(filename)) { | 2371 | if (!QFile::exists(filename)) { |
2373 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2372 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2374 | return false; | 2373 | return false; |
2375 | } | 2374 | } |
2376 | 2375 | ||
2377 | globalFlagBlockAgenda = 1; | 2376 | globalFlagBlockAgenda = 1; |
2378 | clearAllViews(); | 2377 | clearAllViews(); |
2379 | if (!merge) { | 2378 | if (!merge) { |
2380 | mViewManager->setDocumentId( filename ); | 2379 | mViewManager->setDocumentId( filename ); |
2381 | mCalendar->close(); | 2380 | mCalendar->close(); |
2382 | } | 2381 | } |
2383 | mStorage->setFileName( filename ); | 2382 | mStorage->setFileName( filename ); |
2384 | 2383 | ||
2385 | if ( mStorage->load() ) { | 2384 | if ( mStorage->load() ) { |
2386 | if ( merge ) ;//setModified( true ); | 2385 | if ( merge ) ;//setModified( true ); |
2387 | else { | 2386 | else { |
2388 | //setModified( true ); | 2387 | //setModified( true ); |
2389 | mViewManager->setDocumentId( filename ); | 2388 | mViewManager->setDocumentId( filename ); |
2390 | mDialogManager->setDocumentId( filename ); | 2389 | mDialogManager->setDocumentId( filename ); |
2391 | mTodoList->setDocumentId( filename ); | 2390 | mTodoList->setDocumentId( filename ); |
2392 | } | 2391 | } |
2393 | globalFlagBlockAgenda = 2; | 2392 | globalFlagBlockAgenda = 2; |
2394 | // if ( getLastSyncEvent() ) | 2393 | // if ( getLastSyncEvent() ) |
2395 | // getLastSyncEvent()->setReadOnly( true ); | 2394 | // getLastSyncEvent()->setReadOnly( true ); |
2396 | mCalendar->reInitAlarmSettings(); | 2395 | mCalendar->reInitAlarmSettings(); |
2397 | setSyncEventsReadOnly(); | 2396 | setSyncEventsReadOnly(); |
2398 | //updateUnmanagedViews(); | 2397 | //updateUnmanagedViews(); |
2399 | //updateView(); | 2398 | //updateView(); |
2400 | if ( filename != MainWindow::defaultFileName() ) { | 2399 | if ( filename != MainWindow::defaultFileName() ) { |
2401 | saveCalendar( MainWindow::defaultFileName() ); | 2400 | saveCalendar( MainWindow::defaultFileName() ); |
2402 | } else { | 2401 | } else { |
2403 | QFileInfo finf ( MainWindow::defaultFileName()); | 2402 | QFileInfo finf ( MainWindow::defaultFileName()); |
2404 | if ( finf.exists() ) { | 2403 | if ( finf.exists() ) { |
2405 | setLoadedFileVersion( finf.lastModified () ); | 2404 | setLoadedFileVersion( finf.lastModified () ); |
2406 | } | 2405 | } |
2407 | } | 2406 | } |
2408 | return true; | 2407 | return true; |
2409 | } else { | 2408 | } else { |
2410 | // while failing to load, the calendar object could | 2409 | // while failing to load, the calendar object could |
2411 | // have become partially populated. Clear it out. | 2410 | // have become partially populated. Clear it out. |
2412 | if ( !merge ) { | 2411 | if ( !merge ) { |
2413 | mCalendar->close(); | 2412 | mCalendar->close(); |
2414 | mViewManager->setDocumentId( filename ); | 2413 | mViewManager->setDocumentId( filename ); |
2415 | mDialogManager->setDocumentId( filename ); | 2414 | mDialogManager->setDocumentId( filename ); |
2416 | mTodoList->setDocumentId( filename ); | 2415 | mTodoList->setDocumentId( filename ); |
2417 | } | 2416 | } |
2418 | 2417 | ||
2419 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2418 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2420 | 2419 | ||
2421 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2420 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2422 | globalFlagBlockAgenda = 2; | 2421 | globalFlagBlockAgenda = 2; |
2423 | mCalendar->reInitAlarmSettings(); | 2422 | mCalendar->reInitAlarmSettings(); |
2424 | setSyncEventsReadOnly(); | 2423 | setSyncEventsReadOnly(); |
2425 | updateUnmanagedViews(); | 2424 | updateUnmanagedViews(); |
2426 | updateView(); | 2425 | updateView(); |
2427 | } | 2426 | } |
2428 | return false; | 2427 | return false; |
2429 | } | 2428 | } |
2430 | void CalendarView::mergeFile( QString fn ) | 2429 | void CalendarView::mergeFile( QString fn ) |
2431 | { | 2430 | { |
2432 | clearAllViews(); | 2431 | clearAllViews(); |
2433 | mCalendar->mergeCalendarFile( fn ); | 2432 | mCalendar->mergeCalendarFile( fn ); |
2434 | mCalendar->reInitAlarmSettings(); | 2433 | mCalendar->reInitAlarmSettings(); |
2435 | setSyncEventsReadOnly(); | 2434 | setSyncEventsReadOnly(); |
2436 | updateUnmanagedViews(); | 2435 | updateUnmanagedViews(); |
2437 | updateView(); | 2436 | updateView(); |
2438 | } | 2437 | } |
2439 | void CalendarView::showOpenError() | 2438 | void CalendarView::showOpenError() |
2440 | { | 2439 | { |
2441 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2440 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2442 | } | 2441 | } |
2443 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2442 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2444 | { | 2443 | { |
2445 | loadedFileVersion = dt; | 2444 | loadedFileVersion = dt; |
2446 | } | 2445 | } |
2447 | bool CalendarView::checkFileChanged(QString fn) | 2446 | bool CalendarView::checkFileChanged(QString fn) |
2448 | { | 2447 | { |
2449 | QFileInfo finf ( fn ); | 2448 | QFileInfo finf ( fn ); |
2450 | if ( !finf.exists() ) | 2449 | if ( !finf.exists() ) |
2451 | return true; | 2450 | return true; |
2452 | QDateTime dt = finf.lastModified (); | 2451 | QDateTime dt = finf.lastModified (); |
2453 | if ( dt <= loadedFileVersion ) | 2452 | if ( dt <= loadedFileVersion ) |
2454 | return false; | 2453 | return false; |
2455 | return true; | 2454 | return true; |
2456 | 2455 | ||
2457 | } | 2456 | } |
2458 | void CalendarView::watchSavedFile() | 2457 | void CalendarView::watchSavedFile() |
2459 | { | 2458 | { |
2460 | QFileInfo finf ( MainWindow::defaultFileName()); | 2459 | QFileInfo finf ( MainWindow::defaultFileName()); |
2461 | if ( !finf.exists() ) | 2460 | if ( !finf.exists() ) |
2462 | return; | 2461 | return; |
2463 | QDateTime dt = finf.lastModified (); | 2462 | QDateTime dt = finf.lastModified (); |
2464 | if ( dt < loadedFileVersion ) { | 2463 | if ( dt < loadedFileVersion ) { |
2465 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2464 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2466 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2465 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2467 | return; | 2466 | return; |
2468 | } | 2467 | } |
2469 | loadedFileVersion = dt; | 2468 | loadedFileVersion = dt; |
2470 | } | 2469 | } |
2471 | bool CalendarView::checkAllFileVersions() | 2470 | bool CalendarView::checkAllFileVersions() |
2472 | { | 2471 | { |
2473 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2472 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2474 | KopiCalendarFile * cal = calendars.first(); | 2473 | KopiCalendarFile * cal = calendars.first(); |
2475 | mCalendar->setDefaultCalendar( 1 ); | 2474 | mCalendar->setDefaultCalendar( 1 ); |
2476 | mCalendar->setDefaultCalendarEnabledOnly(); | 2475 | mCalendar->setDefaultCalendarEnabledOnly(); |
2477 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2476 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2478 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2477 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2479 | restoreCalendarSettings(); | 2478 | restoreCalendarSettings(); |
2480 | return false; | 2479 | return false; |
2481 | } | 2480 | } |
2482 | } | 2481 | } |
2483 | cal = calendars.next(); | 2482 | cal = calendars.next(); |
2484 | QDateTime storeTemp = loadedFileVersion; | 2483 | QDateTime storeTemp = loadedFileVersion; |
2485 | while ( cal ) { | 2484 | while ( cal ) { |
2486 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2485 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2487 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2486 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2488 | mCalendar->setDefaultCalendarEnabledOnly(); | 2487 | mCalendar->setDefaultCalendarEnabledOnly(); |
2489 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2488 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2490 | if ( !checkFileVersion(cal->mFileName )) { | 2489 | if ( !checkFileVersion(cal->mFileName )) { |
2491 | loadedFileVersion = storeTemp; | 2490 | loadedFileVersion = storeTemp; |
2492 | restoreCalendarSettings(); | 2491 | restoreCalendarSettings(); |
2493 | return false; | 2492 | return false; |
2494 | } | 2493 | } |
2495 | } | 2494 | } |
2496 | cal = calendars.next(); | 2495 | cal = calendars.next(); |
2497 | } | 2496 | } |
2498 | loadedFileVersion = storeTemp; | 2497 | loadedFileVersion = storeTemp; |
2499 | return true; | 2498 | return true; |
2500 | } | 2499 | } |
2501 | bool CalendarView::checkFileVersion(QString fn) | 2500 | bool CalendarView::checkFileVersion(QString fn) |
2502 | { | 2501 | { |
2503 | QFileInfo finf ( fn ); | 2502 | QFileInfo finf ( fn ); |
2504 | if ( !finf.exists() ) | 2503 | if ( !finf.exists() ) |
2505 | return true; | 2504 | return true; |
2506 | QDateTime dt = finf.lastModified (); | 2505 | QDateTime dt = finf.lastModified (); |
2507 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2506 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2508 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2507 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2509 | if ( dt <= loadedFileVersion ) | 2508 | if ( dt <= loadedFileVersion ) |
2510 | return true; | 2509 | return true; |
2511 | 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)) , | 2510 | 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)) , |
2512 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2511 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2513 | i18n("Sync+save")); | 2512 | i18n("Sync+save")); |
2514 | 2513 | ||
2515 | if ( km == KMessageBox::Cancel ) | 2514 | if ( km == KMessageBox::Cancel ) |
2516 | return false; | 2515 | return false; |
2517 | if ( km == KMessageBox::Yes ) | 2516 | if ( km == KMessageBox::Yes ) |
2518 | return true; | 2517 | return true; |
2519 | 2518 | ||
2520 | setSyncDevice("deleteaftersync" ); | 2519 | setSyncDevice("deleteaftersync" ); |
2521 | mSyncManager->mAskForPreferences = true; | 2520 | mSyncManager->mAskForPreferences = true; |
2522 | mSyncManager->mSyncAlgoPrefs = 3; | 2521 | mSyncManager->mSyncAlgoPrefs = 3; |
2523 | mSyncManager->mWriteBackFile = false; | 2522 | mSyncManager->mWriteBackFile = false; |
2524 | mSyncManager->mWriteBackExistingOnly = false; | 2523 | mSyncManager->mWriteBackExistingOnly = false; |
2525 | mSyncManager->mShowSyncSummary = false; | 2524 | mSyncManager->mShowSyncSummary = false; |
2526 | syncCalendar( fn, 3 ); | 2525 | syncCalendar( fn, 3 ); |
2527 | Event * e = getLastSyncEvent(); | 2526 | Event * e = getLastSyncEvent(); |
2528 | if ( e ) | 2527 | if ( e ) |
2529 | mCalendar->deleteEvent( e ); | 2528 | mCalendar->deleteEvent( e ); |
2530 | return true; | 2529 | return true; |
2531 | } | 2530 | } |
2532 | bool CalendarView::saveCalendars() | 2531 | bool CalendarView::saveCalendars() |
2533 | { | 2532 | { |
2534 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2533 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2535 | KopiCalendarFile * cal = calendars.first(); | 2534 | KopiCalendarFile * cal = calendars.first(); |
2536 | mCalendar->setDefaultCalendar( 1 ); | 2535 | mCalendar->setDefaultCalendar( 1 ); |
2537 | mCalendar->setDefaultCalendarEnabledOnly(); | 2536 | mCalendar->setDefaultCalendarEnabledOnly(); |
2538 | QString saveError; | 2537 | QString saveError; |
2539 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) | 2538 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) |
2540 | saveError = cal->mName +"\n"; | 2539 | saveError = cal->mName +"\n"; |
2541 | cal = calendars.next(); | 2540 | cal = calendars.next(); |
2542 | while ( cal ) { | 2541 | while ( cal ) { |
2543 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2542 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2544 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2543 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2545 | mCalendar->setDefaultCalendarEnabledOnly(); | 2544 | mCalendar->setDefaultCalendarEnabledOnly(); |
2546 | if ( saveCalendar( cal->mFileName ) ) | 2545 | if ( saveCalendar( cal->mFileName ) ) |
2547 | cal->mLoadDt = QDateTime::currentDateTime(); | 2546 | cal->mLoadDt = QDateTime::currentDateTime(); |
2548 | else | 2547 | else |
2549 | saveError += cal->mName + "\n"; | 2548 | saveError += cal->mName + "\n"; |
2550 | } | 2549 | } |
2551 | cal = calendars.next(); | 2550 | cal = calendars.next(); |
2552 | } | 2551 | } |
2553 | restoreCalendarSettings(); | 2552 | restoreCalendarSettings(); |
2554 | //saveError = "test error"; | 2553 | //saveError = "test error"; |
2555 | if ( !saveError.isEmpty() ) { | 2554 | if ( !saveError.isEmpty() ) { |
2556 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; | 2555 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; |
2557 | KMessageBox::error(this, saveError, i18n("Error saving data")); | 2556 | KMessageBox::error(this, saveError, i18n("Error saving data")); |
2558 | return false; | 2557 | return false; |
2559 | } | 2558 | } |
2560 | return true; | 2559 | return true; |
2561 | } | 2560 | } |
2562 | bool CalendarView::saveCalendar( QString filename ) | 2561 | bool CalendarView::saveCalendar( QString filename ) |
2563 | { | 2562 | { |
2564 | 2563 | ||
2565 | // Store back all unsaved data into calendar object | 2564 | // Store back all unsaved data into calendar object |
2566 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2565 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2567 | if ( mViewManager->currentView() ) | 2566 | if ( mViewManager->currentView() ) |
2568 | mViewManager->currentView()->flushView(); | 2567 | mViewManager->currentView()->flushView(); |
2569 | 2568 | ||
2570 | 2569 | ||
2571 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2570 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2572 | mStorage->setSaveFormat( new ICalFormat() ); | 2571 | mStorage->setSaveFormat( new ICalFormat() ); |
2573 | mStorage->setFileName( filename ); | 2572 | mStorage->setFileName( filename ); |
2574 | bool success; | 2573 | bool success; |
2575 | success = mStorage->save(); | 2574 | success = mStorage->save(); |
2576 | if ( !success ) { | 2575 | if ( !success ) { |
2577 | return false; | 2576 | return false; |
2578 | } | 2577 | } |
2579 | if ( filename == MainWindow::defaultFileName() ) { | 2578 | if ( filename == MainWindow::defaultFileName() ) { |
2580 | setLoadedFileVersion( lfv ); | 2579 | setLoadedFileVersion( lfv ); |
2581 | watchSavedFile(); | 2580 | watchSavedFile(); |
2582 | } | 2581 | } |
2583 | return true; | 2582 | return true; |
2584 | } | 2583 | } |
2585 | 2584 | ||
2586 | void CalendarView::closeCalendar() | 2585 | void CalendarView::closeCalendar() |
2587 | { | 2586 | { |
2588 | 2587 | ||
2589 | // child windows no longer valid | 2588 | // child windows no longer valid |
2590 | clearAllViews(); | 2589 | clearAllViews(); |
2591 | emit closingDown(); | 2590 | emit closingDown(); |
2592 | 2591 | ||
2593 | mCalendar->close(); | 2592 | mCalendar->close(); |
2594 | setModified(false); | 2593 | setModified(false); |
2595 | updateView(); | 2594 | updateView(); |
2596 | } | 2595 | } |
2597 | 2596 | ||
2598 | void CalendarView::archiveCalendar() | 2597 | void CalendarView::archiveCalendar() |
2599 | { | 2598 | { |
2600 | mDialogManager->showArchiveDialog(); | 2599 | mDialogManager->showArchiveDialog(); |
2601 | } | 2600 | } |
2602 | 2601 | ||
2603 | 2602 | ||
2604 | void CalendarView::readSettings() | 2603 | void CalendarView::readSettings() |
2605 | { | 2604 | { |
2606 | 2605 | ||
2607 | 2606 | ||
2608 | // mViewManager->showAgendaView(); | 2607 | // mViewManager->showAgendaView(); |
2609 | QString str; | 2608 | QString str; |
2610 | //qDebug("CalendarView::readSettings() "); | 2609 | //qDebug("CalendarView::readSettings() "); |
2611 | // read settings from the KConfig, supplying reasonable | 2610 | // read settings from the KConfig, supplying reasonable |
2612 | // defaults where none are to be found | 2611 | // defaults where none are to be found |
2613 | KConfig *config = KOGlobals::config(); | 2612 | KConfig *config = KOGlobals::config(); |
2614 | #ifndef KORG_NOSPLITTER | 2613 | #ifndef KORG_NOSPLITTER |
2615 | config->setGroup("KOrganizer Geometry"); | 2614 | config->setGroup("KOrganizer Geometry"); |
2616 | 2615 | ||
2617 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2616 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2618 | if (sizes.count() != 2) { | 2617 | if (sizes.count() != 2) { |
2619 | sizes << mDateNavigator->minimumSizeHint().width(); | 2618 | sizes << mDateNavigator->minimumSizeHint().width(); |
2620 | sizes << 300; | 2619 | sizes << 300; |
2621 | } | 2620 | } |
2622 | mPanner->setSizes(sizes); | 2621 | mPanner->setSizes(sizes); |
2623 | 2622 | ||
2624 | sizes = config->readIntListEntry("Separator2"); | 2623 | sizes = config->readIntListEntry("Separator2"); |
2625 | if ( ( mResourceView && sizes.count() == 4 ) || | 2624 | if ( ( mResourceView && sizes.count() == 4 ) || |
2626 | ( !mResourceView && sizes.count() == 3 ) ) { | 2625 | ( !mResourceView && sizes.count() == 3 ) ) { |
2627 | mLeftSplitter->setSizes(sizes); | 2626 | mLeftSplitter->setSizes(sizes); |
2628 | } | 2627 | } |
2629 | #endif | 2628 | #endif |
2630 | globalFlagBlockAgenda = 1; | 2629 | globalFlagBlockAgenda = 1; |
2631 | mViewManager->showAgendaView(); | 2630 | mViewManager->showAgendaView(); |
2632 | //mViewManager->readSettings( config ); | 2631 | //mViewManager->readSettings( config ); |
2633 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2632 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2634 | readFilterSettings(config); | 2633 | readFilterSettings(config); |
2635 | 2634 | ||
2636 | #ifdef DESKTOP_VERSION | 2635 | #ifdef DESKTOP_VERSION |
2637 | config->setGroup("WidgetLayout"); | 2636 | config->setGroup("WidgetLayout"); |
2638 | QStringList list; | 2637 | QStringList list; |
2639 | list = config->readListEntry("MainLayout"); | 2638 | list = config->readListEntry("MainLayout"); |
2640 | int x,y,w,h; | 2639 | int x,y,w,h; |
2641 | if ( ! list.isEmpty() ) { | 2640 | if ( ! list.isEmpty() ) { |
2642 | x = list[0].toInt(); | 2641 | x = list[0].toInt(); |
2643 | y = list[1].toInt(); | 2642 | y = list[1].toInt(); |
2644 | w = list[2].toInt(); | 2643 | w = list[2].toInt(); |
2645 | h = list[3].toInt(); | 2644 | h = list[3].toInt(); |
2646 | KApplication::testCoords( &x,&y,&w,&h ); | 2645 | KApplication::testCoords( &x,&y,&w,&h ); |
2647 | topLevelWidget()->setGeometry(x,y,w,h); | 2646 | topLevelWidget()->setGeometry(x,y,w,h); |
2648 | 2647 | ||
2649 | } else { | 2648 | } else { |
2650 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2649 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2651 | } | 2650 | } |
2652 | list = config->readListEntry("EditEventLayout"); | 2651 | list = config->readListEntry("EditEventLayout"); |
2653 | if ( ! list.isEmpty() ) { | 2652 | if ( ! list.isEmpty() ) { |
2654 | x = list[0].toInt(); | 2653 | x = list[0].toInt(); |
2655 | y = list[1].toInt(); | 2654 | y = list[1].toInt(); |
2656 | w = list[2].toInt(); | 2655 | w = list[2].toInt(); |
2657 | h = list[3].toInt(); | 2656 | h = list[3].toInt(); |
2658 | KApplication::testCoords( &x,&y,&w,&h ); | 2657 | KApplication::testCoords( &x,&y,&w,&h ); |
2659 | mEventEditor->setGeometry(x,y,w,h); | 2658 | mEventEditor->setGeometry(x,y,w,h); |
2660 | 2659 | ||
2661 | } | 2660 | } |
2662 | list = config->readListEntry("EditTodoLayout"); | 2661 | list = config->readListEntry("EditTodoLayout"); |
2663 | if ( ! list.isEmpty() ) { | 2662 | if ( ! list.isEmpty() ) { |
2664 | x = list[0].toInt(); | 2663 | x = list[0].toInt(); |
2665 | y = list[1].toInt(); | 2664 | y = list[1].toInt(); |
2666 | w = list[2].toInt(); | 2665 | w = list[2].toInt(); |
2667 | h = list[3].toInt(); | 2666 | h = list[3].toInt(); |
2668 | KApplication::testCoords( &x,&y,&w,&h ); | 2667 | KApplication::testCoords( &x,&y,&w,&h ); |
2669 | mTodoEditor->setGeometry(x,y,w,h); | 2668 | mTodoEditor->setGeometry(x,y,w,h); |
2670 | 2669 | ||
2671 | } | 2670 | } |
2672 | list = config->readListEntry("ViewerLayout"); | 2671 | list = config->readListEntry("ViewerLayout"); |
2673 | if ( ! list.isEmpty() ) { | 2672 | if ( ! list.isEmpty() ) { |
2674 | x = list[0].toInt(); | 2673 | x = list[0].toInt(); |
2675 | y = list[1].toInt(); | 2674 | y = list[1].toInt(); |
2676 | w = list[2].toInt(); | 2675 | w = list[2].toInt(); |
2677 | h = list[3].toInt(); | 2676 | h = list[3].toInt(); |
2678 | KApplication::testCoords( &x,&y,&w,&h ); | 2677 | KApplication::testCoords( &x,&y,&w,&h ); |
2679 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2678 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2680 | } | 2679 | } |
2681 | #endif | 2680 | #endif |
2682 | config->setGroup( "Views" ); | 2681 | config->setGroup( "Views" ); |
2683 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2682 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2684 | 2683 | ||
2685 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2684 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2686 | 2685 | ||
2687 | int resetval = 0; | 2686 | int resetval = 0; |
2688 | int maxVal = 0; | 2687 | int maxVal = 0; |
2689 | if (sizes.count() != 3) { | 2688 | if (sizes.count() != 3) { |
2690 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2689 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2691 | resetval = mDateNavigator->sizeHint().width()+2; | 2690 | resetval = mDateNavigator->sizeHint().width()+2; |
2692 | } else { | 2691 | } else { |
2693 | resetval = mDateNavigator->sizeHint().height()+2; | 2692 | resetval = mDateNavigator->sizeHint().height()+2; |
2694 | } | 2693 | } |
2695 | } | 2694 | } |
2696 | if ( resetval ) { | 2695 | if ( resetval ) { |
2697 | sizes.clear(); | 2696 | sizes.clear(); |
2698 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2697 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2699 | maxVal = QApplication::desktop()->width() -10; | 2698 | maxVal = QApplication::desktop()->width() -10; |
2700 | } else { | 2699 | } else { |
2701 | maxVal = QApplication::desktop()->height()-10; | 2700 | maxVal = QApplication::desktop()->height()-10; |
2702 | } | 2701 | } |
2703 | sizes << resetval; | 2702 | sizes << resetval; |
2704 | if ( maxVal < resetval + resetval) | 2703 | if ( maxVal < resetval + resetval) |
2705 | resetval = maxVal - resetval; | 2704 | resetval = maxVal - resetval; |
2706 | sizes << resetval; | 2705 | sizes << resetval; |
2707 | sizes << 100; | 2706 | sizes << 100; |
2708 | } | 2707 | } |
2709 | mLeftFrame->setSizes(sizes); | 2708 | mLeftFrame->setSizes(sizes); |
2710 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2709 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2711 | resetval = 0; | 2710 | resetval = 0; |
2712 | maxVal = 0; | 2711 | maxVal = 0; |
2713 | if (sizes.count() != 2) { | 2712 | if (sizes.count() != 2) { |
2714 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2713 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2715 | resetval = mDateNavigator->sizeHint().width()+2; | 2714 | resetval = mDateNavigator->sizeHint().width()+2; |
2716 | } else { | 2715 | } else { |
2717 | resetval = mDateNavigator->sizeHint().height()+2; | 2716 | resetval = mDateNavigator->sizeHint().height()+2; |
2718 | } | 2717 | } |
2719 | } | 2718 | } |
2720 | if ( resetval ) { | 2719 | if ( resetval ) { |
2721 | sizes.clear(); | 2720 | sizes.clear(); |
2722 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2721 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2723 | maxVal = QApplication::desktop()->width() -10; | 2722 | maxVal = QApplication::desktop()->width() -10; |
2724 | } else { | 2723 | } else { |
2725 | maxVal = QApplication::desktop()->height()-10; | 2724 | maxVal = QApplication::desktop()->height()-10; |
2726 | } | 2725 | } |
2727 | sizes << resetval; | 2726 | sizes << resetval; |
2728 | if ( maxVal < resetval + resetval) | 2727 | if ( maxVal < resetval + resetval) |
2729 | resetval = maxVal - resetval; | 2728 | resetval = maxVal - resetval; |
2730 | sizes << resetval; | 2729 | sizes << resetval; |
2731 | } | 2730 | } |
2732 | mMainFrame->setSizes(sizes); | 2731 | mMainFrame->setSizes(sizes); |
2733 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2732 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2734 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2733 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2735 | else mNavigator->selectDates( dateCount ); | 2734 | else mNavigator->selectDates( dateCount ); |
2736 | // mViewManager->readSettings( config ); | 2735 | // mViewManager->readSettings( config ); |
2737 | updateConfig(); | 2736 | updateConfig(); |
2738 | globalFlagBlockAgenda = 2; | 2737 | globalFlagBlockAgenda = 2; |
2739 | mViewManager->readSettings( config ); | 2738 | mViewManager->readSettings( config ); |
2740 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2739 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2741 | } | 2740 | } |
2742 | 2741 | ||
2743 | void CalendarView::checkSuspendAlarm() | 2742 | void CalendarView::checkSuspendAlarm() |
2744 | { | 2743 | { |
2745 | if ( mSuspendTimer->isActive() ) { | 2744 | if ( mSuspendTimer->isActive() ) { |
2746 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2745 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2747 | } | 2746 | } |
2748 | } | 2747 | } |
2749 | void CalendarView::writeSettings() | 2748 | void CalendarView::writeSettings() |
2750 | { | 2749 | { |
2751 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2750 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2752 | 2751 | ||
2753 | KConfig *config = KOGlobals::config(); | 2752 | KConfig *config = KOGlobals::config(); |
2754 | 2753 | ||
2755 | mViewManager->writeSettings( config ); | 2754 | mViewManager->writeSettings( config ); |
2756 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2755 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2757 | mDialogManager->writeSettings( config ); | 2756 | mDialogManager->writeSettings( config ); |
2758 | //KOPrefs::instance()->usrWriteConfig(); | 2757 | //KOPrefs::instance()->usrWriteConfig(); |
2759 | KOPrefs::instance()->writeConfig(); | 2758 | KOPrefs::instance()->writeConfig(); |
2760 | 2759 | ||
2761 | writeFilterSettings(config); | 2760 | writeFilterSettings(config); |
2762 | config->setGroup( "AppRun" ); | 2761 | config->setGroup( "AppRun" ); |
2763 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2762 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2764 | int days = dt.daysTo( QDate::currentDate() ); | 2763 | int days = dt.daysTo( QDate::currentDate() ); |
2765 | dt = dt.addDays( days ); | 2764 | dt = dt.addDays( days ); |
2766 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2765 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2767 | config->writeEntry( "LatestProgramStopDays", days ); | 2766 | config->writeEntry( "LatestProgramStopDays", days ); |
2768 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2767 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2769 | //qDebug("KO: Writing stop time: %d ", secs); | 2768 | //qDebug("KO: Writing stop time: %d ", secs); |
2770 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2769 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2771 | //QDateTime latest = dt.addSecs ( secs ); | 2770 | //QDateTime latest = dt.addSecs ( secs ); |
2772 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2771 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2773 | config->setGroup( "Views" ); | 2772 | config->setGroup( "Views" ); |
2774 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2773 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2775 | 2774 | ||
2776 | #if 0 | 2775 | #if 0 |
2777 | qDebug("********************* "); | 2776 | qDebug("********************* "); |
2778 | qDebug("Testcode secsto "); | 2777 | qDebug("Testcode secsto "); |
2779 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2778 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2780 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2779 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2781 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2780 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2782 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2781 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2783 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2782 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2784 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2783 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2785 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2784 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2786 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2785 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2787 | qDebug("********************* testcode end"); | 2786 | qDebug("********************* testcode end"); |
2788 | 2787 | ||
2789 | #endif | 2788 | #endif |
2790 | 2789 | ||
2791 | QValueList<int> listINT = mLeftFrame->sizes(); | 2790 | QValueList<int> listINT = mLeftFrame->sizes(); |
2792 | config->writeEntry("Left Splitter Frame",listINT); | 2791 | config->writeEntry("Left Splitter Frame",listINT); |
2793 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2792 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2794 | config->writeEntry("Main Splitter Frame",listINT2); | 2793 | config->writeEntry("Main Splitter Frame",listINT2); |
2795 | #ifdef DESKTOP_VERSION | 2794 | #ifdef DESKTOP_VERSION |
2796 | config->setGroup("WidgetLayout"); | 2795 | config->setGroup("WidgetLayout"); |
2797 | QStringList list ;//= config->readListEntry("MainLayout"); | 2796 | QStringList list ;//= config->readListEntry("MainLayout"); |
2798 | int x,y,w,h; | 2797 | int x,y,w,h; |
2799 | QWidget* wid; | 2798 | QWidget* wid; |
2800 | wid = topLevelWidget(); | 2799 | wid = topLevelWidget(); |
2801 | x = wid->geometry().x(); | 2800 | x = wid->geometry().x(); |
2802 | y = wid->geometry().y(); | 2801 | y = wid->geometry().y(); |
2803 | w = wid->width(); | 2802 | w = wid->width(); |
2804 | h = wid->height(); | 2803 | h = wid->height(); |
2805 | list.clear(); | 2804 | list.clear(); |
2806 | list << QString::number( x ); | 2805 | list << QString::number( x ); |
2807 | list << QString::number( y ); | 2806 | list << QString::number( y ); |
2808 | list << QString::number( w ); | 2807 | list << QString::number( w ); |
2809 | list << QString::number( h ); | 2808 | list << QString::number( h ); |
2810 | config->writeEntry("MainLayout",list ); | 2809 | config->writeEntry("MainLayout",list ); |
2811 | 2810 | ||
2812 | wid = mEventEditor; | 2811 | wid = mEventEditor; |
2813 | x = wid->geometry().x(); | 2812 | x = wid->geometry().x(); |
2814 | y = wid->geometry().y(); | 2813 | y = wid->geometry().y(); |
2815 | w = wid->width(); | 2814 | w = wid->width(); |
2816 | h = wid->height(); | 2815 | h = wid->height(); |
2817 | list.clear(); | 2816 | list.clear(); |
2818 | list << QString::number( x ); | 2817 | list << QString::number( x ); |
2819 | list << QString::number( y ); | 2818 | list << QString::number( y ); |
2820 | list << QString::number( w ); | 2819 | list << QString::number( w ); |
2821 | list << QString::number( h ); | 2820 | list << QString::number( h ); |
2822 | config->writeEntry("EditEventLayout",list ); | 2821 | config->writeEntry("EditEventLayout",list ); |
2823 | 2822 | ||
2824 | wid = mTodoEditor; | 2823 | wid = mTodoEditor; |
2825 | x = wid->geometry().x(); | 2824 | x = wid->geometry().x(); |
2826 | y = wid->geometry().y(); | 2825 | y = wid->geometry().y(); |
2827 | w = wid->width(); | 2826 | w = wid->width(); |
2828 | h = wid->height(); | 2827 | h = wid->height(); |
2829 | list.clear(); | 2828 | list.clear(); |
2830 | list << QString::number( x ); | 2829 | list << QString::number( x ); |
2831 | list << QString::number( y ); | 2830 | list << QString::number( y ); |
2832 | list << QString::number( w ); | 2831 | list << QString::number( w ); |
2833 | list << QString::number( h ); | 2832 | list << QString::number( h ); |
2834 | config->writeEntry("EditTodoLayout",list ); | 2833 | config->writeEntry("EditTodoLayout",list ); |
2835 | wid = getEventViewerDialog(); | 2834 | wid = getEventViewerDialog(); |
2836 | x = wid->geometry().x(); | 2835 | x = wid->geometry().x(); |
2837 | y = wid->geometry().y(); | 2836 | y = wid->geometry().y(); |
2838 | w = wid->width(); | 2837 | w = wid->width(); |
2839 | h = wid->height(); | 2838 | h = wid->height(); |
2840 | list.clear(); | 2839 | list.clear(); |
2841 | list << QString::number( x ); | 2840 | list << QString::number( x ); |
2842 | list << QString::number( y ); | 2841 | list << QString::number( y ); |
2843 | list << QString::number( w ); | 2842 | list << QString::number( w ); |
2844 | list << QString::number( h ); | 2843 | list << QString::number( h ); |
2845 | config->writeEntry("ViewerLayout",list ); | 2844 | config->writeEntry("ViewerLayout",list ); |
2846 | wid = mDialogManager->getSearchDialog(); | 2845 | wid = mDialogManager->getSearchDialog(); |
2847 | if ( wid ) { | 2846 | if ( wid ) { |
2848 | x = wid->geometry().x(); | 2847 | x = wid->geometry().x(); |
2849 | y = wid->geometry().y(); | 2848 | y = wid->geometry().y(); |
2850 | w = wid->width(); | 2849 | w = wid->width(); |
2851 | h = wid->height(); | 2850 | h = wid->height(); |
2852 | list.clear(); | 2851 | list.clear(); |
2853 | list << QString::number( x ); | 2852 | list << QString::number( x ); |
2854 | list << QString::number( y ); | 2853 | list << QString::number( y ); |
2855 | list << QString::number( w ); | 2854 | list << QString::number( w ); |
2856 | list << QString::number( h ); | 2855 | list << QString::number( h ); |
2857 | config->writeEntry("SearchLayout",list ); | 2856 | config->writeEntry("SearchLayout",list ); |
2858 | } | 2857 | } |
2859 | #endif | 2858 | #endif |
2860 | 2859 | ||
2861 | 2860 | ||
2862 | config->sync(); | 2861 | config->sync(); |
2863 | } | 2862 | } |
2864 | 2863 | ||
2865 | void CalendarView::readFilterSettings(KConfig *config) | 2864 | void CalendarView::readFilterSettings(KConfig *config) |
2866 | { | 2865 | { |
2867 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2866 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2868 | 2867 | ||
2869 | mFilters.clear(); | 2868 | mFilters.clear(); |
2870 | 2869 | ||
2871 | config->setGroup("General"); | 2870 | config->setGroup("General"); |
2872 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2871 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2873 | 2872 | ||
2874 | QStringList::ConstIterator it = filterList.begin(); | 2873 | QStringList::ConstIterator it = filterList.begin(); |
2875 | QStringList::ConstIterator end = filterList.end(); | 2874 | QStringList::ConstIterator end = filterList.end(); |
2876 | while(it != end) { | 2875 | while(it != end) { |
2877 | // kdDebug() << " filter: " << (*it) << endl; | 2876 | // kdDebug() << " filter: " << (*it) << endl; |
2878 | 2877 | ||
2879 | CalFilter *filter; | 2878 | CalFilter *filter; |
2880 | filter = new CalFilter(*it); | 2879 | filter = new CalFilter(*it); |
2881 | config->setGroup("Filter_" + (*it).utf8()); | 2880 | config->setGroup("Filter_" + (*it).utf8()); |
2882 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2881 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2883 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2882 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2884 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2883 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2885 | mFilters.append(filter); | 2884 | mFilters.append(filter); |
2886 | 2885 | ||
2887 | ++it; | 2886 | ++it; |
2888 | } | 2887 | } |
2889 | 2888 | ||
2890 | if (mFilters.count() == 0) { | 2889 | if (mFilters.count() == 0) { |
2891 | CalFilter *filter = new CalFilter(i18n("Default")); | 2890 | CalFilter *filter = new CalFilter(i18n("Default")); |
2892 | mFilters.append(filter); | 2891 | mFilters.append(filter); |
2893 | } | 2892 | } |
2894 | mFilterView->updateFilters(); | 2893 | mFilterView->updateFilters(); |
2895 | config->setGroup("FilterView"); | 2894 | config->setGroup("FilterView"); |
2896 | 2895 | ||
2897 | mFilterView->blockSignals(true); | 2896 | mFilterView->blockSignals(true); |
2898 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2897 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2899 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2898 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2900 | mFilterView->blockSignals(false); | 2899 | mFilterView->blockSignals(false); |
2901 | // We do it manually to avoid it being done twice by the above calls | 2900 | // We do it manually to avoid it being done twice by the above calls |
2902 | updateFilter(); | 2901 | updateFilter(); |
2903 | } | 2902 | } |
2904 | 2903 | ||
2905 | void CalendarView::writeFilterSettings(KConfig *config) | 2904 | void CalendarView::writeFilterSettings(KConfig *config) |
2906 | { | 2905 | { |
2907 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2906 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2908 | 2907 | ||
2909 | QStringList filterList; | 2908 | QStringList filterList; |
2910 | 2909 | ||
2911 | CalFilter *filter = mFilters.first(); | 2910 | CalFilter *filter = mFilters.first(); |
2912 | while(filter) { | 2911 | while(filter) { |
2913 | // kdDebug() << " fn: " << filter->name() << endl; | 2912 | // kdDebug() << " fn: " << filter->name() << endl; |
2914 | filterList << filter->name(); | 2913 | filterList << filter->name(); |
2915 | config->setGroup("Filter_" + filter->name().utf8()); | 2914 | config->setGroup("Filter_" + filter->name().utf8()); |
2916 | config->writeEntry("Criteria",filter->criteria()); | 2915 | config->writeEntry("Criteria",filter->criteria()); |
2917 | config->writeEntry("CategoryList",filter->categoryList()); | 2916 | config->writeEntry("CategoryList",filter->categoryList()); |
2918 | filter = mFilters.next(); | 2917 | filter = mFilters.next(); |
2919 | } | 2918 | } |
2920 | config->setGroup("General"); | 2919 | config->setGroup("General"); |
2921 | config->writeEntry("CalendarFilters",filterList); | 2920 | config->writeEntry("CalendarFilters",filterList); |
2922 | 2921 | ||
2923 | config->setGroup("FilterView"); | 2922 | config->setGroup("FilterView"); |
2924 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2923 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2925 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2924 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2926 | } | 2925 | } |
2927 | 2926 | ||
2928 | 2927 | ||
2929 | void CalendarView::goToday() | 2928 | void CalendarView::goToday() |
2930 | { | 2929 | { |
2931 | if ( mViewManager->currentView()->isMonthView() ) | 2930 | if ( mViewManager->currentView()->isMonthView() ) |
2932 | mNavigator->selectTodayMonth(); | 2931 | mNavigator->selectTodayMonth(); |
2933 | else | 2932 | else |
2934 | mNavigator->selectToday(); | 2933 | mNavigator->selectToday(); |
2935 | } | 2934 | } |
2936 | 2935 | ||
2937 | void CalendarView::goNext() | 2936 | void CalendarView::goNext() |
2938 | { | 2937 | { |
2939 | mNavigator->selectNext(); | 2938 | mNavigator->selectNext(); |
2940 | } | 2939 | } |
2941 | 2940 | ||
2942 | void CalendarView::goPrevious() | 2941 | void CalendarView::goPrevious() |
2943 | { | 2942 | { |
2944 | mNavigator->selectPrevious(); | 2943 | mNavigator->selectPrevious(); |
2945 | } | 2944 | } |
2946 | void CalendarView::goNextMonth() | 2945 | void CalendarView::goNextMonth() |
2947 | { | 2946 | { |
2948 | mNavigator->selectNextMonth(); | 2947 | mNavigator->selectNextMonth(); |
2949 | } | 2948 | } |
2950 | 2949 | ||
2951 | void CalendarView::goPreviousMonth() | 2950 | void CalendarView::goPreviousMonth() |
2952 | { | 2951 | { |
2953 | mNavigator->selectPreviousMonth(); | 2952 | mNavigator->selectPreviousMonth(); |
2954 | } | 2953 | } |
2955 | 2954 | ||
2956 | void CalendarView::updateConfig() | 2955 | void CalendarView::updateConfig() |
2957 | { | 2956 | { |
2958 | if ( KOPrefs::instance()->mUseAppColors ) | 2957 | if ( KOPrefs::instance()->mUseAppColors ) |
2959 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2958 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2960 | emit configChanged(); | 2959 | emit configChanged(); |
2961 | mTodoList->updateConfig(); | 2960 | mTodoList->updateConfig(); |
2962 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2961 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2963 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2962 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2964 | // To make the "fill window" configurations work | 2963 | // To make the "fill window" configurations work |
2965 | //mViewManager->raiseCurrentView(); | 2964 | //mViewManager->raiseCurrentView(); |
2966 | } | 2965 | } |
2967 | 2966 | ||
2968 | 2967 | ||
2969 | void CalendarView::eventChanged(Event *event) | 2968 | void CalendarView::eventChanged(Event *event) |
2970 | { | 2969 | { |
2971 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2970 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2972 | //updateUnmanagedViews(); | 2971 | //updateUnmanagedViews(); |
2973 | } | 2972 | } |
2974 | 2973 | ||
2975 | void CalendarView::eventAdded(Event *event) | 2974 | void CalendarView::eventAdded(Event *event) |
2976 | { | 2975 | { |
2977 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2976 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2978 | } | 2977 | } |
2979 | 2978 | ||
2980 | void CalendarView::eventToBeDeleted(Event *) | 2979 | void CalendarView::eventToBeDeleted(Event *) |
2981 | { | 2980 | { |
2982 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2981 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2983 | } | 2982 | } |
2984 | 2983 | ||
2985 | void CalendarView::eventDeleted() | 2984 | void CalendarView::eventDeleted() |
2986 | { | 2985 | { |
2987 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2986 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2988 | } | 2987 | } |
2989 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2988 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2990 | { | 2989 | { |
2991 | changeIncidenceDisplay((Incidence *)which, action); | 2990 | changeIncidenceDisplay((Incidence *)which, action); |
2992 | mDateNavigator->updateView(); //LR | 2991 | mDateNavigator->updateView(); //LR |
2993 | //mDialogManager->updateSearchDialog(); | 2992 | //mDialogManager->updateSearchDialog(); |
2994 | 2993 | ||
2995 | if (which) { | 2994 | if (which) { |
2996 | mViewManager->updateWNview(); | 2995 | mViewManager->updateWNview(); |
2997 | //mTodoList->updateView(); | 2996 | //mTodoList->updateView(); |
2998 | } | 2997 | } |
2999 | 2998 | ||
3000 | } | 2999 | } |
3001 | 3000 | ||
3002 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 3001 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
3003 | { | 3002 | { |
3004 | updateUnmanagedViews(); | 3003 | updateUnmanagedViews(); |
3005 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 3004 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
@@ -4013,1164 +4012,1178 @@ void CalendarView::deleteTodo(Todo *todo) | |||
4013 | if ( !deleteT ) { | 4012 | if ( !deleteT ) { |
4014 | checkExternalId( todo ); | 4013 | checkExternalId( todo ); |
4015 | calendar()->deleteTodo(todo); | 4014 | calendar()->deleteTodo(todo); |
4016 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 4015 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
4017 | } | 4016 | } |
4018 | updateView(); | 4017 | updateView(); |
4019 | break; | 4018 | break; |
4020 | } // switch | 4019 | } // switch |
4021 | } else { | 4020 | } else { |
4022 | checkExternalId( todo ); | 4021 | checkExternalId( todo ); |
4023 | mCalendar->deleteTodo(todo); | 4022 | mCalendar->deleteTodo(todo); |
4024 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 4023 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
4025 | updateView(); | 4024 | updateView(); |
4026 | } | 4025 | } |
4027 | 4026 | ||
4028 | emit updateSearchDialog(); | 4027 | emit updateSearchDialog(); |
4029 | } | 4028 | } |
4030 | void CalendarView::deleteJournal(Journal *jour) | 4029 | void CalendarView::deleteJournal(Journal *jour) |
4031 | { | 4030 | { |
4032 | if (!jour) { | 4031 | if (!jour) { |
4033 | KNotifyClient::beep(); | 4032 | KNotifyClient::beep(); |
4034 | return; | 4033 | return; |
4035 | } | 4034 | } |
4036 | if (KOPrefs::instance()->mConfirm) { | 4035 | if (KOPrefs::instance()->mConfirm) { |
4037 | 4036 | ||
4038 | QString des; | 4037 | QString des; |
4039 | if ( !jour->summary().isEmpty() ) { | 4038 | if ( !jour->summary().isEmpty() ) { |
4040 | des = jour->summary(); | 4039 | des = jour->summary(); |
4041 | } else { | 4040 | } else { |
4042 | des = jour->description().left(30); | 4041 | des = jour->description().left(30); |
4043 | des = des.simplifyWhiteSpace (); | 4042 | des = des.simplifyWhiteSpace (); |
4044 | des.replace (QRegExp ("\\n"),"" ); | 4043 | des.replace (QRegExp ("\\n"),"" ); |
4045 | des.replace (QRegExp ("\\r"),"" ); | 4044 | des.replace (QRegExp ("\\r"),"" ); |
4046 | } | 4045 | } |
4047 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 4046 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
4048 | case KMessageBox::Continue: // OK | 4047 | case KMessageBox::Continue: // OK |
4049 | calendar()->deleteJournal(jour); | 4048 | calendar()->deleteJournal(jour); |
4050 | updateView(); | 4049 | updateView(); |
4051 | break; | 4050 | break; |
4052 | } // switch | 4051 | } // switch |
4053 | } else { | 4052 | } else { |
4054 | calendar()->deleteJournal(jour);; | 4053 | calendar()->deleteJournal(jour);; |
4055 | updateView(); | 4054 | updateView(); |
4056 | } | 4055 | } |
4057 | emit updateSearchDialog(); | 4056 | emit updateSearchDialog(); |
4058 | } | 4057 | } |
4059 | 4058 | ||
4060 | void CalendarView::deleteEvent(Event *anEvent) | 4059 | void CalendarView::deleteEvent(Event *anEvent) |
4061 | { | 4060 | { |
4062 | if (!anEvent) { | 4061 | if (!anEvent) { |
4063 | KNotifyClient::beep(); | 4062 | KNotifyClient::beep(); |
4064 | return; | 4063 | return; |
4065 | } | 4064 | } |
4066 | 4065 | ||
4067 | if (anEvent->doesRecur()) { | 4066 | if (anEvent->doesRecur()) { |
4068 | QDate itemDate = mViewManager->currentSelectionDate(); | 4067 | QDate itemDate = mViewManager->currentSelectionDate(); |
4069 | int km; | 4068 | int km; |
4070 | if (!itemDate.isValid()) { | 4069 | if (!itemDate.isValid()) { |
4071 | //kdDebug() << "Date Not Valid" << endl; | 4070 | //kdDebug() << "Date Not Valid" << endl; |
4072 | if (KOPrefs::instance()->mConfirm) { | 4071 | if (KOPrefs::instance()->mConfirm) { |
4073 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4072 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4074 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 4073 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
4075 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 4074 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
4076 | if ( km == KMessageBox::Continue ) | 4075 | if ( km == KMessageBox::Continue ) |
4077 | km = KMessageBox::No; // No = all below | 4076 | km = KMessageBox::No; // No = all below |
4078 | } else | 4077 | } else |
4079 | km = KMessageBox::No; | 4078 | km = KMessageBox::No; |
4080 | } else { | 4079 | } else { |
4081 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4080 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4082 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 4081 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
4083 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 4082 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
4084 | i18n("KO/Pi Confirmation"),i18n("Current"), | 4083 | i18n("KO/Pi Confirmation"),i18n("Current"), |
4085 | i18n("All")); | 4084 | i18n("All")); |
4086 | } | 4085 | } |
4087 | switch(km) { | 4086 | switch(km) { |
4088 | 4087 | ||
4089 | case KMessageBox::No: // Continue // all | 4088 | case KMessageBox::No: // Continue // all |
4090 | //qDebug("KMessageBox::No "); | 4089 | //qDebug("KMessageBox::No "); |
4091 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4090 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4092 | schedule(Scheduler::Cancel,anEvent); | 4091 | schedule(Scheduler::Cancel,anEvent); |
4093 | 4092 | ||
4094 | checkExternalId( anEvent); | 4093 | checkExternalId( anEvent); |
4095 | mCalendar->deleteEvent(anEvent); | 4094 | mCalendar->deleteEvent(anEvent); |
4096 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 4095 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
4097 | break; | 4096 | break; |
4098 | 4097 | ||
4099 | // Disabled because it does not work | 4098 | // Disabled because it does not work |
4100 | //#if 0 | 4099 | //#if 0 |
4101 | case KMessageBox::Yes: // just this one | 4100 | case KMessageBox::Yes: // just this one |
4102 | //QDate qd = mNavigator->selectedDates().first(); | 4101 | //QDate qd = mNavigator->selectedDates().first(); |
4103 | //if (!qd.isValid()) { | 4102 | //if (!qd.isValid()) { |
4104 | // kdDebug() << "no date selected, or invalid date" << endl; | 4103 | // kdDebug() << "no date selected, or invalid date" << endl; |
4105 | // KNotifyClient::beep(); | 4104 | // KNotifyClient::beep(); |
4106 | // return; | 4105 | // return; |
4107 | //} | 4106 | //} |
4108 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 4107 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
4109 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 4108 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
4110 | anEvent->addExDate(itemDate); | 4109 | anEvent->addExDate(itemDate); |
4111 | int duration = anEvent->recurrence()->duration(); | 4110 | int duration = anEvent->recurrence()->duration(); |
4112 | if ( duration > 0 ) { | 4111 | if ( duration > 0 ) { |
4113 | anEvent->recurrence()->setDuration( duration - 1 ); | 4112 | anEvent->recurrence()->setDuration( duration - 1 ); |
4114 | } | 4113 | } |
4115 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 4114 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
4116 | } | 4115 | } |
4117 | break; | 4116 | break; |
4118 | //#endif | 4117 | //#endif |
4119 | } // switch | 4118 | } // switch |
4120 | } else { | 4119 | } else { |
4121 | if (KOPrefs::instance()->mConfirm) { | 4120 | if (KOPrefs::instance()->mConfirm) { |
4122 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4121 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4123 | i18n("\nAre you sure you want\nto delete this event?"), | 4122 | i18n("\nAre you sure you want\nto delete this event?"), |
4124 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 4123 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
4125 | case KMessageBox::Continue: // OK | 4124 | case KMessageBox::Continue: // OK |
4126 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4125 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4127 | schedule(Scheduler::Cancel,anEvent); | 4126 | schedule(Scheduler::Cancel,anEvent); |
4128 | checkExternalId( anEvent); | 4127 | checkExternalId( anEvent); |
4129 | mCalendar->deleteEvent(anEvent); | 4128 | mCalendar->deleteEvent(anEvent); |
4130 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4129 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4131 | break; | 4130 | break; |
4132 | } // switch | 4131 | } // switch |
4133 | } else { | 4132 | } else { |
4134 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4133 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4135 | schedule(Scheduler::Cancel,anEvent); | 4134 | schedule(Scheduler::Cancel,anEvent); |
4136 | checkExternalId( anEvent); | 4135 | checkExternalId( anEvent); |
4137 | mCalendar->deleteEvent(anEvent); | 4136 | mCalendar->deleteEvent(anEvent); |
4138 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4137 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4139 | } | 4138 | } |
4140 | } // if-else | 4139 | } // if-else |
4141 | emit updateSearchDialog(); | 4140 | emit updateSearchDialog(); |
4142 | } | 4141 | } |
4143 | 4142 | ||
4144 | bool CalendarView::deleteEvent(const QString &uid) | 4143 | bool CalendarView::deleteEvent(const QString &uid) |
4145 | { | 4144 | { |
4146 | Event *ev = mCalendar->event(uid); | 4145 | Event *ev = mCalendar->event(uid); |
4147 | if (ev) { | 4146 | if (ev) { |
4148 | deleteEvent(ev); | 4147 | deleteEvent(ev); |
4149 | return true; | 4148 | return true; |
4150 | } else { | 4149 | } else { |
4151 | return false; | 4150 | return false; |
4152 | } | 4151 | } |
4153 | } | 4152 | } |
4154 | 4153 | ||
4155 | /*****************************************************************************/ | 4154 | /*****************************************************************************/ |
4156 | 4155 | ||
4157 | void CalendarView::action_mail() | 4156 | void CalendarView::action_mail() |
4158 | { | 4157 | { |
4159 | #ifndef KORG_NOMAIL | 4158 | #ifndef KORG_NOMAIL |
4160 | KOMailClient mailClient; | 4159 | KOMailClient mailClient; |
4161 | 4160 | ||
4162 | Incidence *incidence = currentSelection(); | 4161 | Incidence *incidence = currentSelection(); |
4163 | 4162 | ||
4164 | if (!incidence) { | 4163 | if (!incidence) { |
4165 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4164 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4166 | return; | 4165 | return; |
4167 | } | 4166 | } |
4168 | if(incidence->attendeeCount() == 0 ) { | 4167 | if(incidence->attendeeCount() == 0 ) { |
4169 | KMessageBox::sorry(this, | 4168 | KMessageBox::sorry(this, |
4170 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4169 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4171 | return; | 4170 | return; |
4172 | } | 4171 | } |
4173 | 4172 | ||
4174 | CalendarLocal cal_tmp; | 4173 | CalendarLocal cal_tmp; |
4175 | Event *event = 0; | 4174 | Event *event = 0; |
4176 | Event *ev = 0; | 4175 | Event *ev = 0; |
4177 | if ( incidence && incidence->typeID() == eventID ) { | 4176 | if ( incidence && incidence->typeID() == eventID ) { |
4178 | event = static_cast<Event *>(incidence); | 4177 | event = static_cast<Event *>(incidence); |
4179 | ev = new Event(*event); | 4178 | ev = new Event(*event); |
4180 | cal_tmp.addEvent(ev); | 4179 | cal_tmp.addEvent(ev); |
4181 | } | 4180 | } |
4182 | ICalFormat mForm(); | 4181 | ICalFormat mForm(); |
4183 | QString attachment = mForm.toString( &cal_tmp ); | 4182 | QString attachment = mForm.toString( &cal_tmp ); |
4184 | if (ev) delete(ev); | 4183 | if (ev) delete(ev); |
4185 | 4184 | ||
4186 | mailClient.mailAttendees(currentSelection(), attachment); | 4185 | mailClient.mailAttendees(currentSelection(), attachment); |
4187 | 4186 | ||
4188 | #endif | 4187 | #endif |
4189 | 4188 | ||
4190 | #if 0 | 4189 | #if 0 |
4191 | Event *anEvent = 0; | 4190 | Event *anEvent = 0; |
4192 | if (mViewManager->currentView()->isEventView()) { | 4191 | if (mViewManager->currentView()->isEventView()) { |
4193 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 4192 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
4194 | } | 4193 | } |
4195 | 4194 | ||
4196 | if (!anEvent) { | 4195 | if (!anEvent) { |
4197 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4196 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4198 | return; | 4197 | return; |
4199 | } | 4198 | } |
4200 | if(anEvent->attendeeCount() == 0 ) { | 4199 | if(anEvent->attendeeCount() == 0 ) { |
4201 | KMessageBox::sorry(this, | 4200 | KMessageBox::sorry(this, |
4202 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4201 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4203 | return; | 4202 | return; |
4204 | } | 4203 | } |
4205 | 4204 | ||
4206 | mailobject.emailEvent(anEvent); | 4205 | mailobject.emailEvent(anEvent); |
4207 | #endif | 4206 | #endif |
4208 | } | 4207 | } |
4209 | 4208 | ||
4210 | 4209 | ||
4211 | void CalendarView::schedule_publish(Incidence *incidence) | 4210 | void CalendarView::schedule_publish(Incidence *incidence) |
4212 | { | 4211 | { |
4213 | Event *event = 0; | 4212 | Event *event = 0; |
4214 | Todo *todo = 0; | 4213 | Todo *todo = 0; |
4215 | 4214 | ||
4216 | if (incidence == 0) { | 4215 | if (incidence == 0) { |
4217 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4216 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4218 | if (incidence == 0) { | 4217 | if (incidence == 0) { |
4219 | incidence = mTodoList->selectedIncidences().first(); | 4218 | incidence = mTodoList->selectedIncidences().first(); |
4220 | } | 4219 | } |
4221 | } | 4220 | } |
4222 | if ( incidence && incidence->typeID() == eventID ) { | 4221 | if ( incidence && incidence->typeID() == eventID ) { |
4223 | event = static_cast<Event *>(incidence); | 4222 | event = static_cast<Event *>(incidence); |
4224 | } else { | 4223 | } else { |
4225 | if ( incidence && incidence->typeID() == todoID ) { | 4224 | if ( incidence && incidence->typeID() == todoID ) { |
4226 | todo = static_cast<Todo *>(incidence); | 4225 | todo = static_cast<Todo *>(incidence); |
4227 | } | 4226 | } |
4228 | } | 4227 | } |
4229 | 4228 | ||
4230 | if (!event && !todo) { | 4229 | if (!event && !todo) { |
4231 | KMessageBox::sorry(this,i18n("No event selected.")); | 4230 | KMessageBox::sorry(this,i18n("No event selected.")); |
4232 | return; | 4231 | return; |
4233 | } | 4232 | } |
4234 | 4233 | ||
4235 | PublishDialog *publishdlg = new PublishDialog(); | 4234 | PublishDialog *publishdlg = new PublishDialog(); |
4236 | if (incidence->attendeeCount()>0) { | 4235 | if (incidence->attendeeCount()>0) { |
4237 | QPtrList<Attendee> attendees = incidence->attendees(); | 4236 | QPtrList<Attendee> attendees = incidence->attendees(); |
4238 | attendees.first(); | 4237 | attendees.first(); |
4239 | while ( attendees.current()!=0 ) { | 4238 | while ( attendees.current()!=0 ) { |
4240 | publishdlg->addAttendee(attendees.current()); | 4239 | publishdlg->addAttendee(attendees.current()); |
4241 | attendees.next(); | 4240 | attendees.next(); |
4242 | } | 4241 | } |
4243 | } | 4242 | } |
4244 | bool send = true; | 4243 | bool send = true; |
4245 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 4244 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
4246 | if ( publishdlg->exec() != QDialog::Accepted ) | 4245 | if ( publishdlg->exec() != QDialog::Accepted ) |
4247 | send = false; | 4246 | send = false; |
4248 | } | 4247 | } |
4249 | if ( send ) { | 4248 | if ( send ) { |
4250 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4249 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4251 | if ( event ) { | 4250 | if ( event ) { |
4252 | Event *ev = new Event(*event); | 4251 | Event *ev = new Event(*event); |
4253 | ev->registerObserver(0); | 4252 | ev->registerObserver(0); |
4254 | ev->clearAttendees(); | 4253 | ev->clearAttendees(); |
4255 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4254 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4256 | delete(ev); | 4255 | delete(ev); |
4257 | } | 4256 | } |
4258 | } else { | 4257 | } else { |
4259 | if ( todo ) { | 4258 | if ( todo ) { |
4260 | Todo *ev = new Todo(*todo); | 4259 | Todo *ev = new Todo(*todo); |
4261 | ev->registerObserver(0); | 4260 | ev->registerObserver(0); |
4262 | ev->clearAttendees(); | 4261 | ev->clearAttendees(); |
4263 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4262 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4264 | delete(ev); | 4263 | delete(ev); |
4265 | } | 4264 | } |
4266 | } | 4265 | } |
4267 | } | 4266 | } |
4268 | } | 4267 | } |
4269 | delete publishdlg; | 4268 | delete publishdlg; |
4270 | } | 4269 | } |
4271 | 4270 | ||
4272 | void CalendarView::schedule_request(Incidence *incidence) | 4271 | void CalendarView::schedule_request(Incidence *incidence) |
4273 | { | 4272 | { |
4274 | schedule(Scheduler::Request,incidence); | 4273 | schedule(Scheduler::Request,incidence); |
4275 | } | 4274 | } |
4276 | 4275 | ||
4277 | void CalendarView::schedule_refresh(Incidence *incidence) | 4276 | void CalendarView::schedule_refresh(Incidence *incidence) |
4278 | { | 4277 | { |
4279 | schedule(Scheduler::Refresh,incidence); | 4278 | schedule(Scheduler::Refresh,incidence); |
4280 | } | 4279 | } |
4281 | 4280 | ||
4282 | void CalendarView::schedule_cancel(Incidence *incidence) | 4281 | void CalendarView::schedule_cancel(Incidence *incidence) |
4283 | { | 4282 | { |
4284 | schedule(Scheduler::Cancel,incidence); | 4283 | schedule(Scheduler::Cancel,incidence); |
4285 | } | 4284 | } |
4286 | 4285 | ||
4287 | void CalendarView::schedule_add(Incidence *incidence) | 4286 | void CalendarView::schedule_add(Incidence *incidence) |
4288 | { | 4287 | { |
4289 | schedule(Scheduler::Add,incidence); | 4288 | schedule(Scheduler::Add,incidence); |
4290 | } | 4289 | } |
4291 | 4290 | ||
4292 | void CalendarView::schedule_reply(Incidence *incidence) | 4291 | void CalendarView::schedule_reply(Incidence *incidence) |
4293 | { | 4292 | { |
4294 | schedule(Scheduler::Reply,incidence); | 4293 | schedule(Scheduler::Reply,incidence); |
4295 | } | 4294 | } |
4296 | 4295 | ||
4297 | void CalendarView::schedule_counter(Incidence *incidence) | 4296 | void CalendarView::schedule_counter(Incidence *incidence) |
4298 | { | 4297 | { |
4299 | schedule(Scheduler::Counter,incidence); | 4298 | schedule(Scheduler::Counter,incidence); |
4300 | } | 4299 | } |
4301 | 4300 | ||
4302 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 4301 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
4303 | { | 4302 | { |
4304 | schedule(Scheduler::Declinecounter,incidence); | 4303 | schedule(Scheduler::Declinecounter,incidence); |
4305 | } | 4304 | } |
4306 | 4305 | ||
4307 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 4306 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
4308 | { | 4307 | { |
4309 | QDateTime start = QDateTime::currentDateTime(); | 4308 | QDateTime start = QDateTime::currentDateTime(); |
4310 | QDateTime end = start.addDays(daysToPublish); | 4309 | QDateTime end = start.addDays(daysToPublish); |
4311 | 4310 | ||
4312 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 4311 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
4313 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 4312 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
4314 | 4313 | ||
4315 | 4314 | ||
4316 | PublishDialog *publishdlg = new PublishDialog(); | 4315 | PublishDialog *publishdlg = new PublishDialog(); |
4317 | if ( publishdlg->exec() == QDialog::Accepted ) { | 4316 | if ( publishdlg->exec() == QDialog::Accepted ) { |
4318 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4317 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4319 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 4318 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
4320 | delete(freebusy); | 4319 | delete(freebusy); |
4321 | } | 4320 | } |
4322 | } | 4321 | } |
4323 | delete publishdlg; | 4322 | delete publishdlg; |
4324 | } | 4323 | } |
4325 | 4324 | ||
4326 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 4325 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
4327 | { | 4326 | { |
4328 | Event *event = 0; | 4327 | Event *event = 0; |
4329 | Todo *todo = 0; | 4328 | Todo *todo = 0; |
4330 | 4329 | ||
4331 | if (incidence == 0) { | 4330 | if (incidence == 0) { |
4332 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4331 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4333 | if (incidence == 0) { | 4332 | if (incidence == 0) { |
4334 | incidence = mTodoList->selectedIncidences().first(); | 4333 | incidence = mTodoList->selectedIncidences().first(); |
4335 | } | 4334 | } |
4336 | } | 4335 | } |
4337 | if ( incidence && incidence->typeID() == eventID ) { | 4336 | if ( incidence && incidence->typeID() == eventID ) { |
4338 | event = static_cast<Event *>(incidence); | 4337 | event = static_cast<Event *>(incidence); |
4339 | } | 4338 | } |
4340 | if ( incidence && incidence->typeID() == todoID ) { | 4339 | if ( incidence && incidence->typeID() == todoID ) { |
4341 | todo = static_cast<Todo *>(incidence); | 4340 | todo = static_cast<Todo *>(incidence); |
4342 | } | 4341 | } |
4343 | 4342 | ||
4344 | if (!event && !todo) { | 4343 | if (!event && !todo) { |
4345 | KMessageBox::sorry(this,i18n("No event selected.")); | 4344 | KMessageBox::sorry(this,i18n("No event selected.")); |
4346 | return; | 4345 | return; |
4347 | } | 4346 | } |
4348 | 4347 | ||
4349 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4348 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4350 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4349 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4351 | return; | 4350 | return; |
4352 | } | 4351 | } |
4353 | 4352 | ||
4354 | Event *ev = 0; | 4353 | Event *ev = 0; |
4355 | if (event) ev = new Event(*event); | 4354 | if (event) ev = new Event(*event); |
4356 | Todo *to = 0; | 4355 | Todo *to = 0; |
4357 | if (todo) to = new Todo(*todo); | 4356 | if (todo) to = new Todo(*todo); |
4358 | 4357 | ||
4359 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4358 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4360 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4359 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4361 | if (!me) { | 4360 | if (!me) { |
4362 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4361 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4363 | return; | 4362 | return; |
4364 | } | 4363 | } |
4365 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4364 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4366 | StatusDialog *statdlg = new StatusDialog(this); | 4365 | StatusDialog *statdlg = new StatusDialog(this); |
4367 | if (!statdlg->exec()==QDialog::Accepted) return; | 4366 | if (!statdlg->exec()==QDialog::Accepted) return; |
4368 | me->setStatus( statdlg->status() ); | 4367 | me->setStatus( statdlg->status() ); |
4369 | delete(statdlg); | 4368 | delete(statdlg); |
4370 | } | 4369 | } |
4371 | Attendee *menew = new Attendee(*me); | 4370 | Attendee *menew = new Attendee(*me); |
4372 | if (ev) { | 4371 | if (ev) { |
4373 | ev->clearAttendees(); | 4372 | ev->clearAttendees(); |
4374 | ev->addAttendee(menew,false); | 4373 | ev->addAttendee(menew,false); |
4375 | } else { | 4374 | } else { |
4376 | if (to) { | 4375 | if (to) { |
4377 | todo->clearAttendees(); | 4376 | todo->clearAttendees(); |
4378 | todo->addAttendee(menew,false); | 4377 | todo->addAttendee(menew,false); |
4379 | } | 4378 | } |
4380 | } | 4379 | } |
4381 | } | 4380 | } |
4382 | 4381 | ||
4383 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4382 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4384 | if (ev) { | 4383 | if (ev) { |
4385 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4384 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4386 | } else { | 4385 | } else { |
4387 | if (to) { | 4386 | if (to) { |
4388 | if ( !dlg->addMessage(to,method) ) delete(to); | 4387 | if ( !dlg->addMessage(to,method) ) delete(to); |
4389 | } | 4388 | } |
4390 | } | 4389 | } |
4391 | } | 4390 | } |
4392 | 4391 | ||
4393 | void CalendarView::openAddressbook() | 4392 | void CalendarView::openAddressbook() |
4394 | { | 4393 | { |
4395 | KRun::runCommand("kaddressbook"); | 4394 | KRun::runCommand("kaddressbook"); |
4396 | } | 4395 | } |
4397 | 4396 | ||
4398 | void CalendarView::setModified(bool modified) | 4397 | void CalendarView::setModified(bool modified) |
4399 | { | 4398 | { |
4400 | //qDebug("CalendarView::setModified %d ", modified); | 4399 | //qDebug("CalendarView::setModified %d ", modified); |
4401 | if ( modified ) | 4400 | if ( modified ) |
4402 | emit signalmodified(); | 4401 | emit signalmodified(); |
4403 | mModified = modified; | 4402 | mModified = modified; |
4404 | if ( mModified ) | 4403 | if ( mModified ) |
4405 | emit modifiedChanged(mModified); | 4404 | emit modifiedChanged(mModified); |
4406 | 4405 | ||
4407 | } | 4406 | } |
4408 | 4407 | ||
4409 | bool CalendarView::isReadOnly() | 4408 | bool CalendarView::isReadOnly() |
4410 | { | 4409 | { |
4411 | return mReadOnly; | 4410 | return mReadOnly; |
4412 | } | 4411 | } |
4413 | 4412 | ||
4414 | void CalendarView::setReadOnly(bool readOnly) | 4413 | void CalendarView::setReadOnly(bool readOnly) |
4415 | { | 4414 | { |
4416 | if (mReadOnly != readOnly) { | 4415 | if (mReadOnly != readOnly) { |
4417 | mReadOnly = readOnly; | 4416 | mReadOnly = readOnly; |
4418 | emit readOnlyChanged(mReadOnly); | 4417 | emit readOnlyChanged(mReadOnly); |
4419 | } | 4418 | } |
4420 | } | 4419 | } |
4421 | 4420 | ||
4422 | bool CalendarView::isModified() | 4421 | bool CalendarView::isModified() |
4423 | { | 4422 | { |
4424 | return mModified; | 4423 | return mModified; |
4425 | } | 4424 | } |
4426 | void CalendarView::slotprintSelInc() | 4425 | void CalendarView::slotprintSelInc() |
4427 | { | 4426 | { |
4428 | if ( currentSelection() == 0 ) { | 4427 | if ( currentSelection() == 0 ) { |
4429 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4428 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4430 | return; | 4429 | return; |
4431 | } | 4430 | } |
4432 | showIncidence(); | 4431 | showIncidence(); |
4433 | getEventViewerDialog()->print(); | 4432 | getEventViewerDialog()->print(); |
4434 | 4433 | ||
4435 | } | 4434 | } |
4436 | void CalendarView::printSetup() | 4435 | void CalendarView::printSetup() |
4437 | { | 4436 | { |
4438 | #ifndef KORG_NOPRINTER | 4437 | #ifndef KORG_NOPRINTER |
4439 | createPrinter(); | 4438 | createPrinter(); |
4440 | 4439 | ||
4441 | mCalPrinter->setupPrinter(); | 4440 | mCalPrinter->setupPrinter(); |
4442 | #endif | 4441 | #endif |
4443 | } | 4442 | } |
4444 | 4443 | ||
4445 | void CalendarView::print() | 4444 | void CalendarView::print() |
4446 | { | 4445 | { |
4447 | #ifndef KORG_NOPRINTER | 4446 | #ifndef KORG_NOPRINTER |
4448 | createPrinter(); | 4447 | createPrinter(); |
4449 | 4448 | ||
4450 | DateList tmpDateList = mNavigator->selectedDates(); | 4449 | DateList tmpDateList = mNavigator->selectedDates(); |
4451 | mCalPrinter->print(CalPrinter::Month, | 4450 | mCalPrinter->print(CalPrinter::Month, |
4452 | tmpDateList.first(), tmpDateList.last()); | 4451 | tmpDateList.first(), tmpDateList.last()); |
4453 | #endif | 4452 | #endif |
4454 | } | 4453 | } |
4455 | 4454 | ||
4456 | void CalendarView::printPreview() | 4455 | void CalendarView::printPreview() |
4457 | { | 4456 | { |
4458 | #ifndef KORG_NOPRINTER | 4457 | #ifndef KORG_NOPRINTER |
4459 | kdDebug() << "CalendarView::printPreview()" << endl; | 4458 | kdDebug() << "CalendarView::printPreview()" << endl; |
4460 | 4459 | ||
4461 | createPrinter(); | 4460 | createPrinter(); |
4462 | 4461 | ||
4463 | DateList tmpDateList = mNavigator->selectedDates(); | 4462 | DateList tmpDateList = mNavigator->selectedDates(); |
4464 | 4463 | ||
4465 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4464 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4466 | tmpDateList.last()); | 4465 | tmpDateList.last()); |
4467 | #endif | 4466 | #endif |
4468 | } | 4467 | } |
4469 | bool CalendarView::exportICalendar( QString filename ) | 4468 | bool CalendarView::exportICalendar( QString filename ) |
4470 | { | 4469 | { |
4471 | // Force correct extension | 4470 | // Force correct extension |
4472 | if (filename.right(4) != ".ics") filename += ".ics"; | 4471 | if (filename.right(4) != ".ics") filename += ".ics"; |
4473 | 4472 | ||
4474 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4473 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4475 | return storage.save(); | 4474 | return storage.save(); |
4476 | } | 4475 | } |
4477 | 4476 | ||
4478 | bool CalendarView::exportICalendar() | 4477 | bool CalendarView::exportICalendar() |
4479 | { | 4478 | { |
4480 | return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) ); | 4479 | return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) ); |
4481 | } | 4480 | } |
4482 | 4481 | ||
4483 | bool CalendarView::exportVCalendar( QString filename ) | 4482 | bool CalendarView::exportVCalendar( QString filename ) |
4484 | { | 4483 | { |
4485 | if (mCalendar->journals().count() > 0) { | 4484 | if (mCalendar->journals().count() > 0) { |
4486 | int result = KMessageBox::warningContinueCancel(this, | 4485 | int result = KMessageBox::warningContinueCancel(this, |
4487 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4486 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4488 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4487 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4489 | true); | 4488 | true); |
4490 | if (result != KMessageBox::Continue) return false; | 4489 | if (result != KMessageBox::Continue) return false; |
4491 | } | 4490 | } |
4492 | 4491 | ||
4493 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4492 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4494 | 4493 | ||
4495 | // Force correct extension | 4494 | // Force correct extension |
4496 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4495 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4497 | 4496 | ||
4498 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4497 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4499 | return storage.save(); | 4498 | return storage.save(); |
4500 | 4499 | ||
4501 | } | 4500 | } |
4502 | 4501 | ||
4503 | void CalendarView::eventUpdated(Incidence *) | 4502 | void CalendarView::eventUpdated(Incidence *) |
4504 | { | 4503 | { |
4505 | setModified(); | 4504 | setModified(); |
4506 | // Don't call updateView here. The code, which has caused the update of the | 4505 | // Don't call updateView here. The code, which has caused the update of the |
4507 | // event is responsible for updating the view. | 4506 | // event is responsible for updating the view. |
4508 | // updateView(); | 4507 | // updateView(); |
4509 | } | 4508 | } |
4510 | 4509 | ||
4511 | void CalendarView::adaptNavigationUnits() | 4510 | void CalendarView::adaptNavigationUnits() |
4512 | { | 4511 | { |
4513 | if (mViewManager->currentView()->isEventView()) { | 4512 | if (mViewManager->currentView()->isEventView()) { |
4514 | int days = mViewManager->currentView()->currentDateCount(); | 4513 | int days = mViewManager->currentView()->currentDateCount(); |
4515 | if (days == 1) { | 4514 | if (days == 1) { |
4516 | emit changeNavStringPrev(i18n("&Previous Day")); | 4515 | emit changeNavStringPrev(i18n("&Previous Day")); |
4517 | emit changeNavStringNext(i18n("&Next Day")); | 4516 | emit changeNavStringNext(i18n("&Next Day")); |
4518 | } else { | 4517 | } else { |
4519 | emit changeNavStringPrev(i18n("&Previous Week")); | 4518 | emit changeNavStringPrev(i18n("&Previous Week")); |
4520 | emit changeNavStringNext(i18n("&Next Week")); | 4519 | emit changeNavStringNext(i18n("&Next Week")); |
4521 | } | 4520 | } |
4522 | } | 4521 | } |
4523 | } | 4522 | } |
4524 | 4523 | ||
4525 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4524 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4526 | { | 4525 | { |
4527 | if ( incidence ) mTodoList->clearSelection(); | 4526 | if ( incidence ) mTodoList->clearSelection(); |
4528 | processIncidenceSelection( incidence ); | 4527 | processIncidenceSelection( incidence ); |
4529 | } | 4528 | } |
4530 | 4529 | ||
4531 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4530 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4532 | { | 4531 | { |
4533 | if ( incidence && mViewManager->currentView() ) { | 4532 | if ( incidence && mViewManager->currentView() ) { |
4534 | mViewManager->currentView()->clearSelection(); | 4533 | mViewManager->currentView()->clearSelection(); |
4535 | } | 4534 | } |
4536 | processIncidenceSelection( incidence ); | 4535 | processIncidenceSelection( incidence ); |
4537 | } | 4536 | } |
4538 | 4537 | ||
4539 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4538 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4540 | { | 4539 | { |
4541 | emit incidenceSelected( incidence ); | 4540 | emit incidenceSelected( incidence ); |
4542 | if ( incidence == mSelectedIncidence ) return; | 4541 | if ( incidence == mSelectedIncidence ) return; |
4543 | mSelectedIncidence = incidence; | 4542 | mSelectedIncidence = incidence; |
4544 | 4543 | ||
4545 | if ( incidence && incidence->typeID() == eventID ) { | 4544 | if ( incidence && incidence->typeID() == eventID ) { |
4546 | Event *event = static_cast<Event *>( incidence ); | 4545 | Event *event = static_cast<Event *>( incidence ); |
4547 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4546 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4548 | emit organizerEventsSelected( true ); | 4547 | emit organizerEventsSelected( true ); |
4549 | } else { | 4548 | } else { |
4550 | emit organizerEventsSelected(false); | 4549 | emit organizerEventsSelected(false); |
4551 | } | 4550 | } |
4552 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4551 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4553 | KOPrefs::instance()->email() ) ) { | 4552 | KOPrefs::instance()->email() ) ) { |
4554 | emit groupEventsSelected( true ); | 4553 | emit groupEventsSelected( true ); |
4555 | } else { | 4554 | } else { |
4556 | emit groupEventsSelected(false); | 4555 | emit groupEventsSelected(false); |
4557 | } | 4556 | } |
4558 | return; | 4557 | return; |
4559 | } else { | 4558 | } else { |
4560 | if ( incidence && incidence->typeID() == todoID ) { | 4559 | if ( incidence && incidence->typeID() == todoID ) { |
4561 | emit todoSelected( true ); | 4560 | emit todoSelected( true ); |
4562 | Todo *event = static_cast<Todo *>( incidence ); | 4561 | Todo *event = static_cast<Todo *>( incidence ); |
4563 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4562 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4564 | emit organizerEventsSelected( true ); | 4563 | emit organizerEventsSelected( true ); |
4565 | } else { | 4564 | } else { |
4566 | emit organizerEventsSelected(false); | 4565 | emit organizerEventsSelected(false); |
4567 | } | 4566 | } |
4568 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4567 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4569 | KOPrefs::instance()->email() ) ) { | 4568 | KOPrefs::instance()->email() ) ) { |
4570 | emit groupEventsSelected( true ); | 4569 | emit groupEventsSelected( true ); |
4571 | } else { | 4570 | } else { |
4572 | emit groupEventsSelected(false); | 4571 | emit groupEventsSelected(false); |
4573 | } | 4572 | } |
4574 | return; | 4573 | return; |
4575 | } else { | 4574 | } else { |
4576 | emit todoSelected( false ); | 4575 | emit todoSelected( false ); |
4577 | emit organizerEventsSelected(false); | 4576 | emit organizerEventsSelected(false); |
4578 | emit groupEventsSelected(false); | 4577 | emit groupEventsSelected(false); |
4579 | } | 4578 | } |
4580 | return; | 4579 | return; |
4581 | } | 4580 | } |
4582 | 4581 | ||
4583 | /* if ( incidence && incidence->typeID() == todoID ) { | 4582 | /* if ( incidence && incidence->typeID() == todoID ) { |
4584 | emit todoSelected( true ); | 4583 | emit todoSelected( true ); |
4585 | } else { | 4584 | } else { |
4586 | emit todoSelected( false ); | 4585 | emit todoSelected( false ); |
4587 | }*/ | 4586 | }*/ |
4588 | } | 4587 | } |
4589 | 4588 | ||
4590 | 4589 | ||
4591 | void CalendarView::checkClipboard() | 4590 | void CalendarView::checkClipboard() |
4592 | { | 4591 | { |
4593 | #ifndef KORG_NODND | 4592 | #ifndef KORG_NODND |
4594 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4593 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4595 | emit pasteEnabled(true); | 4594 | emit pasteEnabled(true); |
4596 | } else { | 4595 | } else { |
4597 | emit pasteEnabled(false); | 4596 | emit pasteEnabled(false); |
4598 | } | 4597 | } |
4599 | #endif | 4598 | #endif |
4600 | } | 4599 | } |
4601 | 4600 | ||
4602 | void CalendarView::showDates(const DateList &selectedDates) | 4601 | void CalendarView::showDates(const DateList &selectedDates) |
4603 | { | 4602 | { |
4604 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4603 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4605 | 4604 | ||
4606 | 4605 | ||
4607 | if ( !mBlockShowDates ) { | 4606 | if ( !mBlockShowDates ) { |
4608 | if ( mViewManager->currentView() ) { | 4607 | if ( mViewManager->currentView() ) { |
4609 | updateView( selectedDates.first(), selectedDates.last() ); | 4608 | updateView( selectedDates.first(), selectedDates.last() ); |
4610 | } else { | 4609 | } else { |
4611 | mViewManager->showAgendaView(); | 4610 | mViewManager->showAgendaView(); |
4612 | } | 4611 | } |
4613 | } | 4612 | } |
4614 | 4613 | ||
4615 | QDate date = selectedDates.first(); | 4614 | QDate date = selectedDates.first(); |
4616 | if ( ! date.isValid() ) { | 4615 | if ( ! date.isValid() ) { |
4617 | topLevelWidget()->setCaption(""); | 4616 | topLevelWidget()->setCaption(""); |
4618 | return; | 4617 | return; |
4619 | } | 4618 | } |
4620 | 4619 | ||
4621 | QString selDates; | 4620 | QString selDates; |
4622 | selDates = KGlobal::locale()->formatDate( date, true); | 4621 | selDates = KGlobal::locale()->formatDate( date, true); |
4623 | if (selectedDates.first() < selectedDates.last() ) | 4622 | if (selectedDates.first() < selectedDates.last() ) |
4624 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4623 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4625 | else { | 4624 | else { |
4626 | QString addString; | 4625 | QString addString; |
4627 | if ( date == QDateTime::currentDateTime().date() ) | 4626 | if ( date == QDateTime::currentDateTime().date() ) |
4628 | addString = i18n("Today"); | 4627 | addString = i18n("Today"); |
4629 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4628 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4630 | addString = i18n("Tomorrow"); | 4629 | addString = i18n("Tomorrow"); |
4631 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4630 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4632 | addString = i18n("Yesterday"); | 4631 | addString = i18n("Yesterday"); |
4633 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4632 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4634 | addString = i18n("Day before yesterday"); | 4633 | addString = i18n("Day before yesterday"); |
4635 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4634 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4636 | addString = i18n("Day after tomorrow"); | 4635 | addString = i18n("Day after tomorrow"); |
4637 | if ( !addString.isEmpty() ) { | 4636 | if ( !addString.isEmpty() ) { |
4638 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4637 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4639 | return; | 4638 | return; |
4640 | } | 4639 | } |
4641 | } | 4640 | } |
4642 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4641 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4643 | 4642 | ||
4644 | } | 4643 | } |
4645 | 4644 | ||
4646 | QPtrList<CalFilter> CalendarView::filters() | 4645 | QPtrList<CalFilter> CalendarView::filters() |
4647 | { | 4646 | { |
4648 | return mFilters; | 4647 | return mFilters; |
4649 | 4648 | ||
4650 | } | 4649 | } |
4651 | void CalendarView::editFilters() | 4650 | void CalendarView::editFilters() |
4652 | { | 4651 | { |
4653 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4652 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4654 | 4653 | ||
4655 | CalFilter *filter = mFilters.first(); | 4654 | CalFilter *filter = mFilters.first(); |
4656 | while(filter) { | 4655 | while(filter) { |
4657 | filter = mFilters.next(); | 4656 | filter = mFilters.next(); |
4658 | } | 4657 | } |
4659 | 4658 | ||
4660 | mDialogManager->showFilterEditDialog(&mFilters); | 4659 | mDialogManager->showFilterEditDialog(&mFilters); |
4661 | updateFilter(); | 4660 | updateFilter(); |
4662 | } | 4661 | } |
4663 | void CalendarView::toggleFilter() | 4662 | void CalendarView::toggleFilter() |
4664 | { | 4663 | { |
4665 | if ( mLeftFrame->isHidden() ) { | 4664 | if ( mLeftFrame->isHidden() ) { |
4666 | toggleExpand(); | 4665 | toggleExpand(); |
4667 | showFilter( true ); | 4666 | showFilter( true ); |
4668 | } else | 4667 | } else |
4669 | showFilter(! mCalEditView->isVisible()); | 4668 | showFilter(! mCalEditView->isVisible()); |
4670 | } | 4669 | } |
4671 | 4670 | ||
4672 | KOFilterView *CalendarView::filterView() | 4671 | KOFilterView *CalendarView::filterView() |
4673 | { | 4672 | { |
4674 | return mFilterView; | 4673 | return mFilterView; |
4675 | } | 4674 | } |
4676 | void CalendarView::selectFilter( int fil ) | 4675 | void CalendarView::selectFilter( int fil ) |
4677 | { | 4676 | { |
4678 | mFilterView->setSelectedFilter( fil ); | 4677 | mFilterView->setSelectedFilter( fil ); |
4679 | updateUnmanagedViews(); | 4678 | updateUnmanagedViews(); |
4680 | } | 4679 | } |
4681 | void CalendarView::showFilter(bool visible) | 4680 | void CalendarView::showFilter(bool visible) |
4682 | { | 4681 | { |
4683 | #if 1 | 4682 | #if 1 |
4684 | if (visible) { | 4683 | if (visible) { |
4685 | mCalEditView->readConfig(); | 4684 | mCalEditView->readConfig(); |
4686 | mCalEditView->show(); | 4685 | mCalEditView->show(); |
4687 | QValueList<int> sizes; | 4686 | QValueList<int> sizes; |
4688 | sizes = mLeftFrame->sizes(); | 4687 | sizes = mLeftFrame->sizes(); |
4689 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4688 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4690 | sizes.clear(); | 4689 | sizes.clear(); |
4691 | sizes << 100; | 4690 | sizes << 100; |
4692 | sizes << 0; | 4691 | sizes << 0; |
4693 | sizes << 0; | 4692 | sizes << 0; |
4694 | sizes << 100; | 4693 | sizes << 100; |
4695 | mLeftFrame->setSizes(sizes); | 4694 | mLeftFrame->setSizes(sizes); |
4696 | } | 4695 | } |
4697 | #if 0 | 4696 | #if 0 |
4698 | sizes = mLeftFrame->sizes(); | 4697 | sizes = mLeftFrame->sizes(); |
4699 | int ccc = 0; | 4698 | int ccc = 0; |
4700 | while ( ccc < sizes.count()) { | 4699 | while ( ccc < sizes.count()) { |
4701 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4700 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4702 | ++ccc; | 4701 | ++ccc; |
4703 | } | 4702 | } |
4704 | #endif | 4703 | #endif |
4705 | 4704 | ||
4706 | } | 4705 | } |
4707 | else { | 4706 | else { |
4708 | mCalEditView->hide(); | 4707 | mCalEditView->hide(); |
4709 | } | 4708 | } |
4710 | #else | 4709 | #else |
4711 | if (visible) mFilterView->show(); | 4710 | if (visible) mFilterView->show(); |
4712 | else mFilterView->hide(); | 4711 | else mFilterView->hide(); |
4713 | #endif | 4712 | #endif |
4714 | } | 4713 | } |
4715 | void CalendarView::toggleFilerEnabled( ) | 4714 | void CalendarView::toggleFilerEnabled( ) |
4716 | { | 4715 | { |
4717 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4716 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4718 | if ( !mFilterView->filtersEnabled() ) | 4717 | if ( !mFilterView->filtersEnabled() ) |
4719 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4718 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4720 | updateUnmanagedViews(); | 4719 | updateUnmanagedViews(); |
4721 | 4720 | ||
4722 | } | 4721 | } |
4723 | void CalendarView::updateFilter() | 4722 | void CalendarView::updateFilter() |
4724 | { | 4723 | { |
4725 | CalFilter *filter = mFilterView->selectedFilter(); | 4724 | CalFilter *filter = mFilterView->selectedFilter(); |
4726 | if (filter) { | 4725 | if (filter) { |
4727 | QString mess; | 4726 | QString mess; |
4728 | if (mFilterView->filtersEnabled()) { | 4727 | if (mFilterView->filtersEnabled()) { |
4729 | mess = i18n("Filter selected: ")+filter->name(); | 4728 | mess = i18n("Filter selected: ")+filter->name(); |
4730 | filter->setEnabled(true); | 4729 | filter->setEnabled(true); |
4731 | } | 4730 | } |
4732 | else filter->setEnabled(false); | 4731 | else filter->setEnabled(false); |
4733 | mCalendar->setFilter(filter); | 4732 | mCalendar->setFilter(filter); |
4734 | updateView(); | 4733 | updateView(); |
4735 | if ( !mess.isEmpty() ) | 4734 | if ( !mess.isEmpty() ) |
4736 | topLevelWidget()->setCaption( mess ); | 4735 | topLevelWidget()->setCaption( mess ); |
4737 | 4736 | ||
4738 | } | 4737 | } |
4739 | emit filtersUpdated(); | 4738 | emit filtersUpdated(); |
4740 | } | 4739 | } |
4741 | 4740 | ||
4742 | void CalendarView::filterEdited() | 4741 | void CalendarView::filterEdited() |
4743 | { | 4742 | { |
4744 | mFilterView->updateFilters(); | 4743 | mFilterView->updateFilters(); |
4745 | updateFilter(); | 4744 | updateFilter(); |
4746 | writeSettings(); | 4745 | writeSettings(); |
4747 | } | 4746 | } |
4748 | 4747 | ||
4749 | 4748 | ||
4750 | void CalendarView::takeOverEvent() | 4749 | void CalendarView::takeOverEvent() |
4751 | { | 4750 | { |
4752 | Incidence *incidence = currentSelection(); | 4751 | Incidence *incidence = currentSelection(); |
4753 | 4752 | ||
4754 | if (!incidence) return; | 4753 | if (!incidence) return; |
4755 | 4754 | ||
4756 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4755 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4757 | incidence->recreate(); | 4756 | incidence->recreate(); |
4758 | incidence->setReadOnly(false); | 4757 | incidence->setReadOnly(false); |
4759 | 4758 | ||
4760 | updateView(); | 4759 | updateView(); |
4761 | } | 4760 | } |
4762 | 4761 | ||
4763 | void CalendarView::takeOverCalendar() | 4762 | void CalendarView::takeOverCalendar() |
4764 | { | 4763 | { |
4765 | // TODO: Create Calendar::allIncidences() function and use it here | 4764 | // TODO: Create Calendar::allIncidences() function and use it here |
4766 | 4765 | ||
4767 | clearAllViews(); | 4766 | clearAllViews(); |
4768 | QPtrList<Event> events = mCalendar->events(); | 4767 | QPtrList<Event> events = mCalendar->events(); |
4769 | for(uint i=0; i<events.count(); ++i) { | 4768 | for(uint i=0; i<events.count(); ++i) { |
4770 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4769 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4771 | events.at(i)->recreate(); | 4770 | events.at(i)->recreate(); |
4772 | events.at(i)->setReadOnly(false); | 4771 | events.at(i)->setReadOnly(false); |
4773 | } | 4772 | } |
4774 | 4773 | ||
4775 | QPtrList<Todo> todos = mCalendar->todos(); | 4774 | QPtrList<Todo> todos = mCalendar->todos(); |
4776 | for(uint i=0; i<todos.count(); ++i) { | 4775 | for(uint i=0; i<todos.count(); ++i) { |
4777 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4776 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4778 | todos.at(i)->recreate(); | 4777 | todos.at(i)->recreate(); |
4779 | todos.at(i)->setReadOnly(false); | 4778 | todos.at(i)->setReadOnly(false); |
4780 | } | 4779 | } |
4781 | 4780 | ||
4782 | QPtrList<Journal> journals = mCalendar->journals(); | 4781 | QPtrList<Journal> journals = mCalendar->journals(); |
4783 | for(uint i=0; i<journals.count(); ++i) { | 4782 | for(uint i=0; i<journals.count(); ++i) { |
4784 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4783 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4785 | journals.at(i)->recreate(); | 4784 | journals.at(i)->recreate(); |
4786 | journals.at(i)->setReadOnly(false); | 4785 | journals.at(i)->setReadOnly(false); |
4787 | } | 4786 | } |
4788 | 4787 | ||
4789 | updateView(); | 4788 | updateView(); |
4790 | } | 4789 | } |
4791 | 4790 | ||
4792 | void CalendarView::showIntro() | 4791 | void CalendarView::showIntro() |
4793 | { | 4792 | { |
4794 | kdDebug() << "To be implemented." << endl; | 4793 | kdDebug() << "To be implemented." << endl; |
4795 | } | 4794 | } |
4796 | 4795 | ||
4797 | QWidgetStack *CalendarView::viewStack() | 4796 | QWidgetStack *CalendarView::viewStack() |
4798 | { | 4797 | { |
4799 | return mRightFrame; | 4798 | return mRightFrame; |
4800 | } | 4799 | } |
4801 | 4800 | ||
4802 | QWidget *CalendarView::leftFrame() | 4801 | QWidget *CalendarView::leftFrame() |
4803 | { | 4802 | { |
4804 | return ( QWidget *)mLeftFrame; | 4803 | return ( QWidget *)mLeftFrame; |
4805 | } | 4804 | } |
4806 | 4805 | ||
4807 | DateNavigator *CalendarView::dateNavigator() | 4806 | DateNavigator *CalendarView::dateNavigator() |
4808 | { | 4807 | { |
4809 | return mNavigator; | 4808 | return mNavigator; |
4810 | } | 4809 | } |
4811 | 4810 | ||
4812 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4811 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4813 | { | 4812 | { |
4814 | return mDateNavigator->navigatorView(); | 4813 | return mDateNavigator->navigatorView(); |
4815 | } | 4814 | } |
4816 | void CalendarView::toggleDateNavigatorWidget() | 4815 | void CalendarView::toggleDateNavigatorWidget() |
4817 | { | 4816 | { |
4818 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4817 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4819 | 4818 | ||
4820 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4819 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4821 | mDateNavigator->hide(); | 4820 | mDateNavigator->hide(); |
4822 | else | 4821 | else |
4823 | mDateNavigator->show(); | 4822 | mDateNavigator->show(); |
4824 | } | 4823 | } |
4825 | void CalendarView::addView(KOrg::BaseView *view) | 4824 | void CalendarView::addView(KOrg::BaseView *view) |
4826 | { | 4825 | { |
4827 | mViewManager->addView(view); | 4826 | mViewManager->addView(view); |
4828 | } | 4827 | } |
4829 | 4828 | ||
4830 | void CalendarView::showView(KOrg::BaseView *view) | 4829 | void CalendarView::showView(KOrg::BaseView *view) |
4831 | { | 4830 | { |
4832 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4831 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4833 | } | 4832 | } |
4834 | 4833 | ||
4835 | Incidence *CalendarView::currentSelection() | 4834 | Incidence *CalendarView::currentSelection() |
4836 | { | 4835 | { |
4837 | return mViewManager->currentSelection(); | 4836 | return mViewManager->currentSelection(); |
4838 | } | 4837 | } |
4839 | void CalendarView::toggleAllDaySize() | 4838 | void CalendarView::toggleAllDaySize() |
4840 | { | 4839 | { |
4841 | /* | 4840 | /* |
4842 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4841 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4843 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4842 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4844 | else | 4843 | else |
4845 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4844 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4846 | */ | 4845 | */ |
4847 | viewManager()->agendaView()->toggleAllDay(); | 4846 | viewManager()->agendaView()->toggleAllDay(); |
4848 | } | 4847 | } |
4849 | void CalendarView::toggleExpand() | 4848 | void CalendarView::toggleExpand() |
4850 | { | 4849 | { |
4851 | // if ( mLeftFrame->isHidden() ) { | 4850 | // if ( mLeftFrame->isHidden() ) { |
4852 | // mLeftFrame->show(); | 4851 | // mLeftFrame->show(); |
4853 | // emit calendarViewExpanded( false ); | 4852 | // emit calendarViewExpanded( false ); |
4854 | // } else { | 4853 | // } else { |
4855 | // mLeftFrame->hide(); | 4854 | // mLeftFrame->hide(); |
4856 | // emit calendarViewExpanded( true ); | 4855 | // emit calendarViewExpanded( true ); |
4857 | // } | 4856 | // } |
4858 | //qDebug(" CalendarView::toggleExpand()"); | 4857 | //qDebug(" CalendarView::toggleExpand()"); |
4859 | globalFlagBlockAgenda = 1; | 4858 | globalFlagBlockAgenda = 1; |
4860 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4859 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4861 | globalFlagBlockAgenda = 5; | 4860 | globalFlagBlockAgenda = 5; |
4862 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4861 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4863 | //mViewManager->showView( 0, true ); | 4862 | //mViewManager->showView( 0, true ); |
4864 | } | 4863 | } |
4865 | 4864 | ||
4866 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4865 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4867 | { | 4866 | { |
4868 | setModified( modified ); | 4867 | setModified( modified ); |
4869 | } | 4868 | } |
4870 | 4869 | ||
4871 | Todo *CalendarView::selectedTodo() | 4870 | Todo *CalendarView::selectedTodo() |
4872 | { | 4871 | { |
4873 | Incidence *incidence = currentSelection(); | 4872 | Incidence *incidence = currentSelection(); |
4874 | if ( incidence && incidence->typeID() == todoID ) { | 4873 | if ( incidence && incidence->typeID() == todoID ) { |
4875 | return static_cast<Todo *>( incidence ); | 4874 | return static_cast<Todo *>( incidence ); |
4876 | } | 4875 | } |
4877 | 4876 | ||
4878 | incidence = mTodoList->selectedIncidences().first(); | 4877 | incidence = mTodoList->selectedIncidences().first(); |
4879 | if ( incidence && incidence->typeID() == todoID ) { | 4878 | if ( incidence && incidence->typeID() == todoID ) { |
4880 | return static_cast<Todo *>( incidence ); | 4879 | return static_cast<Todo *>( incidence ); |
4881 | } | 4880 | } |
4882 | 4881 | ||
4883 | return 0; | 4882 | return 0; |
4884 | } | 4883 | } |
4885 | 4884 | ||
4886 | void CalendarView::showIncidence() | 4885 | void CalendarView::showIncidence() |
4887 | { | 4886 | { |
4888 | mViewerCallerIsSearchDialog = false; | 4887 | mViewerCallerIsSearchDialog = false; |
4889 | Incidence *incidence = currentSelection(); | 4888 | Incidence *incidence = currentSelection(); |
4890 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4889 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4891 | if ( incidence ) { | 4890 | if ( incidence ) { |
4892 | ShowIncidenceVisitor v; | 4891 | ShowIncidenceVisitor v; |
4893 | v.act( incidence, this ); | 4892 | v.act( incidence, this ); |
4894 | } | 4893 | } |
4895 | } | 4894 | } |
4896 | void CalendarView::editIncidenceDescription() | 4895 | void CalendarView::editIncidenceDescription() |
4897 | { | 4896 | { |
4898 | mFlagEditDescription = true; | 4897 | mFlagEditDescription = true; |
4899 | editIncidence(); | 4898 | editIncidence(); |
4900 | mFlagEditDescription = false; | 4899 | mFlagEditDescription = false; |
4901 | } | 4900 | } |
4902 | void CalendarView::editIncidence() | 4901 | void CalendarView::editIncidence() |
4903 | { | 4902 | { |
4904 | // qDebug("editIncidence() "); | 4903 | // qDebug("editIncidence() "); |
4905 | Incidence *incidence = currentSelection(); | 4904 | Incidence *incidence = currentSelection(); |
4906 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4905 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4907 | if ( incidence ) { | 4906 | if ( incidence ) { |
4908 | EditIncidenceVisitor v; | 4907 | EditIncidenceVisitor v; |
4909 | v.act( incidence, this ); | 4908 | v.act( incidence, this ); |
4910 | } | 4909 | } |
4911 | } | 4910 | } |
4912 | 4911 | ||
4913 | void CalendarView::deleteIncidence() | 4912 | void CalendarView::deleteIncidence() |
4914 | { | 4913 | { |
4915 | Incidence *incidence = currentSelection(); | 4914 | Incidence *incidence = currentSelection(); |
4916 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4915 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4917 | if ( incidence ) { | 4916 | if ( incidence ) { |
4918 | deleteIncidence(incidence); | 4917 | deleteIncidence(incidence); |
4919 | } | 4918 | } |
4920 | } | 4919 | } |
4921 | void CalendarView::showIncidence(QString uid) | 4920 | void CalendarView::showIncidence(QString uid) |
4922 | { | 4921 | { |
4923 | Incidence *inc = mCalendar->incidence( uid ); | 4922 | Incidence *inc = mCalendar->incidence( uid ); |
4924 | if ( inc ) | 4923 | if ( inc ) |
4925 | showIncidence( inc ); | 4924 | showIncidence( inc ); |
4926 | } | 4925 | } |
4927 | void CalendarView::showIncidence(Incidence *incidence) | 4926 | void CalendarView::showIncidence(Incidence *incidence) |
4928 | { | 4927 | { |
4929 | mViewerCallerIsSearchDialog = false; | 4928 | mViewerCallerIsSearchDialog = false; |
4930 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4929 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4931 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4930 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4932 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4931 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4933 | mViewerCallerIsSearchDialog = true; | 4932 | mViewerCallerIsSearchDialog = true; |
4934 | } | 4933 | } |
4935 | } | 4934 | } |
4936 | if ( incidence ) { | 4935 | if ( incidence ) { |
4937 | ShowIncidenceVisitor v; | 4936 | ShowIncidenceVisitor v; |
4938 | v.act( incidence, this ); | 4937 | v.act( incidence, this ); |
4939 | } | 4938 | } |
4940 | } | 4939 | } |
4941 | 4940 | ||
4942 | void CalendarView::editIncidence(Incidence *incidence) | 4941 | void CalendarView::editIncidence(Incidence *incidence) |
4943 | { | 4942 | { |
4944 | if ( incidence ) { | 4943 | if ( incidence ) { |
4945 | 4944 | ||
4946 | EditIncidenceVisitor v; | 4945 | EditIncidenceVisitor v; |
4947 | v.act( incidence, this ); | 4946 | v.act( incidence, this ); |
4948 | 4947 | ||
4949 | } | 4948 | } |
4950 | } | 4949 | } |
4951 | 4950 | ||
4952 | void CalendarView::deleteIncidence(Incidence *incidence) | 4951 | void CalendarView::deleteIncidence(Incidence *incidence) |
4953 | { | 4952 | { |
4954 | //qDebug(" CalendarView::deleteIncidence "); | 4953 | //qDebug(" CalendarView::deleteIncidence "); |
4955 | if ( incidence == 0 ) { | 4954 | if ( incidence == 0 ) { |
4956 | updateView(); | 4955 | updateView(); |
4957 | emit updateSearchDialog(); | 4956 | emit updateSearchDialog(); |
4958 | return; | 4957 | return; |
4959 | } | 4958 | } |
4960 | if ( incidence ) { | 4959 | if ( incidence ) { |
4961 | DeleteIncidenceVisitor v; | 4960 | DeleteIncidenceVisitor v; |
4962 | v.act( incidence, this ); | 4961 | v.act( incidence, this ); |
4963 | } | 4962 | } |
4964 | } | 4963 | } |
4965 | 4964 | ||
4966 | 4965 | ||
4967 | void CalendarView::lookForOutgoingMessages() | 4966 | void CalendarView::lookForOutgoingMessages() |
4968 | { | 4967 | { |
4969 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4968 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4970 | ogd->loadMessages(); | 4969 | ogd->loadMessages(); |
4971 | } | 4970 | } |
4972 | 4971 | ||
4973 | void CalendarView::lookForIncomingMessages() | 4972 | void CalendarView::lookForIncomingMessages() |
4974 | { | 4973 | { |
4975 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4974 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4976 | icd->retrieve(); | 4975 | icd->retrieve(); |
4977 | } | 4976 | } |
4978 | 4977 | ||
4979 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4978 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4980 | { | 4979 | { |
4981 | bool deleteTodo = true; | 4980 | bool deleteTodo = true; |
4982 | QPtrList<Incidence> subTodos; | 4981 | QPtrList<Incidence> subTodos; |
4983 | Incidence *aTodo; | 4982 | Incidence *aTodo; |
4984 | subTodos = t->relations(); | 4983 | subTodos = t->relations(); |
4985 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4984 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4986 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4985 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4987 | deleteTodo = false; | 4986 | deleteTodo = false; |
4988 | } | 4987 | } |
4989 | if ( deleteTodo ) { | 4988 | if ( deleteTodo ) { |
4990 | if ( t->isCompleted() && !t->doesRecur()) { | 4989 | if ( t->isCompleted() && !t->doesRecur()) { |
4991 | checkExternalId( t ); | 4990 | checkExternalId( t ); |
4992 | mCalendar->deleteTodo( t ); | 4991 | mCalendar->deleteTodo( t ); |
4993 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4992 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4994 | } | 4993 | } |
4995 | else | 4994 | else |
4996 | deleteTodo = false; | 4995 | deleteTodo = false; |
4997 | } | 4996 | } |
4998 | return deleteTodo; | 4997 | return deleteTodo; |
4999 | 4998 | ||
5000 | } | 4999 | } |
5001 | void CalendarView::purgeCompleted() | 5000 | void CalendarView::purgeCompleted() |
5002 | { | 5001 | { |
5003 | int result = KMessageBox::warningContinueCancel(this, | 5002 | int result = KMessageBox::warningContinueCancel(this, |
5004 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 5003 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
5005 | 5004 | ||
5006 | if (result == KMessageBox::Continue) { | 5005 | if (result == KMessageBox::Continue) { |
5007 | 5006 | ||
5008 | QPtrList<Todo> todoCal; | 5007 | QPtrList<Todo> todoCal; |
5009 | QPtrList<Todo> rootTodos; | 5008 | QPtrList<Todo> rootTodos; |
5010 | //QPtrList<Incidence> rel; | 5009 | //QPtrList<Incidence> rel; |
5011 | Todo *aTodo; | 5010 | Todo *aTodo; |
5012 | todoCal = calendar()->todos(); | 5011 | todoCal = calendar()->todos(); |
5013 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 5012 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
5014 | if ( !aTodo->relatedTo() ) | 5013 | if ( !aTodo->relatedTo() ) |
5015 | rootTodos.append( aTodo ); | 5014 | rootTodos.append( aTodo ); |
5016 | } | 5015 | } |
5017 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 5016 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
5018 | removeCompletedSubTodos( aTodo ); | 5017 | removeCompletedSubTodos( aTodo ); |
5019 | } | 5018 | } |
5020 | 5019 | ||
5021 | updateView(); | 5020 | updateView(); |
5022 | } | 5021 | } |
5023 | } | 5022 | } |
5024 | 5023 | ||
5025 | void CalendarView::slotCalendarChanged() | 5024 | void CalendarView::slotCalendarChanged() |
5026 | { | 5025 | { |
5027 | ; | 5026 | ; |
5028 | } | 5027 | } |
5029 | 5028 | ||
5030 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 5029 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
5031 | { | 5030 | { |
5032 | //qDebug("CalendarView::keyPressEvent "); | 5031 | //qDebug("CalendarView::keyPressEvent "); |
5033 | e->ignore(); | 5032 | e->ignore(); |
5034 | } | 5033 | } |
5035 | 5034 | ||
5036 | 5035 | ||
5037 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 5036 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) |
5038 | { | 5037 | { |
5039 | 5038 | ||
5040 | if ( manager != mSyncManager) | 5039 | if ( manager != mSyncManager) |
5041 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 5040 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
5042 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 5041 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
5043 | qDebug("KO: SyncKDE request detected!"); | 5042 | qDebug("KO: SyncKDE request detected!"); |
5044 | } | 5043 | } |
5045 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5044 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5046 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5045 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5047 | return syncCalendar( filename, mode ); | 5046 | if ( !resource.isEmpty() ) { |
5047 | int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | ||
5048 | qDebug( "KO: Sync request for resource: %s", resource.latin1() ); | ||
5049 | |||
5050 | if ( !exclusiveSyncResource ) { | ||
5051 | qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); | ||
5052 | return false; | ||
5053 | } | ||
5054 | mCalendar->setDefaultCalendar( exclusiveSyncResource ); | ||
5055 | mCalendar->setDefaultCalendarEnabledOnly(); | ||
5056 | } | ||
5057 | bool result = syncCalendar( filename, mode ); | ||
5058 | if ( !resource.isEmpty() ) | ||
5059 | restoreCalendarSettings(); | ||
5060 | return result; | ||
5048 | } | 5061 | } |
5049 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 5062 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
5050 | { | 5063 | { |
5051 | //mSyncManager = manager; | 5064 | //mSyncManager = manager; |
5052 | if ( manager != mSyncManager) | 5065 | if ( manager != mSyncManager) |
5053 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 5066 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
5054 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5067 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5055 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5068 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5056 | if ( resource == "sharp" ) | 5069 | if ( resource == "sharp" ) |
5057 | syncExternal( 0 ); | 5070 | syncExternal( 0 ); |
5058 | if ( resource == "phone" ) | 5071 | if ( resource == "phone" ) |
5059 | syncExternal( 1 ); | 5072 | syncExternal( 1 ); |
5060 | // pending setmodified | 5073 | // pending setmodified |
5061 | return true; | 5074 | return true; |
5062 | } | 5075 | } |
5063 | void CalendarView::setSyncManager(KSyncManager* manager) | 5076 | void CalendarView::setSyncManager(KSyncManager* manager) |
5064 | { | 5077 | { |
5065 | mSyncManager = manager; | 5078 | mSyncManager = manager; |
5066 | } | 5079 | } |
5067 | 5080 | ||
5068 | void CalendarView::removeSyncInfo( QString syncProfile) | 5081 | void CalendarView::removeSyncInfo( QString syncProfile) |
5069 | { | 5082 | { |
5070 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 5083 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
5071 | mCalendar->removeSyncInfo( syncProfile ); | 5084 | mCalendar->removeSyncInfo( syncProfile ); |
5072 | 5085 | ||
5073 | } | 5086 | } |
5074 | 5087 | ||
5075 | void CalendarView::undo_delete() | 5088 | void CalendarView::undo_delete() |
5076 | { | 5089 | { |
5077 | //qDebug("undo_delete() "); | 5090 | //qDebug("undo_delete() "); |
5078 | Incidence* undo = mCalendar->undoIncidence(); | 5091 | Incidence* undo = mCalendar->undoIncidence(); |
5079 | if ( !undo ) { | 5092 | if ( !undo ) { |
5080 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 5093 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
5081 | i18n("KO/Pi")); | 5094 | i18n("KO/Pi")); |
5082 | return; | 5095 | return; |
5083 | } | 5096 | } |
5084 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 5097 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
5085 | i18n("\nAre you sure you want\nto restore this?"), | 5098 | i18n("\nAre you sure you want\nto restore this?"), |
5086 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 5099 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
5087 | mCalendar->undoDeleteIncidence(); | 5100 | mCalendar->undoDeleteIncidence(); |
5088 | updateView(); | 5101 | updateView(); |
5089 | } | 5102 | } |
5090 | } | 5103 | } |
5091 | 5104 | ||
5092 | void CalendarView::slotViewerClosed() | 5105 | void CalendarView::slotViewerClosed() |
5093 | { | 5106 | { |
5094 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 5107 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
5095 | } | 5108 | } |
5096 | 5109 | ||
5097 | void CalendarView::resetFocus() | 5110 | void CalendarView::resetFocus() |
5098 | { | 5111 | { |
5099 | if ( mViewerCallerIsSearchDialog ) { | 5112 | if ( mViewerCallerIsSearchDialog ) { |
5100 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 5113 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
5101 | mDialogManager->getSearchDialog()->raise(); | 5114 | mDialogManager->getSearchDialog()->raise(); |
5102 | mDialogManager->getSearchDialog()->setActiveWindow(); | 5115 | mDialogManager->getSearchDialog()->setActiveWindow(); |
5103 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 5116 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
5104 | } else | 5117 | } else |
5105 | mViewerCallerIsSearchDialog = false; | 5118 | mViewerCallerIsSearchDialog = false; |
5106 | } | 5119 | } |
5107 | if ( !mViewerCallerIsSearchDialog ) { | 5120 | if ( !mViewerCallerIsSearchDialog ) { |
5108 | //mViewManager->currentView()->setFocus(); | 5121 | //mViewManager->currentView()->setFocus(); |
5109 | //qDebug("sssssssssssssssset focus "); | 5122 | //qDebug("sssssssssssssssset focus "); |
5110 | topLevelWidget()->raise(); | 5123 | topLevelWidget()->raise(); |
5111 | setActiveWindow(); | 5124 | setActiveWindow(); |
5112 | //setFocus(); | 5125 | //setFocus(); |
5113 | } | 5126 | } |
5114 | mViewerCallerIsSearchDialog = false; | 5127 | mViewerCallerIsSearchDialog = false; |
5115 | } | 5128 | } |
5116 | 5129 | ||
5117 | void CalendarView::showNextAlarms() | 5130 | void CalendarView::showNextAlarms() |
5118 | { | 5131 | { |
5119 | QString message; | 5132 | QString message; |
5120 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 5133 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
5121 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 5134 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
5122 | QString sum = mCalendar->nextSummary(); | 5135 | QString sum = mCalendar->nextSummary(); |
5123 | QDateTime nextA = mNextAlarmDateTime; | 5136 | QDateTime nextA = mNextAlarmDateTime; |
5124 | QDateTime cur = QDateTime::currentDateTime(); | 5137 | QDateTime cur = QDateTime::currentDateTime(); |
5125 | int secs = cur.secsTo( nextA ); | 5138 | int secs = cur.secsTo( nextA ); |
5126 | int min = secs /60; | 5139 | int min = secs /60; |
5127 | int hours = min /60; | 5140 | int hours = min /60; |
5128 | min = min % 60; | 5141 | min = min % 60; |
5129 | int days = hours /24; | 5142 | int days = hours /24; |
5130 | hours = hours % 24; | 5143 | hours = hours % 24; |
5131 | 5144 | ||
5132 | //message = i18n("The next alarm is in:\n"); | 5145 | //message = i18n("The next alarm is in:\n"); |
5133 | if ( days > 1 ) | 5146 | if ( days > 1 ) |
5134 | message += i18n("%1 days\n").arg( days ); | 5147 | message += i18n("%1 days\n").arg( days ); |
5135 | else if ( days == 1 ) | 5148 | else if ( days == 1 ) |
5136 | message += i18n("1 day\n"); | 5149 | message += i18n("1 day\n"); |
5137 | if ( hours > 1 ) | 5150 | if ( hours > 1 ) |
5138 | message += i18n("%1 hours\n").arg( hours ); | 5151 | message += i18n("%1 hours\n").arg( hours ); |
5139 | else if ( hours == 1 ) | 5152 | else if ( hours == 1 ) |
5140 | message += i18n("1 hour\n"); | 5153 | message += i18n("1 hour\n"); |
5141 | if ( min > 1 ) | 5154 | if ( min > 1 ) |
5142 | message += i18n("%1 minutes\n").arg( min ); | 5155 | message += i18n("%1 minutes\n").arg( min ); |
5143 | else if ( min == 1 ) | 5156 | else if ( min == 1 ) |
5144 | message += i18n("1 minute\n"); | 5157 | message += i18n("1 minute\n"); |
5145 | if ( message.isEmpty() ) | 5158 | if ( message.isEmpty() ) |
5146 | message = i18n("The next alarm is in\nless than one minute!"); | 5159 | message = i18n("The next alarm is in\nless than one minute!"); |
5147 | else | 5160 | else |
5148 | message = i18n("The next alarm is in:\n") + message; | 5161 | message = i18n("The next alarm is in:\n") + message; |
5149 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 5162 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
5150 | } else { | 5163 | } else { |
5151 | message = i18n("There is no next alarm."); | 5164 | message = i18n("There is no next alarm."); |
5152 | 5165 | ||
5153 | } | 5166 | } |
5154 | #ifdef DESKTOP_VERSION | 5167 | #ifdef DESKTOP_VERSION |
5155 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 5168 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
5156 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 5169 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
5157 | message += i18n("Enable it in the settings menu, TAB alarm."); | 5170 | message += i18n("Enable it in the settings menu, TAB alarm."); |
5158 | } | 5171 | } |
5159 | 5172 | ||
5160 | #endif | 5173 | #endif |
5161 | KMessageBox::information( this, message); | 5174 | KMessageBox::information( this, message); |
5162 | } | 5175 | } |
5163 | 5176 | ||
5164 | void CalendarView::displayCalendarInfo( int id ) | 5177 | void CalendarView::displayCalendarInfo( int id ) |
5165 | { | 5178 | { |
5166 | int e, t,j; | 5179 | int e, t,j; |
5167 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); | 5180 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); |
5168 | QString name = kkf->mName; | 5181 | QString name = kkf->mName; |
5169 | mCalendar->getIncidenceCount( id, e, t, j ); | 5182 | mCalendar->getIncidenceCount( id, e, t, j ); |
5170 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); | 5183 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); |
5171 | QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); | 5184 | QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); |
5172 | mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); | 5185 | mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); |
5173 | KMessageBox::information( this, mess ); | 5186 | KMessageBox::information( this, mess ); |
5174 | 5187 | ||
5175 | 5188 | ||
5176 | } | 5189 | } |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 80f7ed4..f85b6a3 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,675 +1,675 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #include <qscrollbar.h> | 33 | #include <qscrollbar.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qtopia/ir.h> | 35 | #include <qtopia/ir.h> |
36 | #else | 36 | #else |
37 | #define Ir char | 37 | #define Ir char |
38 | #endif | 38 | #endif |
39 | #include <libkcal/calendar.h> | 39 | #include <libkcal/calendar.h> |
40 | #include <libkcal/scheduler.h> | 40 | #include <libkcal/scheduler.h> |
41 | #include <libkcal/calendarresources.h> | 41 | #include <libkcal/calendarresources.h> |
42 | #include <libkcal/resourcecalendar.h> | 42 | #include <libkcal/resourcecalendar.h> |
43 | #include <KDGanttMinimizeSplitter.h> | 43 | #include <KDGanttMinimizeSplitter.h> |
44 | 44 | ||
45 | #include <korganizer/calendarviewbase.h> | 45 | #include <korganizer/calendarviewbase.h> |
46 | 46 | ||
47 | #include <ksyncmanager.h> | 47 | #include <ksyncmanager.h> |
48 | //#include <koprefs.h> | 48 | //#include <koprefs.h> |
49 | 49 | ||
50 | class QWidgetStack; | 50 | class QWidgetStack; |
51 | class QSplitter; | 51 | class QSplitter; |
52 | class KopiCalendarFile; | 52 | class KopiCalendarFile; |
53 | class CalPrinter; | 53 | class CalPrinter; |
54 | class KOFilterView; | 54 | class KOFilterView; |
55 | class KOCalEditView; | 55 | class KOCalEditView; |
56 | class KOViewManager; | 56 | class KOViewManager; |
57 | class KODialogManager; | 57 | class KODialogManager; |
58 | class KOTodoView; | 58 | class KOTodoView; |
59 | class KDateNavigator; | 59 | class KDateNavigator; |
60 | class DateNavigatorContainer; | 60 | class DateNavigatorContainer; |
61 | class DateNavigator; | 61 | class DateNavigator; |
62 | class KOIncidenceEditor; | 62 | class KOIncidenceEditor; |
63 | class KDatePicker; | 63 | class KDatePicker; |
64 | class ResourceView; | 64 | class ResourceView; |
65 | class KOEventEditor; | 65 | class KOEventEditor; |
66 | class KOTodoEditor ; | 66 | class KOTodoEditor ; |
67 | class KOEventViewerDialog; | 67 | class KOEventViewerDialog; |
68 | class KOBeamPrefs; | 68 | class KOBeamPrefs; |
69 | class KSyncProfile; | 69 | class KSyncProfile; |
70 | class AlarmDialog; | 70 | class AlarmDialog; |
71 | class KCal::Attendee; | 71 | class KCal::Attendee; |
72 | 72 | ||
73 | namespace KCal { class FileStorage; } | 73 | namespace KCal { class FileStorage; } |
74 | 74 | ||
75 | using namespace KCal; | 75 | using namespace KCal; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | This is the main calendar widget. It provides the different vies on t he | 78 | This is the main calendar widget. It provides the different vies on t he |
79 | calendar data as well as the date navigator. It also handles synchronisation | 79 | calendar data as well as the date navigator. It also handles synchronisation |
80 | of the different views and controls the different dialogs like preferences, | 80 | of the different views and controls the different dialogs like preferences, |
81 | event editor, search dialog etc. | 81 | event editor, search dialog etc. |
82 | 82 | ||
83 | @short main calendar view widget | 83 | @short main calendar view widget |
84 | @author Cornelius Schumacher | 84 | @author Cornelius Schumacher |
85 | */ | 85 | */ |
86 | 86 | ||
87 | #include <qtextbrowser.h> | 87 | #include <qtextbrowser.h> |
88 | #include <qtextcodec.h> | 88 | #include <qtextcodec.h> |
89 | 89 | ||
90 | class MissedAlarmTextBrowser : public QTextBrowser { | 90 | class MissedAlarmTextBrowser : public QTextBrowser { |
91 | Q_OBJECT | 91 | Q_OBJECT |
92 | public: | 92 | public: |
93 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); | 93 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); |
94 | ~MissedAlarmTextBrowser(); | 94 | ~MissedAlarmTextBrowser(); |
95 | void setSource(const QString & n); | 95 | void setSource(const QString & n); |
96 | 96 | ||
97 | private: | 97 | private: |
98 | Incidence * getNextInc(QDateTime start ); | 98 | Incidence * getNextInc(QDateTime start ); |
99 | QPtrList<Incidence> mAlarms; | 99 | QPtrList<Incidence> mAlarms; |
100 | signals: | 100 | signals: |
101 | void showIncidence( QString uid); | 101 | void showIncidence( QString uid); |
102 | }; | 102 | }; |
103 | 103 | ||
104 | 104 | ||
105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
106 | { | 106 | { |
107 | Q_OBJECT | 107 | Q_OBJECT |
108 | public: | 108 | public: |
109 | /** | 109 | /** |
110 | Constructs a new calendar view widget. | 110 | Constructs a new calendar view widget. |
111 | 111 | ||
112 | @param calendar calendar document | 112 | @param calendar calendar document |
113 | @param parent parent window | 113 | @param parent parent window |
114 | @param name Qt internal widget object name | 114 | @param name Qt internal widget object name |
115 | */ | 115 | */ |
116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
117 | const char *name = 0 ); | 117 | const char *name = 0 ); |
118 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 118 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
119 | const char *name = 0 ); | 119 | const char *name = 0 ); |
120 | virtual ~CalendarView(); | 120 | virtual ~CalendarView(); |
121 | 121 | ||
122 | Calendar *calendar() { return mCalendar; } | 122 | Calendar *calendar() { return mCalendar; } |
123 | 123 | ||
124 | KOViewManager *viewManager(); | 124 | KOViewManager *viewManager(); |
125 | KODialogManager *dialogManager(); | 125 | KODialogManager *dialogManager(); |
126 | 126 | ||
127 | QDate startDate(); | 127 | QDate startDate(); |
128 | QDate endDate(); | 128 | QDate endDate(); |
129 | 129 | ||
130 | QWidgetStack *viewStack(); | 130 | QWidgetStack *viewStack(); |
131 | QWidget *leftFrame(); | 131 | QWidget *leftFrame(); |
132 | 132 | ||
133 | DateNavigator *dateNavigator(); | 133 | DateNavigator *dateNavigator(); |
134 | KDateNavigator *dateNavigatorWidget(); | 134 | KDateNavigator *dateNavigatorWidget(); |
135 | 135 | ||
136 | void addView(KOrg::BaseView *); | 136 | void addView(KOrg::BaseView *); |
137 | void showView(KOrg::BaseView *); | 137 | void showView(KOrg::BaseView *); |
138 | KOEventViewerDialog* getEventViewerDialog(); | 138 | KOEventViewerDialog* getEventViewerDialog(); |
139 | Incidence *currentSelection(); | 139 | Incidence *currentSelection(); |
140 | void checkSuspendAlarm(); | 140 | void checkSuspendAlarm(); |
141 | void mergeFile( QString fn ); | 141 | void mergeFile( QString fn ); |
142 | 142 | ||
143 | signals: | 143 | signals: |
144 | void save (); | 144 | void save (); |
145 | void saveStopTimer (); | 145 | void saveStopTimer (); |
146 | void tempDisableBR(bool); | 146 | void tempDisableBR(bool); |
147 | /** This todo has been modified */ | 147 | /** This todo has been modified */ |
148 | void todoModified(Todo *, int); | 148 | void todoModified(Todo *, int); |
149 | 149 | ||
150 | /** when change is made to options dialog, the topwidget will catch this | 150 | /** when change is made to options dialog, the topwidget will catch this |
151 | * and emit this signal which notifies all widgets which have registered | 151 | * and emit this signal which notifies all widgets which have registered |
152 | * for notification to update their settings. */ | 152 | * for notification to update their settings. */ |
153 | void configChanged(); | 153 | void configChanged(); |
154 | /** emitted when the topwidget is closing down, so that any attached | 154 | /** emitted when the topwidget is closing down, so that any attached |
155 | child windows can also close. */ | 155 | child windows can also close. */ |
156 | void closingDown(); | 156 | void closingDown(); |
157 | /** emitted right before we die */ | 157 | /** emitted right before we die */ |
158 | void closed(QWidget *); | 158 | void closed(QWidget *); |
159 | 159 | ||
160 | /** Emitted when state of modified flag changes */ | 160 | /** Emitted when state of modified flag changes */ |
161 | void modifiedChanged(bool); | 161 | void modifiedChanged(bool); |
162 | void signalmodified(); | 162 | void signalmodified(); |
163 | 163 | ||
164 | /** Emitted when state of read-only flag changes */ | 164 | /** Emitted when state of read-only flag changes */ |
165 | void readOnlyChanged(bool); | 165 | void readOnlyChanged(bool); |
166 | 166 | ||
167 | /** Emitted when the unit of navigation changes */ | 167 | /** Emitted when the unit of navigation changes */ |
168 | void changeNavStringPrev(const QString &); | 168 | void changeNavStringPrev(const QString &); |
169 | void changeNavStringNext(const QString &); | 169 | void changeNavStringNext(const QString &); |
170 | 170 | ||
171 | /** Emitted when state of events selection has changed and user is organizer*/ | 171 | /** Emitted when state of events selection has changed and user is organizer*/ |
172 | void organizerEventsSelected(bool); | 172 | void organizerEventsSelected(bool); |
173 | /** Emitted when state of events selection has changed and user is attendee*/ | 173 | /** Emitted when state of events selection has changed and user is attendee*/ |
174 | void groupEventsSelected(bool); | 174 | void groupEventsSelected(bool); |
175 | /** | 175 | /** |
176 | Emitted when an incidence gets selected. If the selection is cleared the | 176 | Emitted when an incidence gets selected. If the selection is cleared the |
177 | signal is emitted with 0 as argument. | 177 | signal is emitted with 0 as argument. |
178 | */ | 178 | */ |
179 | void incidenceSelected( Incidence * ); | 179 | void incidenceSelected( Incidence * ); |
180 | /** Emitted, when a todoitem is selected or deselected. */ | 180 | /** Emitted, when a todoitem is selected or deselected. */ |
181 | void todoSelected( bool ); | 181 | void todoSelected( bool ); |
182 | 182 | ||
183 | /** | 183 | /** |
184 | Emitted, when clipboard content changes. Parameter indicates if paste | 184 | Emitted, when clipboard content changes. Parameter indicates if paste |
185 | is possible or not. | 185 | is possible or not. |
186 | */ | 186 | */ |
187 | void pasteEnabled(bool); | 187 | void pasteEnabled(bool); |
188 | 188 | ||
189 | /** Emitted, when the number of incoming messages has changed. */ | 189 | /** Emitted, when the number of incoming messages has changed. */ |
190 | void numIncomingChanged(int); | 190 | void numIncomingChanged(int); |
191 | 191 | ||
192 | /** Emitted, when the number of outgoing messages has changed. */ | 192 | /** Emitted, when the number of outgoing messages has changed. */ |
193 | void numOutgoingChanged(int); | 193 | void numOutgoingChanged(int); |
194 | 194 | ||
195 | /** Send status message, which can e.g. be displayed in the status bar. */ | 195 | /** Send status message, which can e.g. be displayed in the status bar. */ |
196 | void statusMessage(const QString &); | 196 | void statusMessage(const QString &); |
197 | 197 | ||
198 | void calendarViewExpanded( bool ); | 198 | void calendarViewExpanded( bool ); |
199 | void updateSearchDialog(); | 199 | void updateSearchDialog(); |
200 | void filtersUpdated(); | 200 | void filtersUpdated(); |
201 | 201 | ||
202 | 202 | ||
203 | public slots: | 203 | public slots: |
204 | void displayCalendarInfo( int id ); | 204 | void displayCalendarInfo( int id ); |
205 | void nextConflict( bool all, bool allday ); | 205 | void nextConflict( bool all, bool allday ); |
206 | void conflictAll(); | 206 | void conflictAll(); |
207 | void conflictAllday(); | 207 | void conflictAllday(); |
208 | void conflictNotAll(); | 208 | void conflictNotAll(); |
209 | void setCalReadOnly( int id, bool readO ); | 209 | void setCalReadOnly( int id, bool readO ); |
210 | void checkAlarms(); | 210 | void checkAlarms(); |
211 | void checkFiles(); | 211 | void checkFiles(); |
212 | void slotprintSelInc(); | 212 | void slotprintSelInc(); |
213 | void showNextAlarms(); | 213 | void showNextAlarms(); |
214 | void showOpenError(); | 214 | void showOpenError(); |
215 | void watchSavedFile(); | 215 | void watchSavedFile(); |
216 | void recheckTimerAlarm(); | 216 | void recheckTimerAlarm(); |
217 | void checkNextTimerAlarm(); | 217 | void checkNextTimerAlarm(); |
218 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 218 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
219 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 219 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
220 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 220 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
221 | 221 | ||
222 | /** options dialog made a changed to the configuration. we catch this | 222 | /** options dialog made a changed to the configuration. we catch this |
223 | * and notify all widgets which need to update their configuration. */ | 223 | * and notify all widgets which need to update their configuration. */ |
224 | void updateConfig(); | 224 | void updateConfig(); |
225 | 225 | ||
226 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 226 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
227 | const QStringList& anniversaryList, const QStringList& realNameList, | 227 | const QStringList& anniversaryList, const QStringList& realNameList, |
228 | const QStringList& emailList, const QStringList& assembledNameList, | 228 | const QStringList& emailList, const QStringList& assembledNameList, |
229 | const QStringList& uidList); | 229 | const QStringList& uidList); |
230 | 230 | ||
231 | /** | 231 | /** |
232 | Load calendar from file \a filename. If \a merge is true, load | 232 | Load calendar from file \a filename. If \a merge is true, load |
233 | calendar into existing one, if it is false, clear calendar, before | 233 | calendar into existing one, if it is false, clear calendar, before |
234 | loading. Return true, if calendar could be successfully loaded. | 234 | loading. Return true, if calendar could be successfully loaded. |
235 | */ | 235 | */ |
236 | bool openCalendar(QString filename, bool merge=false); | 236 | bool openCalendar(QString filename, bool merge=false); |
237 | bool loadCalendars(); | 237 | bool loadCalendars(); |
238 | bool saveCalendars(); | 238 | bool saveCalendars(); |
239 | bool restoreCalendarSettings(); | 239 | bool restoreCalendarSettings(); |
240 | bool addCalendar( KopiCalendarFile * ); | 240 | bool addCalendar( KopiCalendarFile * ); |
241 | void addCalendarId( int id ); | 241 | void addCalendarId( int id ); |
242 | bool syncCalendar(QString filename,int mode = 0 ); | 242 | bool syncCalendar(QString filename,int mode = 0 ); |
243 | 243 | ||
244 | /** | 244 | /** |
245 | Save calendar data to file. Return true if calendar could be | 245 | Save calendar data to file. Return true if calendar could be |
246 | successfully saved. | 246 | successfully saved. |
247 | */ | 247 | */ |
248 | bool saveCalendar(QString filename); | 248 | bool saveCalendar(QString filename); |
249 | 249 | ||
250 | /** | 250 | /** |
251 | Close calendar. Clear calendar data and reset views to display an empty | 251 | Close calendar. Clear calendar data and reset views to display an empty |
252 | calendar. | 252 | calendar. |
253 | */ | 253 | */ |
254 | void closeCalendar(); | 254 | void closeCalendar(); |
255 | 255 | ||
256 | /** Archive old events of calendar */ | 256 | /** Archive old events of calendar */ |
257 | void archiveCalendar(); | 257 | void archiveCalendar(); |
258 | 258 | ||
259 | void showIncidence(); | 259 | void showIncidence(); |
260 | void editIncidence(); | 260 | void editIncidence(); |
261 | void editIncidenceDescription(); | 261 | void editIncidenceDescription(); |
262 | void deleteIncidence(); | 262 | void deleteIncidence(); |
263 | void cloneIncidence(); | 263 | void cloneIncidence(); |
264 | void moveIncidence(); | 264 | void moveIncidence(); |
265 | void beamIncidence(); | 265 | void beamIncidence(); |
266 | void toggleCancelIncidence(); | 266 | void toggleCancelIncidence(); |
267 | 267 | ||
268 | /** create an editeventwin with supplied date/time, and if bool is true, | 268 | /** create an editeventwin with supplied date/time, and if bool is true, |
269 | * make the event take all day. */ | 269 | * make the event take all day. */ |
270 | void newEvent(QDateTime, QDateTime, bool allDay ); | 270 | void newEvent(QDateTime, QDateTime, bool allDay ); |
271 | void newEvent(QDateTime, QDateTime); | 271 | void newEvent(QDateTime, QDateTime); |
272 | void newEvent(QDateTime fh); | 272 | void newEvent(QDateTime fh); |
273 | void newEvent(QDate dt); | 273 | void newEvent(QDate dt); |
274 | /** create new event without having a date hint. Takes current date as | 274 | /** create new event without having a date hint. Takes current date as |
275 | default hint. */ | 275 | default hint. */ |
276 | void newEvent(); | 276 | void newEvent(); |
277 | void newFloatingEvent(); | 277 | void newFloatingEvent(); |
278 | 278 | ||
279 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 279 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
280 | void showIncidence(Incidence *); | 280 | void showIncidence(Incidence *); |
281 | void showIncidence(QString uid); | 281 | void showIncidence(QString uid); |
282 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 282 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
283 | void editIncidence(Incidence *); | 283 | void editIncidence(Incidence *); |
284 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 284 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
285 | void deleteIncidence(Incidence *); | 285 | void deleteIncidence(Incidence *); |
286 | void cloneIncidence(Incidence *); | 286 | void cloneIncidence(Incidence *); |
287 | void cancelIncidence(Incidence *); | 287 | void cancelIncidence(Incidence *); |
288 | /** Create an editor for the supplied event. */ | 288 | /** Create an editor for the supplied event. */ |
289 | void editEvent(Event *); | 289 | void editEvent(Event *); |
290 | /** Delete the supplied event. */ | 290 | /** Delete the supplied event. */ |
291 | void deleteEvent(Event *); | 291 | void deleteEvent(Event *); |
292 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 292 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
293 | found. */ | 293 | found. */ |
294 | bool deleteEvent(const QString &uid); | 294 | bool deleteEvent(const QString &uid); |
295 | /** Create a read-only viewer dialog for the supplied event. */ | 295 | /** Create a read-only viewer dialog for the supplied event. */ |
296 | void showEvent(Event *); | 296 | void showEvent(Event *); |
297 | 297 | ||
298 | void editJournal(Journal *); | 298 | void editJournal(Journal *); |
299 | void showJournal(Journal *); | 299 | void showJournal(Journal *); |
300 | void deleteJournal(Journal *); | 300 | void deleteJournal(Journal *); |
301 | /** Create an editor dialog for a todo */ | 301 | /** Create an editor dialog for a todo */ |
302 | void editTodo(Todo *); | 302 | void editTodo(Todo *); |
303 | /** Create a read-only viewer dialog for the supplied todo */ | 303 | /** Create a read-only viewer dialog for the supplied todo */ |
304 | void showTodo(Todo *); | 304 | void showTodo(Todo *); |
305 | /** create new todo */ | 305 | /** create new todo */ |
306 | void newTodo(); | 306 | void newTodo(); |
307 | void newTodoDateTime(QDateTime, bool allday); | 307 | void newTodoDateTime(QDateTime, bool allday); |
308 | /** create new todo with a parent todo */ | 308 | /** create new todo with a parent todo */ |
309 | void newSubTodo(); | 309 | void newSubTodo(); |
310 | /** create new todo with a parent todo */ | 310 | /** create new todo with a parent todo */ |
311 | void newSubTodo(Todo *); | 311 | void newSubTodo(Todo *); |
312 | /** Delete todo */ | 312 | /** Delete todo */ |
313 | void deleteTodo(Todo *); | 313 | void deleteTodo(Todo *); |
314 | 314 | ||
315 | 315 | ||
316 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 316 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
317 | * emitted as result. */ | 317 | * emitted as result. */ |
318 | void checkClipboard(); | 318 | void checkClipboard(); |
319 | 319 | ||
320 | /** using the KConfig associated with the kapp variable, read in the | 320 | /** using the KConfig associated with the kapp variable, read in the |
321 | * settings from the config file. | 321 | * settings from the config file. |
322 | */ | 322 | */ |
323 | void readSettings(); | 323 | void readSettings(); |
324 | 324 | ||
325 | /** write current state to config file. */ | 325 | /** write current state to config file. */ |
326 | void writeSettings(); | 326 | void writeSettings(); |
327 | 327 | ||
328 | /** read settings for calendar filters */ | 328 | /** read settings for calendar filters */ |
329 | void readFilterSettings(KConfig *config); | 329 | void readFilterSettings(KConfig *config); |
330 | 330 | ||
331 | /** write settings for calendar filters */ | 331 | /** write settings for calendar filters */ |
332 | void writeFilterSettings(KConfig *config); | 332 | void writeFilterSettings(KConfig *config); |
333 | 333 | ||
334 | /** passes on the message that an event has changed to the currently | 334 | /** passes on the message that an event has changed to the currently |
335 | * activated view so that it can make appropriate display changes. */ | 335 | * activated view so that it can make appropriate display changes. */ |
336 | void changeEventDisplay(Event *, int); | 336 | void changeEventDisplay(Event *, int); |
337 | void changeIncidenceDisplay(Incidence *, int); | 337 | void changeIncidenceDisplay(Incidence *, int); |
338 | void changeTodoDisplay(Todo *, int); | 338 | void changeTodoDisplay(Todo *, int); |
339 | 339 | ||
340 | void eventAdded(Event *); | 340 | void eventAdded(Event *); |
341 | void eventChanged(Event *); | 341 | void eventChanged(Event *); |
342 | void eventToBeDeleted(Event *); | 342 | void eventToBeDeleted(Event *); |
343 | void eventDeleted(); | 343 | void eventDeleted(); |
344 | 344 | ||
345 | void todoAdded(Todo *); | 345 | void todoAdded(Todo *); |
346 | void todoChanged(Todo *); | 346 | void todoChanged(Todo *); |
347 | void todoToBeDeleted(Todo *); | 347 | void todoToBeDeleted(Todo *); |
348 | void todoDeleted(); | 348 | void todoDeleted(); |
349 | 349 | ||
350 | void updateView(const QDate &start, const QDate &end); | 350 | void updateView(const QDate &start, const QDate &end); |
351 | void updateView(); | 351 | void updateView(); |
352 | void clearAllViews(); | 352 | void clearAllViews(); |
353 | 353 | ||
354 | /** Full update of visible todo views */ | 354 | /** Full update of visible todo views */ |
355 | void updateTodoViews(); | 355 | void updateTodoViews(); |
356 | 356 | ||
357 | void updateUnmanagedViews(); | 357 | void updateUnmanagedViews(); |
358 | 358 | ||
359 | /** cut the current appointment to the clipboard */ | 359 | /** cut the current appointment to the clipboard */ |
360 | void edit_cut(); | 360 | void edit_cut(); |
361 | 361 | ||
362 | /** copy the current appointment(s) to the clipboard */ | 362 | /** copy the current appointment(s) to the clipboard */ |
363 | void edit_copy(); | 363 | void edit_copy(); |
364 | 364 | ||
365 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 365 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
366 | void edit_paste(); | 366 | void edit_paste(); |
367 | 367 | ||
368 | /** edit viewing and configuration options. */ | 368 | /** edit viewing and configuration options. */ |
369 | void edit_options(); | 369 | void edit_options(); |
370 | void edit_global_options(); | 370 | void edit_global_options(); |
371 | /** | 371 | /** |
372 | Functions for printing, previewing a print, and setting up printing | 372 | Functions for printing, previewing a print, and setting up printing |
373 | parameters. | 373 | parameters. |
374 | */ | 374 | */ |
375 | void print(); | 375 | void print(); |
376 | void printSetup(); | 376 | void printSetup(); |
377 | void printPreview(); | 377 | void printPreview(); |
378 | 378 | ||
379 | /** Export as iCalendar file */ | 379 | /** Export as iCalendar file */ |
380 | bool exportICalendar(); | 380 | bool exportICalendar(); |
381 | bool exportICalendar( QString fn ); | 381 | bool exportICalendar( QString fn ); |
382 | 382 | ||
383 | /** Export as vCalendar file */ | 383 | /** Export as vCalendar file */ |
384 | bool exportVCalendar( QString fn); | 384 | bool exportVCalendar( QString fn); |
385 | 385 | ||
386 | /** pop up a dialog to show an existing appointment. */ | 386 | /** pop up a dialog to show an existing appointment. */ |
387 | void appointment_show(); | 387 | void appointment_show(); |
388 | /** | 388 | /** |
389 | * pop up an Appointment Dialog to edit an existing appointment.Get | 389 | * pop up an Appointment Dialog to edit an existing appointment.Get |
390 | * information on the appointment from the list of unique IDs that is | 390 | * information on the appointment from the list of unique IDs that is |
391 | * currently in the View, called currIds. | 391 | * currently in the View, called currIds. |
392 | */ | 392 | */ |
393 | void appointment_edit(); | 393 | void appointment_edit(); |
394 | /** | 394 | /** |
395 | * pop up dialog confirming deletion of currently selected event in the | 395 | * pop up dialog confirming deletion of currently selected event in the |
396 | * View. | 396 | * View. |
397 | */ | 397 | */ |
398 | void appointment_delete(); | 398 | void appointment_delete(); |
399 | 399 | ||
400 | /** mails the currently selected event to a particular user as a vCalendar | 400 | /** mails the currently selected event to a particular user as a vCalendar |
401 | attachment. */ | 401 | attachment. */ |
402 | void action_mail(); | 402 | void action_mail(); |
403 | 403 | ||
404 | /* frees a subtodo from it's relation */ | 404 | /* frees a subtodo from it's relation */ |
405 | void todo_unsub( Todo * ); | 405 | void todo_unsub( Todo * ); |
406 | void todo_resub( Todo * parent, Todo * sub ); | 406 | void todo_resub( Todo * parent, Todo * sub ); |
407 | 407 | ||
408 | /** Take ownership of selected event. */ | 408 | /** Take ownership of selected event. */ |
409 | void takeOverEvent(); | 409 | void takeOverEvent(); |
410 | 410 | ||
411 | /** Take ownership of all events in calendar. */ | 411 | /** Take ownership of all events in calendar. */ |
412 | void takeOverCalendar(); | 412 | void takeOverCalendar(); |
413 | 413 | ||
414 | /** query whether or not the calendar is "dirty". */ | 414 | /** query whether or not the calendar is "dirty". */ |
415 | bool isModified(); | 415 | bool isModified(); |
416 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 416 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
417 | void setModified(bool modified=true); | 417 | void setModified(bool modified=true); |
418 | 418 | ||
419 | /** query if the calendar is read-only. */ | 419 | /** query if the calendar is read-only. */ |
420 | bool isReadOnly(); | 420 | bool isReadOnly(); |
421 | /** set state of calendar to read-only */ | 421 | /** set state of calendar to read-only */ |
422 | void setReadOnly(bool readOnly=true); | 422 | void setReadOnly(bool readOnly=true); |
423 | 423 | ||
424 | void eventUpdated(Incidence *); | 424 | void eventUpdated(Incidence *); |
425 | 425 | ||
426 | /* iTIP scheduling actions */ | 426 | /* iTIP scheduling actions */ |
427 | void schedule_publish(Incidence *incidence = 0); | 427 | void schedule_publish(Incidence *incidence = 0); |
428 | void schedule_request(Incidence *incidence = 0); | 428 | void schedule_request(Incidence *incidence = 0); |
429 | void schedule_refresh(Incidence *incidence = 0); | 429 | void schedule_refresh(Incidence *incidence = 0); |
430 | void schedule_cancel(Incidence *incidence = 0); | 430 | void schedule_cancel(Incidence *incidence = 0); |
431 | void schedule_add(Incidence *incidence = 0); | 431 | void schedule_add(Incidence *incidence = 0); |
432 | void schedule_reply(Incidence *incidence = 0); | 432 | void schedule_reply(Incidence *incidence = 0); |
433 | void schedule_counter(Incidence *incidence = 0); | 433 | void schedule_counter(Incidence *incidence = 0); |
434 | void schedule_declinecounter(Incidence *incidence = 0); | 434 | void schedule_declinecounter(Incidence *incidence = 0); |
435 | void schedule_publish_freebusy(int daysToPublish = 30); | 435 | void schedule_publish_freebusy(int daysToPublish = 30); |
436 | 436 | ||
437 | void openAddressbook(); | 437 | void openAddressbook(); |
438 | 438 | ||
439 | void editFilters(); | 439 | void editFilters(); |
440 | void toggleFilerEnabled(); | 440 | void toggleFilerEnabled(); |
441 | QPtrList<CalFilter> filters(); | 441 | QPtrList<CalFilter> filters(); |
442 | void toggleFilter(); | 442 | void toggleFilter(); |
443 | void showFilter(bool visible); | 443 | void showFilter(bool visible); |
444 | void updateFilter(); | 444 | void updateFilter(); |
445 | void filterEdited(); | 445 | void filterEdited(); |
446 | void selectFilter( int ); | 446 | void selectFilter( int ); |
447 | KOFilterView *filterView(); | 447 | KOFilterView *filterView(); |
448 | 448 | ||
449 | void showIntro(); | 449 | void showIntro(); |
450 | 450 | ||
451 | /** Move the curdatepient view date to today */ | 451 | /** Move the curdatepient view date to today */ |
452 | void goToday(); | 452 | void goToday(); |
453 | 453 | ||
454 | /** Move to the next date(s) in the current view */ | 454 | /** Move to the next date(s) in the current view */ |
455 | void goNext(); | 455 | void goNext(); |
456 | 456 | ||
457 | /** Move to the previous date(s) in the current view */ | 457 | /** Move to the previous date(s) in the current view */ |
458 | void goPrevious(); | 458 | void goPrevious(); |
459 | /** Move to the next date(s) in the current view */ | 459 | /** Move to the next date(s) in the current view */ |
460 | void goNextMonth(); | 460 | void goNextMonth(); |
461 | 461 | ||
462 | /** Move to the previous date(s) in the current view */ | 462 | /** Move to the previous date(s) in the current view */ |
463 | void goPreviousMonth(); | 463 | void goPreviousMonth(); |
464 | 464 | ||
465 | void toggleExpand(); | 465 | void toggleExpand(); |
466 | void toggleDateNavigatorWidget(); | 466 | void toggleDateNavigatorWidget(); |
467 | void toggleAllDaySize(); | 467 | void toggleAllDaySize(); |
468 | 468 | ||
469 | /** Look for new messages in the inbox */ | 469 | /** Look for new messages in the inbox */ |
470 | void lookForIncomingMessages(); | 470 | void lookForIncomingMessages(); |
471 | /** Look for new messages in the outbox */ | 471 | /** Look for new messages in the outbox */ |
472 | void lookForOutgoingMessages(); | 472 | void lookForOutgoingMessages(); |
473 | 473 | ||
474 | void processMainViewSelection( Incidence * ); | 474 | void processMainViewSelection( Incidence * ); |
475 | void processTodoListSelection( Incidence * ); | 475 | void processTodoListSelection( Incidence * ); |
476 | 476 | ||
477 | void processIncidenceSelection( Incidence * ); | 477 | void processIncidenceSelection( Incidence * ); |
478 | 478 | ||
479 | void purgeCompleted(); | 479 | void purgeCompleted(); |
480 | bool removeCompletedSubTodos( Todo* ); | 480 | bool removeCompletedSubTodos( Todo* ); |
481 | void slotCalendarChanged(); | 481 | void slotCalendarChanged(); |
482 | bool importBday(); | 482 | bool importBday(); |
483 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 483 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
484 | bool importQtopia( const QString &categoriesFile, | 484 | bool importQtopia( const QString &categoriesFile, |
485 | const QString &datebookFile, | 485 | const QString &datebookFile, |
486 | const QString &tasklistFile ); | 486 | const QString &tasklistFile ); |
487 | void syncExternal( int mode ); | 487 | void syncExternal( int mode ); |
488 | void slotSelectPickerDate( QDate ) ; | 488 | void slotSelectPickerDate( QDate ) ; |
489 | void showDatePicker() ; | 489 | void showDatePicker() ; |
490 | void showDatePickerPopup() ; | 490 | void showDatePickerPopup() ; |
491 | void moveIncidence(Incidence *) ; | 491 | void moveIncidence(Incidence *) ; |
492 | void beamIncidence(Incidence *) ; | 492 | void beamIncidence(Incidence *) ; |
493 | void beamCalendar() ; | 493 | void beamCalendar() ; |
494 | void beamFilteredCalendar() ; | 494 | void beamFilteredCalendar() ; |
495 | void beamIncidenceList(QPtrList<Incidence>) ; | 495 | void beamIncidenceList(QPtrList<Incidence>) ; |
496 | void manageCategories(); | 496 | void manageCategories(); |
497 | void editCategories(); | 497 | void editCategories(); |
498 | int addCategories(); | 498 | int addCategories(); |
499 | void removeCategories(); | 499 | void removeCategories(); |
500 | void setSyncDevice( QString ); | 500 | void setSyncDevice( QString ); |
501 | void setSyncName( QString ); | 501 | void setSyncName( QString ); |
502 | void showDay( QDate ); | 502 | void showDay( QDate ); |
503 | void undo_delete(); | 503 | void undo_delete(); |
504 | protected slots: | 504 | protected slots: |
505 | void resetFocus(); | 505 | void resetFocus(); |
506 | void scrollBarValue(int); | 506 | void scrollBarValue(int); |
507 | void slotViewerClosed(); | 507 | void slotViewerClosed(); |
508 | void timerAlarm(); | 508 | void timerAlarm(); |
509 | void suspendAlarm(); | 509 | void suspendAlarm(); |
510 | void beamDone( Ir *ir ); | 510 | void beamDone( Ir *ir ); |
511 | /** Select a view or adapt the current view to display the specified dates. */ | 511 | /** Select a view or adapt the current view to display the specified dates. */ |
512 | void showDates( const KCal::DateList & ); | 512 | void showDates( const KCal::DateList & ); |
513 | void selectWeekNum ( int ); | 513 | void selectWeekNum ( int ); |
514 | void checkConflictForEvent(); | 514 | void checkConflictForEvent(); |
515 | 515 | ||
516 | public: | 516 | public: |
517 | void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); | 517 | void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); |
518 | // show a standard warning | 518 | // show a standard warning |
519 | // returns KMsgBox::yesNoCancel() | 519 | // returns KMsgBox::yesNoCancel() |
520 | int msgCalModified(); | 520 | int msgCalModified(); |
521 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 521 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource); |
522 | 522 | ||
523 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 523 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
524 | virtual void removeSyncInfo( QString syncProfile); | 524 | virtual void removeSyncInfo( QString syncProfile); |
525 | void setSyncManager(KSyncManager* manager); | 525 | void setSyncManager(KSyncManager* manager); |
526 | void setLoadedFileVersion(QDateTime); | 526 | void setLoadedFileVersion(QDateTime); |
527 | bool checkFileVersion(QString fn); | 527 | bool checkFileVersion(QString fn); |
528 | bool checkAllFileVersions(); | 528 | bool checkAllFileVersions(); |
529 | bool checkFileChanged(QString fn); | 529 | bool checkFileChanged(QString fn); |
530 | Event* getLastSyncEvent(); | 530 | Event* getLastSyncEvent(); |
531 | /** Adapt navigation units correpsonding to step size of navigation of the | 531 | /** Adapt navigation units correpsonding to step size of navigation of the |
532 | * current view. | 532 | * current view. |
533 | */ | 533 | */ |
534 | void adaptNavigationUnits(); | 534 | void adaptNavigationUnits(); |
535 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 535 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
536 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 536 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
537 | //Attendee* getYourAttendee(Event *event); | 537 | //Attendee* getYourAttendee(Event *event); |
538 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 538 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
539 | void setScrollBarStep(int val ); | 539 | void setScrollBarStep(int val ); |
540 | 540 | ||
541 | protected: | 541 | protected: |
542 | Event *mConflictingEvent; | 542 | Event *mConflictingEvent; |
543 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 543 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
544 | 544 | ||
545 | // returns KMsgBox::OKCandel() | 545 | // returns KMsgBox::OKCandel() |
546 | int msgItemDelete(const QString name); | 546 | int msgItemDelete(const QString name); |
547 | void showEventEditor(); | 547 | void showEventEditor(); |
548 | void showTodoEditor(); | 548 | void showTodoEditor(); |
549 | Todo *selectedTodo(); | 549 | Todo *selectedTodo(); |
550 | private: | 550 | private: |
551 | #ifdef DESKTOP_VERSION | 551 | #ifdef DESKTOP_VERSION |
552 | QScrollBar * mDateScrollBar; | 552 | QScrollBar * mDateScrollBar; |
553 | #endif | 553 | #endif |
554 | bool flag_blockConflict; | 554 | bool flag_blockConflict; |
555 | bool flag_blockScrollBar; | 555 | bool flag_blockScrollBar; |
556 | bool flag_checkFileFirsttime; | 556 | bool flag_checkFileFirsttime; |
557 | bool flag_clearallviewsEventDisplay; | 557 | bool flag_clearallviewsEventDisplay; |
558 | bool flag_clearallviewsupdateView; | 558 | bool flag_clearallviewsupdateView; |
559 | QDateTime mNextAlarmDateTime; | 559 | QDateTime mNextAlarmDateTime; |
560 | bool mViewerCallerIsSearchDialog; | 560 | bool mViewerCallerIsSearchDialog; |
561 | bool mBlockShowDates; | 561 | bool mBlockShowDates; |
562 | KSyncManager* mSyncManager; | 562 | KSyncManager* mSyncManager; |
563 | AlarmDialog * mAlarmDialog; | 563 | AlarmDialog * mAlarmDialog; |
564 | QString mAlarmNotification; | 564 | QString mAlarmNotification; |
565 | QString mSuspendAlarmNotification; | 565 | QString mSuspendAlarmNotification; |
566 | QTimer* mSuspendTimer; | 566 | QTimer* mSuspendTimer; |
567 | QTimer* mAlarmTimer; | 567 | QTimer* mAlarmTimer; |
568 | QTimer* mRecheckAlarmTimer; | 568 | QTimer* mRecheckAlarmTimer; |
569 | void computeAlarm( QString ); | 569 | void computeAlarm( QString ); |
570 | void startAlarm( QString, QString ); | 570 | void startAlarm( QString, QString ); |
571 | void setSyncEventsReadOnly(); | 571 | void setSyncEventsReadOnly(); |
572 | 572 | ||
573 | QDateTime loadedFileVersion; | 573 | QDateTime loadedFileVersion; |
574 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 574 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
575 | void checkExternalId( Incidence * inc ); | 575 | void checkExternalId( Incidence * inc ); |
576 | int mGlobalSyncMode; | 576 | int mGlobalSyncMode; |
577 | QString mCurrentSyncDevice; | 577 | QString mCurrentSyncDevice; |
578 | QString mCurrentSyncName; | 578 | QString mCurrentSyncName; |
579 | void init(); | 579 | void init(); |
580 | int mDatePickerMode; | 580 | int mDatePickerMode; |
581 | bool mFlagEditDescription; | 581 | bool mFlagEditDescription; |
582 | QDateTime mLastCalendarSync; | 582 | QDateTime mLastCalendarSync; |
583 | void createPrinter(); | 583 | void createPrinter(); |
584 | 584 | ||
585 | void calendarModified( bool, Calendar * ); | 585 | void calendarModified( bool, Calendar * ); |
586 | 586 | ||
587 | CalPrinter *mCalPrinter; | 587 | CalPrinter *mCalPrinter; |
588 | 588 | ||
589 | QSplitter *mPanner; | 589 | QSplitter *mPanner; |
590 | QSplitter *mLeftSplitter; | 590 | QSplitter *mLeftSplitter; |
591 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; | 591 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; |
592 | QWidgetStack *mRightFrame; | 592 | QWidgetStack *mRightFrame; |
593 | 593 | ||
594 | KDatePicker* mDatePicker; | 594 | KDatePicker* mDatePicker; |
595 | QVBox* mDateFrame; | 595 | QVBox* mDateFrame; |
596 | 596 | ||
597 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. | 597 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. |
598 | 598 | ||
599 | KOFilterView *mFilterView; | 599 | KOFilterView *mFilterView; |
600 | KOCalEditView *mCalEditView; | 600 | KOCalEditView *mCalEditView; |
601 | 601 | ||
602 | ResourceView *mResourceView; | 602 | ResourceView *mResourceView; |
603 | 603 | ||
604 | // calendar object for this viewing instance | 604 | // calendar object for this viewing instance |
605 | Calendar *mCalendar; | 605 | Calendar *mCalendar; |
606 | 606 | ||
607 | CalendarResourceManager *mResourceManager; | 607 | CalendarResourceManager *mResourceManager; |
608 | 608 | ||
609 | FileStorage *mStorage; | 609 | FileStorage *mStorage; |
610 | 610 | ||
611 | DateNavigator *mNavigator; | 611 | DateNavigator *mNavigator; |
612 | 612 | ||
613 | KOViewManager *mViewManager; | 613 | KOViewManager *mViewManager; |
614 | KODialogManager *mDialogManager; | 614 | KODialogManager *mDialogManager; |
615 | 615 | ||
616 | // Calendar filters | 616 | // Calendar filters |
617 | QPtrList<CalFilter> mFilters; | 617 | QPtrList<CalFilter> mFilters; |
618 | 618 | ||
619 | // various housekeeping variables. | 619 | // various housekeeping variables. |
620 | bool mModified; // flag indicating if calendar is modified | 620 | bool mModified; // flag indicating if calendar is modified |
621 | bool mReadOnly; // flag indicating if calendar is read-only | 621 | bool mReadOnly; // flag indicating if calendar is read-only |
622 | QDate mSaveSingleDate; | 622 | QDate mSaveSingleDate; |
623 | 623 | ||
624 | Incidence *mSelectedIncidence; | 624 | Incidence *mSelectedIncidence; |
625 | Incidence *mMoveIncidence; | 625 | Incidence *mMoveIncidence; |
626 | QDate mMoveIncidenceOldDate; | 626 | QDate mMoveIncidenceOldDate; |
627 | KOTodoView *mTodoList; | 627 | KOTodoView *mTodoList; |
628 | KOEventEditor * mEventEditor; | 628 | KOEventEditor * mEventEditor; |
629 | KOTodoEditor * mTodoEditor; | 629 | KOTodoEditor * mTodoEditor; |
630 | KOEventViewerDialog * mEventViewerDialog; | 630 | KOEventViewerDialog * mEventViewerDialog; |
631 | void keyPressEvent ( QKeyEvent *e) ; | 631 | void keyPressEvent ( QKeyEvent *e) ; |
632 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 632 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
633 | }; | 633 | }; |
634 | 634 | ||
635 | 635 | ||
636 | class CalendarViewVisitor : public Incidence::Visitor | 636 | class CalendarViewVisitor : public Incidence::Visitor |
637 | { | 637 | { |
638 | public: | 638 | public: |
639 | CalendarViewVisitor() : mView( 0 ) {} | 639 | CalendarViewVisitor() : mView( 0 ) {} |
640 | 640 | ||
641 | bool act( Incidence *incidence, CalendarView *view ) | 641 | bool act( Incidence *incidence, CalendarView *view ) |
642 | { | 642 | { |
643 | mView = view; | 643 | mView = view; |
644 | return incidence->accept( *this ); | 644 | return incidence->accept( *this ); |
645 | } | 645 | } |
646 | 646 | ||
647 | protected: | 647 | protected: |
648 | CalendarView *mView; | 648 | CalendarView *mView; |
649 | }; | 649 | }; |
650 | 650 | ||
651 | class ShowIncidenceVisitor : public CalendarViewVisitor | 651 | class ShowIncidenceVisitor : public CalendarViewVisitor |
652 | { | 652 | { |
653 | protected: | 653 | protected: |
654 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 654 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
655 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 655 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
656 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 656 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
657 | }; | 657 | }; |
658 | 658 | ||
659 | class EditIncidenceVisitor : public CalendarViewVisitor | 659 | class EditIncidenceVisitor : public CalendarViewVisitor |
660 | { | 660 | { |
661 | protected: | 661 | protected: |
662 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 662 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
663 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 663 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
664 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 664 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
665 | }; | 665 | }; |
666 | 666 | ||
667 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 667 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
668 | { | 668 | { |
669 | protected: | 669 | protected: |
670 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 670 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
671 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 671 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
672 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 672 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
673 | }; | 673 | }; |
674 | 674 | ||
675 | #endif | 675 | #endif |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 1b0e5f4..31ef338 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,636 +1,646 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 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 <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kglobalsettings.h> | 39 | #include <kglobalsettings.h> |
40 | #include <kconfig.h> | 40 | #include <kconfig.h> |
41 | #include <klocale.h> | 41 | #include <klocale.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kemailsettings.h> | 43 | #include <kemailsettings.h> |
44 | #include <kstaticdeleter.h> | 44 | #include <kstaticdeleter.h> |
45 | #include <libkdepim/kpimglobalprefs.h> | 45 | #include <libkdepim/kpimglobalprefs.h> |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "mainwindow.h" | 48 | #include "mainwindow.h" |
49 | 49 | ||
50 | KOPrefs *KOPrefs::mInstance = 0; | 50 | KOPrefs *KOPrefs::mInstance = 0; |
51 | static KStaticDeleter<KOPrefs> insd; | 51 | static KStaticDeleter<KOPrefs> insd; |
52 | 52 | ||
53 | KOPrefs::KOPrefs() : | 53 | KOPrefs::KOPrefs() : |
54 | KPimPrefs("korganizerrc") | 54 | KPimPrefs("korganizerrc") |
55 | { | 55 | { |
56 | mGlobalUpdateDisabled = false; | 56 | mGlobalUpdateDisabled = false; |
57 | mCategoryColors.setAutoDelete(true); | 57 | mCategoryColors.setAutoDelete(true); |
58 | fillMailDefaults(); | 58 | fillMailDefaults(); |
59 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | 59 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); |
60 | QColor defaultHolidayColor = QColor(255,0,0); | 60 | QColor defaultHolidayColor = QColor(255,0,0); |
61 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | 61 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); |
62 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | 62 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); |
63 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | 63 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); |
64 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | 64 | QColor defaultTodoDueTodayColor = QColor(255,220,100); |
65 | QColor defaultTodoOverdueColor = QColor(255,153,125); | 65 | QColor defaultTodoOverdueColor = QColor(255,153,125); |
66 | QColor defaultTodoRunColor = QColor(99,194,30); | 66 | QColor defaultTodoRunColor = QColor(99,194,30); |
67 | KPrefs::setCurrentGroup("General"); | 67 | KPrefs::setCurrentGroup("General"); |
68 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 68 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
69 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 69 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
70 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 70 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
71 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 71 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
72 | addItemBool("ShowIconList",&mShowIconList,true); | 72 | addItemBool("ShowIconList",&mShowIconList,true); |
73 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 73 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
74 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 74 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
75 | addItemBool("ShowIconDay6",&mShowIconDay6,true); | 75 | addItemBool("ShowIconDay6",&mShowIconDay6,true); |
76 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 76 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
77 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 77 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
78 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 78 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
79 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 79 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
80 | addItemBool("ShowIconBack",&mShowIconBack,true); | 80 | addItemBool("ShowIconBack",&mShowIconBack,true); |
81 | addItemBool("ShowIconToday",&mShowIconToday,true); | 81 | addItemBool("ShowIconToday",&mShowIconToday,true); |
82 | addItemBool("ShowIconForward",&mShowIconForward,true); | 82 | addItemBool("ShowIconForward",&mShowIconForward,true); |
83 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 83 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
84 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); | 84 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); |
85 | addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); | 85 | addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); |
86 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 86 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
87 | addItemBool("ShowIconNext",&mShowIconNext,true); | 87 | addItemBool("ShowIconNext",&mShowIconNext,true); |
88 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 88 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
89 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 89 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
90 | addItemBool("ShowIconFilter",&mShowIconFilter,false); | 90 | addItemBool("ShowIconFilter",&mShowIconFilter,false); |
91 | addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); | 91 | addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); |
92 | 92 | ||
93 | bool addIcons = false; | 93 | bool addIcons = false; |
94 | #ifdef DESKTOP_VERSION | 94 | #ifdef DESKTOP_VERSION |
95 | addIcons = true; | 95 | addIcons = true; |
96 | #endif | 96 | #endif |
97 | addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); | 97 | addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); |
98 | addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); | 98 | addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); |
99 | addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); | 99 | addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); |
100 | addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); | 100 | addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); |
101 | 101 | ||
102 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); | 102 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); |
103 | 103 | ||
104 | addItemBool("AskForQuit",&mAskForQuit,false); | 104 | addItemBool("AskForQuit",&mAskForQuit,false); |
105 | 105 | ||
106 | #ifndef DESKTOP_VERSION | 106 | #ifndef DESKTOP_VERSION |
107 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 107 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
108 | #else | 108 | #else |
109 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 109 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
110 | #endif | 110 | #endif |
111 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 111 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
112 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 112 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
113 | addItemBool("ToolBarHorV",&mToolBarHorV, true ); | 113 | addItemBool("ToolBarHorV",&mToolBarHorV, true ); |
114 | addItemBool("ToolBarUpV",&mToolBarUpV, false ); | 114 | addItemBool("ToolBarUpV",&mToolBarUpV, false ); |
115 | addItemBool("ToolBarHorN",&mToolBarHorN, true ); | 115 | addItemBool("ToolBarHorN",&mToolBarHorN, true ); |
116 | addItemBool("ToolBarUpN",&mToolBarUpN, false ); | 116 | addItemBool("ToolBarUpN",&mToolBarUpN, false ); |
117 | addItemBool("ToolBarHorF",&mToolBarHorF, true ); | 117 | addItemBool("ToolBarHorF",&mToolBarHorF, true ); |
118 | addItemBool("ToolBarUpF",&mToolBarUpF, false ); | 118 | addItemBool("ToolBarUpF",&mToolBarUpF, false ); |
119 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 119 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
120 | addItemBool("WhatsNextTime2Lines",&mWhatsNextTime2Lines, false ); | 120 | addItemBool("WhatsNextTime2Lines",&mWhatsNextTime2Lines, false ); |
121 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 121 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
122 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 122 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
123 | 123 | ||
124 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 124 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
125 | addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); | 125 | addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); |
126 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); | 126 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); |
127 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); | 127 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); |
128 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 128 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
129 | addItemInt("AllDay Size",&mAllDaySize,28); | 129 | addItemInt("AllDay Size",&mAllDaySize,28); |
130 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 130 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
131 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 131 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
132 | 132 | ||
133 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 133 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
134 | addItemStringList("EventSummary User",&mEventSummaryUser); | 134 | addItemStringList("EventSummary User",&mEventSummaryUser); |
135 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 135 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
136 | addItemStringList("JournalSummary User",&mJournalSummaryUser); | 136 | addItemStringList("JournalSummary User",&mJournalSummaryUser); |
137 | 137 | ||
138 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 138 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
139 | addItemBool("Enable Project View",&mEnableProjectView,false); | 139 | addItemBool("Enable Project View",&mEnableProjectView,false); |
140 | addItemBool("Auto Save",&mAutoSave,false); | 140 | addItemBool("Auto Save",&mAutoSave,false); |
141 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 141 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
142 | addItemBool("Confirm Deletes",&mConfirm,true); | 142 | addItemBool("Confirm Deletes",&mConfirm,true); |
143 | addItemString("Archive File",&mArchiveFile); | 143 | addItemString("Archive File",&mArchiveFile); |
144 | addItemString("Html Export File",&mHtmlExportFile, | 144 | addItemString("Html Export File",&mHtmlExportFile, |
145 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 145 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
146 | addItemBool("Html With Save",&mHtmlWithSave,false); | 146 | addItemBool("Html With Save",&mHtmlWithSave,false); |
147 | 147 | ||
148 | KPrefs::setCurrentGroup("Personal Settings"); | 148 | KPrefs::setCurrentGroup("Personal Settings"); |
149 | 149 | ||
150 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 150 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
151 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 151 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
152 | addItemBool("Bcc",&mBcc,false); | 152 | addItemBool("Bcc",&mBcc,false); |
153 | 153 | ||
154 | KPrefs::setCurrentGroup("Time & Date"); | 154 | KPrefs::setCurrentGroup("Time & Date"); |
155 | 155 | ||
156 | 156 | ||
157 | addItemInt("Default Start Time",&mStartTime,10); | 157 | addItemInt("Default Start Time",&mStartTime,10); |
158 | addItemInt("Default Duration",&mDefaultDuration,2); | 158 | addItemInt("Default Duration",&mDefaultDuration,2); |
159 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 159 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
160 | KPrefs::setCurrentGroup("AlarmSettings"); | 160 | KPrefs::setCurrentGroup("AlarmSettings"); |
161 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 161 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
162 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 162 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
163 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 163 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
164 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 164 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
165 | 165 | ||
166 | 166 | ||
167 | KPrefs::setCurrentGroup("Calendar"); | 167 | KPrefs::setCurrentGroup("Calendar"); |
168 | 168 | ||
169 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 169 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
170 | 170 | ||
171 | KPrefs::setCurrentGroup("Fonts"); | 171 | KPrefs::setCurrentGroup("Fonts"); |
172 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 172 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
173 | QFont fon = KGlobalSettings::generalFont(); | 173 | QFont fon = KGlobalSettings::generalFont(); |
174 | addItemFont("TimeBar Font",&mTimeBarFont,fon ); | 174 | addItemFont("TimeBar Font",&mTimeBarFont,fon ); |
175 | addItemFont("MonthView Font",&mMonthViewFont,fon); | 175 | addItemFont("MonthView Font",&mMonthViewFont,fon); |
176 | addItemFont("AgendaView Font",&mAgendaViewFont,fon); | 176 | addItemFont("AgendaView Font",&mAgendaViewFont,fon); |
177 | addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); | 177 | addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); |
178 | addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); | 178 | addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); |
179 | addItemFont("TodoView Font",&mTodoViewFont,fon); | 179 | addItemFont("TodoView Font",&mTodoViewFont,fon); |
180 | addItemFont("ListView Font",&mListViewFont,fon); | 180 | addItemFont("ListView Font",&mListViewFont,fon); |
181 | addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); | 181 | addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); |
182 | addItemFont("EditBox Font",&mEditBoxFont,fon); | 182 | addItemFont("EditBox Font",&mEditBoxFont,fon); |
183 | addItemFont("JournalView Font",&mJornalViewFont,fon); | 183 | addItemFont("JournalView Font",&mJornalViewFont,fon); |
184 | addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); | 184 | addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); |
185 | addItemFont("EventView Font",&mEventViewFont,fon); | 185 | addItemFont("EventView Font",&mEventViewFont,fon); |
186 | 186 | ||
187 | KPrefs::setCurrentGroup("RemoteSyncing"); | 187 | KPrefs::setCurrentGroup("RemoteSyncing"); |
188 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 188 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
189 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 189 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
190 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 190 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
191 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 191 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
192 | 192 | ||
193 | #ifdef _WIN32_ | 193 | #ifdef _WIN32_ |
194 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 194 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
195 | #else | 195 | #else |
196 | QString hdp= locateLocal("data","korganizer")+"/"; | 196 | QString hdp= locateLocal("data","korganizer")+"/"; |
197 | #endif | 197 | #endif |
198 | 198 | ||
199 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 199 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
200 | 200 | ||
201 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 201 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
202 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 202 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
203 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 203 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
204 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 204 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
205 | 205 | ||
206 | 206 | ||
207 | KPrefs::setCurrentGroup("Locale"); | 207 | KPrefs::setCurrentGroup("Locale"); |
208 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 208 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
209 | 209 | ||
210 | 210 | ||
211 | KPrefs::setCurrentGroup("Colors"); | 211 | KPrefs::setCurrentGroup("Colors"); |
212 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 212 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
213 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 213 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
214 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 214 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
215 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); | 215 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); |
216 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 216 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
217 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 217 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
218 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 218 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
219 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 219 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
220 | addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); | 220 | addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); |
221 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 221 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
222 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 222 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
223 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 223 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
224 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 224 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
225 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 225 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
226 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); | 226 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); |
227 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 227 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
228 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 228 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
229 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 229 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
230 | addItemBool("UseAppColors",&mUseAppColors,false); | 230 | addItemBool("UseAppColors",&mUseAppColors,false); |
231 | 231 | ||
232 | 232 | ||
233 | KPrefs::setCurrentGroup("Conflicts"); | 233 | KPrefs::setCurrentGroup("Conflicts"); |
234 | addItemBool("EnableAutoDetect",&mDetectConflicts,true); | 234 | addItemBool("EnableAutoDetect",&mDetectConflicts,true); |
235 | addItemBool("CheckConflictsFree",&mIncludeFree,true); | 235 | addItemBool("CheckConflictsFree",&mIncludeFree,true); |
236 | addItemBool("CheckConflictsAllDayAllDay",&mCheckConflictsAllDayAllDay,false); | 236 | addItemBool("CheckConflictsAllDayAllDay",&mCheckConflictsAllDayAllDay,false); |
237 | addItemBool("CheckConflictsAllDayNonAD",&mCheckConflictsAllDayNonAD,false); | 237 | addItemBool("CheckConflictsAllDayNonAD",&mCheckConflictsAllDayNonAD,false); |
238 | addItemBool("CheckConflictsNonADAllDay",&mCheckConflictsNonADAllDay,false); | 238 | addItemBool("CheckConflictsNonADAllDay",&mCheckConflictsNonADAllDay,false); |
239 | addItemBool("CheckConflictsNonADNonAD",&mCheckConflictsNonADNonAD,true); | 239 | addItemBool("CheckConflictsNonADNonAD",&mCheckConflictsNonADNonAD,true); |
240 | addItemString("FilterConflictEditItem", &mFilterConflictEditItem ,"nofilter" ); | 240 | addItemString("FilterConflictEditItem", &mFilterConflictEditItem ,"nofilter" ); |
241 | addItemString("FilterConflictAllItem", &mFilterConflictAllItem ,"nofilter" ); | 241 | addItemString("FilterConflictAllItem", &mFilterConflictAllItem ,"nofilter" ); |
242 | 242 | ||
243 | KPrefs::setCurrentGroup("Views"); | 243 | KPrefs::setCurrentGroup("Views"); |
244 | addItemBool("Block Popup Menu",&mBlockPopupMenu,false); | 244 | addItemBool("Block Popup Menu",&mBlockPopupMenu,false); |
245 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); | 245 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); |
246 | addItemInt("Hour Size",&mHourSize,8); | 246 | addItemInt("Hour Size",&mHourSize,8); |
247 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 247 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
248 | addItemBool("ShowLongAllday",&mLongAllday,true); | 248 | addItemBool("ShowLongAllday",&mLongAllday,true); |
249 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 249 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
250 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 250 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
251 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 251 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
252 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 252 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
253 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 253 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
254 | addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); | 254 | addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); |
255 | #ifdef DESKTOP_VERION | 255 | #ifdef DESKTOP_VERION |
256 | addItemBool("Enable ToolTips",&mEnableToolTips,true); | 256 | addItemBool("Enable ToolTips",&mEnableToolTips,true); |
257 | #else | 257 | #else |
258 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 258 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
259 | #endif | 259 | #endif |
260 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 260 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
261 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 261 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
262 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 262 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
263 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 263 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
264 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); | 264 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); |
265 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 265 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
266 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 266 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
267 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 267 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
268 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 268 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
269 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; | 269 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; |
270 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); | 270 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); |
271 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 271 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
272 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 272 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
273 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 273 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
274 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 274 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
275 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 275 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
276 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); | 276 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); |
277 | addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); | 277 | addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); |
278 | addItemBool("MonthViewWeekRowlayout",&mMonthViewWeekRowlayout,false); | 278 | addItemBool("MonthViewWeekRowlayout",&mMonthViewWeekRowlayout,false); |
279 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 279 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
280 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 280 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
281 | #ifdef DESKTOP_VERSION | 281 | #ifdef DESKTOP_VERSION |
282 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 282 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
283 | #else | 283 | #else |
284 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 284 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
285 | #endif | 285 | #endif |
286 | addItemInt("Day Begins",&mDayBegins,7); | 286 | addItemInt("Day Begins",&mDayBegins,7); |
287 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 287 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
288 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 288 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
289 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 289 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
290 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 290 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
291 | 291 | ||
292 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 292 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
293 | addItemBool("Full View Month",&mFullViewMonth,true); | 293 | addItemBool("Full View Month",&mFullViewMonth,true); |
294 | addItemBool("Full View Todo",&mFullViewTodo,true); | 294 | addItemBool("Full View Todo",&mFullViewTodo,true); |
295 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 295 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
296 | 296 | ||
297 | addItemInt("Next X Days",&mNextXDays,3); | 297 | addItemInt("Next X Days",&mNextXDays,3); |
298 | 298 | ||
299 | KPrefs::setCurrentGroup("Printer"); | 299 | KPrefs::setCurrentGroup("Printer"); |
300 | 300 | ||
301 | KPrefs::setCurrentGroup("Layout"); | 301 | KPrefs::setCurrentGroup("Layout"); |
302 | 302 | ||
303 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 303 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
304 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 304 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
305 | 305 | ||
306 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 306 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
307 | 307 | ||
308 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 308 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
309 | 309 | ||
310 | KPrefs::setCurrentGroup("Group Scheduling"); | 310 | KPrefs::setCurrentGroup("Group Scheduling"); |
311 | 311 | ||
312 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 312 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
313 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 313 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
314 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 314 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
315 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 315 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
316 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 316 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
317 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 317 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
318 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 318 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
319 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 319 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
320 | 320 | ||
321 | KPrefs::setCurrentGroup( "Editors" ); | 321 | KPrefs::setCurrentGroup( "Editors" ); |
322 | 322 | ||
323 | addItemStringList( "EventTemplates", &mEventTemplates ); | 323 | addItemStringList( "EventTemplates", &mEventTemplates ); |
324 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 324 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
325 | 325 | ||
326 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 326 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
327 | 327 | ||
328 | KPrefs::setCurrentGroup( "ViewOptions" ); | 328 | KPrefs::setCurrentGroup( "ViewOptions" ); |
329 | addItemBool("EVshowDetails",&mEVshowDetails,true); | 329 | addItemBool("EVshowDetails",&mEVshowDetails,true); |
330 | addItemBool("EVshowCreated",&mEVshowCreated,true); | 330 | addItemBool("EVshowCreated",&mEVshowCreated,true); |
331 | addItemBool("EVshowChanged",&mEVshowChanged,true); | 331 | addItemBool("EVshowChanged",&mEVshowChanged,true); |
332 | addItemBool("WTshowDetails",&mWTshowDetails,false); | 332 | addItemBool("WTshowDetails",&mWTshowDetails,false); |
333 | addItemBool("WTshowCreated",&mWTshowCreated,false); | 333 | addItemBool("WTshowCreated",&mWTshowCreated,false); |
334 | addItemBool("WTshowChanged",&mWTshowChanged,false); | 334 | addItemBool("WTshowChanged",&mWTshowChanged,false); |
335 | mCalendars.setAutoDelete( true ); | 335 | mCalendars.setAutoDelete( true ); |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | KOPrefs::~KOPrefs() | 339 | KOPrefs::~KOPrefs() |
340 | { | 340 | { |
341 | if (mInstance == this) | 341 | if (mInstance == this) |
342 | mInstance = insd.setObject(0); | 342 | mInstance = insd.setObject(0); |
343 | mCalendars.setAutoDelete( true ); | 343 | mCalendars.setAutoDelete( true ); |
344 | mCalendars.clear(); | 344 | mCalendars.clear(); |
345 | //qDebug("KOPrefs::~KOPrefs() "); | 345 | //qDebug("KOPrefs::~KOPrefs() "); |
346 | } | 346 | } |
347 | 347 | ||
348 | 348 | ||
349 | KOPrefs *KOPrefs::instance() | 349 | KOPrefs *KOPrefs::instance() |
350 | { | 350 | { |
351 | if (!mInstance) { | 351 | if (!mInstance) { |
352 | mInstance = insd.setObject(new KOPrefs()); | 352 | mInstance = insd.setObject(new KOPrefs()); |
353 | mInstance->readConfig(); | 353 | mInstance->readConfig(); |
354 | } | 354 | } |
355 | 355 | ||
356 | return mInstance; | 356 | return mInstance; |
357 | } | 357 | } |
358 | 358 | ||
359 | void KOPrefs::usrSetDefaults() | 359 | void KOPrefs::usrSetDefaults() |
360 | { | 360 | { |
361 | 361 | ||
362 | } | 362 | } |
363 | 363 | ||
364 | void KOPrefs::fillMailDefaults() | 364 | void KOPrefs::fillMailDefaults() |
365 | { | 365 | { |
366 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 366 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
367 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 367 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
368 | } | 368 | } |
369 | 369 | ||
370 | void KOPrefs::setTimeZoneIdDefault() | 370 | void KOPrefs::setTimeZoneIdDefault() |
371 | { | 371 | { |
372 | ; | 372 | ; |
373 | } | 373 | } |
374 | 374 | ||
375 | void KOPrefs::setAllDefaults() | 375 | void KOPrefs::setAllDefaults() |
376 | { | 376 | { |
377 | setCategoryDefaults(); | 377 | setCategoryDefaults(); |
378 | mEventSummaryUser = getDefaultList() ; | 378 | mEventSummaryUser = getDefaultList() ; |
379 | mTodoSummaryUser = getDefaultList() ; | 379 | mTodoSummaryUser = getDefaultList() ; |
380 | mJournalSummaryUser = getDefaultList() ; | 380 | mJournalSummaryUser = getDefaultList() ; |
381 | mLocationDefaults = getLocationDefaultList(); | 381 | mLocationDefaults = getLocationDefaultList(); |
382 | } | 382 | } |
383 | 383 | ||
384 | void KOPrefs::setCategoryDefaults() | 384 | void KOPrefs::setCategoryDefaults() |
385 | { | 385 | { |
386 | mCustomCategories.clear(); | 386 | mCustomCategories.clear(); |
387 | mCustomCategories = getDefaultList(); | 387 | mCustomCategories = getDefaultList(); |
388 | 388 | ||
389 | QStringList::Iterator it; | 389 | QStringList::Iterator it; |
390 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 390 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
391 | setCategoryColor(*it,mDefaultCategoryColor); | 391 | setCategoryColor(*it,mDefaultCategoryColor); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | QStringList KOPrefs::getLocationDefaultList() | 394 | QStringList KOPrefs::getLocationDefaultList() |
395 | { | 395 | { |
396 | QStringList retval ; | 396 | QStringList retval ; |
397 | retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 397 | retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
398 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") | 398 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") |
399 | << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 399 | << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
400 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 400 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
401 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 401 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
402 | 402 | ||
403 | retval.sort(); | 403 | retval.sort(); |
404 | return retval; | 404 | return retval; |
405 | } | 405 | } |
406 | QStringList KOPrefs::getDefaultList() | 406 | QStringList KOPrefs::getDefaultList() |
407 | { | 407 | { |
408 | QStringList retval ; | 408 | QStringList retval ; |
409 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") | 409 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") |
410 | << i18n("Break") | 410 | << i18n("Break") |
411 | << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") | 411 | << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") |
412 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") | 412 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") |
413 | << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") | 413 | << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") |
414 | << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") | 414 | << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") |
415 | << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") | 415 | << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") |
416 | << i18n("Vacation") ; | 416 | << i18n("Vacation") ; |
417 | retval.sort(); | 417 | retval.sort(); |
418 | //qDebug("cat %s ", retval.join("-").latin1()); | 418 | //qDebug("cat %s ", retval.join("-").latin1()); |
419 | return retval; | 419 | return retval; |
420 | } | 420 | } |
421 | // << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema") | 421 | // << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema") |
422 | void KOPrefs::usrReadConfig() | 422 | void KOPrefs::usrReadConfig() |
423 | { | 423 | { |
424 | config()->setGroup("General"); | 424 | config()->setGroup("General"); |
425 | 425 | ||
426 | //qDebug("KOPrefs::usrReadConfig() "); | 426 | //qDebug("KOPrefs::usrReadConfig() "); |
427 | mCustomCategories = config()->readListEntry("Custom Categories"); | 427 | mCustomCategories = config()->readListEntry("Custom Categories"); |
428 | mOldLoadedLanguage = mOldLanguage ; | 428 | mOldLoadedLanguage = mOldLanguage ; |
429 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 429 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
430 | if (mLocationDefaults.isEmpty()) { | 430 | if (mLocationDefaults.isEmpty()) { |
431 | mLocationDefaults = getLocationDefaultList(); | 431 | mLocationDefaults = getLocationDefaultList(); |
432 | } | 432 | } |
433 | 433 | ||
434 | if (mEventSummaryUser.isEmpty()) { | 434 | if (mEventSummaryUser.isEmpty()) { |
435 | mEventSummaryUser = getDefaultList() ; | 435 | mEventSummaryUser = getDefaultList() ; |
436 | } | 436 | } |
437 | if (mTodoSummaryUser.isEmpty()) { | 437 | if (mTodoSummaryUser.isEmpty()) { |
438 | mTodoSummaryUser = getDefaultList() ; | 438 | mTodoSummaryUser = getDefaultList() ; |
439 | } | 439 | } |
440 | 440 | ||
441 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 441 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
442 | 442 | ||
443 | config()->setGroup("Personal Settings"); | 443 | config()->setGroup("Personal Settings"); |
444 | mName = config()->readEntry("user_name",""); | 444 | mName = config()->readEntry("user_name",""); |
445 | mEmail = config()->readEntry("user_email",""); | 445 | mEmail = config()->readEntry("user_email",""); |
446 | fillMailDefaults(); | 446 | fillMailDefaults(); |
447 | 447 | ||
448 | config()->setGroup("Category Colors"); | 448 | config()->setGroup("Category Colors"); |
449 | QStringList::Iterator it; | 449 | QStringList::Iterator it; |
450 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 450 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
451 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 451 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
452 | 452 | ||
453 | } | 453 | } |
454 | KConfig fc (locateLocal("config","kopicalendarrc")); | 454 | KConfig fc (locateLocal("config","kopicalendarrc")); |
455 | fc.setGroup("CC"); | 455 | fc.setGroup("CC"); |
456 | int numCals = fc.readNumEntry("NumberCalendars",0 ); | 456 | int numCals = fc.readNumEntry("NumberCalendars",0 ); |
457 | mNextAvailableCalendar = 1; | 457 | mNextAvailableCalendar = 1; |
458 | if ( numCals == 0 ) { | 458 | if ( numCals == 0 ) { |
459 | KopiCalendarFile *kkf = getNewCalendar(); | 459 | KopiCalendarFile *kkf = getNewCalendar(); |
460 | kkf->isStandard = true; | 460 | kkf->isStandard = true; |
461 | kkf->mName = i18n("Standard"); | 461 | kkf->mName = i18n("Standard"); |
462 | kkf->mFileName = QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); | 462 | kkf->mFileName = QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); |
463 | } | 463 | } |
464 | while ( mNextAvailableCalendar <= numCals ) { | 464 | while ( mNextAvailableCalendar <= numCals ) { |
465 | //qDebug("Read cal #%d ", mNextAvailableCalendar ); | 465 | //qDebug("Read cal #%d ", mNextAvailableCalendar ); |
466 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); | 466 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); |
467 | KopiCalendarFile *kkf = getNewCalendar(); | 467 | KopiCalendarFile *kkf = getNewCalendar(); |
468 | kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); | 468 | kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); |
469 | kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); | 469 | kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); |
470 | kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); | 470 | kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); |
471 | kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); | 471 | kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); |
472 | kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); | 472 | kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); |
473 | kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); | 473 | kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); |
474 | kkf->mFileName = QDir::convertSeparators( fc.readEntry( prefix+"_FileName", kkf->mFileName) ); | 474 | kkf->mFileName = QDir::convertSeparators( fc.readEntry( prefix+"_FileName", kkf->mFileName) ); |
475 | kkf->mSavedFileName = QDir::convertSeparators( fc.readEntry( prefix+"_SavedFileName", kkf->mFileName) ); | 475 | kkf->mSavedFileName = QDir::convertSeparators( fc.readEntry( prefix+"_SavedFileName", kkf->mFileName) ); |
476 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); | 476 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); |
477 | if ( kkf->mCalNumber == 1 ) { | 477 | if ( kkf->mCalNumber == 1 ) { |
478 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); | 478 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); |
479 | } | 479 | } |
480 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); | 480 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); |
481 | if ( kkf->mName == i18n("Birthdays") ) { | 481 | if ( kkf->mName == i18n("Birthdays") ) { |
482 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); | 482 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); |
483 | } | 483 | } |
484 | if ( kkf->isRelative ) | 484 | if ( kkf->isRelative ) |
485 | kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName ); | 485 | kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName ); |
486 | } | 486 | } |
487 | 487 | ||
488 | KPimPrefs::usrReadConfig(); | 488 | KPimPrefs::usrReadConfig(); |
489 | } | 489 | } |
490 | 490 | ||
491 | KopiCalendarFile * KOPrefs::getCalendar( int num ) | 491 | KopiCalendarFile * KOPrefs::getCalendar( int num ) |
492 | { | 492 | { |
493 | return mDefCalColors[num-1]; | 493 | return mDefCalColors[num-1]; |
494 | } | 494 | } |
495 | 495 | ||
496 | KopiCalendarFile * KOPrefs::getNewCalendar() | 496 | KopiCalendarFile * KOPrefs::getNewCalendar() |
497 | { | 497 | { |
498 | KopiCalendarFile * kkf = new KopiCalendarFile(); | 498 | KopiCalendarFile * kkf = new KopiCalendarFile(); |
499 | kkf->mCalNumber = mNextAvailableCalendar; | 499 | kkf->mCalNumber = mNextAvailableCalendar; |
500 | mDefCalColors.resize( mNextAvailableCalendar ); | 500 | mDefCalColors.resize( mNextAvailableCalendar ); |
501 | mDefCalColors[mNextAvailableCalendar-1] = kkf; | 501 | mDefCalColors[mNextAvailableCalendar-1] = kkf; |
502 | ++mNextAvailableCalendar; | 502 | ++mNextAvailableCalendar; |
503 | kkf->mDefaultColor = mEventColor; | 503 | kkf->mDefaultColor = mEventColor; |
504 | kkf->mName = i18n("New Calendar"); | 504 | kkf->mName = i18n("New Calendar"); |
505 | mCalendars.append( kkf ); | 505 | mCalendars.append( kkf ); |
506 | return kkf; | 506 | return kkf; |
507 | } | 507 | } |
508 | void KOPrefs::deleteCalendar( int num ) | 508 | void KOPrefs::deleteCalendar( int num ) |
509 | { | 509 | { |
510 | KopiCalendarFile * kkf = mCalendars.first(); | 510 | KopiCalendarFile * kkf = mCalendars.first(); |
511 | while ( kkf ) { | 511 | while ( kkf ) { |
512 | if ( kkf->mCalNumber == num ) { | 512 | if ( kkf->mCalNumber == num ) { |
513 | qDebug("KOPrefs::deleteCalendar %d ", num ); | 513 | qDebug("KOPrefs::deleteCalendar %d ", num ); |
514 | mCalendars.remove( kkf ); | 514 | mCalendars.remove( kkf ); |
515 | delete kkf; | 515 | delete kkf; |
516 | return; | 516 | return; |
517 | } | 517 | } |
518 | kkf = mCalendars.next(); | 518 | kkf = mCalendars.next(); |
519 | } | 519 | } |
520 | } | 520 | } |
521 | int KOPrefs::getCalendarID( const QString & name ) | 521 | int KOPrefs::getCalendarID( const QString & name ) |
522 | { | 522 | { |
523 | KopiCalendarFile * kkf = mCalendars.first(); | 523 | KopiCalendarFile * kkf = mCalendars.first(); |
524 | while ( kkf ) { | 524 | while ( kkf ) { |
525 | if ( name == kkf->mName) | 525 | if ( name == kkf->mName) |
526 | return kkf->mCalNumber; | 526 | return kkf->mCalNumber; |
527 | kkf = mCalendars.next(); | 527 | kkf = mCalendars.next(); |
528 | } | 528 | } |
529 | return 1; | 529 | return 1; |
530 | } | 530 | } |
531 | int KOPrefs::getFuzzyCalendarID( const QString & name ) | ||
532 | { | ||
533 | KopiCalendarFile * kkf = mCalendars.first(); | ||
534 | while ( kkf ) { | ||
535 | if ( name.lower() == kkf->mName.lower()) | ||
536 | return kkf->mCalNumber; | ||
537 | kkf = mCalendars.next(); | ||
538 | } | ||
539 | return 0; | ||
540 | } | ||
531 | QString KOPrefs::calName( int calNum) const | 541 | QString KOPrefs::calName( int calNum) const |
532 | { | 542 | { |
533 | return (mDefCalColors[calNum-1])->mName; | 543 | return (mDefCalColors[calNum-1])->mName; |
534 | } | 544 | } |
535 | QColor KOPrefs::defaultColor( int calNum ) const | 545 | QColor KOPrefs::defaultColor( int calNum ) const |
536 | { | 546 | { |
537 | if ( calNum == 1 ) return mEventColor; | 547 | if ( calNum == 1 ) return mEventColor; |
538 | return (mDefCalColors[calNum-1])->mDefaultColor; | 548 | return (mDefCalColors[calNum-1])->mDefaultColor; |
539 | } | 549 | } |
540 | void KOPrefs::usrWriteConfig() | 550 | void KOPrefs::usrWriteConfig() |
541 | { | 551 | { |
542 | config()->setGroup("General"); | 552 | config()->setGroup("General"); |
543 | config()->writeEntry("Custom Categories",mCustomCategories); | 553 | config()->writeEntry("Custom Categories",mCustomCategories); |
544 | 554 | ||
545 | config()->setGroup("Personal Settings"); | 555 | config()->setGroup("Personal Settings"); |
546 | config()->writeEntry("user_name",mName); | 556 | config()->writeEntry("user_name",mName); |
547 | config()->writeEntry("user_email",mEmail); | 557 | config()->writeEntry("user_email",mEmail); |
548 | 558 | ||
549 | config()->setGroup("Category Colors"); | 559 | config()->setGroup("Category Colors"); |
550 | QDictIterator<QColor> it(mCategoryColors); | 560 | QDictIterator<QColor> it(mCategoryColors); |
551 | while (it.current()) { | 561 | while (it.current()) { |
552 | config()->writeEntry(it.currentKey(),*(it.current())); | 562 | config()->writeEntry(it.currentKey(),*(it.current())); |
553 | ++it; | 563 | ++it; |
554 | } | 564 | } |
555 | KConfig fc (locateLocal("config","kopicalendarrc")); | 565 | KConfig fc (locateLocal("config","kopicalendarrc")); |
556 | fc.setGroup("CC"); | 566 | fc.setGroup("CC"); |
557 | fc.deleteGroup( "CC"); | 567 | fc.deleteGroup( "CC"); |
558 | fc.setGroup("CC"); | 568 | fc.setGroup("CC"); |
559 | fc.writeEntry("NumberCalendars",mCalendars.count()); | 569 | fc.writeEntry("NumberCalendars",mCalendars.count()); |
560 | int numCal = 1; | 570 | int numCal = 1; |
561 | int writeCal = 0; | 571 | int writeCal = 0; |
562 | while ( numCal < mNextAvailableCalendar ) { | 572 | while ( numCal < mNextAvailableCalendar ) { |
563 | KopiCalendarFile * kkf = mCalendars.first(); | 573 | KopiCalendarFile * kkf = mCalendars.first(); |
564 | while ( kkf ) { | 574 | while ( kkf ) { |
565 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); | 575 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); |
566 | if ( kkf->mCalNumber == numCal ) { | 576 | if ( kkf->mCalNumber == numCal ) { |
567 | ++writeCal; | 577 | ++writeCal; |
568 | //qDebug("Write calendar %d %d ", numCal , writeCal); | 578 | //qDebug("Write calendar %d %d ", numCal , writeCal); |
569 | QString prefix = "Cal_" + QString::number( writeCal ); | 579 | QString prefix = "Cal_" + QString::number( writeCal ); |
570 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); | 580 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); |
571 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); | 581 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); |
572 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); | 582 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); |
573 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); | 583 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); |
574 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); | 584 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); |
575 | fc.writeEntry( prefix+"_Name", kkf->mName); | 585 | fc.writeEntry( prefix+"_Name", kkf->mName); |
576 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); | 586 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); |
577 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); | 587 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); |
578 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); | 588 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); |
579 | } | 589 | } |
580 | kkf = mCalendars.next(); | 590 | kkf = mCalendars.next(); |
581 | } | 591 | } |
582 | ++numCal; | 592 | ++numCal; |
583 | } | 593 | } |
584 | fc.sync(); | 594 | fc.sync(); |
585 | KPimPrefs::usrWriteConfig(); | 595 | KPimPrefs::usrWriteConfig(); |
586 | } | 596 | } |
587 | 597 | ||
588 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 598 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
589 | { | 599 | { |
590 | mCategoryColors.replace(cat,new QColor(color)); | 600 | mCategoryColors.replace(cat,new QColor(color)); |
591 | } | 601 | } |
592 | 602 | ||
593 | QColor *KOPrefs::categoryColor(QString cat) | 603 | QColor *KOPrefs::categoryColor(QString cat) |
594 | { | 604 | { |
595 | QColor *color = 0; | 605 | QColor *color = 0; |
596 | 606 | ||
597 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 607 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
598 | 608 | ||
599 | if (color) return color; | 609 | if (color) return color; |
600 | else return &mDefaultCategoryColor; | 610 | else return &mDefaultCategoryColor; |
601 | } | 611 | } |
602 | 612 | ||
603 | void KOPrefs::setFullName(const QString &name) | 613 | void KOPrefs::setFullName(const QString &name) |
604 | { | 614 | { |
605 | mName = name; | 615 | mName = name; |
606 | } | 616 | } |
607 | 617 | ||
608 | void KOPrefs::setEmail(const QString &email) | 618 | void KOPrefs::setEmail(const QString &email) |
609 | { | 619 | { |
610 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 620 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
611 | mEmail = email; | 621 | mEmail = email; |
612 | } | 622 | } |
613 | 623 | ||
614 | QString KOPrefs::fullName() | 624 | QString KOPrefs::fullName() |
615 | { | 625 | { |
616 | if (mEmailControlCenter) { | 626 | if (mEmailControlCenter) { |
617 | KEMailSettings settings; | 627 | KEMailSettings settings; |
618 | return settings.getSetting(KEMailSettings::RealName); | 628 | return settings.getSetting(KEMailSettings::RealName); |
619 | } else { | 629 | } else { |
620 | return mName; | 630 | return mName; |
621 | } | 631 | } |
622 | } | 632 | } |
623 | 633 | ||
624 | QString KOPrefs::email() | 634 | QString KOPrefs::email() |
625 | { | 635 | { |
626 | if (mEmailControlCenter) { | 636 | if (mEmailControlCenter) { |
627 | KEMailSettings settings; | 637 | KEMailSettings settings; |
628 | return settings.getSetting(KEMailSettings::EmailAddress); | 638 | return settings.getSetting(KEMailSettings::EmailAddress); |
629 | } else { | 639 | } else { |
630 | return mEmail; | 640 | return mEmail; |
631 | } | 641 | } |
632 | } | 642 | } |
633 | KConfig* KOPrefs::getConfig() | 643 | KConfig* KOPrefs::getConfig() |
634 | { | 644 | { |
635 | return config(); | 645 | return config(); |
636 | } | 646 | } |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index bac8010..70da096 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -1,376 +1,377 @@ | |||
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 | #ifndef KOPREFS_H | 23 | #ifndef KOPREFS_H |
24 | #define KOPREFS_H | 24 | #define KOPREFS_H |
25 | 25 | ||
26 | 26 | ||
27 | #include <libkdepim/kpimprefs.h> | 27 | #include <libkdepim/kpimprefs.h> |
28 | #include <qdict.h> | 28 | #include <qdict.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qobject.h> | 30 | #include <qobject.h> |
31 | 31 | ||
32 | class KConfig; | 32 | class KConfig; |
33 | class QFont; | 33 | class QFont; |
34 | class QColor; | 34 | class QColor; |
35 | class QStringList; | 35 | class QStringList; |
36 | 36 | ||
37 | #define VIEW_WN_VIEW 1 | 37 | #define VIEW_WN_VIEW 1 |
38 | #define VIEW_NX_VIEW 2 | 38 | #define VIEW_NX_VIEW 2 |
39 | #define VIEW_J_VIEW 3 | 39 | #define VIEW_J_VIEW 3 |
40 | #define VIEW_A_VIEW 4 | 40 | #define VIEW_A_VIEW 4 |
41 | #define VIEW_ML_VIEW 5 | 41 | #define VIEW_ML_VIEW 5 |
42 | #define VIEW_M_VIEW 6 | 42 | #define VIEW_M_VIEW 6 |
43 | #define VIEW_L_VIEW 7 | 43 | #define VIEW_L_VIEW 7 |
44 | #define VIEW_T_VIEW 8 | 44 | #define VIEW_T_VIEW 8 |
45 | 45 | ||
46 | class KopiCalendarFile : public QObject | 46 | class KopiCalendarFile : public QObject |
47 | { | 47 | { |
48 | public: | 48 | public: |
49 | KopiCalendarFile( ) : QObject( ) | 49 | KopiCalendarFile( ) : QObject( ) |
50 | { | 50 | { |
51 | isStandard = false; | 51 | isStandard = false; |
52 | isEnabled = true; | 52 | isEnabled = true; |
53 | isAlarmEnabled = true; | 53 | isAlarmEnabled = true; |
54 | isReadOnly = false; | 54 | isReadOnly = false; |
55 | mName = "Calendar"; | 55 | mName = "Calendar"; |
56 | mFileName = QDir::homeDirPath() + "/icalfile.ics"; | 56 | mFileName = QDir::homeDirPath() + "/icalfile.ics"; |
57 | mSavedFileName = "icalfile.ics"; | 57 | mSavedFileName = "icalfile.ics"; |
58 | mCalNumber = 0; | 58 | mCalNumber = 0; |
59 | mDefaultColor = Qt::red; | 59 | mDefaultColor = Qt::red; |
60 | mErrorOnLoad = false; | 60 | mErrorOnLoad = false; |
61 | isRelative = false; | 61 | isRelative = false; |
62 | } | 62 | } |
63 | bool isStandard; | 63 | bool isStandard; |
64 | bool isEnabled; | 64 | bool isEnabled; |
65 | bool isAlarmEnabled; | 65 | bool isAlarmEnabled; |
66 | bool isReadOnly; | 66 | bool isReadOnly; |
67 | bool mErrorOnLoad; | 67 | bool mErrorOnLoad; |
68 | QString mName; | 68 | QString mName; |
69 | QString mFileName; | 69 | QString mFileName; |
70 | QString mSavedFileName; | 70 | QString mSavedFileName; |
71 | bool isRelative; | 71 | bool isRelative; |
72 | int mCalNumber; | 72 | int mCalNumber; |
73 | QColor mDefaultColor; | 73 | QColor mDefaultColor; |
74 | QDateTime mLoadDt; | 74 | QDateTime mLoadDt; |
75 | }; | 75 | }; |
76 | class KOPrefs : public KPimPrefs | 76 | class KOPrefs : public KPimPrefs |
77 | { | 77 | { |
78 | public: | 78 | public: |
79 | enum { FormatVCalendar, FormatICalendar }; | 79 | enum { FormatVCalendar, FormatICalendar }; |
80 | enum { MailClientKMail, MailClientSendmail }; | 80 | enum { MailClientKMail, MailClientSendmail }; |
81 | enum { IMIPDummy, IMIPKMail }; | 81 | enum { IMIPDummy, IMIPKMail }; |
82 | enum { IMIPOutbox, IMIPdirectsend }; | 82 | enum { IMIPOutbox, IMIPdirectsend }; |
83 | enum { neverAuto, addressbookAuto, selectedAuto }; | 83 | enum { neverAuto, addressbookAuto, selectedAuto }; |
84 | enum { standardDestination, askDestination }; | 84 | enum { standardDestination, askDestination }; |
85 | 85 | ||
86 | virtual ~KOPrefs(); | 86 | virtual ~KOPrefs(); |
87 | 87 | ||
88 | /** Get instance of KOPrefs. It is made sure that there is only one | 88 | /** Get instance of KOPrefs. It is made sure that there is only one |
89 | instance. */ | 89 | instance. */ |
90 | static KOPrefs *instance(); | 90 | static KOPrefs *instance(); |
91 | 91 | ||
92 | /** Set preferences to default values */ | 92 | /** Set preferences to default values */ |
93 | void usrSetDefaults(); | 93 | void usrSetDefaults(); |
94 | 94 | ||
95 | /** Read preferences from config file */ | 95 | /** Read preferences from config file */ |
96 | void usrReadConfig(); | 96 | void usrReadConfig(); |
97 | 97 | ||
98 | /** Write preferences to config file */ | 98 | /** Write preferences to config file */ |
99 | void usrWriteConfig(); | 99 | void usrWriteConfig(); |
100 | void setCategoryDefaults(); | 100 | void setCategoryDefaults(); |
101 | void setAllDefaults(); | 101 | void setAllDefaults(); |
102 | KopiCalendarFile * getNewCalendar(); | 102 | KopiCalendarFile * getNewCalendar(); |
103 | KopiCalendarFile * getCalendar( int ); | 103 | KopiCalendarFile * getCalendar( int ); |
104 | void deleteCalendar( int ); | 104 | void deleteCalendar( int ); |
105 | QColor defaultColor( int ) const; | 105 | QColor defaultColor( int ) const; |
106 | QString calName( int ) const; | 106 | QString calName( int ) const; |
107 | int getCalendarID( const QString & name ); | 107 | int getCalendarID( const QString & name ); |
108 | int getFuzzyCalendarID( const QString & name ); | ||
108 | protected: | 109 | protected: |
109 | void setTimeZoneIdDefault(); | 110 | void setTimeZoneIdDefault(); |
110 | 111 | ||
111 | /** Fill empty mail fields with default values. */ | 112 | /** Fill empty mail fields with default values. */ |
112 | void fillMailDefaults(); | 113 | void fillMailDefaults(); |
113 | 114 | ||
114 | private: | 115 | private: |
115 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 116 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
116 | object. */ | 117 | object. */ |
117 | KOPrefs(); | 118 | KOPrefs(); |
118 | 119 | ||
119 | static KOPrefs *mInstance; | 120 | static KOPrefs *mInstance; |
120 | QStringList getDefaultList(); | 121 | QStringList getDefaultList(); |
121 | QStringList getLocationDefaultList(); | 122 | QStringList getLocationDefaultList(); |
122 | public: | 123 | public: |
123 | // preferences data | 124 | // preferences data |
124 | KConfig* getConfig(); | 125 | KConfig* getConfig(); |
125 | void setFullName(const QString &); | 126 | void setFullName(const QString &); |
126 | QString fullName(); | 127 | QString fullName(); |
127 | void setEmail(const QString &); | 128 | void setEmail(const QString &); |
128 | QString email(); | 129 | QString email(); |
129 | 130 | ||
130 | QString mAdditional; | 131 | QString mAdditional; |
131 | 132 | ||
132 | bool mEmailControlCenter; | 133 | bool mEmailControlCenter; |
133 | 134 | ||
134 | bool mBcc; | 135 | bool mBcc; |
135 | bool mAutoSave; | 136 | bool mAutoSave; |
136 | int mAutoSaveInterval; | 137 | int mAutoSaveInterval; |
137 | bool mConfirm; | 138 | bool mConfirm; |
138 | 139 | ||
139 | bool mEnableGroupScheduling; | 140 | bool mEnableGroupScheduling; |
140 | bool mEnableProjectView; | 141 | bool mEnableProjectView; |
141 | 142 | ||
142 | int mDefaultFormat; | 143 | int mDefaultFormat; |
143 | int mMailClient; | 144 | int mMailClient; |
144 | 145 | ||
145 | int mStartTime; | 146 | int mStartTime; |
146 | int mDefaultDuration; | 147 | int mDefaultDuration; |
147 | int mAlarmTime; | 148 | int mAlarmTime; |
148 | 149 | ||
149 | int mWorkingHoursStart; | 150 | int mWorkingHoursStart; |
150 | int mWorkingHoursEnd; | 151 | int mWorkingHoursEnd; |
151 | bool mExcludeHolidays; | 152 | bool mExcludeHolidays; |
152 | bool mExcludeSaturdays; | 153 | bool mExcludeSaturdays; |
153 | bool mMarcusBainsShowSeconds; | 154 | bool mMarcusBainsShowSeconds; |
154 | 155 | ||
155 | QFont mTimeBarFont; | 156 | QFont mTimeBarFont; |
156 | QFont mMonthViewFont; | 157 | QFont mMonthViewFont; |
157 | QFont mAgendaViewFont; | 158 | QFont mAgendaViewFont; |
158 | QFont mMarcusBainsFont; | 159 | QFont mMarcusBainsFont; |
159 | QFont mTimeLabelsFont; | 160 | QFont mTimeLabelsFont; |
160 | QFont mTodoViewFont; | 161 | QFont mTodoViewFont; |
161 | QFont mListViewFont; | 162 | QFont mListViewFont; |
162 | QFont mDateNavigatorFont; | 163 | QFont mDateNavigatorFont; |
163 | QFont mEditBoxFont; | 164 | QFont mEditBoxFont; |
164 | QFont mJornalViewFont; | 165 | QFont mJornalViewFont; |
165 | QFont mWhatsNextFont; | 166 | QFont mWhatsNextFont; |
166 | QFont mEventViewFont; | 167 | QFont mEventViewFont; |
167 | 168 | ||
168 | 169 | ||
169 | 170 | ||
170 | 171 | ||
171 | QColor mHolidayColor; | 172 | QColor mHolidayColor; |
172 | QColor mHighlightColor; | 173 | QColor mHighlightColor; |
173 | QColor mEventColor; | 174 | QColor mEventColor; |
174 | QColor mTodoDoneColor; | 175 | QColor mTodoDoneColor; |
175 | QColor mAgendaBgColor; | 176 | QColor mAgendaBgColor; |
176 | QColor mWorkingHoursColor; | 177 | QColor mWorkingHoursColor; |
177 | QColor mTodoDueTodayColor; | 178 | QColor mTodoDueTodayColor; |
178 | QColor mTodoOverdueColor; | 179 | QColor mTodoOverdueColor; |
179 | QColor mTodoRunColor; | 180 | QColor mTodoRunColor; |
180 | QColor mMonthViewEvenColor; | 181 | QColor mMonthViewEvenColor; |
181 | QColor mMonthViewOddColor; | 182 | QColor mMonthViewOddColor; |
182 | QColor mMonthViewHolidayColor; | 183 | QColor mMonthViewHolidayColor; |
183 | bool mMonthViewUsesDayColors; | 184 | bool mMonthViewUsesDayColors; |
184 | bool mMonthViewSatSunTog; | 185 | bool mMonthViewSatSunTog; |
185 | bool mMonthViewWeek; | 186 | bool mMonthViewWeek; |
186 | bool mMonthViewWeekRowlayout; | 187 | bool mMonthViewWeekRowlayout; |
187 | QColor mAppColor1; | 188 | QColor mAppColor1; |
188 | QColor mAppColor2; | 189 | QColor mAppColor2; |
189 | bool mUseAppColors; | 190 | bool mUseAppColors; |
190 | 191 | ||
191 | int mDayBegins; | 192 | int mDayBegins; |
192 | int mHourSize; | 193 | int mHourSize; |
193 | int mAllDaySize; | 194 | int mAllDaySize; |
194 | bool mShowFullMenu; | 195 | bool mShowFullMenu; |
195 | bool mDailyRecur; | 196 | bool mDailyRecur; |
196 | bool mWeeklyRecur; | 197 | bool mWeeklyRecur; |
197 | bool mLongAllday; | 198 | bool mLongAllday; |
198 | bool mMonthDailyRecur; | 199 | bool mMonthDailyRecur; |
199 | bool mMonthWeeklyRecur; | 200 | bool mMonthWeeklyRecur; |
200 | bool mMonthShowIcons; | 201 | bool mMonthShowIcons; |
201 | bool mMonthShowTimes; | 202 | bool mMonthShowTimes; |
202 | bool mMonthShowShort; | 203 | bool mMonthShowShort; |
203 | bool mEnableToolTips; | 204 | bool mEnableToolTips; |
204 | bool mEnableMonthScroll; | 205 | bool mEnableMonthScroll; |
205 | bool mFullViewMonth; | 206 | bool mFullViewMonth; |
206 | bool mMonthViewUsesCategoryColor; | 207 | bool mMonthViewUsesCategoryColor; |
207 | bool mFullViewTodo; | 208 | bool mFullViewTodo; |
208 | bool mShowCompletedTodo; | 209 | bool mShowCompletedTodo; |
209 | bool mMarcusBainsEnabled; | 210 | bool mMarcusBainsEnabled; |
210 | int mNextXDays; | 211 | int mNextXDays; |
211 | int mWhatsNextDays; | 212 | int mWhatsNextDays; |
212 | bool mWhatsNextTime2Lines; | 213 | bool mWhatsNextTime2Lines; |
213 | int mWhatsNextPrios; | 214 | int mWhatsNextPrios; |
214 | bool mEnableQuickTodo; | 215 | bool mEnableQuickTodo; |
215 | 216 | ||
216 | bool mCompactDialogs; | 217 | bool mCompactDialogs; |
217 | bool mVerticalScreen; | 218 | bool mVerticalScreen; |
218 | 219 | ||
219 | bool mShowIconNewTodo; | 220 | bool mShowIconNewTodo; |
220 | bool mShowIconNewEvent; | 221 | bool mShowIconNewEvent; |
221 | bool mShowIconSearch; | 222 | bool mShowIconSearch; |
222 | bool mShowIconList; | 223 | bool mShowIconList; |
223 | bool mShowIconDay1; | 224 | bool mShowIconDay1; |
224 | bool mShowIconDay5; | 225 | bool mShowIconDay5; |
225 | bool mShowIconDay6; | 226 | bool mShowIconDay6; |
226 | bool mShowIconDay7; | 227 | bool mShowIconDay7; |
227 | bool mShowIconMonth; | 228 | bool mShowIconMonth; |
228 | bool mShowIconTodoview; | 229 | bool mShowIconTodoview; |
229 | bool mShowIconBackFast; | 230 | bool mShowIconBackFast; |
230 | bool mShowIconBack; | 231 | bool mShowIconBack; |
231 | bool mShowIconToday; | 232 | bool mShowIconToday; |
232 | bool mShowIconForward; | 233 | bool mShowIconForward; |
233 | bool mShowIconForwardFast; | 234 | bool mShowIconForwardFast; |
234 | bool mShowIconWhatsThis; | 235 | bool mShowIconWhatsThis; |
235 | bool mShowIconWeekNum; | 236 | bool mShowIconWeekNum; |
236 | bool mShowIconNextDays; | 237 | bool mShowIconNextDays; |
237 | bool mShowIconNext; | 238 | bool mShowIconNext; |
238 | bool mShowIconJournal; | 239 | bool mShowIconJournal; |
239 | bool mShowIconFilter; | 240 | bool mShowIconFilter; |
240 | bool mShowIconOnetoolbar; | 241 | bool mShowIconOnetoolbar; |
241 | bool mShowIconNavigator; | 242 | bool mShowIconNavigator; |
242 | bool mShowIconAllday; | 243 | bool mShowIconAllday; |
243 | bool mShowIconFilterview; | 244 | bool mShowIconFilterview; |
244 | bool mShowIconToggleFull; | 245 | bool mShowIconToggleFull; |
245 | 246 | ||
246 | bool mShowIconStretch; | 247 | bool mShowIconStretch; |
247 | 248 | ||
248 | bool mToolBarHor; | 249 | bool mToolBarHor; |
249 | bool mToolBarUp; | 250 | bool mToolBarUp; |
250 | bool mToolBarHorV; | 251 | bool mToolBarHorV; |
251 | bool mToolBarUpV; | 252 | bool mToolBarUpV; |
252 | bool mToolBarHorN; | 253 | bool mToolBarHorN; |
253 | bool mToolBarUpN; | 254 | bool mToolBarUpN; |
254 | bool mToolBarHorF; | 255 | bool mToolBarHorF; |
255 | bool mToolBarUpF; | 256 | bool mToolBarUpF; |
256 | bool mToolBarMiniIcons; | 257 | bool mToolBarMiniIcons; |
257 | 258 | ||
258 | bool mAskForQuit; | 259 | bool mAskForQuit; |
259 | bool mUsePassWd; | 260 | bool mUsePassWd; |
260 | bool mShowSyncEvents; | 261 | bool mShowSyncEvents; |
261 | bool mShowTodoInAgenda; | 262 | bool mShowTodoInAgenda; |
262 | bool mShowCompletedTodoInAgenda; | 263 | bool mShowCompletedTodoInAgenda; |
263 | bool mShowTimeInAgenda; | 264 | bool mShowTimeInAgenda; |
264 | bool mHideNonStartedTodos; | 265 | bool mHideNonStartedTodos; |
265 | 266 | ||
266 | bool mBlockPopupMenu; | 267 | bool mBlockPopupMenu; |
267 | 268 | ||
268 | int mLastSyncTime; | 269 | int mLastSyncTime; |
269 | void setCategoryColor(QString cat,const QColor & color); | 270 | void setCategoryColor(QString cat,const QColor & color); |
270 | QColor *categoryColor(QString cat); | 271 | QColor *categoryColor(QString cat); |
271 | 272 | ||
272 | QString mArchiveFile; | 273 | QString mArchiveFile; |
273 | QString mHtmlExportFile; | 274 | QString mHtmlExportFile; |
274 | bool mHtmlWithSave; | 275 | bool mHtmlWithSave; |
275 | 276 | ||
276 | QStringList mSelectedPlugins; | 277 | QStringList mSelectedPlugins; |
277 | 278 | ||
278 | QString mLastImportFile; | 279 | QString mLastImportFile; |
279 | QString mLastVcalFile; | 280 | QString mLastVcalFile; |
280 | QString mLastSaveFile; | 281 | QString mLastSaveFile; |
281 | QString mLastLoadFile; | 282 | QString mLastLoadFile; |
282 | 283 | ||
283 | 284 | ||
284 | QString mDefaultAlarmFile; | 285 | QString mDefaultAlarmFile; |
285 | int mIMIPScheduler; | 286 | int mIMIPScheduler; |
286 | int mIMIPSend; | 287 | int mIMIPSend; |
287 | QStringList mAdditionalMails; | 288 | QStringList mAdditionalMails; |
288 | int mIMIPAutoRefresh; | 289 | int mIMIPAutoRefresh; |
289 | int mIMIPAutoInsertReply; | 290 | int mIMIPAutoInsertReply; |
290 | int mIMIPAutoInsertRequest; | 291 | int mIMIPAutoInsertRequest; |
291 | int mIMIPAutoFreeBusy; | 292 | int mIMIPAutoFreeBusy; |
292 | int mIMIPAutoFreeBusyReply; | 293 | int mIMIPAutoFreeBusyReply; |
293 | 294 | ||
294 | QStringList mTodoTemplates; | 295 | QStringList mTodoTemplates; |
295 | QStringList mEventTemplates; | 296 | QStringList mEventTemplates; |
296 | 297 | ||
297 | int mDestination; | 298 | int mDestination; |
298 | 299 | ||
299 | 300 | ||
300 | bool mEditOnDoubleClick; | 301 | bool mEditOnDoubleClick; |
301 | bool mViewChangeHoldFullscreen; | 302 | bool mViewChangeHoldFullscreen; |
302 | bool mViewChangeHoldNonFullscreen; | 303 | bool mViewChangeHoldNonFullscreen; |
303 | bool mCenterOnCurrentTime; | 304 | bool mCenterOnCurrentTime; |
304 | bool mSetTimeToDayStartAt; | 305 | bool mSetTimeToDayStartAt; |
305 | bool mHighlightCurrentDay; | 306 | bool mHighlightCurrentDay; |
306 | bool mUseHighlightLightColor; | 307 | bool mUseHighlightLightColor; |
307 | bool mListViewMonthTimespan; | 308 | bool mListViewMonthTimespan; |
308 | bool mWNViewShowsParents; | 309 | bool mWNViewShowsParents; |
309 | bool mWNViewShowsPast; | 310 | bool mWNViewShowsPast; |
310 | bool mWNViewShowLocation; | 311 | bool mWNViewShowLocation; |
311 | bool mTodoViewShowsPercentage; | 312 | bool mTodoViewShowsPercentage; |
312 | bool mTodoViewUsesCatColors; | 313 | bool mTodoViewUsesCatColors; |
313 | bool mMonthViewUsesBigFont; | 314 | bool mMonthViewUsesBigFont; |
314 | bool mTodoViewUsesSmallFont; | 315 | bool mTodoViewUsesSmallFont; |
315 | bool mTodoViewUsesForegroundColor; | 316 | bool mTodoViewUsesForegroundColor; |
316 | bool mMonthViewUsesForegroundColor; | 317 | bool mMonthViewUsesForegroundColor; |
317 | 318 | ||
318 | bool mHightlightDateTimeEdit; | 319 | bool mHightlightDateTimeEdit; |
319 | bool mShortDateInViewer; | 320 | bool mShortDateInViewer; |
320 | 321 | ||
321 | bool mShowDateNavigator; | 322 | bool mShowDateNavigator; |
322 | 323 | ||
323 | QStringList mLocationDefaults; | 324 | QStringList mLocationDefaults; |
324 | QStringList mEventSummaryUser; | 325 | QStringList mEventSummaryUser; |
325 | QStringList mTodoSummaryUser; | 326 | QStringList mTodoSummaryUser; |
326 | QStringList mJournalSummaryUser; | 327 | QStringList mJournalSummaryUser; |
327 | 328 | ||
328 | bool mUseInternalAlarmNotification; | 329 | bool mUseInternalAlarmNotification; |
329 | int mAlarmPlayBeeps; | 330 | int mAlarmPlayBeeps; |
330 | int mAlarmSuspendTime; | 331 | int mAlarmSuspendTime; |
331 | int mAlarmSuspendCount; | 332 | int mAlarmSuspendCount; |
332 | int mAlarmBeepInterval; | 333 | int mAlarmBeepInterval; |
333 | int mOldLanguage; | 334 | int mOldLanguage; |
334 | int mOldLoadedLanguage; | 335 | int mOldLoadedLanguage; |
335 | 336 | ||
336 | 337 | ||
337 | QString mActiveSyncPort; | 338 | QString mActiveSyncPort; |
338 | QString mActiveSyncIP; | 339 | QString mActiveSyncIP; |
339 | 340 | ||
340 | // settings for eventviewer | 341 | // settings for eventviewer |
341 | bool mEVshowDetails; | 342 | bool mEVshowDetails; |
342 | bool mEVshowCreated; | 343 | bool mEVshowCreated; |
343 | bool mEVshowChanged; | 344 | bool mEVshowChanged; |
344 | bool mWTshowDetails; | 345 | bool mWTshowDetails; |
345 | bool mWTshowCreated; | 346 | bool mWTshowCreated; |
346 | bool mWTshowChanged; | 347 | bool mWTshowChanged; |
347 | 348 | ||
348 | int mCurrentDisplayedView; | 349 | int mCurrentDisplayedView; |
349 | QPtrList<KopiCalendarFile> mCalendars; | 350 | QPtrList<KopiCalendarFile> mCalendars; |
350 | int mNextAvailableCalendar; | 351 | int mNextAvailableCalendar; |
351 | bool mGlobalUpdateDisabled; | 352 | bool mGlobalUpdateDisabled; |
352 | 353 | ||
353 | 354 | ||
354 | bool mDetectConflicts; | 355 | bool mDetectConflicts; |
355 | bool mIncludeFree; | 356 | bool mIncludeFree; |
356 | bool mCheckConflictsAllDayAllDay; | 357 | bool mCheckConflictsAllDayAllDay; |
357 | bool mCheckConflictsAllDayNonAD; | 358 | bool mCheckConflictsAllDayNonAD; |
358 | bool mCheckConflictsNonADAllDay; | 359 | bool mCheckConflictsNonADAllDay; |
359 | bool mCheckConflictsNonADNonAD; | 360 | bool mCheckConflictsNonADNonAD; |
360 | QString mFilterConflictEditItem; | 361 | QString mFilterConflictEditItem; |
361 | QString mFilterConflictAllItem; | 362 | QString mFilterConflictAllItem; |
362 | 363 | ||
363 | private: | 364 | private: |
364 | QDict<QColor> mCategoryColors; | 365 | QDict<QColor> mCategoryColors; |
365 | QArray<KopiCalendarFile*> mDefCalColors; | 366 | QArray<KopiCalendarFile*> mDefCalColors; |
366 | QColor mDefaultCategoryColor; | 367 | QColor mDefaultCategoryColor; |
367 | 368 | ||
368 | QFont mDefaultTimeBarFont; | 369 | QFont mDefaultTimeBarFont; |
369 | QFont mDefaultViewFont; | 370 | QFont mDefaultViewFont; |
370 | QFont mDefaultMonthViewFont; | 371 | QFont mDefaultMonthViewFont; |
371 | 372 | ||
372 | QString mName; | 373 | QString mName; |
373 | QString mEmail; | 374 | QString mEmail; |
374 | }; | 375 | }; |
375 | 376 | ||
376 | #endif | 377 | #endif |