author | zautrix <zautrix> | 2005-06-27 00:49:23 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-27 00:49:23 (UTC) |
commit | 2e566a307bb50ac595fe729ebed0f5336f2af5a8 (patch) (unidiff) | |
tree | 926a9346f1a3c3389e314e170da5cfa64811f9b6 /korganizer/kofilterview.cpp | |
parent | 72721fd5da5bc08f595cda85bc260112764b2bd8 (diff) | |
download | kdepimpi-2e566a307bb50ac595fe729ebed0f5336f2af5a8.zip kdepimpi-2e566a307bb50ac595fe729ebed0f5336f2af5a8.tar.gz kdepimpi-2e566a307bb50ac595fe729ebed0f5336f2af5a8.tar.bz2 |
fixesss
-rw-r--r-- | korganizer/kofilterview.cpp | 32 |
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 | |||
@@ -341,77 +341,97 @@ void KOCalEditView::readConfig() | |||
341 | mainLayout->addWidget( lab,row,0 ); | 341 | mainLayout->addWidget( lab,row,0 ); |
342 | mw->show(); | 342 | mw->show(); |
343 | 343 | ||
344 | } | 344 | } |
345 | 345 | ||
346 | 346 | ||
347 | void KOCalEditView::defaultInfo() | 347 | void 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 | } |
351 | void KOCalEditView::addCal() | 351 | void 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 | } | ||
383 | int 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 | } |
410 | int 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 | |||
402 | void KOCalEditView::enableAll() | 422 | void KOCalEditView::enableAll() |
403 | { | 423 | { |
404 | toggleList( mEnabledB ); | 424 | toggleList( mEnabledB ); |
405 | } | 425 | } |
406 | void KOCalEditView::enableAlarm() | 426 | void KOCalEditView::enableAlarm() |
407 | { | 427 | { |
408 | toggleList( mAlarmB ); | 428 | toggleList( mAlarmB ); |
409 | } | 429 | } |
410 | void KOCalEditView::disableRO() | 430 | void KOCalEditView::disableRO() |
411 | { | 431 | { |
412 | toggleList( mROB ); | 432 | toggleList( mROB ); |
413 | } | 433 | } |
414 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) | 434 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) |
415 | { | 435 | { |
416 | bool dis = false; | 436 | bool dis = false; |
417 | KOCalCheckButton* it = list.first(); | 437 | KOCalCheckButton* it = list.first(); |