summaryrefslogtreecommitdiffabout
path: root/korganizer/kofilterview.cpp
Unidiff
Diffstat (limited to 'korganizer/kofilterview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kofilterview.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index a8a3052..3cde103 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -345,69 +345,89 @@ void KOCalEditView::readConfig()
345 345
346 346
347void KOCalEditView::defaultInfo() 347void KOCalEditView::defaultInfo()
348{ 348{
349 KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") ); 349 KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") );
350} 350}
351void KOCalEditView::addCal() 351void KOCalEditView::addCal()
352{ 352{
353 bool tryagain = true; 353 bool tryagain = true;
354 QString name, file; 354 QString name, file;
355 while ( tryagain ) { 355 while ( tryagain ) {
356 KONewCalPrefs prefs ( this ); 356 KONewCalPrefs prefs ( this );
357 prefs.nameE->setText( name ); 357 prefs.nameE->setText( name );
358 prefs.url->setURL( file ); 358 prefs.url->setURL( file );
359 if ( ! prefs.exec() ) 359 if ( ! prefs.exec() )
360 return; 360 return;
361 name = prefs.calName(); 361 name = prefs.calName();
362 file = prefs.calFileName(); 362 file = prefs.calFileName();
363 tryagain = false; 363 tryagain = false;
364 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 364 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
365 while ( kkf ) { 365 while ( kkf ) {
366 if ( kkf->mName == name ) { 366 if ( kkf->mName == name ) {
367 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); 367 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) );
368 name = ""; 368 name = "";
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() ) {
383 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No ) 388 if ( ask )
384 return; 389 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No )
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 );
399 emit needsUpdate(); 405 if ( ask )
400 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 406 emit needsUpdate();
407 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
408 return kkf->mCalNumber;
401} 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 );
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}