author | zautrix <zautrix> | 2005-08-10 17:39:44 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-10 17:39:44 (UTC) |
commit | 1a13e55dd4726cc03c756412fe27b3144a43fc4c (patch) (unidiff) | |
tree | e41b3f85d0a011b1416c4ea50a9348ee3863a4df /korganizer/calendarview.cpp | |
parent | 1af305e995d99549091c5b1e167b6101a3910f0d (diff) | |
download | kdepimpi-1a13e55dd4726cc03c756412fe27b3144a43fc4c.zip kdepimpi-1a13e55dd4726cc03c756412fe27b3144a43fc4c.tar.gz kdepimpi-1a13e55dd4726cc03c756412fe27b3144a43fc4c.tar.bz2 |
alarm save as file
-rw-r--r-- | korganizer/calendarview.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index d51187a..316826a 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1062,411 +1062,441 @@ void CalendarView::checkAlarms() | |||
1062 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); | 1062 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); |
1063 | nt->setPercentComplete( 20 ); | 1063 | nt->setPercentComplete( 20 ); |
1064 | Todo * workLutz12 = nt; | 1064 | Todo * workLutz12 = nt; |
1065 | workLutz12->setRelatedTo( sub2 ); | 1065 | workLutz12->setRelatedTo( sub2 ); |
1066 | 1066 | ||
1067 | nt = new Todo; | 1067 | nt = new Todo; |
1068 | mCalendar->addTodo( nt ); | 1068 | mCalendar->addTodo( nt ); |
1069 | nt->setSummary( "Work on 2: Norbert"); | 1069 | nt->setSummary( "Work on 2: Norbert"); |
1070 | nt->setPriority( 1 ); | 1070 | nt->setPriority( 1 ); |
1071 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1071 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1072 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); | 1072 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); |
1073 | nt->setPercentComplete( 20 ); | 1073 | nt->setPercentComplete( 20 ); |
1074 | Todo * workNorbert12 = nt; | 1074 | Todo * workNorbert12 = nt; |
1075 | workNorbert12->setRelatedTo( sub2 ); | 1075 | workNorbert12->setRelatedTo( sub2 ); |
1076 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); | 1076 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); |
1077 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); | 1077 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); |
1078 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); | 1078 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); |
1079 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); | 1079 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); |
1080 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); | 1080 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); |
1081 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); | 1081 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); |
1082 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); | 1082 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); |
1083 | } | 1083 | } |
1084 | updateView(); | 1084 | updateView(); |
1085 | #endif | 1085 | #endif |
1086 | 1086 | ||
1087 | } | 1087 | } |
1088 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) | 1088 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) |
1089 | { | 1089 | { |
1090 | static int ccc = 0; | 1090 | static int ccc = 0; |
1091 | ++ccc; | 1091 | ++ccc; |
1092 | QDateTime t_start = start; | 1092 | QDateTime t_start = start; |
1093 | runT->setPriority( 5 ); | 1093 | runT->setPriority( 5 ); |
1094 | runT->setPercentComplete( 0 ); | 1094 | runT->setPercentComplete( 0 ); |
1095 | int count = 0; | 1095 | int count = 0; |
1096 | int prio = 5; | 1096 | int prio = 5; |
1097 | int complete = 0; | 1097 | int complete = 0; |
1098 | while ( t_start < end ) { | 1098 | while ( t_start < end ) { |
1099 | ++count; | 1099 | ++count; |
1100 | if ( count > ccc ) { | 1100 | if ( count > ccc ) { |
1101 | count = 0; | 1101 | count = 0; |
1102 | --prio; | 1102 | --prio; |
1103 | if ( prio == 0 ) prio = 5; | 1103 | if ( prio == 0 ) prio = 5; |
1104 | complete += 20; | 1104 | complete += 20; |
1105 | if ( complete > 100 ) complete = 0; | 1105 | if ( complete > 100 ) complete = 0; |
1106 | runT->setPriority( prio ); | 1106 | runT->setPriority( prio ); |
1107 | runT->setPercentComplete( complete ); | 1107 | runT->setPercentComplete( complete ); |
1108 | } | 1108 | } |
1109 | runT->setRunning( true ); | 1109 | runT->setRunning( true ); |
1110 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); | 1110 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); |
1111 | if ( dayInterval ) | 1111 | if ( dayInterval ) |
1112 | t_start = t_start.addDays( dayInterval ); | 1112 | t_start = t_start.addDays( dayInterval ); |
1113 | else { | 1113 | else { |
1114 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); | 1114 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); |
1115 | } | 1115 | } |
1116 | } | 1116 | } |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | void CalendarView::showDay( QDate d ) | 1119 | void CalendarView::showDay( QDate d ) |
1120 | { | 1120 | { |
1121 | dateNavigator()->blockSignals( true ); | 1121 | dateNavigator()->blockSignals( true ); |
1122 | dateNavigator()->selectDate( d ); | 1122 | dateNavigator()->selectDate( d ); |
1123 | dateNavigator()->blockSignals( false ); | 1123 | dateNavigator()->blockSignals( false ); |
1124 | mViewManager->showDayView(); | 1124 | mViewManager->showDayView(); |
1125 | //dateNavigator()->selectDate( d ); | 1125 | //dateNavigator()->selectDate( d ); |
1126 | } | 1126 | } |
1127 | void CalendarView::timerAlarm() | 1127 | void CalendarView::timerAlarm() |
1128 | { | 1128 | { |
1129 | //qDebug("CalendarView::timerAlarm() "); | 1129 | //qDebug("CalendarView::timerAlarm() "); |
1130 | computeAlarm(mAlarmNotification ); | 1130 | computeAlarm(mAlarmNotification ); |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | void CalendarView::suspendAlarm() | 1133 | void CalendarView::suspendAlarm() |
1134 | { | 1134 | { |
1135 | //qDebug(" CalendarView::suspendAlarm() "); | 1135 | //qDebug(" CalendarView::suspendAlarm() "); |
1136 | computeAlarm(mSuspendAlarmNotification ); | 1136 | computeAlarm(mSuspendAlarmNotification ); |
1137 | 1137 | ||
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | void CalendarView::startAlarm( QString mess , QString filename) | 1140 | void CalendarView::startAlarm( QString mess , QString filename) |
1141 | { | 1141 | { |
1142 | 1142 | ||
1143 | topLevelWidget()->showNormal(); | 1143 | topLevelWidget()->showNormal(); |
1144 | topLevelWidget()->setActiveWindow(); | 1144 | topLevelWidget()->setActiveWindow(); |
1145 | topLevelWidget()->raise(); | 1145 | topLevelWidget()->raise(); |
1146 | 1146 | ||
1147 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 1147 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
1148 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 1148 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
1149 | 1149 | ||
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | void CalendarView::checkNextTimerAlarm() | 1152 | void CalendarView::checkNextTimerAlarm() |
1153 | { | 1153 | { |
1154 | mCalendar->checkAlarmForIncidence( 0, true ); | 1154 | mCalendar->checkAlarmForIncidence( 0, true ); |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | void CalendarView::computeAlarm( QString msg ) | 1157 | void CalendarView::computeAlarm( QString msg ) |
1158 | { | 1158 | { |
1159 | 1159 | ||
1160 | QString mess = msg; | 1160 | QString mess = msg; |
1161 | QString mAlarmMessage = mess.mid( 9 ); | 1161 | QString mAlarmMessage = mess.mid( 9 ); |
1162 | QString filename = MainWindow::resourcePath(); | 1162 | QString filename = MainWindow::resourcePath(); |
1163 | filename += "koalarm.wav"; | 1163 | filename += "koalarm.wav"; |
1164 | QString tempfilename; | 1164 | QString tempfilename; |
1165 | if ( mess.left( 13 ) == "suspend_alarm") { | 1165 | if ( mess.left( 13 ) == "suspend_alarm") { |
1166 | bool error = false; | 1166 | bool error = false; |
1167 | int len = mess.mid( 13 ).find("+++"); | 1167 | int len = mess.mid( 13 ).find("+++"); |
1168 | if ( len < 2 ) | 1168 | if ( len < 2 ) |
1169 | error = true; | 1169 | error = true; |
1170 | else { | 1170 | else { |
1171 | tempfilename = mess.mid( 13, len ); | 1171 | tempfilename = mess.mid( 13, len ); |
1172 | if ( !QFile::exists( tempfilename ) ) | 1172 | if ( !QFile::exists( tempfilename ) ) |
1173 | error = true; | 1173 | error = true; |
1174 | } | 1174 | } |
1175 | if ( ! error ) { | 1175 | if ( ! error ) { |
1176 | filename = tempfilename; | 1176 | filename = tempfilename; |
1177 | } | 1177 | } |
1178 | mAlarmMessage = mess.mid( 13+len+3 ); | 1178 | mAlarmMessage = mess.mid( 13+len+3 ); |
1179 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 1179 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
1180 | startAlarm( mAlarmMessage, filename); | 1180 | startAlarm( mAlarmMessage, filename); |
1181 | return; | 1181 | return; |
1182 | } | 1182 | } |
1183 | if ( mess.left( 11 ) == "timer_alarm") { | 1183 | if ( mess.left( 11 ) == "timer_alarm") { |
1184 | //mTimerTime = 0; | 1184 | //mTimerTime = 0; |
1185 | startAlarm( mess.mid( 11 ), filename ); | 1185 | startAlarm( mess.mid( 11 ), filename ); |
1186 | return; | 1186 | return; |
1187 | } | 1187 | } |
1188 | if ( mess.left( 10 ) == "proc_alarm") { | 1188 | if ( mess.left( 10 ) == "proc_alarm") { |
1189 | bool error = false; | 1189 | bool error = false; |
1190 | int len = mess.mid( 10 ).find("+++"); | 1190 | int len = mess.mid( 10 ).find("+++"); |
1191 | if ( len < 2 ) | 1191 | if ( len < 2 ) |
1192 | error = true; | 1192 | error = true; |
1193 | else { | 1193 | else { |
1194 | tempfilename = mess.mid( 10, len ); | 1194 | tempfilename = mess.mid( 10, len ); |
1195 | if ( !QFile::exists( tempfilename ) ) | 1195 | if ( !QFile::exists( tempfilename ) ) |
1196 | error = true; | 1196 | error = true; |
1197 | } | 1197 | } |
1198 | if ( error ) { | 1198 | if ( error ) { |
1199 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 1199 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
1200 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 1200 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
1201 | } else { | 1201 | } else { |
1202 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 1202 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
1203 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 1203 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
1204 | #ifndef _WIN32_ | 1204 | #ifndef _WIN32_ |
1205 | if ( vfork () == 0 ) { | 1205 | if ( vfork () == 0 ) { |
1206 | execl ( tempfilename.latin1(), 0 ); | 1206 | execl ( tempfilename.latin1(), 0 ); |
1207 | return; | 1207 | return; |
1208 | } | 1208 | } |
1209 | #else | 1209 | #else |
1210 | QProcess* p = new QProcess(); | 1210 | QProcess* p = new QProcess(); |
1211 | p->addArgument( tempfilename.latin1() ); | 1211 | p->addArgument( tempfilename.latin1() ); |
1212 | p->start(); | 1212 | p->start(); |
1213 | return; | 1213 | return; |
1214 | #endif | 1214 | #endif |
1215 | 1215 | ||
1216 | return; | 1216 | return; |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1219 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1220 | } | 1220 | } |
1221 | if ( mess.left( 11 ) == "audio_alarm") { | 1221 | if ( mess.left( 11 ) == "audio_alarm") { |
1222 | bool error = false; | 1222 | bool error = false; |
1223 | int len = mess.mid( 11 ).find("+++"); | 1223 | int len = mess.mid( 11 ).find("+++"); |
1224 | if ( len < 2 ) | 1224 | if ( len < 2 ) |
1225 | error = true; | 1225 | error = true; |
1226 | else { | 1226 | else { |
1227 | tempfilename = mess.mid( 11, len ); | 1227 | tempfilename = mess.mid( 11, len ); |
1228 | if ( !QFile::exists( tempfilename ) ) | 1228 | if ( !QFile::exists( tempfilename ) ) |
1229 | error = true; | 1229 | error = true; |
1230 | } | 1230 | } |
1231 | if ( ! error ) { | 1231 | if ( ! error ) { |
1232 | filename = tempfilename; | 1232 | filename = tempfilename; |
1233 | } | 1233 | } |
1234 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1234 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1235 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1235 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1236 | } | 1236 | } |
1237 | if ( mess.left( 9 ) == "cal_alarm") { | 1237 | if ( mess.left( 9 ) == "cal_alarm") { |
1238 | mAlarmMessage = mess.mid( 9 ) ; | 1238 | mAlarmMessage = mess.mid( 9 ) ; |
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | startAlarm( mAlarmMessage, filename ); | 1241 | startAlarm( mAlarmMessage, filename ); |
1242 | 1242 | ||
1243 | 1243 | ||
1244 | } | 1244 | } |
1245 | 1245 | ||
1246 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1246 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1247 | { | 1247 | { |
1248 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1248 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1249 | 1249 | ||
1250 | mSuspendAlarmNotification = noti; | 1250 | mSuspendAlarmNotification = noti; |
1251 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1251 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1252 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1252 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1253 | mSuspendTimer->start( ms , true ); | 1253 | mSuspendTimer->start( ms , true ); |
1254 | #ifdef DESKTOP_VERSION | ||
1255 | if ( QApplication::desktop()->width() < 1024 ) { | ||
1256 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | ||
1257 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); | ||
1258 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; | ||
1259 | QFile file( fn ); | ||
1260 | if (!file.open( IO_WriteOnly ) ) { | ||
1261 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | ||
1262 | } else { | ||
1263 | QTextStream ts( &file ); | ||
1264 | ts << mess; | ||
1265 | file.close(); | ||
1266 | } | ||
1267 | } | ||
1268 | #endif | ||
1254 | 1269 | ||
1255 | } | 1270 | } |
1256 | 1271 | ||
1257 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1272 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1258 | { | 1273 | { |
1259 | mNextAlarmDateTime = qdt; | 1274 | mNextAlarmDateTime = qdt; |
1260 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1275 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1261 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1276 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1262 | #ifndef DESKTOP_VERSION | 1277 | #ifndef DESKTOP_VERSION |
1263 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1278 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1264 | #endif | 1279 | #endif |
1265 | return; | 1280 | return; |
1266 | } | 1281 | } |
1282 | #ifdef DESKTOP_VERSION | ||
1283 | if ( QApplication::desktop()->width() < 1024 ) { | ||
1284 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | ||
1285 | //qDebug("nextalarm = \n%s ",mess.latin1() ); | ||
1286 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; | ||
1287 | QFile file( fn ); | ||
1288 | if (!file.open( IO_WriteOnly ) ) { | ||
1289 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | ||
1290 | } else { | ||
1291 | QTextStream ts( &file ); | ||
1292 | ts << mess; | ||
1293 | file.close(); | ||
1294 | } | ||
1295 | } | ||
1296 | #endif | ||
1267 | int maxSec; | 1297 | int maxSec; |
1268 | //maxSec = 5; //testing only | 1298 | //maxSec = 5; //testing only |
1269 | maxSec = 86400+3600; // one day+1hour | 1299 | maxSec = 86400+3600; // one day+1hour |
1270 | mAlarmNotification = noti; | 1300 | mAlarmNotification = noti; |
1271 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1301 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1272 | if ( sec > maxSec ) { | 1302 | if ( sec > maxSec ) { |
1273 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1303 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1274 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1304 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1275 | return; | 1305 | return; |
1276 | } else { | 1306 | } else { |
1277 | mRecheckAlarmTimer->stop(); | 1307 | mRecheckAlarmTimer->stop(); |
1278 | } | 1308 | } |
1279 | //qDebug("Alarm timer started with secs: %d ", sec); | 1309 | //qDebug("Alarm timer started with secs: %d ", sec); |
1280 | mAlarmTimer->start( sec *1000 , true ); | 1310 | mAlarmTimer->start( sec * 1000 , true ); |
1281 | 1311 | ||
1282 | } | 1312 | } |
1283 | // called by mRecheckAlarmTimer to get next alarm | 1313 | // called by mRecheckAlarmTimer to get next alarm |
1284 | // we need this, because a QTimer has only a max range of 25 days | 1314 | // we need this, because a QTimer has only a max range of 25 days |
1285 | void CalendarView::recheckTimerAlarm() | 1315 | void CalendarView::recheckTimerAlarm() |
1286 | { | 1316 | { |
1287 | mAlarmTimer->stop(); | 1317 | mAlarmTimer->stop(); |
1288 | mRecheckAlarmTimer->stop(); | 1318 | mRecheckAlarmTimer->stop(); |
1289 | mCalendar->checkAlarmForIncidence( 0, true ); | 1319 | mCalendar->checkAlarmForIncidence( 0, true ); |
1290 | } | 1320 | } |
1291 | #ifndef DESKTOP_VERSION | 1321 | #ifndef DESKTOP_VERSION |
1292 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1322 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1293 | #else | 1323 | #else |
1294 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1324 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1295 | #endif | 1325 | #endif |
1296 | { | 1326 | { |
1297 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1327 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1298 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1328 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1299 | #ifndef DESKTOP_VERSION | 1329 | #ifndef DESKTOP_VERSION |
1300 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1330 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1301 | #endif | 1331 | #endif |
1302 | return; | 1332 | return; |
1303 | } | 1333 | } |
1304 | mAlarmTimer->stop(); | 1334 | mAlarmTimer->stop(); |
1305 | } | 1335 | } |
1306 | void CalendarView::selectWeekNum ( int num ) | 1336 | void CalendarView::selectWeekNum ( int num ) |
1307 | { | 1337 | { |
1308 | dateNavigator()->blockSignals( true ); | 1338 | dateNavigator()->blockSignals( true ); |
1309 | dateNavigator()->selectWeek( num ); | 1339 | dateNavigator()->selectWeek( num ); |
1310 | dateNavigator()->blockSignals( false ); | 1340 | dateNavigator()->blockSignals( false ); |
1311 | mViewManager->showWeekView(); | 1341 | mViewManager->showWeekView(); |
1312 | } | 1342 | } |
1313 | KOViewManager *CalendarView::viewManager() | 1343 | KOViewManager *CalendarView::viewManager() |
1314 | { | 1344 | { |
1315 | return mViewManager; | 1345 | return mViewManager; |
1316 | } | 1346 | } |
1317 | 1347 | ||
1318 | KODialogManager *CalendarView::dialogManager() | 1348 | KODialogManager *CalendarView::dialogManager() |
1319 | { | 1349 | { |
1320 | return mDialogManager; | 1350 | return mDialogManager; |
1321 | } | 1351 | } |
1322 | 1352 | ||
1323 | QDate CalendarView::startDate() | 1353 | QDate CalendarView::startDate() |
1324 | { | 1354 | { |
1325 | DateList dates = mNavigator->selectedDates(); | 1355 | DateList dates = mNavigator->selectedDates(); |
1326 | 1356 | ||
1327 | return dates.first(); | 1357 | return dates.first(); |
1328 | } | 1358 | } |
1329 | 1359 | ||
1330 | QDate CalendarView::endDate() | 1360 | QDate CalendarView::endDate() |
1331 | { | 1361 | { |
1332 | DateList dates = mNavigator->selectedDates(); | 1362 | DateList dates = mNavigator->selectedDates(); |
1333 | 1363 | ||
1334 | return dates.last(); | 1364 | return dates.last(); |
1335 | } | 1365 | } |
1336 | 1366 | ||
1337 | 1367 | ||
1338 | void CalendarView::createPrinter() | 1368 | void CalendarView::createPrinter() |
1339 | { | 1369 | { |
1340 | #ifndef KORG_NOPRINTER | 1370 | #ifndef KORG_NOPRINTER |
1341 | if (!mCalPrinter) { | 1371 | if (!mCalPrinter) { |
1342 | mCalPrinter = new CalPrinter(this, mCalendar); | 1372 | mCalPrinter = new CalPrinter(this, mCalendar); |
1343 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1373 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1344 | } | 1374 | } |
1345 | #endif | 1375 | #endif |
1346 | } | 1376 | } |
1347 | 1377 | ||
1348 | 1378 | ||
1349 | //KOPrefs::instance()->mWriteBackFile | 1379 | //KOPrefs::instance()->mWriteBackFile |
1350 | //KOPrefs::instance()->mWriteBackExistingOnly | 1380 | //KOPrefs::instance()->mWriteBackExistingOnly |
1351 | 1381 | ||
1352 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1382 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1353 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1383 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1354 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1384 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1355 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1385 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1356 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1386 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1357 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1387 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1358 | 1388 | ||
1359 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1389 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1360 | { | 1390 | { |
1361 | 1391 | ||
1362 | // 0 equal | 1392 | // 0 equal |
1363 | // 1 take local | 1393 | // 1 take local |
1364 | // 2 take remote | 1394 | // 2 take remote |
1365 | // 3 cancel | 1395 | // 3 cancel |
1366 | QDateTime lastSync = mLastCalendarSync; | 1396 | QDateTime lastSync = mLastCalendarSync; |
1367 | QDateTime localMod = local->lastModified(); | 1397 | QDateTime localMod = local->lastModified(); |
1368 | QDateTime remoteMod = remote->lastModified(); | 1398 | QDateTime remoteMod = remote->lastModified(); |
1369 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1399 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1370 | bool remCh, locCh; | 1400 | bool remCh, locCh; |
1371 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1401 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1372 | //if ( remCh ) | 1402 | //if ( remCh ) |
1373 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1403 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1374 | locCh = ( localMod > mLastCalendarSync ); | 1404 | locCh = ( localMod > mLastCalendarSync ); |
1375 | if ( !remCh && ! locCh ) { | 1405 | if ( !remCh && ! locCh ) { |
1376 | //qDebug("both not changed "); | 1406 | //qDebug("both not changed "); |
1377 | lastSync = localMod.addDays(1); | 1407 | lastSync = localMod.addDays(1); |
1378 | if ( mode <= SYNC_PREF_ASK ) | 1408 | if ( mode <= SYNC_PREF_ASK ) |
1379 | return 0; | 1409 | return 0; |
1380 | } else { | 1410 | } else { |
1381 | if ( locCh ) { | 1411 | if ( locCh ) { |
1382 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1412 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1383 | lastSync = localMod.addDays( -1 ); | 1413 | lastSync = localMod.addDays( -1 ); |
1384 | if ( !remCh ) | 1414 | if ( !remCh ) |
1385 | remoteMod = ( lastSync.addDays( -1 ) ); | 1415 | remoteMod = ( lastSync.addDays( -1 ) ); |
1386 | } else { | 1416 | } else { |
1387 | //qDebug(" not loc changed "); | 1417 | //qDebug(" not loc changed "); |
1388 | lastSync = localMod.addDays( 1 ); | 1418 | lastSync = localMod.addDays( 1 ); |
1389 | if ( remCh ) | 1419 | if ( remCh ) |
1390 | remoteMod =( lastSync.addDays( 1 ) ); | 1420 | remoteMod =( lastSync.addDays( 1 ) ); |
1391 | 1421 | ||
1392 | } | 1422 | } |
1393 | } | 1423 | } |
1394 | full = true; | 1424 | full = true; |
1395 | if ( mode < SYNC_PREF_ASK ) | 1425 | if ( mode < SYNC_PREF_ASK ) |
1396 | mode = SYNC_PREF_ASK; | 1426 | mode = SYNC_PREF_ASK; |
1397 | } else { | 1427 | } else { |
1398 | if ( localMod == remoteMod ) | 1428 | if ( localMod == remoteMod ) |
1399 | // if ( local->revision() == remote->revision() ) | 1429 | // if ( local->revision() == remote->revision() ) |
1400 | return 0; | 1430 | return 0; |
1401 | 1431 | ||
1402 | } | 1432 | } |
1403 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1433 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1404 | 1434 | ||
1405 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1435 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1406 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1436 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1407 | //full = true; //debug only | 1437 | //full = true; //debug only |
1408 | if ( full ) { | 1438 | if ( full ) { |
1409 | bool equ = false; | 1439 | bool equ = false; |
1410 | if ( local->typeID() == eventID ) { | 1440 | if ( local->typeID() == eventID ) { |
1411 | equ = (*((Event*) local) == *((Event*) remote)); | 1441 | equ = (*((Event*) local) == *((Event*) remote)); |
1412 | } | 1442 | } |
1413 | else if ( local->typeID() == todoID ) | 1443 | else if ( local->typeID() == todoID ) |
1414 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1444 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1415 | else if ( local->typeID() == journalID ) | 1445 | else if ( local->typeID() == journalID ) |
1416 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1446 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1417 | if ( equ ) { | 1447 | if ( equ ) { |
1418 | //qDebug("equal "); | 1448 | //qDebug("equal "); |
1419 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1449 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1420 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1450 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1421 | } | 1451 | } |
1422 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1452 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1423 | return 0; | 1453 | return 0; |
1424 | 1454 | ||
1425 | }//else //debug only | 1455 | }//else //debug only |
1426 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1456 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1427 | } | 1457 | } |
1428 | int result; | 1458 | int result; |
1429 | bool localIsNew; | 1459 | bool localIsNew; |
1430 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 1460 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
1431 | 1461 | ||
1432 | 1462 | ||
1433 | // ************************************************ | 1463 | // ************************************************ |
1434 | // ************************************************ | 1464 | // ************************************************ |
1435 | // ************************************************ | 1465 | // ************************************************ |
1436 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1466 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1437 | // BUT remoteMod != localMod | 1467 | // BUT remoteMod != localMod |
1438 | 1468 | ||
1439 | 1469 | ||
1440 | if ( full && mode < SYNC_PREF_NEWEST ) | 1470 | if ( full && mode < SYNC_PREF_NEWEST ) |
1441 | mode = SYNC_PREF_ASK; | 1471 | mode = SYNC_PREF_ASK; |
1442 | 1472 | ||
1443 | switch( mode ) { | 1473 | switch( mode ) { |
1444 | case SYNC_PREF_LOCAL: | 1474 | case SYNC_PREF_LOCAL: |
1445 | if ( lastSync > remoteMod ) | 1475 | if ( lastSync > remoteMod ) |
1446 | return 1; | 1476 | return 1; |
1447 | if ( lastSync > localMod ) | 1477 | if ( lastSync > localMod ) |
1448 | return 2; | 1478 | return 2; |
1449 | return 1; | 1479 | return 1; |
1450 | break; | 1480 | break; |
1451 | case SYNC_PREF_REMOTE: | 1481 | case SYNC_PREF_REMOTE: |
1452 | if ( lastSync > localMod ) | 1482 | if ( lastSync > localMod ) |
1453 | return 2; | 1483 | return 2; |
1454 | if ( lastSync > remoteMod ) | 1484 | if ( lastSync > remoteMod ) |
1455 | return 1; | 1485 | return 1; |
1456 | return 2; | 1486 | return 2; |
1457 | break; | 1487 | break; |
1458 | case SYNC_PREF_NEWEST: | 1488 | case SYNC_PREF_NEWEST: |
1459 | if ( localMod >= remoteMod ) | 1489 | if ( localMod >= remoteMod ) |
1460 | return 1; | 1490 | return 1; |
1461 | else | 1491 | else |
1462 | return 2; | 1492 | return 2; |
1463 | break; | 1493 | break; |
1464 | case SYNC_PREF_ASK: | 1494 | case SYNC_PREF_ASK: |
1465 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1495 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1466 | if ( lastSync > remoteMod && lastSync > localMod) | 1496 | if ( lastSync > remoteMod && lastSync > localMod) |
1467 | return 0; | 1497 | return 0; |
1468 | if ( lastSync > remoteMod ) | 1498 | if ( lastSync > remoteMod ) |
1469 | return 1; | 1499 | return 1; |
1470 | if ( lastSync > localMod ) | 1500 | if ( lastSync > localMod ) |
1471 | return 2; | 1501 | return 2; |
1472 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1502 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |