-rw-r--r-- | korganizer/kofilterview.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp index 7ce3f1f..6a6fff9 100644 --- a/korganizer/kofilterview.cpp +++ b/korganizer/kofilterview.cpp | |||
@@ -320,125 +320,129 @@ void KOCalEditView::readConfig() | |||
320 | //lab = new QLabel (" ", mw ); | 320 | //lab = new QLabel (" ", mw ); |
321 | //mainLayout->addWidget( lab,row,++iii ); | 321 | //mainLayout->addWidget( lab,row,++iii ); |
322 | cb = new KOCalCheckButton( mw ); | 322 | cb = new KOCalCheckButton( mw ); |
323 | mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); | 323 | mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); |
324 | cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad); | 324 | cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad); |
325 | cb->setNum( kkf->mCalNumber ); | 325 | cb->setNum( kkf->mCalNumber ); |
326 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); | 326 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); |
327 | if ( kkf->mErrorOnLoad ) | 327 | if ( kkf->mErrorOnLoad ) |
328 | cb->setEnabled( false ); | 328 | cb->setEnabled( false ); |
329 | cb = new KOCalCheckButton( mw ); | 329 | cb = new KOCalCheckButton( mw ); |
330 | mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); | 330 | mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); |
331 | cb->setChecked( kkf->isReadOnly ); | 331 | cb->setChecked( kkf->isReadOnly ); |
332 | cb->setNum( kkf->mCalNumber ); | 332 | cb->setNum( kkf->mCalNumber ); |
333 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); | 333 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); |
334 | if ( kkf->mErrorOnLoad ) | 334 | if ( kkf->mErrorOnLoad ) |
335 | cb->setEnabled( false ); | 335 | cb->setEnabled( false ); |
336 | if ( row > 1) { | 336 | if ( row > 1) { |
337 | KColorButton *colb = new KColorButton( mw ); | 337 | KColorButton *colb = new KColorButton( mw ); |
338 | mainLayout->addWidget( colb,row,++iii ); | 338 | mainLayout->addWidget( colb,row,++iii ); |
339 | colb->setID( kkf->mCalNumber ); | 339 | colb->setID( kkf->mCalNumber ); |
340 | colb->setColor( kkf->mDefaultColor ); | 340 | colb->setColor( kkf->mDefaultColor ); |
341 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); | 341 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); |
342 | KOCalButton* calb = new KOCalButton( mw ); | 342 | KOCalButton* calb = new KOCalButton( mw ); |
343 | mainLayout->addWidget( calb,row,++iii ); | 343 | mainLayout->addWidget( calb,row,++iii ); |
344 | calb->setNum( kkf->mCalNumber ); | 344 | calb->setNum( kkf->mCalNumber ); |
345 | calb->setPixmap ( SmallIcon("minus")); | 345 | calb->setPixmap ( SmallIcon("minus")); |
346 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); | 346 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); |
347 | int hei = calb->sizeHint().height(); | 347 | int hei = calb->sizeHint().height(); |
348 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); | 348 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); |
349 | } | 349 | } |
350 | ++row; | 350 | ++row; |
351 | kkf = KOPrefs::instance()->mCalendars.next(); | 351 | kkf = KOPrefs::instance()->mCalendars.next(); |
352 | } | 352 | } |
353 | if ( errorLoadStandard ) | 353 | if ( errorLoadStandard ) |
354 | findNewStandard(); | 354 | findNewStandard(); |
355 | lab = new QLabel ( "", mw ); | 355 | lab = new QLabel ( "", mw ); |
356 | mainLayout->addWidget( lab,row,0 ); | 356 | mainLayout->addWidget( lab,row,0 ); |
357 | mw->show(); | 357 | mw->show(); |
358 | 358 | ||
359 | } | 359 | } |
360 | 360 | ||
361 | void KOCalEditView::defaultInfo() | 361 | void KOCalEditView::defaultInfo() |
362 | { | 362 | { |
363 | 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.") ); | 363 | 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.") ); |
364 | } | 364 | } |
365 | void KOCalEditView::addCal() | 365 | void KOCalEditView::addCal() |
366 | { | 366 | { |
367 | bool tryagain = true; | 367 | bool tryagain = true; |
368 | QString name, file; | 368 | QString name, file = KGlobalSettings::calendarDir()+"newCal.ics"; |
369 | while ( tryagain ) { | 369 | while ( tryagain ) { |
370 | KONewCalPrefs prefs ( this ); | 370 | KONewCalPrefs prefs ( this ); |
371 | prefs.nameE->setText( name ); | 371 | prefs.nameE->setText( name ); |
372 | prefs.url->setURL( file ); | 372 | prefs.url->setURL( file ); |
373 | if ( ! prefs.exec() ) | 373 | if ( ! prefs.exec() ) |
374 | return; | 374 | return; |
375 | name = prefs.calName(); | 375 | name = prefs.calName(); |
376 | file = prefs.calFileName(); | 376 | file = prefs.calFileName(); |
377 | tryagain = false; | 377 | tryagain = false; |
378 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 378 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
379 | while ( kkf ) { | 379 | while ( kkf ) { |
380 | if ( kkf->mName == name ) { | 380 | if ( kkf->mName == name ) { |
381 | KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); | 381 | KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); |
382 | name = ""; | 382 | name = ""; |
383 | tryagain = true; | 383 | tryagain = true; |
384 | break; | 384 | break; |
385 | } | 385 | } |
386 | if ( kkf->mFileName == file ) { | 386 | if ( kkf->mFileName == file ) { |
387 | KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); | 387 | KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); |
388 | tryagain = true; | 388 | tryagain = true; |
389 | file = ""; | 389 | file = KGlobalSettings::calendarDir()+"newCal.ics"; |
390 | break; | 390 | break; |
391 | } | 391 | } |
392 | kkf = KOPrefs::instance()->mCalendars.next(); | 392 | kkf = KOPrefs::instance()->mCalendars.next(); |
393 | } | ||
394 | QFileInfo fi ( file ); | ||
395 | if ( fi.isDir() ) { | ||
396 | tryagain = true; | ||
393 | } | 397 | } |
394 | } | 398 | } |
395 | addCalendar ( name, file ); | 399 | addCalendar ( name, file ); |
396 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); | 400 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); |
397 | } | 401 | } |
398 | int KOCalEditView::addCalendar( QString name, QString file, bool ask ) | 402 | int KOCalEditView::addCalendar( QString name, QString file, bool ask ) |
399 | { | 403 | { |
400 | 404 | ||
401 | QFileInfo fi ( file ); | 405 | QFileInfo fi ( file ); |
402 | QString absFile = file; | 406 | QString absFile = file; |
403 | bool isRelative = false; | 407 | bool isRelative = false; |
404 | if ( fi.isRelative() ) { | 408 | if ( fi.isRelative() ) { |
405 | isRelative = true; | 409 | isRelative = true; |
406 | absFile = KGlobalSettings::calendarDir()+file; | 410 | absFile = KGlobalSettings::calendarDir()+file; |
407 | fi.setFile( absFile ); | 411 | fi.setFile( absFile ); |
408 | } else { | 412 | } else { |
409 | QString cd = KGlobalSettings::calendarDir(); | 413 | QString cd = KGlobalSettings::calendarDir(); |
410 | if ( file.left( cd.length() ) == cd ) { | 414 | if ( file.left( cd.length() ) == cd ) { |
411 | isRelative = true; | 415 | isRelative = true; |
412 | file = fi.fileName (); | 416 | file = fi.fileName (); |
413 | fi.setFile( absFile ); | 417 | fi.setFile( absFile ); |
414 | } | 418 | } |
415 | } | 419 | } |
416 | if (!fi.exists() ) { | 420 | if (!fi.exists() ) { |
417 | if ( ask ) | 421 | if ( ask ) |
418 | if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No ) | 422 | if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No ) |
419 | return 0; | 423 | return 0; |
420 | QFile fileIn( absFile ); | 424 | QFile fileIn( absFile ); |
421 | if (!fileIn.open( IO_WriteOnly ) ) { | 425 | if (!fileIn.open( IO_WriteOnly ) ) { |
422 | KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); | 426 | KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); |
423 | return 0; | 427 | return 0; |
424 | } | 428 | } |
425 | QTextStream tsIn( &fileIn ); | 429 | QTextStream tsIn( &fileIn ); |
426 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 430 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
427 | tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; | 431 | tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; |
428 | fileIn.close(); | 432 | fileIn.close(); |
429 | } | 433 | } |
430 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); | 434 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); |
431 | kkf->mName = name; | 435 | kkf->mName = name; |
432 | kkf->mFileName = absFile; | 436 | kkf->mFileName = absFile; |
433 | kkf->mSavedFileName = file; | 437 | kkf->mSavedFileName = file; |
434 | kkf->isRelative = isRelative; | 438 | kkf->isRelative = isRelative; |
435 | emit calendarAdded( kkf->mCalNumber ); | 439 | emit calendarAdded( kkf->mCalNumber ); |
436 | if ( ask ) | 440 | if ( ask ) |
437 | emit needsUpdate(); | 441 | emit needsUpdate(); |
438 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 442 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
439 | return kkf->mCalNumber; | 443 | return kkf->mCalNumber; |
440 | } | 444 | } |
441 | int KOCalEditView::getBirtdayID() | 445 | int KOCalEditView::getBirtdayID() |
442 | { | 446 | { |
443 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 447 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
444 | while ( kkf ) { | 448 | while ( kkf ) { |