summaryrefslogtreecommitdiffabout
path: root/korganizer/kofilterview.cpp
Unidiff
Diffstat (limited to 'korganizer/kofilterview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kofilterview.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index a8a3052..3cde103 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -369,45 +369,65 @@ void KOCalEditView::addCal()
369 tryagain = true; 369 tryagain = true;
370 break; 370 break;
371 } 371 }
372 if ( kkf->mFileName == file ) { 372 if ( kkf->mFileName == file ) {
373 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); 373 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) );
374 tryagain = true; 374 tryagain = true;
375 file = ""; 375 file = "";
376 break; 376 break;
377 } 377 }
378 kkf = KOPrefs::instance()->mCalendars.next(); 378 kkf = KOPrefs::instance()->mCalendars.next();
379 } 379 }
380 } 380 }
381 addCalendar ( name, file );
382}
383int KOCalEditView::addCalendar( QString name, QString file, bool ask )
384{
385
381 QFileInfo fi ( file ); 386 QFileInfo fi ( file );
382 if (!fi.exists() ) { 387 if (!fi.exists() ) {
388 if ( ask )
383 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No ) 389 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No )
384 return; 390 return 0;
385 QFile fileIn( file ); 391 QFile fileIn( file );
386 if (!fileIn.open( IO_WriteOnly ) ) { 392 if (!fileIn.open( IO_WriteOnly ) ) {
387 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); 393 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) );
388 return; 394 return 0;
389 } 395 }
390 QTextStream tsIn( &fileIn ); 396 QTextStream tsIn( &fileIn );
391 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 397 tsIn.setCodec( QTextCodec::codecForName("utf8") );
392 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; 398 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n";
393 fileIn.close(); 399 fileIn.close();
394 } 400 }
395 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); 401 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
396 kkf->mName = name; 402 kkf->mName = name;
397 kkf->mFileName = file; 403 kkf->mFileName = file;
398 emit calendarAdded( kkf->mCalNumber ); 404 emit calendarAdded( kkf->mCalNumber );
405 if ( ask )
399 emit needsUpdate(); 406 emit needsUpdate();
400 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 407 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
408 return kkf->mCalNumber;
409}
410int KOCalEditView::getBirtdayID()
411{
412 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
413 while ( kkf ) {
414 if ( kkf->mName == i18n("Birthdays") )
415 return kkf->mCalNumber;
416 kkf = KOPrefs::instance()->mCalendars.next();
417 }
418 QString file = locateLocal( "data", "korganizer/birthdays.ics" );
419 return addCalendar( i18n("Birthdays"), file, false );
401} 420}
421
402void KOCalEditView::enableAll() 422void KOCalEditView::enableAll()
403{ 423{
404 toggleList( mEnabledB ); 424 toggleList( mEnabledB );
405} 425}
406void KOCalEditView::enableAlarm() 426void KOCalEditView::enableAlarm()
407{ 427{
408 toggleList( mAlarmB ); 428 toggleList( mAlarmB );
409} 429}
410void KOCalEditView::disableRO() 430void KOCalEditView::disableRO()
411{ 431{
412 toggleList( mROB ); 432 toggleList( mROB );
413} 433}