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
@@ -461,2 +461,6 @@ void CalendarView::init()
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 );
@@ -1836,2 +1840,42 @@ void CalendarView::setSyncEventsReadOnly()
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)
@@ -1966,3 +2010,20 @@ bool CalendarView::checkFileVersion(QString fn)
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 )
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index cdce072..0144ba4 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -46,2 +46,3 @@
46#include <ksyncmanager.h> 46#include <ksyncmanager.h>
47//#include <koprefs.h>
47 48
@@ -49,3 +50,3 @@ class QWidgetStack;
49class QSplitter; 50class QSplitter;
50 51class KopiCalendarFile;
51class CalPrinter; 52class CalPrinter;
@@ -224,2 +225,6 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
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 );
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index 2dd4567..29a4393 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -68,3 +68,3 @@ class KONewCalPrefs : public QDialog
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 }
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 95e1607..f05ada5 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -310,3 +310,3 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
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() );
@@ -1859,3 +1859,3 @@ void MainWindow::save()
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;
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index f4350d9..5092d1a 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -55,2 +55,3 @@ void Calendar::init()
55 mUndoIncidence = 0; 55 mUndoIncidence = 0;
56 mDeleteIncidencesOnClose = true;
56 mModified = false; 57 mModified = false;
@@ -114,2 +115,6 @@ Calendar::~Calendar()
114} 115}
116void Calendar::setDontDeleteIncidencesOnClose ()
117{
118 mDeleteIncidencesOnClose = false;
119}
115void Calendar::setDefaultCalendar( int d ) 120void Calendar::setDefaultCalendar( int d )
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 4c6760f..73f82bb 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -76,2 +76,4 @@ public:
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
@@ -304,6 +306,9 @@ public:
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;
@@ -336,2 +341,3 @@ public:
336 int mDefaultCalendar; 341 int mDefaultCalendar;
342 bool mDeleteIncidencesOnClose;
337 343
@@ -345,2 +351,3 @@ private:
345 351
352
346 CalFilter *mFilter; 353 CalFilter *mFilter;
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index c5500bf..e48122a 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -67,5 +67,43 @@ CalendarLocal::~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 )
@@ -758,2 +796,16 @@ void CalendarLocal::setCalendarEnabled( int id, bool enable )
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 )
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index b25fcbe..65f6aa7 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -45,3 +45,4 @@ class CalendarLocal : public Calendar
45 ~CalendarLocal(); 45 ~CalendarLocal();
46 46 void addCalendar( Calendar* );
47 bool addCalendarFile( QString name, int id );
47 /** 48 /**
@@ -181,5 +182,6 @@ class CalendarLocal : public Calendar
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();