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 | |
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 | |||
@@ -1222,91 +1222,121 @@ void CalendarView::computeAlarm( QString msg ) | |||
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 | } |