-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 @@ -356,3 +356,3 @@ void KOCalEditView::addCal() KONewCalPrefs prefs ( this ); - prefs.nameE->setText( name ); + prefs.nameE->setText( name ); prefs.url->setURL( file ); @@ -380,6 +380,12 @@ void KOCalEditView::addCal() } + addCalendar ( name, file ); +} +int KOCalEditView::addCalendar( QString name, QString file, bool ask ) +{ + QFileInfo fi ( file ); if (!fi.exists() ) { - if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No ) - return; + if ( ask ) + if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No ) + return 0; QFile fileIn( file ); @@ -387,3 +393,3 @@ void KOCalEditView::addCal() KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); - return; + return 0; } @@ -398,5 +404,19 @@ void KOCalEditView::addCal() emit calendarAdded( kkf->mCalNumber ); - emit needsUpdate(); - QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); + if ( ask ) + emit needsUpdate(); + QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); + return kkf->mCalNumber; } +int KOCalEditView::getBirtdayID() +{ + KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); + while ( kkf ) { + if ( kkf->mName == i18n("Birthdays") ) + return kkf->mCalNumber; + kkf = KOPrefs::instance()->mCalendars.next(); + } + QString file = locateLocal( "data", "korganizer/birthdays.ics" ); + return addCalendar( i18n("Birthdays"), file, false ); +} + void KOCalEditView::enableAll() |