-rw-r--r-- | korganizer/kofilterview.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp index ff80afc..7ce3f1f 100644 --- a/korganizer/kofilterview.cpp +++ b/korganizer/kofilterview.cpp | |||
@@ -28,24 +28,25 @@ | |||
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qdialog.h> | 29 | #include <qdialog.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | 32 | ||
33 | 33 | ||
34 | #include <libkcal/calfilter.h> | 34 | #include <libkcal/calfilter.h> |
35 | 35 | ||
36 | #include "kofilterview.h" | 36 | #include "kofilterview.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #include <kiconloader.h> | 38 | #include <kiconloader.h> |
39 | #include <kglobal.h> | 39 | #include <kglobal.h> |
40 | #include <kglobalsettings.h> | ||
40 | #include <kcolorbutton.h> | 41 | #include <kcolorbutton.h> |
41 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
42 | 43 | ||
43 | 44 | ||
44 | 45 | ||
45 | 46 | ||
46 | 47 | ||
47 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, | 48 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, |
48 | const char* name,WFlags fl ) | 49 | const char* name,WFlags fl ) |
49 | : KOFilterView_base(parent,name,fl) | 50 | : KOFilterView_base(parent,name,fl) |
50 | { | 51 | { |
51 | mFilters = filterList; | 52 | mFilters = filterList; |
@@ -389,41 +390,57 @@ void KOCalEditView::addCal() | |||
389 | break; | 390 | break; |
390 | } | 391 | } |
391 | kkf = KOPrefs::instance()->mCalendars.next(); | 392 | kkf = KOPrefs::instance()->mCalendars.next(); |
392 | } | 393 | } |
393 | } | 394 | } |
394 | addCalendar ( name, file ); | 395 | addCalendar ( name, file ); |
395 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); | 396 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); |
396 | } | 397 | } |
397 | int KOCalEditView::addCalendar( QString name, QString file, bool ask ) | 398 | int KOCalEditView::addCalendar( QString name, QString file, bool ask ) |
398 | { | 399 | { |
399 | 400 | ||
400 | QFileInfo fi ( file ); | 401 | QFileInfo fi ( file ); |
402 | QString absFile = file; | ||
403 | bool isRelative = false; | ||
404 | if ( fi.isRelative() ) { | ||
405 | isRelative = true; | ||
406 | absFile = KGlobalSettings::calendarDir()+file; | ||
407 | fi.setFile( absFile ); | ||
408 | } else { | ||
409 | QString cd = KGlobalSettings::calendarDir(); | ||
410 | if ( file.left( cd.length() ) == cd ) { | ||
411 | isRelative = true; | ||
412 | file = fi.fileName (); | ||
413 | fi.setFile( absFile ); | ||
414 | } | ||
415 | } | ||
401 | if (!fi.exists() ) { | 416 | if (!fi.exists() ) { |
402 | if ( ask ) | 417 | if ( ask ) |
403 | if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No ) | 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 ) |
404 | return 0; | 419 | return 0; |
405 | QFile fileIn( file ); | 420 | QFile fileIn( absFile ); |
406 | if (!fileIn.open( IO_WriteOnly ) ) { | 421 | if (!fileIn.open( IO_WriteOnly ) ) { |
407 | KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); | 422 | KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); |
408 | return 0; | 423 | return 0; |
409 | } | 424 | } |
410 | QTextStream tsIn( &fileIn ); | 425 | QTextStream tsIn( &fileIn ); |
411 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 426 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
412 | tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; | 427 | tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; |
413 | fileIn.close(); | 428 | fileIn.close(); |
414 | } | 429 | } |
415 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); | 430 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); |
416 | kkf->mName = name; | 431 | kkf->mName = name; |
417 | kkf->mFileName = file; | 432 | kkf->mFileName = absFile; |
433 | kkf->mSavedFileName = file; | ||
434 | kkf->isRelative = isRelative; | ||
418 | emit calendarAdded( kkf->mCalNumber ); | 435 | emit calendarAdded( kkf->mCalNumber ); |
419 | if ( ask ) | 436 | if ( ask ) |
420 | emit needsUpdate(); | 437 | emit needsUpdate(); |
421 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 438 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
422 | return kkf->mCalNumber; | 439 | return kkf->mCalNumber; |
423 | } | 440 | } |
424 | int KOCalEditView::getBirtdayID() | 441 | int KOCalEditView::getBirtdayID() |
425 | { | 442 | { |
426 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 443 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
427 | while ( kkf ) { | 444 | while ( kkf ) { |
428 | if ( kkf->mName == i18n("Birthdays") ) | 445 | if ( kkf->mName == i18n("Birthdays") ) |
429 | return kkf->mCalNumber; | 446 | return kkf->mCalNumber; |