summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp63
-rw-r--r--korganizer/calendarview.h7
-rw-r--r--korganizer/kofilterview.cpp2
-rw-r--r--korganizer/mainwindow.cpp4
-rw-r--r--libkcal/calendar.cpp5
-rw-r--r--libkcal/calendar.h9
-rw-r--r--libkcal/calendarlocal.cpp56
-rw-r--r--libkcal/calendarlocal.h6
8 files changed, 142 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index b3686aa..07ec459 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -414,96 +414,100 @@ void CalendarView::init()
414 connect( mResourceView, SIGNAL( resourcesChanged() ), 414 connect( mResourceView, SIGNAL( resourcesChanged() ),
415 SLOT( updateView() ) ); 415 SLOT( updateView() ) );
416 } else { 416 } else {
417 mResourceView = 0; 417 mResourceView = 0;
418 } 418 }
419#endif 419#endif
420 QWidget *rightBox = new QWidget( mPanner ); 420 QWidget *rightBox = new QWidget( mPanner );
421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
422 422
423 mRightFrame = new QWidgetStack( rightBox ); 423 mRightFrame = new QWidgetStack( rightBox );
424 rightLayout->addWidget( mRightFrame, 1 ); 424 rightLayout->addWidget( mRightFrame, 1 );
425 425
426 mLeftFrame = mLeftSplitter; 426 mLeftFrame = mLeftSplitter;
427#else 427#else
428 //QWidget *mainBox = new QWidget( this ); 428 //QWidget *mainBox = new QWidget( this );
429 //QWidget *leftFrame = new QWidget( mainBox ); 429 //QWidget *leftFrame = new QWidget( mainBox );
430 //QBoxLayout * mainBoxLayout; 430 //QBoxLayout * mainBoxLayout;
431 if ( KOPrefs::instance()->mVerticalScreen ) { 431 if ( KOPrefs::instance()->mVerticalScreen ) {
432 //mainBoxLayout = new QVBoxLayout(mainBox); 432 //mainBoxLayout = new QVBoxLayout(mainBox);
433 //leftFrameLayout = new QHBoxLayout(leftFrame ); 433 //leftFrameLayout = new QHBoxLayout(leftFrame );
434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
438 } else { 438 } else {
439 //mainBoxLayout = new QHBoxLayout(mainBox); 439 //mainBoxLayout = new QHBoxLayout(mainBox);
440 //leftFrameLayout = new QVBoxLayout(leftFrame ); 440 //leftFrameLayout = new QVBoxLayout(leftFrame );
441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
445 } 445 }
446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
447 //QBoxLayout * leftFrameLayout; 447 //QBoxLayout * leftFrameLayout;
448 topLayout->addWidget( mMainFrame ); 448 topLayout->addWidget( mMainFrame );
449 //mainBoxLayout->addWidget (mLeftFrame); 449 //mainBoxLayout->addWidget (mLeftFrame);
450 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 450 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
451 "CalendarView::DateNavigator" ); 451 "CalendarView::DateNavigator" );
452#if 0 452#if 0
453 // FIXME 453 // FIXME
454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
455 "CalendarView::DateNavigator", QDate::currentDate()); 455 "CalendarView::DateNavigator", QDate::currentDate());
456#endif 456#endif
457 // mDateNavigator->blockSignals( true ); 457 // mDateNavigator->blockSignals( true );
458 //leftFrameLayout->addWidget( mDateNavigator ); 458 //leftFrameLayout->addWidget( mDateNavigator );
459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
462 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
463 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
464 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) );
465 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
462 mTodoList->setNavigator( mNavigator ); 466 mTodoList->setNavigator( mNavigator );
463#if 0 467#if 0
464 if ( QApplication::desktop()->width() < 480 ) { 468 if ( QApplication::desktop()->width() < 480 ) {
465 leftFrameLayout->addWidget(mFilterView); 469 leftFrameLayout->addWidget(mFilterView);
466 leftFrameLayout->addWidget(mTodoList, 2 ); 470 leftFrameLayout->addWidget(mTodoList, 2 );
467 471
468 } else { 472 } else {
469 leftFrameLayout->addWidget(mTodoList,2 ); 473 leftFrameLayout->addWidget(mTodoList,2 );
470 leftFrameLayout->addWidget(mFilterView ); 474 leftFrameLayout->addWidget(mFilterView );
471 } 475 }
472#endif 476#endif
473 mFilterView->hide(); 477 mFilterView->hide();
474 mCalEditView->hide(); 478 mCalEditView->hide();
475 QWidget *rightBox = new QWidget( mMainFrame ); 479 QWidget *rightBox = new QWidget( mMainFrame );
476 //mainBoxLayout->addWidget ( rightBox, 10 ); 480 //mainBoxLayout->addWidget ( rightBox, 10 );
477 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 481 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
478 mRightFrame = new QWidgetStack( rightBox ); 482 mRightFrame = new QWidgetStack( rightBox );
479 rightLayout->addWidget( mRightFrame, 10 ); 483 rightLayout->addWidget( mRightFrame, 10 );
480 484
481 //mLeftFrame = (QWidget *)leftFrame; 485 //mLeftFrame = (QWidget *)leftFrame;
482 if ( KOPrefs::instance()->mVerticalScreen ) { 486 if ( KOPrefs::instance()->mVerticalScreen ) {
483 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 487 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
484 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 488 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
485 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 489 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
486 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 490 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
487 } else { 491 } else {
488 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 492 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
489 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 493 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
490 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 494 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
491 } 495 }
492 if ( !KOPrefs::instance()->mShowDateNavigator) 496 if ( !KOPrefs::instance()->mShowDateNavigator)
493 mDateNavigator->hide(); 497 mDateNavigator->hide();
494 //qDebug("Calendarview Size %d %d ", width(), height()); 498 //qDebug("Calendarview Size %d %d ", width(), height());
495#endif 499#endif
496 500
497 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 501 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
498 SLOT( showDates( const KCal::DateList & ) ) ); 502 SLOT( showDates( const KCal::DateList & ) ) );
499 503
500 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 504 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
501 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 505 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
502 506
503 507
504 508
505 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 509 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
506 mViewManager, SLOT( showMonth( const QDate & ) ) ); 510 mViewManager, SLOT( showMonth( const QDate & ) ) );
507 511
508 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 512 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
509 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 513 mNavigator, SLOT( selectWeek( const QDate & ) ) );
@@ -1789,96 +1793,136 @@ bool CalendarView::importQtopia( const QString &categories,
1789 QtopiaFormat qtopiaFormat; 1793 QtopiaFormat qtopiaFormat;
1790 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1794 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1791 bool loadOk = true; 1795 bool loadOk = true;
1792 if ( !categories.isEmpty() ) 1796 if ( !categories.isEmpty() )
1793 loadOk = qtopiaFormat.load( calendar, categories ); 1797 loadOk = qtopiaFormat.load( calendar, categories );
1794 if ( loadOk && !datebook.isEmpty() ) 1798 if ( loadOk && !datebook.isEmpty() )
1795 loadOk = qtopiaFormat.load( calendar, datebook ); 1799 loadOk = qtopiaFormat.load( calendar, datebook );
1796 if ( loadOk && !todolist.isEmpty() ) 1800 if ( loadOk && !todolist.isEmpty() )
1797 loadOk = qtopiaFormat.load( calendar, todolist ); 1801 loadOk = qtopiaFormat.load( calendar, todolist );
1798 1802
1799 if ( loadOk ) { 1803 if ( loadOk ) {
1800 getEventViewerDialog()->setSyncMode( true ); 1804 getEventViewerDialog()->setSyncMode( true );
1801 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1805 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1802 getEventViewerDialog()->setSyncMode( false ); 1806 getEventViewerDialog()->setSyncMode( false );
1803 qApp->processEvents(); 1807 qApp->processEvents();
1804 if ( syncOK ) { 1808 if ( syncOK ) {
1805 if ( mSyncManager->mWriteBackFile ) 1809 if ( mSyncManager->mWriteBackFile )
1806 { 1810 {
1807 // write back XML file 1811 // write back XML file
1808 1812
1809 } 1813 }
1810 setModified( true ); 1814 setModified( true );
1811 } 1815 }
1812 } else { 1816 } else {
1813 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1817 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1814 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1818 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1815 question, i18n("Ok")) ; 1819 question, i18n("Ok")) ;
1816 } 1820 }
1817 delete calendar; 1821 delete calendar;
1818 updateView(); 1822 updateView();
1819 return syncOK; 1823 return syncOK;
1820 1824
1821 1825
1822#endif 1826#endif
1823 1827
1824} 1828}
1825 1829
1826void CalendarView::setSyncEventsReadOnly() 1830void CalendarView::setSyncEventsReadOnly()
1827{ 1831{
1828 Event * ev; 1832 Event * ev;
1829 QPtrList<Event> eL = mCalendar->rawEvents(); 1833 QPtrList<Event> eL = mCalendar->rawEvents();
1830 ev = eL.first(); 1834 ev = eL.first();
1831 while ( ev ) { 1835 while ( ev ) {
1832 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1836 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1833 ev->setReadOnly( true ); 1837 ev->setReadOnly( true );
1834 ev = eL.next(); 1838 ev = eL.next();
1835 } 1839 }
1836} 1840}
1841
1842bool CalendarView::loadCalendars()
1843{
1844 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1845 KopiCalendarFile * cal = calendars.first();
1846 mCalendar->setDefaultCalendar( 1 );
1847 openCalendar( MainWindow::defaultFileName(), false );
1848 cal = calendars.next();
1849 while ( cal ) {
1850 addCalendar( cal );
1851 cal = calendars.next();
1852 }
1853 restoreCalendarSettings();
1854 mCalendar->reInitAlarmSettings();
1855 setSyncEventsReadOnly();
1856 updateUnmanagedViews();
1857 updateView();
1858}
1859bool CalendarView::restoreCalendarSettings()
1860{
1861 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1862 KopiCalendarFile * cal = calendars.first();
1863 while ( cal ) {
1864 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1865 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1866 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1867 if ( cal->isStandard )
1868 mCalendar->setDefaultCalendar( cal->mCalNumber );
1869 cal = calendars.next();
1870 }
1871}
1872bool CalendarView::addCalendar( KopiCalendarFile * cal )
1873{
1874
1875 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber ))
1876 return true;
1877 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
1878 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
1879 return false;
1880}
1837bool CalendarView::openCalendar(QString filename, bool merge) 1881bool CalendarView::openCalendar(QString filename, bool merge)
1838{ 1882{
1839 1883
1840 if (filename.isEmpty()) { 1884 if (filename.isEmpty()) {
1841 return false; 1885 return false;
1842 } 1886 }
1843 1887
1844 if (!QFile::exists(filename)) { 1888 if (!QFile::exists(filename)) {
1845 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1889 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1846 return false; 1890 return false;
1847 } 1891 }
1848 1892
1849 globalFlagBlockAgenda = 1; 1893 globalFlagBlockAgenda = 1;
1850 clearAllViews(); 1894 clearAllViews();
1851 if (!merge) { 1895 if (!merge) {
1852 mViewManager->setDocumentId( filename ); 1896 mViewManager->setDocumentId( filename );
1853 mCalendar->close(); 1897 mCalendar->close();
1854 } 1898 }
1855 mStorage->setFileName( filename ); 1899 mStorage->setFileName( filename );
1856 1900
1857 if ( mStorage->load() ) { 1901 if ( mStorage->load() ) {
1858 if ( merge ) ;//setModified( true ); 1902 if ( merge ) ;//setModified( true );
1859 else { 1903 else {
1860 //setModified( true ); 1904 //setModified( true );
1861 mViewManager->setDocumentId( filename ); 1905 mViewManager->setDocumentId( filename );
1862 mDialogManager->setDocumentId( filename ); 1906 mDialogManager->setDocumentId( filename );
1863 mTodoList->setDocumentId( filename ); 1907 mTodoList->setDocumentId( filename );
1864 } 1908 }
1865 globalFlagBlockAgenda = 2; 1909 globalFlagBlockAgenda = 2;
1866 // if ( getLastSyncEvent() ) 1910 // if ( getLastSyncEvent() )
1867 // getLastSyncEvent()->setReadOnly( true ); 1911 // getLastSyncEvent()->setReadOnly( true );
1868 mCalendar->reInitAlarmSettings(); 1912 mCalendar->reInitAlarmSettings();
1869 setSyncEventsReadOnly(); 1913 setSyncEventsReadOnly();
1870 updateUnmanagedViews(); 1914 updateUnmanagedViews();
1871 updateView(); 1915 updateView();
1872 if ( filename != MainWindow::defaultFileName() ) { 1916 if ( filename != MainWindow::defaultFileName() ) {
1873 saveCalendar( MainWindow::defaultFileName() ); 1917 saveCalendar( MainWindow::defaultFileName() );
1874 } else { 1918 } else {
1875 QFileInfo finf ( MainWindow::defaultFileName()); 1919 QFileInfo finf ( MainWindow::defaultFileName());
1876 if ( finf.exists() ) { 1920 if ( finf.exists() ) {
1877 setLoadedFileVersion( finf.lastModified () ); 1921 setLoadedFileVersion( finf.lastModified () );
1878 } 1922 }
1879 } 1923 }
1880 return true; 1924 return true;
1881 } else { 1925 } else {
1882 // while failing to load, the calendar object could 1926 // while failing to load, the calendar object could
1883 // have become partially populated. Clear it out. 1927 // have become partially populated. Clear it out.
1884 if ( !merge ) { 1928 if ( !merge ) {
@@ -1919,97 +1963,114 @@ bool CalendarView::checkFileChanged(QString fn)
1919 1963
1920} 1964}
1921void CalendarView::watchSavedFile() 1965void CalendarView::watchSavedFile()
1922{ 1966{
1923 QFileInfo finf ( MainWindow::defaultFileName()); 1967 QFileInfo finf ( MainWindow::defaultFileName());
1924 if ( !finf.exists() ) 1968 if ( !finf.exists() )
1925 return; 1969 return;
1926 QDateTime dt = finf.lastModified (); 1970 QDateTime dt = finf.lastModified ();
1927 if ( dt < loadedFileVersion ) { 1971 if ( dt < loadedFileVersion ) {
1928 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1972 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1929 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1973 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1930 return; 1974 return;
1931 } 1975 }
1932 loadedFileVersion = dt; 1976 loadedFileVersion = dt;
1933} 1977}
1934 1978
1935bool CalendarView::checkFileVersion(QString fn) 1979bool CalendarView::checkFileVersion(QString fn)
1936{ 1980{
1937 QFileInfo finf ( fn ); 1981 QFileInfo finf ( fn );
1938 if ( !finf.exists() ) 1982 if ( !finf.exists() )
1939 return true; 1983 return true;
1940 QDateTime dt = finf.lastModified (); 1984 QDateTime dt = finf.lastModified ();
1941 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1985 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1942 //qDebug("file on disk version %s",dt.toString().latin1()); 1986 //qDebug("file on disk version %s",dt.toString().latin1());
1943 if ( dt <= loadedFileVersion ) 1987 if ( dt <= loadedFileVersion )
1944 return true; 1988 return true;
1945 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1989 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1946 i18n("KO/Pi Warning"),i18n("Overwrite"), 1990 i18n("KO/Pi Warning"),i18n("Overwrite"),
1947 i18n("Sync+save")); 1991 i18n("Sync+save"));
1948 1992
1949 if ( km == KMessageBox::Cancel ) 1993 if ( km == KMessageBox::Cancel )
1950 return false; 1994 return false;
1951 if ( km == KMessageBox::Yes ) 1995 if ( km == KMessageBox::Yes )
1952 return true; 1996 return true;
1953 1997
1954 setSyncDevice("deleteaftersync" ); 1998 setSyncDevice("deleteaftersync" );
1955 mSyncManager->mAskForPreferences = true; 1999 mSyncManager->mAskForPreferences = true;
1956 mSyncManager->mSyncAlgoPrefs = 3; 2000 mSyncManager->mSyncAlgoPrefs = 3;
1957 mSyncManager->mWriteBackFile = false; 2001 mSyncManager->mWriteBackFile = false;
1958 mSyncManager->mWriteBackExistingOnly = false; 2002 mSyncManager->mWriteBackExistingOnly = false;
1959 mSyncManager->mShowSyncSummary = false; 2003 mSyncManager->mShowSyncSummary = false;
1960 syncCalendar( fn, 3 ); 2004 syncCalendar( fn, 3 );
1961 Event * e = getLastSyncEvent(); 2005 Event * e = getLastSyncEvent();
1962 if ( e ) 2006 if ( e )
1963 deleteEvent ( e ); 2007 deleteEvent ( e );
1964 updateView(); 2008 updateView();
1965 return true; 2009 return true;
1966} 2010}
1967 2011bool CalendarView::saveCalendars()
2012{
2013 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2014 KopiCalendarFile * cal = calendars.first();
2015 mCalendar->setDefaultCalendar( 1 );
2016 mCalendar->setDefaultCalendarEnabledOnly();
2017 saveCalendar( MainWindow::defaultFileName() );
2018 cal = calendars.next();
2019 while ( cal ) {
2020 if ( !cal->isReadOnly ) {
2021 mCalendar->setDefaultCalendar( cal->mCalNumber );
2022 mCalendar->setDefaultCalendarEnabledOnly();
2023 saveCalendar( cal->mFileName );
2024 }
2025 cal = calendars.next();
2026 }
2027 restoreCalendarSettings();
2028}
1968bool CalendarView::saveCalendar( QString filename ) 2029bool CalendarView::saveCalendar( QString filename )
1969{ 2030{
1970 2031
1971 // Store back all unsaved data into calendar object 2032 // Store back all unsaved data into calendar object
1972 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2033 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1973 if ( mViewManager->currentView() ) 2034 if ( mViewManager->currentView() )
1974 mViewManager->currentView()->flushView(); 2035 mViewManager->currentView()->flushView();
1975 2036
1976 2037
1977 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2038 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1978 mStorage->setSaveFormat( new ICalFormat() ); 2039 mStorage->setSaveFormat( new ICalFormat() );
1979 mStorage->setFileName( filename ); 2040 mStorage->setFileName( filename );
1980 bool success; 2041 bool success;
1981 success = mStorage->save(); 2042 success = mStorage->save();
1982 if ( !success ) { 2043 if ( !success ) {
1983 return false; 2044 return false;
1984 } 2045 }
1985 if ( filename == MainWindow::defaultFileName() ) { 2046 if ( filename == MainWindow::defaultFileName() ) {
1986 setLoadedFileVersion( lfv ); 2047 setLoadedFileVersion( lfv );
1987 watchSavedFile(); 2048 watchSavedFile();
1988 } 2049 }
1989 return true; 2050 return true;
1990} 2051}
1991 2052
1992void CalendarView::closeCalendar() 2053void CalendarView::closeCalendar()
1993{ 2054{
1994 2055
1995 // child windows no longer valid 2056 // child windows no longer valid
1996 clearAllViews(); 2057 clearAllViews();
1997 emit closingDown(); 2058 emit closingDown();
1998 2059
1999 mCalendar->close(); 2060 mCalendar->close();
2000 setModified(false); 2061 setModified(false);
2001 updateView(); 2062 updateView();
2002} 2063}
2003 2064
2004void CalendarView::archiveCalendar() 2065void CalendarView::archiveCalendar()
2005{ 2066{
2006 mDialogManager->showArchiveDialog(); 2067 mDialogManager->showArchiveDialog();
2007} 2068}
2008 2069
2009 2070
2010void CalendarView::readSettings() 2071void CalendarView::readSettings()
2011{ 2072{
2012 2073
2013 2074
2014 // mViewManager->showAgendaView(); 2075 // mViewManager->showAgendaView();
2015 QString str; 2076 QString str;
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index cdce072..0144ba4 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,98 +1,99 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42#include <KDGanttMinimizeSplitter.h> 42#include <KDGanttMinimizeSplitter.h>
43 43
44#include <korganizer/calendarviewbase.h> 44#include <korganizer/calendarviewbase.h>
45 45
46#include <ksyncmanager.h> 46#include <ksyncmanager.h>
47//#include <koprefs.h>
47 48
48class QWidgetStack; 49class QWidgetStack;
49class QSplitter; 50class QSplitter;
50 51class KopiCalendarFile;
51class CalPrinter; 52class CalPrinter;
52class KOFilterView; 53class KOFilterView;
53class KOCalEditView; 54class KOCalEditView;
54class KOViewManager; 55class KOViewManager;
55class KODialogManager; 56class KODialogManager;
56class KOTodoView; 57class KOTodoView;
57class KDateNavigator; 58class KDateNavigator;
58class DateNavigatorContainer; 59class DateNavigatorContainer;
59class DateNavigator; 60class DateNavigator;
60class KOIncidenceEditor; 61class KOIncidenceEditor;
61class KDatePicker; 62class KDatePicker;
62class ResourceView; 63class ResourceView;
63class KOEventEditor; 64class KOEventEditor;
64class KOTodoEditor ; 65class KOTodoEditor ;
65class KOEventViewerDialog; 66class KOEventViewerDialog;
66class KOBeamPrefs; 67class KOBeamPrefs;
67class KSyncProfile; 68class KSyncProfile;
68class AlarmDialog; 69class AlarmDialog;
69class KCal::Attendee; 70class KCal::Attendee;
70 71
71namespace KCal { class FileStorage; } 72namespace KCal { class FileStorage; }
72 73
73using namespace KCal; 74using namespace KCal;
74 75
75/** 76/**
76 This is the main calendar widget. It provides the different vies on t he 77 This is the main calendar widget. It provides the different vies on t he
77 calendar data as well as the date navigator. It also handles synchronisation 78 calendar data as well as the date navigator. It also handles synchronisation
78 of the different views and controls the different dialogs like preferences, 79 of the different views and controls the different dialogs like preferences,
79 event editor, search dialog etc. 80 event editor, search dialog etc.
80 81
81 @short main calendar view widget 82 @short main calendar view widget
82 @author Cornelius Schumacher 83 @author Cornelius Schumacher
83*/ 84*/
84 85
85#include <qtextbrowser.h> 86#include <qtextbrowser.h>
86#include <qtextcodec.h> 87#include <qtextcodec.h>
87 88
88class MissedAlarmTextBrowser : public QTextBrowser { 89class MissedAlarmTextBrowser : public QTextBrowser {
89 Q_OBJECT 90 Q_OBJECT
90 public: 91 public:
91 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); 92 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start);
92 ~MissedAlarmTextBrowser(); 93 ~MissedAlarmTextBrowser();
93 void setSource(const QString & n); 94 void setSource(const QString & n);
94 95
95 private: 96 private:
96 Incidence * getNextInc(QDateTime start ); 97 Incidence * getNextInc(QDateTime start );
97 QPtrList<Incidence> mAlarms; 98 QPtrList<Incidence> mAlarms;
98 signals: 99 signals:
@@ -177,96 +178,100 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
177 void todoSelected( bool ); 178 void todoSelected( bool );
178 179
179 /** 180 /**
180 Emitted, when clipboard content changes. Parameter indicates if paste 181 Emitted, when clipboard content changes. Parameter indicates if paste
181 is possible or not. 182 is possible or not.
182 */ 183 */
183 void pasteEnabled(bool); 184 void pasteEnabled(bool);
184 185
185 /** Emitted, when the number of incoming messages has changed. */ 186 /** Emitted, when the number of incoming messages has changed. */
186 void numIncomingChanged(int); 187 void numIncomingChanged(int);
187 188
188 /** Emitted, when the number of outgoing messages has changed. */ 189 /** Emitted, when the number of outgoing messages has changed. */
189 void numOutgoingChanged(int); 190 void numOutgoingChanged(int);
190 191
191 /** Send status message, which can e.g. be displayed in the status bar. */ 192 /** Send status message, which can e.g. be displayed in the status bar. */
192 void statusMessage(const QString &); 193 void statusMessage(const QString &);
193 194
194 void calendarViewExpanded( bool ); 195 void calendarViewExpanded( bool );
195 void updateSearchDialog(); 196 void updateSearchDialog();
196 197
197 198
198 public slots: 199 public slots:
199 void checkAlarms(); 200 void checkAlarms();
200 void slotprintSelInc(); 201 void slotprintSelInc();
201 void showNextAlarms(); 202 void showNextAlarms();
202 void showOpenError(); 203 void showOpenError();
203 void watchSavedFile(); 204 void watchSavedFile();
204 void recheckTimerAlarm(); 205 void recheckTimerAlarm();
205 void checkNextTimerAlarm(); 206 void checkNextTimerAlarm();
206 void addAlarm(const QDateTime &qdt, const QString &noti ); 207 void addAlarm(const QDateTime &qdt, const QString &noti );
207 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 208 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
208 void removeAlarm(const QDateTime &qdt, const QString &noti ); 209 void removeAlarm(const QDateTime &qdt, const QString &noti );
209 210
210 /** options dialog made a changed to the configuration. we catch this 211 /** options dialog made a changed to the configuration. we catch this
211 * and notify all widgets which need to update their configuration. */ 212 * and notify all widgets which need to update their configuration. */
212 void updateConfig(); 213 void updateConfig();
213 214
214 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 215 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
215 const QStringList& anniversaryList, const QStringList& realNameList, 216 const QStringList& anniversaryList, const QStringList& realNameList,
216 const QStringList& emailList, const QStringList& assembledNameList, 217 const QStringList& emailList, const QStringList& assembledNameList,
217 const QStringList& uidList); 218 const QStringList& uidList);
218 219
219 /** 220 /**
220 Load calendar from file \a filename. If \a merge is true, load 221 Load calendar from file \a filename. If \a merge is true, load
221 calendar into existing one, if it is false, clear calendar, before 222 calendar into existing one, if it is false, clear calendar, before
222 loading. Return true, if calendar could be successfully loaded. 223 loading. Return true, if calendar could be successfully loaded.
223 */ 224 */
224 bool openCalendar(QString filename, bool merge=false); 225 bool openCalendar(QString filename, bool merge=false);
226 bool loadCalendars();
227 bool saveCalendars();
228 bool restoreCalendarSettings();
229 bool addCalendar( KopiCalendarFile * );
225 bool syncCalendar(QString filename,int mode = 0 ); 230 bool syncCalendar(QString filename,int mode = 0 );
226 231
227 /** 232 /**
228 Save calendar data to file. Return true if calendar could be 233 Save calendar data to file. Return true if calendar could be
229 successfully saved. 234 successfully saved.
230 */ 235 */
231 bool saveCalendar(QString filename); 236 bool saveCalendar(QString filename);
232 237
233 /** 238 /**
234 Close calendar. Clear calendar data and reset views to display an empty 239 Close calendar. Clear calendar data and reset views to display an empty
235 calendar. 240 calendar.
236 */ 241 */
237 void closeCalendar(); 242 void closeCalendar();
238 243
239 /** Archive old events of calendar */ 244 /** Archive old events of calendar */
240 void archiveCalendar(); 245 void archiveCalendar();
241 246
242 void showIncidence(); 247 void showIncidence();
243 void editIncidence(); 248 void editIncidence();
244 void editIncidenceDescription(); 249 void editIncidenceDescription();
245 void deleteIncidence(); 250 void deleteIncidence();
246 void cloneIncidence(); 251 void cloneIncidence();
247 void moveIncidence(); 252 void moveIncidence();
248 void beamIncidence(); 253 void beamIncidence();
249 void toggleCancelIncidence(); 254 void toggleCancelIncidence();
250 255
251 /** create an editeventwin with supplied date/time, and if bool is true, 256 /** create an editeventwin with supplied date/time, and if bool is true,
252 * make the event take all day. */ 257 * make the event take all day. */
253 void newEvent(QDateTime, QDateTime, bool allDay ); 258 void newEvent(QDateTime, QDateTime, bool allDay );
254 void newEvent(QDateTime, QDateTime); 259 void newEvent(QDateTime, QDateTime);
255 void newEvent(QDateTime fh); 260 void newEvent(QDateTime fh);
256 void newEvent(QDate dt); 261 void newEvent(QDate dt);
257 /** create new event without having a date hint. Takes current date as 262 /** create new event without having a date hint. Takes current date as
258 default hint. */ 263 default hint. */
259 void newEvent(); 264 void newEvent();
260 void newFloatingEvent(); 265 void newFloatingEvent();
261 266
262 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 267 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
263 void showIncidence(Incidence *); 268 void showIncidence(Incidence *);
264 void showIncidence(QString uid); 269 void showIncidence(QString uid);
265 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 270 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
266 void editIncidence(Incidence *); 271 void editIncidence(Incidence *);
267 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 272 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
268 void deleteIncidence(Incidence *); 273 void deleteIncidence(Incidence *);
269 void cloneIncidence(Incidence *); 274 void cloneIncidence(Incidence *);
270 void cancelIncidence(Incidence *); 275 void cancelIncidence(Incidence *);
271 /** Create an editor for the supplied event. */ 276 /** Create an editor for the supplied event. */
272 void editEvent(Event *); 277 void editEvent(Event *);
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index 2dd4567..29a4393 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -21,97 +21,97 @@
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qdialog.h> 29#include <qdialog.h>
30 30
31 31
32#include <libkcal/calfilter.h> 32#include <libkcal/calfilter.h>
33 33
34#include "kofilterview.h" 34#include "kofilterview.h"
35#include "koprefs.h" 35#include "koprefs.h"
36#include <kiconloader.h> 36#include <kiconloader.h>
37#include <kglobal.h> 37#include <kglobal.h>
38#include <kcolorbutton.h> 38#include <kcolorbutton.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40 40
41 41
42#include <kurlrequester.h> 42#include <kurlrequester.h>
43#include <klineedit.h> 43#include <klineedit.h>
44 44
45class KONewCalPrefs : public QDialog 45class KONewCalPrefs : public QDialog
46{ 46{
47 public: 47 public:
48 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : 48 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) :
49 QDialog( parent, name, true ) 49 QDialog( parent, name, true )
50 { 50 {
51 setCaption( i18n("Add new Calendar") ); 51 setCaption( i18n("Add new Calendar") );
52 QVBoxLayout* lay = new QVBoxLayout( this ); 52 QVBoxLayout* lay = new QVBoxLayout( this );
53 lay->setSpacing( 3 ); 53 lay->setSpacing( 3 );
54 lay->setMargin( 3 ); 54 lay->setMargin( 3 );
55 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); 55 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this );
56 lay->addWidget( lab ); 56 lay->addWidget( lab );
57 nameE = new KLineEdit( this ); 57 nameE = new KLineEdit( this );
58 lay->addWidget( nameE ); 58 lay->addWidget( nameE );
59 lab = new QLabel( i18n("Local ical (*.ics) file:"), this ); 59 lab = new QLabel( i18n("Local ical (*.ics) file:"), this );
60 lay->addWidget( lab ); 60 lay->addWidget( lab );
61 url = new KURLRequester ( this ); 61 url = new KURLRequester ( this );
62 lay->addWidget( url ); 62 lay->addWidget( url );
63 QPushButton * ok = new QPushButton( i18n("OK"), this ); 63 QPushButton * ok = new QPushButton( i18n("OK"), this );
64 lay->addWidget( ok ); 64 lay->addWidget( ok );
65 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 65 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
66 lay->addWidget( cancel ); 66 lay->addWidget( cancel );
67 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 67 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
68 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 68 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
69 resize( 200, 200 ); 69 //resize( 200, 200 );
70 } 70 }
71 71
72 QString calName() { return nameE->text(); } 72 QString calName() { return nameE->text(); }
73 QString calFileName() { return url->url(); } 73 QString calFileName() { return url->url(); }
74private: 74private:
75 KLineEdit* nameE; 75 KLineEdit* nameE;
76 KURLRequester *url; 76 KURLRequester *url;
77}; 77};
78 78
79 79
80KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, 80KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent,
81 const char* name,WFlags fl ) 81 const char* name,WFlags fl )
82 : KOFilterView_base(parent,name,fl) 82 : KOFilterView_base(parent,name,fl)
83{ 83{
84 mFilters = filterList; 84 mFilters = filterList;
85 85
86 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); 86 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
87 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); 87 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
88 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); 88 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
89} 89}
90 90
91KOFilterView::~KOFilterView() 91KOFilterView::~KOFilterView()
92{ 92{
93 // no need to delete child widgets, Qt does it all for us 93 // no need to delete child widgets, Qt does it all for us
94} 94}
95 95
96bool KOFilterView::filtersEnabled() 96bool KOFilterView::filtersEnabled()
97{ 97{
98 return mEnabledCheck->isChecked(); 98 return mEnabledCheck->isChecked();
99} 99}
100 100
101void KOFilterView::setFiltersEnabled(bool set) 101void KOFilterView::setFiltersEnabled(bool set)
102{ 102{
103 mEnabledCheck->setChecked(set); 103 mEnabledCheck->setChecked(set);
104 emit filterChanged(); 104 emit filterChanged();
105} 105}
106 106
107 107
108void KOFilterView::updateFilters() 108void KOFilterView::updateFilters()
109{ 109{
110 mSelectionCombo->clear(); 110 mSelectionCombo->clear();
111 111
112 CalFilter *filter = mFilters->first(); 112 CalFilter *filter = mFilters->first();
113 while(filter) { 113 while(filter) {
114 mSelectionCombo->insertItem(filter->name()); 114 mSelectionCombo->insertItem(filter->name());
115 filter = mFilters->next(); 115 filter = mFilters->next();
116 } 116 }
117} 117}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 95e1607..f05ada5 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -263,97 +263,97 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
263 mView = new CalendarView( mCalendar, this,"mCalendar " ); 263 mView = new CalendarView( mCalendar, this,"mCalendar " );
264 mView->hide(); 264 mView->hide();
265 //mView->resize(splash->size() ); 265 //mView->resize(splash->size() );
266 initActions(); 266 initActions();
267 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 267 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
268 mSyncManager->setBlockSave(false); 268 mSyncManager->setBlockSave(false);
269 mView->setSyncManager(mSyncManager); 269 mView->setSyncManager(mSyncManager);
270#ifndef DESKTOP_VERSION 270#ifndef DESKTOP_VERSION
271 iconToolBar->show(); 271 iconToolBar->show();
272 qApp->processEvents(); 272 qApp->processEvents();
273#endif 273#endif
274 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 274 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
275 int vh = height() ; 275 int vh = height() ;
276 int vw = width(); 276 int vw = width();
277 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 277 //qDebug("Toolbar hei %d ",iconToolBar->height() );
278 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 278 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
279 vh -= iconToolBar->height(); 279 vh -= iconToolBar->height();
280 } else { 280 } else {
281 vw -= iconToolBar->height(); 281 vw -= iconToolBar->height();
282 } 282 }
283 //mView->setMaximumSize( splash->size() ); 283 //mView->setMaximumSize( splash->size() );
284 //mView->resize( splash->size() ); 284 //mView->resize( splash->size() );
285 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 285 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
286 mView->readSettings(); 286 mView->readSettings();
287 bool newFile = false; 287 bool newFile = false;
288 if( !QFile::exists( defaultFileName() ) ) { 288 if( !QFile::exists( defaultFileName() ) ) {
289 QFileInfo finfo ( defaultFileName() ); 289 QFileInfo finfo ( defaultFileName() );
290 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 290 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
291 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 291 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
292 finfo.setFile( oldFile ); 292 finfo.setFile( oldFile );
293 if (finfo.exists() ) { 293 if (finfo.exists() ) {
294 KMessageBox::information( this, message); 294 KMessageBox::information( this, message);
295 mView->openCalendar( oldFile ); 295 mView->openCalendar( oldFile );
296 qApp->processEvents(); 296 qApp->processEvents();
297 } else { 297 } else {
298 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 298 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
299 finfo.setFile( oldFile ); 299 finfo.setFile( oldFile );
300 if (finfo.exists() ) { 300 if (finfo.exists() ) {
301 KMessageBox::information( this, message); 301 KMessageBox::information( this, message);
302 mView->openCalendar( oldFile ); 302 mView->openCalendar( oldFile );
303 qApp->processEvents(); 303 qApp->processEvents();
304 } 304 }
305 } 305 }
306 mView->saveCalendar( defaultFileName() ); 306 mView->saveCalendar( defaultFileName() );
307 newFile = true; 307 newFile = true;
308 } 308 }
309 309
310 QTime neededSaveTime = QDateTime::currentDateTime().time(); 310 QTime neededSaveTime = QDateTime::currentDateTime().time();
311 mView->openCalendar( defaultFileName() ); 311 mView->loadCalendars();
312 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 312 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
313 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 313 qDebug("KO: Calendar loading time: %d ms",msNeeded );
314 314
315 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 315 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
316 KOPrefs::instance()->setAllDefaults(); 316 KOPrefs::instance()->setAllDefaults();
317 int count = mView->addCategories(); 317 int count = mView->addCategories();
318 } 318 }
319 processIncidenceSelection( 0 ); 319 processIncidenceSelection( 0 );
320 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 320 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
321 SLOT( processIncidenceSelection( Incidence * ) ) ); 321 SLOT( processIncidenceSelection( Incidence * ) ) );
322 connect( mView, SIGNAL( modifiedChanged( bool ) ), 322 connect( mView, SIGNAL( modifiedChanged( bool ) ),
323 SLOT( slotModifiedChanged( bool ) ) ); 323 SLOT( slotModifiedChanged( bool ) ) );
324 324
325 325
326 connect( mView, SIGNAL( tempDisableBR(bool) ), 326 connect( mView, SIGNAL( tempDisableBR(bool) ),
327 SLOT( disableBR(bool) ) ); 327 SLOT( disableBR(bool) ) );
328 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 328 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
329 mView->setModified( false ); 329 mView->setModified( false );
330 mBlockAtStartup = false; 330 mBlockAtStartup = false;
331 mView->setModified( false ); 331 mView->setModified( false );
332 setCentralWidget( mView ); 332 setCentralWidget( mView );
333 globalFlagBlockStartup = 0; 333 globalFlagBlockStartup = 0;
334 mView->show(); 334 mView->show();
335 delete splash; 335 delete splash;
336 if ( newFile ) 336 if ( newFile )
337 mView->updateConfig(); 337 mView->updateConfig();
338 // qApp->processEvents(); 338 // qApp->processEvents();
339 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 339 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
340 //fillSyncMenu(); 340 //fillSyncMenu();
341 341
342 342
343 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 343 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
344 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 344 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
345 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 345 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
346 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 346 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
347 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 347 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
348 mSyncManager->setDefaultFileName( sentSyncFile()); 348 mSyncManager->setDefaultFileName( sentSyncFile());
349 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 349 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
350 mSyncManager->fillSyncMenu(); 350 mSyncManager->fillSyncMenu();
351 351
352 352
353 353
354 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 354 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
355 if ( showWarning ) { 355 if ( showWarning ) {
356 KMessageBox::information( this, 356 KMessageBox::information( this,
357 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 357 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
358 qApp->processEvents(); 358 qApp->processEvents();
359 mView->dialogManager()->showSyncOptions(); 359 mView->dialogManager()->showSyncOptions();
@@ -1812,97 +1812,97 @@ void MainWindow::slotModifiedChanged( bool changed )
1812 mCalendarModifiedFlag = true; 1812 mCalendarModifiedFlag = true;
1813} 1813}
1814void MainWindow::saveStopTimer() 1814void MainWindow::saveStopTimer()
1815{ 1815{
1816 mSaveTimer.stop(); 1816 mSaveTimer.stop();
1817} 1817}
1818void MainWindow::save() 1818void MainWindow::save()
1819{ 1819{
1820 if ( !mCalendarModifiedFlag ) { 1820 if ( !mCalendarModifiedFlag ) {
1821 qDebug("KO: Calendar not modified. Nothing saved."); 1821 qDebug("KO: Calendar not modified. Nothing saved.");
1822 return; 1822 return;
1823 } 1823 }
1824 if ( mSyncManager->blockSave() ) 1824 if ( mSyncManager->blockSave() )
1825 return; 1825 return;
1826 mSyncManager->setBlockSave(true); 1826 mSyncManager->setBlockSave(true);
1827 if ( mView->checkFileVersion( defaultFileName()) ) { 1827 if ( mView->checkFileVersion( defaultFileName()) ) {
1828 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 1828 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1829 QDate reference ( 2000,1,1); 1829 QDate reference ( 2000,1,1);
1830 int daysTo = reference.daysTo ( QDate::currentDate() ); 1830 int daysTo = reference.daysTo ( QDate::currentDate() );
1831 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 1831 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1832 setCaption(i18n("Creating backup ... please wait ..." )); 1832 setCaption(i18n("Creating backup ... please wait ..." ));
1833 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1833 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1834 // we need the file path, the backup dir and the number of bups as param 1834 // we need the file path, the backup dir and the number of bups as param
1835 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1835 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1836 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1836 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1837 bupDir = KGlobalSettings::backupDataDir(); 1837 bupDir = KGlobalSettings::backupDataDir();
1838 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1838 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1839 if ( retval == 0 ) { 1839 if ( retval == 0 ) {
1840 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1840 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1841 // retval == 0 : backup skipped for today, try again tomorrow 1841 // retval == 0 : backup skipped for today, try again tomorrow
1842 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1842 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1843 } else if ( retval == 1 ){ 1843 } else if ( retval == 1 ){
1844 qDebug("KO: Backup created."); 1844 qDebug("KO: Backup created.");
1845 // backup ok 1845 // backup ok
1846 KOPrefs::instance()->mLastBackupDate = daysTo; 1846 KOPrefs::instance()->mLastBackupDate = daysTo;
1847 1847
1848 } else if ( retval == 2 ){ 1848 } else if ( retval == 2 ){
1849 qDebug("KO: Backup globally cancelled."); 1849 qDebug("KO: Backup globally cancelled.");
1850 // backup globally cancelled 1850 // backup globally cancelled
1851 KPimGlobalPrefs::instance()->mBackupEnabled = false; 1851 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1852 } 1852 }
1853 // retval == 3: do nothing, try again later 1853 // retval == 3: do nothing, try again later
1854 } 1854 }
1855 ; // KPimGlobalPrefs::instance()->mLastBackupDate 1855 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1856 } 1856 }
1857 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1857 QTime neededSaveTime = QDateTime::currentDateTime().time();
1858 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1858 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1859 qDebug("KO: Start saving data to file!"); 1859 qDebug("KO: Start saving data to file!");
1860 mView->saveCalendar( defaultFileName() ); 1860 mView->saveCalendars();
1861 mCalendarModifiedFlag = false; 1861 mCalendarModifiedFlag = false;
1862 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1862 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1863 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1863 qDebug("KO: Needed %d ms for saving.",msNeeded );
1864 QString savemes; 1864 QString savemes;
1865 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1865 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1866 setCaption(savemes); 1866 setCaption(savemes);
1867 } else 1867 } else
1868 setCaption(i18n("Saving cancelled!")); 1868 setCaption(i18n("Saving cancelled!"));
1869 mSyncManager->setBlockSave( false ); 1869 mSyncManager->setBlockSave( false );
1870} 1870}
1871 1871
1872void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1872void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1873{ 1873{
1874 if ( !e->isAutoRepeat() ) { 1874 if ( !e->isAutoRepeat() ) {
1875 mFlagKeyPressed = false; 1875 mFlagKeyPressed = false;
1876 } 1876 }
1877} 1877}
1878void MainWindow::keyPressEvent ( QKeyEvent * e ) 1878void MainWindow::keyPressEvent ( QKeyEvent * e )
1879{ 1879{
1880 qApp->processEvents(); 1880 qApp->processEvents();
1881 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1881 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1882 e->ignore(); 1882 e->ignore();
1883 // qDebug(" ignore %d",e->isAutoRepeat() ); 1883 // qDebug(" ignore %d",e->isAutoRepeat() );
1884 return; 1884 return;
1885 } 1885 }
1886 if (! e->isAutoRepeat() ) 1886 if (! e->isAutoRepeat() )
1887 mFlagKeyPressed = true; 1887 mFlagKeyPressed = true;
1888 KOPrefs *p = KOPrefs::instance(); 1888 KOPrefs *p = KOPrefs::instance();
1889 bool showSelectedDates = false; 1889 bool showSelectedDates = false;
1890 int size; 1890 int size;
1891 int pro = 0; 1891 int pro = 0;
1892 //qDebug("MainWindow::keyPressEvent "); 1892 //qDebug("MainWindow::keyPressEvent ");
1893 switch ( e->key() ) { 1893 switch ( e->key() ) {
1894 case Qt::Key_Right: 1894 case Qt::Key_Right:
1895 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1895 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1896 mView->goNextMonth(); 1896 mView->goNextMonth();
1897 else 1897 else
1898 mView->goNext(); 1898 mView->goNext();
1899 showSelectedDates = true; 1899 showSelectedDates = true;
1900 break; 1900 break;
1901 case Qt::Key_Left: 1901 case Qt::Key_Left:
1902 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1902 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1903 mView->goPreviousMonth(); 1903 mView->goPreviousMonth();
1904 else 1904 else
1905 mView->goPrevious(); 1905 mView->goPrevious();
1906 showSelectedDates = true; 1906 showSelectedDates = true;
1907 break; 1907 break;
1908 case Qt::Key_Down: 1908 case Qt::Key_Down:
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index f4350d9..5092d1a 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -8,155 +8,160 @@
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <stdlib.h> 22#include <stdlib.h>
23#include <time.h> 23#include <time.h>
24 24
25#include <kdebug.h> 25#include <kdebug.h>
26#include <kglobal.h> 26#include <kglobal.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29#include "exceptions.h" 29#include "exceptions.h"
30#include "calfilter.h" 30#include "calfilter.h"
31 31
32#include "calendar.h" 32#include "calendar.h"
33#include "syncdefines.h" 33#include "syncdefines.h"
34 34
35using namespace KCal; 35using namespace KCal;
36 36
37Calendar::Calendar() 37Calendar::Calendar()
38{ 38{
39 39
40 init(); 40 init();
41 setTimeZoneId( " 00:00 Europe/London(UTC)" ); 41 setTimeZoneId( " 00:00 Europe/London(UTC)" );
42} 42}
43 43
44Calendar::Calendar( const QString &timeZoneId ) 44Calendar::Calendar( const QString &timeZoneId )
45{ 45{
46 46
47 init(); 47 init();
48 setTimeZoneId(timeZoneId); 48 setTimeZoneId(timeZoneId);
49} 49}
50 50
51void Calendar::init() 51void Calendar::init()
52{ 52{
53 mObserver = 0; 53 mObserver = 0;
54 mNewObserver = false; 54 mNewObserver = false;
55 mUndoIncidence = 0; 55 mUndoIncidence = 0;
56 mDeleteIncidencesOnClose = true;
56 mModified = false; 57 mModified = false;
57 mDefaultCalendar = 1; 58 mDefaultCalendar = 1;
58 // Setup default filter, which does nothing 59 // Setup default filter, which does nothing
59 mDefaultFilter = new CalFilter; 60 mDefaultFilter = new CalFilter;
60 mFilter = mDefaultFilter; 61 mFilter = mDefaultFilter;
61 mFilter->setEnabled(false); 62 mFilter->setEnabled(false);
62 63
63 // initialize random numbers. This is a hack, and not 64 // initialize random numbers. This is a hack, and not
64 // even that good of one at that. 65 // even that good of one at that.
65// srandom(time(0)); 66// srandom(time(0));
66 67
67 // user information... 68 // user information...
68 setOwner(i18n("Unknown Name")); 69 setOwner(i18n("Unknown Name"));
69 setEmail(i18n("unknown@nowhere")); 70 setEmail(i18n("unknown@nowhere"));
70 71
71#if 0 72#if 0
72 tmpStr = KOPrefs::instance()->mTimeZone; 73 tmpStr = KOPrefs::instance()->mTimeZone;
73// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; 74// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl;
74 int dstSetting = KOPrefs::instance()->mDaylightSavings; 75 int dstSetting = KOPrefs::instance()->mDaylightSavings;
75 extern long int timezone; 76 extern long int timezone;
76 struct tm *now; 77 struct tm *now;
77 time_t curtime; 78 time_t curtime;
78 curtime = time(0); 79 curtime = time(0);
79 now = localtime(&curtime); 80 now = localtime(&curtime);
80 int hourOff = - ((timezone / 60) / 60); 81 int hourOff = - ((timezone / 60) / 60);
81 if (now->tm_isdst) 82 if (now->tm_isdst)
82 hourOff += 1; 83 hourOff += 1;
83 QString tzStr; 84 QString tzStr;
84 tzStr.sprintf("%.2d%.2d", 85 tzStr.sprintf("%.2d%.2d",
85 hourOff, 86 hourOff,
86 abs((timezone / 60) % 60)); 87 abs((timezone / 60) % 60));
87 88
88 // if no time zone was in the config file, write what we just discovered. 89 // if no time zone was in the config file, write what we just discovered.
89 if (tmpStr.isEmpty()) { 90 if (tmpStr.isEmpty()) {
90// KOPrefs::instance()->mTimeZone = tzStr; 91// KOPrefs::instance()->mTimeZone = tzStr;
91 } else { 92 } else {
92 tzStr = tmpStr; 93 tzStr = tmpStr;
93 } 94 }
94 95
95 // if daylight savings has changed since last load time, we need 96 // if daylight savings has changed since last load time, we need
96 // to rewrite these settings to the config file. 97 // to rewrite these settings to the config file.
97 if ((now->tm_isdst && !dstSetting) || 98 if ((now->tm_isdst && !dstSetting) ||
98 (!now->tm_isdst && dstSetting)) { 99 (!now->tm_isdst && dstSetting)) {
99 KOPrefs::instance()->mTimeZone = tzStr; 100 KOPrefs::instance()->mTimeZone = tzStr;
100 KOPrefs::instance()->mDaylightSavings = now->tm_isdst; 101 KOPrefs::instance()->mDaylightSavings = now->tm_isdst;
101 } 102 }
102 103
103 setTimeZone(tzStr); 104 setTimeZone(tzStr);
104#endif 105#endif
105 106
106// KOPrefs::instance()->writeConfig(); 107// KOPrefs::instance()->writeConfig();
107} 108}
108 109
109Calendar::~Calendar() 110Calendar::~Calendar()
110{ 111{
111 delete mDefaultFilter; 112 delete mDefaultFilter;
112 if ( mUndoIncidence ) 113 if ( mUndoIncidence )
113 delete mUndoIncidence; 114 delete mUndoIncidence;
114} 115}
116void Calendar::setDontDeleteIncidencesOnClose ()
117{
118 mDeleteIncidencesOnClose = false;
119}
115void Calendar::setDefaultCalendar( int d ) 120void Calendar::setDefaultCalendar( int d )
116{ 121{
117 mDefaultCalendar = d; 122 mDefaultCalendar = d;
118} 123}
119int Calendar::defaultCalendar() 124int Calendar::defaultCalendar()
120{ 125{
121 return mDefaultCalendar; 126 return mDefaultCalendar;
122} 127}
123const QString &Calendar::getOwner() const 128const QString &Calendar::getOwner() const
124{ 129{
125 return mOwner; 130 return mOwner;
126} 131}
127 132
128bool Calendar::undoDeleteIncidence() 133bool Calendar::undoDeleteIncidence()
129{ 134{
130 if (!mUndoIncidence) 135 if (!mUndoIncidence)
131 return false; 136 return false;
132 addIncidence(mUndoIncidence); 137 addIncidence(mUndoIncidence);
133 mUndoIncidence = 0; 138 mUndoIncidence = 0;
134 return true; 139 return true;
135} 140}
136void Calendar::setOwner(const QString &os) 141void Calendar::setOwner(const QString &os)
137{ 142{
138 int i; 143 int i;
139 mOwner = os; 144 mOwner = os;
140 i = mOwner.find(','); 145 i = mOwner.find(',');
141 if (i != -1) 146 if (i != -1)
142 mOwner = mOwner.left(i); 147 mOwner = mOwner.left(i);
143 148
144 setModified( true ); 149 setModified( true );
145} 150}
146 151
147void Calendar::setTimeZone(const QString & tz) 152void Calendar::setTimeZone(const QString & tz)
148{ 153{
149 bool neg = FALSE; 154 bool neg = FALSE;
150 int hours, minutes; 155 int hours, minutes;
151 QString tmpStr(tz); 156 QString tmpStr(tz);
152 157
153 if (tmpStr.left(1) == "-") 158 if (tmpStr.left(1) == "-")
154 neg = TRUE; 159 neg = TRUE;
155 if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") 160 if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+")
156 tmpStr.remove(0, 1); 161 tmpStr.remove(0, 1);
157 hours = tmpStr.left(2).toInt(); 162 hours = tmpStr.left(2).toInt();
158 if (tmpStr.length() > 2) 163 if (tmpStr.length() > 2)
159 minutes = tmpStr.right(2).toInt(); 164 minutes = tmpStr.right(2).toInt();
160 else 165 else
161 minutes = 0; 166 minutes = 0;
162 mTimeZone = (60*hours+minutes); 167 mTimeZone = (60*hours+minutes);
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 4c6760f..73f82bb 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -29,96 +29,98 @@
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "event.h" 32#include "event.h"
33#include "todo.h" 33#include "todo.h"
34#include "journal.h" 34#include "journal.h"
35#include "calfilter.h" 35#include "calfilter.h"
36 36
37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ 37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */
38 38
39class KConfig; 39class KConfig;
40 40
41namespace KCal { 41namespace KCal {
42 42
43 43
44/** 44/**
45 This is the main "calendar" object class for KOrganizer. It holds 45 This is the main "calendar" object class for KOrganizer. It holds
46 information like all appointments/events, user information, etc. etc. 46 information like all appointments/events, user information, etc. etc.
47 one calendar is associated with each CalendarView (@see calendarview.h). 47 one calendar is associated with each CalendarView (@see calendarview.h).
48 This is an abstract base class defining the interface to a calendar. It is 48 This is an abstract base class defining the interface to a calendar. It is
49 implemented by subclasses like @see CalendarLocal, which use different 49 implemented by subclasses like @see CalendarLocal, which use different
50 methods to store and access the data. 50 methods to store and access the data.
51 51
52 Ownership of events etc. is handled by the following policy: As soon as an 52 Ownership of events etc. is handled by the following policy: As soon as an
53 event (or any other subclass of IncidenceBase) object is added to the 53 event (or any other subclass of IncidenceBase) object is added to the
54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes 54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes
55 care of deleting it. All Events returned by the query functions are returned 55 care of deleting it. All Events returned by the query functions are returned
56 as pointers, that means all changes to the returned events are immediately 56 as pointers, that means all changes to the returned events are immediately
57 visible in the Calendar. You shouldn't delete any Event object you get from 57 visible in the Calendar. You shouldn't delete any Event object you get from
58 Calendar. 58 Calendar.
59*/ 59*/
60class Calendar : public QObject, public CustomProperties, 60class Calendar : public QObject, public CustomProperties,
61 public IncidenceBase::Observer 61 public IncidenceBase::Observer
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 Calendar(); 65 Calendar();
66 Calendar(const QString &timeZoneId); 66 Calendar(const QString &timeZoneId);
67 virtual ~Calendar(); 67 virtual ~Calendar();
68 Incidence * undoIncidence() { return mUndoIncidence; }; 68 Incidence * undoIncidence() { return mUndoIncidence; };
69 bool undoDeleteIncidence(); 69 bool undoDeleteIncidence();
70 void deleteIncidence(Incidence *in); 70 void deleteIncidence(Incidence *in);
71 void resetTempSyncStat(); 71 void resetTempSyncStat();
72 void resetPilotStat(int id); 72 void resetPilotStat(int id);
73 /** 73 /**
74 Clears out the current calendar, freeing all used memory etc. 74 Clears out the current calendar, freeing all used memory etc.
75 */ 75 */
76 virtual void close() = 0; 76 virtual void close() = 0;
77 virtual void addCalendar( Calendar* ) = 0;
78 virtual bool addCalendarFile( QString name, int id ) = 0;
77 79
78 /** 80 /**
79 Sync changes in memory to persistant storage. 81 Sync changes in memory to persistant storage.
80 */ 82 */
81 virtual void save() = 0; 83 virtual void save() = 0;
82 virtual QPtrList<Event> getExternLastSyncEvents() = 0; 84 virtual QPtrList<Event> getExternLastSyncEvents() = 0;
83 virtual void removeSyncInfo( QString syncProfile) = 0; 85 virtual void removeSyncInfo( QString syncProfile) = 0;
84 virtual bool isSaving() { return false; } 86 virtual bool isSaving() { return false; }
85 87
86 /** 88 /**
87 Return the owner of the calendar's full name. 89 Return the owner of the calendar's full name.
88 */ 90 */
89 const QString &getOwner() const; 91 const QString &getOwner() const;
90 /** 92 /**
91 Set the owner of the calendar. Should be owner's full name. 93 Set the owner of the calendar. Should be owner's full name.
92 */ 94 */
93 void setOwner( const QString &os ); 95 void setOwner( const QString &os );
94 /** 96 /**
95 Return the email address of the calendar owner. 97 Return the email address of the calendar owner.
96 */ 98 */
97 const QString &getEmail(); 99 const QString &getEmail();
98 /** 100 /**
99 Set the email address of the calendar owner. 101 Set the email address of the calendar owner.
100 */ 102 */
101 void setEmail( const QString & ); 103 void setEmail( const QString & );
102 104
103 /** 105 /**
104 Set time zone from a timezone string (e.g. -2:00) 106 Set time zone from a timezone string (e.g. -2:00)
105 */ 107 */
106 void setTimeZone( const QString &tz ); 108 void setTimeZone( const QString &tz );
107 /** 109 /**
108 Set time zone from a minutes value (e.g. -60) 110 Set time zone from a minutes value (e.g. -60)
109 */ 111 */
110 void setTimeZone( int tz ); 112 void setTimeZone( int tz );
111 /** 113 /**
112 Return time zone as offest in minutes. 114 Return time zone as offest in minutes.
113 */ 115 */
114 int getTimeZone() const; 116 int getTimeZone() const;
115 /** 117 /**
116 Compute an ISO 8601 format string from the time zone. 118 Compute an ISO 8601 format string from the time zone.
117 */ 119 */
118 QString getTimeZoneStr() const; 120 QString getTimeZoneStr() const;
119 /** 121 /**
120 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal 122 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal
121 values). 123 values).
122 */ 124 */
123 void setTimeZoneId( const QString & ); 125 void setTimeZoneId( const QString & );
124 /** 126 /**
@@ -257,110 +259,115 @@ public:
257 /** 259 /**
258 Setup relations for an incidence. 260 Setup relations for an incidence.
259 */ 261 */
260 virtual void setupRelations( Incidence * ); 262 virtual void setupRelations( Incidence * );
261 /** 263 /**
262 Remove all relations to an incidence 264 Remove all relations to an incidence
263 */ 265 */
264 virtual void removeRelations( Incidence * ); 266 virtual void removeRelations( Incidence * );
265 267
266 /** 268 /**
267 Set calendar filter, which filters events for the events() functions. 269 Set calendar filter, which filters events for the events() functions.
268 The Filter object is owned by the caller. 270 The Filter object is owned by the caller.
269 */ 271 */
270 void setFilter( CalFilter * ); 272 void setFilter( CalFilter * );
271 /** 273 /**
272 Return calendar filter. 274 Return calendar filter.
273 */ 275 */
274 CalFilter *filter(); 276 CalFilter *filter();
275 virtual QDateTime nextAlarm( int daysTo ) = 0; 277 virtual QDateTime nextAlarm( int daysTo ) = 0;
276 virtual QString nextSummary( ) const = 0; 278 virtual QString nextSummary( ) const = 0;
277 virtual void reInitAlarmSettings() = 0; 279 virtual void reInitAlarmSettings() = 0;
278 virtual QDateTime nextAlarmEventDateTime() const = 0; 280 virtual QDateTime nextAlarmEventDateTime() const = 0;
279 virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; 281 virtual void checkAlarmForIncidence( Incidence *, bool ) = 0;
280 /** 282 /**
281 Return all alarms, which ocur in the given time interval. 283 Return all alarms, which ocur in the given time interval.
282 */ 284 */
283 virtual Alarm::List alarms( const QDateTime &from, 285 virtual Alarm::List alarms( const QDateTime &from,
284 const QDateTime &to ) = 0; 286 const QDateTime &to ) = 0;
285 287
286 class Observer { 288 class Observer {
287 public: 289 public:
288 virtual void calendarModified( bool, Calendar * ) = 0; 290 virtual void calendarModified( bool, Calendar * ) = 0;
289 }; 291 };
290 292
291 void registerObserver( Observer * ); 293 void registerObserver( Observer * );
292 294
293 void setModified( bool ); 295 void setModified( bool );
294 296
295 /** 297 /**
296 Set product id returned by loadedProductId(). This function is only 298 Set product id returned by loadedProductId(). This function is only
297 useful for the calendar loading code. 299 useful for the calendar loading code.
298 */ 300 */
299 void setLoadedProductId( const QString & ); 301 void setLoadedProductId( const QString & );
300 /** 302 /**
301 Return product id taken from file that has been loaded. Returns 303 Return product id taken from file that has been loaded. Returns
302 QString::null, if no calendar has been loaded. 304 QString::null, if no calendar has been loaded.
303 */ 305 */
304 QString loadedProductId(); 306 QString loadedProductId();
305 void setDefaultCalendar( int );
306 int defaultCalendar(); 307 int defaultCalendar();
308 void setDontDeleteIncidencesOnClose ();
309 public slots:
310 void setDefaultCalendar( int );
307 virtual void setCalendarEnabled( int id, bool enable ) = 0; 311 virtual void setCalendarEnabled( int id, bool enable ) = 0;
308 virtual void setAlarmEnabled( int id, bool enable ) = 0; 312 virtual void setAlarmEnabled( int id, bool enable ) = 0;
313 virtual void setReadOnly( int id, bool enable ) = 0;
309 virtual void setDefaultCalendarEnabledOnly() = 0; 314 virtual void setDefaultCalendarEnabledOnly() = 0;
310 signals: 315 signals:
311 void calendarChanged(); 316 void calendarChanged();
312 void calendarSaved(); 317 void calendarSaved();
313 void calendarLoaded(); 318 void calendarLoaded();
314 void addAlarm(const QDateTime &qdt, const QString &noti ); 319 void addAlarm(const QDateTime &qdt, const QString &noti );
315 void removeAlarm(const QDateTime &qdt, const QString &noti ); 320 void removeAlarm(const QDateTime &qdt, const QString &noti );
316 321
317 protected: 322 protected:
318 /** 323 /**
319 Get unfiltered events, which occur on the given date. 324 Get unfiltered events, which occur on the given date.
320 */ 325 */
321 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; 326 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0;
322 /** 327 /**
323 Get unfiltered events, which occur on the given date. 328 Get unfiltered events, which occur on the given date.
324 */ 329 */
325 virtual QPtrList<Event> rawEventsForDate( const QDate &date, 330 virtual QPtrList<Event> rawEventsForDate( const QDate &date,
326 bool sorted = false ) = 0; 331 bool sorted = false ) = 0;
327 /** 332 /**
328 Get events in a range of dates. If inclusive is set to true, only events 333 Get events in a range of dates. If inclusive is set to true, only events
329 are returned, which are completely included in the range. 334 are returned, which are completely included in the range.
330 */ 335 */
331 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 336 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
332 bool inclusive = false ) = 0; 337 bool inclusive = false ) = 0;
333 338
334 Incidence *mNextAlarmIncidence; 339 Incidence *mNextAlarmIncidence;
335 Incidence *mUndoIncidence; 340 Incidence *mUndoIncidence;
336 int mDefaultCalendar; 341 int mDefaultCalendar;
342 bool mDeleteIncidencesOnClose;
337 343
338private: 344private:
339 void init(); 345 void init();
340 346
341 QString mOwner; // who the calendar belongs to 347 QString mOwner; // who the calendar belongs to
342 QString mOwnerEmail; // email address of the owner 348 QString mOwnerEmail; // email address of the owner
343 int mTimeZone; // timezone OFFSET from GMT (MINUTES) 349 int mTimeZone; // timezone OFFSET from GMT (MINUTES)
344 bool mLocalTime; // use local time, not UTC or a time zone 350 bool mLocalTime; // use local time, not UTC or a time zone
345 351
352
346 CalFilter *mFilter; 353 CalFilter *mFilter;
347 CalFilter *mDefaultFilter; 354 CalFilter *mDefaultFilter;
348 355
349 356
350 QString mTimeZoneId; 357 QString mTimeZoneId;
351 358
352 Observer *mObserver; 359 Observer *mObserver;
353 bool mNewObserver; 360 bool mNewObserver;
354 361
355 bool mModified; 362 bool mModified;
356 363
357 QString mLoadedProductId; 364 QString mLoadedProductId;
358 365
359 // This list is used to put together related todos 366 // This list is used to put together related todos
360 QDict<Incidence> mOrphans; 367 QDict<Incidence> mOrphans;
361 QDict<Incidence> mOrphanUids; 368 QDict<Incidence> mOrphanUids;
362}; 369};
363 370
364} 371}
365 372
366#endif 373#endif
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index c5500bf..e48122a 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -20,99 +20,137 @@
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26 26
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#include <klocale.h> 30#include <klocale.h>
31 31
32#include "vcaldrag.h" 32#include "vcaldrag.h"
33#include "vcalformat.h" 33#include "vcalformat.h"
34#include "icalformat.h" 34#include "icalformat.h"
35#include "exceptions.h" 35#include "exceptions.h"
36#include "incidence.h" 36#include "incidence.h"
37#include "journal.h" 37#include "journal.h"
38#include "filestorage.h" 38#include "filestorage.h"
39#include "calfilter.h" 39#include "calfilter.h"
40 40
41#include "calendarlocal.h" 41#include "calendarlocal.h"
42 42
43// #ifndef DESKTOP_VERSION 43// #ifndef DESKTOP_VERSION
44// #include <qtopia/alarmserver.h> 44// #include <qtopia/alarmserver.h>
45// #endif 45// #endif
46using namespace KCal; 46using namespace KCal;
47 47
48CalendarLocal::CalendarLocal() 48CalendarLocal::CalendarLocal()
49 : Calendar() 49 : Calendar()
50{ 50{
51 init(); 51 init();
52} 52}
53 53
54CalendarLocal::CalendarLocal(const QString &timeZoneId) 54CalendarLocal::CalendarLocal(const QString &timeZoneId)
55 : Calendar(timeZoneId) 55 : Calendar(timeZoneId)
56{ 56{
57 init(); 57 init();
58} 58}
59 59
60void CalendarLocal::init() 60void CalendarLocal::init()
61{ 61{
62 mNextAlarmIncidence = 0; 62 mNextAlarmIncidence = 0;
63} 63}
64 64
65 65
66CalendarLocal::~CalendarLocal() 66CalendarLocal::~CalendarLocal()
67{ 67{
68 close(); 68 if ( mDeleteIncidencesOnClose )
69 close();
70}
71bool CalendarLocal::addCalendarFile( QString name, int id )
72{
73 CalendarLocal calendar( timeZoneId() );
74 calendar.setDefaultCalendar( id );
75 if ( calendar.load( name ) ) {
76 addCalendar( &calendar );
77 return true;
78 }
79 return false;
80}
81void CalendarLocal::addCalendar( Calendar* cal )
82{
83 cal->setDontDeleteIncidencesOnClose();
84 {
85 QPtrList<Event> EventList = cal->rawEvents();
86 Event * ev = EventList.first();
87 while ( ev ) {
88 mEventList.append( ev );
89 ev = EventList.next();
90 }
91 }
92 {
93 QPtrList<Todo> TodoList = cal->rawTodos();
94 Todo * ev = TodoList.first();
95 while ( ev ) {
96 mTodoList.append( ev );
97 ev = TodoList.next();
98 }
99 }
100 {
101 QPtrList<Journal> JournalList = cal->journals();
102 Journal * ev = JournalList.first();
103 while ( ev ) {
104 mJournalList.append( ev );
105 ev = JournalList.next();
106 }
107 }
69} 108}
70
71bool CalendarLocal::load( const QString &fileName ) 109bool CalendarLocal::load( const QString &fileName )
72{ 110{
73 FileStorage storage( this, fileName ); 111 FileStorage storage( this, fileName );
74 return storage.load(); 112 return storage.load();
75} 113}
76 114
77bool CalendarLocal::save( const QString &fileName, CalFormat *format ) 115bool CalendarLocal::save( const QString &fileName, CalFormat *format )
78{ 116{
79 FileStorage storage( this, fileName, format ); 117 FileStorage storage( this, fileName, format );
80 return storage.save(); 118 return storage.save();
81} 119}
82 120
83void CalendarLocal::close() 121void CalendarLocal::close()
84{ 122{
85 123
86 Todo * i; 124 Todo * i;
87 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); 125 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false);
88 126
89 mEventList.setAutoDelete( true ); 127 mEventList.setAutoDelete( true );
90 mTodoList.setAutoDelete( true ); 128 mTodoList.setAutoDelete( true );
91 mJournalList.setAutoDelete( false ); 129 mJournalList.setAutoDelete( false );
92 130
93 mEventList.clear(); 131 mEventList.clear();
94 mTodoList.clear(); 132 mTodoList.clear();
95 mJournalList.clear(); 133 mJournalList.clear();
96 134
97 mEventList.setAutoDelete( false ); 135 mEventList.setAutoDelete( false );
98 mTodoList.setAutoDelete( false ); 136 mTodoList.setAutoDelete( false );
99 mJournalList.setAutoDelete( false ); 137 mJournalList.setAutoDelete( false );
100 138
101 setModified( false ); 139 setModified( false );
102} 140}
103 141
104bool CalendarLocal::addAnniversaryNoDup( Event *event ) 142bool CalendarLocal::addAnniversaryNoDup( Event *event )
105{ 143{
106 QString cat; 144 QString cat;
107 bool isBirthday = true; 145 bool isBirthday = true;
108 if( event->categoriesStr() == i18n( "Anniversary" ) ) { 146 if( event->categoriesStr() == i18n( "Anniversary" ) ) {
109 isBirthday = false; 147 isBirthday = false;
110 cat = i18n( "Anniversary" ); 148 cat = i18n( "Anniversary" );
111 } else if( event->categoriesStr() == i18n( "Birthday" ) ) { 149 } else if( event->categoriesStr() == i18n( "Birthday" ) ) {
112 isBirthday = true; 150 isBirthday = true;
113 cat = i18n( "Birthday" ); 151 cat = i18n( "Birthday" );
114 } else { 152 } else {
115 qDebug("addAnniversaryNoDup called without fitting category! "); 153 qDebug("addAnniversaryNoDup called without fitting category! ");
116 return false; 154 return false;
117 } 155 }
118 Event * eve; 156 Event * eve;
@@ -711,72 +749,86 @@ void CalendarLocal::deleteJournal( Journal *journal )
711 if ( mUndoIncidence ) delete mUndoIncidence; 749 if ( mUndoIncidence ) delete mUndoIncidence;
712 mUndoIncidence = journal->clone(); 750 mUndoIncidence = journal->clone();
713 mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); 751 mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
714 if ( mJournalList.removeRef(journal) ) { 752 if ( mJournalList.removeRef(journal) ) {
715 setModified( true ); 753 setModified( true );
716 } 754 }
717} 755}
718 756
719Journal *CalendarLocal::journal( const QDate &date ) 757Journal *CalendarLocal::journal( const QDate &date )
720{ 758{
721// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; 759// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
722 760
723 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 761 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
724 if ( it->calEnabled() && it->dtStart().date() == date ) 762 if ( it->calEnabled() && it->dtStart().date() == date )
725 return it; 763 return it;
726 764
727 return 0; 765 return 0;
728} 766}
729 767
730Journal *CalendarLocal::journal( const QString &uid ) 768Journal *CalendarLocal::journal( const QString &uid )
731{ 769{
732 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 770 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
733 if ( it->calEnabled() && it->uid() == uid ) 771 if ( it->calEnabled() && it->uid() == uid )
734 return it; 772 return it;
735 773
736 return 0; 774 return 0;
737} 775}
738 776
739QPtrList<Journal> CalendarLocal::journals() 777QPtrList<Journal> CalendarLocal::journals()
740{ 778{
741 QPtrList<Journal> el; 779 QPtrList<Journal> el;
742 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 780 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
743 if ( it->calEnabled() ) el.append( it ); 781 if ( it->calEnabled() ) el.append( it );
744 return el; 782 return el;
745} 783}
746 784
747void CalendarLocal::setCalendarEnabled( int id, bool enable ) 785void CalendarLocal::setCalendarEnabled( int id, bool enable )
748{ 786{
749 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 787 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
750 if ( it->calID() == id ) it->setCalEnabled( enable ); 788 if ( it->calID() == id ) it->setCalEnabled( enable );
751 789
752 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 790 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
753 if ( it->calID() == id ) it->setCalEnabled( enable ); 791 if ( it->calID() == id ) it->setCalEnabled( enable );
754 792
755 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 793 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
756 if ( it->calID() == id ) it->setCalEnabled( enable ); 794 if ( it->calID() == id ) it->setCalEnabled( enable );
757 795
758} 796}
797
798void CalendarLocal::setReadOnly( int id, bool enable )
799{
800 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
801 if ( it->calID() == id ) it->setReadOnly( enable );
802
803 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
804 if ( it->calID() == id ) it->setReadOnly( enable );
805
806 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
807 if ( it->calID() == id ) it->setReadOnly( enable );
808
809}
810
759void CalendarLocal::setAlarmEnabled( int id, bool enable ) 811void CalendarLocal::setAlarmEnabled( int id, bool enable )
760{ 812{
761 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 813 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
762 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 814 if ( it->calID() == id ) it->setAlarmEnabled( enable );
763 815
764 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 816 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
765 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 817 if ( it->calID() == id ) it->setAlarmEnabled( enable );
766 818
767 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 819 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
768 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 820 if ( it->calID() == id ) it->setAlarmEnabled( enable );
769 821
770} 822}
771void CalendarLocal::setDefaultCalendarEnabledOnly() 823void CalendarLocal::setDefaultCalendarEnabledOnly()
772{ 824{
773 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 825 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
774 it->setCalEnabled( it->calID() == mDefaultCalendar ); 826 it->setCalEnabled( it->calID() == mDefaultCalendar );
775 827
776 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 828 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
777 it->setCalEnabled( it->calID() == mDefaultCalendar); 829 it->setCalEnabled( it->calID() == mDefaultCalendar);
778 830
779 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 831 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
780 it->setCalEnabled( it->calID() == mDefaultCalendar); 832 it->setCalEnabled( it->calID() == mDefaultCalendar);
781 833
782} 834}
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index b25fcbe..65f6aa7 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -1,94 +1,95 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> 5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22#ifndef KCAL_CALENDARLOCAL_H 22#ifndef KCAL_CALENDARLOCAL_H
23#define KCAL_CALENDARLOCAL_H 23#define KCAL_CALENDARLOCAL_H
24 24
25#include "calendar.h" 25#include "calendar.h"
26 26
27namespace KCal { 27namespace KCal {
28 28
29class CalFormat; 29class CalFormat;
30 30
31/** 31/**
32 This class provides a calendar stored as a local file. 32 This class provides a calendar stored as a local file.
33*/ 33*/
34class CalendarLocal : public Calendar 34class CalendarLocal : public Calendar
35{ 35{
36 public: 36 public:
37 /** 37 /**
38 Constructs a new calendar, with variables initialized to sane values. 38 Constructs a new calendar, with variables initialized to sane values.
39 */ 39 */
40 CalendarLocal(); 40 CalendarLocal();
41 /** 41 /**
42 Constructs a new calendar, with variables initialized to sane values. 42 Constructs a new calendar, with variables initialized to sane values.
43 */ 43 */
44 CalendarLocal( const QString &timeZoneId ); 44 CalendarLocal( const QString &timeZoneId );
45 ~CalendarLocal(); 45 ~CalendarLocal();
46 46 void addCalendar( Calendar* );
47 bool addCalendarFile( QString name, int id );
47 /** 48 /**
48 Loads a calendar on disk in vCalendar or iCalendar format into the current 49 Loads a calendar on disk in vCalendar or iCalendar format into the current
49 calendar. Any information already present is lost. 50 calendar. Any information already present is lost.
50 @return true, if successfull, false on error. 51 @return true, if successfull, false on error.
51 @param fileName the name of the calendar on disk. 52 @param fileName the name of the calendar on disk.
52 */ 53 */
53 bool load( const QString &fileName ); 54 bool load( const QString &fileName );
54 /** 55 /**
55 Writes out the calendar to disk in the specified \a format. 56 Writes out the calendar to disk in the specified \a format.
56 CalendarLocal takes ownership of the CalFormat object. 57 CalendarLocal takes ownership of the CalFormat object.
57 @return true, if successfull, false on error. 58 @return true, if successfull, false on error.
58 @param fileName the name of the file 59 @param fileName the name of the file
59 */ 60 */
60 bool save( const QString &fileName, CalFormat *format = 0 ); 61 bool save( const QString &fileName, CalFormat *format = 0 );
61 62
62 /** 63 /**
63 Clears out the current calendar, freeing all used memory etc. etc. 64 Clears out the current calendar, freeing all used memory etc. etc.
64 */ 65 */
65 void close(); 66 void close();
66 67
67 void save() {} 68 void save() {}
68 69
69 /** 70 /**
70 Add Event to calendar. 71 Add Event to calendar.
71 */ 72 */
72 void removeSyncInfo( QString syncProfile); 73 void removeSyncInfo( QString syncProfile);
73 bool addAnniversaryNoDup( Event *event ); 74 bool addAnniversaryNoDup( Event *event );
74 bool addEventNoDup( Event *event ); 75 bool addEventNoDup( Event *event );
75 bool addEvent( Event *event ); 76 bool addEvent( Event *event );
76 /** 77 /**
77 Deletes an event from this calendar. 78 Deletes an event from this calendar.
78 */ 79 */
79 void deleteEvent( Event *event ); 80 void deleteEvent( Event *event );
80 81
81 /** 82 /**
82 Retrieves an event on the basis of the unique string ID. 83 Retrieves an event on the basis of the unique string ID.
83 */ 84 */
84 Event *event( const QString &uid ); 85 Event *event( const QString &uid );
85 /** 86 /**
86 Return unfiltered list of all events in calendar. 87 Return unfiltered list of all events in calendar.
87 */ 88 */
88 QPtrList<Event> rawEvents(); 89 QPtrList<Event> rawEvents();
89 QPtrList<Event> getExternLastSyncEvents(); 90 QPtrList<Event> getExternLastSyncEvents();
90 /** 91 /**
91 Add a todo to the todolist. 92 Add a todo to the todolist.
92 */ 93 */
93 bool addTodo( Todo *todo ); 94 bool addTodo( Todo *todo );
94 bool addTodoNoDup( Todo *todo ); 95 bool addTodoNoDup( Todo *todo );
@@ -134,88 +135,89 @@ class CalendarLocal : public Calendar
134 Journal *journal( const QString &uid ); 135 Journal *journal( const QString &uid );
135 /** 136 /**
136 Return list of all Journals stored in calendar. 137 Return list of all Journals stored in calendar.
137 */ 138 */
138 QPtrList<Journal> journals(); 139 QPtrList<Journal> journals();
139 140
140 /** 141 /**
141 Return all alarms, which ocur in the given time interval. 142 Return all alarms, which ocur in the given time interval.
142 */ 143 */
143 Alarm::List alarms( const QDateTime &from, const QDateTime &to ); 144 Alarm::List alarms( const QDateTime &from, const QDateTime &to );
144 145
145 /** 146 /**
146 Return all alarms, which ocur before given date. 147 Return all alarms, which ocur before given date.
147 */ 148 */
148 Alarm::List alarmsTo( const QDateTime &to ); 149 Alarm::List alarmsTo( const QDateTime &to );
149 150
150 QDateTime nextAlarm( int daysTo ) ; 151 QDateTime nextAlarm( int daysTo ) ;
151 QDateTime nextAlarmEventDateTime() const; 152 QDateTime nextAlarmEventDateTime() const;
152 void checkAlarmForIncidence( Incidence *, bool deleted ) ; 153 void checkAlarmForIncidence( Incidence *, bool deleted ) ;
153 void registerAlarm(); 154 void registerAlarm();
154 void deRegisterAlarm(); 155 void deRegisterAlarm();
155 QString getAlarmNotification(); 156 QString getAlarmNotification();
156 QString nextSummary() const ; 157 QString nextSummary() const ;
157 /** 158 /**
158 This method should be called whenever a Event is modified directly 159 This method should be called whenever a Event is modified directly
159 via it's pointer. It makes sure that the calendar is internally 160 via it's pointer. It makes sure that the calendar is internally
160 consistent. 161 consistent.
161 */ 162 */
162 void update( IncidenceBase *incidence ); 163 void update( IncidenceBase *incidence );
163 164
164 /** 165 /**
165 Builds and then returns a list of all events that match for the 166 Builds and then returns a list of all events that match for the
166 date specified. useful for dayView, etc. etc. 167 date specified. useful for dayView, etc. etc.
167 */ 168 */
168 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); 169 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false );
169 /** 170 /**
170 Get unfiltered events for date \a qdt. 171 Get unfiltered events for date \a qdt.
171 */ 172 */
172 QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); 173 QPtrList<Event> rawEventsForDate( const QDateTime &qdt );
173 /** 174 /**
174 Get unfiltered events in a range of dates. If inclusive is set to true, 175 Get unfiltered events in a range of dates. If inclusive is set to true,
175 only events are returned, which are completely included in the range. 176 only events are returned, which are completely included in the range.
176 */ 177 */
177 QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 178 QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
178 bool inclusive = false ); 179 bool inclusive = false );
179 Todo *todo( QString, QString ); 180 Todo *todo( QString, QString );
180 Event *event( QString, QString ); 181 Event *event( QString, QString );
181 182
182 183public slots:
183 void setCalendarEnabled( int id, bool enable ); 184 void setCalendarEnabled( int id, bool enable );
184 void setAlarmEnabled( int id, bool enable ); 185 void setAlarmEnabled( int id, bool enable );
186 void setReadOnly( int id, bool enable );
185 void setDefaultCalendarEnabledOnly(); 187 void setDefaultCalendarEnabledOnly();
186 188
187 protected: 189 protected:
188 190
189 // Event* mNextAlarmEvent; 191 // Event* mNextAlarmEvent;
190 QString mNextSummary; 192 QString mNextSummary;
191 QString mNextAlarmEventDateTimeString; 193 QString mNextAlarmEventDateTimeString;
192 QString mLastAlarmNotificationString; 194 QString mLastAlarmNotificationString;
193 QDateTime mNextAlarmEventDateTime; 195 QDateTime mNextAlarmEventDateTime;
194 QDateTime mNextAlarmDateTime; 196 QDateTime mNextAlarmDateTime;
195 void reInitAlarmSettings(); 197 void reInitAlarmSettings();
196 198
197 /** Notification function of IncidenceBase::Observer. */ 199 /** Notification function of IncidenceBase::Observer. */
198 void incidenceUpdated( IncidenceBase *i ) { update( i ); } 200 void incidenceUpdated( IncidenceBase *i ) { update( i ); }
199 201
200 /** inserts an event into its "proper place" in the calendar. */ 202 /** inserts an event into its "proper place" in the calendar. */
201 void insertEvent( Event *event ); 203 void insertEvent( Event *event );
202 204
203 /** Append alarms of incidence in interval to list of alarms. */ 205 /** Append alarms of incidence in interval to list of alarms. */
204 void appendAlarms( Alarm::List &alarms, Incidence *incidence, 206 void appendAlarms( Alarm::List &alarms, Incidence *incidence,
205 const QDateTime &from, const QDateTime &to ); 207 const QDateTime &from, const QDateTime &to );
206 208
207 /** Append alarms of recurring events in interval to list of alarms. */ 209 /** Append alarms of recurring events in interval to list of alarms. */
208 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, 210 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence,
209 const QDateTime &from, const QDateTime &to ); 211 const QDateTime &from, const QDateTime &to );
210 212
211 private: 213 private:
212 void init(); 214 void init();
213 215
214 QPtrList<Event> mEventList; 216 QPtrList<Event> mEventList;
215 QPtrList<Todo> mTodoList; 217 QPtrList<Todo> mTodoList;
216 QPtrList<Journal> mJournalList; 218 QPtrList<Journal> mJournalList;
217}; 219};
218 220
219} 221}
220 222
221#endif 223#endif