summaryrefslogtreecommitdiffabout
path: root/korganizer/kofilterview.cpp
Side-by-side diff
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()
void KOCalEditView::defaultInfo()
{
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.") );
}
void KOCalEditView::addCal()
{
bool tryagain = true;
QString name, file;
while ( tryagain ) {
KONewCalPrefs prefs ( this );
- prefs.nameE->setText( name );
+ prefs.nameE->setText( name );
prefs.url->setURL( file );
if ( ! prefs.exec() )
return;
name = prefs.calName();
file = prefs.calFileName();
tryagain = false;
KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
while ( kkf ) {
if ( kkf->mName == name ) {
KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) );
name = "";
tryagain = true;
break;
}
if ( kkf->mFileName == file ) {
KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) );
tryagain = true;
file = "";
break;
}
kkf = KOPrefs::instance()->mCalendars.next();
}
}
+ 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 );
if (!fileIn.open( IO_WriteOnly ) ) {
KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) );
- return;
+ return 0;
}
QTextStream tsIn( &fileIn );
tsIn.setCodec( QTextCodec::codecForName("utf8") );
tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n";
fileIn.close();
}
KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
kkf->mName = name;
kkf->mFileName = file;
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()
{
toggleList( mEnabledB );
}
void KOCalEditView::enableAlarm()
{
toggleList( mAlarmB );
}
void KOCalEditView::disableRO()
{
toggleList( mROB );
}